wp_cache_phase2()
Hooks from the function
Returns
null. Nothing (null).
Usage
wp_cache_phase2();
wp_cache_phase2() wp cache phase2 code WPSCache 3.1.0
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;
}
if ( ob_get_level() > 1 ) {
global $wp_super_cache_late_init;
wp_cache_debug( '***********************************************************************************' );
wp_cache_debug( '* An extra output buffer has been detected. Check your plugins, themes, *' );
wp_cache_debug( '* mu-plugins, and other custom code as this may interfere with caching. *' );
if ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init ) {
wp_cache_debug( '* Late init is enabled. This allows third-party code to run before WP Super Cache *' );
wp_cache_debug( '* sets up an output buffer. That code may have set up the output buffer. *' );
}
wp_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. 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 ( wpsc_is_get_query() ) {
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();
}