WP Super Cache - Version 1.1

Version Description

Lots of bugfixes

=

Download this release

Release Info

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

Code changes from version 1.0 to 1.1

Changelog.txt CHANGED
@@ -1,3 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2011-12-05 17:56 donncha
2
 
3
  * wp-super-cache.pot: Updated the translation file
1
+ 2012-05-23 10:17 donncha
2
+
3
+ * wp-super-cache.pot: Updated translation file
4
+
5
+ 2012-05-23 10:14 donncha
6
+
7
+ * wp-cache.php: Remove mentions of wp-minify as that plugin doesn't
8
+ exist any more
9
+
10
+ 2012-05-23 10:06 donncha
11
+
12
+ * wp-super-cache.pot: Updated translation file
13
+
14
+ 2012-05-23 10:04 donncha
15
+
16
+ * wp-cache.php: Added message to yellow box.
17
+
18
+ 2012-05-23 10:03 donncha
19
+
20
+ * wp-super-cache.pot: Updated translation file
21
+
22
+ 2012-05-17 15:36 donncha
23
+
24
+ * wp-cache-phase1.php, wp-cache.php: Remove the debug log level, I
25
+ always recommend level 5 anyway.
26
+
27
+ 2012-05-14 16:32 donncha
28
+
29
+ * wp-cache.php: Correctly check $wp_cache_disable_utf8 is not set
30
+
31
+ 2012-05-11 15:24 donncha
32
+
33
+ * Changelog.txt, readme.txt: Added changelog entries for 1.0 and
34
+ 1.1
35
+
36
+ 2012-05-11 15:02 donncha
37
+
38
+ * wp-super-cache.pot: Updated translation file
39
+
40
+ 2012-05-10 11:14 donncha
41
+
42
+ * wp-cache-phase2.php: Create the legacy cache dir if it's not
43
+ there
44
+
45
+ 2012-05-10 10:50 donncha
46
+
47
+ * wp-cache-phase2.php: Added wp_cache_clear_cache_on_menu() to
48
+ clear the cache when the navigation menu is modified
49
+
50
+ 2012-05-10 10:41 donncha
51
+
52
+ * wp-cache-phase2.php: Revert previous change,
53
+ wp_cache_clear_cache() with no parameter is supposed to clear out
54
+ all cached files
55
+
56
+ 2012-05-10 10:32 donncha
57
+
58
+ * wp-cache-phase2.php: Only clear the cache for the current blog,
59
+ not all blogs
60
+
61
+ 2012-05-10 10:28 donncha
62
+
63
+ * wp-cache-phase2.php: Only clear the cache cache of the current
64
+ blog when "clear all cache on new post" is enabled, not all blogs
65
+
66
+ 2012-05-10 10:25 donncha
67
+
68
+ * wp-cache-phase2.php: Added $blog_id parameter to
69
+ wp_cache_clear_cache() so only one blog's cache files are deleted
70
+ (except legacy files, all deleted regardless)
71
+
72
+ 2012-05-10 10:22 donncha
73
+
74
+ * wp-cache-phase1.php, wp-cache-phase2.php: Put code that creates
75
+ the cache/blogs/ directories into a function so it doesn't get
76
+ called all the time, slight speed up and less empty directories
77
+
78
+ 2012-05-10 10:08 donncha
79
+
80
+ * wp-cache-phase2.php: Added "clean_post_cache" action to clear
81
+ cache but stop the function being called twice
82
+
83
+ 2012-05-10 10:07 donncha
84
+
85
+ * wp-cache-phase1.php: Add $blog_id parameter to get_supercache_dir
86
+ function to get the directory for that blog
87
+
88
+ 2012-05-01 17:01 donncha
89
+
90
+ * wp-cache.php: Removed "Last GC" time as it's on the advanced
91
+ settings page.
92
+
93
+ 2012-05-01 16:50 donncha
94
+
95
+ * plugins/wptouch.php, wp-cache-phase1.php: Added
96
+ wp_cache_check_mobile filter to short circuit mobile check. See
97
+ http://wordpress.org/support/topic/wp-super-cache-and-wptouch?replies=2
98
+
99
+ 2012-04-26 07:51 donncha
100
+
101
+ * wp-cache-phase2.php: Don't delete cached files on draft post
102
+ save, props jrevillini
103
+ http://wordpress.org/support/topic/plugin-wp-super-cache-clear-all-cache-shouldnt-be-executed-on-a-draft-post?replies=7#post-2760461
104
+
105
+ 2012-04-13 14:05 donncha
106
+
107
+ * wp-cache-phase2.php: Added action for wp_trash_post so it clears
108
+ the cache
109
+
110
+ 2012-04-13 14:02 donncha
111
+
112
+ * wp-cache.php: Show more files in the file listing
113
+
114
+ 2012-04-13 13:21 donncha
115
+
116
+ * wp-cache.php: Show a warning when 304 browser caching is disabled
117
+
118
+ 2012-03-12 08:57 donncha
119
+
120
+ * wp-cache.php: If site is running less than PHP 5.3.0 then check
121
+ for safe mode. Props cyberws,
122
+ http://wordpress.org/support/topic/plugin-wp-super-cache-php-53-compatibility
123
+
124
+ 2012-03-07 10:59 donncha
125
+
126
+ * wp-cache-phase1.php: Reverse logic on the remove cookies filter
127
+
128
+ 2012-03-07 10:55 donncha
129
+
130
+ * wp-cache-phase1.php: Added a filter,
131
+ 'wp_supercache_remove_cookies' that decides if cookies should be
132
+ removed on a per request basis. See
133
+ http://wordpress.org/support/topic/plugin-wp-super-cache-make-known-users-anonymous-breaks-autheticated-commenting
134
+
135
+ 2012-03-01 11:52 donncha
136
+
137
+ * wp-cache.php: Fixed cache schedule dropdown
138
+
139
+ 2012-02-22 22:03 donncha
140
+
141
+ * wp-cache-base.php, wp-cache.php: Check that WP_MULTI_SITE is true
142
+ as well!
143
+
144
+ 2012-02-22 22:02 donncha
145
+
146
+ * wp-cache-phase2.php: No need to call this twice, removed second
147
+ call.
148
+
149
+ 2012-02-17 10:09 donncha
150
+
151
+ * wp-super-cache.pot: Updated translation file
152
+
153
+ 2012-02-16 14:18 donncha
154
+
155
+ * wp-cache.php: Added a title to the Delete Cache admin menu link
156
+
157
+ 2012-02-16 13:55 donncha
158
+
159
+ * wp-cache-base.php, wp-cache.php: Check for VHOST as well as
160
+ MULTISITE checks for sites that upgrade from MU and don't have
161
+ that constant set.
162
+
163
+ 2012-02-15 22:11 donncha
164
+
165
+ * wp-cache.php: When preloading, don't preload page_on_front or
166
+ page_for_poss pages as that will probably clear the cache. Props
167
+ te-deum. See
168
+ http://wordpress.org/support/topic/plugin-wp-super-cache-preloaded-pages-not-created-until-user-visits?replies=28#post-2627649
169
+
170
+ 2012-02-09 19:28 donncha
171
+
172
+ * wp-cache-phase2.php: Disable caching AFTER actions added so cache
173
+ is cleared
174
+
175
+ 2012-02-09 18:17 donncha
176
+
177
+ * wp-cache-phase1.php: If SERVER_NAME isn't defined then use
178
+ HTTP_HOST
179
+
180
+ 2012-02-09 18:03 donncha
181
+
182
+ * wp-cache-phase2.php: Hopefully fix moderation/administration of
183
+ comments.
184
+
185
+ 2012-02-09 16:09 donncha
186
+
187
+ * wp-cache-phase1.php, wp-cache-phase2.php: Check if variables
188
+ defined and avoid warnings
189
+
190
+ 2012-02-09 15:53 donncha
191
+
192
+ * wp-cache-phase1.php: Check that site_url returns something and
193
+ deal with it if it doesn't. PHP is weird sometimes.
194
+ http://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made
195
+
196
+ 2012-02-09 14:01 donncha
197
+
198
+ * wp-cache-phase2.php: Check if referer is comments admin page to
199
+ decide what to delete, all or single page.
200
+
201
+ 2012-02-09 13:59 donncha
202
+
203
+ * wp-cache-base.php, wp-cache-phase1.php, wp-cache.php: Replace
204
+ HTTP_HOST with SERVER_NAME, props _ck_
205
+ http://wordpress.org/support/topic/plugin-wp-super-cache-minor-bug-with-use-of-_serverhttp_host-instead-of-_serverserver_name
206
+
207
+ 2012-02-09 13:58 donncha
208
+
209
+ * wp-cache-phase2.php: Add slashes to page urls when doing GC
210
+
211
+ 2012-02-09 13:49 donncha
212
+
213
+ * wp-cache.php: This error points at the wrong place in the docs
214
+
215
+ 2012-02-03 09:30 donncha
216
+
217
+ * wp-cache.php: Added link to Cron View, a plugin that can help
218
+ debug wp-cron problems
219
+
220
+ 2012-01-30 13:44 donncha
221
+
222
+ * readme.txt: Added link to Cron View plugin to help diagnose
223
+ crontab problems
224
+
225
+ 2012-01-30 12:00 donncha
226
+
227
+ * wp-cache-phase2.php: CRON requests are non empty GET requests so
228
+ we want to ignore those params
229
+
230
+ 2012-01-30 11:22 donncha
231
+
232
+ * wp-cache.php: Add description of GC notification emails checkbox
233
+
234
+ 2012-01-30 11:21 donncha
235
+
236
+ * wp-cache.php: Make it clearer that GC jobs are scheduled to UTC
237
+ times
238
+
239
+ 2012-01-30 09:19 donncha
240
+
241
+ * wp-cache.php: Make preloading of taxonomies optional, see
242
+ http://wordpress.org/support/topic/wp-super-cache-causes-time-out-on-file-delete-with-rackspace-cloudsites?replies=12
243
+
244
+ 2012-01-30 09:16 donncha
245
+
246
+ * wp-cache.php: Fixes for PHP warnings, props vStone, lots more to
247
+ come when I have time.
248
+ http://plugins.trac.wordpress.org/ticket/1466
249
+
250
+ 2012-01-23 09:19 donncha
251
+
252
+ * wp-cache.php: Use get_supercache_dir() rather than hardcoding the
253
+ supercache directory
254
+
255
+ 2012-01-23 09:18 donncha
256
+
257
+ * plugins/domain-mapping.php, wp-cache-phase1.php: Added
258
+ 'wp_super_cache_supercachedir' filter on supercache directory and
259
+ modified domain mapping plugin to support it, props Matthew
260
+ Boynes.
261
+
262
+ 2012-01-19 08:23 donncha
263
+
264
+ * plugins/wptouch.php: Check if wptouch functions exist before
265
+ filtering browsers
266
+
267
+ 2012-01-18 11:38 donncha
268
+
269
+ * readme.txt: Added warning that files in the cache directory are
270
+ prone to be deleted. See
271
+ http://ocaoimh.ie/2012/01/18/a-cache-directory-is-a-temporary-directory/
272
+
273
+ 2012-01-13 09:27 donncha
274
+
275
+ * wp-cache-phase2.php: Check that function returns false as it can
276
+ return 0 if not files deleted
277
+
278
+ 2012-01-11 10:59 donncha
279
+
280
+ * wp-cache-phase2.php: Clear out the global /page/* pages when a
281
+ post is published
282
+
283
+ 2012-01-11 10:58 donncha
284
+
285
+ * wp-cache-phase1.php: Remove https from the home url to get the
286
+ supercache dir
287
+
288
+ 2012-01-10 14:42 donncha
289
+
290
+ * wp-cache-phase2.php: Just some more debug messages!
291
+
292
+ 2012-01-10 14:41 donncha
293
+
294
+ * wp-cache-phase1.php, wp-cache-phase2.php, wp-cache.php: Added
295
+ options:
296
+ * disable caching if GET is not empty.
297
+ * disable the blog_charset .htaccess directive which I added back
298
+ in.
299
+
300
+ 2012-01-10 14:37 donncha
301
+
302
+ * wp-cache.php: don't check the mobile prefix or browser strings
303
+ against the rewrite rules when they're empty. Any changes will be
304
+ caught further down anyway
305
+
306
+ 2012-01-09 22:33 donncha
307
+
308
+ * wp-cache.php: I forgot that do_cacheaction() isn't defined before
309
+ the plugin is configured! See
310
+ http://wordpress.org/support/topic/plugin-wp-super-cache-my-page-2-is-randomly-redirecting-to-other-posts?replies=19#post-2549174
311
+
312
+ 2012-01-05 17:04 donncha
313
+
314
+ * plugins/multisite.php, wp-cache.php: Disable the settings page
315
+ when caching disabled on Site admin page.
316
+
317
+ 2012-01-05 15:52 donncha
318
+
319
+ * plugins/multisite.php: Added multisite Network Admin Sites
320
+ "Cached" column
321
+
322
+ 2012-01-05 12:51 donncha
323
+
324
+ * wp-cache-phase2.php: Cache the output of is_* functions used by
325
+ the plugin because $wp_query may be destroyed by the PHP
326
+ destructor. See
327
+ http://ocaoimh.ie/2012/01/04/wp-super-cache-bug-fixing-and-php-object-destruction/
328
+
329
+ 2012-01-04 16:22 donncha
330
+
331
+ * wp-cache.php: Removed unneeded debug log
332
+
333
+ 2012-01-04 16:04 donncha
334
+
335
+ * wp-cache.php: Put preload taxonomy code within posts limit checks
336
+ so it doesn't do extra preloads!
337
+
338
+ 2012-01-04 16:02 donncha
339
+
340
+ * wp-cache.php: Check if number of posts is less than post limit so
341
+ preload finishes without trying to do an extra 100 posts
342
+
343
+ 2012-01-04 16:01 donncha
344
+
345
+ * wp-cache.php: Update preload counter before taxonomy preload so
346
+ the admin page shows the preload action
347
+
348
+ 2012-01-04 16:00 donncha
349
+
350
+ * wp-cache-phase2.php, wp-cache.php: Added lots more debugging -
351
+ prune_super_cache and preload functions
352
+
353
+ 2012-01-04 11:56 donncha
354
+
355
+ * plugins/wptouch.php: Make sure ua list is an array as it's stored
356
+ as a string
357
+
358
+ 2012-01-04 10:26 donncha
359
+
360
+ * wp-cache-phase2.php: Fixed minor typo in debug log message
361
+
362
+ 2012-01-04 10:20 donncha
363
+
364
+ * wp-cache-phase2.php: Only write meta cache file if not using only
365
+ supercache files.
366
+
367
+ 2012-01-04 10:16 donncha
368
+
369
+ * wp-cache-phase2.php: Check if $wp_query is defined before
370
+ checking for is_feed, is_search etc.
371
+
372
+ 2012-01-04 09:57 donncha
373
+
374
+ * wp-cache-phase2.php: Correctly check if GET is empty for anon
375
+ caching
376
+
377
+ 2012-01-04 09:08 donncha
378
+
379
+ * plugins/searchengine.php: Update plugin admin page to match other
380
+ plugins
381
+
382
+ 2012-01-04 00:03 donncha
383
+
384
+ * wp-cache-phase2.php: Make sure we don't write anon files for GET
385
+ requests, see
386
+ http://wordpress.org/support/topic/plugin-wp-super-cache-my-page-2-is-randomly-redirecting-to-other-posts?replies=5
387
+
388
+ 2012-01-03 23:58 donncha
389
+
390
+ * wp-cache-phase2.php: Write meta file if user is not using
391
+ supercacheonly or is not logged in, not AND.
392
+
393
+ 2012-01-03 18:14 donncha
394
+
395
+ * wp-cache-phase2.php: Make sure a post is published before
396
+ removing cache files. Props _ck_, see
397
+ http://wordpress.org/support/topic/plugin-wp-super-cache-found-possible-bug-with-starting-new-post
398
+
399
+ 2012-01-03 18:08 donncha
400
+
401
+ * plugins/wptouch.php, wp-cache-phase1.php, wp-cache.php: Added
402
+ WPTouch plugin to modify browser list and prefix list and added
403
+ support for exclude list in that plugin.
404
+
405
+ 2012-01-03 13:12 donncha
406
+
407
+ * wp-cache.php: Use display text for scheduled interval.
408
+
409
+ 2012-01-03 11:02 donncha
410
+
411
+ * ossdl-cdn.php: Make sure $arr_of_excludes is an array always to
412
+ avoid stristr warning
413
+
414
+ 2011-12-22 13:16 donncha
415
+
416
+ * wp-cache.php: Don't check the blog_id if the site isn't a
417
+ multisite network.
418
+
419
+ 2011-12-22 12:39 donncha
420
+
421
+ * wp-cache.php: Only show the "Delete Cache" link in the admin bar
422
+ when caching off for known users
423
+
424
+ 2011-12-15 08:57 donncha
425
+
426
+ * wp-cache.php: Make sure pages returned by cache tester are not
427
+ error objects!
428
+
429
+ 2011-12-11 09:05 donncha
430
+
431
+ * wp-cache.php: Delete index files rather than directory when
432
+ deleting post supercache files.
433
+
434
+ 2011-12-11 09:04 donncha
435
+
436
+ * wp-cache-phase2.php: Added another debug message
437
+
438
+ 2011-12-10 22:31 donncha
439
+
440
+ * wp-cache-phase2.php: Add the cache age limit to the debug message
441
+ when a cache file is deleted during GC
442
+
443
+ 2011-12-10 22:30 donncha
444
+
445
+ * wp-cache-phase2.php: Filter the tags that are checked at the end
446
+ of a web document with a 'wp_cache_eof_tags' filter. See
447
+ http://wordpress.org/support/topic/plugin-wp-super-cache-feature-request-test-for-opening-xml-tag-in-wp_cache_get_ob?replies=4
448
+
449
+ 2011-12-10 10:50 donncha
450
+
451
+ * wp-cache.php: Fix schedule frequency form,
452
+ http://wordpress.org/support/topic/plugin-wp-super-cache-garbage-collection-scheduler-interval-not-saved-always-hourly?replies=2
453
+
454
+ 2011-12-10 10:02 donncha
455
+
456
+ * wp-cache.php: Clear out wp-cache legacy files from root cache dir
457
+ as well as blogs directories
458
+
459
+ 2011-12-10 10:01 donncha
460
+
461
+ * readme.txt: Attempt to fix formatting of FAQ
462
+
463
+ 2011-12-06 17:04 donncha
464
+
465
+ * wp-cache-phase1.php, wp-cache-phase2.php: Check if the rejected
466
+ uri or ua is an array.
467
+
468
+ 2011-12-06 15:13 donncha
469
+
470
+ * wp-super-cache.pot: Updated the translation file
471
+
472
+ 2011-12-06 12:44 donncha
473
+
474
+ * wp-cache.php: Explain that cancelling a preload may take some
475
+ time.
476
+
477
+ 2011-12-06 12:22 donncha
478
+
479
+ * wp-cache.php: Move preload notifications around and added
480
+ notification for taxonomy preload
481
+
482
+ 2011-12-05 20:42 donncha
483
+
484
+ * readme.txt: Bump the WP version number.
485
+
486
+ 2011-12-05 18:01 donncha
487
+
488
+ * readme.txt, wp-cache.php: Bump version to 1.0
489
+
490
+ 2011-12-05 17:58 donncha
491
+
492
+ * Changelog.txt: Updated changelog
493
+
494
  2011-12-05 17:56 donncha
495
 
496
  * wp-super-cache.pot: Updated the translation file
ossdl-cdn.php CHANGED
@@ -14,6 +14,8 @@ if ( get_option( 'ossdl_off_exclude' ) == false )
14
  add_option('ossdl_off_exclude', '.php');
15
  $ossdl_off_exclude = trim(get_option('ossdl_off_exclude'));
16
  $arr_of_excludes = array_map('trim', explode(',', $ossdl_off_exclude));
 
 
17
 
18
  if ( get_option( 'ossdl_cname' ) == false )
19
  add_option('ossdl_cname', '');
@@ -65,7 +67,7 @@ function scossdl_off_rewriter($match) {
65
  if ( false == in_array( $ossdl_off_cdn_url, $arr_of_cnames ) )
66
  $arr_of_cnames[] = $ossdl_off_cdn_url;
67
 
68
- if (scossdl_off_exclude_match($match[0], $arr_of_excludes)) {
69
  return $match[0];
70
  } else {
71
  $include_dirs = scossdl_off_additional_directories();
14
  add_option('ossdl_off_exclude', '.php');
15
  $ossdl_off_exclude = trim(get_option('ossdl_off_exclude'));
16
  $arr_of_excludes = array_map('trim', explode(',', $ossdl_off_exclude));
17
+ if ( !is_array( $arr_of_excludes ) )
18
+ $arr_of_excludes = array();
19
 
20
  if ( get_option( 'ossdl_cname' ) == false )
21
  add_option('ossdl_cname', '');
67
  if ( false == in_array( $ossdl_off_cdn_url, $arr_of_cnames ) )
68
  $arr_of_cnames[] = $ossdl_off_cdn_url;
69
 
70
+ if ( scossdl_off_exclude_match( $match[0], $arr_of_excludes ) ) {
71
  return $match[0];
72
  } else {
73
  $include_dirs = scossdl_off_additional_directories();
plugins/domain-mapping.php CHANGED
@@ -30,9 +30,24 @@ function domain_mapping_gc_cache( $function, $directory ) {
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
  }
30
  return $directory;
31
  }
32
 
33
+ function domain_mapping_supercachedir( $dir ) {
34
+ global $cache_path;
35
+ if ( !function_exists( 'domain_mapping_warning' ) )
36
+ return $dir;
37
+
38
+ $siteurl = domain_mapping_siteurl( false );
39
+ if ( !$siteurl )
40
+ return $dir;
41
+
42
+ $protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
43
+ $siteurl = str_replace( $protocol, '', $siteurl );
44
+ return $cache_path . 'supercache/' . $siteurl;
45
+ }
46
+
47
  function domain_mapping_actions() {
48
  global $cache_domain_mapping;
49
  if( $cache_domain_mapping == '1' ) {
50
+ add_filter( 'wp_super_cache_supercachedir', 'domain_mapping_supercachedir' );
51
  add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
52
  }
53
  }
plugins/multisite.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( defined( 'WP_ALLOW_MULTISITE' ) )
4
+ add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
5
+
6
+ function wp_super_cache_multisite_init() {
7
+ add_filter( 'wpmu_blogs_columns', 'wp_super_cache_blogs_col' );
8
+ add_action( 'manage_sites_custom_column', 'wp_super_cache_blogs_field', 10, 2 );
9
+ add_action( 'init', 'wp_super_cache_override_on_flag' );
10
+ }
11
+
12
+ function wp_super_cache_blogs_col( $col ) {
13
+ $col[ 'wp_super_cache' ] = __( 'Cached', 'wp-super-cache' );
14
+ return $col;
15
+ }
16
+
17
+ function wp_super_cache_blogs_field( $name, $blog_id ) {
18
+ if ( $name != 'wp_super_cache' )
19
+ return false;
20
+
21
+ if ( isset( $_GET[ 'id' ] ) && $blog_id == $_GET[ 'id' ] ) {
22
+ $valid_nonce = isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_GET[ '_wpnonce' ], 'wp-cache' . $_GET[ 'id' ] ) : false;
23
+ if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'disable_cache' ) {
24
+ add_blog_option( $_GET[ 'id' ], 'wp_super_cache_disabled', 1 );
25
+ } elseif ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'enable_cache' ) {
26
+ delete_blog_option( $_GET[ 'id' ], 'wp_super_cache_disabled' );
27
+ }
28
+ }
29
+
30
+ if ( get_blog_option( $blog_id, 'wp_super_cache_disabled' ) == 1 ) {
31
+ echo "<a href='" . wp_nonce_url( add_query_arg( array( 'action' => 'enable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . "'>" . __( 'Enable', 'wp-super-cache' ) . "</a>";
32
+ } else {
33
+ echo "<a href='" . wp_nonce_url( add_query_arg( array( 'action' => 'disable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . "'>" . __( 'Disable', 'wp-super-cache' ) . "</a>";
34
+ }
35
+ }
36
+
37
+ function wp_super_cache_multisite_notice() {
38
+ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' )
39
+ echo '<div class="error"><p><strong>' . __( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '</strong></p></div>';
40
+ }
41
+
42
+ function wp_super_cache_override_on_flag() {
43
+ global $cache_enabled, $super_cache_enabled;
44
+ if ( $cache_enabled != true )
45
+ return false;
46
+
47
+ if ( get_option( 'wp_super_cache_disabled' ) ) {
48
+ $cache_enabled = false;
49
+ $super_cache_enabled = false;
50
+ define( 'DONOTCACHEPAGE', 1 );
51
+ define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
52
+ if ( is_admin() )
53
+ add_action( 'admin_notices', 'wp_super_cache_multisite_notice' );
54
+ }
55
+ }
56
+
57
+ ?>
plugins/searchengine.php CHANGED
@@ -61,21 +61,28 @@ 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 '<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' );
68
- } else {
69
- $status = __( 'enabled', 'wp-super-cache' );
70
- }
71
- echo '<strong>' . sprintf( __( '<a href="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a> plugin is %s.', 'wp-super-cache' ), $status );
72
- echo '</strong> ' . __( '(requires <a href="http://ocaoimh.ie/no-adverts-for-friends/">friendsadverts.php</a> too) ', 'wp-super-cache' );
73
- if( $cache_no_adverts_for_friends == 'no' ) {
74
- echo '<input type="submit" name="cache_no_adverts_for_friends" value="' . __( 'Enable', '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' );
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
+ $id = 'no_adverts_for_friends-section';
65
+ ?>
66
+ <fieldset id="<?php echo $id; ?>" class="options">
67
+ <h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
68
+ <form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
69
+ <label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php if( $cache_no_adverts_for_friends == 'yes' ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
70
+ <label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php if( $cache_no_adverts_for_friends == 'no' ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
71
+ <p><?php _e( '', 'wp-super-cache' ); ?></p><?php
72
+ echo '<p>' . __( 'Provides support for <a href="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache' ) . '</p>';
73
+ if ($changed) {
74
+ if ( 'yes' == $cache_no_adverts_for_friends )
75
+ $status = __( "enabled" );
76
+ else
77
+ $status = __( "disabled" );
78
+ echo "<p><strong>" . sprintf( __( "No Adverts for Friends support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
79
+ }
80
+ echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
81
  wp_nonce_field('wp-cache');
82
+ ?>
83
+ </form>
84
+ </fieldset>
85
+ <?php
 
 
 
 
 
 
 
 
 
86
 
87
  }
88
  add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
plugins/wptouch.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wp_super_cache_wptouch_admin() {
4
+ global $cache_wptouch, $wp_cache_config_file, $valid_nonce;
5
+
6
+ $cache_wptouch = $cache_wptouch == '' ? '0' : $cache_wptouch;
7
+
8
+ if(isset($_POST['cache_wptouch']) && $valid_nonce) {
9
+ if ( $cache_wptouch == (int)$_POST['cache_wptouch'] ) {
10
+ $changed = false;
11
+ } else {
12
+ $changed = true;
13
+ }
14
+ $cache_wptouch = (int)$_POST['cache_wptouch'];
15
+ wp_cache_replace_line('^ *\$cache_wptouch', "\$cache_wptouch = '$cache_wptouch';", $wp_cache_config_file);
16
+ }
17
+ $id = 'wptouch-section';
18
+ ?>
19
+ <fieldset id="<?php echo $id; ?>" class="options">
20
+ <h4><?php _e( 'WPTouch', 'wp-super-cache' ); ?></h4>
21
+ <form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
22
+ <label><input type="radio" name="cache_wptouch" value="1" <?php if( $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
23
+ <label><input type="radio" name="cache_wptouch" value="0" <?php if( !$cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
24
+ <p><?php _e( '', 'wp-super-cache' ); ?></p><?php
25
+ echo '<p>' . __( 'Provides support for <a href="http://wordpress.org/extend/plugins/wptouch/">WPTouch</a> mobile theme and plugin.', 'wp-super-cache' ) . '</p>';
26
+ if ($changed) {
27
+ if ( $cache_wptouch )
28
+ $status = __( "enabled" );
29
+ else
30
+ $status = __( "disabled" );
31
+ echo "<p><strong>" . sprintf( __( "WPTouch support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
32
+ }
33
+ echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
34
+ wp_nonce_field('wp-cache');
35
+ ?>
36
+ </form>
37
+ </fieldset>
38
+ <?php
39
+ }
40
+ add_cacheaction( 'cache_admin_page', 'wp_super_cache_wptouch_admin' );
41
+
42
+ function wp_super_cache_wptouch_notice() {
43
+ global $cache_enabled, $cache_wptouch;
44
+ if( $cache_enabled )
45
+ echo '<div class="error"><p><strong>' . __('WPTouch plugin detected! Please go to the Supercache plugins page and enable the WPTouch helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
46
+ }
47
+ function wp_super_cache_wptouch_exists() {
48
+ global $cache_wptouch;
49
+ if ( $cache_wptouch == 1 )
50
+ return false;
51
+
52
+ if ( is_admin() && function_exists( 'wptouch_get_plugin_dir_name' ) )
53
+ add_action( 'admin_notices', 'wp_super_cache_wptouch_notice' );
54
+ }
55
+
56
+ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
57
+ add_cacheaction( 'add_cacheaction', 'wp_super_cache_wptouch_exists' );
58
+ }
59
+
60
+ // disable mobile checking if
61
+ function wp_super_cache_maybe_disable_wptouch( $t ) {
62
+ global $cache_wptouch, $wptouch_exclude_ua;
63
+ if ( $cache_wptouch != 1 )
64
+ return false;
65
+
66
+ if ( isset( $_COOKIE[ 'wptouch_switch_toggle' ] ) && $_COOKIE['wptouch_switch_toggle'] == 'normal' )
67
+ return true;
68
+
69
+ $ua = explode( ",", $wptouch_exclude_ua );
70
+ foreach( $ua as $agent ) {
71
+ if ( preg_match( "#$agent#i", $_SERVER[ 'HTTP_HOST' ] ) )
72
+ return true; // disable mobile ua check if matches the exclude list in wptouch
73
+ }
74
+
75
+ return false;
76
+
77
+ }
78
+
79
+ add_cacheaction( 'disable_mobile_check', 'wp_super_cache_maybe_disable_wptouch' );
80
+
81
+ function wp_super_cache_wptouch_browsers( $browsers ) {
82
+ global $cache_wptouch, $wptouch_exclude_ua, $wp_cache_config_file;
83
+
84
+ if ( false == function_exists( 'bnc_wptouch_get_exclude_user_agents' ) || false == function_exists( 'bnc_wptouch_get_user_agents' ) )
85
+ return $browsers;
86
+
87
+ $browsers = implode( ',', bnc_wptouch_get_exclude_user_agents() ); // hack, support exclude agents too
88
+ if ( $browsers != $wptouch_exclude_ua ) {
89
+ wp_cache_replace_line('^ *\$wptouch_exclude_ua', "\$wptouch_exclude_ua = '$browsers';", $wp_cache_config_file);
90
+ $wptouch_exclude_ua = $browsers;
91
+ }
92
+
93
+ return bnc_wptouch_get_user_agents();
94
+ }
95
+
96
+ function wp_super_cache_wptouch_prefixes( $prefixes ) {
97
+ return array(); // wptouch doesn't support UA prefixes
98
+ }
99
+
100
+ function wp_super_cache_wptouch_cookie_check( $cache_key ) {
101
+ if ( false == isset( $_COOKIE[ 'wptouch_switch_toggle' ] ) )
102
+ return $cache_key;
103
+ if ( $_COOKIE[ 'wptouch_switch_toggle' ] == 'normal' || $_COOKIE[ 'wptouch_switch_toggle' ] == 'mobile' )
104
+ return $_COOKIE[ 'wptouch_switch_toggle' ];
105
+
106
+ return $cache_key;
107
+ }
108
+
109
+ if ( $cache_wptouch == 1 ) {
110
+ add_cacheaction( 'wp_super_cache_mobile_browsers', 'wp_super_cache_wptouch_browsers' );
111
+ add_cacheaction( 'wp_super_cache_mobile_prefixes', 'wp_super_cache_wptouch_prefixes' );
112
+ add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_wptouch_cookie_check' );
113
+ }
114
+ ?>
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
- Tested up to: 3.3.1
5
- Stable tag: 1.0
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -52,13 +52,56 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
52
 
53
  Interested in translating WP Super Cache to your language? Grab the [development version](http://downloads.wordpress.org/plugin/wp-super-cache.zip) where you will find an up to date wp-super-cache.pot. Send any translation files to donncha @ ocaoimh.ie and thank you!
54
 
 
 
55
  == Upgrade Notice ==
56
 
57
- = 0.9.9.9 =
58
- Serve repeated static files from the same CDN hostname, translations, lots of bug fixes
59
 
60
  == Changelog ==
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  = 0.9.9.9 =
63
  * Fixed typo, is_front_page.
64
  * Serve repeated static files from the same CDN hostname.
@@ -442,10 +485,9 @@ If things don't work when you installed the plugin here are a few things to chec
442
  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.
443
  14. Make sure cache/wp_cache_mutex.lock is writable by the web server if using coarse file locking.
444
  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.
445
- 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.
446
 
447
  `127.0.0.1 myhostname.com`
448
- A line like "127.0.0.1 localhost localhost.localdomain" is ok.
449
  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.
450
  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.
451
  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.
@@ -455,7 +497,6 @@ A line like "127.0.0.1 localhost localhost.localdomain" is ok.
455
  21. If you see garbage in your browser after enabling compression in the plugin, compression may already be enabled in your web server. In Apache you must disable mod_deflate, or in PHP zlib compression may be enabled. You can disable that in three ways. If you have root access, edit your php.ini and find the zlib.output_compression setting and make sure it's "Off" or add this line to your .htaccess:
456
 
457
  `php_flag zlib.output_compression off`
458
-
459
  If that doesn't work, add this line to your wp-config.php:
460
 
461
  `ini_set('zlib.output_compression', 0);`
@@ -466,6 +507,7 @@ If that doesn't work, add this line to your wp-config.php:
466
  26. If certain characters do not appear correctly on your website your server may not be configured correctly. You need to tell visitors what character set is used. Go to Settings->Reading and copy the 'Encoding for pages and feeds' value. Edit the .htaccess file with all your Supercache and WordPress rewrite rules and add this at the top, replacing CHARSET with the copied value. (for example, 'UTF-8')
467
 
468
  `AddDefaultCharset CHARSET`
 
469
 
470
 
471
  == CDN ==
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 3.4
5
+ Stable tag: 1.1
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
52
 
53
  Interested in translating WP Super Cache to your language? Grab the [development version](http://downloads.wordpress.org/plugin/wp-super-cache.zip) where you will find an up to date wp-super-cache.pot. Send any translation files to donncha @ ocaoimh.ie and thank you!
54
 
55
+ The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
56
+
57
  == Upgrade Notice ==
58
 
59
+ = 1.1 =
60
+ Lots of bugfixes
61
 
62
  == Changelog ==
63
 
64
+ = 1.1 =
65
+ * Use $_SERVER[ 'SERVER_NAME' ] to create cache directories.
66
+ * Only create blogs cached directories if valid requests and blogs exist.
67
+ * Only clear current blog's cache files if navigation menu is modified
68
+ * Added clean_post_cache action to clear cache on post actions
69
+ * Removed garbage collection details on Contents tab
70
+ * Added wp_cache_check_mobile cacheaction filter to shortcircuit mobile device check.
71
+ * Don't delete cache files for draft posts
72
+ * Added action on wp_trash_post to clear the cache when trashed posts are deleted
73
+ * Show a warning when 304 browser caching is disabled (because mod_rewrite caching is on)
74
+ * New check for safe mode if using less that PHP 5.3.0
75
+ * Added wp_supercache_remove_cookies filter to disable anonymous browsing mode.
76
+ * Fixed garbage collection schedule dropdown
77
+ * Fixed preload problem clearing site's cache on "page on front" sites.
78
+ * Fix for PHP variable not defined warnings
79
+ * Fixed problem refreshing cache when comments made as siteurl() sometimes didn't work
80
+ * Preloading of taxonomies is now optional
81
+ * Domain mapping fixes.
82
+ * Better support for https sites. Remove https:// to get cache paths.
83
+ * Added AddDefaultCharset .htaccess rule back in and added an option to remove it if required.
84
+ * Added multisite plugin that adds a "Cached" column to Network->Sites to disable caching on a per site basis.
85
+ * Added WPTouch plugin to modify browser and prefix list in mobile detection code. Added support for that plugin's exclude list.
86
+ * Fixed cache tester
87
+ * Filter the tags that are used to detect end-of-page using the wp_cache_eof_tags filter.
88
+ * Removed debug level from logging as it wasn't helpful.
89
+ * Removed mention of wp-minify.
90
+
91
+ = 1.0 =
92
+ * Removed AddDefaultCharset .htaccess rule
93
+ * Fixed problem with blogs in a folder and don't have a trailing slash
94
+ * New scheduling of garbage collection
95
+ * Added a "Delete cache" link to admin bar to delete cache of current page.
96
+ * Updated documentation
97
+ * Sorry Digg, Stephen Fry power now!
98
+ * Updated translations
99
+ * Preload taxonomies and all post types except revisionsand nav menu items
100
+ * Fixed previews by logged in users.
101
+ * Added option to make logged in users anonymous
102
+ * Use WP 3.0 variables to detect multisite installs
103
+ * Hash filenames so files are served from the same CDNs
104
+
105
  = 0.9.9.9 =
106
  * Fixed typo, is_front_page.
107
  * Serve repeated static files from the same CDN hostname.
485
  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.
486
  14. Make sure cache/wp_cache_mutex.lock is writable by the web server if using coarse file locking.
487
  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.
488
+ 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. A line like "127.0.0.1 localhost localhost.localdomain" is ok.
489
 
490
  `127.0.0.1 myhostname.com`
 
491
  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.
492
  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.
493
  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.
497
  21. If you see garbage in your browser after enabling compression in the plugin, compression may already be enabled in your web server. In Apache you must disable mod_deflate, or in PHP zlib compression may be enabled. You can disable that in three ways. If you have root access, edit your php.ini and find the zlib.output_compression setting and make sure it's "Off" or add this line to your .htaccess:
498
 
499
  `php_flag zlib.output_compression off`
 
500
  If that doesn't work, add this line to your wp-config.php:
501
 
502
  `ini_set('zlib.output_compression', 0);`
507
  26. If certain characters do not appear correctly on your website your server may not be configured correctly. You need to tell visitors what character set is used. Go to Settings->Reading and copy the 'Encoding for pages and feeds' value. Edit the .htaccess file with all your Supercache and WordPress rewrite rules and add this at the top, replacing CHARSET with the copied value. (for example, 'UTF-8')
508
 
509
  `AddDefaultCharset CHARSET`
510
+ 27. Use [Cron View](http://wordpress.org/extend/plugins/cron-view/) to help diagnose garbage collection and preload problems. Use the plugin to make sure jobs are scheduled and for what time. Look for the wp_cache_gc and wp_cache_full_preload_hook jobs.
511
 
512
 
513
  == CDN ==
wp-cache-base.php CHANGED
@@ -12,10 +12,10 @@ if (!class_exists('CacheMeta')) {
12
 
13
  // We want to be able to identify each blog in a WordPress MU install
14
  $blogcacheid = '';
15
- if( defined( 'WP_ALLOW_MULTISITE' ) ) {
16
  $blogcacheid = 'blog'; // main blog
17
  if( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
18
- $blogcacheid = $_SERVER['HTTP_HOST'];
19
  } else {
20
  $request_uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI'] ) );
21
  if( strpos( $request_uri, '/', 1 ) ) {
12
 
13
  // We want to be able to identify each blog in a WordPress MU install
14
  $blogcacheid = '';
15
+ if ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) {
16
  $blogcacheid = 'blog'; // main blog
17
  if( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
18
+ $blogcacheid = $_SERVER['SERVER_NAME'];
19
  } else {
20
  $request_uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI'] ) );
21
  if( strpos( $request_uri, '/', 1 ) ) {
wp-cache-phase1.php CHANGED
@@ -10,6 +10,9 @@ if( !include( WP_CONTENT_DIR . '/wp-cache-config.php' ) )
10
  if( !defined( 'WPCACHEHOME' ) )
11
  define('WPCACHEHOME', dirname(__FILE__).'/');
12
 
 
 
 
13
  include( WPCACHEHOME . 'wp-cache-base.php');
14
 
15
  if( $blogcacheid != '' ) {
@@ -58,7 +61,7 @@ function gzip_accepted(){
58
  if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) // don't compress WP-Cache data files when PHP is already doing it
59
  return false;
60
 
61
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) return false;
62
  return 'gzip';
63
  }
64
 
@@ -80,14 +83,16 @@ if ( $wp_cache_object_cache ) {
80
  return;
81
  }
82
 
83
- if( false == @is_dir( $blog_cache_dir ) ) {
84
- @mkdir( $cache_path . "blogs" );
85
- @mkdir( $blog_cache_dir );
86
- }
87
-
88
- if( false == @is_dir( $blog_cache_dir . 'meta' ) )
89
- @mkdir( $blog_cache_dir . 'meta' );
90
 
 
 
 
91
 
92
  $wp_start_time = microtime();
93
 
@@ -95,7 +100,7 @@ function get_wp_cache_key( $url = false ) {
95
  global $wp_cache_request_uri, $wp_cache_gzip_encoding;
96
  if ( !$url )
97
  $url = $wp_cache_request_uri;
98
- return do_cacheaction( 'wp_cache_key', $_SERVER['HTTP_HOST'] . intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() );
99
  }
100
 
101
  function wp_super_cache_init() {
@@ -114,7 +119,7 @@ function wp_super_cache_init() {
114
 
115
  function wp_cache_serve_cache_file() {
116
  global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
117
- global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path;
118
 
119
  extract( wp_super_cache_init() );
120
 
@@ -123,6 +128,11 @@ function wp_cache_serve_cache_file() {
123
  return false;
124
  }
125
 
 
 
 
 
 
126
  if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
127
  if ( !empty( $_GET ) ) {
128
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Not serving request from object cache", 1 );
@@ -258,7 +268,7 @@ function wp_cache_serve_cache_file() {
258
  die();
259
  }
260
  } else {
261
- if ( $meta[ 'dynamic' ] ) {
262
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file", 5 );
263
  if ( $ungzip ) {
264
  $cache = file_get_contents( $cache_file );
@@ -384,10 +394,23 @@ function wp_cache_check_mobile( $cache_key ) {
384
  if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
385
  return $cache_key;
386
 
 
 
 
 
 
 
 
 
 
 
387
  if ( !isset( $_SERVER[ "HTTP_USER_AGENT" ] ) ) {
388
  return $cache_key;
389
  }
390
 
 
 
 
391
  $browsers = explode( ',', $wp_cache_mobile_browsers );
392
  $user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
393
  foreach ($browsers as $browser) {
@@ -410,7 +433,7 @@ function wp_cache_check_mobile( $cache_key ) {
410
  }
411
  }
412
  }
413
- $accept = strtolower($_SERVER['HTTP_ACCEPT']);
414
  if (strpos($accept, 'wap') !== false) {
415
  return $cache_key . '-' . 'wap';
416
  }
@@ -418,11 +441,12 @@ function wp_cache_check_mobile( $cache_key ) {
418
  if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) {
419
  return $cache_key . '-' . 'operamini';
420
  }
 
421
  return $cache_key;
422
  }
423
 
424
  function wp_cache_debug( $message, $level = 1 ) {
425
- global $wp_cache_debug_level, $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
426
 
427
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug == false )
428
  return false;
@@ -430,11 +454,6 @@ function wp_cache_debug( $message, $level = 1 ) {
430
  if ( isset( $wp_cache_debug_log ) == false )
431
  return false;
432
 
433
- if ( isset( $wp_cache_debug_level ) == false )
434
- $wp_cache_debug_level = 1;
435
- if ( $wp_cache_debug_level < $level )
436
- return false;
437
-
438
  if ( isset( $wp_cache_debug_ip ) && $wp_cache_debug_ip != '' && $wp_cache_debug_ip != $_SERVER[ 'REMOTE_ADDR' ] )
439
  return false;
440
 
@@ -449,6 +468,8 @@ function wp_cache_user_agent_is_rejected() {
449
  if (!function_exists('apache_request_headers')) return false;
450
  $headers = apache_request_headers();
451
  if (!isset($headers["User-Agent"])) return false;
 
 
452
  foreach ($cache_rejected_user_agent as $expr) {
453
  if (strlen($expr) > 0 && stristr($headers["User-Agent"], $expr))
454
  return true;
@@ -456,9 +477,14 @@ function wp_cache_user_agent_is_rejected() {
456
  return false;
457
  }
458
 
459
- function get_supercache_dir() {
460
  global $cache_path;
461
- return $cache_path . 'supercache/' . trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) );
 
 
 
 
 
462
  }
463
  function get_current_url_supercache_dir( $post_id = 0 ) {
464
  global $cached_direct_pages, $cache_path, $wp_cache_request_uri;
@@ -468,14 +494,44 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
468
  return $saved_supercache_dir[ $post_id ];
469
  }
470
 
 
471
  if ( $post_id != 0 ) {
472
- $uri = str_replace( site_url(), '', get_permalink( $post_id ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  } else {
474
  $uri = strtolower( $wp_cache_request_uri );
475
  }
476
  $uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $uri ) ) ) );
477
  $uri = str_replace( '\\', '', $uri );
478
- $dir = preg_replace( '/:.*$/', '', $_SERVER["HTTP_HOST"] ) . $uri; // To avoid XSS attacks
479
  if ( function_exists( "apply_filters" ) ) {
480
  $dir = apply_filters( 'supercache_dir', $dir );
481
  } else {
@@ -487,7 +543,8 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
487
  }
488
  $dir = str_replace( '//', '/', $dir );
489
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "supercache dir: $dir", 5 );
490
- $saved_supercache_dir[ $post_id ] = $dir;
 
491
  return $dir;
492
  }
493
 
@@ -523,7 +580,7 @@ function get_all_supercache_filenames( $dir = '' ) {
523
 
524
  function supercache_filename() {
525
  //Add support for https and http caching
526
- $is_https = ('on' == strtolower($_SERVER['HTTPS']) || 'https' == strtolower($_SERVER['HTTP_X_FORWARDED_PROTO'])); //Also supports https requests coming from an nginx reverse proxy
527
  $extra_str = $is_https ? '-https' : '';
528
 
529
  if ( function_exists( "apply_filters" ) ) {
@@ -557,7 +614,7 @@ function get_oc_key( $url = false ) {
557
  global $wp_cache_gzip_encoding;
558
 
559
  if ( $url ) {
560
- $key = intval( $_SERVER[ 'SERVER_PORT' ] ) . strtolower( preg_replace( '/:.*$/', '', $_SERVER[ "HTTP_HOST" ] ) ) . $url;
561
  } else {
562
  $key = get_current_url_supercache_dir();
563
  }
@@ -568,6 +625,9 @@ function wp_supercache_cache_for_admins() {
568
  if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() )
569
  return $cookies;
570
 
 
 
 
571
  $cookie_keys = array( 'wordpress_logged_in', 'comment_author_' );
572
  reset( $_COOKIE );
573
  foreach( $_COOKIE as $cookie => $val ) {
10
  if( !defined( 'WPCACHEHOME' ) )
11
  define('WPCACHEHOME', dirname(__FILE__).'/');
12
 
13
+ if ( false == isset( $_SERVER[ 'SERVER_NAME' ] ) && true == isset( $_SERVER[ 'HTTP_HOST' ] ) )
14
+ $_SERVER[ 'SERVER_NAME' ] = $_SERVER[ 'HTTP_HOST' ];
15
+
16
  include( WPCACHEHOME . 'wp-cache-base.php');
17
 
18
  if( $blogcacheid != '' ) {
61
  if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) // don't compress WP-Cache data files when PHP is already doing it
62
  return false;
63
 
64
+ if ( isset( $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] ) && strpos( $_SERVER[ 'HTTP_ACCEPT_ENCODING' ], 'gzip' ) === false ) return false;
65
  return 'gzip';
66
  }
67
 
83
  return;
84
  }
85
 
86
+ function setup_blog_cache_dir() {
87
+ global $blog_cache_dir, $cache_path;
88
+ if( false == @is_dir( $blog_cache_dir ) ) {
89
+ @mkdir( $cache_path . "blogs" );
90
+ @mkdir( $blog_cache_dir );
91
+ }
 
92
 
93
+ if( false == @is_dir( $blog_cache_dir . 'meta' ) )
94
+ @mkdir( $blog_cache_dir . 'meta' );
95
+ }
96
 
97
  $wp_start_time = microtime();
98
 
100
  global $wp_cache_request_uri, $wp_cache_gzip_encoding;
101
  if ( !$url )
102
  $url = $wp_cache_request_uri;
103
+ return do_cacheaction( 'wp_cache_key', $_SERVER['SERVER_NAME'] . intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() );
104
  }
105
 
106
  function wp_super_cache_init() {
119
 
120
  function wp_cache_serve_cache_file() {
121
  global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
122
+ global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path, $wp_cache_no_cache_for_get;
123
 
124
  extract( wp_super_cache_init() );
125
 
128
  return false;
129
  }
130
 
131
+ if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
132
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page.", 1 );
133
+ return false;
134
+ }
135
+
136
  if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
137
  if ( !empty( $_GET ) ) {
138
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Not serving request from object cache", 1 );
268
  die();
269
  }
270
  } else {
271
+ if ( isset( $meta[ 'dynamic' ] ) ) {
272
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file", 5 );
273
  if ( $ungzip ) {
274
  $cache = file_get_contents( $cache_file );
394
  if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
395
  return $cache_key;
396
 
397
+ // allow plugins to short circuit mobile check. Cookie, extra UA checks?
398
+ switch( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) {
399
+ case "normal":
400
+ return $cache_key;
401
+ break;
402
+ case "mobile":
403
+ return $cache_key . "_mobile";
404
+ break;
405
+ }
406
+
407
  if ( !isset( $_SERVER[ "HTTP_USER_AGENT" ] ) ) {
408
  return $cache_key;
409
  }
410
 
411
+ if ( do_cacheaction( 'disable_mobile_check', false ) )
412
+ return $cache_key;
413
+
414
  $browsers = explode( ',', $wp_cache_mobile_browsers );
415
  $user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
416
  foreach ($browsers as $browser) {
433
  }
434
  }
435
  }
436
+ $accept = isset( $_SERVER[ 'HTTP_ACCEPT' ] ) ? strtolower( $_SERVER[ 'HTTP_ACCEPT' ] ) : '';
437
  if (strpos($accept, 'wap') !== false) {
438
  return $cache_key . '-' . 'wap';
439
  }
441
  if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) {
442
  return $cache_key . '-' . 'operamini';
443
  }
444
+
445
  return $cache_key;
446
  }
447
 
448
  function wp_cache_debug( $message, $level = 1 ) {
449
+ global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
450
 
451
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug == false )
452
  return false;
454
  if ( isset( $wp_cache_debug_log ) == false )
455
  return false;
456
 
 
 
 
 
 
457
  if ( isset( $wp_cache_debug_ip ) && $wp_cache_debug_ip != '' && $wp_cache_debug_ip != $_SERVER[ 'REMOTE_ADDR' ] )
458
  return false;
459
 
468
  if (!function_exists('apache_request_headers')) return false;
469
  $headers = apache_request_headers();
470
  if (!isset($headers["User-Agent"])) return false;
471
+ if ( false == is_array( $cache_rejected_user_agent ) )
472
+ return false;
473
  foreach ($cache_rejected_user_agent as $expr) {
474
  if (strlen($expr) > 0 && stristr($headers["User-Agent"], $expr))
475
  return true;
477
  return false;
478
  }
479
 
480
+ function get_supercache_dir( $blog_id = 0 ) {
481
  global $cache_path;
482
+ if ( $blog_id == 0 ) {
483
+ $home = get_option( 'home' );
484
+ } else {
485
+ $home = get_blog_option( $blog_id, 'home' );
486
+ }
487
+ return apply_filters( 'wp_super_cache_supercachedir', $cache_path . 'supercache/' . trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', str_replace( 'https://', '', $home ) ) ) ) ) );
488
  }
489
  function get_current_url_supercache_dir( $post_id = 0 ) {
490
  global $cached_direct_pages, $cache_path, $wp_cache_request_uri;
494
  return $saved_supercache_dir[ $post_id ];
495
  }
496
 
497
+ $DONOTREMEMBER = 0;
498
  if ( $post_id != 0 ) {
499
+ $site_url = site_url();
500
+ $permalink = get_permalink( $post_id );
501
+ if ( false === strpos( $permalink, $site_url ) ) {
502
+ /*
503
+ * Sometimes site_url doesn't return the siteurl. See http://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made
504
+ */
505
+ $DONOTREMEMBER = 1;
506
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 );
507
+ if ( false === strpos( $permalink, $_SERVER[ 'SERVER_NAME' ] ) ) {
508
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$_SERVER[ 'SERVER_NAME' ]}) not found in permalink ($permalink). ", 1 );
509
+ $p = parse_url( $permalink );
510
+ if ( is_array( $p ) ) {
511
+ $uri = $p[ 'path' ];
512
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: WARNING! Using $uri as permalink. Used parse_url.", 1 );
513
+ } else {
514
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: WARNING! Permalink ($permalink) could not be understood by parse_url. Using front page.", 1 );
515
+ $uri = '';
516
+ }
517
+ } else {
518
+ if ( isset( $_SERVER[ 'HTTPS' ] ) )
519
+ $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
520
+ else
521
+ $protocol = 'http://';
522
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$_SERVER[ 'SERVER_NAME' ]}) and $protocol from permalink ($permalink). Is the url right?", 1 );
523
+ $uri = str_replace( $_SERVER[ 'SERVER_NAME' ], '', $permalink );
524
+ $uri = str_replace( $protocol, '', $uri );
525
+ }
526
+ } else {
527
+ $uri = str_replace( $site_url, '', $permalink );
528
+ }
529
  } else {
530
  $uri = strtolower( $wp_cache_request_uri );
531
  }
