| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/Migration.php.tar |
xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Admin/Notices/Migration.php 0000644 00000003044 15111424152 0030061 0 ustar 00 home <?php
namespace AIOSEO\Plugin\Common\Admin\Notices;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* V3 to V4 migration notice.
*
* @since 4.0.0
*/
class Migration {
/**
* Go through all the checks to see if we should show the notice.
*
* @since 4.0.0
*
* @return void
*/
public function maybeShowNotice() {
$transientPosts = aioseo()->core->cache->get( 'v3_migration_in_progress_posts' );
$transientTerms = aioseo()->core->cache->get( 'v3_migration_in_progress_terms' );
if ( ! $transientPosts && ! $transientTerms ) {
return;
}
$this->showNotice();
}
/**
* Register the notice so that it appears.
*
* @since 4.0.0
*
* @return void
*/
public function showNotice() {
// Translators: 1 - The plugin name ("AIOSEO).
$string1 = sprintf( __( '%1$s V3->V4 Migration In Progress', 'all-in-one-seo-pack' ), AIOSEO_PLUGIN_SHORT_NAME );
// Translators: 1 - The plugin name ("All in One SEO").
$string2 = sprintf( __( '%1$s is currently upgrading your database and migrating your SEO data in the background.', 'all-in-one-seo-pack' ), AIOSEO_PLUGIN_NAME );
$string3 = __( 'This notice will automatically disappear as soon as the migration has completed. Meanwhile, everything should continue to work as expected.', 'all-in-one-seo-pack' );
?>
<div class="notice notice-info aioseo-migration">
<p><strong><?php echo esc_html( $string1 ); ?></strong></p>
<p><?php echo esc_html( $string2 ); ?></p>
<p><?php echo esc_html( $string3 ); ?></p>
</div>
<style>
</style>
<?php
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Migration/Migration.php 0000644 00000014014 15113615420 0027436 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Migration;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Handles the migration from V3 to V4.
*/
class Migration {
/**
* The old V3 options.
*
* @since 4.0.0
*
* @var array
*/
public $oldOptions = [];
/**
* Meta class instance.
*
* @since 4.2.7
*
* @var Meta
*/
public $meta = null;
/**
* Helpers class instance.
*
* @since 4.2.7
*
* @var Helpers
*/
public $helpers = null;
/**
* Class constructor.
*
* @since 4.0.0
*/
public function __construct() {
$this->meta = new Meta();
$this->helpers = new Helpers();
// NOTE: This needs to go above the is_admin check in order for it to run at all.
add_action( 'aioseo_migrate_post_meta', [ $this->meta, 'migratePostMeta' ] );
if ( ! is_admin() ) {
return;
}
if ( wp_doing_ajax() || wp_doing_cron() ) {
return;
}
add_action( 'init', [ $this, 'init' ], 2000 );
}
/**
* Initializes the class.
*
* @since 4.0.0
*
* @return void
*/
public function init() {
// Since the version numbers may vary, we only want to compare the first 3 numbers.
$lastActiveVersion = aioseo()->internalOptions->internal->lastActiveVersion;
$lastActiveVersion = $lastActiveVersion ? explode( '-', $lastActiveVersion ) : null;
if ( version_compare( $lastActiveVersion[0], '4.0.0', '<' ) ) {
aioseo()->internalOptions->internal->migratedVersion = $lastActiveVersion[0];
add_action( 'wp_loaded', [ $this, 'doMigration' ] );
}
// Run our migration again for V4 users between v4.0.0 and v4.0.4.
if (
version_compare( $lastActiveVersion[0], '4.0.0', '>=' ) &&
version_compare( $lastActiveVersion[0], '4.0.4', '<' ) &&
get_option( 'aioseop_options' )
) {
add_action( 'wp_loaded', [ $this, 'redoMetaMigration' ] );
}
// Stop migration for new v4 users where it was incorrectly triggered.
if ( version_compare( $lastActiveVersion[0], '4.0.4', '=' ) && ! get_option( 'aioseop_options' ) ) {
aioseo()->core->cache->delete( 'v3_migration_in_progress_posts' );
aioseo()->core->cache->delete( 'v3_migration_in_progress_terms' );
try {
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_post_meta' );
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_term_meta' );
} catch ( \Exception $e ) {
// Do nothing.
}
}
}
/**
* Starts the migration.
*
* @since 4.0.0
*
* @return void
*/
public function doMigration() {
// If our tables do not exist, create them now.
if ( ! aioseo()->core->db->tableExists( 'aioseo_posts' ) ) {
aioseo()->updates->addInitialCustomTablesForV4();
}
$this->oldOptions = ( new OldOptions() )->oldOptions;
if (
! $this->oldOptions ||
! is_array( $this->oldOptions ) ||
! count( $this->oldOptions )
) {
return;
}
update_option( 'aioseo_options_v3', $this->oldOptions );
aioseo()->core->cache->update( 'v3_migration_in_progress_posts', time(), WEEK_IN_SECONDS );
$this->migrateSettings();
$this->meta->migrateMeta();
}
/**
* Reruns the post meta migration.
*
* This is meant for users on v4.0.0, v4.0.1 or v4.0.2 where the migration might have failed.
*
* @since 4.0.3
*
* @return void
*/
public function redoMetaMigration() {
aioseo()->core->cache->update( 'v3_migration_in_progress_posts', time(), WEEK_IN_SECONDS );
$this->meta->migrateMeta();
}
/**
* Migrates the plugin settings.
*
* @since 4.0.0
*
* @param array $oldOptions The old options. We pass it in directly via the Importer/Exporter.
* @return void
*/
public function migrateSettings( $oldOptions = [] ) {
if ( empty( $this->oldOptions ) && ! empty( $oldOptions ) ) {
$this->oldOptions = ( new OldOptions( $oldOptions ) )->oldOptions;
if (
! $this->oldOptions ||
! is_array( $this->oldOptions ) ||
! count( $this->oldOptions )
) {
return;
}
}
aioseo()->core->cache->update( 'v3_migration_in_progress_settings', time() );
new GeneralSettings();
if ( ! isset( $this->oldOptions['modules']['aiosp_feature_manager_options'] ) ) {
new Sitemap();
aioseo()->core->cache->delete( 'v3_migration_in_progress_settings' );
return;
}
$this->migrateFeatureManager();
if ( isset( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_opengraph'] ) ) {
new SocialMeta();
}
if ( isset( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] ) ) {
new Sitemap();
}
if ( isset( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_robots'] ) ) {
new RobotsTxt();
}
if ( aioseo()->helpers->isWpmlActive() ) {
new Wpml();
}
aioseo()->core->cache->delete( 'v3_migration_in_progress_settings' );
}
/**
* Migrates the Feature Manager settings.
*
* @since 4.0.0
*
* @return void
*/
protected function migrateFeatureManager() {
if ( empty( $this->oldOptions['modules']['aiosp_feature_manager_options'] ) ) {
return;
}
if ( empty( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_opengraph'] ) ) {
aioseo()->options->social->facebook->general->enable = false;
aioseo()->options->social->twitter->general->enable = false;
}
if ( empty( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] ) ) {
aioseo()->options->sitemap->general->enable = false;
aioseo()->options->sitemap->rss->enable = false;
}
if ( ! empty( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_robots'] ) ) {
aioseo()->options->tools->robots->enable = true;
}
}
/**
* Checks whether the V3 migration is running.
*
* @since 4.1.8
*
* @return bool Whether the V3 migration is running.
*/
public function isMigrationRunning() {
return aioseo()->core->cache->get( 'v3_migration_in_progress_settings' ) || aioseo()->core->cache->get( 'v3_migration_in_progress_posts' );
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Admin/Notices/Migration.php 0000644 00000003044 15113766525 0026743 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Admin\Notices;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* V3 to V4 migration notice.
*
* @since 4.0.0
*/
class Migration {
/**
* Go through all the checks to see if we should show the notice.
*
* @since 4.0.0
*
* @return void
*/
public function maybeShowNotice() {
$transientPosts = aioseo()->core->cache->get( 'v3_migration_in_progress_posts' );
$transientTerms = aioseo()->core->cache->get( 'v3_migration_in_progress_terms' );
if ( ! $transientPosts && ! $transientTerms ) {
return;
}
$this->showNotice();
}
/**
* Register the notice so that it appears.
*
* @since 4.0.0
*
* @return void
*/
public function showNotice() {
// Translators: 1 - The plugin name ("AIOSEO).
$string1 = sprintf( __( '%1$s V3->V4 Migration In Progress', 'all-in-one-seo-pack' ), AIOSEO_PLUGIN_SHORT_NAME );
// Translators: 1 - The plugin name ("All in One SEO").
$string2 = sprintf( __( '%1$s is currently upgrading your database and migrating your SEO data in the background.', 'all-in-one-seo-pack' ), AIOSEO_PLUGIN_NAME );
$string3 = __( 'This notice will automatically disappear as soon as the migration has completed. Meanwhile, everything should continue to work as expected.', 'all-in-one-seo-pack' );
?>
<div class="notice notice-info aioseo-migration">
<p><strong><?php echo esc_html( $string1 ); ?></strong></p>
<p><?php echo esc_html( $string2 ); ?></p>
<p><?php echo esc_html( $string3 ); ?></p>
</div>
<style>
</style>
<?php
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Migration/Migration.php 0000644 00000014014 15114307316 0026225 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Migration;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
/**
* Handles the migration from V3 to V4.
*/
class Migration {
/**
* The old V3 options.
*
* @since 4.0.0
*
* @var array
*/
public $oldOptions = [];
/**
* Meta class instance.
*
* @since 4.2.7
*
* @var Meta
*/
public $meta = null;
/**
* Helpers class instance.
*
* @since 4.2.7
*
* @var Helpers
*/
public $helpers = null;
/**
* Class constructor.
*
* @since 4.0.0
*/
public function __construct() {
$this->meta = new Meta();
$this->helpers = new Helpers();
// NOTE: This needs to go above the is_admin check in order for it to run at all.
add_action( 'aioseo_migrate_post_meta', [ $this->meta, 'migratePostMeta' ] );
if ( ! is_admin() ) {
return;
}
if ( wp_doing_ajax() || wp_doing_cron() ) {
return;
}
add_action( 'init', [ $this, 'init' ], 2000 );
}
/**
* Initializes the class.
*
* @since 4.0.0
*
* @return void
*/
public function init() {
// Since the version numbers may vary, we only want to compare the first 3 numbers.
$lastActiveVersion = aioseo()->internalOptions->internal->lastActiveVersion;
$lastActiveVersion = $lastActiveVersion ? explode( '-', $lastActiveVersion ) : null;
if ( version_compare( $lastActiveVersion[0], '4.0.0', '<' ) ) {
aioseo()->internalOptions->internal->migratedVersion = $lastActiveVersion[0];
add_action( 'wp_loaded', [ $this, 'doMigration' ] );
}
// Run our migration again for V4 users between v4.0.0 and v4.0.4.
if (
version_compare( $lastActiveVersion[0], '4.0.0', '>=' ) &&
version_compare( $lastActiveVersion[0], '4.0.4', '<' ) &&
get_option( 'aioseop_options' )
) {
add_action( 'wp_loaded', [ $this, 'redoMetaMigration' ] );
}
// Stop migration for new v4 users where it was incorrectly triggered.
if ( version_compare( $lastActiveVersion[0], '4.0.4', '=' ) && ! get_option( 'aioseop_options' ) ) {
aioseo()->core->cache->delete( 'v3_migration_in_progress_posts' );
aioseo()->core->cache->delete( 'v3_migration_in_progress_terms' );
try {
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_post_meta' );
aioseo()->actionScheduler->unschedule( 'aioseo_migrate_term_meta' );
} catch ( \Exception $e ) {
// Do nothing.
}
}
}
/**
* Starts the migration.
*
* @since 4.0.0
*
* @return void
*/
public function doMigration() {
// If our tables do not exist, create them now.
if ( ! aioseo()->core->db->tableExists( 'aioseo_posts' ) ) {
aioseo()->updates->addInitialCustomTablesForV4();
}
$this->oldOptions = ( new OldOptions() )->oldOptions;
if (
! $this->oldOptions ||
! is_array( $this->oldOptions ) ||
! count( $this->oldOptions )
) {
return;
}
update_option( 'aioseo_options_v3', $this->oldOptions );
aioseo()->core->cache->update( 'v3_migration_in_progress_posts', time(), WEEK_IN_SECONDS );
$this->migrateSettings();
$this->meta->migrateMeta();
}
/**
* Reruns the post meta migration.
*
* This is meant for users on v4.0.0, v4.0.1 or v4.0.2 where the migration might have failed.
*
* @since 4.0.3
*
* @return void
*/
public function redoMetaMigration() {
aioseo()->core->cache->update( 'v3_migration_in_progress_posts', time(), WEEK_IN_SECONDS );
$this->meta->migrateMeta();
}
/**
* Migrates the plugin settings.
*
* @since 4.0.0
*
* @param array $oldOptions The old options. We pass it in directly via the Importer/Exporter.
* @return void
*/
public function migrateSettings( $oldOptions = [] ) {
if ( empty( $this->oldOptions ) && ! empty( $oldOptions ) ) {
$this->oldOptions = ( new OldOptions( $oldOptions ) )->oldOptions;
if (
! $this->oldOptions ||
! is_array( $this->oldOptions ) ||
! count( $this->oldOptions )
) {
return;
}
}
aioseo()->core->cache->update( 'v3_migration_in_progress_settings', time() );
new GeneralSettings();
if ( ! isset( $this->oldOptions['modules']['aiosp_feature_manager_options'] ) ) {
new Sitemap();
aioseo()->core->cache->delete( 'v3_migration_in_progress_settings' );
return;
}
$this->migrateFeatureManager();
if ( isset( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_opengraph'] ) ) {
new SocialMeta();
}
if ( isset( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] ) ) {
new Sitemap();
}
if ( isset( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_robots'] ) ) {
new RobotsTxt();
}
if ( aioseo()->helpers->isWpmlActive() ) {
new Wpml();
}
aioseo()->core->cache->delete( 'v3_migration_in_progress_settings' );
}
/**
* Migrates the Feature Manager settings.
*
* @since 4.0.0
*
* @return void
*/
protected function migrateFeatureManager() {
if ( empty( $this->oldOptions['modules']['aiosp_feature_manager_options'] ) ) {
return;
}
if ( empty( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_opengraph'] ) ) {
aioseo()->options->social->facebook->general->enable = false;
aioseo()->options->social->twitter->general->enable = false;
}
if ( empty( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] ) ) {
aioseo()->options->sitemap->general->enable = false;
aioseo()->options->sitemap->rss->enable = false;
}
if ( ! empty( $this->oldOptions['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_robots'] ) ) {
aioseo()->options->tools->robots->enable = true;
}
}
/**
* Checks whether the V3 migration is running.
*
* @since 4.1.8
*
* @return bool Whether the V3 migration is running.
*/
public function isMigrationRunning() {
return aioseo()->core->cache->get( 'v3_migration_in_progress_settings' ) || aioseo()->core->cache->get( 'v3_migration_in_progress_posts' );
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Api/Migration.php 0000644 00000003575 15114440054 0026230 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Api;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Migration as CommonMigration;
use AIOSEO\Plugin\Common\Models;
/**
* Route class for the API.
*
* @since 4.0.6
*/
class Migration {
/**
* Resets blank title formats and retriggers the post/term meta migration.
*
* @since 4.0.6
*
* @return \WP_REST_Response The response.
*/
public static function fixBlankFormats() {
$oldOptions = ( new CommonMigration\OldOptions() )->oldOptions;
if ( ! $oldOptions ) {
return new \WP_REST_Response( [
'success' => true,
'message' => 'Could not load v3 options.'
], 400 );
}
$postTypes = aioseo()->helpers->getPublicPostTypes( true );
$taxonomies = aioseo()->helpers->getPublicTaxonomies( true );
foreach ( $oldOptions as $k => $v ) {
if ( ! preg_match( '/^aiosp_([a-zA-Z]*)_title_format$/', (string) $k, $match ) || ! empty( $v ) ) {
continue;
}
$objectName = $match[1];
if ( in_array( $objectName, $postTypes, true ) && aioseo()->dynamicOptions->searchAppearance->postTypes->has( $objectName ) ) {
aioseo()->dynamicOptions->searchAppearance->postTypes->$objectName->title = '#post_title #separator_sa #site_title';
continue;
}
if ( in_array( $objectName, $taxonomies, true ) && aioseo()->dynamicOptions->searchAppearance->taxonomies->has( $objectName ) ) {
aioseo()->dynamicOptions->searchAppearance->taxonomies->$objectName->title = '#taxonomy_title #separator_sa #site_title';
}
}
aioseo()->migration->redoMetaMigration();
Models\Notification::deleteNotificationByName( 'v3-migration-title-formats-blank' );
return new \WP_REST_Response( [
'success' => true,
'message' => 'Title formats have been reset; post/term migration has been scheduled.',
'notifications' => Models\Notification::getNotifications()
], 200 );
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Api/Migration.php 0000644 00000003575 15114515125 0025016 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Api;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Migration as CommonMigration;
use AIOSEO\Plugin\Common\Models;
/**
* Route class for the API.
*
* @since 4.0.6
*/
class Migration {
/**
* Resets blank title formats and retriggers the post/term meta migration.
*
* @since 4.0.6
*
* @return \WP_REST_Response The response.
*/
public static function fixBlankFormats() {
$oldOptions = ( new CommonMigration\OldOptions() )->oldOptions;
if ( ! $oldOptions ) {
return new \WP_REST_Response( [
'success' => true,
'message' => 'Could not load v3 options.'
], 400 );
}
$postTypes = aioseo()->helpers->getPublicPostTypes( true );
$taxonomies = aioseo()->helpers->getPublicTaxonomies( true );
foreach ( $oldOptions as $k => $v ) {
if ( ! preg_match( '/^aiosp_([a-zA-Z]*)_title_format$/', (string) $k, $match ) || ! empty( $v ) ) {
continue;
}
$objectName = $match[1];
if ( in_array( $objectName, $postTypes, true ) && aioseo()->dynamicOptions->searchAppearance->postTypes->has( $objectName ) ) {
aioseo()->dynamicOptions->searchAppearance->postTypes->$objectName->title = '#post_title #separator_sa #site_title';
continue;
}
if ( in_array( $objectName, $taxonomies, true ) && aioseo()->dynamicOptions->searchAppearance->taxonomies->has( $objectName ) ) {
aioseo()->dynamicOptions->searchAppearance->taxonomies->$objectName->title = '#taxonomy_title #separator_sa #site_title';
}
}
aioseo()->migration->redoMetaMigration();
Models\Notification::deleteNotificationByName( 'v3-migration-title-formats-blank' );
return new \WP_REST_Response( [
'success' => true,
'message' => 'Title formats have been reset; post/term migration has been scheduled.',
'notifications' => Models\Notification::getNotifications()
], 200 );
}
}