PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / trunk
Search Atlas SEO – OTTO AI SEO Automation for WordPress vtrunk
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 2.6.4 2.6.3 2.5.23 All 138 releases
metasync / includes / metasync-runtime-init.php

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

108 lines 3.1 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 // Only initialize in admin area (excludes AJAX and REST API requests)
25 if (is_admin() && !wp_doing_ajax() && !defined('REST_REQUEST')) {
26 Metasync_GA4::get_instance();
27 }
28 }
29 add_action('admin_init', 'metasync_init_analytics', 10);
30
31 /**
32 * Initialize API Backoff System
33 * Hooked to init for proper WordPress lifecycle integration
34 * Monitors API responses and manages exponential backoff for rate limiting
35 * @since 2.7.1
36 */
37 function metasync_init_api_backoff() {
38 if (metasync_is_non_metasync_admin_ajax()) {
39 return;
40 }
41 // Initialize backoff manager (registers HTTP response filters)
42 Metasync_API_Backoff_Manager::get_instance();
43
44 // Initialize admin notices (only in admin area)
45 if (is_admin()) {
46 Metasync_API_Backoff_Notices::get_instance();
47 }
48 }
49 add_action('init', 'metasync_init_api_backoff', 5);
50
51 /**
52 * Initialize Review Notice
53 * Shows a dismissible notice asking users to rate the plugin after a usage period
54 * @since 2.8.0
55 */
56 function metasync_init_review_notice() {
57 if (metasync_is_non_metasync_admin_ajax()) {
58 return;
59 }
60 if (is_admin()) {
61 Metasync_Review_Notice::get_instance();
62 }
63 }
64 add_action('init', 'metasync_init_review_notice');
65
66 /**
67 * Initialize Host Blocking Check
68 * Owns the shared GET/POST reachability probe, its post-activation + weekly crons,
69 * and the warning notice. Initialised unconditionally (not gated on is_admin) because
70 * the cron callbacks must be registered on WP-Cron requests, where is_admin() is false.
71 * @since 2.8.x
72 */
73 function metasync_init_host_blocking_check() {
74 if (metasync_is_non_metasync_admin_ajax()) {
75 return;
76 }
77 Metasync_Host_Blocking_Check::get_instance();
78 }
79 add_action('plugins_loaded', 'metasync_init_host_blocking_check');
80
81 /**
82 * Global convenience function to get active JWT token
83 * Can be called from anywhere in WordPress (themes, other plugins, etc.)
84 *
85 * @param bool $force_refresh Force generation of new token even if cached one exists
86 * @return string|false JWT token on success, false on failure
87 */
88 if (!function_exists('metasync_get_jwt_token')) {
89 function metasync_get_jwt_token($force_refresh = false)
90 {
91 return Metasync::get_jwt_token($force_refresh);
92 }
93 }
94
95
96 /**
97 * Initialize Debug Mode Manager
98 * Hooked to 'init' for proper WordPress lifecycle integration
99 */
100 function metasync_init_debug_mode_manager() {
101 if (metasync_is_non_metasync_admin_ajax()) {
102 return;
103 }
104 // Initialize the Debug Mode Manager singleton
105 Metasync_Debug_Mode_Manager::get_instance();
106 }
107 add_action('init', 'metasync_init_debug_mode_manager', 10);
108