0) { set_transient('abj404_runtime_missing_files', $missingRuntimeFiles, $ttlSeconds); } else { delete_transient('abj404_runtime_missing_files'); } set_transient('abj404_runtime_integrity_checked', 1, $ttlSeconds); } } /** This only runs after WordPress is done enqueuing scripts. */ if (!function_exists('abj404_loadSomethingWhenWordPressIsReady')) { /** @return void */ function abj404_loadSomethingWhenWordPressIsReady() { // If boot failed (missing files), skip all init that depends on plugin classes. if (!$GLOBALS['abj404_boot_ok']) { return; } $isAdminRequest = is_admin(); if ($isAdminRequest) { abj404_load_textdomain_if_needed(); } // make debugging easier on localhost etc if ($isAdminRequest) { $serverNameRaw = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : (array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : '(not found)'); $serverName = is_scalar($serverNameRaw) ? (string)$serverNameRaw : '(not found)'; $whitelist = isset($GLOBALS['abj404_whitelist']) && is_array($GLOBALS['abj404_whitelist']) ? $GLOBALS['abj404_whitelist'] : array(); $serverNameIsInTheWhiteList = in_array($serverName, $whitelist); // Keep localhost debug helper on admin screens only; frontend requests stay lean. if ($serverNameIsInTheWhiteList && function_exists('wp_get_current_user')) { require_once(plugin_dir_path( ABJ404_FILE ) . "includes/Loader.php"); if (abj_service('admin_access_policy')->isPluginAdmin()) { $GLOBALS['abj404_display_errors'] = true; } } } $action = null; if ($isAdminRequest) { $actionGet = ABJ_404_Solution_RequestInputNormalizer::readText($_GET, array('name' => 'action')); $actionPost = ABJ_404_Solution_RequestInputNormalizer::readText($_POST, array('name' => 'action')); if ($actionGet !== '') { $action = $actionGet; } else if ($actionPost !== '') { $action = $actionPost; } else { $action = null; } } if ($isAdminRequest && abj404_is_local_debug_host() && abj404_current_user_is_plugin_admin() && isset($_GET['abj404_set_sim_db_ms'])) { $nonce = isset($_GET['_wpnonce']) && is_string($_GET['_wpnonce']) ? $_GET['_wpnonce'] : ''; $nonceOk = $nonce !== '' ? wp_verify_nonce($nonce, 'abj404_set_sim_db_ms') : false; if ($nonceOk) { $simMsRaw = $_GET['abj404_set_sim_db_ms']; $newMs = max(0, min(5000, absint(is_scalar($simMsRaw) ? $simMsRaw : 0))); update_option('abj404_simulated_db_latency_ms', $newMs, false); } } // An admin-only link on the front-end suggestions page can ask to open a // field that only exists in Advanced Mode. Honour it before the page // renders, so the field is there when the browser jumps to the anchor. // The literal must stay in step with SettingsModeDeepLink::QUERY_ARG; it is // spelled out here so the guard costs nothing on requests that do not // carry it (the class is not loaded until it is). if ($isAdminRequest && isset($_GET['abj404_show_advanced'])) { require_once(plugin_dir_path( ABJ404_FILE ) . "includes/Loader.php"); ABJ_404_Solution_SettingsModeDeepLink::applyIfRequested(); } $ttl = defined('HOUR_IN_SECONDS') ? (12 * HOUR_IN_SECONDS) : 43200; abj404_maybe_refresh_runtime_integrity_cache($ttl); if ($isAdminRequest && $action === 'exportRedirects' && abj404_current_user_is_plugin_admin()) { require_once(plugin_dir_path( ABJ404_FILE ) . "includes/Loader.php"); $abj404logic = ABJ_404_Solution_PluginLogic::getInstance(); $abj404logic->adminActions()->handleActionExport(); } } }