diff --git a/activitypub.php b/activitypub.php index 380b438..bf718f2 100644 --- a/activitypub.php +++ b/activitypub.php @@ -33,12 +33,15 @@ require_once __DIR__ . '/includes/functions.php'; \defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "[ap_title]\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" ); \defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) || \define( 'ACTIVITYPUB_AUTHORIZED_FETCH', false ); \defined( 'ACTIVITYPUB_DISABLE_REWRITES' ) || \define( 'ACTIVITYPUB_DISABLE_REWRITES', false ); +\defined( 'ACTIVITYPUB_DEFAULT_TRANSFORMER' ) || \define( 'ACTIVITYPUB_DEFAULT_TRANSFORMER', 'activitypub/defualt' ); + \define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); \define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); \define( 'ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) ); \define( 'ACTIVITYPUB_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); + /** * Initialize REST routes. */ diff --git a/includes/class-migration.php b/includes/class-migration.php index cd13f8d..74ecfbe 100644 --- a/includes/class-migration.php +++ b/includes/class-migration.php @@ -4,6 +4,7 @@ namespace Activitypub; use Activitypub\Activitypub; use Activitypub\Model\Blog_User; use Activitypub\Collection\Followers; +use Activitypub\Admin; /** * ActivityPub Migration Class @@ -114,12 +115,30 @@ class Migration { if ( version_compare( $version_from_db, '1.0.0', '<' ) ) { self::migrate_from_0_17(); } + if ( version_compare( $version_from_db, 'version_number_transformer_management_placeholder', '<' ) ) { + self::migrate_from_version_number_transformer_management_placeholder(); + } update_option( 'activitypub_db_version', self::get_target_version() ); self::unlock(); } + /** + * Updates the supported post type settings to the mapped transformer setting. + * TODO: Test this + * @return void + */ + private static function migrate_from_version_number_transformer_management_placeholder() { + $supported_post_types = \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) ); + Admin::register_settings(); + $transformer_mapping = array(); + foreach ( $supported_post_types as $supported_post_type ) { + $transformer_mapping[ $supported_post_type ] = ACTIVITYPUB_DEFAULT_TRANSFORMER; + } + update_option( 'activitypub_transformer_mapping', $transformer_mapping ); + } + /** * Updates the DB-schema of the followers-list * diff --git a/includes/class-transformers-manager.php b/includes/class-transformers-manager.php index dc425e5..a546a4a 100644 --- a/includes/class-transformers-manager.php +++ b/includes/class-transformers-manager.php @@ -28,8 +28,8 @@ if ( ! defined( 'ABSPATH' ) ) { class Transformers_Manager { const DEFAULT_TRANSFORMER_MAPPING = array( - 'post' => 'activitypub/default', - 'page' => 'activitypub/default' + 'post' => ACTIVITYPUB_DEFAULT_TRANSFORMER, + 'page' => ACTIVITYPUB_DEFAULT_TRANSFORMER, ); /**