wp_cache_ob_callback() │ WPSCache 1.0
Hooks from the function
Return
null
. Nothing (null).
Usage
wp_cache_ob_callback( $buffer );
- $buffer (required)
- -
wp_cache_ob_callback() wp cache ob callback code WPSCache 1.12.4
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_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers, $super_cache_enabled; $script = basename( $_SERVER['PHP_SELF'] ); // All the things that can stop a page being cached $cache_this_page = true; if ( wpsc_is_fatal_error() ) { wp_cache_debug( 'wp_cache_ob_callback: PHP Fatal error occurred. Not caching incomplete page.' ); $cache_this_page = false; } elseif ( empty( $wp_super_cache_query ) && ! empty( $buffer ) && is_object( $wp_query ) && method_exists( $wp_query, 'get' ) ) { $wp_super_cache_query = wp_super_cache_query_vars(); } elseif ( empty( $wp_super_cache_query ) && function_exists( 'http_response_code' ) ) { wpsc_catch_http_status_code( http_response_code() ); } $buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer ); if ( defined( 'DONOTCACHEPAGE' ) ) { wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 ); $cache_this_page = false; } elseif ( $wp_cache_no_cache_for_get && wpsc_is_get_query() ) { wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 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 ( $_SERVER['REQUEST_METHOD'] == 'PUT' ) { wp_cache_debug( 'Not caching PUT request.', 5 ); $cache_this_page = false; } elseif ( $_SERVER['REQUEST_METHOD'] == 'DELETE' ) { wp_cache_debug( 'Not caching DELETE request.', 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, (array) $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; } elseif ( isset( $wp_super_cache_query['is_rest'] ) ) { wp_cache_debug( 'REST API detected. Caching disabled.' ); $cache_this_page = false; } elseif ( isset( $wp_super_cache_query['is_robots'] ) ) { wp_cache_debug( 'robots.txt detected. Caching disabled.' ); $cache_this_page = false; } elseif ( isset( $wp_super_cache_query['is_redirect'] ) ) { wp_cache_debug( 'Redirect detected. Caching disabled.' ); $cache_this_page = false; } elseif ( isset( $wp_super_cache_query['is_304'] ) ) { wp_cache_debug( 'HTTP 304 (Not Modified) sent. Caching disabled.' ); $cache_this_page = false; } elseif ( empty( $wp_super_cache_query ) && ! empty( $buffer ) && apply_filters( 'wpsc_only_cache_known_pages', 1 ) ) { wp_cache_debug( 'wp_cache_ob_callback: wp_super_cache_query is empty. Not caching unknown page type. Return 0 to the wpsc_only_cache_known_pages filter to cache this page.' ); $cache_this_page = false; } elseif ( wpsc_is_caching_user_disabled() ) { wp_cache_debug( 'wp_cache_ob_callback: Caching disabled for known user. User logged in or cookie found.' ); $cache_this_page = false; } elseif ( wp_cache_user_agent_is_rejected() ) { wp_cache_debug( 'wp_cache_ob_callback: Caching disabled because user agent was rejected.' ); $cache_this_page = false; } if ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) { $super_cache_enabled = false; // use standard caching to record headers } if ( $cache_this_page ) { wp_cache_debug( 'Output buffer callback', 4 ); $buffer = wp_cache_get_ob( $buffer ); wp_cache_shutdown_callback(); if ( ! empty( $wpsc_file_mtimes ) && is_array( $wpsc_file_mtimes ) ) { foreach ( $wpsc_file_mtimes as $cache_file => $old_mtime ) { if ( $old_mtime == @filemtime( $cache_file ) ) { wp_cache_debug( "wp_cache_ob_callback deleting unmodified rebuilt cache file: $cache_file" ); if ( wp_cache_confirm_delete( $cache_file ) ) { @unlink( $cache_file ); } } } } return $buffer; } else { if ( ! empty( $do_rebuild_list ) && is_array( $do_rebuild_list ) ) { foreach ( $do_rebuild_list as $dir => $n ) { if ( wp_cache_confirm_delete( $dir ) ) { wp_cache_debug( 'wp_cache_ob_callback clearing rebuilt files in ' . $dir ); wpsc_delete_files( $dir ); } } } return wp_cache_maybe_dynamic( $buffer ); } }