PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 1.27.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v1.27.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 / analysis / class-get-integrations-status.php

class-get-integrations-status.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 1.27.0, at includes/abilities/analysis/class-get-integrations-status.php

124 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get integrations status ability.
4 *
5 * @package ThinkRank\Abilities\Analysis
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities\Analysis;
11
12 use ThinkRank\Abilities\Ability_Base;
13 use ThinkRank\Core\Settings;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Reports the connection status of ThinkRank's Google integrations.
21 *
22 * Covers Google Analytics (GA4), Search Console, and PageSpeed. Returns only
23 * non-sensitive status — connected/configured booleans, the public GA4
24 * measurement ID, and the selected Search Console site. It deliberately never
25 * returns API keys, OAuth access/refresh tokens, or any secret material.
26 */
27 class Get_Integrations_Status extends Ability_Base {
28 /**
29 * Constructor.
30 */
31 public function __construct() {
32 $this->id = 'thinkrank/get-integrations-status';
33 $this->label = __( 'Get Integrations Status', 'thinkrank' );
34 $this->description = __( 'Report the connection status of the Google Analytics, Search Console, and PageSpeed integrations (connected/configured flags, GA4 measurement ID, selected Search Console site). Never returns API keys or OAuth tokens.', 'thinkrank' );
35 }
36
37 /**
38 * {@inheritDoc}
39 *
40 * @return array<string, bool|float|string>
41 */
42 public function get_annotations() {
43 return [
44 'readonly' => true,
45 'destructive' => false,
46 'idempotent' => true,
47 'priority' => 1.0,
48 'openWorldHint' => false,
49 ];
50 }
51
52 /**
53 * {@inheritDoc}
54 *
55 * @return array<string, mixed>
56 */
57 public function get_input_schema() {
58 return [
59 'type' => 'object',
60 'additionalProperties' => false,
61 'properties' => [],
62 ];
63 }
64
65 /**
66 * {@inheritDoc}
67 *
68 * @return array<string, mixed>
69 */
70 public function get_output_schema() {
71 return [
72 'type' => 'object',
73 'properties' => [
74 'google_account_connected' => [ 'type' => 'boolean' ],
75 'google_analytics' => [
76 'type' => 'object',
77 'additionalProperties' => true,
78 ],
79 'search_console' => [
80 'type' => 'object',
81 'additionalProperties' => true,
82 ],
83 'pagespeed' => [
84 'type' => 'object',
85 'additionalProperties' => true,
86 ],
87 ],
88 ];
89 }
90
91 /**
92 * Execute ability.
93 *
94 * @param array<string, mixed> $input Ability input payload.
95 * @return array<string, mixed>
96 */
97 public function execute( $input ) {
98 $settings = Settings::instance();
99
100 // Derive "configured" from presence only — never surface the value itself.
101 $ga_configured = '' !== (string) $settings->get( 'google_analytics_api_key', '' );
102 $sc_configured = '' !== (string) $settings->get( 'google_search_console_api_key', '' );
103 $ps_configured = '' !== (string) $settings->get( 'google_pagespeed_api_key', '' );
104 $oauth_present = '' !== (string) $settings->get( 'google_access_token', '' );
105
106 return [
107 'google_account_connected' => (bool) $settings->get( 'google_account_connected', false ),
108 'google_analytics' => [
109 'configured' => $ga_configured,
110 'measurement_id' => (string) $settings->get( 'ga4_measurement_id', '' ),
111 'tracking_verified' => (bool) $settings->get( 'ga4_tracking_verified', false ),
112 ],
113 'search_console' => [
114 'configured' => $sc_configured,
115 'site' => (string) $settings->get( 'google_search_console_site', '' ),
116 ],
117 'pagespeed' => [
118 'configured' => $ps_configured,
119 'oauth_connected' => $oauth_present,
120 ],
121 ];
122 }
123 }
124