PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 1.28.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v1.28.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / includes / abilities / settings / class-get-site-identity-settings.php

class-get-site-identity-settings.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 1.28.0, at includes/abilities/settings/class-get-site-identity-settings.php

145 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get site identity settings ability.
4 *
5 * @package ThinkRank\Abilities\Settings
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities\Settings;
11
12 use ThinkRank\Abilities\Ability_Base;
13 use ThinkRank\SEO\Site_Identity_Manager;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Retrieves ThinkRank site identity settings.
21 *
22 * Covers title templates, site name/description, breadcrumb configuration, and
23 * brand imagery. The robots.txt keys managed by this manager are intentionally
24 * excluded here; use the dedicated robots.txt ability for those.
25 */
26 class Get_Site_Identity_Settings extends Ability_Base {
27 /**
28 * Boolean-typed site identity keys.
29 */
30 private const BOOL_KEYS = [
31 'enabled',
32 'breadcrumbs_enabled',
33 ];
34
35 /**
36 * String-typed site identity keys.
37 */
38 private const STRING_KEYS = [
39 'title_template',
40 'title_separator',
41 'site_name',
42 'site_description',
43 'tagline',
44 'breadcrumb_type',
45 'breadcrumb_home_text',
46 'breadcrumb_separator',
47 'logo_url',
48 'favicon_url',
49 'apple_touch_icon_url',
50 ];
51
52 /**
53 * Constructor.
54 */
55 public function __construct() {
56 $this->id = 'thinkrank/get-site-identity-settings';
57 $this->label = __( 'Get ThinkRank Site Identity Settings', 'thinkrank' );
58 $this->description = __( 'Retrieve ThinkRank site identity settings: title templates, site name/description, breadcrumb configuration, and brand imagery. Robots.txt configuration is excluded.', 'thinkrank' );
59 }
60
61 /**
62 * {@inheritDoc}
63 *
64 * @return array<string, bool|float|string>
65 */
66 public function get_annotations() {
67 return [
68 'readonly' => true,
69 'destructive' => false,
70 'idempotent' => true,
71 'priority' => 1.0,
72 'openWorldHint' => false,
73 ];
74 }
75
76 /**
77 * Build the JSON schema properties for site identity settings.
78 *
79 * @return array<string, mixed>
80 */
81 private static function schema_properties() {
82 $props = [];
83
84 foreach ( self::BOOL_KEYS as $key ) {
85 $props[ $key ] = [ 'type' => 'boolean' ];
86 }
87 foreach ( self::STRING_KEYS as $key ) {
88 $props[ $key ] = [ 'type' => 'string' ];
89 }
90
91 return $props;
92 }
93
94 /**
95 * {@inheritDoc}
96 *
97 * @return array<string, mixed>
98 */
99 public function get_input_schema() {
100 return [
101 'type' => 'object',
102 'additionalProperties' => false,
103 'properties' => [],
104 ];
105 }
106
107 /**
108 * {@inheritDoc}
109 *
110 * @return array<string, mixed>
111 */
112 public function get_output_schema() {
113 return [
114 'type' => 'object',
115 'properties' => [
116 'settings' => [
117 'type' => 'object',
118 'properties' => self::schema_properties(),
119 ],
120 ],
121 ];
122 }
123
124 /**
125 * Execute ability.
126 *
127 * @param array<string, mixed> $input Ability input payload.
128 * @return array<string, mixed>
129 */
130 public function execute( $input ) {
131 $mgr = new Site_Identity_Manager();
132 $s = $mgr->get_settings( 'site', null );
133
134 $out = [];
135 foreach ( self::BOOL_KEYS as $key ) {
136 $out[ $key ] = (bool) ( $s[ $key ] ?? false );
137 }
138 foreach ( self::STRING_KEYS as $key ) {
139 $out[ $key ] = (string) ( $s[ $key ] ?? '' );
140 }
141
142 return [ 'settings' => $out ];
143 }
144 }
145