diff --git a/includes/base/class-transformer-base.php b/includes/base/class-transformer-base.php
index 890462e..044ba27 100644
--- a/includes/base/class-transformer-base.php
+++ b/includes/base/class-transformer-base.php
@@ -20,9 +20,31 @@ abstract class Transformer_Base {
* @return string[] An array containing all the supported post types.
*/
public function get_supported_post_types() {
- return \get_post_types( ['public' => true], 'names' );
+ return \get_post_types( array( 'public' => true ), 'names' );
}
+ /**
+ * Get the name of the plugin that registered the transformer.
+ *
+ * @see Forked from the WordPress elementor plugin.
+ *
+ * @since version_number_transformer_management_placeholder
+ * @return string Plugin name
+ */
+ private function get_plugin_name_from_transformer_instance( $transformer ) {
+ $class_reflection = new \ReflectionClass( $transformer );
+
+ $plugin_basename = plugin_basename( $class_reflection->getFileName() );
+
+ $plugin_directory = strtok( $plugin_basename, '/' );
+
+ $plugins_data = get_plugins( '/' . $plugin_directory );
+ $plugin_data = array_shift( $plugins_data );
+
+ return $plugin_data['Name'] ?? esc_html__( 'Unknown', 'activitypub' );
+ }
+
+
/**
* Get the name used for registering the transformer with the ActivityPub plugin.
*
diff --git a/includes/class-admin.php b/includes/class-admin.php
index cdf0a8c..dbafea2 100644
--- a/includes/class-admin.php
+++ b/includes/class-admin.php
@@ -169,6 +169,50 @@ class Admin {
'default' => array( 'post', 'pages' ),
)
);
+
+ /**
+ * Flexible activation of post_types together with mapping ActivityPub transformers.
+ *
+ * If a post-type is not mapped to any ActivtiyPub transformer it means it is not activated
+ * for ActivityPub federation.
+ *
+ * @since version_number_transformer_management_placeholder
+ */
+ register_setting(
+ 'activitypub',
+ 'activitypub_transformer_mapping',
+ array(
+ 'type' => 'array',
+ 'default' => array(
+ 'post' => 'note',
+ ),
+ 'show_in_rest' => array(
+ 'schema' => array(
+ 'type' => 'array',
+ 'items' => array(
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ 'sanitize_callback' => function ( $value ) {
+ // Check if $value is an array
+ if (!is_array($value)) {
+ return array();
+ }
+ $value_keys = array_keys( $value );
+
+ $all_public_post_types = \get_post_types( array( 'public' => true ), 'names' );
+
+ // Unset the keys that are missing in $keysToCheck
+ foreach ( array_diff( $value_keys, $all_public_post_types ) as $missing_key ) {
+ unset($value[$missing_key]);
+ }
+ // var_dump($value);
+ return $value;
+
+ }
+ )
+ );
\register_setting(
'activitypub',
'activitypub_blog_user_identifier',
diff --git a/includes/managers/class-transformers-manager.php b/includes/managers/class-transformers-manager.php
index 983e95a..941b09f 100644
--- a/includes/managers/class-transformers-manager.php
+++ b/includes/managers/class-transformers-manager.php
@@ -169,5 +169,30 @@ class Transformers_Manager {
}
+ /**
+ * Get available ActivityPub transformers.
+ *
+ * Retrieve the registered widget types list.
+ *
+ * @since 1.0.0
+ * @access public
+ *
+ * @param string $widget_name Optional. Widget name. Default is null.
+ *
+ * @return Widget_Base|Widget_Base[]|null Registered widget types.
+ */
+ public function get_widget_types( $widget_name = null ) {
+ if ( is_null( $this->_widget_types ) ) {
+ $this->init_widgets();
+ }
+
+ if ( null !== $widget_name ) {
+ return isset( $this->_widget_types[ $widget_name ] ) ? $this->_widget_types[ $widget_name ] : null;
+ }
+
+ return $this->_widget_types;
+ }
+
+
}
diff --git a/includes/transformer/class-post.php b/includes/transformer/class-post.php
index 2117ce7..684d59c 100644
--- a/includes/transformer/class-post.php
+++ b/includes/transformer/class-post.php
@@ -14,10 +14,10 @@ use function Activitypub\site_supports_blocks;
/**
* WordPress Post Transformer
- *
* The Post Transformer is responsible for transforming a WP_Post object into different othe
* Object-Types.
*
+ *
* Currently supported are:
*
* - Activitypub\Activity\Base_Object
diff --git a/templates/settings.php b/templates/settings.php
index 5ce90e1..95a3297 100644
--- a/templates/settings.php
+++ b/templates/settings.php
@@ -236,6 +236,127 @@
+
+
+
+