wordpress-seo
/
src
/
actions
/
importing
/
aioseo
/
aioseo-default-archive-settings-importing-action.php
aioseo-default-archive-settings-importing-action.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/actions/importing/aioseo/aioseo-default-archive-settings-importing-action.php
| 1 | <?php |
| 2 | |
| 3 | // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case. |
| 4 | namespace Yoast\WP\SEO\Actions\Importing\Aioseo; |
| 5 | |
| 6 | /** |
| 7 | * Importing action for AIOSEO default archive settings data. |
| 8 | * |
| 9 | * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded |
| 10 | */ |
| 11 | class Aioseo_Default_Archive_Settings_Importing_Action extends Abstract_Aioseo_Settings_Importing_Action { |
| 12 | |
| 13 | /** |
| 14 | * The plugin of the action. |
| 15 | */ |
| 16 | const PLUGIN = 'aioseo'; |
| 17 | |
| 18 | /** |
| 19 | * The type of the action. |
| 20 | */ |
| 21 | const TYPE = 'default_archive_settings'; |
| 22 | |
| 23 | /** |
| 24 | * The option_name of the AIOSEO option that contains the settings. |
| 25 | */ |
| 26 | const SOURCE_OPTION_NAME = 'aioseo_options'; |
| 27 | |
| 28 | /** |
| 29 | * The map of aioseo_options to yoast settings. |
| 30 | * |
| 31 | * @var array |
| 32 | */ |
| 33 | protected $aioseo_options_to_yoast_map = []; |
| 34 | |
| 35 | /** |
| 36 | * The tab of the aioseo settings we're working with. |
| 37 | * |
| 38 | * @var string |
| 39 | */ |
| 40 | protected $settings_tab = 'archives'; |
| 41 | |
| 42 | /** |
| 43 | * Builds the mapping that ties AOISEO option keys with Yoast ones and their data transformation method. |
| 44 | * |
| 45 | * @return void |
| 46 | */ |
| 47 | protected function build_mapping() { |
| 48 | $this->aioseo_options_to_yoast_map = [ |
| 49 | '/author/title' => [ |
| 50 | 'yoast_name' => 'title-author-wpseo', |
| 51 | 'transform_method' => 'simple_import', |
| 52 | ], |
| 53 | '/author/metaDescription' => [ |
| 54 | 'yoast_name' => 'metadesc-author-wpseo', |
| 55 | 'transform_method' => 'simple_import', |
| 56 | ], |
| 57 | '/date/title' => [ |
| 58 | 'yoast_name' => 'title-archive-wpseo', |
| 59 | 'transform_method' => 'simple_import', |
| 60 | ], |
| 61 | '/date/metaDescription' => [ |
| 62 | 'yoast_name' => 'metadesc-archive-wpseo', |
| 63 | 'transform_method' => 'simple_import', |
| 64 | ], |
| 65 | '/search/title' => [ |
| 66 | 'yoast_name' => 'title-search-wpseo', |
| 67 | 'transform_method' => 'simple_import', |
| 68 | ], |
| 69 | '/author/advanced/robotsMeta/noindex' => [ |
| 70 | 'yoast_name' => 'noindex-author-wpseo', |
| 71 | 'transform_method' => 'import_noindex', |
| 72 | 'type' => 'archives', |
| 73 | 'subtype' => 'author', |
| 74 | 'option_name' => 'aioseo_options', |
| 75 | ], |
| 76 | '/date/advanced/robotsMeta/noindex' => [ |
| 77 | 'yoast_name' => 'noindex-archive-wpseo', |
| 78 | 'transform_method' => 'import_noindex', |
| 79 | 'type' => 'archives', |
| 80 | 'subtype' => 'date', |
| 81 | 'option_name' => 'aioseo_options', |
| 82 | ], |
| 83 | ]; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns a setting map of the robot setting for author archives. |
| 88 | * |
| 89 | * @return array The setting map of the robot setting for author archives. |
| 90 | */ |
| 91 | public function pluck_robot_setting_from_mapping() { |
| 92 | $this->build_mapping(); |
| 93 | |
| 94 | foreach ( $this->aioseo_options_to_yoast_map as $setting ) { |
| 95 | // Return the first archive setting map. |
| 96 | if ( $setting['transform_method'] === 'import_noindex' && isset( $setting['subtype'] ) && $setting['subtype'] === 'author' ) { |
| 97 | return $setting; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return []; |
| 102 | } |
| 103 | } |
| 104 |