← All changes
|
includes/abilities/analysis/class-get-integrations-status.php
+23
-35
2.2.0
→
2.7.0
View file →
| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | */ |
| 32 | 32 | public function __construct() { |
| 33 | 33 | $this->id = 'thinkrank/get-integrations-status'; |
| 34 | 34 | $this->label = __( 'Get Integrations Status', 'thinkrank' ); |
| 35 | - $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' ); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * {@inheritDoc} |
| @@ -134,45 +134,33 @@ | ||
| 134 | 134 | // two screens cannot disagree about the same site again (#519). |
| 135 | 135 | $ps_key = (string) $settings->get( 'google_pagespeed_api_key', '' ); |
| 136 | 136 | $ps_configured = Google_PageSpeed_Client::site_has_credentials(); |
| 137 | 137 | |
| 138 | - // ThinkRank's own tag-injection state (see the google_analytics block). | |
| 139 | - $ga4_measurement_id = (string) $settings->get( 'ga4_measurement_id', '' ); | |
| 140 | - $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 | + ]; | |
| 141 | 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 | + | |
| 142 | 160 | return [ |
| 143 | 161 | 'google_account_connected' => (bool) $settings->get( 'google_account_connected', false ), |
| 144 | - 'google_analytics' => [ | |
| 145 | - 'configured' => $ga_configured, | |
| 146 | - // The selected GA4 property, in the Admin API's | |
| 147 | - // "properties/XXXXXXXX" form. Empty means no property picked, | |
| 148 | - // which is the usual reason GA is connected but unusable. | |
| 149 | - 'property_id' => $ga_property, | |
| 150 | - | |
| 151 | - // The two fields below describe ThinkRank's OWN optional | |
| 152 | - // tag-injection feature — NOT whether the site has a working | |
| 153 | - // GA4 tag. On an OAuth-connected site that never used | |
| 154 | - // injection they are legitimately empty/false, and a client | |
| 155 | - // read that as "GA4 tracking is broken" on a site whose tag | |
| 156 | - // was working fine (#250). They are nested and named for what | |
| 157 | - // they actually are so the payload cannot be misread; the | |
| 158 | - // question "can ThinkRank read Analytics data?" is answered by | |
| 159 | - // `configured` above. | |
| 160 | - // | |
| 161 | - // Kept at the top level as well, deprecated, so an existing | |
| 162 | - // consumer does not break on this release. | |
| 163 | - 'tag_injection' => [ | |
| 164 | - 'measurement_id' => $ga4_measurement_id, | |
| 165 | - 'auto_inject_enabled' => (bool) $settings->get( 'ga4_auto_inject', false ), | |
| 166 | - 'last_check_passed' => $ga4_verified, | |
| 167 | - 'last_checked' => (string) $settings->get( 'ga4_last_verification', '' ), | |
| 168 | - ], | |
| 169 | - | |
| 170 | - /** @deprecated 1.27.0 Use tag_injection.measurement_id. */ | |
| 171 | - 'measurement_id' => $ga4_measurement_id, | |
| 172 | - /** @deprecated 1.27.0 Use tag_injection.last_check_passed. */ | |
| 173 | - 'tracking_verified' => $ga4_verified, | |
| 174 | - ], | |
| 162 | + 'google_analytics' => is_array( $filtered ) ? $filtered : $google_analytics, | |
| 175 | 163 | 'search_console' => [ |
| 176 | 164 | 'configured' => $sc_configured, |
| 177 | 165 | // Was reading `google_search_console_site` — a key with no |
| 178 | 166 | // writer anywhere in the plugin (only two disconnect paths |