PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.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-custom-archive-settings-importing-action.php

aioseo-custom-archive-settings-importing-action.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/actions/importing/aioseo/aioseo-custom-archive-settings-importing-action.php

112 lines 3.7 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 use Yoast\WP\SEO\Helpers\Import_Cursor_Helper;
7 use Yoast\WP\SEO\Helpers\Options_Helper;
8 use Yoast\WP\SEO\Helpers\Post_Type_Helper;
9 use Yoast\WP\SEO\Helpers\Sanitization_Helper;
10 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Replacevar_Service;
11 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Provider_Service;
12 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Transformer_Service;
13
14 /**
15 * Importing action for AIOSEO custom archive settings data.
16 *
17 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
18 */
19 class Aioseo_Custom_Archive_Settings_Importing_Action extends Abstract_Aioseo_Settings_Importing_Action {
20
21 /**
22 * The plugin of the action.
23 */
24 public const PLUGIN = 'aioseo';
25
26 /**
27 * The type of the action.
28 */
29 public const TYPE = 'custom_archive_settings';
30
31 /**
32 * The option_name of the AIOSEO option that contains the settings.
33 */
34 public const SOURCE_OPTION_NAME = 'aioseo_options_dynamic';
35
36 /**
37 * The map of aioseo_options to yoast settings.
38 *
39 * @var array
40 */
41 protected $aioseo_options_to_yoast_map = [];
42
43 /**
44 * The tab of the aioseo settings we're working with.
45 *
46 * @var string
47 */
48 protected $settings_tab = 'archives';
49
50 /**
51 * The post type helper.
52 *
53 * @var Post_Type_Helper
54 */
55 protected $post_type;
56
57 /**
58 * Aioseo_Custom_Archive_Settings_Importing_Action constructor.
59 *
60 * @param Import_Cursor_Helper $import_cursor The import cursor helper.
61 * @param Options_Helper $options The options helper.
62 * @param Sanitization_Helper $sanitization The sanitization helper.
63 * @param Post_Type_Helper $post_type The post type helper.
64 * @param Aioseo_Replacevar_Service $replacevar_handler The replacevar handler.
65 * @param Aioseo_Robots_Provider_Service $robots_provider The robots provider service.
66 * @param Aioseo_Robots_Transformer_Service $robots_transformer The robots transfomer service.
67 */
68 public function __construct(
69 Import_Cursor_Helper $import_cursor,
70 Options_Helper $options,
71 Sanitization_Helper $sanitization,
72 Post_Type_Helper $post_type,
73 Aioseo_Replacevar_Service $replacevar_handler,
74 Aioseo_Robots_Provider_Service $robots_provider,
75 Aioseo_Robots_Transformer_Service $robots_transformer
76 ) {
77 parent::__construct( $import_cursor, $options, $sanitization, $replacevar_handler, $robots_provider, $robots_transformer );
78
79 $this->post_type = $post_type;
80 }
81
82 /**
83 * Builds the mapping that ties AOISEO option keys with Yoast ones and their data transformation method.
84 *
85 * @return void
86 */
87 protected function build_mapping() {
88 $post_type_objects = \get_post_types( [ 'public' => true ], 'objects' );
89
90 foreach ( $post_type_objects as $pt ) {
91 // Use all the custom post types that have archives.
92 if ( ! $pt->_builtin && $this->post_type->has_archive( $pt ) ) {
93 $this->aioseo_options_to_yoast_map[ '/' . $pt->name . '/title' ] = [
94 'yoast_name' => 'title-ptarchive-' . $pt->name,
95 'transform_method' => 'simple_import',
96 ];
97 $this->aioseo_options_to_yoast_map[ '/' . $pt->name . '/metaDescription' ] = [
98 'yoast_name' => 'metadesc-ptarchive-' . $pt->name,
99 'transform_method' => 'simple_import',
100 ];
101 $this->aioseo_options_to_yoast_map[ '/' . $pt->name . '/advanced/robotsMeta/noindex' ] = [
102 'yoast_name' => 'noindex-ptarchive-' . $pt->name,
103 'transform_method' => 'import_noindex',
104 'type' => 'archives',
105 'subtype' => $pt->name,
106 'option_name' => 'aioseo_options_dynamic',
107 ];
108 }
109 }
110 }
111 }
112