PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.1
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.1
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
← All changes | includes/class-metasync-ga4.php +14 -27 2.7.2 → 2.7.1 View file →
@@ -33,8 +33,12 @@
33 33 if (!$this->is_configured()) {
34 34 return;
35 35 }
36 36
37 + if (get_option(self::OPT_IN_OPTION) === false) {
38 + update_option(self::OPT_IN_OPTION, 'yes');
39 + }
40 +
37 41 add_action('admin_enqueue_scripts', array($this, 'enqueue_ga4_script'));
38 42 add_action('admin_head', array($this, 'track_admin_page_view'));
39 43 }
40 44
@@ -48,9 +52,9 @@
48 52 return $this->get_measurement_id() !== null;
49 53 }
50 54
51 55 public function is_opted_in() {
52 - return get_option(self::OPT_IN_OPTION, 'no') === 'yes';
56 + return get_option(self::OPT_IN_OPTION, 'yes') === 'yes';
53 57 }
54 58
55 59 private function get_anonymized_user_id() {
56 60 $current_user = wp_get_current_user();
@@ -165,10 +169,13 @@
165 169 array('screen_name' => $screen_name),
166 170 JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
167 171 );
168 172
169 - $inline_tracking = "<script type='text/javascript'>\n if (typeof gtag !== 'undefined') {\n gtag('event', 'plugin_admin_accessed', " . $params . ");\n }\n </script>";
170 - echo $inline_tracking; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $params is wp_json_encode() output with JSON_HEX_TAG/AMP/APOS/QUOT, safe inside an inline <script>
173 + echo "<script type='text/javascript'>
174 + if (typeof gtag !== 'undefined') {
175 + gtag('event', 'plugin_admin_accessed', " . $params . ");
176 + }
177 + </script>";
171 178 }
172 179
173 180 /**
174 181 * Track Content Genius article creation/update (server-side)
@@ -184,32 +191,12 @@
184 191 if (!$post) {
185 192 return;
186 193 }
187 194
188 - // Bulk syncs fire this once per article; roll up to at most one event
189 - // per action per hour with accumulated counts so a sync of N articles
190 - // stays a single send (same shape as the PostHog rollup).
191 - $action = strtolower($action);
192 - $key = 'metasync_ga4_cg_' . $action;
193 - $state = get_option($key, array());
194 - if (!is_array($state)) {
195 - $state = array();
196 - }
197 - $counts = isset($state['counts']) && is_array($state['counts']) ? $state['counts'] : array();
198 - $sent_at = (int) ($state['sent_at'] ?? 0);
199 - $type = (string) $post->post_type;
200 - $counts[$type] = ($counts[$type] ?? 0) + 1;
201 -
202 - if (time() - $sent_at >= HOUR_IN_SECONDS) {
203 - $this->send_mp_event('content_genius_article_' . $action, array(
204 - 'content_type' => $type,
205 - 'action' => ucfirst($action),
206 - 'count' => array_sum($counts),
207 - ));
208 - update_option($key, array('counts' => array(), 'sent_at' => time()), false);
209 - } else {
210 - update_option($key, array('counts' => $counts, 'sent_at' => $sent_at), false);
211 - }
195 + $this->send_mp_event('content_genius_article_' . strtolower($action), array(
196 + 'content_type' => $post->post_type,
197 + 'action' => ucfirst($action),
198 + ));
212 199 }
213 200
214 201 /**
215 202 * Track OTTO page optimization (server-side)