Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.6.5 |
Comparing to | |
See all releases |
Code changes from version 1.6.4 to 1.6.5
- ossdl-cdn.php +223 -92
- plugins/domain-mapping.php +53 -48
- plugins/multisite.php +1 -1
- readme.txt +25 -3
- wp-cache-base.php +30 -22
- wp-cache-config-sample.php +0 -1
- wp-cache-phase2.php +103 -79
- wp-cache.php +401 -345
ossdl-cdn.php
CHANGED
@@ -2,36 +2,92 @@
|
|
2 |
|
3 |
/* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki (http://mark.ossdl.de/) and used with permission */
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
add_option( 'ossdl_off_cdn_url', get_option( 'siteurl' ) );
|
8 |
-
}
|
9 |
-
if ( get_option( 'ossdl_off_blog_url' ) === false ) {
|
10 |
-
add_option( 'ossdl_off_blog_url', apply_filters( 'ossdl_off_blog_url', untrailingslashit( get_option( 'siteurl' ) ) ) );
|
11 |
-
}
|
12 |
-
$ossdl_off_blog_url = get_option( 'ossdl_off_blog_url' );
|
13 |
-
$ossdl_off_cdn_url = trim( get_option( 'ossdl_off_cdn_url' ) );
|
14 |
-
if ( get_option( 'ossdl_off_include_dirs' ) === false ) {
|
15 |
-
add_option( 'ossdl_off_include_dirs', 'wp-content,wp-includes' );
|
16 |
-
}
|
17 |
-
$ossdl_off_include_dirs = trim( get_option( 'ossdl_off_include_dirs' ) );
|
18 |
-
if ( get_option( 'ossdl_off_exclude' ) === false ) {
|
19 |
-
add_option( 'ossdl_off_exclude', '.php' );
|
20 |
}
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
$arr_of_excludes = array();
|
25 |
}
|
26 |
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -44,25 +100,29 @@ if ( $arr_of_cnames[0] == '' ) {
|
|
44 |
*/
|
45 |
function scossdl_off_exclude_match( $match, $excludes ) {
|
46 |
foreach ( $excludes as $badword ) {
|
47 |
-
if (
|
48 |
return true;
|
49 |
}
|
50 |
}
|
|
|
51 |
return false;
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
* Compute string modulo, based on SHA1 hash
|
56 |
*
|
57 |
-
* @param string $str
|
58 |
-
* @param int $mod
|
59 |
*
|
60 |
-
* @return int
|
61 |
*/
|
62 |
function scossdl_string_mod( $str, $mod ) {
|
63 |
-
|
64 |
-
*
|
|
|
|
|
65 |
$num = hexdec( substr( sha1( $str ), 0, 5 ) );
|
|
|
66 |
return $num % $mod;
|
67 |
}
|
68 |
|
@@ -72,28 +132,26 @@ function scossdl_string_mod( $str, $mod ) {
|
|
72 |
* Called by #scossdl_off_filter.
|
73 |
*/
|
74 |
function scossdl_off_rewriter( $match ) {
|
75 |
-
global $ossdl_off_blog_url, $
|
|
|
76 |
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
}
|
80 |
|
81 |
-
if ( $ossdl_https && 0 ===
|
82 |
return $match[0];
|
83 |
}
|
84 |
|
85 |
-
if (
|
86 |
-
$arr_of_cnames[] = $ossdl_off_cdn_url;
|
87 |
-
}
|
88 |
-
|
89 |
-
if ( scossdl_off_exclude_match( $match[0], $arr_of_excludes ) ) {
|
90 |
return $match[0];
|
91 |
}
|
92 |
|
93 |
-
$include_dirs
|
94 |
-
|
95 |
-
|
96 |
-
return str_replace( $ossdl_off_blog_url, $arr_of_cnames[ $offset ], $match[0] );
|
97 |
}
|
98 |
|
99 |
return $match[0];
|
@@ -105,28 +163,47 @@ function scossdl_off_rewriter( $match ) {
|
|
105 |
* @return String with the pattern with {@literal |} as prefix, or empty
|
106 |
*/
|
107 |
function scossdl_off_additional_directories() {
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
|
115 |
-
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
* Output filter which runs the actual plugin logic.
|
|
|
|
|
|
|
|
|
120 |
*/
|
121 |
function scossdl_off_filter( $content ) {
|
122 |
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
if (
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
$dirs = scossdl_off_additional_directories();
|
129 |
-
$regex = '
|
130 |
return preg_replace_callback( $regex, 'scossdl_off_rewriter', $content );
|
131 |
}
|
132 |
|
@@ -135,28 +212,41 @@ function scossdl_off_filter( $content ) {
|
|
135 |
*/
|
136 |
function do_scossdl_off_ob_start() {
|
137 |
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
add_filter( 'wp_cache_ob_callback_filter', 'scossdl_off_filter' );
|
140 |
}
|
141 |
}
|
142 |
-
if ( false == isset( $ossdlcdn ) ) {
|
143 |
-
$ossdlcdn = 1; // have to default to on for existing users.
|
144 |
-
}
|
145 |
-
if ( $ossdlcdn == 1 ) {
|
146 |
-
add_action( 'init', 'do_scossdl_off_ob_start' );
|
147 |
-
}
|
148 |
|
|
|
|
|
|
|
149 |
function scossdl_off_update() {
|
150 |
|
151 |
if ( isset( $_POST['action'], $_POST['_wpnonce'] )
|
152 |
-
&& 'update_ossdl_off' === $_POST['action']
|
153 |
&& wp_verify_nonce( $_POST['_wpnonce'], 'wp-cache' )
|
154 |
) {
|
155 |
-
update_option( 'ossdl_off_cdn_url', untrailingslashit( $_POST['ossdl_off_cdn_url'] ) );
|
156 |
-
update_option( 'ossdl_off_blog_url', untrailingslashit( $_POST['ossdl_off_blog_url'] ) );
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
$ossdl_https = empty( $_POST['ossdl_https'] ) ? 0 : 1;
|
162 |
$ossdlcdn = empty( $_POST['ossdlcdn'] ) ? 0 : 1;
|
@@ -166,78 +256,119 @@ function scossdl_off_update() {
|
|
166 |
}
|
167 |
}
|
168 |
|
|
|
|
|
|
|
169 |
function scossdl_off_options() {
|
170 |
-
global $ossdlcdn, $ossdl_off_blog_url;
|
|
|
171 |
|
172 |
scossdl_off_update();
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
$
|
177 |
-
$example_cnames
|
|
|
|
|
178 |
|
179 |
-
$example_cdn_uri =
|
180 |
$example_cdn_uri .= '/wp-includes/js/jquery/jquery-migrate.js';
|
181 |
$example_cdn_uri = esc_url( $example_cdn_uri );
|
182 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
<p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore, this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="https://knowledgelayer.softlayer.com/faq/how-does-origin-pull-work" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
|
184 |
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . esc_html( $example_cdn_uri ) . '</code>' ); ?></p>
|
185 |
|
186 |
-
<?php if (
|
187 |
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Your siteurl and homeurl are different. The plugin is using %s as the homepage URL of your site but if that is wrong please use the filter "ossdl_off_blog_url" to fix it.', 'wp-super-cache' ), '<code>' . esc_html( $ossdl_off_blog_url ) . '</code>' ); ?></p>
|
188 |
<?php } ?>
|
189 |
-
|
190 |
-
<p><?php _e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
|
191 |
<p><form method="post" action="">
|
192 |
<?php wp_nonce_field( 'wp-cache' ); ?>
|
193 |
<table class="form-table"><tbody>
|
194 |
<tr valign="top">
|
195 |
<td style='text-align: right'>
|
196 |
-
<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php
|
197 |
</td>
|
198 |
-
<th scope="row"><label for="ossdlcdn"><?php
|
199 |
</tr>
|
200 |
<tr valign="top">
|
201 |
-
<th scope="row"><label for="ossdl_off_cdn_url"><?php
|
202 |
<td>
|
203 |
-
<input type="text" name="ossdl_off_blog_url" value="<?php echo
|
204 |
<span class="description"><?php _e( 'The URL of your site. No trailing <code>/</code> please.', 'wp-super-cache' ); ?></span>
|
205 |
</td>
|
206 |
</tr>
|
207 |
<tr valign="top">
|
208 |
-
<th scope="row"><label for="ossdl_off_cdn_url"><?php
|
209 |
<td>
|
210 |
-
<input type="text" name="ossdl_off_cdn_url" value="<?php echo
|
211 |
-
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), esc_html(
|
212 |
</td>
|
213 |
</tr>
|
214 |
<tr valign="top">
|
215 |
-
<th scope="row"><label for="ossdl_off_include_dirs"><?php
|
216 |
<td>
|
217 |
-
<input type="text" name="ossdl_off_include_dirs" value="<?php echo esc_attr(
|
218 |
<span class="description"><?php _e( 'Directories to include in static file matching. Use a comma as the delimiter. Default is <code>wp-content, wp-includes</code>, which will be enforced if this field is left empty.', 'wp-super-cache' ); ?></span>
|
219 |
</td>
|
220 |
</tr>
|
221 |
<tr valign="top">
|
222 |
-
<th scope="row"><label for="ossdl_off_exclude"><?php
|
223 |
<td>
|
224 |
-
<input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr(
|
225 |
<span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the URL. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
|
226 |
</td>
|
227 |
</tr>
|
228 |
<tr valign="top">
|
229 |
-
<th scope="row"><label for="ossdl_cname"><?php
|
230 |
<td>
|
231 |
-
<input type="text" name="ossdl_cname" value="<?php echo esc_attr(
|
232 |
-
<span class="description"><?php printf( __( 'These <a href="
|
233 |
</td>
|
234 |
</tr>
|
235 |
<tr valign="top">
|
236 |
-
<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php
|
237 |
</tr>
|
238 |
</tbody></table>
|
239 |
<input type="hidden" name="action" value="update_ossdl_off" />
|
240 |
-
<p class="submit"><input type="submit" class="button-primary" value="<?php
|
241 |
</form></p>
|
242 |
<p><?php _e( 'CDN functionality provided by <a href="https://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
|
243 |
<?php
|
2 |
|
3 |
/* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki (http://mark.ossdl.de/) and used with permission */
|
4 |
|
5 |
+
if ( ! isset( $ossdlcdn ) ) {
|
6 |
+
$ossdlcdn = 1; // have to default to on for existing users.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
+
|
9 |
+
if ( 1 === $ossdlcdn && ! is_admin() ) {
|
10 |
+
add_action( 'init', 'do_scossdl_off_ob_start' );
|
|
|
11 |
}
|
12 |
|
13 |
+
/**
|
14 |
+
* Set up some defaults.
|
15 |
+
*
|
16 |
+
* @global string $ossdl_off_blog_url
|
17 |
+
* @global string $ossdl_off_cdn_url
|
18 |
+
* @global string $ossdl_cname
|
19 |
+
* @global int $ossdl_https
|
20 |
+
* @global array $ossdl_off_include_dirs
|
21 |
+
* @global array $ossdl_off_excludes
|
22 |
+
* @global array $ossdl_arr_of_cnames
|
23 |
+
*
|
24 |
+
* @return void
|
25 |
+
*/
|
26 |
+
function scossdl_off_get_options() {
|
27 |
+
global $ossdl_off_blog_url, $ossdl_off_cdn_url, $ossdl_cname, $ossdl_https;
|
28 |
+
global $ossdl_off_include_dirs, $ossdl_off_excludes, $ossdl_arr_of_cnames;
|
29 |
+
|
30 |
+
$ossdl_off_blog_url = get_option( 'ossdl_off_blog_url' );
|
31 |
+
if ( false === $ossdl_off_blog_url ) {
|
32 |
+
$ossdl_off_blog_url = untrailingslashit( get_site_url() );
|
33 |
+
add_option( 'ossdl_off_blog_url', $ossdl_off_blog_url );
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( has_filter( 'ossdl_off_blog_url' ) ) {
|
37 |
+
$ossdl_off_blog_url = untrailingslashit( apply_filters( 'ossdl_off_blog_url', $ossdl_off_blog_url ) );
|
38 |
+
}
|
39 |
+
|
40 |
+
$ossdl_off_cdn_url = get_option( 'ossdl_off_cdn_url' );
|
41 |
+
if ( false === $ossdl_off_cdn_url ) {
|
42 |
+
$ossdl_off_cdn_url = untrailingslashit( get_site_url() );
|
43 |
+
add_option( 'ossdl_off_cdn_url', $ossdl_off_cdn_url );
|
44 |
+
}
|
45 |
+
|
46 |
+
$include_dirs = get_option( 'ossdl_off_include_dirs' );
|
47 |
+
if ( false !== $include_dirs ) {
|
48 |
+
$ossdl_off_include_dirs = array_filter( array_map( 'trim', explode( ',', $include_dirs ) ) );
|
49 |
+
} else {
|
50 |
+
$ossdl_off_include_dirs = scossdl_off_default_inc_dirs();
|
51 |
+
add_option( 'ossdl_off_include_dirs', implode( ',', $ossdl_off_include_dirs ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
$exclude = get_option( 'ossdl_off_exclude' );
|
55 |
+
if ( false !== $exclude ) {
|
56 |
+
$ossdl_off_excludes = array_filter( array_map( 'trim', explode( ',', $exclude ) ) );
|
57 |
+
} else {
|
58 |
+
$ossdl_off_excludes = array( '.php' );
|
59 |
+
add_option( 'ossdl_off_exclude', implode( ',', $ossdl_off_excludes ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
$ossdl_cname = get_option( 'ossdl_cname' );
|
63 |
+
if ( false !== $ossdl_cname ) {
|
64 |
+
$ossdl_cname = trim( $ossdl_cname );
|
65 |
+
} else {
|
66 |
+
$ossdl_cname = '';
|
67 |
+
add_option( 'ossdl_cname', $ossdl_cname );
|
68 |
+
}
|
69 |
+
$ossdl_arr_of_cnames = array_filter( array_map( 'trim', explode( ',', $ossdl_cname ) ) );
|
70 |
+
|
71 |
+
$ossdl_https = intval( get_option( 'ossdl_https' ) );
|
72 |
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Get default directories.
|
76 |
+
*
|
77 |
+
* @return array
|
78 |
+
*/
|
79 |
+
function scossdl_off_default_inc_dirs() {
|
80 |
+
|
81 |
+
$home_path = trailingslashit( (string) parse_url( get_option( 'siteurl' ), PHP_URL_PATH ) );
|
82 |
+
$inc_dirs = array();
|
83 |
+
|
84 |
+
foreach ( array( content_url(), includes_url() ) as $dir ) {
|
85 |
+
$dir = wp_make_link_relative( $dir );
|
86 |
+
$dir = preg_replace( '`^' . preg_quote( $home_path, '`' ) . '`', '', $dir );
|
87 |
+
$inc_dirs[] = trim( $dir, '/' );
|
88 |
+
}
|
89 |
+
|
90 |
+
return $inc_dirs;
|
91 |
}
|
92 |
|
93 |
/**
|
100 |
*/
|
101 |
function scossdl_off_exclude_match( $match, $excludes ) {
|
102 |
foreach ( $excludes as $badword ) {
|
103 |
+
if ( false !== stripos( $match, $badword ) ) {
|
104 |
return true;
|
105 |
}
|
106 |
}
|
107 |
+
|
108 |
return false;
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Compute string modulo, based on SHA1 hash
|
113 |
*
|
114 |
+
* @param string $str The string.
|
115 |
+
* @param int $mod The divisor.
|
116 |
*
|
117 |
+
* @return int The remainder.
|
118 |
*/
|
119 |
function scossdl_string_mod( $str, $mod ) {
|
120 |
+
/**
|
121 |
+
* The full SHA1 is too large for PHP integer types.
|
122 |
+
* This should be enough for our purpose.
|
123 |
+
*/
|
124 |
$num = hexdec( substr( sha1( $str ), 0, 5 ) );
|
125 |
+
|
126 |
return $num % $mod;
|
127 |
}
|
128 |
|
132 |
* Called by #scossdl_off_filter.
|
133 |
*/
|
134 |
function scossdl_off_rewriter( $match ) {
|
135 |
+
global $ossdl_off_blog_url, $ossdl_https, $ossdl_off_excludes, $ossdl_arr_of_cnames;
|
136 |
+
static $count_cnames = null, $include_dirs = null;
|
137 |
|
138 |
+
// Set up static variables. Run once only.
|
139 |
+
if ( ! isset( $count_cnames ) ) {
|
140 |
+
$count_cnames = count( $ossdl_arr_of_cnames );
|
141 |
+
$include_dirs = scossdl_off_additional_directories();
|
142 |
}
|
143 |
|
144 |
+
if ( $ossdl_https && 0 === strpos( $match[0], 'https' ) ) {
|
145 |
return $match[0];
|
146 |
}
|
147 |
|
148 |
+
if ( scossdl_off_exclude_match( $match[0], $ossdl_off_excludes ) ) {
|
|
|
|
|
|
|
|
|
149 |
return $match[0];
|
150 |
}
|
151 |
|
152 |
+
if ( preg_match( '`(' . $include_dirs . ')`', $match[0] ) ) {
|
153 |
+
$offset = scossdl_string_mod( $match[1], $count_cnames );
|
154 |
+
return str_replace( $ossdl_off_blog_url, $ossdl_arr_of_cnames[ $offset ], $match[0] );
|
|
|
155 |
}
|
156 |
|
157 |
return $match[0];
|
163 |
* @return String with the pattern with {@literal |} as prefix, or empty
|
164 |
*/
|
165 |
function scossdl_off_additional_directories() {
|
166 |
+
global $ossdl_off_include_dirs;
|
167 |
|
168 |
+
$arr_dirs = array();
|
169 |
+
foreach ( $ossdl_off_include_dirs as $dir ) {
|
170 |
+
$arr_dirs[] = preg_quote( trim( $dir ), '`' );
|
171 |
+
}
|
172 |
|
173 |
+
return implode( '|', $arr_dirs );
|
174 |
}
|
175 |
|
176 |
/**
|
177 |
* Output filter which runs the actual plugin logic.
|
178 |
+
*
|
179 |
+
* @param string $content The content of the output buffer.
|
180 |
+
*
|
181 |
+
* @return string The rewritten content.
|
182 |
*/
|
183 |
function scossdl_off_filter( $content ) {
|
184 |
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
|
185 |
+
global $ossdl_off_include_dirs, $ossdl_off_excludes, $ossdl_arr_of_cnames;
|
186 |
+
|
187 |
+
if ( empty( $content ) || empty( $ossdl_off_cdn_url ) ||
|
188 |
+
$ossdl_off_blog_url === $ossdl_off_cdn_url
|
189 |
+
) {
|
190 |
+
return $content; // no rewrite needed.
|
191 |
+
}
|
192 |
+
|
193 |
+
if ( empty( $ossdl_off_include_dirs ) || ! is_array( $ossdl_off_include_dirs ) ) {
|
194 |
+
$ossdl_off_include_dirs = scossdl_off_default_inc_dirs();
|
195 |
+
}
|
196 |
|
197 |
+
if ( empty( $ossdl_off_excludes ) || ! is_array( $ossdl_off_excludes ) ) {
|
198 |
+
$ossdl_off_excludes = array();
|
199 |
+
}
|
200 |
+
|
201 |
+
if ( ! in_array( $ossdl_off_cdn_url, (array) $ossdl_arr_of_cnames, true ) ) {
|
202 |
+
$ossdl_arr_of_cnames = array_merge( array( $ossdl_off_cdn_url ), (array) $ossdl_arr_of_cnames );
|
203 |
}
|
204 |
|
205 |
$dirs = scossdl_off_additional_directories();
|
206 |
+
$regex = '`(?<=[(\"\'])' . preg_quote( $ossdl_off_blog_url, '`' ) . '/(?:((?:' . $dirs . ')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])`';
|
207 |
return preg_replace_callback( $regex, 'scossdl_off_rewriter', $content );
|
208 |
}
|
209 |
|
212 |
*/
|
213 |
function do_scossdl_off_ob_start() {
|
214 |
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
|
215 |
+
|
216 |
+
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
|
220 |
+
scossdl_off_get_options();
|
221 |
+
|
222 |
+
if ( ! empty( $ossdl_off_cdn_url ) &&
|
223 |
+
$ossdl_off_blog_url !== $ossdl_off_cdn_url
|
224 |
+
) {
|
225 |
add_filter( 'wp_cache_ob_callback_filter', 'scossdl_off_filter' );
|
226 |
}
|
227 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
+
/**
|
230 |
+
* Update CDN settings to the options database table.
|
231 |
+
*/
|
232 |
function scossdl_off_update() {
|
233 |
|
234 |
if ( isset( $_POST['action'], $_POST['_wpnonce'] )
|
235 |
+
&& 'update_ossdl_off' === $_POST['action'] // WPCS: sanitization ok.
|
236 |
&& wp_verify_nonce( $_POST['_wpnonce'], 'wp-cache' )
|
237 |
) {
|
238 |
+
update_option( 'ossdl_off_cdn_url', untrailingslashit( wp_unslash( $_POST['ossdl_off_cdn_url'] ) ) ); // WPSC: sanitization ok.
|
239 |
+
update_option( 'ossdl_off_blog_url', untrailingslashit( wp_unslash( $_POST['ossdl_off_blog_url'] ) ) ); // WPSC: sanitization ok.
|
240 |
+
|
241 |
+
if ( empty( $_POST['ossdl_off_include_dirs'] ) ) {
|
242 |
+
$include_dirs = implode( ',', scossdl_off_default_inc_dirs() );
|
243 |
+
} else {
|
244 |
+
$include_dirs = sanitize_text_field( wp_unslash( $_POST['ossdl_off_include_dirs'] ) ); // WPSC: validation ok,sanitization ok.
|
245 |
+
}
|
246 |
+
update_option( 'ossdl_off_include_dirs', $include_dirs );
|
247 |
+
|
248 |
+
update_option( 'ossdl_off_exclude', sanitize_text_field( wp_unslash( $_POST['ossdl_off_exclude'] ) ) ); // WPSC: sanitization ok.
|
249 |
+
update_option( 'ossdl_cname', sanitize_text_field( wp_unslash( $_POST['ossdl_cname'] ) ) ); // WPSC: sanitization ok.
|
250 |
|
251 |
$ossdl_https = empty( $_POST['ossdl_https'] ) ? 0 : 1;
|
252 |
$ossdlcdn = empty( $_POST['ossdlcdn'] ) ? 0 : 1;
|
256 |
}
|
257 |
}
|
258 |
|
259 |
+
/**
|
260 |
+
* Show CDN settings.
|
261 |
+
*/
|
262 |
function scossdl_off_options() {
|
263 |
+
global $ossdlcdn, $ossdl_off_blog_url, $ossdl_off_cdn_url, $ossdl_cname, $ossdl_https;
|
264 |
+
global $ossdl_off_include_dirs, $ossdl_off_excludes;
|
265 |
|
266 |
scossdl_off_update();
|
267 |
|
268 |
+
scossdl_off_get_options();
|
269 |
+
|
270 |
+
$example_cdn_uri = ( is_ssl() ? 'https' : 'http' ) . '://cdn.' . preg_replace( '`^(https?:)?//(www\.)?`', '', get_site_url() );
|
271 |
+
$example_cnames = str_replace( '://cdn.', '://cdn1.', $example_cdn_uri );
|
272 |
+
$example_cnames .= ',' . str_replace( '://cdn.', '://cdn2.', $example_cdn_uri );
|
273 |
+
$example_cnames .= ',' . str_replace( '://cdn.', '://cdn3.', $example_cdn_uri );
|
274 |
|
275 |
+
$example_cdn_uri = ( get_site_url() === $ossdl_off_cdn_url ) ? $example_cdn_uri : $ossdl_off_cdn_url;
|
276 |
$example_cdn_uri .= '/wp-includes/js/jquery/jquery-migrate.js';
|
277 |
$example_cdn_uri = esc_url( $example_cdn_uri );
|
278 |
?>
|
279 |
+
<h3><?php _e( 'Jetpack CDN' ); ?></h3>
|
280 |
+
<p><?php printf(
|
281 |
+
__( 'The free %1$sJetpack plugin%2$s has a %3$sSite Accelerator%2$s feature that is easier to use than the CDN functionality in this plugin. However files will be cached "forever" and will not update if you update the local file. Files will need to be renamed to refresh them. The %3$sJetpack documentation%2$s explains more about this.', 'wp-super-cache' ),
|
282 |
+
'<a href="https://jetpack.com/">',
|
283 |
+
'</a>',
|
284 |
+
'<a href="https://jetpack.com/support/site-accelerator/">'
|
285 |
+
); ?></p>
|
286 |
+
<?php
|
287 |
+
if ( class_exists( 'Jetpack' ) ) {
|
288 |
+
if ( Jetpack::is_module_active( 'photon' ) ) {
|
289 |
+
?><p><strong><?php printf(
|
290 |
+
__( 'You already have Jetpack installed and %1$sSite Accelerator%2$s enabled on this blog. The CDN here is disabled to avoid conflicts with Jetpack.', 'wp-super-cache' ),
|
291 |
+
'<a href="https://jetpack.com/support/site-accelerator/">',
|
292 |
+
'</a>'
|
293 |
+
); ?></strong></p><?php
|
294 |
+
} else {
|
295 |
+
?><p><?php printf(
|
296 |
+
__( 'You already have Jetpack installed but %1$sSite Accelerator%2$s is disabled on this blog. Enable it on the %3$sJetpack settings page%2$s.', 'wp-super-cache' ),
|
297 |
+
'<a href="https://jetpack.com/support/site-accelerator/">',
|
298 |
+
'</a>',
|
299 |
+
'<a href="' . admin_url( 'admin.php?page=jetpack#/settings' ) . '">'
|
300 |
+
); ?></p><?php
|
301 |
+
}
|
302 |
+
} else {
|
303 |
+
?><p><strong><?php printf(
|
304 |
+
__( '%1$sJetpack%2$s was not found on your site but %3$syou can install it%2$s. The Site Accelerator feature is free to use on any WordPress site and offers the same benefit as other CDN services. You should give it a try!', 'wp-super-cache' ),
|
305 |
+
'<a href="https://jetpack.com/">',
|
306 |
+
'</a>',
|
307 |
+
'<a href="' . admin_url( 'plugin-install.php?s=jetpack&tab=search&type=term' ) . '">'
|
308 |
+
); ?></strong></p><?php
|
309 |
+
}
|
310 |
+
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
|
311 |
+
return;
|
312 |
+
}
|
313 |
+
?>
|
314 |
+
<h3><?php _e( 'Simple CDN' ); ?></h3>
|
315 |
<p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore, this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="https://knowledgelayer.softlayer.com/faq/how-does-origin-pull-work" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
|
316 |
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . esc_html( $example_cdn_uri ) . '</code>' ); ?></p>
|
317 |
|
318 |
+
<?php if ( get_home_url() !== $ossdl_off_blog_url ) { ?>
|
319 |
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Your siteurl and homeurl are different. The plugin is using %s as the homepage URL of your site but if that is wrong please use the filter "ossdl_off_blog_url" to fix it.', 'wp-super-cache' ), '<code>' . esc_html( $ossdl_off_blog_url ) . '</code>' ); ?></p>
|
320 |
<?php } ?>
|
321 |
+
<p><?php esc_html_e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
|
|
|
322 |
<p><form method="post" action="">
|
323 |
<?php wp_nonce_field( 'wp-cache' ); ?>
|
324 |
<table class="form-table"><tbody>
|
325 |
<tr valign="top">
|
326 |
<td style='text-align: right'>
|
327 |
+
<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php checked( $ossdlcdn ); ?> />
|
328 |
</td>
|
329 |
+
<th scope="row"><label for="ossdlcdn"><?php esc_html_e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
|
330 |
</tr>
|
331 |
<tr valign="top">
|
332 |
+
<th scope="row"><label for="ossdl_off_cdn_url"><?php esc_html_e( 'Site URL', 'wp-super-cache' ); ?></label></th>
|
333 |
<td>
|
334 |
+
<input type="text" name="ossdl_off_blog_url" value="<?php echo esc_attr( untrailingslashit( $ossdl_off_blog_url ) ); ?>" size="64" class="regular-text code" /><br />
|
335 |
<span class="description"><?php _e( 'The URL of your site. No trailing <code>/</code> please.', 'wp-super-cache' ); ?></span>
|
336 |
</td>
|
337 |
</tr>
|
338 |
<tr valign="top">
|
339 |
+
<th scope="row"><label for="ossdl_off_cdn_url"><?php esc_html_e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
|
340 |
<td>
|
341 |
+
<input type="text" name="ossdl_off_cdn_url" value="<?php echo esc_attr( $ossdl_off_cdn_url ); ?>" size="64" class="regular-text code" /><br />
|
342 |
+
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), esc_html( get_site_url() ), esc_html( $example_cdn_uri ) ); ?></span>
|
343 |
</td>
|
344 |
</tr>
|
345 |
<tr valign="top">
|
346 |
+
<th scope="row"><label for="ossdl_off_include_dirs"><?php esc_html_e( 'Include directories', 'wp-super-cache' ); ?></label></th>
|
347 |
<td>
|
348 |
+
<input type="text" name="ossdl_off_include_dirs" value="<?php echo esc_attr( implode( ',', $ossdl_off_include_dirs ) ); ?>" size="64" class="regular-text code" /><br />
|
349 |
<span class="description"><?php _e( 'Directories to include in static file matching. Use a comma as the delimiter. Default is <code>wp-content, wp-includes</code>, which will be enforced if this field is left empty.', 'wp-super-cache' ); ?></span>
|
350 |
</td>
|
351 |
</tr>
|
352 |
<tr valign="top">
|
353 |
+
<th scope="row"><label for="ossdl_off_exclude"><?php esc_html_e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
|
354 |
<td>
|
355 |
+
<input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( implode( ',', $ossdl_off_excludes ) ); ?>" size="64" class="regular-text code" /><br />
|
356 |
<span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the URL. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
|
357 |
</td>
|
358 |
</tr>
|
359 |
<tr valign="top">
|
360 |
+
<th scope="row"><label for="ossdl_cname"><?php esc_html_e( 'Additional CNAMES', 'wp-super-cache' ); ?></label></th>
|
361 |
<td>
|
362 |
+
<input type="text" name="ossdl_cname" value="<?php echo esc_attr( $ossdl_cname ); ?>" size="64" class="regular-text code" /><br />
|
363 |
+
<span class="description"><?php printf( __( 'These <a href="https://www.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), esc_html( get_site_url() ), esc_html( $example_cnames ) ); ?></span>
|
364 |
</td>
|
365 |
</tr>
|
366 |
<tr valign="top">
|
367 |
+
<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php checked( $ossdl_https ); ?> /><?php esc_html_e( 'Skip https URLs to avoid "mixed content" errors', 'wp-super-cache' ); ?></label></th>
|
368 |
</tr>
|
369 |
</tbody></table>
|
370 |
<input type="hidden" name="action" value="update_ossdl_off" />
|
371 |
+
<p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-super-cache' ); ?>" /></p>
|
372 |
</form></p>
|
373 |
<p><?php _e( 'CDN functionality provided by <a href="https://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
|
374 |
<?php
|
plugins/domain-mapping.php
CHANGED
@@ -4,16 +4,15 @@ function domain_mapping_gc_cache( $function, $directory ) {
|
|
4 |
global $cache_path;
|
5 |
|
6 |
if ( ! function_exists( 'domain_mapping_warning' ) ) {
|
7 |
-
return
|
8 |
}
|
9 |
|
10 |
$siteurl = domain_mapping_siteurl( false );
|
11 |
if ( ! $siteurl ) {
|
12 |
-
return
|
13 |
}
|
14 |
|
15 |
-
$
|
16 |
-
$siteurl = trailingslashit( str_replace( $protocol, '', $siteurl ) );
|
17 |
|
18 |
if ( 'homepage' === $directory ) {
|
19 |
$directory = '';
|
@@ -21,20 +20,17 @@ function domain_mapping_gc_cache( $function, $directory ) {
|
|
21 |
|
22 |
switch ( $function ) {
|
23 |
case 'rebuild':
|
24 |
-
|
25 |
-
@wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz' );
|
26 |
break;
|
27 |
case 'prune':
|
28 |
-
|
29 |
-
prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true );
|
30 |
break;
|
31 |
}
|
32 |
-
|
33 |
-
return $directory;
|
34 |
}
|
35 |
|
36 |
function domain_mapping_supercachedir( $dir ) {
|
37 |
global $cache_path;
|
|
|
38 |
if ( ! function_exists( 'domain_mapping_warning' ) ) {
|
39 |
return $dir;
|
40 |
}
|
@@ -44,56 +40,62 @@ function domain_mapping_supercachedir( $dir ) {
|
|
44 |
return $dir;
|
45 |
}
|
46 |
|
47 |
-
$
|
48 |
-
|
49 |
-
return trailingslashit( $cache_path . 'supercache/' . $
|
50 |
}
|
51 |
|
52 |
function domain_mapping_actions() {
|
53 |
global $cache_domain_mapping;
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
57 |
}
|
|
|
|
|
|
|
58 |
}
|
59 |
add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
|
60 |
|
61 |
function wp_supercache_domain_mapping_admin() {
|
62 |
global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
|
63 |
|
64 |
-
$
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
$cache_domain_mapping = (int) $_POST['cache_domain_mapping'];
|
73 |
-
wp_cache_replace_line( '^ *\$cache_domain_mapping', "\$cache_domain_mapping = '$cache_domain_mapping';", $wp_cache_config_file );
|
74 |
}
|
|
|
75 |
$id = 'domain_mapping-section';
|
76 |
?>
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
<form name="wp_manager" action="" method="post">
|
80 |
-
<label><input type="radio" name="cache_domain_mapping" value="1" <?php
|
81 |
-
<label><input type="radio" name="cache_domain_mapping" value="0" <?php
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
</fieldset>
|
98 |
<?php
|
99 |
}
|
@@ -101,14 +103,17 @@ add_cacheaction( 'cache_admin_page', 'wp_supercache_domain_mapping_admin' );
|
|
101 |
|
102 |
function wp_supercache_domain_mapping_notice() {
|
103 |
global $cache_enabled;
|
|
|
104 |
if ( $cache_enabled ) {
|
105 |
-
echo '<div class="error"><p><strong>' .
|
106 |
}
|
107 |
}
|
108 |
function wp_supercache_domain_mapping_exists() {
|
109 |
global $cache_domain_mapping;
|
110 |
-
|
111 |
-
|
|
|
|
|
112 |
}
|
113 |
|
114 |
if ( is_admin() && function_exists( 'domain_mapping_warning' ) ) {
|
@@ -124,8 +129,8 @@ function wpsc_domain_mapping_list( $list ) {
|
|
124 |
$list['domain_mapping'] = array(
|
125 |
'key' => 'domain_mapping',
|
126 |
'url' => 'https://wordpress.org/plugins/wordpress-mu-domain-mapping/',
|
127 |
-
'title' =>
|
128 |
-
'desc' =>
|
129 |
);
|
130 |
return $list;
|
131 |
}
|
4 |
global $cache_path;
|
5 |
|
6 |
if ( ! function_exists( 'domain_mapping_warning' ) ) {
|
7 |
+
return;
|
8 |
}
|
9 |
|
10 |
$siteurl = domain_mapping_siteurl( false );
|
11 |
if ( ! $siteurl ) {
|
12 |
+
return;
|
13 |
}
|
14 |
|
15 |
+
$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
|
|
|
16 |
|
17 |
if ( 'homepage' === $directory ) {
|
18 |
$directory = '';
|
20 |
|
21 |
switch ( $function ) {
|
22 |
case 'rebuild':
|
23 |
+
wpsc_rebuild_files( $cache_path . 'supercache/' . $sitedir . $directory );
|
|
|
24 |
break;
|
25 |
case 'prune':
|
26 |
+
wpsc_delete_files( $cache_path . 'supercache/' . $sitedir . $directory );
|
|
|
27 |
break;
|
28 |
}
|
|
|
|
|
29 |
}
|
30 |
|
31 |
function domain_mapping_supercachedir( $dir ) {
|
32 |
global $cache_path;
|
33 |
+
|
34 |
if ( ! function_exists( 'domain_mapping_warning' ) ) {
|
35 |
return $dir;
|
36 |
}
|
40 |
return $dir;
|
41 |
}
|
42 |
|
43 |
+
$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
|
44 |
+
|
45 |
+
return trailingslashit( $cache_path . 'supercache/' . $sitedir );
|
46 |
}
|
47 |
|
48 |
function domain_mapping_actions() {
|
49 |
global $cache_domain_mapping;
|
50 |
+
|
51 |
+
$cache_domain_mapping = (int) $cache_domain_mapping;
|
52 |
+
if ( 1 !== $cache_domain_mapping ) {
|
53 |
+
return;
|
54 |
}
|
55 |
+
|
56 |
+
add_filter( 'wp_super_cache_supercachedir', 'domain_mapping_supercachedir' );
|
57 |
+
add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
|
58 |
}
|
59 |
add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
|
60 |
|
61 |
function wp_supercache_domain_mapping_admin() {
|
62 |
global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
|
63 |
|
64 |
+
$requested_state = isset( $_POST['cache_domain_mapping'] ) ? (int) $_POST['cache_domain_mapping'] : null;
|
65 |
+
$cache_domain_mapping = (int) $cache_domain_mapping;
|
66 |
|
67 |
+
$changed = false;
|
68 |
+
if ( null !== $requested_state && $valid_nonce ) {
|
69 |
+
$cache_domain_mapping = $requested_state;
|
70 |
+
|
71 |
+
wp_cache_replace_line( '^\s*\$cache_domain_mapping\s*=', '$cache_domain_mapping = ' . intval( $cache_domain_mapping ) . ';', $wp_cache_config_file );
|
72 |
+
$changed = true;
|
|
|
|
|
73 |
}
|
74 |
+
|
75 |
$id = 'domain_mapping-section';
|
76 |
?>
|
77 |
+
<fieldset id="<?php echo esc_attr( $id ); ?>" class="options">
|
78 |
+
|
79 |
+
<h4><?php esc_html_e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
|
80 |
+
|
81 |
<form name="wp_manager" action="" method="post">
|
82 |
+
<label><input type="radio" name="cache_domain_mapping" value="1" <?php checked( $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Enabled', 'wp-super-cache' ); ?></label>
|
83 |
+
<label><input type="radio" name="cache_domain_mapping" value="0" <?php checked( ! $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Disabled', 'wp-super-cache' ); ?></label>
|
84 |
+
<?php
|
85 |
+
echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache' ) . '</p>';
|
86 |
+
|
87 |
+
if ( $changed ) {
|
88 |
+
echo '<p><strong>' . sprintf(
|
89 |
+
esc_html__( 'Domain Mapping support is now %s', 'wp-super-cache' ),
|
90 |
+
esc_html( $cache_domain_mapping ? __( 'enabled', 'wp-super-cache' ) : __( 'disabled', 'wp-super-cache' ) )
|
91 |
+
) . '</strong></p>';
|
92 |
}
|
93 |
+
|
94 |
+
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . ' type="submit" value="' . esc_html__( 'Update', 'wp-super-cache' ) . '" /></div>';
|
95 |
+
wp_nonce_field( 'wp-cache' );
|
96 |
+
?>
|
97 |
+
</form>
|
98 |
+
|
99 |
</fieldset>
|
100 |
<?php
|
101 |
}
|
103 |
|
104 |
function wp_supercache_domain_mapping_notice() {
|
105 |
global $cache_enabled;
|
106 |
+
|
107 |
if ( $cache_enabled ) {
|
108 |
+
echo '<div class="error"><p><strong>' . esc_html__( 'Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
|
109 |
}
|
110 |
}
|
111 |
function wp_supercache_domain_mapping_exists() {
|
112 |
global $cache_domain_mapping;
|
113 |
+
|
114 |
+
$cache_domain_mapping = (int) $cache_domain_mapping;
|
115 |
+
if ( 1 === $cache_domain_mapping ) {
|
116 |
+
return;
|
117 |
}
|
118 |
|
119 |
if ( is_admin() && function_exists( 'domain_mapping_warning' ) ) {
|
129 |
$list['domain_mapping'] = array(
|
130 |
'key' => 'domain_mapping',
|
131 |
'url' => 'https://wordpress.org/plugins/wordpress-mu-domain-mapping/',
|
132 |
+
'title' => esc_html__( 'Domain Mapping', 'wp-super-cache' ),
|
133 |
+
'desc' => esc_html__( 'Provides support for Domain Mapping plugin to map multiple domains to a blog.', 'wp-super-cache' ),
|
134 |
);
|
135 |
return $list;
|
136 |
}
|
plugins/multisite.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if ( (
|
4 |
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
|
5 |
}
|
6 |
|
1 |
<?php
|
2 |
|
3 |
+
if ( is_multisite() ) {
|
4 |
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
|
5 |
}
|
6 |
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
-
* Tested up to:
|
5 |
-
* Stable tag: 1.6.
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
@@ -266,6 +266,28 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
266 |
|
267 |
## Changelog ##
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
### 1.6.4 ###
|
270 |
* Changes between [1.6.3 and 1.6.4](https://github.com/Automattic/wp-super-cache/compare/1.6.3...1.6.4)
|
271 |
* Fixes for WP-CLI (#587) (#592)
|
@@ -691,4 +713,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
691 |
|
692 |
|
693 |
## Upgrade Notice ##
|
694 |
-
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
+
* Tested up to: 5.1.1
|
5 |
+
* Stable tag: 1.6.5
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
266 |
|
267 |
## Changelog ##
|
268 |
|
269 |
+
### 1.6.5 ###
|
270 |
+
* Check advanced-cache.php was created by the plugin before modifying/deleting it. (#666)
|
271 |
+
* When saving settings, save blank lines. Fixes problems with WP_CACHE and WPCACHEHOME in wp-config.php. Related to #652. (#667)
|
272 |
+
* Update outdated code and use is_multisite() (#600)
|
273 |
+
* Fix the delete cache button in the admin bar. (#603)
|
274 |
+
* Code cleanup in #602
|
275 |
+
* Use get_post_status instead of post_status (#623)
|
276 |
+
* Fixes button - Update Direct Pages (#622)
|
277 |
+
* Removes apache_response_headers and uses only headers_list (#618)
|
278 |
+
* Function is_site_admin has been deprecated (#611)
|
279 |
+
* Fixes action urls in wp_cache_manager (#610)
|
280 |
+
* Remove the link to the HibbsLupusTrust tweet. (#635)
|
281 |
+
* Don't load wp-cache-config.php if it's already loaded (#605)
|
282 |
+
* PHPCS fixes and optimization for plugins/domain-mapping.php (#615)
|
283 |
+
* Introduces PHP_VERSION_ID for faster checking (#604)
|
284 |
+
* Fixes regex and optimizes ossdl-cdn.php (#596)
|
285 |
+
* Only update new settings and use a temporary file to avoid corruption. (#652)
|
286 |
+
* Serve cached files to rejected user agents, don't cache them. (#658)
|
287 |
+
* Combine multiple headers with the same name (#641)
|
288 |
+
* Open ‘Delete Cache’ link in same window (#656)
|
289 |
+
* Promote the Jetpack Site Accelerator on the CDN page. (#636)
|
290 |
+
|
291 |
### 1.6.4 ###
|
292 |
* Changes between [1.6.3 and 1.6.4](https://github.com/Automattic/wp-super-cache/compare/1.6.3...1.6.4)
|
293 |
* Fixes for WP-CLI (#587) (#592)
|
713 |
|
714 |
|
715 |
## Upgrade Notice ##
|
716 |
+
Many bug fixes
|
wp-cache-base.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
2 |
-
global $WPSC_HTTP_HOST, $blogcacheid;
|
3 |
|
4 |
if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
|
5 |
-
$WPSC_HTTP_HOST =
|
|
|
6 |
} elseif ( PHP_SAPI === 'cli' && function_exists( 'get_option' ) ) {
|
7 |
$WPSC_HTTP_HOST = (string) parse_url( get_option( 'home' ), PHP_URL_HOST );
|
8 |
} else {
|
@@ -11,29 +12,36 @@ if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
|
|
11 |
}
|
12 |
|
13 |
// We want to be able to identify each blog in a WordPress MU install
|
14 |
-
$blogcacheid
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
$blogcacheid = $WPSC_HTTP_HOST;
|
19 |
} else {
|
20 |
-
if ( isset( $base ) == false ) {
|
21 |
-
$base = '';
|
22 |
-
}
|
23 |
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
$blogcacheid = substr( $blogcacheid, 0, strpos( $blogcacheid, '/', 1 ) );
|
31 |
-
}
|
32 |
-
}
|
33 |
-
if ( '/' == substr( $blogcacheid, -1 ) ) {
|
34 |
-
$blogcacheid = substr( $blogcacheid, 0, -1 );
|
35 |
-
}
|
36 |
}
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
|
|
39 |
}
|
1 |
<?php
|
2 |
+
global $WPSC_HTTP_HOST, $cache_enabled, $cache_path, $blogcacheid, $blog_cache_dir;
|
3 |
|
4 |
if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
|
5 |
+
$WPSC_HTTP_HOST = function_exists( 'mb_strtolower' ) ? mb_strtolower( $_SERVER['HTTP_HOST'] ) : strtolower( $_SERVER['HTTP_HOST'] );
|
6 |
+
$WPSC_HTTP_HOST = htmlentities( $WPSC_HTTP_HOST );
|
7 |
} elseif ( PHP_SAPI === 'cli' && function_exists( 'get_option' ) ) {
|
8 |
$WPSC_HTTP_HOST = (string) parse_url( get_option( 'home' ), PHP_URL_HOST );
|
9 |
} else {
|
12 |
}
|
13 |
|
14 |
// We want to be able to identify each blog in a WordPress MU install
|
15 |
+
$blogcacheid = '';
|
16 |
+
$blog_cache_dir = $cache_path;
|
17 |
+
|
18 |
+
if ( is_multisite() ) {
|
19 |
+
global $current_blog;
|
20 |
+
|
21 |
+
if ( is_object( $current_blog ) && function_exists( 'is_subdomain_install' ) ) {
|
22 |
+
$blogcacheid = is_subdomain_install() ? $current_blog->domain : trim( $current_blog->path, '/' );
|
23 |
+
} elseif ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) {
|
24 |
$blogcacheid = $WPSC_HTTP_HOST;
|
25 |
} else {
|
|
|
|
|
|
|
26 |
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
|
27 |
+
$request_uri = str_replace( '//', '/', $request_uri );
|
28 |
+
|
29 |
+
$wpsc_path_segs = array_filter( explode( '/', trim( $request_uri, '/' ) ) );
|
30 |
+
$wpsc_base_count = defined( 'PATH_CURRENT_SITE' ) ? count( array_filter( explode( '/', trim( PATH_CURRENT_SITE, '/' ) ) ) ) : 0;
|
31 |
+
if ( '/' !== substr( $request_uri, -1 ) ) {
|
32 |
+
$wpsc_path_segs = array_slice( $wpsc_path_segs, 0, -1 );
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
+
|
35 |
+
if ( count( $wpsc_path_segs ) > $wpsc_base_count &&
|
36 |
+
( ! defined( 'PATH_CURRENT_SITE' ) || 0 === strpos( $request_uri, PATH_CURRENT_SITE ) )
|
37 |
+
) {
|
38 |
+
$blogcacheid = $wpsc_path_segs[ $wpsc_base_count ];
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
// If blogcacheid is empty then set it to main blog.
|
43 |
+
if ( empty( $blogcacheid ) ) {
|
44 |
+
$blogcacheid = 'blog';
|
45 |
}
|
46 |
+
$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
|
47 |
}
|
wp-cache-config-sample.php
CHANGED
@@ -76,7 +76,6 @@ $wp_cache_pages[ "author" ] = 0;
|
|
76 |
$wp_cache_hide_donation = 0;
|
77 |
$wp_cache_not_logged_in = 0;
|
78 |
$wp_cache_clear_on_post_edit = 0;
|
79 |
-
$wp_cache_hello_world = 0;
|
80 |
$wp_cache_mobile_enabled = 0;
|
81 |
$wp_cache_cron_check = 0;
|
82 |
$wp_cache_mfunc_enabled = 0;
|
76 |
$wp_cache_hide_donation = 0;
|
77 |
$wp_cache_not_logged_in = 0;
|
78 |
$wp_cache_clear_on_post_edit = 0;
|
|
|
79 |
$wp_cache_mobile_enabled = 0;
|
80 |
$wp_cache_cron_check = 0;
|
81 |
$wp_cache_mfunc_enabled = 0;
|
wp-cache-phase2.php
CHANGED
@@ -52,11 +52,6 @@ function wp_cache_serve_cache_file() {
|
|
52 |
return false;
|
53 |
}
|
54 |
|
55 |
-
if ( wp_cache_user_agent_is_rejected() ) {
|
56 |
-
wp_cache_debug( 'No wp-cache file served as user agent rejected.', 5 );
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
|
60 |
if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
|
61 |
wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
|
62 |
return false;
|
@@ -226,10 +221,11 @@ function wp_cache_serve_cache_file() {
|
|
226 |
} else {
|
227 |
$ungzip = false;
|
228 |
}
|
229 |
-
foreach ($meta[
|
230 |
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
|
231 |
-
if( strpos( $header, 'Last-Modified:' ) === false )
|
232 |
-
header($header);
|
|
|
233 |
}
|
234 |
if ( isset( $wpsc_served_header ) && $wpsc_served_header ) {
|
235 |
header( 'X-WP-Super-Cache: Served WPCache cache file' );
|
@@ -825,7 +821,7 @@ function get_oc_key( $url = false ) {
|
|
825 |
global $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
|
826 |
|
827 |
if ( $url ) {
|
828 |
-
$key = intval( $_SERVER[ 'SERVER_PORT' ] ) .
|
829 |
} else {
|
830 |
$key = get_current_url_supercache_dir();
|
831 |
}
|
@@ -1109,13 +1105,23 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1109 |
}
|
1110 |
}
|
1111 |
foreach( (array) $lines as $line ) {
|
1112 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
$found = true;
|
1114 |
-
break;
|
1115 |
}
|
1116 |
}
|
1117 |
|
1118 |
-
$
|
|
|
|
|
|
|
|
|
1119 |
if ( ! $fd ) {
|
1120 |
if ( function_exists( 'set_transient' ) ) {
|
1121 |
set_transient( 'wpsc_config_error', 'config_file_ro', 10 );
|
@@ -1144,6 +1150,8 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1144 |
}
|
1145 |
}
|
1146 |
fclose( $fd );
|
|
|
|
|
1147 |
|
1148 |
if ( function_exists( "opcache_invalidate" ) ) {
|
1149 |
@opcache_invalidate( $my_file );
|
@@ -1160,6 +1168,11 @@ function wp_cache_phase2() {
|
|
1160 |
return false;
|
1161 |
}
|
1162 |
|
|
|
|
|
|
|
|
|
|
|
1163 |
wp_cache_debug( 'In WP Cache Phase 2', 5 );
|
1164 |
|
1165 |
$wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. https://wordpress.org/support/topic/224349
|
@@ -1374,79 +1387,83 @@ function wp_cache_user_agent_is_rejected() {
|
|
1374 |
|
1375 |
function wp_cache_get_response_headers() {
|
1376 |
static $known_headers = array(
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
|
|
|
|
|
|
|
|
1425 |
|
1426 |
$known_headers = apply_filters( 'wpsc_known_headers', $known_headers );
|
1427 |
|
1428 |
-
if ( ! isset( $known_headers[
|
1429 |
$known_headers = array_map( 'strtolower', $known_headers );
|
1430 |
}
|
1431 |
|
1432 |
$headers = array();
|
1433 |
-
|
1434 |
-
$
|
1435 |
-
}
|
1436 |
-
if ( empty( $headers ) && function_exists( 'headers_list' ) ) {
|
1437 |
-
$headers = array();
|
1438 |
-
foreach( headers_list() as $hdr ) {
|
1439 |
-
$header_parts = explode( ':', $hdr, 2 );
|
1440 |
-
$header_name = isset( $header_parts[0] ) ? trim( $header_parts[0] ) : '';
|
1441 |
-
$header_value = isset( $header_parts[1] ) ? trim( $header_parts[1] ) : '';
|
1442 |
|
1443 |
-
|
|
|
1444 |
}
|
1445 |
-
}
|
1446 |
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1450 |
}
|
1451 |
}
|
1452 |
|
@@ -2760,7 +2777,7 @@ function wp_cache_post_edit( $post_id ) {
|
|
2760 |
|
2761 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2762 |
// define this constant to disable the post status check.
|
2763 |
-
if (
|
2764 |
wp_cache_debug( 'wp_cache_post_edit: draft post, not deleting any cache files. status: ' . $post->post_status, 4 );
|
2765 |
return $post_id;
|
2766 |
}
|
@@ -2825,17 +2842,24 @@ function wp_cache_post_change( $post_id ) {
|
|
2825 |
wp_cache_debug( "wp_cache_post_change(${action}): Already processed post $post_id.", 4 );
|
2826 |
return $post_id;
|
2827 |
}
|
2828 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2829 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2830 |
// define this constant to disable the post status check.
|
2831 |
-
if (
|
2832 |
wp_cache_debug( 'wp_cache_post_change: draft post, not deleting any cache files.', 4 );
|
2833 |
return $post_id;
|
2834 |
}
|
2835 |
$last_processed = $post_id;
|
2836 |
|
2837 |
-
if( !wp_cache_writers_entry() )
|
2838 |
return $post_id;
|
|
|
2839 |
|
2840 |
if (
|
2841 |
isset( $wp_cache_refresh_single_only ) &&
|
52 |
return false;
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
|
56 |
wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
|
57 |
return false;
|
221 |
} else {
|
222 |
$ungzip = false;
|
223 |
}
|
224 |
+
foreach ( $meta['headers'] as $t => $header ) {
|
225 |
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
|
226 |
+
if ( strpos( $header, 'Last-Modified:' ) === false ) {
|
227 |
+
header( $header );
|
228 |
+
}
|
229 |
}
|
230 |
if ( isset( $wpsc_served_header ) && $wpsc_served_header ) {
|
231 |
header( 'X-WP-Super-Cache: Served WPCache cache file' );
|
821 |
global $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
|
822 |
|
823 |
if ( $url ) {
|
824 |
+
$key = intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace( '/:.*$/', '', $WPSC_HTTP_HOST ) . $url;
|
825 |
} else {
|
826 |
$key = get_current_url_supercache_dir();
|
827 |
}
|
1105 |
}
|
1106 |
}
|
1107 |
foreach( (array) $lines as $line ) {
|
1108 |
+
if (
|
1109 |
+
trim( $new ) != '' &&
|
1110 |
+
trim( $new ) == trim( $line )
|
1111 |
+
) {
|
1112 |
+
wp_cache_debug( "wp_cache_replace_line: setting not changed - $new" );
|
1113 |
+
return false;
|
1114 |
+
} elseif ( preg_match( "/$old/", $line ) ) {
|
1115 |
+
wp_cache_debug( "wp_cache_replace_line: changing line " . trim( $line ) . " to *$new*" );
|
1116 |
$found = true;
|
|
|
1117 |
}
|
1118 |
}
|
1119 |
|
1120 |
+
$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
|
1121 |
+
rename( $tmp_config_filename, $tmp_wpcache_filename . ".php" );
|
1122 |
+
$tmp_config_filename .= ".php";
|
1123 |
+
wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
|
1124 |
+
$fd = fopen( $tmp_config_filename, 'w' );
|
1125 |
if ( ! $fd ) {
|
1126 |
if ( function_exists( 'set_transient' ) ) {
|
1127 |
set_transient( 'wpsc_config_error', 'config_file_ro', 10 );
|
1150 |
}
|
1151 |
}
|
1152 |
fclose( $fd );
|
1153 |
+
rename( $tmp_config_filename, $my_file );
|
1154 |
+
wp_cache_debug( 'wp_cache_replace_line: moved ' . $tmp_config_filename . ' to ' . $my_file );
|
1155 |
|
1156 |
if ( function_exists( "opcache_invalidate" ) ) {
|
1157 |
@opcache_invalidate( $my_file );
|
1168 |
return false;
|
1169 |
}
|
1170 |
|
1171 |
+
if ( wp_cache_user_agent_is_rejected() ) {
|
1172 |
+
wp_cache_debug( 'wp_cache_phase2: No caching to do as user agent rejected.' );
|
1173 |
+
return false;
|
1174 |
+
}
|
1175 |
+
|
1176 |
wp_cache_debug( 'In WP Cache Phase 2', 5 );
|
1177 |
|
1178 |
$wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. https://wordpress.org/support/topic/224349
|
1387 |
|
1388 |
function wp_cache_get_response_headers() {
|
1389 |
static $known_headers = array(
|
1390 |
+
'Access-Control-Allow-Origin',
|
1391 |
+
'Accept-Ranges',
|
1392 |
+
'Age',
|
1393 |
+
'Allow',
|
1394 |
+
'Cache-Control',
|
1395 |
+
'Connection',
|
1396 |
+
'Content-Encoding',
|
1397 |
+
'Content-Language',
|
1398 |
+
'Content-Length',
|
1399 |
+
'Content-Location',
|
1400 |
+
'Content-MD5',
|
1401 |
+
'Content-Disposition',
|
1402 |
+
'Content-Range',
|
1403 |
+
'Content-Type',
|
1404 |
+
'Date',
|
1405 |
+
'ETag',
|
1406 |
+
'Expires',
|
1407 |
+
'Last-Modified',
|
1408 |
+
'Link',
|
1409 |
+
'Location',
|
1410 |
+
'P3P',
|
1411 |
+
'Pragma',
|
1412 |
+
'Proxy-Authenticate',
|
1413 |
+
'Referrer-Policy',
|
1414 |
+
'Refresh',
|
1415 |
+
'Retry-After',
|
1416 |
+
'Server',
|
1417 |
+
'Status',
|
1418 |
+
'Strict-Transport-Security',
|
1419 |
+
'Trailer',
|
1420 |
+
'Transfer-Encoding',
|
1421 |
+
'Upgrade',
|
1422 |
+
'Vary',
|
1423 |
+
'Via',
|
1424 |
+
'Warning',
|
1425 |
+
'WWW-Authenticate',
|
1426 |
+
'X-Frame-Options',
|
1427 |
+
'Public-Key-Pins',
|
1428 |
+
'X-XSS-Protection',
|
1429 |
+
'Content-Security-Policy',
|
1430 |
+
'X-Pingback',
|
1431 |
+
'X-Content-Security-Policy',
|
1432 |
+
'X-WebKit-CSP',
|
1433 |
+
'X-Content-Type-Options',
|
1434 |
+
'X-Powered-By',
|
1435 |
+
'X-UA-Compatible',
|
1436 |
+
'X-Robots-Tag',
|
1437 |
+
);
|
1438 |
+
|
1439 |
+
if ( ! function_exists( 'headers_list' ) ) {
|
1440 |
+
return array();
|
1441 |
+
}
|
1442 |
|
1443 |
$known_headers = apply_filters( 'wpsc_known_headers', $known_headers );
|
1444 |
|
1445 |
+
if ( ! isset( $known_headers['age'] ) ) {
|
1446 |
$known_headers = array_map( 'strtolower', $known_headers );
|
1447 |
}
|
1448 |
|
1449 |
$headers = array();
|
1450 |
+
foreach ( headers_list() as $hdr ) {
|
1451 |
+
$ptr = strpos( $hdr, ':' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1452 |
|
1453 |
+
if ( empty( $ptr ) ) {
|
1454 |
+
continue;
|
1455 |
}
|
|
|
1456 |
|
1457 |
+
$hdr_key = rtrim( substr( $hdr, 0, $ptr ) );
|
1458 |
+
|
1459 |
+
if ( in_array( strtolower( $hdr_key ), $known_headers, true ) ) {
|
1460 |
+
$hdr_val = ltrim( substr( $hdr, $ptr + 1 ) );
|
1461 |
+
|
1462 |
+
if ( ! empty( $headers[ $hdr_key ] ) ) {
|
1463 |
+
$hdr_val = $headers[ $hdr_key ] . ', ' . $hdr_val;
|
1464 |
+
}
|
1465 |
+
|
1466 |
+
$headers[ $hdr_key ] = $hdr_val;
|
1467 |
}
|
1468 |
}
|
1469 |
|
2777 |
|
2778 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2779 |
// define this constant to disable the post status check.
|
2780 |
+
if ( ! defined( 'WPSCFORCEUPDATE' ) && ! in_array( get_post_status( $post ), array( 'publish', 'private' ), true ) ) {
|
2781 |
wp_cache_debug( 'wp_cache_post_edit: draft post, not deleting any cache files. status: ' . $post->post_status, 4 );
|
2782 |
return $post_id;
|
2783 |
}
|
2842 |
wp_cache_debug( "wp_cache_post_change(${action}): Already processed post $post_id.", 4 );
|
2843 |
return $post_id;
|
2844 |
}
|
2845 |
+
|
2846 |
+
$post = get_post( $post_id );
|
2847 |
+
$ptype = is_object( $post ) ? get_post_type_object( $post->post_type ) : null;
|
2848 |
+
if ( empty( $ptype ) || ! $ptype->public ) {
|
2849 |
+
return $post_id;
|
2850 |
+
}
|
2851 |
+
|
2852 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2853 |
// define this constant to disable the post status check.
|
2854 |
+
if ( ! defined( 'WPSCFORCEUPDATE' ) && ! in_array( get_post_status( $post ), array( 'publish', 'private' ), true ) ) {
|
2855 |
wp_cache_debug( 'wp_cache_post_change: draft post, not deleting any cache files.', 4 );
|
2856 |
return $post_id;
|
2857 |
}
|
2858 |
$last_processed = $post_id;
|
2859 |
|
2860 |
+
if ( ! wp_cache_writers_entry() ) {
|
2861 |
return $post_id;
|
2862 |
+
}
|
2863 |
|
2864 |
if (
|
2865 |
isset( $wp_cache_refresh_single_only ) &&
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
-
Version: 1.6.
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
@@ -33,6 +33,13 @@ if ( ! function_exists( 'wp_cache_phase2' ) ) {
|
|
33 |
require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
function wpsc_init() {
|
37 |
global $wp_cache_config_file, $wp_cache_config_file_sample, $wp_cache_file, $wp_cache_check_wp_config, $wp_cache_link;
|
38 |
|
@@ -76,17 +83,13 @@ global $wp_cache_preload_email_me, $wp_cache_preload_email_volume;
|
|
76 |
global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
|
77 |
global $wp_cache_config_file, $wp_cache_config_file_sample;
|
78 |
|
79 |
-
//
|
80 |
-
if (
|
81 |
-
$
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
87 |
-
@include($wp_cache_config_file_sample);
|
88 |
-
} else {
|
89 |
-
get_wpcachehome();
|
90 |
}
|
91 |
|
92 |
include(WPCACHEHOME . 'wp-cache-base.php');
|
@@ -116,25 +119,42 @@ add_action( 'template_redirect', 'wp_cache_set_home' );
|
|
116 |
include_once( WPCACHEHOME . 'ossdl-cdn.php' );
|
117 |
|
118 |
function get_wpcachehome() {
|
119 |
-
if(
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
124 |
} else {
|
125 |
-
die( sprintf(
|
126 |
}
|
127 |
}
|
128 |
}
|
129 |
|
130 |
-
function
|
131 |
-
global $
|
132 |
-
|
133 |
-
|
134 |
-
if (
|
135 |
-
|
|
|
|
|
|
|
136 |
}
|
137 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
wp_cache_remove_index();
|
140 |
|
@@ -157,9 +177,7 @@ if ( is_admin() ) {
|
|
157 |
function wpsupercache_deactivate() {
|
158 |
global $wp_cache_config_file, $wp_cache_link, $cache_path;
|
159 |
|
160 |
-
|
161 |
-
unlink( $wp_cache_link );
|
162 |
-
}
|
163 |
|
164 |
if ( ! empty( $cache_path ) ) {
|
165 |
prune_super_cache( $cache_path, true );
|
@@ -202,29 +220,23 @@ register_activation_hook( __FILE__, 'wpsupercache_activate' );
|
|
202 |
function wpsupercache_site_admin() {
|
203 |
global $wp_version;
|
204 |
|
205 |
-
if ( version_compare(
|
206 |
return current_user_can( 'setup_network' );
|
207 |
}
|
208 |
|
209 |
-
|
210 |
-
return is_super_admin();
|
211 |
-
} elseif ( function_exists( 'is_site_admin' ) ) {
|
212 |
-
return is_site_admin();
|
213 |
-
} else {
|
214 |
-
return true;
|
215 |
-
}
|
216 |
}
|
217 |
|
218 |
function wp_cache_add_pages() {
|
219 |
-
|
220 |
-
|
221 |
-
add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
|
222 |
}
|
223 |
}
|
224 |
-
add_action('admin_menu', 'wp_cache_add_pages');
|
225 |
|
226 |
function wp_cache_network_pages() {
|
227 |
-
add_submenu_page('settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
|
228 |
}
|
229 |
add_action( 'network_admin_menu', 'wp_cache_network_pages' );
|
230 |
|
@@ -233,17 +245,18 @@ function wp_cache_manager_error_checks() {
|
|
233 |
global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
|
234 |
global $htaccess_path;
|
235 |
|
236 |
-
if ( !wpsupercache_site_admin() )
|
237 |
return false;
|
|
|
238 |
|
239 |
-
if (
|
240 |
-
echo '<div class="notice notice-error"><h4>' .
|
241 |
-
|
242 |
-
|
243 |
|
244 |
-
if( !ini_get( 'safe_mode_gid' ) ) {
|
245 |
-
|
246 |
-
|
|
|
247 |
} else {
|
248 |
_e( 'You or an administrator must disable this. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.', 'wp-super-cache' );
|
249 |
}
|
@@ -481,21 +494,23 @@ add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
|
|
481 |
*/
|
482 |
function admin_bar_delete_page() {
|
483 |
|
484 |
-
if (
|
485 |
return false;
|
486 |
}
|
487 |
|
488 |
-
$req_path =
|
489 |
$referer = wp_get_referer();
|
490 |
$valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false;
|
491 |
|
492 |
$path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
|
493 |
|
494 |
if ( $path ) {
|
495 |
-
$path
|
496 |
$supercachepath = realpath( get_supercache_dir() );
|
497 |
|
498 |
-
if ( false
|
|
|
|
|
499 |
wp_die( 'Could not delete directory' );
|
500 |
}
|
501 |
|
@@ -503,7 +518,7 @@ function admin_bar_delete_page() {
|
|
503 |
}
|
504 |
|
505 |
if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
|
506 |
-
|
507 |
exit;
|
508 |
}
|
509 |
}
|
@@ -512,7 +527,7 @@ if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) {
|
|
512 |
}
|
513 |
|
514 |
function wp_cache_manager_updates() {
|
515 |
-
global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $
|
516 |
global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
|
517 |
|
518 |
if ( !wpsupercache_site_admin() )
|
@@ -557,7 +572,7 @@ function wp_cache_manager_updates() {
|
|
557 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
558 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
559 |
}
|
560 |
-
$advanced_settings = array( 'wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', '
|
561 |
foreach( $advanced_settings as $setting ) {
|
562 |
if ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) {
|
563 |
$_POST[ $setting ] = 1;
|
@@ -661,13 +676,6 @@ function wp_cache_manager_updates() {
|
|
661 |
}
|
662 |
wp_cache_setting( 'wp_cache_mod_rewrite', $wp_cache_mod_rewrite );
|
663 |
|
664 |
-
if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) {
|
665 |
-
$wp_cache_hello_world = 1;
|
666 |
-
} else {
|
667 |
-
$wp_cache_hello_world = 0;
|
668 |
-
}
|
669 |
-
wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . $wp_cache_hello_world . ";", $wp_cache_config_file);
|
670 |
-
|
671 |
if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
|
672 |
$wp_cache_clear_on_post_edit = 1;
|
673 |
} else {
|
@@ -760,7 +768,7 @@ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' )
|
|
760 |
add_action( 'admin_init', 'wp_cache_manager_updates' );
|
761 |
|
762 |
function wp_cache_manager() {
|
763 |
-
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled
|
764 |
global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get;
|
765 |
global $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret;
|
766 |
global $wp_super_cache_front_page_check, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes;
|
@@ -849,23 +857,25 @@ table.wpsc-settings-table {
|
|
849 |
echo '<div class="wrap">';
|
850 |
echo '<h3>' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '</h3>';
|
851 |
|
852 |
-
//
|
853 |
-
if ( $cache_enabled
|
854 |
$wp_cache_mod_rewrite = 0;
|
855 |
-
} elseif ( !isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) {
|
856 |
$wp_cache_mod_rewrite = 1;
|
857 |
}
|
858 |
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
|
|
|
|
865 |
}
|
866 |
|
867 |
-
if (
|
868 |
-
if ( $super_cache_enabled
|
869 |
global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
|
870 |
$count = wpsc_post_count();
|
871 |
if ( $count > 1000 ) {
|
@@ -874,31 +884,33 @@ table.wpsc-settings-table {
|
|
874 |
$min_refresh_interval = 30;
|
875 |
}
|
876 |
$return = wpsc_preload_settings( $min_refresh_interval );
|
877 |
-
$msg
|
878 |
if ( empty( $return ) == false ) {
|
879 |
-
foreach( $return as $message ) {
|
880 |
$msg .= $message;
|
881 |
}
|
882 |
}
|
883 |
$currently_preloading = false;
|
884 |
|
885 |
$preload_counter = get_option( 'preload_cache_counter' );
|
886 |
-
if ( isset( $preload_counter[
|
887 |
-
update_option( 'preload_cache_counter', array( 'c' => $preload_counter[
|
888 |
-
|
889 |
-
|
|
|
|
|
890 |
$currently_preloading = true;
|
891 |
-
if ( @file_exists( $cache_path .
|
892 |
-
$url
|
893 |
-
$msg .=
|
894 |
}
|
895 |
if ( $msg != '' ) {
|
896 |
-
echo '<div class="notice notice-warning"><h4>' .
|
897 |
-
echo '<form name="do_preload" action="" method="POST">';
|
898 |
echo '<input type="hidden" name="action" value="preload" />';
|
899 |
echo '<input type="hidden" name="page" value="wpsupercache" />';
|
900 |
-
echo '<p><input class="button-primary" type="submit" name="preload_off" value="' .
|
901 |
-
wp_nonce_field('wp-cache');
|
902 |
echo '</form>';
|
903 |
echo '</div>';
|
904 |
}
|
@@ -909,60 +921,63 @@ table.wpsc-settings-table {
|
|
909 |
}
|
910 |
}
|
911 |
|
|
|
912 |
|
913 |
-
|
914 |
-
|
915 |
-
if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
|
916 |
-
wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
|
917 |
wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
|
918 |
}
|
919 |
|
920 |
-
if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
|
921 |
-
unlink($wp_cache_config_file);
|
922 |
-
echo '<strong>' .
|
923 |
}
|
924 |
|
925 |
if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
|
926 |
-
wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file);
|
927 |
} else {
|
928 |
-
wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file);
|
929 |
}
|
930 |
$home_path = parse_url( site_url() );
|
931 |
-
$home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path[
|
932 |
-
if (! isset( $wp_cache_home_path ) ) {
|
933 |
$wp_cache_home_path = '/';
|
934 |
wp_cache_setting( 'wp_cache_home_path', '/' );
|
935 |
}
|
936 |
-
if ( "$home_path" != "$wp_cache_home_path" )
|
937 |
wp_cache_setting( 'wp_cache_home_path', $home_path );
|
|
|
938 |
|
939 |
-
|
940 |
-
if( $wp_cache_mobile_enabled == 1 ) {
|
941 |
update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
|
942 |
}
|
943 |
|
944 |
-
?>
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
case
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
|
|
|
|
|
|
|
|
958 |
if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
|
959 |
echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
|
960 |
echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
|
961 |
echo '<p>' . __( 'In ’Preload Mode’ regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
|
962 |
-
echo '<form name="cache_filler" action="" method="POST">';
|
963 |
echo '<input type="hidden" name="action" value="preload" />';
|
964 |
echo '<input type="hidden" name="page" value="wpsupercache" />';
|
965 |
-
echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='wp_cache_preload_interval' value='" . (int)$wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>';
|
966 |
if ( $count > 100 ) {
|
967 |
$step = (int)( $count / 10 );
|
968 |
|
@@ -1014,9 +1029,9 @@ table.wpsc-settings-table {
|
|
1014 |
}
|
1015 |
echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Save Settings', 'wp-super-cache' ) . '" />';
|
1016 |
echo '</div>';
|
1017 |
-
wp_nonce_field('wp-cache');
|
1018 |
echo '</form>';
|
1019 |
-
echo '<form name="do_preload" action="" method="POST">';
|
1020 |
echo '<input type="hidden" name="action" value="preload" />';
|
1021 |
echo '<input type="hidden" name="page" value="wpsupercache" />';
|
1022 |
echo '<div class="submit">';
|
@@ -1026,25 +1041,27 @@ table.wpsc-settings-table {
|
|
1026 |
echo '<input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
|
1027 |
}
|
1028 |
echo '</div>';
|
1029 |
-
wp_nonce_field('wp-cache');
|
1030 |
echo '</form>';
|
1031 |
} else {
|
1032 |
echo '<div class="notice notice-warning"><p>' . __( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ) . '</p></div>';
|
1033 |
}
|
1034 |
-
|
1035 |
case 'plugins':
|
1036 |
-
|
1037 |
-
|
1038 |
case 'debug':
|
1039 |
-
|
1040 |
-
|
1041 |
case 'settings':
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
|
|
|
|
1048 |
<tr valign="top">
|
1049 |
<th scope="row"><label for="wp_cache_enabled"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th>
|
1050 |
<td>
|
@@ -1067,44 +1084,44 @@ table.wpsc-settings-table {
|
|
1067 |
</fieldset>
|
1068 |
</td>
|
1069 |
</tr>
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
<label><input type='checkbox' name='cache_rebuild_files' <?php if ( $cache_rebuild_files ) echo "checked"; ?> value='1'> <?php _e( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
|
1088 |
<?php
|
1089 |
$disable_304 = true;
|
1090 |
if ( 0 == $wp_cache_mod_rewrite )
|
1091 |
$disable_304 = false;
|
1092 |
if ( $disable_304 )
|
1093 |
echo "<strike>";
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
|
|
1108 |
<tr valign="top">
|
1109 |
<th scope="row"><label for="wp_cache_status"><?php _e( 'Advanced', 'wp-super-cache' ); ?></label></th>
|
1110 |
<td>
|
@@ -1162,85 +1179,90 @@ table.wpsc-settings-table {
|
|
1162 |
</td>
|
1163 |
</tr>
|
1164 |
</table>
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
|
|
|
|
|
|
1177 |
|
1178 |
-
|
1179 |
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
|
1188 |
-
|
1189 |
|
1190 |
-
|
1191 |
|
1192 |
-
|
1193 |
|
1194 |
-
|
1195 |
-
case
|
1196 |
default:
|
1197 |
-
echo '<form name="wp_manager" action="" method="post">';
|
1198 |
echo '<input type="hidden" name="action" value="easysetup" />';
|
1199 |
-
wp_nonce_field('wp-cache');
|
1200 |
-
|
|
|
1201 |
<tr valign="top">
|
1202 |
-
<th scope="row"><label for="wp_cache_status"><?php
|
1203 |
<td>
|
1204 |
<fieldset>
|
1205 |
-
<label><input type='radio' name='wp_cache_easy_on' value='1' <?php
|
1206 |
-
<label><input type='radio' name='wp_cache_easy_on' value='0' <?php
|
1207 |
</fieldset>
|
1208 |
</td>
|
1209 |
</tr>
|
1210 |
-
|
1211 |
<?php
|
1212 |
-
if ( ! $is_nginx && $cache_enabled &&
|
1213 |
$scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) );
|
1214 |
-
if ( $scrules
|
1215 |
-
echo
|
1216 |
}
|
1217 |
}
|
1218 |
-
echo
|
1219 |
if ( $cache_enabled ) {
|
1220 |
-
echo
|
1221 |
-
echo '<p>' .
|
1222 |
echo '<p>' . __( 'Note: if you use Cloudflare or other transparent front-end proxy service this test may fail.<ol><li> If you have Cloudflare minification enabled this plugin may detect differences in the pages and report an error.</li><li> Try using the development mode of Cloudflare to perform the test. You can disable development mode afterwards if the test succeeds.</li></ol>', 'wp-super-cache' ) . '</p>';
|
1223 |
-
if ( array_key_exists('action', $_POST) && $_POST[
|
1224 |
$url = trailingslashit( get_bloginfo( 'url' ) );
|
1225 |
-
if ( isset( $_POST[
|
1226 |
$url = str_replace( 'https://', 'http://', $url );
|
1227 |
-
|
1228 |
-
$
|
|
|
1229 |
$cache_test_error = false;
|
1230 |
-
$page
|
1231 |
-
foreach( $test_messages as $message ) {
|
1232 |
-
echo
|
1233 |
-
$page[ $c ] = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
|
1234 |
-
if ( !is_wp_error( $page[ $c ] ) ) {
|
1235 |
-
$fp = fopen( $cache_path . $c .
|
1236 |
-
fwrite( $fp, $page[ $c ][
|
1237 |
fclose( $fp );
|
1238 |
-
echo '<span style="color: #0a0; font-weight: bold;">' .
|
1239 |
sleep( 1 );
|
1240 |
} else {
|
1241 |
$cache_test_error = true;
|
1242 |
-
echo '<span style="color: #a00; font-weight: bold;">' .
|
1243 |
-
$errors
|
1244 |
$messages = '';
|
1245 |
foreach ( $page[ $c ]->get_error_codes() as $code ) {
|
1246 |
$severity = $page[ $c ]->get_error_data( $code );
|
@@ -1248,64 +1270,67 @@ table.wpsc-settings-table {
|
|
1248 |
$errors .= $severity . ': ' . $err . "<br />\n";
|
1249 |
}
|
1250 |
}
|
1251 |
-
if (
|
1252 |
-
echo
|
|
|
1253 |
}
|
1254 |
$c ++;
|
1255 |
}
|
1256 |
|
1257 |
if ( false == $cache_test_error ) {
|
1258 |
-
echo '<ul><li>' . sprintf(
|
1259 |
-
echo '<li>' . sprintf(
|
1260 |
}
|
1261 |
|
1262 |
-
if ( false == $cache_test_error && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[
|
1263 |
-
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[
|
1264 |
-
|
1265 |
-
echo '<p>' . sprintf(
|
1266 |
-
echo '<p
|
|
|
1267 |
} else {
|
1268 |
-
echo '<p><strong>' .
|
1269 |
-
echo '<p>' .
|
1270 |
-
echo '<ol><li>' .
|
1271 |
-
echo '<li>' .
|
1272 |
-
echo '<li>' .
|
1273 |
-
echo
|
1274 |
}
|
1275 |
}
|
1276 |
-
echo '<form name="cache_tester" action="" method="post">';
|
1277 |
echo '<input type="hidden" name="action" value="test" />';
|
1278 |
-
if (
|
1279 |
-
echo
|
|
|
1280 |
|
1281 |
if ( isset( $wp_super_cache_comments ) && $wp_super_cache_comments == 0 ) {
|
1282 |
-
echo
|
1283 |
-
echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' .
|
1284 |
} else {
|
1285 |
echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
|
1286 |
}
|
1287 |
|
1288 |
-
wp_nonce_field('wp-cache');
|
1289 |
echo '</form>';
|
1290 |
}
|
1291 |
-
echo
|
1292 |
-
echo
|
1293 |
-
echo '<form name="wp_cache_content_delete" action="
|
1294 |
echo '<input type="hidden" name="wp_delete_cache" />';
|
1295 |
-
echo '<div class="submit"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' .
|
1296 |
-
wp_nonce_field('wp-cache');
|
1297 |
echo "</form>\n";
|
1298 |
|
1299 |
-
if ( (
|
1300 |
-
echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
|
1301 |
echo '<input type="hidden" name="wp_delete_all_cache" />';
|
1302 |
-
echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' .
|
1303 |
-
wp_nonce_field('wp-cache');
|
1304 |
echo "</form><br />\n";
|
1305 |
}
|
1306 |
?>
|
1307 |
-
<h4 class="clear"><?php
|
1308 |
-
<p><?php
|
1309 |
<ul style="list-style: square; margin-left: 2em;">
|
1310 |
<li><?php printf( __( '<a href="%s">Jetpack</a> provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ), 'https://jetpack.com/redirect/?source=jitm-wpsc-recommended' ); ?></li>
|
1311 |
<li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://yslow.org/', 'https://gtmetrix.com/' ); ?></li>
|
@@ -1313,12 +1338,12 @@ table.wpsc-settings-table {
|
|
1313 |
<li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
|
1314 |
<li><?php printf( __( '<a href="%s">WP Crontrol</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
|
1315 |
</ul>
|
1316 |
-
|
1317 |
<?php
|
1318 |
-
break;
|
1319 |
-
}
|
1320 |
|
|
|
|
|
1321 |
?>
|
|
|
1322 |
</fieldset>
|
1323 |
</td><td valign='top' style='width: 300px'>
|
1324 |
<div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 3px 15px'>
|
@@ -1334,25 +1359,26 @@ table.wpsc-settings-table {
|
|
1334 |
<li><?php printf( __( 'Visit the <a href="%1$s">plugin homepage</a>.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/' ); ?></li>
|
1335 |
<li><?php printf( __( 'Try out the <a href="%1$s">development version</a> for the latest fixes (<a href="%2$s">changelog</a>).', 'wp-super-cache' ), 'https://odd.blog/y/2o', 'https://plugins.trac.wordpress.org/log/wp-super-cache/' ); ?></li>
|
1336 |
</ol>
|
1337 |
-
<h4><?php
|
1338 |
<p><?php printf( __( 'Please <a href="%s">rate us</a> and give feedback.', 'wp-super-cache' ), 'https://wordpress.org/support/plugin/wp-super-cache/reviews?rate=5#new-post' ); ?></p>
|
1339 |
|
1340 |
<?php
|
1341 |
if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
|
1342 |
$start_date = get_option( 'wpsupercache_start' );
|
1343 |
-
if (
|
1344 |
$start_date = time();
|
1345 |
}
|
1346 |
?>
|
1347 |
<p><?php printf( __( 'Cached pages since %1$s : <strong>%2$s</strong>', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?></p>
|
1348 |
<p><?php _e( 'Newest Cached Pages:', 'wp-super-cache' ); ?><ol>
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
|
|
1356 |
</p><?php
|
1357 |
} elseif ( false == get_option( 'wpsupercache_start' ) ) {
|
1358 |
update_option( 'wpsupercache_start', time() );
|
@@ -1368,51 +1394,55 @@ table.wpsc-settings-table {
|
|
1368 |
}
|
1369 |
|
1370 |
function wpsc_plugins_tab() {
|
1371 |
-
echo '<p>' .
|
1372 |
-
echo '<p>' .
|
1373 |
echo '<p>' . sprintf( __( '<strong>Warning</strong>! Due to the way WordPress upgrades plugins, the ones you upload to the WP Super Cache folder (wp-super-cache/plugins/) will be deleted when you upgrade WP Super Cache. To avoid this loss, load your cache plugins from a different location. When you set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php, WP Super Cache will look there instead. <br />You can find additional details in the <a href="%s">developer documentation</a>.', 'wp-super-cache' ), 'https://odd.blog/wp-super-cache-developers/' ) . '</p>';
|
1374 |
ob_start();
|
1375 |
-
if( defined( 'WP_CACHE' ) ) {
|
1376 |
-
if( function_exists( 'do_cacheaction' ) ) {
|
1377 |
do_cacheaction( 'cache_admin_page' );
|
1378 |
}
|
1379 |
}
|
1380 |
$out = ob_get_contents();
|
1381 |
ob_end_clean();
|
1382 |
-
|
1383 |
-
|
1384 |
-
echo
|
|
|
1385 |
echo $out;
|
1386 |
-
echo
|
1387 |
}
|
1388 |
-
|
1389 |
}
|
1390 |
|
1391 |
-
function wpsc_admin_tabs( $current =
|
1392 |
-
global $
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
} else {
|
1397 |
-
$current = 'easy';
|
1398 |
-
}
|
1399 |
-
}
|
1400 |
-
$tabs = array( 'easy' => __( 'Easy', 'wp-super-cache' ), 'settings' => __( 'Advanced', 'wp-super-cache' ), 'cdn' => __( 'CDN', 'wp-super-cache' ), 'contents' => __( 'Contents', 'wp-super-cache' ), 'preload' => __( 'Preload', 'wp-super-cache' ), 'plugins' => __( 'Plugins', 'wp-super-cache' ), 'debug' => __( 'Debug', 'wp-super-cache' ) );
|
1401 |
-
$links = array();
|
1402 |
-
foreach( $tabs as $tab => $name ) {
|
1403 |
-
if ( $current == $tab ) {
|
1404 |
-
$links[] = "<a class='nav-tab nav-tab-active' href='?page=wpsupercache&tab=$tab'>$name</a>";
|
1405 |
-
} else {
|
1406 |
-
$links[] = "<a class='nav-tab' href='?page=wpsupercache&tab=$tab'>$name</a>";
|
1407 |
-
}
|
1408 |
}
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1415 |
}
|
|
|
|
|
1416 |
}
|
1417 |
|
1418 |
function wsc_mod_rewrite() {
|
@@ -1482,8 +1512,9 @@ function wsc_mod_rewrite() {
|
|
1482 |
}
|
1483 |
|
1484 |
function wp_cache_restore() {
|
|
|
1485 |
echo '<fieldset class="options"><h4>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h4>';
|
1486 |
-
echo '<form name="wp_restore" action="#top" method="post">';
|
1487 |
echo '<input type="hidden" name="wp_restore_config" />';
|
1488 |
echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>';
|
1489 |
wp_nonce_field('wp-cache');
|
@@ -1596,6 +1627,7 @@ function wpsc_update_direct_pages() {
|
|
1596 |
function wp_lock_down() {
|
1597 |
global $cached_direct_pages, $cache_enabled, $super_cache_enabled;
|
1598 |
|
|
|
1599 |
$wp_lock_down = wp_update_lock_down();
|
1600 |
|
1601 |
?><a name='lockdown'></a>
|
@@ -1614,11 +1646,11 @@ function wp_lock_down() {
|
|
1614 |
}
|
1615 |
$new_lockdown = $wp_lock_down == '1' ? '0' : '1';
|
1616 |
$new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
|
1617 |
-
echo '<form name="wp_lock_down" action="#lockdown" method="post">';
|
1618 |
echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
|
1619 |
-
echo
|
1620 |
-
wp_nonce_field('wp-cache');
|
1621 |
-
echo
|
1622 |
|
1623 |
?></fieldset><?php
|
1624 |
if( $cache_enabled == true && $super_cache_enabled == true ) {
|
@@ -1639,7 +1671,7 @@ function wp_lock_down() {
|
|
1639 |
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( '%s is writable. Please make it readonly after your page is generated as this is a security risk.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
|
1640 |
}
|
1641 |
}
|
1642 |
-
echo '<form name="direct_page" action="#direct" method="post">';
|
1643 |
if( is_array( $cached_direct_pages ) ) {
|
1644 |
$out = '';
|
1645 |
foreach( $cached_direct_pages as $page ) {
|
@@ -1655,20 +1687,27 @@ function wp_lock_down() {
|
|
1655 |
echo "$out</table>";
|
1656 |
}
|
1657 |
}
|
1658 |
-
if( $readonly != 'READONLY' )
|
1659 |
-
echo __( "Add direct page:", 'wp-super-cache' ) . "<input type='text' $readonly name='new_direct_page' size='30' value='' />";
|
1660 |
|
1661 |
-
|
1662 |
-
|
1663 |
-
echo "<p>" . sprintf( __( 'For example: to cache <em>%1$sabout/</em>, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ), trailingslashit( get_option( 'siteurl' ) ) ) . "</p>";
|
1664 |
-
echo "<p>" . __( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . "</p>";
|
1665 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1666 |
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
echo
|
1671 |
-
|
|
|
|
|
1672 |
} // if $super_cache_enabled
|
1673 |
}
|
1674 |
|
@@ -1769,6 +1808,7 @@ function wp_cache_time_update() {
|
|
1769 |
function wp_cache_edit_max_time() {
|
1770 |
global $cache_max_time, $wp_cache_config_file, $valid_nonce, $super_cache_enabled, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval, $cache_time_interval, $cache_gc_email_me, $wp_cache_preload_on;
|
1771 |
|
|
|
1772 |
$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
|
1773 |
|
1774 |
wp_cache_time_update();
|
@@ -1803,7 +1843,7 @@ function wp_cache_edit_max_time() {
|
|
1803 |
});
|
1804 |
});";
|
1805 |
echo "</script>";
|
1806 |
-
echo '<form name="wp_edit_max_time" action="#expirytime" method="post">';
|
1807 |
echo '<input name="action" value="expirytime" type="hidden" />';
|
1808 |
echo '<table class="form-table">';
|
1809 |
echo '<tr><td><label for="wp_max_time"><strong>' . __( 'Cache Timeout', 'wp-super-cache' ) . '</strong></label></td>';
|
@@ -1873,13 +1913,16 @@ function wp_cache_update_rejected_ua() {
|
|
1873 |
function wp_cache_edit_rejected_ua() {
|
1874 |
global $cache_rejected_user_agent, $wp_cache_config_file, $valid_nonce;
|
1875 |
|
1876 |
-
if ( !function_exists( 'apache_request_headers' ) )
|
|
|
|
|
1877 |
|
|
|
1878 |
wp_cache_update_rejected_ua();
|
1879 |
|
1880 |
echo '<a name="useragents"></a><fieldset class="options"><h4>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h4>';
|
1881 |
echo "<p>" . __( 'Strings in the HTTP ’User Agent’ header that prevent WP-Cache from caching bot, spiders, and crawlers’ requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "</p>\n";
|
1882 |
-
echo '<form name="wp_edit_rejected_user_agent" action="#useragents" method="post">';
|
1883 |
echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
1884 |
foreach( $cache_rejected_user_agent as $ua ) {
|
1885 |
echo esc_html( $ua ) . "\n";
|
@@ -1911,11 +1954,12 @@ function wp_cache_update_rejected_pages() {
|
|
1911 |
function wp_cache_edit_rejected_pages() {
|
1912 |
global $wp_cache_config_file, $valid_nonce, $wp_cache_pages;
|
1913 |
|
|
|
1914 |
wp_cache_update_rejected_pages();
|
1915 |
|
1916 |
echo '<a name="rejectpages"></a>';
|
1917 |
echo '<p>' . __( 'Do not cache the following page types. See the <a href="https://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> documentation for a complete discussion on each type.', 'wp-super-cache' ) . '</p>';
|
1918 |
-
echo '<form name="wp_edit_rejected_pages" action="#rejectpages" method="post">';
|
1919 |
echo '<input type="hidden" name="wp_edit_rejected_pages" value="1" />';
|
1920 |
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[single]" ' . checked( 1, $wp_cache_pages[ 'single' ], false ) . ' /> ' . __( 'Single Posts', 'wp-super-cache' ) . ' (is_single)</label><br />';
|
1921 |
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[pages]" ' . checked( 1, $wp_cache_pages[ 'pages' ], false ) . ' /> ' . __( 'Pages', 'wp-super-cache' ) . ' (is_page)</label><br />';
|
@@ -1947,10 +1991,11 @@ function wp_cache_update_rejected_strings() {
|
|
1947 |
function wp_cache_edit_rejected() {
|
1948 |
global $cache_rejected_uri;
|
1949 |
|
|
|
1950 |
wp_cache_update_rejected_strings();
|
1951 |
|
1952 |
echo '<a name="rejecturi"></a>';
|
1953 |
-
echo '<form name="wp_edit_rejected" action="#rejecturi" method="post">';
|
1954 |
echo "<p>" . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it’s enough to specify the year, i.e. ’/2004/’. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "</p>\n";
|
1955 |
echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
1956 |
foreach ($cache_rejected_uri as $file) {
|
@@ -1975,9 +2020,10 @@ function wp_cache_edit_accepted() {
|
|
1975 |
global $cache_acceptable_files;
|
1976 |
|
1977 |
wp_cache_update_accepted_strings();
|
|
|
1978 |
|
1979 |
echo '<a name="cancache"></a>';
|
1980 |
-
echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="#cancache" method="post">';
|
1981 |
echo "<p>" . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "</p>\n";
|
1982 |
echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
|
1983 |
foreach ($cache_acceptable_files as $file) {
|
@@ -2076,6 +2122,7 @@ function wp_cache_debug_settings() {
|
|
2076 |
global $wp_cache_debug_username;
|
2077 |
|
2078 |
extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username
|
|
|
2079 |
|
2080 |
echo '<a name="debug"></a>';
|
2081 |
echo '<fieldset class="options">';
|
@@ -2092,12 +2139,13 @@ function wp_cache_debug_settings() {
|
|
2092 |
}
|
2093 |
echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
|
2094 |
|
2095 |
-
echo '<form name="wpsc_delete" action="" method="post">';
|
2096 |
wp_nonce_field('wp-cache');
|
2097 |
echo "<input type='hidden' name='wpsc_delete_log' value='1' />";
|
2098 |
submit_button( __( 'Delete', 'wp-super-cache' ), 'delete', 'wpsc_delete_log_form', false );
|
2099 |
echo "</form>";
|
2100 |
-
|
|
|
2101 |
if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
|
2102 |
$debug_status_message = __( 'Enable Logging', 'wp-super-cache' );
|
2103 |
$not_status = 1;
|
@@ -2109,7 +2157,8 @@ function wp_cache_debug_settings() {
|
|
2109 |
wp_nonce_field('wp-cache');
|
2110 |
submit_button( $debug_status_message, 'primary', 'wpsc_log_status', true );
|
2111 |
echo "</form>";
|
2112 |
-
|
|
|
2113 |
echo "<input type='hidden' name='wp_cache_debug' value='1' /><br />";
|
2114 |
echo "<table class='form-table'>";
|
2115 |
echo "<tr><th>" . __( 'IP Address', 'wp-super-cache' ) . "</th><td> <input type='text' size='20' name='wp_cache_debug_ip' value='{$wp_cache_debug_ip}' /> " . sprintf( __( '(only log requests from this IP address. Your IP is %s)', 'wp-super-cache' ), $_SERVER[ 'REMOTE_ADDR' ] ) . "</td></tr>";
|
@@ -2120,15 +2169,15 @@ function wp_cache_debug_settings() {
|
|
2120 |
<!-- super cache --></pre></td></tr>";
|
2121 |
echo "</table>\n";
|
2122 |
if ( isset( $wp_super_cache_advanced_debug ) ) {
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
|
2131 |
-
|
2132 |
}
|
2133 |
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Settings', 'wp-super-cache' ) . '" /></div>';
|
2134 |
wp_nonce_field('wp-cache');
|
@@ -2523,6 +2572,16 @@ function wp_cache_create_advanced_cache() {
|
|
2523 |
}
|
2524 |
$ret = true;
|
2525 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2526 |
$file = file_get_contents( $wp_cache_file );
|
2527 |
$fp = @fopen( $wp_cache_link, 'w' );
|
2528 |
if( $fp ) {
|
@@ -2543,11 +2602,7 @@ function wp_cache_check_link() {
|
|
2543 |
if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
|
2544 |
return true;
|
2545 |
} else {
|
2546 |
-
|
2547 |
-
$ret = false;
|
2548 |
-
} else {
|
2549 |
-
$ret = wp_cache_create_advanced_cache();
|
2550 |
-
}
|
2551 |
}
|
2552 |
} else {
|
2553 |
$ret = wp_cache_create_advanced_cache();
|
@@ -2845,19 +2900,21 @@ function wp_cache_files() {
|
|
2845 |
|
2846 |
function wp_cache_delete_buttons() {
|
2847 |
|
2848 |
-
|
|
|
|
|
2849 |
echo '<input type="hidden" name="wp_delete_expired" />';
|
2850 |
echo '<div class="submit" style="float:left"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . '" /></div>';
|
2851 |
wp_nonce_field('wp-cache');
|
2852 |
echo "</form>\n";
|
2853 |
|
2854 |
-
echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
|
2855 |
echo '<input type="hidden" name="wp_delete_cache" />';
|
2856 |
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . '" /></div>';
|
2857 |
wp_nonce_field('wp-cache');
|
2858 |
echo "</form>\n";
|
2859 |
-
if ( (
|
2860 |
-
echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
|
2861 |
echo '<input type="hidden" name="wp_delete_all_cache" />';
|
2862 |
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
|
2863 |
wp_nonce_field('wp-cache');
|
@@ -2992,6 +3049,8 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
|
|
2992 |
return false;
|
2993 |
|
2994 |
if ( $handle = @opendir( $dir ) ) {
|
|
|
|
|
2995 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
2996 |
if ( is_file( $dir . $file ) == false || $file == 'index.html' ) {
|
2997 |
continue;
|
@@ -3004,8 +3063,9 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
|
|
3004 |
@unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
|
3005 |
} else {
|
3006 |
$meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true );
|
3007 |
-
if (
|
3008 |
continue;
|
|
|
3009 |
@unlink( $dir . $file);
|
3010 |
@unlink( $dir . 'meta/' . $file);
|
3011 |
}
|
@@ -3084,12 +3144,6 @@ function wpsc_remove_marker( $filename, $marker ) {
|
|
3084 |
}
|
3085 |
}
|
3086 |
|
3087 |
-
function wp_super_cache_footer() {
|
3088 |
-
?><p id='supercache'><?php printf( __( '%1$s is Stephen Fry proof thanks to caching by %2$s', 'wp-super-cache' ), get_bloginfo( 'name', 'display' ), '<a href="https://odd.blog/wp-super-cache/">WP Super Cache</a>' ); ?></p><?php
|
3089 |
-
}
|
3090 |
-
if( isset( $wp_cache_hello_world ) && $wp_cache_hello_world )
|
3091 |
-
add_action( 'wp_footer', 'wp_super_cache_footer' );
|
3092 |
-
|
3093 |
if( get_option( 'gzipcompression' ) )
|
3094 |
update_option( 'gzipcompression', 0 );
|
3095 |
|
@@ -3144,8 +3198,9 @@ function wp_cache_admin_notice() {
|
|
3144 |
echo '<div class="notice notice-info"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
|
3145 |
|
3146 |
if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
|
3147 |
-
|
3148 |
-
|
|
|
3149 |
}
|
3150 |
}
|
3151 |
add_action( 'admin_notices', 'wp_cache_admin_notice' );
|
@@ -3218,6 +3273,7 @@ function wpsc_update_htaccess() {
|
|
3218 |
function wpsc_update_htaccess_form( $short_form = true ) {
|
3219 |
global $wpmu_version;
|
3220 |
|
|
|
3221 |
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
|
3222 |
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
|
3223 |
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h5>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h5><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
|
@@ -3236,7 +3292,7 @@ function wpsc_update_htaccess_form( $short_form = true ) {
|
|
3236 |
echo "</div>";
|
3237 |
}
|
3238 |
if ( !isset( $wpmu_version ) || $wpmu_version == '' ) {
|
3239 |
-
echo '<form name="updatehtaccess" action="#modrewrite" method="post">';
|
3240 |
echo '<input type="hidden" name="updatehtaccess" value="1" />';
|
3241 |
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . '" /></div>';
|
3242 |
wp_nonce_field('wp-cache');
|
@@ -3760,7 +3816,7 @@ function wpsc_admin_bar_render( $wp_admin_bar ) {
|
|
3760 |
'id' => 'delete-cache',
|
3761 |
'title' => __( 'Delete Cache', 'wp-super-cache' ),
|
3762 |
'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ),
|
3763 |
-
'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' .
|
3764 |
) );
|
3765 |
}
|
3766 |
|
@@ -3769,7 +3825,7 @@ function wpsc_admin_bar_render( $wp_admin_bar ) {
|
|
3769 |
'parent' => '',
|
3770 |
'id' => 'delete-cache',
|
3771 |
'title' => __( 'Delete Cache', 'wp-super-cache' ),
|
3772 |
-
'meta' => array( 'title' => __( 'Delete Super Cache cached files
|
3773 |
'href' => wp_nonce_url( admin_url( 'options-general.php?page=wpsupercache&tab=contents&wp_delete_cache=1' ), 'wp-cache' )
|
3774 |
) );
|
3775 |
}
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
+
Version: 1.6.5
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
33 |
require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
|
34 |
}
|
35 |
|
36 |
+
if ( ! defined( 'PHP_VERSION_ID' ) ) {
|
37 |
+
// For versions of PHP below 5.2.7, this constant doesn't exist.
|
38 |
+
$wpsc_php_version = explode( '.', PHP_VERSION );
|
39 |
+
define( 'PHP_VERSION_ID', intval( $wpsc_php_version[0] * 10000 + $wpsc_php_version[1] * 100 + $wpsc_php_version[2] ) );
|
40 |
+
unset( $wpsc_php_version );
|
41 |
+
}
|
42 |
+
|
43 |
function wpsc_init() {
|
44 |
global $wp_cache_config_file, $wp_cache_config_file_sample, $wp_cache_file, $wp_cache_check_wp_config, $wp_cache_link;
|
45 |
|
83 |
global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
|
84 |
global $wp_cache_config_file, $wp_cache_config_file_sample;
|
85 |
|
86 |
+
// Check is cache config already loaded.
|
87 |
+
if ( ! isset( $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite, $cache_path ) &&
|
88 |
+
empty( $wp_cache_phase1_loaded ) &&
|
89 |
+
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
90 |
+
! @include( $wp_cache_config_file )
|
91 |
+
) {
|
92 |
+
@include $wp_cache_config_file_sample; // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
include(WPCACHEHOME . 'wp-cache-base.php');
|
119 |
include_once( WPCACHEHOME . 'ossdl-cdn.php' );
|
120 |
|
121 |
function get_wpcachehome() {
|
122 |
+
if ( function_exists( '_deprecated_function' ) ) {
|
123 |
+
_deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.5' );
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( ! defined( 'WPCACHEHOME' ) ) {
|
127 |
+
if ( is_file( dirname( __FILE__ ) . '/wp-cache-config-sample.php' ) ) {
|
128 |
+
define( 'WPCACHEHOME', trailingslashit( dirname( __FILE__ ) ) );
|
129 |
+
} elseif ( is_file( dirname( __FILE__ ) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
|
130 |
+
define( 'WPCACHEHOME', dirname( __FILE__ ) . '/wp-super-cache/' );
|
131 |
} else {
|
132 |
+
die( sprintf( esc_html__( 'Please create %s /wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ) );
|
133 |
}
|
134 |
}
|
135 |
}
|
136 |
|
137 |
+
function wpsc_remove_advanced_cache() {
|
138 |
+
global $wp_cache_link;
|
139 |
+
if ( file_exists( $wp_cache_link ) ) {
|
140 |
+
$file = file_get_contents( $wp_cache_link );
|
141 |
+
if (
|
142 |
+
strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ||
|
143 |
+
strpos( $file, "WP SUPER CACHE 1.2" )
|
144 |
+
) {
|
145 |
+
unlink( $wp_cache_link );
|
146 |
}
|
147 |
}
|
148 |
+
}
|
149 |
+
|
150 |
+
function wpsupercache_uninstall() {
|
151 |
+
global $wp_cache_config_file, $cache_path;
|
152 |
+
|
153 |
+
wpsc_remove_advanced_cache();
|
154 |
+
|
155 |
+
if ( file_exists( $wp_cache_config_file ) ) {
|
156 |
+
unlink( $wp_cache_config_file );
|
157 |
+
}
|
158 |
|
159 |
wp_cache_remove_index();
|
160 |
|
177 |
function wpsupercache_deactivate() {
|
178 |
global $wp_cache_config_file, $wp_cache_link, $cache_path;
|
179 |
|
180 |
+
wpsc_remove_advanced_cache();
|
|
|
|
|
181 |
|
182 |
if ( ! empty( $cache_path ) ) {
|
183 |
prune_super_cache( $cache_path, true );
|
220 |
function wpsupercache_site_admin() {
|
221 |
global $wp_version;
|
222 |
|
223 |
+
if ( version_compare( $wp_version, '4.8', '>=' ) ) {
|
224 |
return current_user_can( 'setup_network' );
|
225 |
}
|
226 |
|
227 |
+
return is_super_admin();
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
}
|
229 |
|
230 |
function wp_cache_add_pages() {
|
231 |
+
if ( wpsupercache_site_admin() ) {
|
232 |
+
// In single or MS mode add this menu item too, but only for superadmins in MS mode.
|
233 |
+
add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
|
234 |
}
|
235 |
}
|
236 |
+
add_action( 'admin_menu', 'wp_cache_add_pages' );
|
237 |
|
238 |
function wp_cache_network_pages() {
|
239 |
+
add_submenu_page( 'settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
|
240 |
}
|
241 |
add_action( 'network_admin_menu', 'wp_cache_network_pages' );
|
242 |
|
245 |
global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
|
246 |
global $htaccess_path;
|
247 |
|
248 |
+
if ( ! wpsupercache_site_admin() ) {
|
249 |
return false;
|
250 |
+
}
|
251 |
|
252 |
+
if ( PHP_VERSION_ID < 50300 && ( ini_get( 'safe_mode' ) === '1' || strtolower( ini_get( 'safe_mode' ) ) === 'on' ) ) { // @codingStandardsIgnoreLine
|
253 |
+
echo '<div class="notice notice-error"><h4>' . esc_html__( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h4>';
|
254 |
+
echo '<p>' . esc_html__( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . '<br />';
|
|
|
255 |
|
256 |
+
if ( ! ini_get( 'safe_mode_gid' ) ) { // @codingStandardsIgnoreLine
|
257 |
+
esc_html_e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' );
|
258 |
+
echo '<br />';
|
259 |
+
printf( __( 'You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) );
|
260 |
} else {
|
261 |
_e( 'You or an administrator must disable this. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.', 'wp-super-cache' );
|
262 |
}
|
494 |
*/
|
495 |
function admin_bar_delete_page() {
|
496 |
|
497 |
+
if ( ! current_user_can( 'delete_others_posts' ) ) {
|
498 |
return false;
|
499 |
}
|
500 |
|
501 |
+
$req_path = isset( $_GET['path'] ) ? sanitize_text_field( stripslashes( $_GET['path'] ) ) : '';
|
502 |
$referer = wp_get_referer();
|
503 |
$valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false;
|
504 |
|
505 |
$path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
|
506 |
|
507 |
if ( $path ) {
|
508 |
+
$path = trailingslashit( $path );
|
509 |
$supercachepath = realpath( get_supercache_dir() );
|
510 |
|
511 |
+
if ( false === wp_cache_confirm_delete( $path ) ||
|
512 |
+
0 !== strpos( $path, $supercachepath )
|
513 |
+
) {
|
514 |
wp_die( 'Could not delete directory' );
|
515 |
}
|
516 |
|
518 |
}
|
519 |
|
520 |
if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
|
521 |
+
wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
|
522 |
exit;
|
523 |
}
|
524 |
}
|
527 |
}
|
528 |
|
529 |
function wp_cache_manager_updates() {
|
530 |
+
global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get;
|
531 |
global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
|
532 |
|
533 |
if ( !wpsupercache_site_admin() )
|
572 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
573 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
574 |
}
|
575 |
+
$advanced_settings = array( 'wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', 'wp_cache_clear_on_post_edit', 'wp_cache_not_logged_in', 'wp_cache_make_known_anon','wp_cache_object_cache', 'wp_cache_refresh_single_only', 'cache_compression' );
|
576 |
foreach( $advanced_settings as $setting ) {
|
577 |
if ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) {
|
578 |
$_POST[ $setting ] = 1;
|
676 |
}
|
677 |
wp_cache_setting( 'wp_cache_mod_rewrite', $wp_cache_mod_rewrite );
|
678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
|
680 |
$wp_cache_clear_on_post_edit = 1;
|
681 |
} else {
|
768 |
add_action( 'admin_init', 'wp_cache_manager_updates' );
|
769 |
|
770 |
function wp_cache_manager() {
|
771 |
+
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled;
|
772 |
global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get;
|
773 |
global $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret;
|
774 |
global $wp_super_cache_front_page_check, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes;
|
857 |
echo '<div class="wrap">';
|
858 |
echo '<h3>' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '</h3>';
|
859 |
|
860 |
+
// Set a default.
|
861 |
+
if ( false === $cache_enabled && ! isset( $wp_cache_mod_rewrite ) ) {
|
862 |
$wp_cache_mod_rewrite = 0;
|
863 |
+
} elseif ( ! isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) {
|
864 |
$wp_cache_mod_rewrite = 1;
|
865 |
}
|
866 |
|
867 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
868 |
+
$curr_tab = ! empty( $_GET['tab'] ) ? sanitize_text_field( stripslashes( $_GET['tab'] ) ) : ''; // WPCS: sanitization ok.
|
869 |
+
if ( empty( $curr_tab ) ) {
|
870 |
+
$curr_tab = 'easy';
|
871 |
+
if ( $wp_cache_mod_rewrite ) {
|
872 |
+
$curr_tab = 'settings';
|
873 |
+
echo '<div class="notice notice-info is-dismissible"><p>' . __( 'Notice: <em>Expert mode caching enabled</em>. Showing Advanced Settings Page by default.', 'wp-super-cache' ) . '</p></div>';
|
874 |
+
}
|
875 |
}
|
876 |
|
877 |
+
if ( 'preload' === $curr_tab ) {
|
878 |
+
if ( true === $super_cache_enabled && ! defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
|
879 |
global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
|
880 |
$count = wpsc_post_count();
|
881 |
if ( $count > 1000 ) {
|
884 |
$min_refresh_interval = 30;
|
885 |
}
|
886 |
$return = wpsc_preload_settings( $min_refresh_interval );
|
887 |
+
$msg = '';
|
888 |
if ( empty( $return ) == false ) {
|
889 |
+
foreach ( $return as $message ) {
|
890 |
$msg .= $message;
|
891 |
}
|
892 |
}
|
893 |
$currently_preloading = false;
|
894 |
|
895 |
$preload_counter = get_option( 'preload_cache_counter' );
|
896 |
+
if ( isset( $preload_counter['first'] ) ) { // converted from int to array
|
897 |
+
update_option( 'preload_cache_counter', array( 'c' => $preload_counter['c'], 't' => time() ) );
|
898 |
+
}
|
899 |
+
|
900 |
+
if ( is_array( $preload_counter ) && $preload_counter['c'] > 0 ) {
|
901 |
+
$msg .= '<p>' . sprintf( esc_html__( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter['c'] - 100 ), $preload_counter['c'] ) . '</p>';
|
902 |
$currently_preloading = true;
|
903 |
+
if ( @file_exists( $cache_path . 'preload_permalink.txt' ) ) {
|
904 |
+
$url = file_get_contents( $cache_path . 'preload_permalink.txt' );
|
905 |
+
$msg .= '<p>' . sprintf( __( '<strong>Page last cached:</strong> %s', 'wp-super-cache' ), $url ) . '</p>';
|
906 |
}
|
907 |
if ( $msg != '' ) {
|
908 |
+
echo '<div class="notice notice-warning"><h4>' . esc_html__( 'Preload Active', 'wp-super-cache' ) . '</h4>' . $msg;
|
909 |
+
echo '<form name="do_preload" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
|
910 |
echo '<input type="hidden" name="action" value="preload" />';
|
911 |
echo '<input type="hidden" name="page" value="wpsupercache" />';
|
912 |
+
echo '<p><input class="button-primary" type="submit" name="preload_off" value="' . esc_html__( 'Cancel Cache Preload', 'wp-super-cache' ) . '" /></p>';
|
913 |
+
wp_nonce_field( 'wp-cache' );
|
914 |
echo '</form>';
|
915 |
echo '</div>';
|
916 |
}
|
921 |
}
|
922 |
}
|
923 |
|
924 |
+
wpsc_admin_tabs( $curr_tab );
|
925 |
|
926 |
+
if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && ! wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
|
927 |
+
wp_schedule_single_event( time() + 360, 'wp_cache_check_site_hook' );
|
|
|
|
|
928 |
wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
|
929 |
}
|
930 |
|
931 |
+
if ( isset( $_REQUEST['wp_restore_config'] ) && $valid_nonce ) {
|
932 |
+
unlink( $wp_cache_config_file );
|
933 |
+
echo '<strong>' . esc_html__( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>';
|
934 |
}
|
935 |
|
936 |
if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
|
937 |
+
wp_cache_replace_line( '^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file );
|
938 |
} else {
|
939 |
+
wp_cache_replace_line( '^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file );
|
940 |
}
|
941 |
$home_path = parse_url( site_url() );
|
942 |
+
$home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path['path'] : '' );
|
943 |
+
if ( ! isset( $wp_cache_home_path ) ) {
|
944 |
$wp_cache_home_path = '/';
|
945 |
wp_cache_setting( 'wp_cache_home_path', '/' );
|
946 |
}
|
947 |
+
if ( "$home_path" != "$wp_cache_home_path" ) {
|
948 |
wp_cache_setting( 'wp_cache_home_path', $home_path );
|
949 |
+
}
|
950 |
|
951 |
+
if ( $wp_cache_mobile_enabled == 1 ) {
|
|
|
952 |
update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
|
953 |
}
|
954 |
|
955 |
+
?>
|
956 |
+
<table class="wpsc-settings-table"><td valign="top">
|
957 |
+
<?php
|
958 |
+
|
959 |
+
switch ( $curr_tab ) {
|
960 |
+
case 'cdn':
|
961 |
+
scossdl_off_options();
|
962 |
+
break;
|
963 |
+
case 'tester':
|
964 |
+
case 'contents':
|
965 |
+
echo '<a name="test"></a>';
|
966 |
+
wp_cache_files();
|
967 |
+
break;
|
968 |
+
case 'preload':
|
969 |
+
if ( ! $cache_enabled ) {
|
970 |
+
wp_die( esc_html__( 'Caching must be enabled to use this feature', 'wp-super-cache' ) );
|
971 |
+
}
|
972 |
+
echo '<a name="preload"></a>';
|
973 |
if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
|
974 |
echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
|
975 |
echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
|
976 |
echo '<p>' . __( 'In ’Preload Mode’ regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
|
977 |
+
echo '<form name="cache_filler" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
|
978 |
echo '<input type="hidden" name="action" value="preload" />';
|
979 |
echo '<input type="hidden" name="page" value="wpsupercache" />';
|
980 |
+
echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='wp_cache_preload_interval' value='" . (int) $wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>';
|
981 |
if ( $count > 100 ) {
|
982 |
$step = (int)( $count / 10 );
|
983 |
|
1029 |
}
|
1030 |
echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Save Settings', 'wp-super-cache' ) . '" />';
|
1031 |
echo '</div>';
|
1032 |
+
wp_nonce_field( 'wp-cache' );
|
1033 |
echo '</form>';
|
1034 |
+
echo '<form name="do_preload" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
|
1035 |
echo '<input type="hidden" name="action" value="preload" />';
|
1036 |
echo '<input type="hidden" name="page" value="wpsupercache" />';
|
1037 |
echo '<div class="submit">';
|
1041 |
echo '<input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
|
1042 |
}
|
1043 |
echo '</div>';
|
1044 |
+
wp_nonce_field( 'wp-cache' );
|
1045 |
echo '</form>';
|
1046 |
} else {
|
1047 |
echo '<div class="notice notice-warning"><p>' . __( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ) . '</p></div>';
|
1048 |
}
|
1049 |
+
break;
|
1050 |
case 'plugins':
|
1051 |
+
wpsc_plugins_tab();
|
1052 |
+
break;
|
1053 |
case 'debug':
|
1054 |
+
wp_cache_debug_settings();
|
1055 |
+
break;
|
1056 |
case 'settings':
|
1057 |
+
if ( isset( $wp_cache_front_page_checks ) == false ) {
|
1058 |
+
$wp_cache_front_page_checks = true;
|
1059 |
+
}
|
1060 |
+
echo '<form name="wp_manager" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) ) . '" method="post">';
|
1061 |
+
wp_nonce_field( 'wp-cache' );
|
1062 |
+
echo '<input type="hidden" name="action" value="scupdates" />';
|
1063 |
+
?>
|
1064 |
+
<table class="form-table">
|
1065 |
<tr valign="top">
|
1066 |
<th scope="row"><label for="wp_cache_enabled"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th>
|
1067 |
<td>
|
1084 |
</fieldset>
|
1085 |
</td>
|
1086 |
</tr>
|
1087 |
+
<tr valign="top">
|
1088 |
+
<th scope="row"><label for="wp_cache_status"><?php esc_html_e( 'Miscellaneous', 'wp-super-cache' ); ?></label></th>
|
1089 |
+
<td>
|
1090 |
+
<fieldset>
|
1091 |
+
<legend class="hidden">Miscellaneous</legend>
|
1092 |
+
<label><input type='checkbox' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in ); ?> value='1'> <?php echo __( 'Don’t cache pages for <acronym title="Logged in users and those that comment">known users</acronym>.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
|
1093 |
+
<label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php checked( $wp_cache_no_cache_for_get ); ?> value='1'> <?php _e( 'Don’t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br />
|
1094 |
+
<?php if ( ! defined( 'WPSC_DISABLE_COMPRESSION' ) ) : ?>
|
1095 |
+
<?php if ( ! function_exists( 'gzencode' ) ) : ?>
|
1096 |
+
<em><?php esc_html_e( 'Warning! Compression is disabled as gzencode() function was not found.', 'wp-super-cache' ); ?></em><br />
|
1097 |
+
<?php else : ?>
|
1098 |
+
<label><input type='checkbox' name='cache_compression' <?php checked( $cache_compression ); ?> value='1'> <?php echo __( 'Compress pages so they’re served more quickly to visitors.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
|
1099 |
+
<em><?php esc_html_e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching it on and off clears the cache.', 'wp-super-cache' ); ?></em><br />
|
1100 |
+
<?php endif; ?>
|
1101 |
+
<?php endif; ?>
|
1102 |
+
<label><input type='checkbox' name='wpsc_save_headers' <?php checked( $wpsc_save_headers ); ?> value='1' /> <?php esc_html_e( 'Cache HTTP headers with page content.', 'wp-super-cache' ); ?></label><br />
|
1103 |
+
<label><input type='checkbox' name='cache_rebuild_files' <?php checked( $cache_rebuild_files ); ?> value='1'> <?php echo esc_html__( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
|
|
|
1104 |
<?php
|
1105 |
$disable_304 = true;
|
1106 |
if ( 0 == $wp_cache_mod_rewrite )
|
1107 |
$disable_304 = false;
|
1108 |
if ( $disable_304 )
|
1109 |
echo "<strike>";
|
1110 |
+
?>
|
1111 |
+
<label><input <?php disabled( $disable_304 ); ?> type='checkbox' name='wp_supercache_304' <?php checked( $wp_supercache_304 ); ?> value='1'> <?php echo esc_html__( '304 Not Modified browser caching. Indicate when a page has not been modified since it was last requested.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
|
1112 |
+
<?php
|
1113 |
+
if ( $disable_304 ) {
|
1114 |
+
echo '</strike>';
|
1115 |
+
echo '<p><strong>' . esc_html__( 'Warning! 304 browser caching is only supported when mod_rewrite caching is not used.', 'wp-super-cache' ) . '</strong></p>';
|
1116 |
+
} else {
|
1117 |
+
echo '<em>' . esc_html__( '304 support is disabled by default because some hosts have had problems with the headers used in the past.', 'wp-super-cache' ) . '</em><br />';
|
1118 |
+
}
|
1119 |
+
?>
|
1120 |
+
<label><input type='checkbox' name='wp_cache_make_known_anon' <?php checked( $wp_cache_make_known_anon ); ?> value='1'> <?php _e( 'Make known users anonymous so they’re served supercached static files.', 'wp-super-cache' ); ?></label><br />
|
1121 |
+
</legend>
|
1122 |
+
</fieldset>
|
1123 |
+
</td>
|
1124 |
+
</tr>
|
1125 |
<tr valign="top">
|
1126 |
<th scope="row"><label for="wp_cache_status"><?php _e( 'Advanced', 'wp-super-cache' ); ?></label></th>
|
1127 |
<td>
|
1179 |
</td>
|
1180 |
</tr>
|
1181 |
</table>
|
1182 |
+
<h4><?php esc_html_e( 'Note:', 'wp-super-cache' ); ?></h4>
|
1183 |
+
<ol>
|
1184 |
+
<li><?php esc_html_e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required, then simple instructions are provided.', 'wp-super-cache' ); ?></li>
|
1185 |
+
<li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable is probably a good idea!)', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ); ?></li>
|
1186 |
+
<li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), plugins_url() ); ?></li>
|
1187 |
+
<li><?php echo '<em>' . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/', 'https://wordpress.org/support/topic-tag/wp-super-cache/?forum_id=10' ) . '</em>'; ?></li>
|
1188 |
+
</ol>
|
1189 |
|
1190 |
+
<?php
|
1191 |
+
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" /></div>';
|
1192 |
+
wp_nonce_field( 'wp-cache' );
|
1193 |
+
|
1194 |
+
?></form><?php
|
1195 |
+
|
1196 |
+
wsc_mod_rewrite();
|
1197 |
|
1198 |
+
wp_cache_edit_max_time();
|
1199 |
|
1200 |
+
echo '<a name="files"></a><fieldset class="options"><h4>' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '</h4>';
|
1201 |
+
wp_cache_edit_rejected_pages();
|
1202 |
+
echo "\n";
|
1203 |
+
wp_cache_edit_rejected();
|
1204 |
+
echo "\n";
|
1205 |
+
wp_cache_edit_accepted();
|
1206 |
+
echo '</fieldset>';
|
1207 |
|
1208 |
+
wp_cache_edit_rejected_ua();
|
1209 |
|
1210 |
+
wp_lock_down();
|
1211 |
|
1212 |
+
wp_cache_restore();
|
1213 |
|
1214 |
+
break;
|
1215 |
+
case 'easy':
|
1216 |
default:
|
1217 |
+
echo '<form name="wp_manager" action="' . esc_url_raw( add_query_arg( 'tab', 'easy', $admin_url ) ) . '" method="post">';
|
1218 |
echo '<input type="hidden" name="action" value="easysetup" />';
|
1219 |
+
wp_nonce_field( 'wp-cache' );
|
1220 |
+
?>
|
1221 |
+
<table class="form-table">
|
1222 |
<tr valign="top">
|
1223 |
+
<th scope="row"><label for="wp_cache_status"><?php esc_html_e( 'Caching', 'wp-super-cache' ); ?></label></th>
|
1224 |
<td>
|
1225 |
<fieldset>
|
1226 |
+
<label><input type='radio' name='wp_cache_easy_on' value='1' <?php checked( $cache_enabled ); ?> ><?php echo esc_html__( 'Caching On', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
|
1227 |
+
<label><input type='radio' name='wp_cache_easy_on' value='0' <?php checked( ! $cache_enabled ); ?> ><?php esc_html_e( 'Caching Off', 'wp-super-cache' ); ?></label><br />
|
1228 |
</fieldset>
|
1229 |
</td>
|
1230 |
</tr>
|
1231 |
+
</table>
|
1232 |
<?php
|
1233 |
+
if ( ! $is_nginx && $cache_enabled && ! $wp_cache_mod_rewrite ) {
|
1234 |
$scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) );
|
1235 |
+
if ( ! empty( $scrules ) ) {
|
1236 |
+
echo '<p><strong>' . esc_html__( 'Notice: Simple caching enabled but Supercache mod_rewrite rules from expert mode detected. Cached files will be served using those rules. If your site is working ok, please ignore this message. Otherwise, you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
|
1237 |
}
|
1238 |
}
|
1239 |
+
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" /></div></form>';
|
1240 |
if ( $cache_enabled ) {
|
1241 |
+
echo '<h4>' . esc_html__( 'Cache Tester', 'wp-super-cache' ) . '</h4>';
|
1242 |
+
echo '<p>' . esc_html__( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>';
|
1243 |
echo '<p>' . __( 'Note: if you use Cloudflare or other transparent front-end proxy service this test may fail.<ol><li> If you have Cloudflare minification enabled this plugin may detect differences in the pages and report an error.</li><li> Try using the development mode of Cloudflare to perform the test. You can disable development mode afterwards if the test succeeds.</li></ol>', 'wp-super-cache' ) . '</p>';
|
1244 |
+
if ( array_key_exists( 'action', $_POST ) && 'test' === $_POST['action'] && $valid_nonce ) {
|
1245 |
$url = trailingslashit( get_bloginfo( 'url' ) );
|
1246 |
+
if ( isset( $_POST['httponly'] ) ) {
|
1247 |
$url = str_replace( 'https://', 'http://', $url );
|
1248 |
+
}
|
1249 |
+
$test_messages = array( esc_html__( 'Fetching %s to prime cache: ', 'wp-super-cache' ), esc_html__( 'Fetching first copy of %s: ', 'wp-super-cache' ), esc_html__( 'Fetching second copy of %s: ', 'wp-super-cache' ) );
|
1250 |
+
$c = 0;
|
1251 |
$cache_test_error = false;
|
1252 |
+
$page = array();
|
1253 |
+
foreach ( $test_messages as $message ) {
|
1254 |
+
echo '<p>' . sprintf( $message, $url );
|
1255 |
+
$page[ $c ] = wp_remote_get( $url, array( 'timeout' => 60, 'blocking' => true ) );
|
1256 |
+
if ( ! is_wp_error( $page[ $c ] ) ) {
|
1257 |
+
$fp = fopen( $cache_path . $c . '.html', 'w' );
|
1258 |
+
fwrite( $fp, $page[ $c ]['body'] );
|
1259 |
fclose( $fp );
|
1260 |
+
echo '<span style="color: #0a0; font-weight: bold;">' . esc_html__( 'OK', 'wp-super-cache' ) . "</span> (<a href='" . esc_url_raw( WP_CONTENT_URL . '/cache/' . $c . '.html' ) . "'>" . $c . '.html</a>)</p>';
|
1261 |
sleep( 1 );
|
1262 |
} else {
|
1263 |
$cache_test_error = true;
|
1264 |
+
echo '<span style="color: #a00; font-weight: bold;">' . esc_html__( 'FAILED', 'wp-super-cache' ) . '</span></p>';
|
1265 |
+
$errors = '';
|
1266 |
$messages = '';
|
1267 |
foreach ( $page[ $c ]->get_error_codes() as $code ) {
|
1268 |
$severity = $page[ $c ]->get_error_data( $code );
|
1270 |
$errors .= $severity . ': ' . $err . "<br />\n";
|
1271 |
}
|
1272 |
}
|
1273 |
+
if ( ! empty( $errors ) ) {
|
1274 |
+
echo '<p>' . sprintf( __( '<strong>Errors:</strong> %s', 'wp-super-cache' ), $errors ) . '</p>';
|
1275 |
+
}
|
1276 |
}
|
1277 |
$c ++;
|
1278 |
}
|
1279 |
|
1280 |
if ( false == $cache_test_error ) {
|
1281 |
+
echo '<ul><li>' . sprintf( esc_html__( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, intval( $page[1]['response']['code'] ), esc_attr( $page[1]['response']['message'] ) ) . '</li>';
|
1282 |
+
echo '<li>' . sprintf( esc_html__( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, intval( $page[2]['response']['code'] ), esc_attr( $page[2]['response']['message'] ) ) . '</li></ul>';
|
1283 |
}
|
1284 |
|
1285 |
+
if ( false == $cache_test_error && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[1]['body'], $matches1 ) &&
|
1286 |
+
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[2]['body'], $matches2 ) && $matches1[2] == $matches2[2]
|
1287 |
+
) {
|
1288 |
+
echo '<p>' . sprintf( esc_html__( 'Page 1: %s', 'wp-super-cache' ), $matches1[2] ) . '</p>';
|
1289 |
+
echo '<p>' . sprintf( esc_html__( 'Page 2: %s', 'wp-super-cache' ), $matches2[2] ) . '</p>';
|
1290 |
+
echo '<p><span style="color: #0a0; font-weight: bold;">' . esc_html__( 'The timestamps on both pages match!', 'wp-super-cache' ) . '</span></p>';
|
1291 |
} else {
|
1292 |
+
echo '<p><strong>' . esc_html__( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '</strong></p>';
|
1293 |
+
echo '<p>' . esc_html__( 'Things you can do:', 'wp-super-cache' ) . '</p>';
|
1294 |
+
echo '<ol><li>' . esc_html__( 'Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.', 'wp-super-cache' ) . '</li>';
|
1295 |
+
echo '<li>' . esc_html__( 'Enable logging on the Debug page here. That should help you track down the problem.', 'wp-super-cache' ) . '</li>';
|
1296 |
+
echo '<li>' . esc_html__( 'You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.', 'wp-super-cache' ) . '</li>';
|
1297 |
+
echo '</ol>';
|
1298 |
}
|
1299 |
}
|
1300 |
+
echo '<form name="cache_tester" action="' . esc_url_raw( add_query_arg( 'tab', 'easy', $admin_url ) ) . '" method="post">';
|
1301 |
echo '<input type="hidden" name="action" value="test" />';
|
1302 |
+
if ( ! empty( $_SERVER['HTTPS'] ) && 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
|
1303 |
+
echo '<input type="checkbox" name="httponly" checked="checked" value="1" /> ' . esc_html__( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
|
1304 |
+
}
|
1305 |
|
1306 |
if ( isset( $wp_super_cache_comments ) && $wp_super_cache_comments == 0 ) {
|
1307 |
+
echo '<p>' . __( '<strong>Warning!</strong> Cache comments are currently disabled. Please go to the Debug page and enable Cache Status Messages there. You should clear the cache before testing.', 'wp-super-cache' ) . '</p>';
|
1308 |
+
echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' . esc_html__( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
|
1309 |
} else {
|
1310 |
echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
|
1311 |
}
|
1312 |
|
1313 |
+
wp_nonce_field( 'wp-cache' );
|
1314 |
echo '</form>';
|
1315 |
}
|
1316 |
+
echo '<h4>' . esc_html__( 'Delete Cached Pages', 'wp-super-cache' ) . '</h4>';
|
1317 |
+
echo '<p>' . esc_html__( 'Cached pages are stored on your server as html and PHP files. If you need to delete them, use the button below.', 'wp-super-cache' ) . '</p>';
|
1318 |
+
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) ) . '" method="post">';
|
1319 |
echo '<input type="hidden" name="wp_delete_cache" />';
|
1320 |
+
echo '<div class="submit"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . esc_html__( 'Delete Cache', 'wp-super-cache' ) . ' " /></div>';
|
1321 |
+
wp_nonce_field( 'wp-cache' );
|
1322 |
echo "</form>\n";
|
1323 |
|
1324 |
+
if ( is_multisite() && wpsupercache_site_admin() ) {
|
1325 |
+
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
|
1326 |
echo '<input type="hidden" name="wp_delete_all_cache" />';
|
1327 |
+
echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . esc_html__( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
|
1328 |
+
wp_nonce_field( 'wp-cache' );
|
1329 |
echo "</form><br />\n";
|
1330 |
}
|
1331 |
?>
|
1332 |
+
<h4 class="clear"><?php esc_html_e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h4>
|
1333 |
+
<p><?php esc_html_e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
|
1334 |
<ul style="list-style: square; margin-left: 2em;">
|
1335 |
<li><?php printf( __( '<a href="%s">Jetpack</a> provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ), 'https://jetpack.com/redirect/?source=jitm-wpsc-recommended' ); ?></li>
|
1336 |
<li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://yslow.org/', 'https://gtmetrix.com/' ); ?></li>
|
1338 |
<li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
|
1339 |
<li><?php printf( __( '<a href="%s">WP Crontrol</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
|
1340 |
</ul>
|
|
|
1341 |
<?php
|
|
|
|
|
1342 |
|
1343 |
+
break;
|
1344 |
+
}
|
1345 |
?>
|
1346 |
+
|
1347 |
</fieldset>
|
1348 |
</td><td valign='top' style='width: 300px'>
|
1349 |
<div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 3px 15px'>
|
1359 |
<li><?php printf( __( 'Visit the <a href="%1$s">plugin homepage</a>.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/' ); ?></li>
|
1360 |
<li><?php printf( __( 'Try out the <a href="%1$s">development version</a> for the latest fixes (<a href="%2$s">changelog</a>).', 'wp-super-cache' ), 'https://odd.blog/y/2o', 'https://plugins.trac.wordpress.org/log/wp-super-cache/' ); ?></li>
|
1361 |
</ol>
|
1362 |
+
<h4><?php esc_html_e( 'Rate This Plugin', 'wp-super-cache' ); ?></h4>
|
1363 |
<p><?php printf( __( 'Please <a href="%s">rate us</a> and give feedback.', 'wp-super-cache' ), 'https://wordpress.org/support/plugin/wp-super-cache/reviews?rate=5#new-post' ); ?></p>
|
1364 |
|
1365 |
<?php
|
1366 |
if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
|
1367 |
$start_date = get_option( 'wpsupercache_start' );
|
1368 |
+
if ( ! $start_date ) {
|
1369 |
$start_date = time();
|
1370 |
}
|
1371 |
?>
|
1372 |
<p><?php printf( __( 'Cached pages since %1$s : <strong>%2$s</strong>', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?></p>
|
1373 |
<p><?php _e( 'Newest Cached Pages:', 'wp-super-cache' ); ?><ol>
|
1374 |
+
<?php
|
1375 |
+
foreach ( array_reverse( (array) get_option( 'supercache_last_cached' ) ) as $url ) {
|
1376 |
+
$since = time() - strtotime( $url['date'] );
|
1377 |
+
echo "<li><a title='" . sprintf( esc_html__( 'Cached %s seconds ago', 'wp-super-cache' ), (int) $since ) . "' href='" . site_url( $url['url'] ) . "'>" . substr( $url['url'], 0, 20 ) . "</a></li>\n";
|
1378 |
+
}
|
1379 |
+
?>
|
1380 |
+
</ol>
|
1381 |
+
<small><?php esc_html_e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small>
|
1382 |
</p><?php
|
1383 |
} elseif ( false == get_option( 'wpsupercache_start' ) ) {
|
1384 |
update_option( 'wpsupercache_start', time() );
|
1394 |
}
|
1395 |
|
1396 |
function wpsc_plugins_tab() {
|
1397 |
+
echo '<p>' . esc_html__( 'Cache plugins are PHP scripts you\'ll find in a dedicated folder inside the WP Super Cache folder (wp-super-cache/plugins/). They load at the same time as WP Super Cache, and before regular WordPress plugins.', 'wp-super-cache' ) . '</p>';
|
1398 |
+
echo '<p>' . esc_html__( 'Keep in mind that cache plugins are for advanced users only. To create and manage them, you\'ll need extensive knowledge of both PHP and WordPress actions.', 'wp-super-cache' ) . '</p>';
|
1399 |
echo '<p>' . sprintf( __( '<strong>Warning</strong>! Due to the way WordPress upgrades plugins, the ones you upload to the WP Super Cache folder (wp-super-cache/plugins/) will be deleted when you upgrade WP Super Cache. To avoid this loss, load your cache plugins from a different location. When you set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php, WP Super Cache will look there instead. <br />You can find additional details in the <a href="%s">developer documentation</a>.', 'wp-super-cache' ), 'https://odd.blog/wp-super-cache-developers/' ) . '</p>';
|
1400 |
ob_start();
|
1401 |
+
if ( defined( 'WP_CACHE' ) ) {
|
1402 |
+
if ( function_exists( 'do_cacheaction' ) ) {
|
1403 |
do_cacheaction( 'cache_admin_page' );
|
1404 |
}
|
1405 |
}
|
1406 |
$out = ob_get_contents();
|
1407 |
ob_end_clean();
|
1408 |
+
|
1409 |
+
if ( SUBMITDISABLED == ' ' && $out != '' ) {
|
1410 |
+
echo '<h4>' . esc_html__( 'Available Plugins', 'wp-super-cache' ) . '</h4>';
|
1411 |
+
echo '<ol>';
|
1412 |
echo $out;
|
1413 |
+
echo '</ol>';
|
1414 |
}
|
|
|
1415 |
}
|
1416 |
|
1417 |
+
function wpsc_admin_tabs( $current = '' ) {
|
1418 |
+
global $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite;
|
1419 |
+
|
1420 |
+
if ( '' === $current ) {
|
1421 |
+
$current = ! empty( $_GET['tab'] ) ? stripslashes( $_GET['tab'] ) : ''; // WPCS: CSRF ok, sanitization ok.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1422 |
}
|
1423 |
+
|
1424 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1425 |
+
$admin_tabs = array(
|
1426 |
+
'easy' => __( 'Easy', 'wp-super-cache' ),
|
1427 |
+
'settings' => __( 'Advanced', 'wp-super-cache' ),
|
1428 |
+
'cdn' => __( 'CDN', 'wp-super-cache' ),
|
1429 |
+
'contents' => __( 'Contents', 'wp-super-cache' ),
|
1430 |
+
'preload' => __( 'Preload', 'wp-super-cache' ),
|
1431 |
+
'plugins' => __( 'Plugins', 'wp-super-cache' ),
|
1432 |
+
'debug' => __( 'Debug', 'wp-super-cache' ),
|
1433 |
+
);
|
1434 |
+
|
1435 |
+
echo '<div id="nav"><h3 class="themes-php">';
|
1436 |
+
|
1437 |
+
foreach ( $admin_tabs as $tab => $name ) {
|
1438 |
+
printf( '<a class="%s" href="%s">%s</a>',
|
1439 |
+
esc_attr( $tab === $current ? 'nav-tab nav-tab-active' : 'nav-tab' ),
|
1440 |
+
esc_url_raw( add_query_arg( 'tab', $tab, $admin_url ) ),
|
1441 |
+
esc_html( $name )
|
1442 |
+
);
|
1443 |
}
|
1444 |
+
|
1445 |
+
echo '</div></h3>';
|
1446 |
}
|
1447 |
|
1448 |
function wsc_mod_rewrite() {
|
1512 |
}
|
1513 |
|
1514 |
function wp_cache_restore() {
|
1515 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1516 |
echo '<fieldset class="options"><h4>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h4>';
|
1517 |
+
echo '<form name="wp_restore" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#top' ) . '" method="post">';
|
1518 |
echo '<input type="hidden" name="wp_restore_config" />';
|
1519 |
echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>';
|
1520 |
wp_nonce_field('wp-cache');
|
1627 |
function wp_lock_down() {
|
1628 |
global $cached_direct_pages, $cache_enabled, $super_cache_enabled;
|
1629 |
|
1630 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1631 |
$wp_lock_down = wp_update_lock_down();
|
1632 |
|
1633 |
?><a name='lockdown'></a>
|
1646 |
}
|
1647 |
$new_lockdown = $wp_lock_down == '1' ? '0' : '1';
|
1648 |
$new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
|
1649 |
+
echo '<form name="wp_lock_down" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#lockdown' ) . '" method="post">';
|
1650 |
echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
|
1651 |
+
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr( $new_lockdown_desc . ' ' . __( 'Lock Down', 'wp-super-cache' ) ) . '" /></div>';
|
1652 |
+
wp_nonce_field( 'wp-cache' );
|
1653 |
+
echo '</form>';
|
1654 |
|
1655 |
?></fieldset><?php
|
1656 |
if( $cache_enabled == true && $super_cache_enabled == true ) {
|
1671 |
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( '%s is writable. Please make it readonly after your page is generated as this is a security risk.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
|
1672 |
}
|
1673 |
}
|
1674 |
+
echo '<form name="direct_page" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#direct' ) . '" method="post">';
|
1675 |
if( is_array( $cached_direct_pages ) ) {
|
1676 |
$out = '';
|
1677 |
foreach( $cached_direct_pages as $page ) {
|
1687 |
echo "$out</table>";
|
1688 |
}
|
1689 |
}
|
|
|
|
|
1690 |
|
1691 |
+
if ( 'READONLY' !== $readonly ) {
|
1692 |
+
echo esc_html__( 'Add direct page:', 'wp-super-cache' ) . '<input type="text" name="new_direct_page" size="30" value="" />';
|
|
|
|
|
1693 |
}
|
1694 |
+
echo '<p>' . sprintf(
|
1695 |
+
esc_html__( 'Directly cached files are files created directly off %s where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.', 'wp-super-cache' ),
|
1696 |
+
esc_attr( ABSPATH )
|
1697 |
+
) . '</p>';
|
1698 |
+
if ( 'READONLY' !== $readonly ) {
|
1699 |
+
echo '<p>' . sprintf( __( 'For example: to cache <em>%1$sabout/</em>, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ),
|
1700 |
+
esc_attr( trailingslashit( get_option( 'siteurl' ) ) )
|
1701 |
+
) . '</p>';
|
1702 |
+
echo '<p>' . esc_html__( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . '</p>';
|
1703 |
|
1704 |
+
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr__( 'Update Direct Pages', 'wp-super-cache' ) . '" /></div>';
|
1705 |
+
}
|
1706 |
+
wp_nonce_field( 'wp-cache' );
|
1707 |
+
echo '</form>';
|
1708 |
+
?>
|
1709 |
+
</fieldset>
|
1710 |
+
<?php
|
1711 |
} // if $super_cache_enabled
|
1712 |
}
|
1713 |
|
1808 |
function wp_cache_edit_max_time() {
|
1809 |
global $cache_max_time, $wp_cache_config_file, $valid_nonce, $super_cache_enabled, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval, $cache_time_interval, $cache_gc_email_me, $wp_cache_preload_on;
|
1810 |
|
1811 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1812 |
$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
|
1813 |
|
1814 |
wp_cache_time_update();
|
1843 |
});
|
1844 |
});";
|
1845 |
echo "</script>";
|
1846 |
+
echo '<form name="wp_edit_max_time" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#expirytime' ) . '" method="post">';
|
1847 |
echo '<input name="action" value="expirytime" type="hidden" />';
|
1848 |
echo '<table class="form-table">';
|
1849 |
echo '<tr><td><label for="wp_max_time"><strong>' . __( 'Cache Timeout', 'wp-super-cache' ) . '</strong></label></td>';
|
1913 |
function wp_cache_edit_rejected_ua() {
|
1914 |
global $cache_rejected_user_agent, $wp_cache_config_file, $valid_nonce;
|
1915 |
|
1916 |
+
if ( ! function_exists( 'apache_request_headers' ) ) {
|
1917 |
+
return;
|
1918 |
+
}
|
1919 |
|
1920 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1921 |
wp_cache_update_rejected_ua();
|
1922 |
|
1923 |
echo '<a name="useragents"></a><fieldset class="options"><h4>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h4>';
|
1924 |
echo "<p>" . __( 'Strings in the HTTP ’User Agent’ header that prevent WP-Cache from caching bot, spiders, and crawlers’ requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "</p>\n";
|
1925 |
+
echo '<form name="wp_edit_rejected_user_agent" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#useragents' ) . '" method="post">';
|
1926 |
echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
1927 |
foreach( $cache_rejected_user_agent as $ua ) {
|
1928 |
echo esc_html( $ua ) . "\n";
|
1954 |
function wp_cache_edit_rejected_pages() {
|
1955 |
global $wp_cache_config_file, $valid_nonce, $wp_cache_pages;
|
1956 |
|
1957 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1958 |
wp_cache_update_rejected_pages();
|
1959 |
|
1960 |
echo '<a name="rejectpages"></a>';
|
1961 |
echo '<p>' . __( 'Do not cache the following page types. See the <a href="https://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> documentation for a complete discussion on each type.', 'wp-super-cache' ) . '</p>';
|
1962 |
+
echo '<form name="wp_edit_rejected_pages" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejectpages' ) . '" method="post">';
|
1963 |
echo '<input type="hidden" name="wp_edit_rejected_pages" value="1" />';
|
1964 |
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[single]" ' . checked( 1, $wp_cache_pages[ 'single' ], false ) . ' /> ' . __( 'Single Posts', 'wp-super-cache' ) . ' (is_single)</label><br />';
|
1965 |
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[pages]" ' . checked( 1, $wp_cache_pages[ 'pages' ], false ) . ' /> ' . __( 'Pages', 'wp-super-cache' ) . ' (is_page)</label><br />';
|
1991 |
function wp_cache_edit_rejected() {
|
1992 |
global $cache_rejected_uri;
|
1993 |
|
1994 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
1995 |
wp_cache_update_rejected_strings();
|
1996 |
|
1997 |
echo '<a name="rejecturi"></a>';
|
1998 |
+
echo '<form name="wp_edit_rejected" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejecturi' ) . '" method="post">';
|
1999 |
echo "<p>" . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it’s enough to specify the year, i.e. ’/2004/’. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "</p>\n";
|
2000 |
echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
2001 |
foreach ($cache_rejected_uri as $file) {
|
2020 |
global $cache_acceptable_files;
|
2021 |
|
2022 |
wp_cache_update_accepted_strings();
|
2023 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
2024 |
|
2025 |
echo '<a name="cancache"></a>';
|
2026 |
+
echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#cancache' ) . '" method="post">';
|
2027 |
echo "<p>" . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "</p>\n";
|
2028 |
echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
|
2029 |
foreach ($cache_acceptable_files as $file) {
|
2122 |
global $wp_cache_debug_username;
|
2123 |
|
2124 |
extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username
|
2125 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
2126 |
|
2127 |
echo '<a name="debug"></a>';
|
2128 |
echo '<fieldset class="options">';
|
2139 |
}
|
2140 |
echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
|
2141 |
|
2142 |
+
echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
|
2143 |
wp_nonce_field('wp-cache');
|
2144 |
echo "<input type='hidden' name='wpsc_delete_log' value='1' />";
|
2145 |
submit_button( __( 'Delete', 'wp-super-cache' ), 'delete', 'wpsc_delete_log_form', false );
|
2146 |
echo "</form>";
|
2147 |
+
|
2148 |
+
echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
|
2149 |
if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
|
2150 |
$debug_status_message = __( 'Enable Logging', 'wp-super-cache' );
|
2151 |
$not_status = 1;
|
2157 |
wp_nonce_field('wp-cache');
|
2158 |
submit_button( $debug_status_message, 'primary', 'wpsc_log_status', true );
|
2159 |
echo "</form>";
|
2160 |
+
|
2161 |
+
echo '<form name="wp_cache_debug" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
|
2162 |
echo "<input type='hidden' name='wp_cache_debug' value='1' /><br />";
|
2163 |
echo "<table class='form-table'>";
|
2164 |
echo "<tr><th>" . __( 'IP Address', 'wp-super-cache' ) . "</th><td> <input type='text' size='20' name='wp_cache_debug_ip' value='{$wp_cache_debug_ip}' /> " . sprintf( __( '(only log requests from this IP address. Your IP is %s)', 'wp-super-cache' ), $_SERVER[ 'REMOTE_ADDR' ] ) . "</td></tr>";
|
2169 |
<!-- super cache --></pre></td></tr>";
|
2170 |
echo "</table>\n";
|
2171 |
if ( isset( $wp_super_cache_advanced_debug ) ) {
|
2172 |
+
echo "<h5>" . __( 'Advanced', 'wp-super-cache' ) . "</h5><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>';
|
2173 |
+
echo "<p>" . __( 'I’m 99% certain that they aren’t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you’re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "</p>";
|
2174 |
+
echo "<table class='form-table'>";
|
2175 |
+
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_check' value='1' " . checked( 1, $wp_super_cache_front_page_check, false ) . " /> " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "</td></tr>";
|
2176 |
+
echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing, the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
|
2177 |
+
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
|
2178 |
+
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
|
2179 |
|
2180 |
+
echo "</table>\n";
|
2181 |
}
|
2182 |
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Settings', 'wp-super-cache' ) . '" /></div>';
|
2183 |
wp_nonce_field('wp-cache');
|
2572 |
}
|
2573 |
$ret = true;
|
2574 |
|
2575 |
+
if ( file_exists( $wp_cache_link ) ) {
|
2576 |
+
$file = file_get_contents( $wp_cache_link );
|
2577 |
+
if (
|
2578 |
+
! strpos( $file, "WP SUPER CACHE 0.8.9.1" ) &&
|
2579 |
+
! strpos( $file, "WP SUPER CACHE 1.2" )
|
2580 |
+
) {
|
2581 |
+
wp_die( '<div class="notice notice-error"><h4>' . __( 'Warning!', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file %s already exists. Please manually delete it before using this plugin.', 'wp-super-cache' ), $wp_cache_link ) . "</p></div>" );
|
2582 |
+
}
|
2583 |
+
}
|
2584 |
+
|
2585 |
$file = file_get_contents( $wp_cache_file );
|
2586 |
$fp = @fopen( $wp_cache_link, 'w' );
|
2587 |
if( $fp ) {
|
2602 |
if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
|
2603 |
return true;
|
2604 |
} else {
|
2605 |
+
$ret = wp_cache_create_advanced_cache();
|
|
|
|
|
|
|
|
|
2606 |
}
|
2607 |
} else {
|
2608 |
$ret = wp_cache_create_advanced_cache();
|
2900 |
|
2901 |
function wp_cache_delete_buttons() {
|
2902 |
|
2903 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
2904 |
+
|
2905 |
+
echo '<form name="wp_cache_content_expired" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
|
2906 |
echo '<input type="hidden" name="wp_delete_expired" />';
|
2907 |
echo '<div class="submit" style="float:left"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . '" /></div>';
|
2908 |
wp_nonce_field('wp-cache');
|
2909 |
echo "</form>\n";
|
2910 |
|
2911 |
+
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
|
2912 |
echo '<input type="hidden" name="wp_delete_cache" />';
|
2913 |
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . '" /></div>';
|
2914 |
wp_nonce_field('wp-cache');
|
2915 |
echo "</form>\n";
|
2916 |
+
if ( is_multisite() && wpsupercache_site_admin() ) {
|
2917 |
+
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
|
2918 |
echo '<input type="hidden" name="wp_delete_all_cache" />';
|
2919 |
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
|
2920 |
wp_nonce_field('wp-cache');
|
3049 |
return false;
|
3050 |
|
3051 |
if ( $handle = @opendir( $dir ) ) {
|
3052 |
+
$curr_blog_id = is_multisite() ? get_current_blog_id() : false;
|
3053 |
+
|
3054 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
3055 |
if ( is_file( $dir . $file ) == false || $file == 'index.html' ) {
|
3056 |
continue;
|
3063 |
@unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
|
3064 |
} else {
|
3065 |
$meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true );
|
3066 |
+
if ( $curr_blog_id && $curr_blog_id !== (int)$meta['blog_id'] ) {
|
3067 |
continue;
|
3068 |
+
}
|
3069 |
@unlink( $dir . $file);
|
3070 |
@unlink( $dir . 'meta/' . $file);
|
3071 |
}
|
3144 |
}
|
3145 |
}
|
3146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3147 |
if( get_option( 'gzipcompression' ) )
|
3148 |
update_option( 'gzipcompression', 0 );
|
3149 |
|
3198 |
echo '<div class="notice notice-info"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
|
3199 |
|
3200 |
if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
|
3201 |
+
if ( wp_cache_create_advanced_cache() ) {
|
3202 |
+
echo '<div class="notice notice-error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>';
|
3203 |
+
}
|
3204 |
}
|
3205 |
}
|
3206 |
add_action( 'admin_notices', 'wp_cache_admin_notice' );
|
3273 |
function wpsc_update_htaccess_form( $short_form = true ) {
|
3274 |
global $wpmu_version;
|
3275 |
|
3276 |
+
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
|
3277 |
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
|
3278 |
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
|
3279 |
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h5>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h5><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
|
3292 |
echo "</div>";
|
3293 |
}
|
3294 |
if ( !isset( $wpmu_version ) || $wpmu_version == '' ) {
|
3295 |
+
echo '<form name="updatehtaccess" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#modrewrite' ) . '" method="post">';
|
3296 |
echo '<input type="hidden" name="updatehtaccess" value="1" />';
|
3297 |
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . '" /></div>';
|
3298 |
wp_nonce_field('wp-cache');
|
3816 |
'id' => 'delete-cache',
|
3817 |
'title' => __( 'Delete Cache', 'wp-super-cache' ),
|
3818 |
'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ),
|
3819 |
+
'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . rawurlencode( $path ) ), 'delete-cache' )
|
3820 |
) );
|
3821 |
}
|
3822 |
|
3825 |
'parent' => '',
|
3826 |
'id' => 'delete-cache',
|
3827 |
'title' => __( 'Delete Cache', 'wp-super-cache' ),
|
3828 |
+
'meta' => array( 'title' => __( 'Delete Super Cache cached files', 'wp-super-cache' ) ),
|
3829 |
'href' => wp_nonce_url( admin_url( 'options-general.php?page=wpsupercache&tab=contents&wp_delete_cache=1' ), 'wp-cache' )
|
3830 |
) );
|
3831 |
}
|