PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.3.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.3.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-instant-indexing-settings.php

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

115 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get instant indexing 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
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18 /**
19 * Retrieves ThinkRank instant indexing (IndexNow) settings.
20 *
21 * The IndexNow API key is auto-generated and never exposed in full; the read
22 * only reports whether a key is currently configured.
23 */
24 class Get_Instant_Indexing_Settings extends Ability_Base {
25 /**
26 * Option name that stores the instant indexing settings.
27 */
28 private const OPTION = 'thinkrank_instant_indexing_settings';
29
30 /**
31 * Default instant indexing settings.
32 */
33 private const DEFAULTS = [
34 'enabled' => false,
35 'auto_submit_post_types' => [ 'post', 'page' ],
36 'api_key' => '',
37 ];
38
39 /**
40 * Constructor.
41 */
42 public function __construct() {
43 $this->id = 'thinkrank/get-instant-indexing-settings';
44 $this->label = __( 'Get ThinkRank Instant Indexing Settings', 'thinkrank' );
45 $this->description = __( 'Retrieve ThinkRank instant indexing (IndexNow) settings. The API key is auto-generated and is not exposed; only whether a key is set is reported. Use update-instant-indexing-settings to change them.', 'thinkrank' );
46 }
47
48 /**
49 * {@inheritDoc}
50 *
51 * @return array<string, bool|float|string>
52 */
53 public function get_annotations() {
54 return [
55 'readonly' => true,
56 'destructive' => false,
57 'idempotent' => true,
58 'priority' => 1.0,
59 'openWorldHint' => false,
60 ];
61 }
62
63 /**
64 * {@inheritDoc}
65 *
66 * @return array<string, mixed>
67 */
68 public function get_input_schema() {
69 return [
70 'type' => 'object',
71 'additionalProperties' => false,
72 'properties' => self::empty_properties(),
73 ];
74 }
75
76 /**
77 * {@inheritDoc}
78 *
79 * @return array<string, mixed>
80 */
81 public function get_output_schema() {
82 return [
83 'type' => 'object',
84 'properties' => [
85 'enabled' => [ 'type' => 'boolean' ],
86 'auto_submit_post_types' => [
87 'type' => 'array',
88 'items' => [ 'type' => 'string' ],
89 ],
90 'api_key_set' => [ 'type' => 'boolean' ],
91 ],
92 ];
93 }
94
95 /**
96 * Execute ability.
97 *
98 * @param array<string, mixed> $input Ability input payload.
99 * @return array<string, mixed>
100 */
101 public function execute( $input ) {
102 $settings = wp_parse_args( (array) get_option( self::OPTION, [] ), self::DEFAULTS );
103
104 $post_types = is_array( $settings['auto_submit_post_types'] ?? null )
105 ? array_values( array_map( 'sanitize_key', $settings['auto_submit_post_types'] ) )
106 : [];
107
108 return [
109 'enabled' => (bool) ( $settings['enabled'] ?? false ),
110 'auto_submit_post_types' => $post_types,
111 'api_key_set' => '' !== (string) ( $settings['api_key'] ?? '' ),
112 ];
113 }
114 }
115