WP Super Cache - Version 0.9.9.4

Version Description

Cache tester fixes, Easy settings page and tabs to settings page, new PHP caching mode, fixes to mobile support, domain mapping support plugin.

=

Download this release

Release Info

Developer donncha
Plugin Icon 128x128 WP Super Cache
Version 0.9.9.4
Comparing to
See all releases

Code changes from version 0.9.9.3 to 0.9.9.4

Changelog.txt CHANGED
@@ -1,3 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2010-06-16 10:26 donncha
2
 
3
  * wp-super-cache.pot: Updated translation file for 0.9.9.3
1
+ 2010-09-22 16:02 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump version to 0.9.9.4 and update some
4
+ docs
5
+
6
+ 2010-09-22 15:20 donncha
7
+
8
+ * wp-cache.php: When supercache is disabled delete the mod_rewrite
9
+ rules
10
+
11
+ 2010-09-22 15:16 donncha
12
+
13
+ * wp-cache.php: Don't check the mod_rewrite rules if caching
14
+ disabled
15
+
16
+ 2010-09-22 14:54 donncha
17
+
18
+ * readme.txt: Updated changelog and added language credits
19
+
20
+ 2010-09-22 14:26 donncha
21
+
22
+ * wp-super-cache.pot: Updated translation file
23
+
24
+ 2010-09-22 14:18 donncha
25
+
26
+ * plugins/domain-mapping.php: Added code to check if domain mapping
27
+ used and print a warning message
28
+
29
+ 2010-09-22 13:23 donncha
30
+
31
+ * wp-cache.php: Set "wp_cache_mod_rewrite" if it's not defined
32
+ already, for those upgrading
33
+
34
+ 2010-09-22 11:50 donncha
35
+
36
+ * wp-cache.php: Fixed typo in rewrite rules notice
37
+
38
+ 2010-09-21 11:54 donncha
39
+
40
+ * wp-cache.php: Don't need this adminpage form any more
41
+
42
+ 2010-09-21 10:00 donncha
43
+
44
+ * wp-cache.php: Update the docs explaining garbage collection
45
+
46
+ 2010-09-21 09:58 donncha
47
+
48
+ * wp-cache.php: Show advanced settings page if legacy caching
49
+ enabled too
50
+
51
+ 2010-09-21 09:44 donncha
52
+
53
+ * wp-cache.php: Show "advanced settings" page when mod_rewrite
54
+ caching enabled.
55
+
56
+ 2010-09-21 09:34 donncha
57
+
58
+ * wp-cache.php: Disable .htaccess checks when not running on "main
59
+ site" instead of disabling settings page completely
60
+
61
+ 2010-09-20 15:43 donncha
62
+
63
+ * plugins/domain-mapping.php, wp-cache-phase2.php: Added "gc_cache"
64
+ action and domain mapping cache plugin to clear the cache of
65
+ domain mapped multisite websites
66
+
67
+ 2010-09-20 12:58 donncha
68
+
69
+ * wp-cache.php: Added another check for the mod_rewrite config
70
+ before displaying a warning about those rules
71
+
72
+ 2010-09-20 12:47 donncha
73
+
74
+ * wp-cache.php: Correctly check for the "main blog"
75
+
76
+ 2010-09-20 12:01 donncha
77
+
78
+ * wp-cache.php: * Tester tab added "& Contents" to make it clearer
79
+ what's in this page.
80
+ * Add back in "List Files" link. Oops.
81
+
82
+ 2010-09-20 11:59 donncha
83
+
84
+ * wp-cache-config-sample.php, wp-cache.php: No need for simple
85
+ setup variable now
86
+
87
+ 2010-09-20 11:37 donncha
88
+
89
+ * plugins/awaitingmoderation.php: Added example plugin to remove
90
+ "Awaiting moderation" message when comments left on posts.
91
+
92
+ 2010-09-20 11:36 donncha
93
+
94
+ * plugins/badbehaviour.php, plugins/searchengine.php: Make plugins
95
+ listed in an ordered list
96
+
97
+ 2010-09-20 11:35 donncha
98
+
99
+ * wp-cache.php: * Added Plugins tab
100
+ * Check if if PHP or Supercache mode before checking .htaccess
101
+ file for rewrite rules.
102
+ * Change "half-on" text to "legacy" to reflect new terminology
103
+ * Split Settings page into Easy and Advanced tabs instead of
104
+ form.
105
+
106
+ 2010-09-13 22:46 donncha
107
+
108
+ * wp-cache.php: Make tabs like those on the themes page
109
+
110
+ 2010-09-13 04:31 donncha
111
+
112
+ * wp-cache.php: Cast as an array to hide a warning about 2nd arg.
113
+
114
+ 2010-09-13 04:28 donncha
115
+
116
+ * wp-cache.php: Hopefully trap wp_errors generating from page
117
+ requests to tester
118
+
119
+ 2010-09-07 16:16 donncha
120
+
121
+ * wp-cache.php: Enable "PHP Caching" from the easy setup page
122
+
123
+ 2010-09-07 16:07 donncha
124
+
125
+ * wp-cache.php: Minor tweaks to layout of admin page
126
+
127
+ 2010-09-07 16:06 donncha
128
+
129
+ * wp-cache-config-sample.php, wp-cache.php: Added "easy setup"
130
+ configuration screen (WIP)
131
+
132
+ 2010-09-07 16:03 donncha
133
+
134
+ * wp-cache.php: Fixed check for "main site" on MU sites
135
+
136
+ 2010-09-07 12:31 donncha
137
+
138
+ * wp-cache.php: * Fixed check for "main site"
139
+ * Updated error messages
140
+
141
+ 2010-09-07 12:09 donncha
142
+
143
+ * wp-cache.php: Added tabs to the Supercache admin page
144
+
145
+ 2010-09-06 07:33 donncha
146
+
147
+ * readme.txt: Added FAQ on writable directories and fixed a few
148
+ typos
149
+
150
+ 2010-09-03 15:15 donncha
151
+
152
+ * readme.txt, wp-cache-phase1.php: Updated headers and docs for PHP
153
+ served cache files
154
+
155
+ 2010-08-31 17:55 donncha
156
+
157
+ * wp-cache.php: Added "$wp_super_cache_lock_down" config variable
158
+ to hide lockdown and directly cached pages admin menus
159
+
160
+ 2010-08-31 17:44 donncha
161
+
162
+ * readme.txt: Major updates to the docs, covering legacy mode.
163
+
164
+ 2010-08-31 15:34 donncha
165
+
166
+ * readme.txt: Updated docs on legacy caching
167
+
168
+ 2010-08-31 13:50 donncha
169
+
170
+ * readme.txt: Minor mod to caching mechanism list
171
+
172
+ 2010-08-31 13:48 donncha
173
+
174
+ * readme.txt: Added docs on legacy caching and the different
175
+ caching mechanisms
176
+
177
+ 2010-08-31 12:45 donncha
178
+
179
+ * wp-cache-phase2.php: Added action on "wp_update_nav_menu" to
180
+ clear cache, props
181
+ http://www.webmasterbulletin.net/2010/07/wp-super-cache-and-wp3-0-menus/1270
182
+
183
+ 2010-08-30 16:50 donncha
184
+
185
+ * wp-cache.php: Admin page upgrades:
186
+ * Separate out PHP and mod_rewrite supercaching.
187
+ * Minor text changes
188
+
189
+ 2010-08-30 16:38 donncha
190
+
191
+ * wp-cache-phase2.php: Hide potential error messages
192
+
193
+ 2010-08-30 16:37 donncha
194
+
195
+ * wp-cache-phase2.php: Revert this settings change for now.
196
+
197
+ 2010-08-30 16:35 donncha
198
+
199
+ * wp-cache-phase2.php: If caching disabled, then don't run the
200
+ second phase function
201
+
202
+ 2010-08-30 11:46 donncha
203
+
204
+ * wp-cache-phase1.php: Minor whitespace mod
205
+
206
+ 2010-08-30 11:46 donncha
207
+
208
+ * wp-cache-phase1.php: Serve a gzipped supercache file if the
209
+ client supports it.
210
+
211
+ 2010-08-30 10:16 donncha
212
+
213
+ * wp-cache-phase2.php: Remove unused global variable
214
+
215
+ 2010-08-30 09:36 donncha
216
+
217
+ * wp-cache-phase2.php: Don't delete supercache files if supercache
218
+ is disabled when posts change. Stops moderated comments deleting
219
+ the front page.
220
+
221
+ 2010-08-29 10:17 donncha
222
+
223
+ * wp-cache-phase2.php: Check for empty tmp cache files and report
224
+ them correctly.
225
+
226
+ 2010-08-27 15:40 donncha
227
+
228
+ * wp-cache.php: Change cache compression on/off into a checkbox and
229
+ move into "Misc" section.
230
+
231
+ 2010-08-27 14:56 donncha
232
+
233
+ * wp-cache.php: Ignore case when checking mobile user agents in
234
+ .htaccess
235
+
236
+ 2010-08-26 16:37 donncha
237
+
238
+ * wp-cache.php: Hide warnings from these unlinks, even though the
239
+ plugin checks if they exist!
240
+
241
+ 2010-08-26 14:43 donncha
242
+
243
+ * wp-cache.php: Add a timestamp to the preload counter to catch
244
+ when it stalls. Reschedule the preload job when that happens.
245
+
246
+ 2010-08-26 12:34 donncha
247
+
248
+ * wp-cache.php: Cache tester should probably send http requests for
249
+ homepage if admin is secure
250
+
251
+ 2010-08-26 11:30 donncha
252
+
253
+ * wp-cache.php: Ony add mobile rules if mobile support is enabled
254
+
255
+ 2010-08-26 11:26 donncha
256
+
257
+ * wp-cache.php: Move code to handle updating the options into it's
258
+ own function and move more error checking into it's own function
259
+
260
+ 2010-08-24 17:07 donncha
261
+
262
+ * wp-cache.php: First go at reorganising the admin page
263
+
264
+ 2010-08-23 17:27 donncha
265
+
266
+ * wp-cache-phase2.php: Starting to use $wpsc_settings
267
+
268
+ 2010-08-23 17:09 donncha
269
+
270
+ * wp-cache-phase1.php, wp-cache-phase2.php: Added
271
+ "wp_cache_load_config()" and $wpsc_settings array
272
+
273
+ 2010-08-23 12:23 donncha
274
+
275
+ * readme.txt: Added new FAQ, "How do I delay serving the cache
276
+ until the "init" action fires?"
277
+
278
+ 2010-08-23 12:07 donncha
279
+
280
+ * readme.txt: Include a simple mfunc example
281
+
282
+ 2010-08-23 12:06 donncha
283
+
284
+ * wp-cache-config-sample.php, wp-cache-phase2.php: Removed
285
+ $wp_cache_gzip_first, if compression is enabled there's no reason
286
+ it won't work for the cache generating visit
287
+
288
+ 2010-08-23 11:40 donncha
289
+
290
+ * wp-cache-phase2.php: Warn if late init not set on dynamic pages
291
+
292
+ 2010-08-23 10:45 donncha
293
+
294
+ * wp-cache-phase2.php: Added "wp_cache_append_tag()" to add the
295
+ Supercache log message after filtering
296
+
297
+ 2010-08-06 17:09 donncha
298
+
299
+ * wp-cache.php: Added the function "wpsupercache_site_admin()" to
300
+ support old versions of MU using is_site_admin()
301
+
302
+ 2010-08-06 16:10 donncha
303
+
304
+ * wp-cache-phase1.php, wp-cache.php: Removed lots of PHP variable
305
+ warnings. Props Joel Hardi
306
+
307
+ 2010-08-06 15:30 donncha
308
+
309
+ * wp-cache.php: Fixed cache tester when WP is installed in a sub
310
+ directory
311
+
312
+ 2010-08-03 12:17 donncha
313
+
314
+ * wp-cache-phase2.php: Check for closing "urlset" tag for xml
315
+ sitemap generators
316
+ (http://wordpress.org/support/topic/plugin-wp-super-cache-xml-sitemap-feed-not-cached?replies=11#post-1627457)
317
+
318
+ 2010-07-30 12:19 donncha
319
+
320
+ * wp-cache.php: Check the status of pages returned by the cache
321
+ tester and report any problems.
322
+
323
+ 2010-07-01 15:30 donncha
324
+
325
+ * wp-cache.php: Removed donation blurb from admin page
326
+
327
+ 2010-07-01 15:27 donncha
328
+
329
+ * readme.txt: Removed donation link, updated min version and added
330
+ automattic as contributor
331
+
332
+ 2010-06-28 10:25 donncha
333
+
334
+ * wp-cache-config-sample.php: Use WP_PLUGIN_DIR instead of
335
+ WP_CONTENT_DIR, props Baris Unver
336
+
337
+ 2010-06-21 15:42 donncha
338
+
339
+ * wp-cache.php: On MU/WP 3.0 network sites only allow admin page on
340
+ main site. http://wordpress.org/support/topic/412472?replies=2
341
+
342
+ 2010-06-16 10:34 donncha
343
+
344
+ * Changelog.txt, readme.txt: Updated changelogs
345
+
346
  2010-06-16 10:26 donncha
347
 
348
  * wp-super-cache.pot: Updated translation file for 0.9.9.3
plugins/awaitingmoderation.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function awaitingmoderation_action( $buffer ) {
4
+ $buffer = str_replace( __( 'Your comment is awaiting moderation.' ), '', $buffer );
5
+ return $buffer;
6
+ }
7
+
8
+ function awaitingmoderation_actions() {
9
+ global $cache_awaitingmoderation;
10
+ if( $cache_awaitingmoderation == '1' ) {
11
+ add_filter( 'wpsupercache_buffer', 'awaitingmoderation_action' );
12
+ }
13
+ }
14
+ add_cacheaction( 'add_cacheaction', 'awaitingmoderation_actions' );
15
+
16
+ //Your comment is awaiting moderation.
17
+ function wp_supercache_awaitingmoderation_admin() {
18
+ global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
19
+
20
+ $cache_awaitingmoderation = $cache_awaitingmoderation == '' ? '0' : $cache_awaitingmoderation;
21
+
22
+ if(isset($_POST['cache_awaitingmoderation']) && $valid_nonce) {
23
+ $cache_awaitingmoderation = $_POST['cache_awaitingmoderation'] == __( 'Disable', 'wp-super-cache' ) ? '0' : '1';
24
+ wp_cache_replace_line('^ *\$cache_awaitingmoderation', "\$cache_awaitingmoderation = '$cache_awaitingmoderation';", $wp_cache_config_file);
25
+ }
26
+ echo '<li><form name="wp_supercache_searchengine_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
27
+ wp_nonce_field('wp-cache');
28
+ if( $cache_awaitingmoderation == '0' ) {
29
+ $status = __( 'disabled', 'wp-super-cache' );
30
+ } else {
31
+ $status = __( 'enabled', 'wp-super-cache' );
32
+ }
33
+ echo '<strong>' . sprintf( __( 'Awaiting Moderation plugin is %s', 'wp-super-cache' ), $status );
34
+ echo '.</strong> ' . __( '(Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.) ', 'wp-super-cache' );
35
+ if( $cache_awaitingmoderation == '0' ) {
36
+ echo '<input type="submit" name="cache_awaitingmoderation" value="' . __( 'Enable', 'wp-super-cache' ) . '" />';
37
+ } else {
38
+ echo '<input type="submit" name="cache_awaitingmoderation" value="' . __( 'Disable', 'wp-super-cache' ) . '" />';
39
+ }
40
+ echo "</form></li>\n";
41
+
42
+ }
43
+ add_cacheaction( 'cache_admin_page', 'wp_supercache_awaitingmoderation_admin' );
44
+ ?>
plugins/badbehaviour.php CHANGED
@@ -49,7 +49,7 @@ function wp_supercache_badbehaviour_admin() {
49
  wp_cache_replace_line('^ *\$cache_badbehaviour', "\$cache_badbehaviour = $cache_badbehaviour;", $wp_cache_config_file);
50
  wp_cache_replace_line('^ *\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '$bbfile';", $wp_cache_config_file);
51
  }
52
- echo '<form name="wp_supercache_badbehaviour_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
53
  wp_nonce_field('wp-cache');
54
  if( $cache_badbehaviour == 0 ) {
55
  $bb_status = __( 'disabled', 'wp-super-cache' );
@@ -58,7 +58,7 @@ function wp_supercache_badbehaviour_admin() {
58
  wp_super_cache_disable();
59
  }
60
  echo '<strong>' . sprintf( __( 'Bad Behaviour support is %s.', 'wp-super-cache' ), $bb_status ) . '</strong>';
61
- printf( __( '(Only half-on caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR );
62
  if( $cache_badbehaviour == 0 ) {
63
  echo '<input type="submit" name="cache_badbehaviour" value="' . __( 'Enable', 'wp-super-cache' ) . '" />';
64
  } else {
@@ -67,6 +67,7 @@ function wp_supercache_badbehaviour_admin() {
67
  echo "</form>\n";
68
  if( $err )
69
  echo "<p><strong>" . __( 'Warning!', 'wp-super-cache' ) . "</strong> $err</p>";
 
70
 
71
  }
72
  add_cacheaction( 'cache_admin_page', 'wp_supercache_badbehaviour_admin' );
49
  wp_cache_replace_line('^ *\$cache_badbehaviour', "\$cache_badbehaviour = $cache_badbehaviour;", $wp_cache_config_file);
50
  wp_cache_replace_line('^ *\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '$bbfile';", $wp_cache_config_file);
51
  }
52
+ echo '<li><form name="wp_supercache_badbehaviour_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
53
  wp_nonce_field('wp-cache');
54
  if( $cache_badbehaviour == 0 ) {
55
  $bb_status = __( 'disabled', 'wp-super-cache' );
58
  wp_super_cache_disable();
59
  }
60
  echo '<strong>' . sprintf( __( 'Bad Behaviour support is %s.', 'wp-super-cache' ), $bb_status ) . '</strong>';
61
+ printf( __( '(Only legacy caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR );
62
  if( $cache_badbehaviour == 0 ) {
63
  echo '<input type="submit" name="cache_badbehaviour" value="' . __( 'Enable', 'wp-super-cache' ) . '" />';
64
  } else {
67
  echo "</form>\n";
68
  if( $err )
69
  echo "<p><strong>" . __( 'Warning!', 'wp-super-cache' ) . "</strong> $err</p>";
70
+ echo '</li>';
71
 
72
  }
73
  add_cacheaction( 'cache_admin_page', 'wp_supercache_badbehaviour_admin' );
plugins/domain-mapping.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function domain_mapping_gc_cache( $function, $directory ) {
4
+ global $cache_path;
5
+
6
+ if ( !function_exists( 'domain_mapping_warning' ) )
7
+ return false;
8
+
9
+ $siteurl = domain_mapping_siteurl( false );
10
+ if ( !$siteurl )
11
+ return false;
12
+
13
+ $protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
14
+ $siteurl = trailingslashit( str_replace( $protocol, '', $siteurl ) );
15
+
16
+ if ( $directory == 'homepage' )
17
+ $directory = '';
18
+
19
+ switch( $function ) {
20
+ case "rebuild":
21
+ @wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html' );
22
+ @wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz' );
23
+ break;
24
+ case "prune":
25
+ prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true );
26
+ prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true );
27
+ break;
28
+ }
29
+
30
+ return $directory;
31
+ }
32
+
33
+ function domain_mapping_actions() {
34
+ global $cache_domain_mapping;
35
+ if( $cache_domain_mapping == '1' ) {
36
+ add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
37
+ }
38
+ }
39
+ add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
40
+
41
+ function wp_supercache_domain_mapping_admin() {
42
+ global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
43
+
44
+ $cache_domain_mapping = $cache_domain_mapping == '' ? '0' : $cache_domain_mapping;
45
+
46
+ if(isset($_POST['cache_domain_mapping']) && $valid_nonce) {
47
+ $cache_domain_mapping = $_POST['cache_domain_mapping'] == __( 'Disable', 'wp-super-cache' ) ? '0' : '1';
48
+ wp_cache_replace_line('^ *\$cache_domain_mapping', "\$cache_domain_mapping = '$cache_domain_mapping';", $wp_cache_config_file);
49
+ }
50
+ echo '<li><form name="wp_supercache_searchengine_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
51
+ wp_nonce_field('wp-cache');
52
+ if( $cache_domain_mapping == '0' ) {
53
+ $status = __( 'disabled', 'wp-super-cache' );
54
+ } else {
55
+ $status = __( 'enabled', 'wp-super-cache' );
56
+ }
57
+ echo '<strong>' . sprintf( __( '<a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> support plugin is %s', 'wp-super-cache' ), $status );
58
+ echo '.</strong> ' . __( '(support for multiple domains on multisite websites) ', 'wp-super-cache' );
59
+ if( $cache_domain_mapping == '0' ) {
60
+ echo '<input type="submit" name="cache_domain_mapping" value="' . __( 'Enable', 'wp-super-cache' ) . '" />';
61
+ } else {
62
+ echo '<input type="submit" name="cache_domain_mapping" value="' . __( 'Disable', 'wp-super-cache' ) . '" />';
63
+ }
64
+ echo "</form></li>\n";
65
+
66
+ }
67
+ add_cacheaction( 'cache_admin_page', 'wp_supercache_domain_mapping_admin' );
68
+
69
+ function wp_supercache_domain_mapping_notice() {
70
+ global $cache_enabled, $cache_domain_mapping;
71
+ if( $cache_enabled )
72
+ echo '<div class="error"><p><strong>' . __('Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
73
+ }
74
+ function wp_supercache_domain_mapping_exists() {
75
+ global $cache_domain_mapping;
76
+ if ( $cache_domain_mapping == 1 )
77
+ return false;
78
+
79
+ if ( is_admin() && function_exists( 'domain_mapping_warning' ) )
80
+ add_action( 'admin_notices', 'wp_supercache_domain_mapping_notice' );
81
+ }
82
+
83
+ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
84
+ add_cacheaction( 'add_cacheaction', 'wp_supercache_domain_mapping_exists' );
85
+ }
86
+ ?>
plugins/searchengine.php CHANGED
@@ -61,7 +61,7 @@ function wp_supercache_searchengine_admin() {
61
  $cache_no_adverts_for_friends = $_POST['cache_no_adverts_for_friends'] == __( 'Disable', 'wp-super-cache' ) ? 'no' : 'yes';
62
  wp_cache_replace_line('^ *\$cache_no_adverts_for_friends', "\$cache_no_adverts_for_friends = '$cache_no_adverts_for_friends';", $wp_cache_config_file);
63
  }
64
- echo '<form name="wp_supercache_searchengine_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
65
  wp_nonce_field('wp-cache');
66
  if( $cache_no_adverts_for_friends == 'no' ) {
67
  $status = __( 'disabled', 'wp-super-cache' );
@@ -75,7 +75,7 @@ function wp_supercache_searchengine_admin() {
75
  } else {
76
  echo '<input type="submit" name="cache_no_adverts_for_friends" value="' . __( 'Disable', 'wp-super-cache' ) . '" />';
77
  }
78
- echo "</form>\n";
79
 
80
  }
81
  add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
61
  $cache_no_adverts_for_friends = $_POST['cache_no_adverts_for_friends'] == __( 'Disable', 'wp-super-cache' ) ? 'no' : 'yes';
62
  wp_cache_replace_line('^ *\$cache_no_adverts_for_friends', "\$cache_no_adverts_for_friends = '$cache_no_adverts_for_friends';", $wp_cache_config_file);
63
  }
64
+ echo '<li><form name="wp_supercache_searchengine_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
65
  wp_nonce_field('wp-cache');
66
  if( $cache_no_adverts_for_friends == 'no' ) {
67
  $status = __( 'disabled', 'wp-super-cache' );
75
  } else {
76
  echo '<input type="submit" name="cache_no_adverts_for_friends" value="' . __( 'Disable', 'wp-super-cache' ) . '" />';
77
  }
78
+ echo "</form></li>\n";
79
 
80
  }
81
  add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
readme.txt CHANGED
@@ -1,17 +1,16 @@
1
  === WP Super Cache ===
2
- Contributors: donncha
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
- Tested up to: 3.0
5
- Stable tag: 0.9.9.3
6
- Requires at least: 2.6
7
- Donate link: http://ocaoimh.ie/gad/
8
 
9
  A very fast caching engine for WordPress that produces static html files.
10
 
11
  == Description ==
12
  This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
13
 
14
- The static html files will be served to the vast majority of your users, but because a user's details are displayed in the comment form after they leave a comment those requests are handled by PHP. Static files are served to:
15
 
16
  1. Users who are not logged in.
17
  2. Users who have not left a comment on your blog.
@@ -22,17 +21,55 @@ The static html files will be served to the vast majority of your users, but bec
22
  If for some reason "supercaching" doesn't work on your server then don't worry. Caching will still be performed, but every request will require loading the PHP engine. In normal circumstances this isn't bad at all. Visitors to your site will notice no slowdown or difference. Supercache really comes into it's own if your server is underpowered, or you're experiencing heavy traffic.
23
  Super Cached html files will be served more quickly than PHP generated cached files but in every day use, the difference isn't noticeable.
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  See the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) for further information. [Developer documentation](http://ocaoimh.ie/wp-super-cache-developers/) is also available for those who need to interact with the cache or write plugins.
26
 
27
  The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is a good place to start if you want to know what has changed since you last downloaded the plugin.
28
 
29
  == Upgrade Notice ==
30
 
31
- = 0.9.9.3 =
32
- Fix division by zero error in half-on mode, always show "delete cache" button, fix "Update mod_rewrite rules" button.
33
 
34
  == Changelog ==
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  = 0.9.9.3 =
37
  * Fixed division by zero error in half on mode.
38
  * Always show "delete cache" button.
@@ -127,13 +164,13 @@ Fix division by zero error in half-on mode, always show "delete cache" button, f
127
  6. Fixed problems with posts and comments not refreshing.
128
 
129
  == Installation ==
130
- 1. You should have the Apache mod mime and mod rewrite modules installed and WordPress fancy permalinks enabled. PHP safe mode should be disabled. If any of those are missing or off you can still use the slower WP-Cache part of the plugin.
131
  2. If you have WP-Cache installed already, please disable it. Edit wp-config.php and make sure the WP_CACHE define is deleted, and remove the files wp-content/wp-cache-config.php and wp-content/advanced-cache.php. These will be recreated when you install this plugin.
132
  3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
133
  4. If you are using WordPress MU you will need to install this in 'wp-content/mu-plugins/wp-super-cache/' and the file wp-cache.php must be copied into the mu-plugins directory.
134
  5. WordPress users should go to their Plugins page and activate "WP Super Cache".
135
- 6. Now go to Settings->WP Super Cache and enable caching. If you see an error message or a blank screen you may need to fix it. See the "FAQ" section later in this readme for instructions.
136
- 7. mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
137
 
138
  `-----------------.htaccess-----------------`
139
  `RewriteEngine On`
@@ -192,7 +229,7 @@ Fix division by zero error in half-on mode, always show "delete cache" button, f
192
  == How to uninstall WP Super Cache ==
193
 
194
  Edit the file uninstall.php in your plugins/wp-super-cache/ directory and set
195
- UNINSTALL_WPSUPERCACHE to a non blank value.
196
 
197
  `define( 'UNINSTALL_WPSUPERCACHE', '1' );`
198
 
@@ -221,8 +258,8 @@ To manually uninstall:
221
  = How do I know my blog is being cached? =
222
 
223
  View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking.
224
- In "HALF-ON" mode, if you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. WP-Cache (PHP) cached pages will have the header "WP-Super-Cache: WP-Cache". I used the <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a> extension for Firefox to examine the headers. You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.
225
- If the plugin rules are missing from your .htaccess file, the plugin will attempt to serve the super cached page if it's found. The header "WP-Cache: Served supercache file from PHP" if this happens.
226
 
227
  = WP-Cache vs Supercache files =
228
 
@@ -239,11 +276,11 @@ Comments will show as soon as they are moderated, depending on the comment polic
239
 
240
  = Will the Super Cache compression slow down my server? =
241
 
242
- No, it will do the opposite in fact. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.
243
 
244
  = How do I make certain parts of the page stay dynamic? =
245
 
246
- WP Super Cache retains the dynamic loading code of WP Cache but only works in "half on" mode.
247
 
248
  There are two ways to do this, you can have functions that stay dynamic or you can include other files on every page load. To have a dynamic function in the cached PHP page use this syntax around the function:
249
 
@@ -259,6 +296,15 @@ The HTML comments around the mirrored PHP allow it to be executed in the static
259
 
260
  That will include file.php under the ABSPATH directory, which is the same as where your wp-config.php file is located.
261
 
 
 
 
 
 
 
 
 
 
262
  = Why doesn't WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now? =
263
 
264
  This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the mfunc/mclude code described in the previous answer to update or display dynamic information.
@@ -274,7 +320,7 @@ A tiny proportion of websites will have problems with the following configuratio
274
  1. Uses a static page for the front page.
275
  2. Uses /%category%/%postname%/ permalink structure.
276
 
277
- Sometimes a category page is cached as the homepage of the site instead of the static page. I can't [replicate the problem](http://wordpress.org/support/topic/237415/page/2?replies=38) but a simple solution is to switch the plugin to half-on mode. For normal traffic you will see no difference in the speed of your site.
278
 
279
  = Why do I get warnings about caching from http://ismyblogworking.com/ =
280
 
@@ -289,6 +335,10 @@ Try the Cacheability Engine at http://www.ircache.net/cgi-bin/cacheability.py or
289
 
290
  That tracking adds a query string to each url linked from various sources like Twitter and feedreaders. Unfortunately it stops pages being supercached. See [Joost's comment here](http://ocaoimh.ie/remove-unused-utmsource-urls/#comment-672813) for how to turn it into an anchor tag which can be supercached.
291
 
 
 
 
 
292
  = Troubleshooting =
293
 
294
  If things don't work when you installed the plugin here are a few things to check:
@@ -308,15 +358,15 @@ If things don't work when you installed the plugin here are a few things to chec
308
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin if you are using an old WordPress install. The latest versions redirect themselves (you should always be running the latest version of WordPress anyway!)
309
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
310
  13. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value. You can also disable file locking from the Admin screen as a last resort.
311
- 14. Make sure cache/wp_cache_mutex.lock is writeable by the web server.
312
  15. The cache folder cannot be put on an NFS or Samba or NAS share. It has to be on a local disk. File locking and deleting expired files will not work properly unless the cache folder is on the local machine.
313
  16. Garbage collection of old cache files won't work if WordPress can't find wp-cron.php. If your hostname resolves to 127.0.0.1 it could be preventing the garbage collection from working. Check your access_logs for wp-cron.php entries. Do they return a 404 (file not found) or 200 code? If it's 404 or you don't see wp-cron.php anywhere WordPress may be looking for that script in the wrong place. You should speak to your server administator to correct this or edit /etc/hosts on Unix servers and remove the following line. Your hostname must resolve to the external IP address other servers on the network/Internet use. See http://yoast.com/wp-cron-issues/ for more.
314
 
315
  `127.0.0.1 myhostname.com`
316
  A line like "127.0.0.1 localhost localhost.localdomain" is ok.
317
  17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
318
- 18. The error message, "WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!" appears at the end of every page. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? If it is not the caching engine will not load.
319
- 19. Caching doesn't work. The timestamp on my blog keeps changing when I reload. Check that the path in your .htaccess rules matches where the supercache directory is. You may have to hardcode it. Or use the plugin in Half-On mode.
320
  20. If supercache cache files are generated but not served, check the permissions on all your wp-content/cache/supercache folders (and each of wp-content cache and supercache folders) and wp-content/cache/.htaccess. If your PHP runs as a different user to Apache and permissions are strict Apache may not be able to read the PHP generated cache files. To fix you must add the following line to your wp-config.php (Add it above the WP_CACHE define.) Then clear your cache.
321
 
322
  `umask( 0022 );`
@@ -356,5 +406,10 @@ I would sincerely like to thank [John Pozadzides](http://onemansblog.com/) for g
356
  Thanks to James Farmer and Andrew Billits of [Edu Blogs](http://edublogs.org/) fame who helped me make this more WordPress MU friendly.
357
 
358
  Translators who did a great job converting the text of the plugin to their native language. Thank you!
359
- [Gianni Diurno](http://gidibao.net/) (Italian)
360
- [Omi](http://equipajedemano.info/) (Spanish)
 
 
 
 
 
1
  === WP Super Cache ===
2
+ Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 3.0.1
5
+ Stable tag: 0.9.9.4
6
+ Requires at least: 2.9.2
 
7
 
8
  A very fast caching engine for WordPress that produces static html files.
9
 
10
  == Description ==
11
  This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
12
 
13
+ The static html files will be served to the vast majority of your users, but because a user's details are displayed in the comment form after they leave a comment those requests are handled by the legacy caching engine. Static files are served to:
14
 
15
  1. Users who are not logged in.
16
  2. Users who have not left a comment on your blog.
21
  If for some reason "supercaching" doesn't work on your server then don't worry. Caching will still be performed, but every request will require loading the PHP engine. In normal circumstances this isn't bad at all. Visitors to your site will notice no slowdown or difference. Supercache really comes into it's own if your server is underpowered, or you're experiencing heavy traffic.
22
  Super Cached html files will be served more quickly than PHP generated cached files but in every day use, the difference isn't noticeable.
23
 
24
+ The plugin serves cached files in 3 ways (ranked by speed):
25
+
26
+ 1. Mod_Rewrite. The fastest method is by using Apache mod_rewrite (or whatever similar module your web server supports) to serve "supercached" static html files. This completely bypasses PHP and is extremely quick. If your server is hit by a deluge of traffic it is more likely to cope as the requests are "lighter". This does require the Apache mod_rewrite module (which is probably installed if you have custom permalinks) and a modification of your .htaccess file. Visits by anonymous or unknown users will be served this way.
27
+ 2. PHP. Supercached static files can now be served by PHP. The plugin will serve a "supercached" file if it exists and it's almost as fast as the mod_rewrite method. It's easier to configure as the .htaccess file doesn't need to be changed. You still need a custom permalink. Your server may not cope as well with a really large amount of traffic. (You're gaming Digg aren't you? You'll need mod_rewrite, the rest of us are ok with PHP!)
28
+ 3. Legacy caching. This is mainly used to cache pages for known users. These are logged in users, visitors who leave comments or those who should be shown custom per-user data. It's the most flexible caching method but also the slowest. As each page is different it's often better not to cache pages for these users at all and avoid legacy caching. Legacy caching will also cache visits by unknown users if this caching mode is selected. See the FAQ, "How do I make certain parts of the page stay dynamic?" for the main reason to use legacy caching.
29
+
30
+ If you're new to caching use PHP caching. It's easy to set up and very fast. Avoid legacy caching unless you want to have highly customised pages.
31
+
32
+ = Recommended Settings =
33
+ Advanced users will probably want to use mod_rewrite caching, but PHP caching is almost as good and recommended for everyone else. Enable the following:
34
+
35
+ 1. PHP caching.
36
+ 2. Compress pages.
37
+ 3. Don't cache pages for known users.
38
+ 4. Cache rebuild.
39
+
40
+ Garbage collection is the act of cleaning up cache files that are out of date and stale. There's no correct value for the expiry time but a good starting point is 1800 seconds if you're not using legacy mode. If you are using that mode start with an expiry time of 600 seconds.
41
+
42
+ If you are not using legacy mode caching consider deleting the contents of the "Rejected User Agents" text box and allow search engines create supercache static files.
43
+
44
+ Likewise, preload as many posts as you can and enable "Preload Mode". Garbage collection will still occur but it won't affect the preloaded files. If you don't care about sidebar widgets updating often set the preload interval to 2880 minutes (2 days) so all your posts aren't recached very often. When the preload occurs the cache files for the post being refreshed is deleted and then regenerated. Afterwards a garbage collection of all old files is performed to clean out stale cache files.
45
+ With preloading on cached files will still be deleted when posts are made or edited or comments made.
46
+
47
  See the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) for further information. [Developer documentation](http://ocaoimh.ie/wp-super-cache-developers/) is also available for those who need to interact with the cache or write plugins.
48
 
49
  The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is a good place to start if you want to know what has changed since you last downloaded the plugin.
50
 
51
  == Upgrade Notice ==
52
 
53
+ = 0.9.9.4 =
54
+ Cache tester fixes, Easy settings page and tabs to settings page, new PHP caching mode, fixes to mobile support, domain mapping support plugin.
55
 
56
  == Changelog ==
57
 
58
+ = 0.9.9.4 =
59
+ * Settings page split into tabbed pages.
60
+ * Added new "Easy" settings page for new users.
61
+ * New PHP caching mode to serve supercached files.
62
+ * Mobile support fixes.
63
+ * Added Domain mapping support plugin.
64
+ * Added "awaiting moderation" plugin that removes that text from posts.
65
+ * Terminology change. Changed "half on" to "legacy caching".
66
+ * Fixed cache tester on some installs of WordPress.
67
+ * Updated documentation
68
+ * Added $wp_super_cache_lock_down config variable to hide lockdown and directly cached pages admin items.
69
+ * Preloaded checks if it has stalled and reschedules the job to continue.
70
+ * Serve the gzipped page when first cached if the client supports compression.
71
+ * Lots more bug fixes..
72
+
73
  = 0.9.9.3 =
74
  * Fixed division by zero error in half on mode.
75
  * Always show "delete cache" button.
164
  6. Fixed problems with posts and comments not refreshing.
165
 
166
  == Installation ==
167
+ 1. You should have the Apache mod mime and mod rewrite modules installed and WordPress custom permalinks (Settings->Permalinks) enabled. PHP safe mode should be disabled. If any of those are missing or off you can still use PHP or legacy caching.
168
  2. If you have WP-Cache installed already, please disable it. Edit wp-config.php and make sure the WP_CACHE define is deleted, and remove the files wp-content/wp-cache-config.php and wp-content/advanced-cache.php. These will be recreated when you install this plugin.
169
  3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
170
  4. If you are using WordPress MU you will need to install this in 'wp-content/mu-plugins/wp-super-cache/' and the file wp-cache.php must be copied into the mu-plugins directory.
171
  5. WordPress users should go to their Plugins page and activate "WP Super Cache".
172
+ 6. Now go to Settings->WP Super Cache and enable caching. If you see an error message or a blank screen see the "FAQ" section later in this readme for instructions.
173
+ 7. If you choose "Mod Rewrite caching", mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
174
 
175
  `-----------------.htaccess-----------------`
176
  `RewriteEngine On`
229
  == How to uninstall WP Super Cache ==
230
 
231
  Edit the file uninstall.php in your plugins/wp-super-cache/ directory and set
232
+ UNINSTALL_WPSUPERCACHE to a non blank value like this:
233
 
234
  `define( 'UNINSTALL_WPSUPERCACHE', '1' );`
235
 
258
  = How do I know my blog is being cached? =
259
 
260
  View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking.
261
+ In legacy caching mode, if you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. PHP cached pages will have the header "WP-Super-Cache: Served supercache file from PHP". Legacy cached files will have the header, "WP-Super-Cache: Served legacy cache file". I used the <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a> extension for Firefox to examine the headers. You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.
262
+ If the plugin rules are missing from your .htaccess file, the plugin will attempt to serve the super cached page if it's found. The header "WP-Super-Cache: Served supercache file from PHP" if this happens.
263
 
264
  = WP-Cache vs Supercache files =
265
 
276
 
277
  = Will the Super Cache compression slow down my server? =
278
 
279
+ No, it will do the opposite. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.
280
 
281
  = How do I make certain parts of the page stay dynamic? =
282
 
283
+ WP Super Cache retains the dynamic loading code of WP Cache but only works in legacy caching mode.
284
 
285
  There are two ways to do this, you can have functions that stay dynamic or you can include other files on every page load. To have a dynamic function in the cached PHP page use this syntax around the function:
286
 
296
 
297
  That will include file.php under the ABSPATH directory, which is the same as where your wp-config.php file is located.
298
 
299
+ Example:
300
+ `<!--mfunc date( 'Y-m-d H:i:s' ) -->
301
+ <?php date( 'Y-m-d H:i:s' ) ?>
302
+ <!--/mfunc-->`
303
+
304
+ = How do I delay serving the cache until the "init" action fires? =
305
+
306
+ Cached files are served before almost all of WordPress is loaded. While that's great for performance it's a pain when you want to extend the plugin using a core part of WordPress. Set $wp_super_cache_late_init to "1" in wp-content/wp-cache-config.php and cached files will be served when "init" fires. WordPress and it's plugins will be loaded now. This is very useful when you are using the mfunc tag in your theme.
307
+
308
  = Why doesn't WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now? =
309
 
310
  This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the mfunc/mclude code described in the previous answer to update or display dynamic information.
320
  1. Uses a static page for the front page.
321
  2. Uses /%category%/%postname%/ permalink structure.
322
 
323
+ Sometimes a category page is cached as the homepage of the site instead of the static page. I can't [replicate the problem](http://wordpress.org/support/topic/237415/page/2?replies=38) but a simple solution is to switch the plugin to PHP mode. For normal traffic you will see no difference in the speed of your site.
324
 
325
  = Why do I get warnings about caching from http://ismyblogworking.com/ =
326
 
335
 
336
  That tracking adds a query string to each url linked from various sources like Twitter and feedreaders. Unfortunately it stops pages being supercached. See [Joost's comment here](http://ocaoimh.ie/remove-unused-utmsource-urls/#comment-672813) for how to turn it into an anchor tag which can be supercached.
337
 
338
+ = The plugin complains that wp-content is writable! htdocs is writable! =
339
+
340
+ It's not good when the web server can write to these directories but sometimes shared hosting accounts are set up in this way to make administration easier. Use `chmod 755 directory` to fix the permissions or find the permissions section of your ftp client. This [Google search](http://www.google.ie/search?sourceid=chrome&ie=UTF-8&q=ftp+fix+directory+permissions+755) will lead you to more information on this topic. Unfortunately some hosts require that those directories be writable. If that's the case just ignore this warning.
341
+
342
  = Troubleshooting =
343
 
344
  If things don't work when you installed the plugin here are a few things to check:
358
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin if you are using an old WordPress install. The latest versions redirect themselves (you should always be running the latest version of WordPress anyway!)
359
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
360
  13. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value. You can also disable file locking from the Admin screen as a last resort.
361
+ 14. Make sure cache/wp_cache_mutex.lock is writable by the web server if using coarse file locking.
362
  15. The cache folder cannot be put on an NFS or Samba or NAS share. It has to be on a local disk. File locking and deleting expired files will not work properly unless the cache folder is on the local machine.
363
  16. Garbage collection of old cache files won't work if WordPress can't find wp-cron.php. If your hostname resolves to 127.0.0.1 it could be preventing the garbage collection from working. Check your access_logs for wp-cron.php entries. Do they return a 404 (file not found) or 200 code? If it's 404 or you don't see wp-cron.php anywhere WordPress may be looking for that script in the wrong place. You should speak to your server administator to correct this or edit /etc/hosts on Unix servers and remove the following line. Your hostname must resolve to the external IP address other servers on the network/Internet use. See http://yoast.com/wp-cron-issues/ for more.
364
 
365
  `127.0.0.1 myhostname.com`
366
  A line like "127.0.0.1 localhost localhost.localdomain" is ok.
367
  17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
368
+ 18. The error message, "WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!" appears at the end of every page. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? This file will normally be in wp-content/plugins/wp-super-cache/. If it is not correct the caching engine will not load.
369
+ 19. Caching doesn't work. The timestamp on my blog keeps changing when I reload. Check that the path in your .htaccess rules matches where the supercache directory is. You may have to hardcode it. Or use the plugin in PHP or legacy caching mode.
370
  20. If supercache cache files are generated but not served, check the permissions on all your wp-content/cache/supercache folders (and each of wp-content cache and supercache folders) and wp-content/cache/.htaccess. If your PHP runs as a different user to Apache and permissions are strict Apache may not be able to read the PHP generated cache files. To fix you must add the following line to your wp-config.php (Add it above the WP_CACHE define.) Then clear your cache.
371
 
372
  `umask( 0022 );`
406
  Thanks to James Farmer and Andrew Billits of [Edu Blogs](http://edublogs.org/) fame who helped me make this more WordPress MU friendly.
407
 
408
  Translators who did a great job converting the text of the plugin to their native language. Thank you!
409
+
410
+ * [Gianni Diurno](http://gidibao.net/) (Italian)
411
+ * [Omi](http://equipajedemano.info/) (Spanish)
412
+ * [tomchen1989](http://emule-fans.com/) (Simplified Chinese)
413
+ * Tai (Japanese)
414
+ * [Vitaly](http://pressword.com.ua/wordpress/) (Ukranian)
415
+ * [Pseric](http://pseric.com/) (Traditional Chinese)
wp-cache-config-sample.php CHANGED
@@ -6,7 +6,7 @@ See wp-cache.php for author details.
6
  */
7
 
8
  if ( ! defined('WPCACHEHOME') )
9
- define( 'WPCACHEHOME', WP_CONTENT_DIR . '/plugins/wp-super-cache/' );
10
 
11
  $cache_compression = 0; // Super cache compression
12
  $cache_enabled = false;
@@ -62,8 +62,6 @@ $wp_cache_mobile = 0;
62
  $wp_cache_mobile_whitelist = 'Stand Alone/QNws';
63
  $wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';
64
 
65
- // gzip the first page generated for clients that support it.
66
- $wp_cache_gzip_first = 0;
67
  // change to relocate the supercache plugins directory
68
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
69
  // set to 1 to do garbage collection during normal process shutdown instead of wp-cron
6
  */
7
 
8
  if ( ! defined('WPCACHEHOME') )
9
+ define( 'WPCACHEHOME', WP_PLUGIN_DIR . '/wp-super-cache/' );
10
 
11
  $cache_compression = 0; // Super cache compression
12
  $cache_enabled = false;
62
  $wp_cache_mobile_whitelist = 'Stand Alone/QNws';
63
  $wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';
64
 
 
 
65
  // change to relocate the supercache plugins directory
66
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
67
  // set to 1 to do garbage collection during normal process shutdown instead of wp-cron
wp-cache-phase1.php CHANGED
@@ -4,24 +4,36 @@
4
  if( !defined('WP_CONTENT_DIR') )
5
  define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
6
 
7
- if( !include( WP_CONTENT_DIR . '/wp-cache-config.php' ) )
 
 
 
 
 
 
 
 
 
 
 
 
8
  return true;
 
9
  if( !defined( 'WPCACHEHOME' ) )
10
  define('WPCACHEHOME', dirname(__FILE__).'/');
11
 
12
  include( WPCACHEHOME . 'wp-cache-base.php');
13
 
14
- if( $blogcacheid != '' ) {
15
- $blog_cache_dir = str_replace( '//', '/', $cache_path . "blogs/" . $blogcacheid . '/' );
16
  } else {
17
- $blog_cache_dir = $cache_path;
18
  }
 
19
 
20
- $mutex_filename = 'wp_cache_mutex.lock';
21
  $new_cache = false;
22
 
23
- // Don't change variables behind this point
24
-
25
  if( !isset( $wp_cache_plugins_dir ) )
26
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
27
 
@@ -152,8 +164,14 @@ function wp_cache_serve_cache_file() {
152
  header( "Content-type: text/html; charset=UTF-8" ); // UTF-8 hard coded is bad but we don't know what it is this early in the process
153
  header( "Vary: Accept-Encoding, Cookie" );
154
  header( "Cache-Control: max-age=300, must-revalidate" );
155
- header( "WP-Cache: Served supercache file from PHP" );
156
- readfile( $file );
 
 
 
 
 
 
157
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Served page from supercache file. Mod rewrite rules may be broken or missing.", 5 );
158
  die();
159
  } else {
@@ -174,7 +192,7 @@ function wp_cache_serve_cache_file() {
174
  if( strpos( $header, 'Last-Modified:' ) === false )
175
  header($header);
176
  }
177
- header( 'WP-Super-Cache: WP-Cache' );
178
  if ( $wp_cache_object_cache ) {
179
  if ( $cache ) {
180
  if ( $ungzip ) {
@@ -285,7 +303,7 @@ function add_cacheaction( $action, $func ) {
285
 
286
  function do_cacheaction( $action, $value = '' ) {
287
  global $wp_supercache_actions;
288
- if( is_array( $wp_supercache_actions[ $action ] ) ) {
289
  $actions = $wp_supercache_actions[ $action ];
290
  foreach( $actions as $func ) {
291
  $value = $func( $value );
@@ -311,10 +329,10 @@ function wp_cache_mobile_group( $user_agent ) {
311
  // From http://wordpress.org/extend/plugins/wordpress-mobile-edition/ by Alex King
312
  function wp_cache_check_mobile( $cache_key ) {
313
  global $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
314
- if( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
315
  return $cache_key;
316
 
317
- if (!isset($_SERVER["HTTP_USER_AGENT"])) {
318
  return $cache_key;
319
  }
320
 
4
  if( !defined('WP_CONTENT_DIR') )
5
  define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
6
 
7
+ function wp_cache_load_config() {
8
+ global $wpsc_settings;
9
+ if( !include( WP_CONTENT_DIR . '/wp-cache-config.php' ) )
10
+ return false;
11
+ $fields = array( "cache_compression", "cache_enabled", "super_cache_enabled", "cache_max_time", "cache_path", "file_prefix", "blogcacheid", "cache_acceptable_files", "cache_rejected_uri", "cache_rejected_user_agent", "cache_rebuild_files", "wp_cache_mutex_disabled", "wp_cache_mobile", "wp_cache_mobile_whitelist", "wp_cache_mobile_browsers", "wp_cache_plugins_dir", "wp_cache_shutdown_gc", "wp_super_cache_late_init", "wp_super_cache_advanced_debug", "wp_super_cache_front_page_text", "wp_super_cache_front_page_clear", "wp_super_cache_front_page_check", "wp_super_cache_front_page_notification", "wp_cache_object_cache", "wp_cache_anon_only", "wp_supercache_cache_list", "wp_cache_debug_to_file", "wp_super_cache_debug", "wp_cache_debug_level", "wp_cache_debug_ip", "wp_cache_debug_log", "wp_cache_debug_email", "wp_cache_pages", "wp_cache_hide_donation", "wp_cache_not_logged_in", "wp_cache_clear_on_post_edit", "wp_cache_hello_world", "wp_cache_mobile_enabled", "wp_cache_cron_check", "use_flock", "sem_id" );
12
+ foreach( $fields as $field ) {
13
+ $GLOBALS[ $field ] = $$field;
14
+ $wpsc_settings[ $field ] = $$field;
15
+ }
16
+ return true;
17
+ }
18
+
19
+ if( false == wp_cache_load_config() )
20
  return true;
21
+
22
  if( !defined( 'WPCACHEHOME' ) )
23
  define('WPCACHEHOME', dirname(__FILE__).'/');
24
 
25
  include( WPCACHEHOME . 'wp-cache-base.php');
26
 
27
+ if( $wpsc_settings[ 'blogcacheid' ] != '' ) {
28
+ $wpsc_settings[ 'blog_cache_dir' ] = str_replace( '//', '/', $wpsc_settings[ 'cache_path' ] . "blogs/" . $wpsc_settings[ 'blogcacheid' ] . '/' );
29
  } else {
30
+ $wpsc_settings[ 'blog_cache_dir' ] = $wpsc_settings[ 'cache_path' ];
31
  }
32
+ $blog_cache_dir = $wpsc_settings[ 'blog_cache_dir' ];
33
 
34
+ $wpsc_settings[ 'mutex_filename' ] = 'wp_cache_mutex.lock';
35
  $new_cache = false;
36
 
 
 
37
  if( !isset( $wp_cache_plugins_dir ) )
38
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
39
 
164
  header( "Content-type: text/html; charset=UTF-8" ); // UTF-8 hard coded is bad but we don't know what it is this early in the process
165
  header( "Vary: Accept-Encoding, Cookie" );
166
  header( "Cache-Control: max-age=300, must-revalidate" );
167
+ header( "WP-Super-Cache: Served supercache file from PHP" );
168
+ if ( file_exists( $file . ".gz" ) && $wp_cache_gzip_encoding ) {
169
+ header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
170
+ header( 'Content-Length: ' . filesize( $file . ".gz" ) );
171
+ readfile( $file . ".gz" );
172
+ } else {
173
+ readfile( $file );
174
+ }
175
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Served page from supercache file. Mod rewrite rules may be broken or missing.", 5 );
176
  die();
177
  } else {
192
  if( strpos( $header, 'Last-Modified:' ) === false )
193
  header($header);
194
  }
195
+ header( 'WP-Super-Cache: Served legacy cache file' );
196
  if ( $wp_cache_object_cache ) {
197
  if ( $cache ) {
198
  if ( $ungzip ) {
303
 
304
  function do_cacheaction( $action, $value = '' ) {
305
  global $wp_supercache_actions;
306
+ if( array_key_exists($action, $wp_supercache_actions) && is_array( $wp_supercache_actions[ $action ] ) ) {
307
  $actions = $wp_supercache_actions[ $action ];
308
  foreach( $actions as $func ) {
309
  $value = $func( $value );
329
  // From http://wordpress.org/extend/plugins/wordpress-mobile-edition/ by Alex King
330
  function wp_cache_check_mobile( $cache_key ) {
331
  global $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
332
+ if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
333
  return $cache_key;
334
 
335
+ if ( !isset( $_SERVER[ "HTTP_USER_AGENT" ] ) ) {
336
  return $cache_key;
337
  }
338
 
wp-cache-phase2.php CHANGED
@@ -1,12 +1,18 @@
1
  <?php
2
 
3
  function wp_cache_phase2() {
4
- global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
 
5
  global $cache_max_time, $wp_cache_request_uri, $super_cache_enabled, $wp_cache_object_cache;
 
 
 
 
 
6
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'In WP Cache Phase 2', 5 );
7
 
8
- $wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
9
- $wp_cache_blog_charset = get_option( 'blog_charset' );
10
 
11
  wp_cache_mutex_init();
12
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
@@ -26,6 +32,8 @@ function wp_cache_phase2() {
26
  add_action('switch_theme', 'wp_cache_no_postid', 99);
27
  add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
28
 
 
 
29
  add_action('wp_cache_gc','wp_cache_gc_cron');
30
 
31
  do_cacheaction( 'add_cacheaction' );
@@ -165,7 +173,7 @@ function wp_cache_is_rejected($uri) {
165
  if( strstr( $uri, $u ) )
166
  return true; // we don't allow caching of wp-admin for security reasons
167
  }
168
- foreach ($cache_rejected_uri as $expr) {
169
  if( $expr != '' && preg_match( "~$expr~", $uri ) )
170
  return true;
171
  }
@@ -173,32 +181,32 @@ function wp_cache_is_rejected($uri) {
173
  }
174
 
175
  function wp_cache_mutex_init() {
176
- global $use_flock, $mutex, $cache_path, $mutex_filename, $sem_id, $blog_cache_dir, $wp_cache_mutex_disabled;
177
 
178
- if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
179
  return true;
180
 
181
- if(!is_bool($use_flock)) {
182
  if(function_exists('sem_get'))
183
- $use_flock = false;
184
  else
185
- $use_flock = true;
186
  }
187
 
188
  $mutex = false;
189
- if ($use_flock) {
190
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on filename: {$blog_cache_dir}{$mutex_filename}", 5 );
191
- $mutex = @fopen($blog_cache_dir . $mutex_filename, 'w');
192
  } else {
193
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on semaphore: $sem_id", 5 );
194
- $mutex = @sem_get($sem_id, 1, 0644 | IPC_CREAT, 1);
195
  }
196
  }
197
 
198
  function wp_cache_writers_entry() {
199
- global $use_flock, $mutex, $cache_path, $mutex_filename, $wp_cache_mutex_disabled;
200
 
201
- if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
202
  return true;
203
 
204
  if( !$mutex ) {
@@ -206,7 +214,7 @@ function wp_cache_writers_entry() {
206
  return false;
207
  }
208
 
209
- if ($use_flock) {
210
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "grabbing lock using flock()", 5 );
211
  flock($mutex, LOCK_EX);
212
  } else {
@@ -218,9 +226,9 @@ function wp_cache_writers_entry() {
218
  }
219
 
220
  function wp_cache_writers_exit() {
221
- global $use_flock, $mutex, $cache_path, $mutex_filename, $wp_cache_mutex_disabled;
222
 
223
- if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
224
  return true;
225
 
226
  if( !$mutex ) {
@@ -228,7 +236,7 @@ function wp_cache_writers_exit() {
228
  return false;
229
  }
230
 
231
- if ($use_flock) {
232
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "releasing lock using flock()", 5 );
233
  flock($mutex, LOCK_UN);
234
  } else {
@@ -280,12 +288,23 @@ function wp_cache_ob_callback( $buffer ) {
280
  return $buffer;
281
  }
282
 
 
 
 
 
 
 
 
 
 
 
283
 
284
  function wp_cache_get_ob(&$buffer) {
 
285
  global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
286
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
287
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
288
- global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
289
  global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
290
  global $wp_cache_not_logged_in, $wp_cache_object_cache, $cache_max_time;
291
 
@@ -310,7 +329,7 @@ function wp_cache_get_ob(&$buffer) {
310
  }
311
  }
312
 
313
- if (!preg_match('/(<\/html>|<\/rss>|<\/feed>)/i',$buffer) ) {
314
  $new_cache = false;
315
  if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) ) {
316
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
@@ -415,12 +434,6 @@ function wp_cache_get_ob(&$buffer) {
415
  }
416
  }
417
 
418
- if ( $cache_enabled || $super_cache_enabled ) {
419
- $buffer .= "<!-- Cached page generated by WP-Super-Cache on " . gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600))) . " -->\n";
420
- } else {
421
- $buffer .= "<!-- Live page served on " . gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600))) . " -->\n";
422
- }
423
-
424
  $added_cache = 0;
425
  $oc_key = get_oc_key();
426
  if ( preg_match('/<!--mclude|<!--mfunc/', $buffer)) { //Dynamic content
@@ -429,11 +442,17 @@ function wp_cache_get_ob(&$buffer) {
429
  "<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);
430
  $store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
431
  "<!--mfunc-->\n<?php $1 ;?>\n<!--/mfunc-->", $store);
432
- $store = apply_filters( 'wpsupercache_buffer', $store );
433
  $wp_cache_meta[ 'dynamic' ] = true;
434
  /* Clean function calls in tag */
435
  $buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
436
  $buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
 
 
 
 
 
 
 
437
  if ( false == $wp_cache_object_cache ) {
438
  if( $fr )
439
  fputs($fr, $store);
@@ -442,6 +461,8 @@ function wp_cache_get_ob(&$buffer) {
442
  }
443
  } else {
444
  $buffer = apply_filters( 'wpsupercache_buffer', $buffer );
 
 
445
  if( $gz || $wp_cache_gzip_encoding ) {
446
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Gzipping buffer.", 5 );
447
  $gzdata = gzencode( $buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP );
@@ -489,35 +510,44 @@ function wp_cache_get_ob(&$buffer) {
489
  $supercacheonly = false;
490
  fclose($fr);
491
  if ( filesize( $tmp_wpcache_filename ) == 0 ) {
 
492
  @unlink( $tmp_wpcache_filename );
493
- } elseif ( !rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename ) ) {
494
- unlink( $blog_cache_dir . $cache_filename );
495
- rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
 
 
 
 
496
  }
497
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp wp-cache file to {$blog_cache_dir}$cache_filename", 5 );
498
- $added_cache = 1;
499
  }
500
  if( $fr2 ) {
501
  fclose($fr2);
502
  if ( filesize( $tmp_cache_filename ) == 0 ) {
 
503
  @unlink( $tmp_cache_filename );
504
- } elseif ( !@rename( $tmp_cache_filename, $cache_fname ) ) {
505
- @unlink( $cache_fname );
506
- @rename( $tmp_cache_filename, $cache_fname );
 
 
 
 
507
  }
508
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
509
- $added_cache = 1;
510
  }
511
  if( $gz ) {
512
  fclose($gz);
513
  if ( filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
 
514
  @unlink( $tmp_cache_filename . '.gz' );
515
- } elseif ( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
516
- @unlink( $cache_fname . '.gz' );
517
- @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
 
 
 
 
518
  }
519
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache gz file to {$cache_fname}.gz", 5 );
520
- $added_cache = 1;
521
  }
522
  }
523
  if ( $added_cache && isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
@@ -529,7 +559,7 @@ function wp_cache_get_ob(&$buffer) {
529
  update_option( 'supercache_last_cached', $last_urls );
530
  }
531
  wp_cache_writers_exit();
532
- if ( !headers_sent() && isset( $wp_cache_gzip_first ) && 1 == $wp_cache_gzip_first && $wp_cache_gzip_encoding && $gzdata) {
533
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzip content headers. Sending buffer to browser", 5 );
534
  header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
535
  header( 'Vary: Accept-Encoding, Cookie' );
@@ -669,8 +699,9 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
669
  }
670
 
671
  function wp_cache_shutdown_callback() {
 
672
  global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename, $supercacheonly, $blog_cache_dir;
673
- global $wp_cache_blog_charset, $wp_cache_request_uri, $wp_cache_key, $wp_cache_object_cache, $cache_enabled;
674
 
675
  $wp_cache_meta[ 'uri' ] = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $wp_cache_request_uri); // To avoid XSS attacks
676
  $wp_cache_meta[ 'blog_id' ] = $blog_id;
@@ -715,7 +746,7 @@ function wp_cache_shutdown_callback() {
715
  if( $value == '' )
716
  $value = 'text/html';
717
  }
718
- $value .= "; charset=\"" . $wp_cache_blog_charset . "\"";
719
 
720
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending 'Content-Type: $value' header.", 2 );
721
  @header("Content-Type: $value");
@@ -742,8 +773,8 @@ function wp_cache_shutdown_callback() {
742
  fclose($fr);
743
  @chmod( $tmp_meta_filename, 0666 & ~umask());
744
  if( !@rename( $tmp_meta_filename, $blog_cache_dir . 'meta/' . $meta_file ) ) {
745
- unlink( $blog_cache_dir . 'meta/' . $meta_file );
746
- rename( $tmp_meta_filename, $blog_cache_dir . 'meta/' . $meta_file );
747
  }
748
  } elseif ( $cache_enabled ) {
749
  $oc_key = get_oc_key() . ".meta";
@@ -853,14 +884,17 @@ function wp_cache_post_id_gc( $siteurl, $post_id, $all = 'all' ) {
853
  if ( $all == 'all' ) {
854
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in $dir{$permalink}.", 4 );
855
  prune_super_cache( $dir . $permalink, true, true );
 
856
  @rmdir( $dir . $permalink );
857
  } else {
858
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cached index.html(.gz) in $dir{$permalink}.", 4 );
859
  prune_super_cache( $dir . $permalink . 'index.html', true, true );
860
  prune_super_cache( $dir . $permalink . 'index.html.gz', true, true );
 
861
  }
862
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}page/.", 4 );
863
  prune_super_cache( $dir . 'page/', true );
 
864
  }
865
 
866
  function wp_cache_post_change( $post_id ) {
@@ -896,6 +930,7 @@ function wp_cache_post_change( $post_id ) {
896
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
897
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
898
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
 
899
  }
900
  wp_cache_post_id_gc( $siteurl, $post_id );
901
  if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
@@ -905,6 +940,7 @@ function wp_cache_post_change( $post_id ) {
905
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( get_option( 'page_for_posts' ) ) ) );
906
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . $permalink . 'index.html', true, true );
907
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . $permalink . 'index.html.gz', true, true );
 
908
  }
909
  }
910
 
@@ -926,15 +962,21 @@ function wp_cache_post_change( $post_id ) {
926
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting post cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
927
  @unlink($meta_pathname);
928
  @unlink($content_pathname);
929
- @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html');
930
- @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html.gz');
 
 
 
931
  }
932
  } elseif ($meta[ 'blog_id' ] == $blog_id) {
933
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
934
  @unlink($meta_pathname);
935
  @unlink($content_pathname);
936
- @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html');
937
- @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html.gz');
 
 
 
938
  }
939
 
940
  }
1
  <?php
2
 
3
  function wp_cache_phase2() {
4
+ global $wpsc_settings;
5
+ global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_last_gc;
6
  global $cache_max_time, $wp_cache_request_uri, $super_cache_enabled, $wp_cache_object_cache;
7
+ global $cache_enabled;
8
+
9
+ if ( $cache_enabled == false )
10
+ return false;
11
+
12
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'In WP Cache Phase 2', 5 );
13
 
14
+ $wpsc_settings[ 'wp_cache_gmt_offset' ] = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
15
+ $wpsc_settings[ 'wp_cache_blog_charset' ] = get_option( 'blog_charset' );
16
 
17
  wp_cache_mutex_init();
18
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
32
  add_action('switch_theme', 'wp_cache_no_postid', 99);
33
  add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
34
 
35
+ add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache' );
36
+
37
  add_action('wp_cache_gc','wp_cache_gc_cron');
38
 
39
  do_cacheaction( 'add_cacheaction' );
173
  if( strstr( $uri, $u ) )
174
  return true; // we don't allow caching of wp-admin for security reasons
175
  }
176
+ foreach ( $cache_rejected_uri as $expr ) {
177
  if( $expr != '' && preg_match( "~$expr~", $uri ) )
178
  return true;
179
  }
181
  }
182
 
183
  function wp_cache_mutex_init() {
184
+ global $wpsc_settings, $mutex;
185
 
186
+ if( isset( $wpsc_settings[ 'wp_cache_mutex_disabled' ] ) && $wpsc_settings[ 'wp_cache_mutex_disabled' ] )
187
  return true;
188
 
189
+ if( !is_bool( $wpsc_settings[ 'use_flock' ] ) ) {
190
  if(function_exists('sem_get'))
191
+ $wpsc_settings[ 'use_flock' ] = false;
192
  else
193
+ $wpsc_settings[ 'use_flock' ] = true;
194
  }
195
 
196
  $mutex = false;
197
+ if ($wpsc_settings[ 'use_flock' ] ) {
198
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on filename: {$wpsc_settings[ 'blog_cache_dir' ]}{$wpsc_settings[ 'mutex_filename' ]}", 5 );
199
+ $mutex = @fopen( $wpsc_settings[ 'blog_cache_dir' ] . $wpsc_settings[ 'mutex_filename' ], 'w' );
200
  } else {
201
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on semaphore: {$wpsc_settings[ 'sem_id' ]}", 5 );
202
+ $mutex = @sem_get( $wpsc_settings[ 'sem_id' ], 1, 0644 | IPC_CREAT, 1 );
203
  }
204
  }
205
 
206
  function wp_cache_writers_entry() {
207
+ global $wpsc_settings, $mutex;
208
 
209
+ if( isset( $wpsc_settings[ 'wp_cache_mutex_disabled' ] ) && $wpsc_settings[ 'wp_cache_mutex_disabled' ] )
210
  return true;
211
 
212
  if( !$mutex ) {
214
  return false;
215
  }
216
 
217
+ if ( $wpsc_settings[ 'use_flock' ] ) {
218
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "grabbing lock using flock()", 5 );
219
  flock($mutex, LOCK_EX);
220
  } else {
226
  }
227
 
228
  function wp_cache_writers_exit() {
229
+ global $wpsc_settings, $mutex;
230
 
231
+ if( isset( $wpsc_settings[ 'wp_cache_mutex_disabled' ] ) && $wpsc_settings[ 'wp_cache_mutex_disabled' ] )
232
  return true;
233
 
234
  if( !$mutex ) {
236
  return false;
237
  }
238
 
239
+ if ( $wpsc_settings[ 'use_flock' ] ) {
240
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "releasing lock using flock()", 5 );
241
  flock($mutex, LOCK_UN);
242
  } else {
288
  return $buffer;
289
  }
290
 
291
+ function wp_cache_append_tag( &$buffer ) {
292
+ global $wpsc_settings;
293
+ global $cache_enabled, $super_cache_enabled;
294
+ $timestamp = gmdate('Y-m-d H:i:s', (time() + ( $wpsc_settings[ 'wp_cache_gmt_offset' ] * 3600)));
295
+ if ( $cache_enabled || $super_cache_enabled ) {
296
+ $buffer .= "<!-- Cached page generated by WP-Super-Cache on $timestamp -->\n";
297
+ } else {
298
+ $buffer .= "<!-- Live page served on $timestamp -->\n";
299
+ }
300
+ }
301
 
302
  function wp_cache_get_ob(&$buffer) {
303
+ global $wpsc_settings;
304
  global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
305
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
306
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
307
+ global $wp_cache_404, $gzsize, $supercacheonly;
308
  global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
309
  global $wp_cache_not_logged_in, $wp_cache_object_cache, $cache_max_time;
310
 
329
  }
330
  }
331
 
332
+ if (!preg_match('/(<\/html>|<\/rss>|<\/feed>|<\/urlset)/i',$buffer) ) {
333
  $new_cache = false;
334
  if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) ) {
335
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
434
  }
435
  }
436
 
 
 
 
 
 
 
437
  $added_cache = 0;
438
  $oc_key = get_oc_key();
439
  if ( preg_match('/<!--mclude|<!--mfunc/', $buffer)) { //Dynamic content
442
  "<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);
443
  $store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
444
  "<!--mfunc-->\n<?php $1 ;?>\n<!--/mfunc-->", $store);
 
445
  $wp_cache_meta[ 'dynamic' ] = true;
446
  /* Clean function calls in tag */
447
  $buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
448
  $buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
449
+ $store = apply_filters( 'wpsupercache_buffer', $store );
450
+ // Append WP Super Cache or Live page comment tag
451
+ wp_cache_append_tag($buffer);
452
+ global $wp_super_cache_late_init;
453
+ if ( false == isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init == 0 ) )
454
+ $buffer .= '<!-- Super Cache dynamic page detected but $wp_super_cache_late_init not set. See the readme.txt for further details. -->';
455
+
456
  if ( false == $wp_cache_object_cache ) {
457
  if( $fr )
458
  fputs($fr, $store);
461
  }
462
  } else {
463
  $buffer = apply_filters( 'wpsupercache_buffer', $buffer );
464
+ // Append WP Super Cache or Live page comment tag
465
+ wp_cache_append_tag($buffer);
466
  if( $gz || $wp_cache_gzip_encoding ) {
467
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Gzipping buffer.", 5 );
468
  $gzdata = gzencode( $buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP );
510
  $supercacheonly = false;
511
  fclose($fr);
512
  if ( filesize( $tmp_wpcache_filename ) == 0 ) {
513
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! The file $tmp_wpcache_filename was empty. Did not rename to {$blog_cache_dir}{$cache_filename}", 5 );
514
  @unlink( $tmp_wpcache_filename );
515
+ } else {
516
+ if ( !rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename ) ) {
517
+ unlink( $blog_cache_dir . $cache_filename );
518
+ rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
519
+ }
520
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp wp-cache file to {$blog_cache_dir}$cache_filename", 5 );
521
+ $added_cache = 1;
522
  }
 
 
523
  }
524
  if( $fr2 ) {
525
  fclose($fr2);
526
  if ( filesize( $tmp_cache_filename ) == 0 ) {
527
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
528
  @unlink( $tmp_cache_filename );
529
+ } else {
530
+ if ( !@rename( $tmp_cache_filename, $cache_fname ) ) {
531
+ @unlink( $cache_fname );
532
+ @rename( $tmp_cache_filename, $cache_fname );
533
+ }
534
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
535
+ $added_cache = 1;
536
  }
 
 
537
  }
538
  if( $gz ) {
539
  fclose($gz);
540
  if ( filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
541
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! The file {$tmp_cache_filename}.gz was empty. Did not rename to {$cache_fname}.gz", 5 );
542
  @unlink( $tmp_cache_filename . '.gz' );
543
+ } else {
544
+ if ( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
545
+ @unlink( $cache_fname . '.gz' );
546
+ @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
547
+ }
548
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache gz file to {$cache_fname}.gz", 5 );
549
+ $added_cache = 1;
550
  }
 
 
551
  }
552
  }
553
  if ( $added_cache && isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
559
  update_option( 'supercache_last_cached', $last_urls );
560
  }
561
  wp_cache_writers_exit();
562
+ if ( !headers_sent() && $wp_cache_gzip_encoding && $gzdata) {
563
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzip content headers. Sending buffer to browser", 5 );
564
  header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
565
  header( 'Vary: Accept-Encoding, Cookie' );
699
  }
700
 
701
  function wp_cache_shutdown_callback() {
702
+ global $wpsc_settings;
703
  global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename, $supercacheonly, $blog_cache_dir;
704
+ global $wp_cache_request_uri, $wp_cache_key, $wp_cache_object_cache, $cache_enabled;
705
 
706
  $wp_cache_meta[ 'uri' ] = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $wp_cache_request_uri); // To avoid XSS attacks
707
  $wp_cache_meta[ 'blog_id' ] = $blog_id;
746
  if( $value == '' )
747
  $value = 'text/html';
748
  }
749
+ $value .= "; charset=\"" . $wpsc_settings[ 'wp_cache_blog_charset' ] . "\"";
750
 
751
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending 'Content-Type: $value' header.", 2 );
752
  @header("Content-Type: $value");
773
  fclose($fr);
774
  @chmod( $tmp_meta_filename, 0666 & ~umask());
775
  if( !@rename( $tmp_meta_filename, $blog_cache_dir . 'meta/' . $meta_file ) ) {
776
+ @unlink( $blog_cache_dir . 'meta/' . $meta_file );
777
+ @rename( $tmp_meta_filename, $blog_cache_dir . 'meta/' . $meta_file );
778
  }
779
  } elseif ( $cache_enabled ) {
780
  $oc_key = get_oc_key() . ".meta";
884
  if ( $all == 'all' ) {
885
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in $dir{$permalink}.", 4 );
886
  prune_super_cache( $dir . $permalink, true, true );
887
+ do_action( 'gc_cache', 'prune', $permalink );
888
  @rmdir( $dir . $permalink );
889
  } else {
890
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cached index.html(.gz) in $dir{$permalink}.", 4 );
891
  prune_super_cache( $dir . $permalink . 'index.html', true, true );
892
  prune_super_cache( $dir . $permalink . 'index.html.gz', true, true );
893
+ do_action( 'gc_cache', 'prune', $permalink );
894
  }
895
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}page/.", 4 );
896
  prune_super_cache( $dir . 'page/', true );
897
+ do_action( 'gc_cache', 'prune', '/page/' );
898
  }
899
 
900
  function wp_cache_post_change( $post_id ) {
930
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
931
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
932
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
933
+ do_action( 'gc_cache', 'prune', 'homepage' );
934
  }
935
  wp_cache_post_id_gc( $siteurl, $post_id );
936
  if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
940
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( get_option( 'page_for_posts' ) ) ) );
941
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . $permalink . 'index.html', true, true );
942
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . $permalink . 'index.html.gz', true, true );
943
+ do_action( 'gc_cache', 'prune', $permalink );
944
  }
945
  }
946
 
962
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting post cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
963
  @unlink($meta_pathname);
964
  @unlink($content_pathname);
965
+ if ( $super_cache_enabled == true ) {
966
+ @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html');
967
+ @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html.gz');
968
+ do_action( 'gc_cache', 'rebuild', trailingslashit( $meta[ 'uri' ] ) );
969
+ }
970
  }
971
  } elseif ($meta[ 'blog_id' ] == $blog_id) {
972
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
973
  @unlink($meta_pathname);
974
  @unlink($content_pathname);
975
+ if ( $super_cache_enabled == true ) {
976
+ @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html');
977
+ @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html.gz');
978
+ do_action( 'gc_cache', 'rebuild', trailingslashit( $meta[ 'uri' ] ) );
979
+ }
980
  }
981
 
982
  }
wp-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Super Cache
4
  Plugin URI: http://ocaoimh.ie/wp-super-cache/
5
  Description: Very fast caching plugin for WordPress.
6
- Version: 0.9.9.3
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -110,27 +110,347 @@ function wpsupercache_activate() {
110
  }
111
  register_activation_hook( __FILE__, 'wpsupercache_activate' );
112
 
 
 
 
 
 
 
 
 
 
 
113
  function wp_cache_add_pages() {
114
- if( function_exists( 'is_site_admin' ) ) {
115
- if( is_site_admin() ) {
116
- add_submenu_page( 'ms-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
117
- add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  } else {
120
- add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
  }
123
- add_action('admin_menu', 'wp_cache_add_pages');
 
124
 
125
  function wp_cache_manager() {
126
  global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world;
127
  global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers;
128
- global $wp_cache_cron_check, $wp_cache_debug, $wp_cache_hide_donation, $wp_cache_not_logged_in, $wp_supercache_cache_list;
129
  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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
- if( function_exists( 'is_site_admin' ) )
132
- if( !is_site_admin() )
133
- return;
134
 
135
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
136
  if( get_option( 'gzipcompression' ) == 1 )
@@ -165,24 +485,30 @@ jQuery(document).ready(function(){
165
  });
166
  });
167
  </script>
 
 
 
 
 
 
 
168
  <?php
 
169
  echo '<div class="wrap">';
170
- echo "<h2><a href='?page=wpsupercache'>" . __( 'WP Super Cache Manager', 'wp-super-cache' ) . "</a></h2>\n";
171
- if ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) {
172
- ?><h3><?php _e( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ); ?></h3>
173
- <p><?php _e( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' );
174
- if( !ini_get( 'safe_mode_gid' ) ) {
175
- echo __( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . "</p><p>";
176
- echo sprintf( __( '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' ), WP_CONTENT_DIR ) . "</p>";
177
- } else {
178
- echo __( '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' ) . "</p>";
179
- }
180
  }
181
 
182
- if ( '' == get_option( 'permalink_structure' ) ) {
183
- echo "<h3>" . __( 'Permlink Structure Error', 'wp-super-cache' ) . "</h3>";
184
- echo "<p>" . __( 'A custom url or permalink structure is required for this plugin to work correctly. Please go to the <a href="options-permalink.php">Permalinks Options Page</a> to configure your permalinks.' ) . "</p>";
185
  }
 
186
 
187
  if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
188
  wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
@@ -194,282 +520,74 @@ jQuery(document).ready(function(){
194
  echo '<strong>' . __( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>';
195
  }
196
 
197
- if ( !wp_cache_check_link() ||
198
- !wp_cache_verify_config_file() ||
199
- !wp_cache_verify_cache_dir() ) {
200
- echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>';
201
- echo "</div>\n";
202
- return;
203
- }
204
-
205
- if (!wp_cache_check_global_config()) {
206
- echo "</div>\n";
207
- return;
208
- }
209
- if( $wp_cache_debug || !$wp_cache_cron_check ) {
210
- if( function_exists( "wp_remote_get" ) == false ) {
211
- $hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) );
212
- if( strpos( $hostname, '/' ) )
213
- $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
214
- $ip = gethostbyname( $hostname );
215
- if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) {
216
- ?><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3>
217
- <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>
218
- <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p>
219
- <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p>
220
- </div>
221
- <?php
222
- } else {
223
- wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file);
224
- }
225
- } else {
226
- $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425');
227
- $cron = wp_remote_get($cron_url, array('timeout' => 0.01, 'blocking' => true));
228
- if( is_array( $cron ) ) {
229
- if( $cron[ 'response' ][ 'code' ] == '404' ) {
230
- ?><h3>Warning! wp-cron.php not found!</h3>
231
- <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>
232
- <p><?php _e( 'Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p>
233
- <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p>
234
- </div>
235
- <?php
236
- } else {
237
- wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file);
238
- }
239
- }
240
- }
241
- }
242
-
243
  if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
244
  wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file);
245
  } else {
246
  wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file);
247
  }
248
 
249
- if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
250
- ?><h4 style='color: #a00'><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h4>
251
- <p><?php _e( 'PHP is compressing the data sent to the visitors of your site. Disabling this is recommended as the plugin caches the compressed output once instead of compressing the same page over and over again. Also see #21 in the Troubleshooting section. See <a href="http://php.net/manual/en/zlib.configuration.php">this page</a> for instructions on modifying your php.ini.', 'wp-super-cache' ); ?></p><?php
252
- }
253
-
254
- if( $cache_enabled == true && $super_cache_enabled == true && !got_mod_rewrite() ) {
255
- ?><h4 style='color: #a00'><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h4>
256
- <p><?php _e( 'It appears that mod_rewrite is not installed. Sometimes this check isn&#8217;t 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use half-on mode.', 'wp-super-cache' ); ?></p><?php
257
  }
258
 
259
- if( !is_writeable_ACLSafe($wp_cache_config_file) ) {
260
- define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
261
- ?><h4 style='text-align:center; color: #a00'><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?> <a href="javascript:toggleLayer('readonlywarning');" title="<?php _e( 'Why your configuration may not be changed', 'wp-super-cache' ); ?>"><?php _e( 'Why', 'wp-super-cache' ); ?></a></h4>
262
- <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
263
- <p><?php printf( __( 'The WP Super Cache configuration file is <code>%s/wp-cache-config.php</code> and cannot be modified. That file must be writeable by the webserver to make any changes.', 'wp-super-cache' ), WP_CONTENT_DIR ); ?>
264
- <?php _e( 'A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it&#8217;s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p>
265
- <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code>
266
- <?php _e( 'Readonly:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
267
- </div><?php
268
- } else {
269
- define( "SUBMITDISABLED", ' ' );
270
- }
271
-
272
- // Server could be running as the owner of the wp-content directory. Therefore, if it's
273
- // writable, issue a warning only if the permissions aren't 755.
274
- if( is_writeable_ACLSafe( WP_CONTENT_DIR . '/' ) ) {
275
- $wp_content_stat = stat(WP_CONTENT_DIR . '/');
276
- $wp_content_mode = ($wp_content_stat['mode'] & 0777);
277
- if( $wp_content_mode != 0755 ) {
278
- ?><h4 style='text-align:center; color: #a00'><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h4>
279
- <p><?php printf( __( 'You should change the permissions on %s and make it more restrictive. Use your ftp client, or the following command to fix things:', 'wp-super-cache' ), WP_CONTENT_DIR ); ?><code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p><?php
280
- }
281
- }
282
-
283
- // used by mod_rewrite rules and config file
284
- if ( function_exists( "cfmobi_default_browsers" ) ) {
285
- $wp_cache_mobile_browsers = cfmobi_default_browsers( "mobile" );
286
- $wp_cache_mobile_browsers = array_merge( $wp_cache_mobile_browsers, cfmobi_default_browsers( "touch" ) );
287
- } else {
288
- $wp_cache_mobile_browsers = array( '2.0 MMP', '240x320', '400X240', 'AvantGo', 'BlackBerry', 'Blazer', 'Cellphone', 'Danger', 'DoCoMo', 'Elaine/3.0', 'EudoraWeb', 'Googlebot-Mobile', 'hiptop', 'IEMobile', 'KYOCERA/WX310K', 'LG/U990', 'MIDP-2.', 'MMEF20', 'MOT-V', 'NetFront', 'Newt', 'Nintendo Wii', 'Nitro', 'Nokia', 'Opera Mini', 'Palm', 'PlayStation Portable', 'portalmmm', 'Proxinet', 'ProxiNet', 'SHARP-TQ-GX10', 'SHG-i900', 'Small', 'SonyEricsson', 'Symbian OS', 'SymbianOS', 'TS21i-10', 'UP.Browser', 'UP.Link', 'webOS', 'Windows CE', 'WinWAP', 'YahooSeeker/M1A1-R2D2', 'iPhone', 'iPod', 'Android', 'BlackBerry9530', 'LG-TU915 Obigo', 'LGE VX', 'webOS', 'Nokia5800' );
289
- }
290
- $wp_cache_mobile_prefixes = array( 'w3c ', 'w3c-', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'htc_', 'inno', 'ipaq', 'ipod', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'lg/u', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-' ); // from http://svn.wp-plugins.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/lite_detection.php
291
- $wp_cache_mobile_browsers = apply_filters( 'cached_mobile_browsers', $wp_cache_mobile_browsers ); // Allow mobile plugins access to modify the mobile UA list
292
- $wp_cache_mobile_prefixes = apply_filters( 'cached_mobile_prefixes', $wp_cache_mobile_prefixes ); // Allow mobile plugins access to modify the mobile UA prefix list
293
- $mobile_groups = apply_filters( 'cached_mobile_groups', array() ); // Group mobile user agents by capabilities. Lump them all together by default
294
- // mobile_groups = array( 'apple' => array( 'ipod', 'iphone' ), 'nokia' => array( 'nokia5800', 'symbianos' ) );
295
-
296
- if ( $valid_nonce ) {
297
- if( isset( $_POST[ 'wp_cache_status' ] ) ) {
298
- if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) {
299
- $wp_cache_mobile_enabled = 1;
300
- } else {
301
- $wp_cache_mobile_enabled = 0;
302
- }
303
- if( $wp_cache_mobile_enabled == 1 ) {
304
- update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
305
- }
306
- wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_