/** Diable here because PHP4.3 does not make the global Serious bug? $mutex_filename = 'wp_cache_mutex.lock'; $new_cache = false; */ function wp_cache_phase2() { global $cache_filename, $cache_acceptable_files; wp_cache_mutex_init(); if (function_exists('add_action')) { // Post ID is received add_action('publish_post', 'wp_cache_post_change', 0); add_action('edit_post', 'wp_cache_post_change', 0); add_action('delete_post', 'wp_cache_post_change', 0); add_action('publish_phone', 'wp_cache_post_change', 0); // Coment ID is received add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0); add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0); add_action('comment_post', 'wp_cache_get_postid_from_comment', 0); add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0); add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0); // No post_id is available add_action('delete_comment', 'wp_cache_no_postid', 0); add_action('switch_theme', 'wp_cache_no_postid', 0); } //$script = basename($_SERVER['SCRIPT_NAME']); if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_settings('gzipcompression')) { return; } $script = basename($_SERVER['PHP_SELF']); if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) { return; } if (wp_cache_user_agent_is_rejected()) { return; } ob_start('wp_cache_ob_callback'); register_shutdown_function('wp_cache_ob_end'); }
/** Diable here because PHP4.3 does not make the global Serious bug? $mutex_filename = 'wp_cache_mutex.lock'; $new_cache = false; */ function wp_cache_phase2() { global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object; wp_cache_mutex_init(); if (function_exists('add_action')) { // Post ID is received add_action('publish_post', 'wp_cache_post_change', 0); add_action('edit_post', 'wp_cache_post_change', 0); add_action('delete_post', 'wp_cache_post_change', 0); add_action('publish_phone', 'wp_cache_post_change', 0); // Coment ID is received add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0); add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0); add_action('comment_post', 'wp_cache_get_postid_from_comment', 0); add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0); add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0); // No post_id is available add_action('delete_comment', 'wp_cache_no_postid', 0); add_action('switch_theme', 'wp_cache_no_postid', 0); } //$script = basename($_SERVER['SCRIPT_NAME']); if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_settings('gzipcompression')) { return; } $script = basename($_SERVER['PHP_SELF']); if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) { return; } if (wp_cache_user_agent_is_rejected()) { return; } if (is_user_logged_in()) { return; } // don't cache pages of logged in users, that is lame. foreach ($_COOKIE as $key => $val) { if (strstr($key, 'comment_author')) { return; // don't perform caching of pages that commenters see, that is lame } } $wp_cache_meta_object = new CacheMeta(); ob_start('wp_cache_ob_callback'); register_shutdown_function('wp_cache_shutdown_callback'); }
function wp_cache_phase2() { global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc; global $cache_max_time, $wp_cache_not_logged_in, $wp_cache_request_uri, $super_cache_enabled; if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('In WP Cache Phase 2', 5); } $wp_cache_gmt_offset = get_option('gmt_offset'); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349 $wp_cache_blog_charset = get_option('blog_charset'); wp_cache_mutex_init(); if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Setting up WordPress actions', 5); } // Post ID is received add_action('publish_post', 'wp_cache_post_edit', 0); add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post add_action('delete_post', 'wp_cache_post_edit', 0); add_action('publish_phone', 'wp_cache_post_edit', 0); // Coment ID is received add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99); add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99); add_action('comment_post', 'wp_cache_get_postid_from_comment', 99); add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99); add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2); // No post_id is available add_action('switch_theme', 'wp_cache_no_postid', 99); add_action('edit_user_profile_update', 'wp_cache_no_postid', 99); add_action('wp_cache_gc', 'wp_cache_gc_cron'); do_cacheaction('add_cacheaction'); } if (is_admin()) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching wp-admin requests.', 5); } return false; } if ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching POST request.', 5); } return false; } if (isset($_GET['preview'])) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching preview post.', 2); } return false; } if (!empty($_GET)) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Supercache caching disabled. Non empty GET request.', 5); } $super_cache_enabled = false; } if ($wp_cache_not_logged_in && is_user_logged_in() && !is_feed() && !is_admin()) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('not caching for logged in user', 5); register_shutdown_function('wpcache_logged_in_message'); } return false; } $script = basename($_SERVER['PHP_SELF']); if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('URI rejected. Not Caching', 2); } return false; } if (wp_cache_user_agent_is_rejected()) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4); } return; } if ($wp_cache_gzip_encoding) { header('Vary: Accept-Encoding, Cookie'); } else { header('Vary: Cookie'); } ob_start('wp_cache_ob_callback'); if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Created output buffer', 4); } // restore old supercache file temporarily if ($super_cache_enabled && $cache_rebuild_files) { $user_info = wp_cache_get_cookies_values(); $do_cache = apply_filters('do_createsupercache', $user_info); if ($user_info == '' || $do_cache === true) { $dir = get_current_url_supercache_dir(); $files_to_check = array($dir . 'index.html', $dir . 'index.html.gz'); foreach ($files_to_check as $cache_file) { if (!@file_exists($cache_file . '.needs-rebuild')) { continue; } $mtime = @filemtime($cache_file . '.needs-rebuild'); if ($mtime && time() - $mtime < 30) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Rebuild file renamed to cache file temporarily", 3); } @rename($cache_file . '.needs-rebuild', $cache_file); } // cleanup old files or if rename fails if (@file_exists($cache_file . '.needs-rebuild')) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Rebuild file deleted", 3); } @unlink($cache_file . '.needs-rebuild'); } } } } if (!isset($cache_max_time)) { $cache_max_time = 600; } $last_gc = get_option("wpsupercache_gc_time"); if (!$last_gc) { update_option('wpsupercache_gc_time', time()); } $next_gc = $cache_max_time < 1800 ? $cache_max_time : 600; if ($last_gc < time() - $next_gc) { update_option('wpsupercache_gc_time', time()); global $wp_cache_shutdown_gc; if (!isset($wp_cache_shutdown_gc) || $wp_cache_shutdown_gc == 0) { if (!wp_next_scheduled('wp_cache_gc')) { wp_schedule_single_event(time() + 10, 'wp_cache_gc'); if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('scheduled wp_cache_gc for 10 seconds time.', 5); } } } else { global $time_to_gc_cache; $time_to_gc_cache = 1; // tell the "shutdown gc" to run! } } }
function wp_cache_phase2() { global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc; global $cache_max_time; $wp_cache_gmt_offset = get_option('gmt_offset'); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349 $wp_cache_blog_charset = get_option('blog_charset'); wp_cache_mutex_init(); if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) { // Post ID is received add_action('publish_post', 'wp_cache_post_edit', 0); add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post add_action('delete_post', 'wp_cache_post_edit', 0); add_action('publish_phone', 'wp_cache_post_edit', 0); // Coment ID is received add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99); add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99); add_action('comment_post', 'wp_cache_get_postid_from_comment', 99); add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99); add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99); // No post_id is available add_action('delete_comment', 'wp_cache_no_postid', 99); add_action('switch_theme', 'wp_cache_no_postid', 99); add_action('wp_cache_gc', 'wp_cache_gc_cron'); do_cacheaction('add_cacheaction'); } if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression')) { return; } $script = basename($_SERVER['PHP_SELF']); if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) { return; } if (wp_cache_user_agent_is_rejected()) { return; } if ($wp_cache_gzip_encoding) { header('Vary: Accept-Encoding, Cookie'); } else { header('Vary: Cookie'); } ob_start('wp_cache_ob_callback'); // restore old supercache file temporarily if ($super_cache_enabled && $cache_rebuild_files) { $user_info = wp_cache_get_cookies_values(); $do_cache = apply_filters('do_createsupercache', $user_info); if ($user_info == '' || $do_cache === true) { $dir = get_current_url_supercache_dir(); $files_to_check = array($dir . 'index.html', $dir . 'index.html.gz'); foreach ($files_to_check as $cache_file) { if (!@file_exists($cache_file . '.needs-rebuild')) { continue; } $mtime = @filemtime($cache_file . '.needs-rebuild'); if ($mtime && time() - $mtime < 30) { @rename($cache_file . '.needs-rebuild', $cache_file); } // cleanup old files or if rename fails if (@file_exists($cache_file . '.needs-rebuild')) { @unlink($cache_file . '.needs-rebuild'); } } } } if (!isset($cache_max_time)) { $cache_max_time = 600; } $last_gc = get_option("wpsupercache_gc_time"); if (!$last_gc) { update_option('wpsupercache_gc_time', time()); } $next_gc = $cache_max_time < 1800 ? $cache_max_time : 600; if ($last_gc < time() - $next_gc) { update_option('wpsupercache_gc_time', time()); global $wp_cache_shutdown_gc; if (!isset($wp_cache_shutdown_gc) || $wp_cache_shutdown_gc == 0) { if (!wp_next_scheduled('wp_cache_gc')) { wp_schedule_single_event(time() + 10, 'wp_cache_gc'); } } else { global $time_to_gc_cache; $time_to_gc_cache = 1; // tell the "shutdown gc" to run! } } }
function wp_cache_phase2() { global $wpsc_settings; global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_last_gc; global $cache_max_time, $wp_cache_request_uri, $super_cache_enabled, $wp_cache_object_cache, $cache_time_interval; global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval; if ($cache_enabled == false) { return false; } if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('In WP Cache Phase 2', 5); } $wp_cache_gmt_offset = get_option('gmt_offset'); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349 $wp_cache_blog_charset = get_option('blog_charset'); wp_cache_mutex_init(); if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Setting up WordPress actions', 5); } // Post ID is received add_action('publish_post', 'wp_cache_post_edit', 0); add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post add_action('delete_post', 'wp_cache_post_edit', 0); add_action('publish_phone', 'wp_cache_post_edit', 0); // Coment ID is received add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99); add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99); add_action('comment_post', 'wp_cache_get_postid_from_comment', 99); add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99); add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2); // No post_id is available add_action('switch_theme', 'wp_cache_no_postid', 99); add_action('edit_user_profile_update', 'wp_cache_no_postid', 99); add_action('wp_update_nav_menu', 'wp_cache_clear_cache'); add_action('wp_cache_gc', 'wp_cache_gc_cron'); add_filter('supercache_filename_str', 'wp_cache_check_mobile'); do_cacheaction('add_cacheaction'); } if (is_admin()) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching wp-admin requests.', 5); } return false; } if ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching POST request.', 5); } return false; } if ($wp_cache_object_cache && !empty($_GET)) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching GET request while object cache storage enabled.', 5); } return false; } if (isset($_GET['preview'])) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Not caching preview post.', 2); } return false; } if (!empty($_GET)) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Supercache caching disabled. Only using wp-cache. Non empty GET request.', 5); } $super_cache_enabled = false; } $script = basename($_SERVER['PHP_SELF']); if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('URI rejected. Not Caching', 2); } return false; } if (wp_cache_user_agent_is_rejected()) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4); } return; } if ($wp_cache_gzip_encoding) { header('Vary: Accept-Encoding, Cookie'); } else { header('Vary: Cookie'); } ob_start('wp_cache_ob_callback'); if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug('Created output buffer', 4); } // restore old supercache file temporarily if ($super_cache_enabled && $cache_rebuild_files) { $user_info = wp_cache_get_cookies_values(); $do_cache = apply_filters('do_createsupercache', $user_info); if ($user_info == '' || $do_cache === true) { wpcache_do_rebuild(get_current_url_supercache_dir()); } } schedule_wp_gc(); }
function wp_cache_ob_callback($buffer) { global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_object_cache, $wp_cache_request_uri; $buffer = apply_filters('wp_cache_ob_callback_filter', $buffer); $script = basename($_SERVER['PHP_SELF']); // All the things that can stop a page being cached $cache_this_page = true; if (defined('DONOTCACHEPAGE')) { wp_cache_debug('DONOTCACHEPAGE defined. Caching disabled.', 2); $cache_this_page = false; } elseif ($wp_cache_no_cache_for_get && false == empty($_GET) && false == defined('DOING_CRON')) { wp_cache_debug("Non empty GET request. Caching disabled on settings page. " . serialize($_GET), 1); $cache_this_page = false; } elseif ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) { wp_cache_debug('Not caching POST request.', 5); $cache_this_page = false; } elseif ($wp_cache_object_cache && !empty($_GET)) { wp_cache_debug('Not caching GET request while object cache storage enabled.', 5); $cache_this_page = false; } elseif (isset($_GET['preview'])) { wp_cache_debug('Not caching preview post.', 2); $cache_this_page = false; } elseif (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) { wp_cache_debug('URI rejected. Not Caching', 2); $cache_this_page = false; } elseif (wp_cache_user_agent_is_rejected()) { wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4); $cache_this_page = false; } elseif (isset($wp_cache_pages['single']) && $wp_cache_pages['single'] == 1 && isset($wp_super_cache_query['is_single'])) { wp_cache_debug('Not caching single post.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['pages']) && $wp_cache_pages['pages'] == 1 && isset($wp_super_cache_query['is_page'])) { wp_cache_debug('Not caching single page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['archives']) && $wp_cache_pages['archives'] == 1 && isset($wp_super_cache_query['is_archive'])) { wp_cache_debug('Not caching archive page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['tag']) && $wp_cache_pages['tag'] == 1 && isset($wp_super_cache_query['is_tag'])) { wp_cache_debug('Not caching tag page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['category']) && $wp_cache_pages['category'] == 1 && isset($wp_super_cache_query['is_category'])) { wp_cache_debug('Not caching category page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['frontpage']) && $wp_cache_pages['frontpage'] == 1 && isset($wp_super_cache_query['is_front_page'])) { wp_cache_debug('Not caching front page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['home']) && $wp_cache_pages['home'] == 1 && isset($wp_super_cache_query['is_home'])) { wp_cache_debug('Not caching home page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['search']) && $wp_cache_pages['search'] == 1 && isset($wp_super_cache_query['is_search'])) { wp_cache_debug('Not caching search page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['author']) && $wp_cache_pages['author'] == 1 && isset($wp_super_cache_query['is_author'])) { wp_cache_debug('Not caching author page.', 2); $cache_this_page = false; } elseif (isset($wp_cache_pages['feed']) && $wp_cache_pages['feed'] == 1 && isset($wp_super_cache_query['is_feed'])) { wp_cache_debug('Not caching feed.', 2); $cache_this_page = false; } if (!isset($wp_query)) { wp_cache_debug('wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4); } if ($cache_this_page) { wp_cache_debug('Output buffer callback', 4); $buffer = wp_cache_get_ob($buffer); wp_cache_shutdown_callback(); return $buffer; } else { return wp_cache_maybe_dynamic($buffer); } }
function wp_cache_phase2() { global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files; wp_cache_mutex_init(); if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) { // Post ID is received add_action('publish_post', 'wp_cache_post_edit', 0); add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post add_action('delete_post', 'wp_cache_post_edit', 0); add_action('publish_phone', 'wp_cache_post_edit', 0); // Coment ID is received add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0); add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0); add_action('comment_post', 'wp_cache_get_postid_from_comment', 0); add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0); add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0); // No post_id is available add_action('delete_comment', 'wp_cache_no_postid', 0); add_action('switch_theme', 'wp_cache_no_postid', 0); add_action('wp_cache_gc', 'wp_cache_gc_cron'); do_cacheaction('add_cacheaction'); } if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression')) { return; } $script = basename($_SERVER['PHP_SELF']); if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) { return; } if (wp_cache_user_agent_is_rejected()) { return; } if (!is_object($wp_cache_meta_object)) { $wp_cache_meta_object = new CacheMeta(); } if ($wp_cache_gzip_encoding) { header('Vary: Accept-Encoding, Cookie'); } else { header('Vary: Cookie'); } ob_start('wp_cache_ob_callback'); // restore old supercache file temporarily if ($super_cache_enabled && $cache_rebuild_files) { $user_info = wp_cache_get_cookies_values(); $do_cache = apply_filters('do_createsupercache', $user_info); if ($user_info == '' || $do_cache === true) { $dir = get_current_url_supercache_dir(); $files_to_check = array($dir . 'index.html', $dir . 'index.html.gz'); foreach ($files_to_check as $cache_file) { if (!file_exists($cache_file . '.needs-rebuild')) { continue; } $mtime = @filemtime($cache_file . '.needs-rebuild'); if ($mtime && time() - $mtime < 30) { @rename($cache_file . '.needs-rebuild', $cache_file); } // cleanup old files or if rename fails if (@file_exists($cache_file . '.needs-rebuild')) { @unlink($cache_file . '.needs-rebuild'); } } } } register_shutdown_function('wp_cache_shutdown_callback'); }