forked from Automattic/wp-super-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-cache-phase1.php
106 lines (79 loc) · 2.8 KB
/
wp-cache-phase1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
require_once dirname( __FILE__ ) . '/wp-cache-phase2.php';
// error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
if ( ! @include WP_CONTENT_DIR . '/wp-cache-config.php' ) {
return false;
}
if ( ! defined( 'WPCACHEHOME' ) ) {
define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
}
if ( defined( 'DISABLE_SUPERCACHE' ) ) {
wp_cache_debug( 'DISABLE_SUPERCACHE set, super_cache disabled.' );
$super_cache_enabled = 0;
}
require WPCACHEHOME . 'wp-cache-base.php';
if ( $blogcacheid != '' ) {
$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
} else {
$blog_cache_dir = $cache_path;
}
$wp_cache_phase1_loaded = true;
$mutex_filename = 'wp_cache_mutex.lock';
$new_cache = false;
if ( ! isset( $wp_cache_plugins_dir ) ) {
$wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
}
if ( isset( $_GET['donotcachepage'] ) && isset( $cache_page_secret ) && $_GET['donotcachepage'] == $cache_page_secret ) {
$cache_enabled = false;
define( 'DONOTCACHEPAGE', 1 );
}
$plugins = glob( $wp_cache_plugins_dir . '/*.php' );
if ( is_array( $plugins ) ) {
foreach ( $plugins as $plugin ) {
if ( is_file( $plugin ) ) {
require_once $plugin;
}
}
}
$wp_start_time = microtime();
if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
return true;
}
if ( isset( $wp_cache_make_known_anon ) && $wp_cache_make_known_anon ) {
wp_supercache_cache_for_admins();
}
do_cacheaction( 'cache_init' );
if ( ! $cache_enabled || ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {
return true;
}
$file_expired = false;
$cache_filename = '';
$meta_file = '';
$wp_cache_gzip_encoding = '';
$gzipped = 0;
$gzsize = 0;
if ( $cache_compression ) {
$wp_cache_gzip_encoding = gzip_accepted();
}
add_cacheaction( 'supercache_filename_str', 'wp_cache_check_mobile' );
if ( function_exists( 'add_filter' ) ) { // loaded since WordPress 4.6
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
}
$wp_cache_request_uri = $_SERVER['REQUEST_URI']; // Cache this in case any plugin modifies it.
if ( $wp_cache_object_cache ) {
if ( ! include_once WP_CONTENT_DIR . '/object-cache.php' ) {
return;
}
wp_cache_init(); // Note: wp-settings.php calls wp_cache_init() which clobbers the object made here.
if ( ! is_object( $wp_object_cache ) ) {
return;
}
}
if ( defined( 'DOING_CRON' ) ) {
extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
return true;
}
if ( ! isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && false == $wp_super_cache_late_init ) ) {
wp_cache_serve_cache_file();
}