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.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 19.0 All 129 releases
wordpress-seo / src / services / importing / aioseo / aioseo-robots-transformer-service.php

aioseo-robots-transformer-service.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/services/importing/aioseo/aioseo-robots-transformer-service.php

57 lines 1.8 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\Services\Importing\Aioseo;
5
6 /**
7 * Transforms AISOEO search appearance robot settings.
8 *
9 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
10 */
11 class Aioseo_Robots_Transformer_Service {
12
13 /**
14 * The robots transfomer service.
15 *
16 * @var Aioseo_Robots_Provider_Service
17 */
18 protected $robots_provider;
19
20 /**
21 * Class constructor.
22 *
23 * @param Aioseo_Robots_Provider_Service $robots_provider The robots provider service.
24 */
25 public function __construct(
26 Aioseo_Robots_Provider_Service $robots_provider
27 ) {
28 $this->robots_provider = $robots_provider;
29 }
30
31 /**
32 * Transforms the robot setting, taking into consideration whether they defer to global defaults.
33 *
34 * @param string $setting_name The name of the robot setting, eg. noindex.
35 * @param bool $setting_value The value of the robot setting.
36 * @param array $mapping The mapping of the setting we're working with.
37 *
38 * @return bool The transformed robot setting.
39 */
40 public function transform_robot_setting( $setting_name, $setting_value, $mapping ) {
41 $aioseo_settings = \json_decode( \get_option( $mapping['option_name'], '' ), true );
42
43 // Let's check first if it defers to global robot settings.
44 if ( empty( $aioseo_settings ) || ! isset( $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta']['default'] ) ) {
45 return $setting_value;
46 }
47
48 $defers_to_defaults = $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta']['default'];
49
50 if ( $defers_to_defaults ) {
51 return $this->robots_provider->get_global_robot_settings( $setting_name );
52 }
53
54 return $setting_value;
55 }
56 }
57