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 / services / importing / aioseo / aioseo-robots-provider-service.php

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

63 lines 1.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\Services\Importing\Aioseo;
5
6 use Yoast\WP\SEO\Helpers\Aioseo_Helper;
7
8 /**
9 * Provides AISOEO search appearance robot settings.
10 */
11 class Aioseo_Robots_Provider_Service {
12
13 /**
14 * The AIOSEO helper.
15 *
16 * @var Aioseo_Helper
17 */
18 protected $aioseo_helper;
19
20 /**
21 * Class constructor.
22 *
23 * @param Aioseo_Helper $aioseo_helper The AIOSEO helper.
24 */
25 public function __construct( Aioseo_Helper $aioseo_helper ) {
26 $this->aioseo_helper = $aioseo_helper;
27 }
28
29 /**
30 * Retrieves the robot setting set globally in AIOSEO.
31 *
32 * @param string $setting_name The name of the robot setting, eg. noindex.
33 *
34 * @return bool Whether global robot settings enable or not the specific setting.
35 */
36 public function get_global_robot_settings( $setting_name ) {
37 $aioseo_settings = $this->aioseo_helper->get_global_option();
38 if ( empty( $aioseo_settings ) ) {
39 return false;
40 }
41
42 $global_robot_settings = $aioseo_settings['searchAppearance']['advanced']['globalRobotsMeta'];
43 if ( $global_robot_settings['default'] === true ) {
44 return false;
45 }
46
47 return $global_robot_settings[ $setting_name ];
48 }
49
50 /**
51 * Gets the subtype's robot setting from the db.
52 *
53 * @param array $mapping The mapping of the setting we're working with.
54 *
55 * @return bool The robot setting.
56 */
57 public function get_subtype_robot_setting( $mapping ) {
58 $aioseo_settings = \json_decode( \get_option( $mapping['option_name'], '' ), true );
59
60 return $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta'][ $mapping['robot_type'] ];
61 }
62 }
63