PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.7.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.7.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
← All changes | includes/abilities/analysis/class-get-integrations-status.php +28 -37 2.0.22.7.0 View file →
@@ -10,8 +10,9 @@
10 10 namespace ThinkRank\Abilities\Analysis;
11 11
12 12 use ThinkRank\Abilities\Ability_Base;
13 13 use ThinkRank\Core\Settings;
14 +use ThinkRank\Integrations\Google_PageSpeed_Client;
14 15
15 16 if ( ! defined( 'ABSPATH' ) ) {
16 17 exit; // Exit if accessed directly.
17 18 }
@@ -30,9 +31,9 @@
30 31 */
31 32 public function __construct() {
32 33 $this->id = 'thinkrank/get-integrations-status';
33 34 $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 + $this->description = __( 'Report the connection status of the Google Analytics, Search Console, and PageSpeed integrations (connected/configured flags, selected GA4 property, selected Search Console site). Never returns API keys or OAuth tokens.', 'thinkrank' );
35 36 }
36 37
37 38 /**
38 39 * {@inheritDoc}
@@ -127,49 +128,39 @@
127 128 $sc_configured = $oauth_present
128 129 || '' !== (string) $settings->get( 'google_search_console_api_key', '' );
129 130
130 131 // PageSpeed: for_site() prefers a dedicated key, else the OAuth token,
131 - // else runs keyless on the per-IP quota. Report credentialed state.
132 + // else runs keyless on the per-IP quota. Report credentialed state, and
133 + // read it from the same predicate the Performance tab gates on, so the
134 + // two screens cannot disagree about the same site again (#519).
132 135 $ps_key = (string) $settings->get( 'google_pagespeed_api_key', '' );
133 - $ps_configured = '' !== $ps_key || $oauth_present;
136 + $ps_configured = Google_PageSpeed_Client::site_has_credentials();
134 137
135 - // ThinkRank's own tag-injection state (see the google_analytics block).
136 - $ga4_measurement_id = (string) $settings->get( 'ga4_measurement_id', '' );
137 - $ga4_verified = (bool) $settings->get( 'ga4_tracking_verified', false );
138 + $google_analytics = [
139 + 'configured' => $ga_configured,
140 + // The selected GA4 property, in the Admin API's
141 + // "properties/XXXXXXXX" form. Empty means no property picked,
142 + // which is the usual reason GA is connected but unusable.
143 + 'property_id' => $ga_property,
144 + ];
138 145
146 + /**
147 + * Filters the google_analytics block of the integrations status.
148 + *
149 + * ThinkRank Pro, which installs the GA4 tag, adds its state here as
150 + * `tag_injection`. That describes the tag Pro prints, not whether the
151 + * site has a working GA4 tag (#250); `configured` answers whether
152 + * ThinkRank can read Analytics data.
153 + *
154 + * @since 2.6.0
155 + *
156 + * @param array<string, mixed> $google_analytics Status block.
157 + */
158 + $filtered = apply_filters( 'thinkrank_integrations_status_google_analytics', $google_analytics );
159 +
139 160 return [
140 161 'google_account_connected' => (bool) $settings->get( 'google_account_connected', false ),
141 - 'google_analytics' => [
142 - 'configured' => $ga_configured,
143 - // The selected GA4 property, in the Admin API's
144 - // "properties/XXXXXXXX" form. Empty means no property picked,
145 - // which is the usual reason GA is connected but unusable.
146 - 'property_id' => $ga_property,
147 -
148 - // The two fields below describe ThinkRank's OWN optional
149 - // tag-injection feature — NOT whether the site has a working
150 - // GA4 tag. On an OAuth-connected site that never used
151 - // injection they are legitimately empty/false, and a client
152 - // read that as "GA4 tracking is broken" on a site whose tag
153 - // was working fine (#250). They are nested and named for what
154 - // they actually are so the payload cannot be misread; the
155 - // question "can ThinkRank read Analytics data?" is answered by
156 - // `configured` above.
157 - //
158 - // Kept at the top level as well, deprecated, so an existing
159 - // consumer does not break on this release.
160 - 'tag_injection' => [
161 - 'measurement_id' => $ga4_measurement_id,
162 - 'auto_inject_enabled' => (bool) $settings->get( 'ga4_auto_inject', false ),
163 - 'last_check_passed' => $ga4_verified,
164 - 'last_checked' => (string) $settings->get( 'ga4_last_verification', '' ),
165 - ],
166 -
167 - /** @deprecated 1.27.0 Use tag_injection.measurement_id. */
168 - 'measurement_id' => $ga4_measurement_id,
169 - /** @deprecated 1.27.0 Use tag_injection.last_check_passed. */
170 - 'tracking_verified' => $ga4_verified,
171 - ],
162 + 'google_analytics' => is_array( $filtered ) ? $filtered : $google_analytics,
172 163 'search_console' => [
173 164 'configured' => $sc_configured,
174 165 // Was reading `google_search_console_site` — a key with no
175 166 // writer anywhere in the plugin (only two disconnect paths