532
  $uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $uri ) ) ) );
533
  $uri = str_replace( '\\', '', $uri );
534
+ $dir = preg_replace( '/:.*$/', '', $_SERVER["SERVER_NAME"] ) . $uri; // To avoid XSS attacks
535
  if ( function_exists( "apply_filters" ) ) {
536
  $dir = apply_filters( 'supercache_dir', $dir );
537
  } else {
543
  }
544
  $dir = str_replace( '//', '/', $dir );
545
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "supercache dir: $dir", 5 );
546
+ if ( $DONOTREMEMBER == 0 )
547
+ $saved_supercache_dir[ $post_id ] = $dir;
548
  return $dir;
549
  }
550
 
580
 
581
  function supercache_filename() {
582
  //Add support for https and http caching
583
+ $is_https = ( ( isset( $_SERVER[ 'HTTPS' ] ) && 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) || ( isset( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) && 'https' == strtolower( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) ) ); //Also supports https requests coming from an nginx reverse proxy
584
  $extra_str = $is_https ? '-https' : '';
585
 
586
  if ( function_exists( "apply_filters" ) ) {
614
  global $wp_cache_gzip_encoding;
615
 
616
  if ( $url ) {
617
+ $key = intval( $_SERVER[ 'SERVER_PORT' ] ) . strtolower( preg_replace( '/:.*$/', '', $_SERVER[ "SERVER_NAME" ] ) ) . $url;
618
  } else {
619
  $key = get_current_url_supercache_dir();
620
  }
625
  if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() )
626
  return $cookies;
627
 
628
+ if ( false == apply_filters( 'wp_supercache_remove_cookies', true ) )
629
+ return true;
630
+
631
  $cookie_keys = array( 'wordpress_logged_in', 'comment_author_' );
632
  reset( $_COOKIE );
633
  foreach( $_COOKIE as $cookie => $val ) {
wp-cache-phase2.php CHANGED
@@ -1,13 +1,14 @@
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, $cache_time_interval;
7
  global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval;
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
 
@@ -17,7 +18,11 @@ function wp_cache_phase2() {
17
  wp_cache_mutex_init();
18
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
19
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Setting up WordPress actions', 5 );
 
 
 
20
  // Post ID is received
 
21
  add_action('publish_post', 'wp_cache_post_edit', 0);
22
  add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post
23
  add_action('delete_post', 'wp_cache_post_edit', 0);
@@ -31,13 +36,19 @@ function wp_cache_phase2() {
31
  // No post_id is available
32
  add_action('switch_theme', 'wp_cache_no_postid', 99);
33
  add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
34
- add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache' );
35
  add_action('wp_cache_gc','wp_cache_gc_cron');
 
36
  add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
37
 
38
  do_cacheaction( 'add_cacheaction' );
39
  }
40
 
 
 
 
 
 
41
  if ( is_admin() ) {
42
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching wp-admin requests.', 5 );
43
  return false;
@@ -121,6 +132,8 @@ if ( !function_exists( 'wp_cache_user_agent_is_rejected' ) ) {
121
  if (!function_exists('apache_request_headers')) return false;
122
  $headers = apache_request_headers();
123
  if (!isset($headers["User-Agent"])) return false;
 
 
124
  foreach ($cache_rejected_user_agent as $expr) {
125
  if (strlen($expr) > 0 && stristr($headers["User-Agent"], $expr))
126
  return true;
@@ -153,6 +166,8 @@ function wp_cache_is_rejected($uri) {
153
  if( strstr( $uri, $u ) )
154
  return true; // we don't allow caching of wp-admin for security reasons
155
  }
 
 
156
  foreach ( $cache_rejected_uri as $expr ) {
157
  if( $expr != '' && @preg_match( "~$expr~", $uri ) )
158
  return true;
@@ -175,6 +190,7 @@ function wp_cache_mutex_init() {
175
 
176
  $mutex = false;
177
  if ($use_flock ) {
 
178
  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 );
179
  $mutex = @fopen( $blog_cache_dir . $mutex_filename, 'w' );
180
  } else {
@@ -225,46 +241,73 @@ function wp_cache_writers_exit() {
225
  }
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  function wp_cache_ob_callback( $buffer ) {
229
- global $wp_cache_pages;
230
  $buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
231
  if( defined( 'DONOTCACHEPAGE' ) ) {
232
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
233
  return $buffer;
234
  }
235
 
236
- if ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && is_single() ) {
237
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single post.', 2 );
238
  return $buffer;
239
- } elseif ( isset( $wp_cache_pages[ 'pages' ] ) && $wp_cache_pages[ 'pages' ] == 1 && is_page() ) {
240
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single page.', 2 );
241
  return $buffer;
242
- } elseif ( isset( $wp_cache_pages[ 'archives' ] ) && $wp_cache_pages[ 'archives' ] == 1 && is_archive() ) {
243
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching archive page.', 2 );
244
  return $buffer;
245
- } elseif ( isset( $wp_cache_pages[ 'tag' ] ) && $wp_cache_pages[ 'tag' ] == 1 && is_tag() ) {
246
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching tag page.', 2 );
247
  return $buffer;
248
- } elseif ( isset( $wp_cache_pages[ 'category' ] ) && $wp_cache_pages[ 'category' ] == 1 && is_category() ) {
249
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching category page.', 2 );
250
  return $buffer;
251
- } elseif ( isset( $wp_cache_pages[ 'frontpage' ] ) && $wp_cache_pages[ 'frontpage' ] == 1 && is_front_page() ) {
252
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching front page.', 2 );
253
  return $buffer;
254
- } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && is_home() ) {
255
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching home page.', 2 );
256
  return $buffer;
257
- } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && is_search() ) {
258
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching search page.', 2 );
259
  return $buffer;
260
- } elseif ( isset( $wp_cache_pages[ 'author' ] ) && $wp_cache_pages[ 'author' ] == 1 && is_author() ) {
261
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching author page.', 2 );
262
  return $buffer;
263
- } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && is_feed() ) {
264
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching feed.', 2 );
265
  return $buffer;
266
  }
267
 
 
 
 
268
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Output buffer callback', 4 );
269
 
270
  $buffer = &wp_cache_get_ob( $buffer );
@@ -284,7 +327,6 @@ function wp_cache_append_tag( &$buffer ) {
284
  }
285
 
286
  function wp_cache_get_ob(&$buffer) {
287
- global $wpsc_settings;
288
  global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
289
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
290
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
@@ -314,7 +356,7 @@ function wp_cache_get_ob(&$buffer) {
314
  }
315
  }
316
 
317
- if (!preg_match('/(<\/html>|<\/rss>|<\/feed>|<\/urlset)/i',$buffer) ) {
318
  $new_cache = false;
319
  if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) ) {
320
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
@@ -357,7 +399,7 @@ function wp_cache_get_ob(&$buffer) {
357
 
358
  $supercacheonly = false;
359
  if( $super_cache_enabled ) {
360
- if ( wp_cache_get_cookies_values() == '' ) {
361
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Anonymous user detected. Only creating Supercache file.", 3 );
362
  $supercacheonly = true;
363
  }
@@ -382,7 +424,7 @@ function wp_cache_get_ob(&$buffer) {
382
  }
383
 
384
  if ( !$cache_enabled ) {
385
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( '', 5 );
386
  wp_cache_writers_exit();
387
  return $buffer . "\n<!-- Page not cached by WP Super Cache. Check your settings page. $cache_error -->";
388
  }
@@ -537,6 +579,8 @@ function wp_cache_get_ob(&$buffer) {
537
  @unlink( $tmp_wpcache_filename );
538
  } else {
539
  if ( !rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename ) ) {
 
 
540
  unlink( $blog_cache_dir . $cache_filename );
541
  rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
542
  }
@@ -562,7 +606,7 @@ function wp_cache_get_ob(&$buffer) {
562
  $added_cache = 1;
563
  }
564
  }
565
- if( $php_fd ) {
566
  fclose( $php_fd );
567
  if ( $php_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() . '.php' && !( $wp_cache_is_home ) ) {
568
  wp_cache_writers_exit();
@@ -675,7 +719,11 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
675
  if( !$rename ) {
676
  @rmdir( $entry );
677
  $log++;
678
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: deleted $entry", 2 );
 
 
 
 
679
  }
680
  }
681
  }
@@ -686,9 +734,11 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
686
  if( in_array( $directory, $protected_directories ) )
687
  $oktodelete = false;
688
  if( $oktodelete && !$rename ) {
 
689
  @unlink( $directory );
690
  $log++;
691
  } elseif( $oktodelete && $rename ) {
 
692
  wp_cache_rebuild_or_delete( $directory );
693
  $log++;
694
  }
@@ -735,7 +785,7 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
735
  if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $cache_max_time) <= $now ) {
736
  if( substr( $file, -9 ) != '.htaccess' ) {
737
  @unlink($blog_cache_dir . $file);
738
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Deleting $blog_cache_dir{$file}", 5 );
739
  }
740
  }
741
  }
@@ -808,7 +858,7 @@ function wp_cache_shutdown_callback() {
808
  $wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
809
  }
810
 
811
- if ( !$supercacheonly && !$wp_cache_not_logged_in && $new_cache ) {
812
  if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
813
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending gzip headers.", 2 );
814
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
@@ -822,7 +872,7 @@ function wp_cache_shutdown_callback() {
822
  $tmp_meta_filename = $blog_cache_dir . 'meta/' . uniqid( mt_rand(), true ) . '.tmp';
823
  $fr = @fopen( $tmp_meta_filename, 'w');
824
  if( !$fr )
825
- @mkdir( $blog_cache_dir . 'meta' );
826
  $fr = @fopen( $tmp_meta_filename, 'w');
827
  if ( $fr ) {
828
  fputs($fr, $serial);
@@ -843,6 +893,8 @@ function wp_cache_shutdown_callback() {
843
  }
844
  wp_cache_writers_exit();
845
  }
 
 
846
  }
847
  global $time_to_gc_cache;
848
  if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
@@ -863,9 +915,10 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
863
  $comment[ 'comment_approved' ] = $status;
864
  }
865
 
866
- if ( ( $status == 'trash' || $status == 'spam' ) && $comment[ 'comment_approved' ] != 1 ) {
867
  // don't modify cache if moderated comments are trashed or spammed
868
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment deleted or spammed. Don't delete any cache files.", 4 );
 
869
  return wp_cache_post_id();
870
  }
871
  $postid = $comment['comment_post_ID'];
@@ -874,16 +927,20 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
874
  if ( !preg_match('/wp-admin\//', $wp_cache_request_uri) ) {
875
  if ( $comment['comment_approved'] == 'delete' && ( isset( $comment[ 'old_comment_approved' ] ) && $comment[ 'old_comment_approved' ] == 0 ) ) { // do nothing if moderated comments are deleted
876
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment deleted. Don't delete any cache files.", 4 );
 
877
  return $postid;
878
  } elseif ( $comment['comment_approved'] == 'spam' ) {
879
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Spam comment. Don't delete any cache files.", 4 );
 
880
  return $postid;
881
  } elseif( $comment['comment_approved'] == '0' ) {
882
  if ( $comment[ 'content_type' ] == '' ) {
883
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment. Don't delete supercache file until comment approved.", 4 );
884
  $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
 
885
  } else {
886
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated ping or trackback. Not deleting cache files..", 4 );
 
887
  return $postid;
888
  }
889
  }
@@ -900,26 +957,50 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
900
  }
901
  }
902
 
 
 
 
 
 
 
903
  /* Clear out the cache directory. */
904
- function wp_cache_clear_cache() {
905
  global $cache_path, $wp_cache_object_cache;
906
  if ( $wp_cache_object_cache ) {
907
  reset_oc_version();
908
  } else {
909
- prune_super_cache( $cache_path . 'supercache/', true );
910
- prune_super_cache( $cache_path, true );
 
 
 
 
 
 
 
911
  }
912
  }
913
 
 
914
  function wp_cache_post_edit($post_id) {
915
  global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
 
 
 
 
 
 
 
 
 
 
916
  if( $wp_cache_clear_on_post_edit ) {
917
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
918
  if ( $wp_cache_object_cache ) {
919
  reset_oc_version();
920
  } else {
921
  prune_super_cache( $blog_cache_dir, true );
922
- prune_super_cache( $cache_path . 'supercache/', true );
923
  }
924
  } else {
925
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Clearing cache for post $post_id on post edit.", 2 );
@@ -928,7 +1009,7 @@ function wp_cache_post_edit($post_id) {
928
  }
929
 
930
  function wp_cache_post_id_gc( $siteurl, $post_id, $all = 'all' ) {
931
- global $cache_path, $wp_cache_object_cache;
932
 
933
  if ( $wp_cache_object_cache )
934
  reset_oc_version();
@@ -949,8 +1030,11 @@ function wp_cache_post_id_gc( $siteurl, $post_id, $all = 'all' ) {
949
  prune_super_cache( $dir, true, true );
950
  do_action( 'gc_cache', 'prune', $permalink );
951
  }
952
- 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 );
953
- prune_super_cache( $dir . 'page/', true );
 
 
 
954
  do_action( 'gc_cache', 'prune', '/page/' );
955
  }
956
 
@@ -961,7 +1045,7 @@ function wp_cache_post_change( $post_id ) {
961
  if ($post_id == $last_processed) return $post_id;
962
  $last_processed = $post_id;
963
  $post = get_post( $post_id );
964
- if( $post->post_status == 'draft' ) {
965
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
966
  return $post_id;
967
  }
@@ -969,9 +1053,14 @@ function wp_cache_post_change( $post_id ) {
969
  if( !wp_cache_writers_entry() )
970
  return $post_id;
971
 
972
- if ( isset( $wp_cache_refresh_single_only ) && $wp_cache_refresh_single_only && strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-comments-post.php' ) ) {
973
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: comment detected. only deleting post page.", 4 );
974
- $all = false;
 
 
 
 
 
975
  } else {
976
  $all = true;
977
  }
@@ -985,7 +1074,6 @@ function wp_cache_post_change( $post_id ) {
985
  $siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) );
986
  // make sure the front page has a rebuild file
987
  wp_cache_post_id_gc( $siteurl, $post_id );
988
- // make sure the front page has a rebuild file
989
  if ( $all == true ) {
990
  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 );
991
  $files_to_check = get_all_supercache_filenames( $dir );
@@ -994,7 +1082,6 @@ function wp_cache_post_change( $post_id ) {
994
  }
995
  do_action( 'gc_cache', 'prune', 'homepage' );
996
  }
997
- wp_cache_post_id_gc( $siteurl, $post_id );
998
  if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
999
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting page_on_front and page_for_posts pages.", 4 );
1000
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: page_on_front " . get_option( 'page_on_front' ), 4 );
@@ -1087,7 +1174,7 @@ function wp_cache_gc_cron() {
1087
 
1088
  $start = time();
1089
  $num = 0;
1090
- if( false == ( $num = wp_cache_phase2_clean_expired( $file_prefix ) ) ) {
1091
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.', 1 );
1092
  update_option( 'wpsupercache_gc_time', time() - ( $cache_time_interval - 10 ) ); // if GC failed then run it again in one minute
1093
  $msg .= __( 'Cache expiry cron job failed. Job will run again in 10 seconds.', 'wp-super-cache' ) . "\n";
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_last_gc;
5
+ global $cache_max_time, $wp_cache_request_uri, $super_cache_enabled, $wp_cache_object_cache, $cache_time_interval, $wp_cache_no_cache_for_get;
6
  global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval;
7
 
8
+ if ( $cache_enabled == false ) {
9
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Caching disabled! quiting!", 1 );
10
  return false;
11
+ }
12
 
13
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'In WP Cache Phase 2', 5 );
14
 
18
  wp_cache_mutex_init();
19
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
20
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Setting up WordPress actions', 5 );
21
+
22
+ add_action( 'template_redirect', 'wp_super_cache_query_vars' );
23
+
24
  // Post ID is received
25
+ add_action('wp_trash_post', 'wp_cache_post_edit', 0);
26
  add_action('publish_post', 'wp_cache_post_edit', 0);
27
  add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post
28
  add_action('delete_post', 'wp_cache_post_edit', 0);
36
  // No post_id is available
37
  add_action('switch_theme', 'wp_cache_no_postid', 99);
38
  add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
39
+ add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
40
  add_action('wp_cache_gc','wp_cache_gc_cron');
41
+ add_action( 'clean_post_cache', 'wp_cache_post_edit' );
42
  add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
43
 
44
  do_cacheaction( 'add_cacheaction' );
45
  }
46
 
47
+ if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
48
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page.", 1 );
49
+ return false;
50
+ }
51
+
52
  if ( is_admin() ) {
53
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching wp-admin requests.', 5 );
54
  return false;
132
  if (!function_exists('apache_request_headers')) return false;
133
  $headers = apache_request_headers();
134
  if (!isset($headers["User-Agent"])) return false;
135
+ if ( false == is_array( $cache_rejected_user_agent ) )
136
+ return false;
137
  foreach ($cache_rejected_user_agent as $expr) {
138
  if (strlen($expr) > 0 && stristr($headers["User-Agent"], $expr))
139
  return true;
166
  if( strstr( $uri, $u ) )
167
  return true; // we don't allow caching of wp-admin for security reasons
168
  }
169
+ if ( false == is_array( $cache_rejected_uri ) )
170
+ return false;
171
  foreach ( $cache_rejected_uri as $expr ) {
172
  if( $expr != '' && @preg_match( "~$expr~", $uri ) )
173
  return true;
190
 
191
  $mutex = false;
192
  if ($use_flock ) {
193
+ setup_blog_cache_dir();
194
  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 );
195
  $mutex = @fopen( $blog_cache_dir . $mutex_filename, 'w' );
196
  } else {
241
  }
242
  }
243
 
244
+ function wp_super_cache_query_vars() {
245
+ global $wp_super_cache_query;
246
+ if ( is_search() )
247
+ $wp_super_cache_query[ 'is_search' ] = 1;
248
+ if ( is_page() )
249
+ $wp_super_cache_query[ 'is_page' ] = 1;
250
+ if ( is_archive() )
251
+ $wp_super_cache_query[ 'is_archive' ] = 1;
252
+ if ( is_tag() )
253
+ $wp_super_cache_query[ 'is_tag' ] = 1;
254
+ if ( is_single() )
255
+ $wp_super_cache_query[ 'is_single' ] = 1;
256
+ if ( is_category() )
257
+ $wp_super_cache_query[ 'is_category' ] = 1;
258
+ if ( is_front_page() )
259
+ $wp_super_cache_query[ 'is_front_page' ] = 1;
260
+ if ( is_home() )
261
+ $wp_super_cache_query[ 'is_home' ] = 1;
262
+ if ( is_author() )
263
+ $wp_super_cache_query[ 'is_author' ] = 1;
264
+ if ( is_feed() )
265
+ $wp_super_cache_query[ 'is_feed' ] = 1;
266
+ }
267
+
268
  function wp_cache_ob_callback( $buffer ) {
269
+ global $wp_cache_pages, $wp_query, $wp_super_cache_query;
270
  $buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
271
  if( defined( 'DONOTCACHEPAGE' ) ) {
272
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
273
  return $buffer;
274
  }
275
 
276
+ if ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && isset( $wp_super_cache_query[ 'is_single' ] ) ) {
277
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single post.', 2 );
278
  return $buffer;
279
+ } elseif ( isset( $wp_cache_pages[ 'pages' ] ) && $wp_cache_pages[ 'pages' ] == 1 && isset( $wp_super_cache_query[ 'is_page' ] ) ) {
280
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single page.', 2 );
281
  return $buffer;
282
+ } elseif ( isset( $wp_cache_pages[ 'archives' ] ) && $wp_cache_pages[ 'archives' ] == 1 && isset( $wp_super_cache_query[ 'is_archive' ] ) ) {
283
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching archive page.', 2 );
284
  return $buffer;
285
+ } elseif ( isset( $wp_cache_pages[ 'tag' ] ) && $wp_cache_pages[ 'tag' ] == 1 && isset( $wp_super_cache_query[ 'is_tag' ] ) ) {
286
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching tag page.', 2 );
287
  return $buffer;
288
+ } elseif ( isset( $wp_cache_pages[ 'category' ] ) && $wp_cache_pages[ 'category' ] == 1 && isset( $wp_super_cache_query[ 'is_category' ] ) ) {
289
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching category page.', 2 );
290
  return $buffer;
291
+ } elseif ( isset( $wp_cache_pages[ 'frontpage' ] ) && $wp_cache_pages[ 'frontpage' ] == 1 && isset( $wp_super_cache_query[ 'is_front_page' ] ) ) {
292
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching front page.', 2 );
293
  return $buffer;
294
+ } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && isset( $wp_super_cache_query[ 'is_home' ] ) ) {
295
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching home page.', 2 );
296
  return $buffer;
297
+ } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && isset( $wp_super_cache_query[ 'is_search' ] ) ) {
298
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching search page.', 2 );
299
  return $buffer;
300
+ } elseif ( isset( $wp_cache_pages[ 'author' ] ) && $wp_cache_pages[ 'author' ] == 1 && isset( $wp_super_cache_query[ 'is_author' ] ) ) {
301
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching author page.', 2 );
302
  return $buffer;
303
+ } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
304
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching feed.', 2 );
305
  return $buffer;
