Merged in feature/314-dev-dev01 (pull request #24)
auto-patch 314-dev-dev01-2024-01-25T04_09_02 * auto-patch 314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
@@ -21,6 +21,8 @@ class WPSEO_Import_Plugins_Detector {
|
||||
|
||||
/**
|
||||
* Detects whether we need to import anything.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function detect() {
|
||||
foreach ( WPSEO_Plugin_Importers::get() as $importer_class ) {
|
||||
|
||||
@@ -17,7 +17,7 @@ class WPSEO_Import_Settings {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const NONCE_ACTION = 'wpseo-import-settings';
|
||||
public const NONCE_ACTION = 'wpseo-import-settings';
|
||||
|
||||
/**
|
||||
* Holds the import status instance.
|
||||
@@ -91,6 +91,8 @@ class WPSEO_Import_Settings {
|
||||
* @param string $name Name string.
|
||||
* @param array $option_group Option group data.
|
||||
* @param array $options Options data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function parse_option_group( $name, $option_group, $options ) {
|
||||
// Make sure that the imported options are cleaned/converted on import.
|
||||
@@ -104,6 +106,8 @@ class WPSEO_Import_Settings {
|
||||
* Imports the options if found.
|
||||
*
|
||||
* @param array $options The options parsed from the provided settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function import_options( $options ) {
|
||||
if ( isset( $options['wpseo']['version'] ) && $options['wpseo']['version'] !== '' ) {
|
||||
|
||||
@@ -240,7 +240,7 @@ abstract class WPSEO_Plugin_Importer {
|
||||
*/
|
||||
protected function meta_keys_clone( $clone_keys ) {
|
||||
foreach ( $clone_keys as $clone_key ) {
|
||||
$result = $this->meta_key_clone( $clone_key['old_key'], $clone_key['new_key'], isset( $clone_key['convert'] ) ? $clone_key['convert'] : [] );
|
||||
$result = $this->meta_key_clone( $clone_key['old_key'], $clone_key['new_key'], ( $clone_key['convert'] ?? [] ) );
|
||||
if ( ! $result ) {
|
||||
return false;
|
||||
}
|
||||
@@ -250,6 +250,8 @@ abstract class WPSEO_Plugin_Importer {
|
||||
|
||||
/**
|
||||
* Sets the import status to false and returns a message about why it failed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function set_missing_db_rights_status() {
|
||||
$this->status->set_status( false );
|
||||
@@ -279,6 +281,8 @@ abstract class WPSEO_Plugin_Importer {
|
||||
* @param string $new_key The key to save.
|
||||
* @param mixed $value The value to set the key to.
|
||||
* @param int $post_id The Post to save the meta for.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function maybe_save_post_meta( $new_key, $value, $post_id ) {
|
||||
// Big. Fat. Sigh. Mostly used for _yst_is_cornerstone, but might be useful for other hidden meta's.
|
||||
|
||||
@@ -107,7 +107,7 @@ class WPSEO_Import_AIOSEO_V4 extends WPSEO_Plugin_Importer {
|
||||
// Now, we'll also loop through the replace_vars array, which holds the mappings between the AiOSEO variables and the Yoast variables.
|
||||
// We'll replace all the AiOSEO variables in the temporary table with their Yoast equivalents.
|
||||
foreach ( $this->replace_vars as $aioseo_variable => $yoast_variable ) {
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
|
||||
@@ -146,7 +146,7 @@ class WPSEO_Import_AIOSEO_V4 extends WPSEO_Plugin_Importer {
|
||||
|
||||
foreach ( $meta_values as $meta_value ) {
|
||||
// Find all custom field replace vars, store them in `$matches`.
|
||||
\preg_match_all(
|
||||
preg_match_all(
|
||||
"/#$aioseo_prefix-([\w-]+)/",
|
||||
$meta_value,
|
||||
$matches
|
||||
@@ -159,11 +159,11 @@ class WPSEO_Import_AIOSEO_V4 extends WPSEO_Plugin_Importer {
|
||||
$custom_fields_or_taxonomies = $matches[1];
|
||||
|
||||
foreach ( $custom_fields_or_taxonomies as $custom_field_or_taxonomy ) {
|
||||
$unique_custom_fields_or_taxonomies[ \trim( $custom_field_or_taxonomy ) ] = 1;
|
||||
$unique_custom_fields_or_taxonomies[ trim( $custom_field_or_taxonomy ) ] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return \array_keys( $unique_custom_fields_or_taxonomies );
|
||||
return array_keys( $unique_custom_fields_or_taxonomies );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,13 +176,15 @@ class WPSEO_Import_AIOSEO_V4 extends WPSEO_Plugin_Importer {
|
||||
* @param string $aioseo_prefix The AiOSEO prefix to use
|
||||
* (e.g. `custom-field` for custom fields or `tax_name` for custom taxonomies).
|
||||
* @param string $yoast_prefix The Yoast prefix to use (e.g. `cf` for custom fields).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function replace_custom_field_or_taxonomy_replace_vars( $unique_custom_fields_or_taxonomies, $wpdb, $aioseo_prefix, $yoast_prefix ) {
|
||||
foreach ( $unique_custom_fields_or_taxonomies as $unique_custom_field_or_taxonomy ) {
|
||||
$aioseo_variable = "#{$aioseo_prefix}-{$unique_custom_field_or_taxonomy}";
|
||||
$yoast_variable = "%%{$yoast_prefix}_{$unique_custom_field_or_taxonomy}%%";
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
|
||||
@@ -193,7 +195,7 @@ class WPSEO_Import_AIOSEO_V4 extends WPSEO_Plugin_Importer {
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
|
||||
/**
|
||||
* Retrieve all the meta values from the temporary meta table that contain
|
||||
@@ -214,7 +216,7 @@ class WPSEO_Import_AIOSEO_V4 extends WPSEO_Plugin_Importer {
|
||||
);
|
||||
}
|
||||
|
||||
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
|
||||
/**
|
||||
* Detects whether there is AIOSEO data to import by looking whether the AIOSEO data have been cleaned up.
|
||||
|
||||
@@ -96,6 +96,8 @@ class WPSEO_Import_AIOSEO extends WPSEO_Plugin_Importer {
|
||||
* Imports the OpenGraph and Twitter settings for a single post.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function import_post_opengraph( $post_id ) {
|
||||
$meta = get_post_meta( $post_id, '_aioseop_opengraph_settings', true );
|
||||
|
||||
@@ -109,6 +109,8 @@ class WPSEO_Import_RankMath extends WPSEO_Plugin_Importer {
|
||||
|
||||
/**
|
||||
* RankMath stores robots meta quite differently, so we have to parse it out.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function import_meta_robots() {
|
||||
global $wpdb;
|
||||
@@ -132,6 +134,8 @@ class WPSEO_Import_RankMath extends WPSEO_Plugin_Importer {
|
||||
|
||||
/**
|
||||
* Imports some of the RankMath settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function import_settings() {
|
||||
$settings = [
|
||||
|
||||
@@ -193,7 +193,12 @@ class WPSEO_Import_WPSEO extends WPSEO_Plugin_Importer {
|
||||
* @return void
|
||||
*/
|
||||
private function import_taxonomy_metas() {
|
||||
$terms = get_terms( get_taxonomies(), [ 'hide_empty' => false ] );
|
||||
$terms = get_terms(
|
||||
[
|
||||
'taxonomy' => get_taxonomies(),
|
||||
'hide_empty' => false,
|
||||
]
|
||||
);
|
||||
$tax_meta = get_option( 'wpseo_taxonomy_meta' );
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
@@ -291,7 +296,13 @@ class WPSEO_Import_WPSEO extends WPSEO_Plugin_Importer {
|
||||
* @return void
|
||||
*/
|
||||
private function cleanup_term_meta() {
|
||||
$terms = get_terms( get_taxonomies(), [ 'hide_empty' => false ] );
|
||||
$terms = get_terms(
|
||||
[
|
||||
'taxonomy' => get_taxonomies(),
|
||||
'hide_empty' => false,
|
||||
]
|
||||
);
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$this->delete_taxonomy_metas( $term->taxonomy, $term->term_id );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user