/i', ltrim( $page_contents ) ); $has_xsl_stylesheet = ( stripos( $page_contents, ' $value) { if ( preg_match( $cookies_regex, $key ) ) { return true; } } } return false; } /** * check if search page * * @return boolean true if search page, false otherwise */ private static function is_search() { if ( apply_filters( 'a2opt_cache_exclude_search', is_search() ) ) { return true; } return false; } /** * check if mobile template * * @return boolean true if mobile template, false otherwise */ private static function is_mobile() { return ( strpos( TEMPLATEPATH, 'wptouch' ) || strpos( TEMPLATEPATH, 'carrington' ) || strpos( TEMPLATEPATH, 'jetpack' ) || strpos( TEMPLATEPATH, 'handheld' ) ); } /** * check if cache should be bypassed * * @return boolean true if cache should be bypassed, false otherwise */ private static function bypass_cache() { // bypass cache hook if ( apply_filters( 'a2opt_cache_bypass_cache', false ) ) { return true; } // check request method if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || $_SERVER['REQUEST_METHOD'] !== 'GET' ) { return true; } // check HTTP status code if ( http_response_code() !== 200 ) { return true; } // check DONOTCACHEPAGE constant if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) { return true; } // check conditional tags if ( self::is_wrong_permalink_structure() || self::is_excluded() ) { return true; } // check conditional tags when output buffering has ended if ( class_exists( 'WP' ) ) { if ( is_admin() || self::is_search() || is_feed() || is_trackback() || is_robots() || is_preview() || post_password_required() || self::is_mobile() ) { return true; } } return false; } /** * deliver cache * * @return boolean false if cached page was not delivered */ public static function deliver_cache() { if ( A2_Optimized_Cache_Disk::cache_exists() && ! A2_Optimized_Cache_Disk::cache_expired() && ! self::bypass_cache() ) { readfile( A2_Optimized_Cache_Disk::get_cache() ); exit; } return false; } }