306
  }
307
 
308
+ if ( !isset( $wp_query ) )
309
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4 );
310
+
311
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Output buffer callback', 4 );
312
 
313
  $buffer = &wp_cache_get_ob( $buffer );
327
  }
328
 
329
  function wp_cache_get_ob(&$buffer) {
 
330
  global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
331
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
332
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
356
  }
357
  }
358
 
359
+ if ( !preg_match( apply_filters( 'wp_cache_eof_tags', '/(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i' ), $buffer ) ) {
360
  $new_cache = false;
361
  if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) ) {
362
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
399
 
400
  $supercacheonly = false;
401
  if( $super_cache_enabled ) {
402
+ if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
403
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Anonymous user detected. Only creating Supercache file.", 3 );
404
  $supercacheonly = true;
405
  }
424
  }
425
 
426
  if ( !$cache_enabled ) {
427
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache is not enabled. Sending buffer to browser.', 5 );
428
  wp_cache_writers_exit();
429
  return $buffer . "\n<!-- Page not cached by WP Super Cache. Check your settings page. $cache_error -->";
430
  }
579
  @unlink( $tmp_wpcache_filename );
580
  } else {
581
  if ( !rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename ) ) {
582
+ if ( false == is_dir( $blog_cache_dir ) )
583
+ @wp_mkdir_p( $blog_cache_dir );
584
  unlink( $blog_cache_dir . $cache_filename );
585
  rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
586
  }
606
  $added_cache = 1;
607
  }
608
  }
609
+ if ( isset( $php_fd ) ) {
610
  fclose( $php_fd );
611
  if ( $php_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() . '.php' && !( $wp_cache_is_home ) ) {
612
  wp_cache_writers_exit();
719
  if( !$rename ) {
720
  @rmdir( $entry );
721
  $log++;
722
+ if ( $force ) {
723
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: deleted $entry, forced delete", 2 );
724
+ } else {
725
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: deleted $entry, older than $cache_max_time seconds", 2 );
726
+ }
727
  }
728
  }
729
  }
734
  if( in_array( $directory, $protected_directories ) )
735
  $oktodelete = false;
736
  if( $oktodelete && !$rename ) {
737
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "prune_super_cache: deleted $directory", 5 );
738
  @unlink( $directory );
739
  $log++;
740
  } elseif( $oktodelete && $rename ) {
741
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_c