| @@ -164,8 +164,18 @@ | ||
| 164 | 164 | } else { |
| 165 | 165 | error_log('MetaSync Google Index: google-index-init.php not found at ' . plugin_dir_path(dirname(__FILE__)) . 'google-index/google-index-init.php'); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | + // The SEO precedence resolver is referenced statically from the render | |
| 169 | + // filters, the sync layer and four admin screens. Require it explicitly | |
| 170 | + // for the same reason as the admin navigation below: a partial update can | |
| 171 | + // leave newer PHP files beside an older committed autoload classmap, and | |
| 172 | + // a missing class on wp_head or the posts list is a fatal, not a | |
| 173 | + // degradation. | |
| 174 | + if (!class_exists('Metasync_Seo_Precedence')) { | |
| 175 | + require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-metasync-seo-precedence.php'; | |
| 176 | + } | |
| 177 | + | |
| 168 | 178 | // Admin navigation is referenced statically from frontend-reachable |
| 169 | 179 | // includes (heartbeat/connect managers). Require it explicitly here so |
| 170 | 180 | // the static call never fatals when wp_head fires before autoload. |
| 171 | 181 | if (!class_exists('Metasync_Admin_Navigation')) { |
| @@ -171,9 +181,17 @@ | ||
| 171 | 181 | if (!class_exists('Metasync_Admin_Navigation')) { |
| 172 | 182 | require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-metasync-admin-navigation.php'; |
| 173 | 183 | } |
| 174 | 184 | |
| 185 | + // Hooked on init at priority 0, before any theme or plugin callback | |
| 186 | + // runs, so it cannot wait for a lazy autoload. See define_public_hooks. | |
| 187 | + if (!class_exists('Metasync_BookingPress_Compat')) { | |
| 188 | + require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-metasync-bookingpress-compat.php'; | |
| 189 | + } | |
| 190 | + | |
| 175 | 191 | $this->loader = new Metasync_Loader(); |
| 192 | + // Install aggregate-option password protection in every runtime context. | |
| 193 | + Metasync_Settings_Registration::instance(); | |
| 176 | 194 | $this->db_heartbeat_errors = new Metasync_HeartBeat_Error_Monitor_Database(); |
| 177 | 195 | $this->db_redirection = new Metasync_Redirection_Database(); |
| 178 | 196 | } |
| 179 | 197 | |
| @@ -410,8 +428,16 @@ | ||
| 410 | 428 | |
| 411 | 429 | // Edge Cache: detect Cloudways Varnish and persist for settings UI |
| 412 | 430 | $this->loader->add_action('init', 'Metasync_Edge_Cache_Purge', 'detect_cloudways'); |
| 413 | 431 | |
| 432 | + // BookingPress starts a PHP session on every front-end request (init | |
| 433 | + // at priority 1), which makes hosts skip page caching site-wide. Its | |
| 434 | + // booking flows manage their own sessions inside their AJAX handlers, | |
| 435 | + // so unhook the global start. Priority 0 keeps this ahead of theirs. | |
| 436 | + // Registered with add_action directly (like Metasync_Oxygen_Compat) | |
| 437 | + // because the loader's $component parameter is typed to objects. | |
| 438 | + add_action('init', ['Metasync_BookingPress_Compat', 'neutralize_bookingpress_session'], 0); | |
| 439 | + | |
| 414 | 440 | // Sitemap exclusions for disabled archive types |
| 415 | 441 | $this->loader->add_filter('wp_sitemaps_taxonomies', $seo_output, 'filter_sitemap_taxonomies'); |
| 416 | 442 | $this->loader->add_filter('wp_sitemaps_users_entry', $seo_output, 'filter_sitemap_users', 10, 2); |
| 417 | 443 | $this->loader->add_filter('wp_sitemaps_add_provider', $seo_output, 'filter_sitemap_providers', 10, 2); |
| @@ -502,8 +528,22 @@ | ||
| 502 | 528 | // Serve the IndexNow key file virtually at /{key}.txt so it works |
| 503 | 529 | // on read-only web roots and nginx hosts that 403 direct static .txt access. |
| 504 | 530 | require_once plugin_dir_path(dirname(__FILE__)) . 'bing-index/class-metasync-bing-instant-index.php'; |
| 505 | 531 | add_action('template_redirect', array('Metasync_Bing_Instant_Index', 'serve_virtual_key_file'), 0); |
| 532 | + | |
| 533 | + // Scheduled IndexNow submissions, deferred from save_post so a slow | |
| 534 | + // IndexNow round-trip cannot stall the editor or REST write. Registered | |
| 535 | + // statically because the class is loaded but never instantiated on | |
| 536 | + // cron loads. The hook name matches the uninstall cron sweep exactly. | |
| 537 | + add_action('metasync_bing_indexnow_submit_event', array('Metasync_Bing_Instant_Index', 'run_scheduled_submit'), 10, 1); | |
| 538 | + | |
| 539 | + // Construct the robots.txt manager on the public load path so its | |
| 540 | + // `robots_txt` filter is registered before a plain GET /robots.txt is | |
| 541 | + // served. The filter is attached in the singleton's constructor, and | |
| 542 | + // previously only admin screens built the instance — so the virtual | |
| 543 | + // robots.txt rules and sitemap lines never rendered on the frontend. | |
| 544 | + require_once plugin_dir_path(dirname(__FILE__)) . 'robots-txt/class-metasync-robots-txt.php'; | |
| 545 | + Metasync_Robots_Txt::get_instance(); | |
| 506 | 546 | |
| 507 | 547 | // One-time upgrade: regenerate sitemap to remove any Beaver Builder template entries |
| 508 | 548 | if ( ! get_option( 'metasync_sitemap_bb_exclusion_applied' ) ) { |
| 509 | 549 | $this->loader->add_action('init', $this, 'maybe_regenerate_sitemap_after_upgrade'); |