add: untestet draft of the migration for the activated post type setting
This commit is contained in:
parent
0ccb6c91eb
commit
246600b84e
3 changed files with 24 additions and 2 deletions
|
@ -33,12 +33,15 @@ require_once __DIR__ . '/includes/functions.php';
|
||||||
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<strong>[ap_title]</strong>\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" );
|
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<strong>[ap_title]</strong>\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" );
|
||||||
\defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) || \define( 'ACTIVITYPUB_AUTHORIZED_FETCH', false );
|
\defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) || \define( 'ACTIVITYPUB_AUTHORIZED_FETCH', false );
|
||||||
\defined( 'ACTIVITYPUB_DISABLE_REWRITES' ) || \define( 'ACTIVITYPUB_DISABLE_REWRITES', 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_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
\define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
\define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||||
\define( 'ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
|
\define( 'ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
|
||||||
\define( 'ACTIVITYPUB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
\define( 'ACTIVITYPUB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize REST routes.
|
* Initialize REST routes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Activitypub;
|
||||||
use Activitypub\Activitypub;
|
use Activitypub\Activitypub;
|
||||||
use Activitypub\Model\Blog_User;
|
use Activitypub\Model\Blog_User;
|
||||||
use Activitypub\Collection\Followers;
|
use Activitypub\Collection\Followers;
|
||||||
|
use Activitypub\Admin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Migration Class
|
* ActivityPub Migration Class
|
||||||
|
@ -114,12 +115,30 @@ class Migration {
|
||||||
if ( version_compare( $version_from_db, '1.0.0', '<' ) ) {
|
if ( version_compare( $version_from_db, '1.0.0', '<' ) ) {
|
||||||
self::migrate_from_0_17();
|
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() );
|
update_option( 'activitypub_db_version', self::get_target_version() );
|
||||||
|
|
||||||
self::unlock();
|
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
|
* Updates the DB-schema of the followers-list
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,8 +28,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
|
||||||
class Transformers_Manager {
|
class Transformers_Manager {
|
||||||
const DEFAULT_TRANSFORMER_MAPPING = array(
|
const DEFAULT_TRANSFORMER_MAPPING = array(
|
||||||
'post' => 'activitypub/default',
|
'post' => ACTIVITYPUB_DEFAULT_TRANSFORMER,
|
||||||
'page' => 'activitypub/default'
|
'page' => ACTIVITYPUB_DEFAULT_TRANSFORMER,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue