PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.6
28.6 28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 All 130 releases
wordpress-seo / src / actions / importing / aioseo / aioseo-taxonomy-settings-importing-action.php

aioseo-taxonomy-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-taxonomy-settings-importing-action.php

111 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 taxonomies settings data.
8 *
9 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
10 */
11 class Aioseo_Taxonomy_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 = 'taxonomy_settings';
22
23 /**
24 * The option_name of the AIOSEO option that contains the settings.
25 */
26 const SOURCE_OPTION_NAME = 'aioseo_options_dynamic';
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 = 'taxonomies';
41
42 /**
43 * Additional mapping between AiOSEO replace vars and Yoast replace vars.
44 *
45 * @var array
46 *
47 * @see https://yoast.com/help/list-available-snippet-variables-yoast-seo/
48 */
49 protected $replace_vars_edited_map = [
50 '#breadcrumb_404_error_format' => '', // Empty string, as AIOSEO shows nothing for that tag.
51 '#breadcrumb_archive_post_type_format' => '', // Empty string, as AIOSEO shows nothing for that tag.
52 '#breadcrumb_archive_post_type_name' => '', // Empty string, as AIOSEO shows nothing for that tag.
53 '#breadcrumb_author_display_name' => '', // Empty string, as AIOSEO shows nothing for that tag.
54 '#breadcrumb_author_first_name' => '', // Empty string, as AIOSEO shows nothing for that tag.
55 '#breadcrumb_blog_page_title' => '', // Empty string, as AIOSEO shows nothing for that tag.
56 '#breadcrumb_label' => '', // Empty string, as AIOSEO shows nothing for that tag.
57 '#breadcrumb_link' => '', // Empty string, as AIOSEO shows nothing for that tag.
58 '#breadcrumb_search_result_format' => '', // Empty string, as AIOSEO shows nothing for that tag.
59 '#breadcrumb_search_string' => '', // Empty string, as AIOSEO shows nothing for that tag.
60 '#breadcrumb_separator' => '', // Empty string, as AIOSEO shows nothing for that tag.
61 '#breadcrumb_taxonomy_title' => '', // Empty string, as AIOSEO shows nothing for that tag.
62 '#taxonomy_title' => '%%term_title%%',
63 ];
64
65 /**
66 * Builds the mapping that ties AOISEO option keys with Yoast ones and their data transformation method.
67 *
68 * @return void
69 */
70 protected function build_mapping() {
71 $taxonomy_objects = \get_taxonomies( [ 'public' => true ], 'object' );
72
73 foreach ( $taxonomy_objects as $tax ) {
74 // Use all the public taxonomies.
75 $this->aioseo_options_to_yoast_map[ '/' . $tax->name . '/title' ] = [
76 'yoast_name' => 'title-tax-' . $tax->name,
77 'transform_method' => 'simple_import',
78 ];
79 $this->aioseo_options_to_yoast_map[ '/' . $tax->name . '/metaDescription' ] = [
80 'yoast_name' => 'metadesc-tax-' . $tax->name,
81 'transform_method' => 'simple_import',
82 ];
83 $this->aioseo_options_to_yoast_map[ '/' . $tax->name . '/advanced/robotsMeta/noindex' ] = [
84 'yoast_name' => 'noindex-tax-' . $tax->name,
85 'transform_method' => 'import_noindex',
86 'type' => 'taxonomies',
87 'subtype' => $tax->name,
88 'option_name' => 'aioseo_options_dynamic',
89 ];
90 }
91 }
92
93 /**
94 * Returns a setting map of the robot setting for post category taxonomies.
95 *
96 * @return array The setting map of the robot setting for post category taxonomies.
97 */
98 public function pluck_robot_setting_from_mapping() {
99 $this->build_mapping();
100
101 foreach ( $this->aioseo_options_to_yoast_map as $setting ) {
102 // Return the first archive setting map.
103 if ( $setting['transform_method'] === 'import_noindex' && isset( $setting['subtype'] ) && $setting['subtype'] === 'category' ) {
104 return $setting;
105 }
106 }
107
108 return [];
109 }
110 }
111