processRedirectAllRequests(); return; } /** If we're currently redirecting to a custom 404 page and we are about to show page * suggestions then update the URL displayed to the user. */ $cookieName = ABJ404_PP . '_REQUEST_URI'; $cookieName .= '_UPDATE_URL'; if (isset($_COOKIE[$cookieName]) && !empty($_COOKIE[$cookieName])) { $cookieName404 = ABJ404_PP . '_STATUS_404'; if (array_key_exists($cookieName404, $_COOKIE) && $_COOKIE[$cookieName404] == 'true') { // clear the cookie setcookie($cookieName404, 'false', time() - 5, "/"); // we're going to a custom 404 page so se the status to 404. status_header(404); } if (array_key_exists('update_suggest_url', $options) && isset($options['update_suggest_url']) && $options['update_suggest_url'] == 1) { // clear the cookie $_REQUEST[$cookieName] = $_COOKIE[$cookieName]; setcookie($cookieName, '', time() - 5, "/"); require_once(plugin_dir_path( __FILE__ ) . "includes/Loader.php"); add_action('wp_head', 'ABJ_404_Solution_ShortCode::updateURLbarIfNecessary'); } } } if (!is_404() || is_admin()) { return; } require_once(plugin_dir_path( __FILE__ ) . "includes/Loader.php"); $connector = ABJ_404_Solution_WordPress_Connector::getInstance(); return $connector->process404(); } function abj404_dailyMaintenanceCronJobListener() { require_once(plugin_dir_path( __FILE__ ) . "includes/Loader.php"); $abj404dao = ABJ_404_Solution_DataAccess::getInstance(); $abj404dao->deleteOldRedirectsCron(); } function abj404_updateLogsHitsTableListener() { require_once(plugin_dir_path( __FILE__ ) . "includes/Loader.php"); $abj404dao = ABJ_404_Solution_DataAccess::getInstance(); $abj404dao->createRedirectsForViewHitsTable(); } function abj404_updatePermalinkCacheListener($maxExecutionTime, $executionCount = 1) { require_once(plugin_dir_path( __FILE__ ) . "includes/Loader.php"); $permalinkCache = ABJ_404_Solution_PermalinkCache::getInstance(); $permalinkCache->updatePermalinkCache($maxExecutionTime, $executionCount); } add_action('abj404_cleanupCronAction', 'abj404_dailyMaintenanceCronJobListener'); add_action('abj404_updateLogsHitsTableAction', 'abj404_updateLogsHitsTableListener'); add_action('abj404_updatePermalinkCacheAction', 'abj404_updatePermalinkCacheListener', 10, 2); function abj404_getUploadsDir() { // figure out the temp directory location. $uploadsDirArray = wp_upload_dir(null, false); $uploadsDir = $uploadsDirArray['basedir']; $uploadsDir .= DIRECTORY_SEPARATOR . 'temp_' . ABJ404_PP . DIRECTORY_SEPARATOR; return $uploadsDir; } /** This only runs after WordPress is done enqueuing scripts. */ function abj404_loadSomethingWhenWordPressIsReady() { // make debugging easier on localhost etc $serverName = '(not found)'; if (array_key_exists('SERVER_NAME', $_SERVER) && isset($_SERVER['SERVER_NAME'])) { $serverName = $_SERVER['SERVER_NAME']; } $whiteList = $GLOBALS['abj404_whitelist']; $serverNameIsInTheWhiteList = in_array($serverName, $whiteList); $userIsAnAdminUser = function_exists('wp_get_current_user') && current_user_can('administrator'); if ($serverNameIsInTheWhiteList && $userIsAnAdminUser) { $GLOBALS['abj404_display_errors'] = true; } } add_action('init', 'abj404_loadSomethingWhenWordPressIsReady');