PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.2
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.2
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
metasync / includes / metasync-runtime-init.php

metasync-runtime-init.php in Search Atlas SEO – OTTO AI SEO Automation for WordPress 2.7.2, at includes/metasync-runtime-init.php

127 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MetaSync — Runtime Feature Initialisers
4 *
5 * GA4 analytics, API backoff, review notice, the global metasync_get_jwt_token()
6 * accessor, and the debug mode manager. Extracted from metasync.php to
7 * keep the plugin entry file a lean bootstrap. Loaded via require_once from
8 * metasync.php; each initialiser registers its own hook. Function names and hook
9 * timing are unchanged.
10 *
11 * @package Search Atlas SEO
12 */
13
14 if (!defined('WPINC')) {
15 die;
16 }
17
18 /**
19 * Initialize GA4 Analytics for Admin Area
20 * Hooked to admin_init for proper WordPress lifecycle integration
21 * Only loads after WordPress, plugins, and themes are fully loaded
22 */
23 function metasync_init_analytics() {
24 // Initialize the consent-gated PostHog dispatcher in every request context
25 // so REST, MCP, cron, and admin events share one central gate.
26 Metasync_PostHog::get_instance();
27
28 // GA4's browser integration remains limited to MetaSync admin screens.
29 if (is_admin() && !wp_doing_ajax() && !defined('REST_REQUEST')) {
30 Metasync_GA4::get_instance();
31 }
32 }
33 add_action('init', 'metasync_init_analytics', 1);
34
35 /**
36 * Initialize API Backoff System
37 * Hooked to init for proper WordPress lifecycle integration
38 * Monitors API responses and manages exponential backoff for rate limiting
39 * @since 2.7.1
40 */
41 function metasync_init_api_backoff() {
42 if (metasync_is_non_metasync_admin_ajax()) {
43 return;
44 }
45 // Initialize backoff manager (registers HTTP response filters)
46 Metasync_API_Backoff_Manager::get_instance();
47
48 // Initialize admin notices (only in admin area)
49 if (is_admin()) {
50 Metasync_API_Backoff_Notices::get_instance();
51 }
52 }
53 add_action('init', 'metasync_init_api_backoff', 5);
54
55 /**
56 * Initialize Review Notice
57 * Shows a dismissible notice asking users to rate the plugin after a usage period
58 * @since 2.8.0
59 */
60 function metasync_init_review_notice() {
61 if (metasync_is_non_metasync_admin_ajax()) {
62 return;
63 }
64 if (is_admin()) {
65 Metasync_Review_Notice::get_instance();
66 }
67 }
68 add_action('init', 'metasync_init_review_notice');
69
70 /**
71 * Initialize Analytics Consent Notice
72 * Asks existing installs to opt in to usage analytics; re-shows every
73 * 10 days while consent stays off.
74 */
75 function metasync_init_analytics_consent_notice() {
76 if (metasync_is_non_metasync_admin_ajax()) {
77 return;
78 }
79 if (is_admin()) {
80 Metasync_Analytics_Consent_Notice::get_instance();
81 }
82 }
83 add_action('init', 'metasync_init_analytics_consent_notice');
84
85 /**
86 * Initialize Host Blocking Check
87 * Owns the shared GET/POST reachability probe, its post-activation + weekly crons,
88 * and the warning notice. Initialised unconditionally (not gated on is_admin) because
89 * the cron callbacks must be registered on WP-Cron requests, where is_admin() is false.
90 * @since 2.8.x
91 */
92 function metasync_init_host_blocking_check() {
93 if (metasync_is_non_metasync_admin_ajax()) {
94 return;
95 }
96 Metasync_Host_Blocking_Check::get_instance();
97 }
98 add_action('plugins_loaded', 'metasync_init_host_blocking_check');
99
100 /**
101 * Global convenience function to get active JWT token
102 * Can be called from anywhere in WordPress (themes, other plugins, etc.)
103 *
104 * @param bool $force_refresh Force generation of new token even if cached one exists
105 * @return string|false JWT token on success, false on failure
106 */
107 if (!function_exists('metasync_get_jwt_token')) {
108 function metasync_get_jwt_token($force_refresh = false)
109 {
110 return Metasync::get_jwt_token($force_refresh);
111 }
112 }
113
114
115 /**
116 * Initialize Debug Mode Manager
117 * Hooked to 'init' for proper WordPress lifecycle integration
118 */
119 function metasync_init_debug_mode_manager() {
120 if (metasync_is_non_metasync_admin_ajax()) {
121 return;
122 }
123 // Initialize the Debug Mode Manager singleton
124 Metasync_Debug_Mode_Manager::get_instance();
125 }
126 add_action('init', 'metasync_init_debug_mode_manager', 10);
127