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-provider-service.php

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

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