wp_cache_phase2() WPSCache 1.0
Hooks from the function
Return
Null. Nothing.
Usage
wp_cache_phase2();
Code of wp_cache_phase2() wp cache phase2 WPSCache 1.7.1
function wp_cache_phase2() {
global $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset;
if ( $cache_enabled == false ) {
wp_cache_debug( 'wp_cache_phase2: Caching disabled! Exit' );
define( 'WPSCSHUTDOWNMESSAGE', __( 'Caching disabled. Page not cached.', 'wp-super-cache' ) );
add_action( 'wp_footer', 'wpsc_shutdown_message' );
return false;
}
if ( wp_cache_user_agent_is_rejected() ) {
wp_cache_debug( 'wp_cache_phase2: No caching to do as user agent rejected.' );
return false;
}
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. https://wordpress.org/support/topic/224349
$wp_cache_blog_charset = get_option( 'blog_charset' );
wp_cache_mutex_init();
if ( function_exists( 'add_action' ) && ( ! defined( 'WPLOCKDOWN' ) || constant( 'WPLOCKDOWN' ) == '0' ) ) {
wp_cache_debug( 'Setting up WordPress actions', 5 );
add_action( 'template_redirect', 'wp_super_cache_query_vars' );
add_filter( 'wp_redirect_status', 'wpsc_catch_http_status_code' );
add_filter( 'status_header', 'wpsc_catch_status_header', 10, 2 );
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
wpsc_register_post_hooks();
do_cacheaction( 'add_cacheaction' );
}
if ( wpsc_is_backend() ) {
wp_cache_debug( 'Not caching wp-admin requests.', 5 );
return false;
}
if ( ! empty( $_GET ) ) {
wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . wpsc_dump_get_request(), 5 );
$super_cache_enabled = false;
}
if ( defined( 'WPSC_VARY_HEADER' ) ) {
if ( WPSC_VARY_HEADER != '' ) {
header( 'Vary: ' . WPSC_VARY_HEADER );
}
} else {
header( 'Vary: Accept-Encoding, Cookie' );
}
ob_start( 'wp_cache_ob_callback' );
wp_cache_debug( 'Created output buffer', 4 );
// restore old supercache file temporarily
if ( ( $_SERVER['REQUEST_METHOD'] !== 'POST' && empty( $_POST ) ) && $super_cache_enabled && $cache_rebuild_files ) {
$user_info = wp_cache_get_cookies_values();
if( empty( $user_info )
|| true === apply_filters( 'do_createsupercache', $user_info )
) {
wpcache_do_rebuild( get_current_url_supercache_dir() );
}
}
schedule_wp_gc();
}