' . esc_html__('Multipify SEO Boost requires PHP 8.0 or later. The plugin is disabled.', 'multipify-seo-boost') . '

'); }); return; } /** mbstring is not guaranteed on shared hosting; avoid fatal undefined-function errors. */ function mpseo_lower($s) { return function_exists('mb_strtolower') ? mb_strtolower((string) $s, 'UTF-8') : strtolower((string) $s); } /** Explicit module list with guarded bootstrap and persistent emergency safe mode. */ function mpseo_752_log_failure($e, $stage) { $failure = array('time'=>time(), 'stage'=>$stage, 'message'=>substr($e->getMessage(),0,500), 'file'=>basename($e->getFile()), 'line'=>$e->getLine()); update_option('mpseo_emergency_safe_mode', $failure, false); // Failure details are retained in the emergency safe-mode option; avoid logging paths and secrets. } function mpseo_752_load_modules() { $files = glob(MPSEO_DIR . 'includes/*.php'); if (!is_array($files) || !$files) throw new RuntimeException(esc_html__('Multipify SEO Boost modules not found', 'multipify-seo-boost')); sort($files); foreach ($files as $file) require_once $file; if (!class_exists('MPSEO_Core') || !class_exists('MPSEO_V70_Bulk_Actions')) throw new RuntimeException(esc_html__('Main module missing', 'multipify-seo-boost')); } function mpseo_752_bootstrap() { // Performance: load every option read on the front end with a single query (missing ones are cached as absent). if (function_exists('wp_prime_option_caches')) wp_prime_option_caches(['mpseo_emergency_safe_mode','mpseo_settings','mpseo_plan','mpseo_redirect_db_version','mpseo_v39_automations','mpseo_access_caps_version','mpseo_v49_db','mpseo_sitemap_configuration','mpseo_redirect_cache_version','mpseo_redirect_counts','mpseo_v31_technical','mpseo_templates','mpseo_v38_schema_archives','mpseo_access_roles']); if (get_option('mpseo_emergency_safe_mode', false)) return; try { mpseo_752_load_modules(); if (function_exists('mpseo_prefix_migrate')) mpseo_prefix_migrate(); MPSEO_V70_Bulk_Actions::init(); MPSEO_Core::init(); MPSEO_V789_Editor_Guidance::init(); MPSEO_V790_Product_Audit::init(); MPSEO_V793_Title_Suffix::init(); MPSEO_V761_List_Scores::init(); MPSEO_V763_Score_Index::init(); MPSEO_V773_Term_Index::init(); MPSEO_V800_Studio::init(); MPSEO_V801_Llms::init(); MPSEO_V802_Cleanup::init(); MPSEO_V803_Editor_Sidebar::init(); MPSEO_V804_Live_Score::init(); MPSEO_V805_Archive_Meta::init(); MPSEO_V806_I18n::init(); } catch (Throwable $e) { mpseo_752_log_failure($e, 'initialization'); } } add_action('plugins_loaded', 'mpseo_752_bootstrap', 20); /** No class references until modules have been loaded. */ register_activation_hook(MPSEO_FILE, function () { delete_option('mpseo_emergency_safe_mode'); try { mpseo_752_load_modules(); if (function_exists('mpseo_prefix_migrate')) mpseo_prefix_migrate(); MPSEO_Core::activate(); } catch (Throwable $e) { mpseo_752_log_failure($e, 'activation'); // Do not fail the entire WordPress request: leave the plugin in safe mode. } }); register_deactivation_hook(MPSEO_FILE, function () { if (class_exists('MPSEO_Core')) MPSEO_Core::deactivate(); }); add_action('admin_notices', function () { if (!current_user_can('manage_options')) return; $failure = get_option('mpseo_emergency_safe_mode', false); if (!$failure) return; echo ('

' . esc_html__('Multipify SEO Boost is in safe mode.', 'multipify-seo-boost') . ' ' . esc_html__('A module failed:', 'multipify-seo-boost') . ' ') . esc_html(($failure['stage']??'') . ' / ' . ($failure['file']??'') . ' : ' . ($failure['message']??'')) . '. ' . esc_html__('The SEO engine is disabled to protect the site.', 'multipify-seo-boost') . '

'; });