← All changes
|
includes/admin/importers/class-import-controller.php
+47
-2
2.10.0
→
2.13.0
View file →
| @@ -41,9 +41,9 @@ | ||
| 41 | 41 | * Kept separate from ALLOWED_PLUGINS because cleanup() deletes the source |
| 42 | 42 | * plugin's live data: the native ThinkRank slug must never reach it, or the |
| 43 | 43 | * endpoint gains a path that wipes our own meta and options. |
| 44 | 44 | */ |
| 45 | - private const SOURCE_PLUGINS = ['yoast', 'rankmath', 'seopress', 'aioseo', 'squirrly']; | |
| 45 | + private const SOURCE_PLUGINS = ['yoast', 'rankmath', 'seopress', 'aioseo', 'squirrly', 'slimseo']; | |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Snapshot slug for ThinkRank's own data (export / backup / restore). |
| 49 | 49 | */ |
| @@ -52,9 +52,9 @@ | ||
| 52 | 52 | /** |
| 53 | 53 | * Allowed plugin slugs for the snapshot endpoints (export, migrate, |
| 54 | 54 | * snapshot delete). Includes the native slug; cleanup uses SOURCE_PLUGINS. |
| 55 | 55 | */ |
| 56 | - private const ALLOWED_PLUGINS = ['yoast', 'rankmath', 'seopress', 'aioseo', 'squirrly', 'thinkrank']; | |
| 56 | + private const ALLOWED_PLUGINS = ['yoast', 'rankmath', 'seopress', 'aioseo', 'squirrly', 'slimseo', 'thinkrank']; | |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Allowed export/migrate types. Must cover every type the exporters and |
| 60 | 60 | * the frontend workflow (useImportWorkflow.js EXPORT_TYPES) can send — |
| @@ -385,8 +385,11 @@ | ||
| 385 | 385 | 'rankmath' => 'rank_math_', |
| 386 | 386 | 'seopress' => '_seopress_', |
| 387 | 387 | 'aioseo' => null, // Custom table |
| 388 | 388 | 'squirrly' => '_sq_', // Fallback meta only; the SEO is in the qss table below |
| 389 | + // Slim SEO is cleaned by exact key below: a `slim_seo` prefix also | |
| 390 | + // matches Slim SEO Pro's and its add-ons' own keys (#886). | |
| 391 | + 'slimseo' => null, | |
| 389 | 392 | ]; |
| 390 | 393 | |
| 391 | 394 | $prefix = $prefix_map[$plugin] ?? null; |
| 392 | 395 | |
| @@ -439,8 +442,48 @@ | ||
| 439 | 442 | } |
| 440 | 443 | } |
| 441 | 444 | } |
| 442 | 445 | |
| 446 | + if ($plugin === 'slimseo') { | |
| 447 | + // Exactly the keys the exporter reads. A `slim_seo%` prefix would | |
| 448 | + // also take data nothing imported (Slim SEO Link Manager's and | |
| 449 | + // Auto Link's settings), and those stay with their plugin. | |
| 450 | + $deleted += (int) $wpdb->query( | |
| 451 | + $wpdb->prepare( | |
| 452 | + "DELETE FROM {$wpdb->postmeta} WHERE meta_key IN (%s, %s, %s, %s, %s) OR meta_key LIKE %s", | |
| 453 | + Slim_SEO_Exporter::META_KEY, | |
| 454 | + Slim_SEO_Exporter::PRO_META_KEY, | |
| 455 | + Slim_SEO_Exporter::SCHEMA_META_KEY, | |
| 456 | + Slim_SEO_Exporter::ALLOW_GLOBAL_META, | |
| 457 | + Slim_SEO_Exporter::OLD_PERMALINK_META, | |
| 458 | + $wpdb->esc_like(Slim_SEO_Exporter::PRIMARY_TERM_PREFIX) . '%' | |
| 459 | + ) | |
| 460 | + ); | |
| 461 | + $deleted += (int) $wpdb->query( | |
| 462 | + $wpdb->prepare("DELETE FROM {$wpdb->termmeta} WHERE meta_key = %s", Slim_SEO_Exporter::META_KEY) | |
| 463 | + ); | |
| 464 | + $options = [ | |
| 465 | + Slim_SEO_Exporter::OPTION, | |
| 466 | + Slim_SEO_Exporter::REDIRECTS_OPTION, | |
| 467 | + Slim_SEO_Exporter::PRO_OPTION, | |
| 468 | + Slim_SEO_Exporter::SCHEMAS_OPTION, | |
| 469 | + 'slim_seo_db_version', | |
| 470 | + 'ss_redirection_db_version', | |
| 471 | + ]; | |
| 472 | + foreach ($options as $option_name) { | |
| 473 | + if (delete_option($option_name)) { | |
| 474 | + $deleted++; | |
| 475 | + } | |
| 476 | + } | |
| 477 | + $table = $wpdb->prefix . Slim_SEO_Exporter::LOG_404_TABLE; | |
| 478 | + if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $table))) { | |
| 479 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name is $wpdb->prefix plus a literal. | |
| 480 | + $deleted += (int) $wpdb->get_var("SELECT COUNT(*) FROM {$table}"); | |
| 481 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name is $wpdb->prefix plus a literal. | |
| 482 | + $wpdb->query("DROP TABLE {$table}"); | |
| 483 | + } | |
| 484 | + } | |
| 485 | + | |
| 443 | 486 | if ($plugin === 'squirrly') { |
| 444 | 487 | // Drop Squirrly's custom tables: per-URL SEO, Advanced Pack |
| 445 | 488 | // redirects and their logs, reusable JSON-LD templates. |
| 446 | 489 | foreach (['qss', 'qss_redirects', 'qss_redirects_logs', 'qss_jsonld'] as $suffix) { |
| @@ -586,8 +629,10 @@ | ||
| 586 | 629 | case 'aioseo': |
| 587 | 630 | return new AIOSEO_Exporter(); |
| 588 | 631 | case Squirrly_Exporter::SLUG: |
| 589 | 632 | return new Squirrly_Exporter(); |
| 633 | + case Slim_SEO_Exporter::SLUG: | |
| 634 | + return new Slim_SEO_Exporter(); | |
| 590 | 635 | case Thinkrank_Exporter::SLUG: |
| 591 | 636 | return new Thinkrank_Exporter(); |
| 592 | 637 | default: |
| 593 | 638 | return new \WP_Error('invalid_plugin', 'Unsupported plugin: ' . $plugin, ['status' => 400]); |