Hyper Cache - Version 2.1.0

Version Description

Download this release

Release Info

Developer satollo
Plugin Icon wp plugin Hyper Cache
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.2 to 2.1.0

Files changed (6) hide show
  1. advanced-cache.php +50 -5
  2. en_US.php +6 -2
  3. it_IT.php +1 -1
  4. options.php +38 -8
  5. plugin.php +32 -20
  6. readme.txt +1 -5
advanced-cache.php CHANGED
@@ -70,14 +70,21 @@ if (is_file($hyper_file))
70
  header('Content-Type: ' . $hyper_data['mime']);
71
 
72
  // Send the cached html
73
- if ($hyper_cache_gzip && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && $hyper_data['gz'])
74
  {
75
  header('Content-Encoding: gzip');
76
  echo $hyper_data['gz'];
77
  }
78
  else
79
  {
80
- echo $hyper_data['html'];
 
 
 
 
 
 
 
81
  }
82
  flush();
83
  hyper_cache_clean();
@@ -157,7 +164,7 @@ function hyper_cache_callback($buffer)
157
  unset($data['gz']);
158
  $data['status'] = 404;
159
  }
160
-
161
  hyper_cache_write($data);
162
 
163
  return $buffer;
@@ -165,7 +172,7 @@ function hyper_cache_callback($buffer)
165
 
166
  function hyper_cache_write(&$data)
167
  {
168
- global $hyper_file;
169
 
170
  $data['uri'] = $_SERVER['REQUEST_URI'];
171
  $data['referer'] = $_SERVER['HTTP_REFERER'];
@@ -173,6 +180,11 @@ function hyper_cache_write(&$data)
173
  $data['host'] = $_SERVER['HTTP_HOST'];
174
  $data['agent'] = $_SERVER['HTTP_USER_AGENT'];
175
 
 
 
 
 
 
176
  $file = fopen($hyper_file, 'w');
177
  fwrite($file, serialize($data));
178
  fclose($file);
@@ -228,6 +240,7 @@ function hyper_cache_clean()
228
  global $hyper_cache_timeout, $hyper_cache_clean_interval;
229
 
230
  if (!$hyper_cache_clean_interval) return;
 
231
 
232
  $time = time();
233
  $file = ABSPATH . 'wp-content/hyper-cache/last-clean.dat';
@@ -236,7 +249,7 @@ function hyper_cache_clean()
236
  touch(ABSPATH . 'wp-content/hyper-cache/last-clean.dat');
237
 
238
  $path = ABSPATH . 'wp-content/hyper-cache';
239
- if ($handle = opendir($path))
240
  {
241
  while ($file = readdir($handle))
242
  {
@@ -249,4 +262,36 @@ function hyper_cache_clean()
249
  }
250
  }
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  ?>
70
  header('Content-Type: ' . $hyper_data['mime']);
71
 
72
  // Send the cached html
73
+ if ($hyper_cache_gzip && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && strlen($hyper_data['gz']) > 0)
74
  {
75
  header('Content-Encoding: gzip');
76
  echo $hyper_data['gz'];
77
  }
78
  else
79
  {
80
+ if (strlen($hyper_data['html']) > 0)
81
+ {
82
+ echo $hyper_data['html'];
83
+ }
84
+ else
85
+ {
86
+ echo gzdecode($hyper_data['gz']);
87
+ }
88
  }
89
  flush();
90
  hyper_cache_clean();
164
  unset($data['gz']);
165
  $data['status'] = 404;
166
  }
167
+
168
  hyper_cache_write($data);
169
 
170
  return $buffer;
172
 
173
  function hyper_cache_write(&$data)
174
  {
175
+ global $hyper_file, $hyper_cache_storage;
176
 
177
  $data['uri'] = $_SERVER['REQUEST_URI'];
178
  $data['referer'] = $_SERVER['HTTP_REFERER'];
180
  $data['host'] = $_SERVER['HTTP_HOST'];
181
  $data['agent'] = $_SERVER['HTTP_USER_AGENT'];
182
 
183
+ if ($hyper_cache_storage == 'minimize')
184
+ {
185
+ unset($data['html']);
186
+ }
187
+
188
  $file = fopen($hyper_file, 'w');
189
  fwrite($file, serialize($data));
190
  fclose($file);
240
  global $hyper_cache_timeout, $hyper_cache_clean_interval;
241
 
242
  if (!$hyper_cache_clean_interval) return;
243
+ if (rand(1, 10) != 5) return;
244
 
245
  $time = time();
246
  $file = ABSPATH . 'wp-content/hyper-cache/last-clean.dat';
249
  touch(ABSPATH . 'wp-content/hyper-cache/last-clean.dat');
250
 
251
  $path = ABSPATH . 'wp-content/hyper-cache';
252
+ if ($handle = @opendir($path))
253
  {
254
  while ($file = readdir($handle))
255
  {
262
  }
263
  }
264
 
265
+ if (!function_exists('gzdecode'))
266
+ {
267
+ function gzdecode ($data)
268
+ {
269
+ $flags = ord(substr($data, 3, 1));
270
+ $headerlen = 10;
271
+ $extralen = 0;
272
+
273
+ $filenamelen = 0;
274
+ if ($flags & 4) {
275
+ $extralen = unpack('v' ,substr($data, 10, 2));
276
+
277
+ $extralen = $extralen[1];
278
+ $headerlen += 2 + $extralen;
279
+ }
280
+ if ($flags & 8) // Filename
281
+
282
+ $headerlen = strpos($data, chr(0), $headerlen) + 1;
283
+ if ($flags & 16) // Comment
284
+
285
+ $headerlen = strpos($data, chr(0), $headerlen) + 1;
286
+ if ($flags & 2) // CRC at end of file
287
+
288
+ $headerlen += 2;
289
+ $unpacked = gzinflate(substr($data, $headerlen));
290
+ if ($unpacked === FALSE)
291
+
292
+ $unpacked = $data;
293
+ return $unpacked;
294
+ }
295
+ }
296
+
297
  ?>
en_US.php CHANGED
@@ -20,8 +20,12 @@ $hyper_labels['mobile'] = "Detetect and cache for mobile devices";
20
  $hyper_labels['clean_interval'] = "Autoclean every";
21
  $hyper_labels['clean_interval_desc'] = "minutes (set to zero to disable)";
22
  $hyper_labels['not_activated'] = "Hyper Cache is NOT correctly installed: some files or directories have not been created. Check if the wp-content directory is writable and remove any advanced-cache.php file into it. Deactivate and reactivate the plugin.";
23
- $hyper_labels['expire_type'] = "How to clean the cache";
24
- $hyper_labels['expire_type_desc'] = "(on new posts, posts update, comments and so on)";
 
 
 
 
25
  $hyper_labels['advanced_options'] = "Advanced options";
26
  $hyper_labels['reject'] = "URI to reject";
27
  $hyper_labels['reject_desc'] = "One per line. When a URI (eg. /video/my-new-performance) starts with one of the listed lines, it won't be cached.";
20
  $hyper_labels['clean_interval'] = "Autoclean every";
21
  $hyper_labels['clean_interval_desc'] = "minutes (set to zero to disable)";
22
  $hyper_labels['not_activated'] = "Hyper Cache is NOT correctly installed: some files or directories have not been created. Check if the wp-content directory is writable and remove any advanced-cache.php file into it. Deactivate and reactivate the plugin.";
23
+ $hyper_labels['expire_type'] = "What cached pages to delete on events";
24
+ $hyper_labels['expire_type_desc'] = "<b>none</b>: the cache never delete the cached page on events (comments, new posts, and so on)<br />";
25
+ $hyper_labels['expire_type_desc'] .= "<b>single pages</b>: the cached pages relative to the post modified (by the editor or when a comment is added) plus the home page. New published posts invalidate all the cache.<br />";
26
+ $hyper_labels['expire_type_desc'] .= "<b>single pages strictly</b>: as 'single pages' but without to invalidate all the cache on new posts publishing.<br />";
27
+ $hyper_labels['expire_type_desc'] .= "<b>all</b>: all the cached pages (the blog is always up to date)<br />";
28
+ $hyper_labels['expire_type_desc'] .= "Beware: when you use 'single pages strictly', a new post will appear on home page, but not on category and tag pages. If you use the 'last posts' widget/feature on sidebar it won't show updated.";
29
  $hyper_labels['advanced_options'] = "Advanced options";
30
  $hyper_labels['reject'] = "URI to reject";
31
  $hyper_labels['reject_desc'] = "One per line. When a URI (eg. /video/my-new-performance) starts with one of the listed lines, it won't be cached.";
it_IT.php CHANGED
@@ -21,7 +21,7 @@ $hyper_labels['clean_interval'] = "Ottimizza la cache ogni";
21
  $hyper_labels['clean_interval_desc'] = "minuti (imposta a zero per disabilitare)";
22
  $hyper_labels['not_activated'] = "Hyper Cache non � installato correttamente: qualche file o qualche cartelle non � stata creata. Controlla se la wp-content � scrivibile e rimuovi il file advanced-cache.php se presente in essa. Disattiva e riattiva il plugin.";
23
  $hyper_labels['expire_type'] = "Come invalidare la cache";
24
- $hyper_labels['expire_type_desc'] = "(nuovi articoli, articoli modificati, commenti, ...)";
25
  $hyper_labels['advanced_options'] = "Opzioni avanzate";
26
  $hyper_labels['reject'] = "URI da rifiutare";
27
  $hyper_labels['reject_desc'] = "Uno per linea. Quando un URI (ad esempio /video/my-new-performance) inizia con uno di quelli scritti non verr� messo in cache.";
21
  $hyper_labels['clean_interval_desc'] = "minuti (imposta a zero per disabilitare)";
22
  $hyper_labels['not_activated'] = "Hyper Cache non � installato correttamente: qualche file o qualche cartelle non � stata creata. Controlla se la wp-content � scrivibile e rimuovi il file advanced-cache.php se presente in essa. Disattiva e riattiva il plugin.";
23
  $hyper_labels['expire_type'] = "Come invalidare la cache";
24
+ //$hyper_labels['expire_type_desc'] = "(nuovi articoli, articoli modificati, commenti, ...)";
25
  $hyper_labels['advanced_options'] = "Opzioni avanzate";
26
  $hyper_labels['reject'] = "URI da rifiutare";
27
  $hyper_labels['reject_desc'] = "Uno per linea. Quando un URI (ad esempio /video/my-new-performance) inizia con uno di quelli scritti non verr� messo in cache.";
options.php CHANGED
@@ -74,7 +74,6 @@ if ($installed && isset($_POST['clear']))
74
  if ($installed && isset($_POST['save']))
75
  {
76
  $options = hyper_request('options');
77
- update_option('hyper', $options);
78
 
79
  if ($options['timeout'] == '' || !is_numeric($options['timeout']))
80
  {
@@ -91,23 +90,30 @@ if ($installed && isset($_POST['save']))
91
  $buffer .= '$hyper_cache_compress = ' . ($options['compress']?'true':'false') . ";\n";
92
  $buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
93
  $buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
94
- $buffer .= '$hyper_cache_gzip = ' . ($options['gzip']?'true':'false') . ";\n";
95
  $buffer .= '$hyper_cache_redirects = ' . ($options['redirects']?'true':'false') . ";\n";
96
  $buffer .= '$hyper_cache_mobile = ' . ($options['mobile']?'true':'false') . ";\n";
97
  //$buffer .= '$hyper_cache_folder = \'' . $options['folder'] . "';\n";
 
 
 
 
 
98
  $buffer .= '$hyper_cache_folder = \'' . ABSPATH . 'wp-content/hyper-cache' . "';\n";
99
  $buffer .= '$hyper_cache_clean_interval = ' . $options['clean_interval'] . ";\n";
 
100
  if (trim($options['reject']) != '')
101
  {
102
  $options['reject'] = str_replace(' ', "\n", $options['reject']);
103
  $options['reject'] = str_replace("\r", "\n", $options['reject']);
104
  $buffer .= '$hyper_cache_reject = array(';
105
  $reject = explode("\n", $options['reject']);
 
106
  foreach ($reject as $uri)
107
  {
108
  $uri = trim($uri);
109
  if ($uri == '') continue;
110
  $buffer .= "'" . addslashes(trim($uri)) . "',";
 
111
  }
112
  $buffer = rtrim($buffer, ',');
113
  $buffer .= ");\n";
@@ -116,7 +122,7 @@ if ($installed && isset($_POST['save']))
116
  $file = fopen(ABSPATH . 'wp-content/hyper-cache-config.php', 'w');
117
  fwrite($file, $buffer);
118
  fclose($file);
119
-
120
  }
121
  else
122
  {
@@ -172,10 +178,12 @@ else
172
  <th scope="row"><label><?php echo $hyper_labels['expire_type']; ?></label></th>
173
  <td>
174
  <select name="options[expire_type]">
175
- <option value="post" <?php echo ($options['expire_type'] == 'post')?'selected':''; ?>>Only the post modified</option>
176
- <option value="all" <?php echo ($options['expire_type'] == 'all')?'selected':''; ?>>All the cache</option>
 
177
  <option value="none" <?php echo ($options['expire_type'] == 'none')?'selected':''; ?>>None</option>
178
- </select>
 
179
  <?php echo $hyper_labels['expire_type_desc']; ?>
180
  </td>
181
  </tr>
@@ -187,7 +195,16 @@ else
187
  <?php hyper_field_checkbox('mobile', $hyper_labels['mobile']); ?>
188
  </tr>
189
  <tr valign="top">
190
- <?php hyper_field_checkbox('gzip', $hyper_labels['gzip'], $hyper_labels['gzip_desc']); ?>
 
 
 
 
 
 
 
 
 
191
  </tr>
192
 
193
  <!--
@@ -206,7 +223,20 @@ else
206
  <table class="form-table">
207
  <tr valign="top">
208
  <?php hyper_field_checkbox('redirects', $hyper_labels['redirects'], $hyper_labels['redirects_desc']); ?>
209
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  <tr valign="top">
211
  <th scope="row"><label><?php echo $hyper_labels['reject']; ?></label></th>
212
  <td>
74
  if ($installed && isset($_POST['save']))
75
  {
76
  $options = hyper_request('options');
 
77
 
78
  if ($options['timeout'] == '' || !is_numeric($options['timeout']))
79
  {
90
  $buffer .= '$hyper_cache_compress = ' . ($options['compress']?'true':'false') . ";\n";
91
  $buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
92
  $buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
 
93
  $buffer .= '$hyper_cache_redirects = ' . ($options['redirects']?'true':'false') . ";\n";
94
  $buffer .= '$hyper_cache_mobile = ' . ($options['mobile']?'true':'false') . ";\n";
95
  //$buffer .= '$hyper_cache_folder = \'' . $options['folder'] . "';\n";
96
+ if (function_exists('gzencode'))
97
+ {
98
+ $buffer .= '$hyper_cache_gzip = ' . ($options['gzip']?'true':'false') . ";\n";
99
+ $buffer .= '$hyper_cache_storage = \'' . $options['storage'] . "';\n";
100
+ }
101
  $buffer .= '$hyper_cache_folder = \'' . ABSPATH . 'wp-content/hyper-cache' . "';\n";
102
  $buffer .= '$hyper_cache_clean_interval = ' . $options['clean_interval'] . ";\n";
103
+
104
  if (trim($options['reject']) != '')
105
  {
106
  $options['reject'] = str_replace(' ', "\n", $options['reject']);
107
  $options['reject'] = str_replace("\r", "\n", $options['reject']);
108
  $buffer .= '$hyper_cache_reject = array(';
109
  $reject = explode("\n", $options['reject']);
110
+ $options['reject'] = '';
111
  foreach ($reject as $uri)
112
  {
113
  $uri = trim($uri);
114
  if ($uri == '') continue;
115
  $buffer .= "'" . addslashes(trim($uri)) . "',";
116
+ $options['reject'] .= $uri . "\n";
117
  }
118
  $buffer = rtrim($buffer, ',');
119
  $buffer .= ");\n";
122
  $file = fopen(ABSPATH . 'wp-content/hyper-cache-config.php', 'w');
123
  fwrite($file, $buffer);
124
  fclose($file);
125
+ update_option('hyper', $options);
126
  }
127
  else
128
  {
178
  <th scope="row"><label><?php echo $hyper_labels['expire_type']; ?></label></th>
179
  <td>
180
  <select name="options[expire_type]">
181
+ <option value="post_strictly" <?php echo ($options['expire_type'] == 'post_strictly')?'selected':''; ?>>Single pages strictly</option>
182
+ <option value="post" <?php echo ($options['expire_type'] == 'post')?'selected':''; ?>>Single pages</option>
183
+ <option value="all" <?php echo ($options['expire_type'] == 'all')?'selected':''; ?>>All</option>
184
  <option value="none" <?php echo ($options['expire_type'] == 'none')?'selected':''; ?>>None</option>
185
+ </select><br />
186
+ <?php echo $hyper_labels['expire_type_desc']; ?><br />
187
  <?php echo $hyper_labels['expire_type_desc']; ?>
188
  </td>
189
  </tr>
195
  <?php hyper_field_checkbox('mobile', $hyper_labels['mobile']); ?>
196
  </tr>
197
  <tr valign="top">
198
+ <th scope="row"><label><?php echo $hyper_labels['gzip']; ?></label></th>
199
+ <td>
200
+ <?php if (function_exists('gzencode')) { ?>
201
+ <input type="checkbox" name="options[gzip]" value="1" <?php echo $options['gzip']!=null?'checked':''; ?> />
202
+ <br />
203
+ <?php echo $hyper_labels['gzip_desc']; ?>
204
+ <?php } else { ?>
205
+ There is not "gzencode" function, may be you PHP has not the zlib extension active.
206
+ <?php } ?>
207
+ </td>
208
  </tr>
209
 
210
  <!--
223
  <table class="form-table">
224
  <tr valign="top">
225
  <?php hyper_field_checkbox('redirects', $hyper_labels['redirects'], $hyper_labels['redirects_desc']); ?>
226
+ </tr>
227
+ <tr valign="top">
228
+ <th scope="row"><label>Storage</label></th>
229
+ <td>
230
+ <?php if (function_exists('gzencode')) { ?>
231
+ <select name="options[storage]">
232
+ <option value="default" <?php echo ($options['storage'] == 'default')?'selected':''; ?>>Default</option>
233
+ <option value="minimize" <?php echo ($options['storage'] == 'minimize')?'selected':''; ?>>Minimize the disk space</option>
234
+ </select>
235
+ <?php } else { ?>
236
+ You have not the zlib extension installed, leave the default option!
237
+ <?php } ?>
238
+ </td>
239
+ </tr>
240
  <tr valign="top">
241
  <th scope="row"><label><?php echo $hyper_labels['reject']; ?></label></th>
242
  <td>
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Hyper Cache
4
  Plugin URI: http://www.satollo.com/english/wordpress/hyper-cache
5
  Description: Hyper Cache is an extremely aggressive cache for WordPress even for mobile blogs. After an upgrade, DEACTIVATE, REACTIVATE and RECONFIGURE. ALWAYS!
6
- Version: 2.0.2
7
  Author: Satollo
8
  Author URI: http://www.satollo.com
9
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -100,8 +100,8 @@ function hyper_deactivate()
100
  hyper_delete_path(ABSPATH . 'wp-content/hyper-cache');
101
  }
102
 
103
- add_action('admin_head', 'hyper_admin_head');
104
- function hyper_admin_head()
105
  {
106
  add_options_page('Hyper Cache', 'Hyper Cache', 'manage_options', 'hyper-cache/options.php');
107
  }
@@ -122,10 +122,10 @@ function hyper_cache_invalidate()
122
  }
123
 
124
  $hyper_invalidated = true;
125
- $path = ABSPATH . 'wp-content/' . time();
126
- rename(ABSPATH . 'wp-content/hyper-cache', $path);
127
- mkdir(ABSPATH . 'wp-content/hyper-cache', 0766);
128
- hyper_delete_path($path);
129
  }
130
 
131
  function hyper_cache_invalidate_post($post_id)
@@ -146,14 +146,17 @@ function hyper_cache_invalidate_post_status($new, $old, $post)
146
 
147
  //hyper_log("Start global invalidation");
148
 
149
- if ($hyper_invalidated) //hyper_log("Already invalidated");
150
- if ($hyper_invalidated) return;
 
 
 
151
 
152
  $hyper_invalidated = true;
153
- $path = ABSPATH . 'wp-content/' . time();
154
- rename(ABSPATH . 'wp-content/hyper-cache', $path);
155
- mkdir(ABSPATH . 'wp-content/hyper-cache', 0766);
156
- hyper_delete_path($path);
157
  }
158
 
159
  function hyper_cache_invalidate_comment($comment_id, $status=1)
@@ -171,7 +174,6 @@ function hyper_delete_by_comment($comment_id)
171
  hyper_delete_by_post($post_id);
172
  }
173
 
174
-
175
  // Delete files in the cache based only on a post id. Only the post cached
176
  // page is deleted (with its mobile versions) and the home page of the blog.
177
  // If the cache has been already invalidated, of the specified post has already
@@ -225,7 +227,7 @@ function hyper_delete_path($path)
225
  {
226
  if ($path == null) return;
227
 
228
- if ($handle = opendir($path))
229
  {
230
  while ($file = readdir($handle))
231
  {
@@ -245,7 +247,7 @@ function hyper_count()
245
  {
246
  $count = 0;
247
  //if (!is_dir(ABSPATH . 'wp-content/hyper-cache')) return 0;
248
- if ($handle = opendir(ABSPATH . 'wp-content/hyper-cache'))
249
  {
250
  while ($file = readdir($handle))
251
  {
@@ -268,7 +270,6 @@ if ($hyper_options['enabled'] && $hyper_options['expire_type'] != 'none')
268
  // tags pages are affected and generally if we use plugin that print out "latest posts"
269
  // or so we cannot know if a deleted post appears on every page.
270
  add_action('switch_theme', 'hyper_cache_invalidate', 0);
271
- add_action('delete_post', 'hyper_cache_invalidate', 0);
272
 
273
  // When a post is modified and we want to expire only it's page we listen for
274
  // post edit (called everytime a post is modified, even if a comment is added) and
@@ -276,15 +277,26 @@ if ($hyper_options['enabled'] && $hyper_options['expire_type'] != 'none')
276
  // invalidate all the cache if the status change from publish to "not publish" or
277
  // from "not publish" to publish. These two cases make a post to appear or disappear
278
  // anc can affect home, categories, single pages with a posts list, ...
279
- if ($hyper_options['expire_type'] == 'post')
280
  {
281
  add_action('edit_post', 'hyper_cache_invalidate_post', 0);
282
- add_action('transition_post_status', 'hyper_cache_invalidate_post_status', 0, 3);
 
 
 
 
 
 
 
 
 
 
283
  }
284
  else
285
  {
286
  // If a complete invalidation is required, we do it on post edit.
287
  add_action('edit_post', 'hyper_cache_invalidate', 0);
 
288
  }
289
 
290
  // When a comment is received, and it's status is approved, the reference
@@ -294,7 +306,7 @@ if ($hyper_options['enabled'] && $hyper_options['expire_type'] != 'none')
294
  // Surely some of those hooks are redundant. When a new comment is added (and
295
  // approved) the action "edit_post" is fired (llok at the code before). I need
296
  // to deeply check this code BUT the plugin is protected from redundant invalidations.
297
- if ($hyper_options['expire_type'] == 'post')
298
  {
299
  add_action('comment_post', 'hyper_cache_invalidate_comment', 10, 2);
300
  add_action('edit_comment', 'hyper_cache_invalidate_comment', 0);
3
  Plugin Name: Hyper Cache
4
  Plugin URI: http://www.satollo.com/english/wordpress/hyper-cache
5
  Description: Hyper Cache is an extremely aggressive cache for WordPress even for mobile blogs. After an upgrade, DEACTIVATE, REACTIVATE and RECONFIGURE. ALWAYS!
6
+ Version: 2.1
7
  Author: Satollo
8
  Author URI: http://www.satollo.com
9
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
100
  hyper_delete_path(ABSPATH . 'wp-content/hyper-cache');
101
  }
102
 
103
+ add_action('admin_menu', 'hyper_admin_menu');
104
+ function hyper_admin_menu()
105
  {
106
  add_options_page('Hyper Cache', 'Hyper Cache', 'manage_options', 'hyper-cache/options.php');
107
  }
122
  }
123
 
124
  $hyper_invalidated = true;
125
+ //$path = ABSPATH . 'wp-content/' . time();
126
+ //rename(ABSPATH . 'wp-content/hyper-cache', $path);
127
+ //mkdir(ABSPATH . 'wp-content/hyper-cache', 0766);
128
+ hyper_delete_path(ABSPATH . 'wp-content/hyper-cache');
129
  }
130
 
131
  function hyper_cache_invalidate_post($post_id)
146
 
147
  //hyper_log("Start global invalidation");
148
 
149
+ if ($hyper_invalidated)
150
+ {
151
+ hyper_log("Already invalidated");
152
+ return;
153
+ }
154
 
155
  $hyper_invalidated = true;
156
+ //$path = ABSPATH . 'wp-content/' . time();
157
+ //rename(ABSPATH . 'wp-content/hyper-cache', $path);
158
+ //mkdir(ABSPATH . 'wp-content/hyper-cache', 0766);
159
+ hyper_delete_path(ABSPATH . 'wp-content/hyper-cache');
160
  }
161
 
162
  function hyper_cache_invalidate_comment($comment_id, $status=1)
174
  hyper_delete_by_post($post_id);
175
  }
176
 
 
177
  // Delete files in the cache based only on a post id. Only the post cached
178
  // page is deleted (with its mobile versions) and the home page of the blog.
179
  // If the cache has been already invalidated, of the specified post has already
227
  {
228
  if ($path == null) return;
229
 
230
+ if ($handle = @opendir($path))
231
  {
232
  while ($file = readdir($handle))
233
  {
247
  {
248
  $count = 0;
249
  //if (!is_dir(ABSPATH . 'wp-content/hyper-cache')) return 0;
250
+ if ($handle = @opendir(ABSPATH . 'wp-content/hyper-cache'))
251
  {
252
  while ($file = readdir($handle))
253
  {
270
  // tags pages are affected and generally if we use plugin that print out "latest posts"
271
  // or so we cannot know if a deleted post appears on every page.
272
  add_action('switch_theme', 'hyper_cache_invalidate', 0);
 
273
 
274
  // When a post is modified and we want to expire only it's page we listen for
275
  // post edit (called everytime a post is modified, even if a comment is added) and
277
  // invalidate all the cache if the status change from publish to "not publish" or
278
  // from "not publish" to publish. These two cases make a post to appear or disappear
279
  // anc can affect home, categories, single pages with a posts list, ...
280
+ if ($hyper_options['expire_type'] != 'all')
281
  {
282
  add_action('edit_post', 'hyper_cache_invalidate_post', 0);
283
+ add_action('delete_post', 'hyper_cache_invalidate_post', 0);
284
+ if ($hyper_options['expire_type'] == 'post')
285
+ {
286
+ // The post and all cache on publishing
287
+ add_action('transition_post_status', 'hyper_cache_invalidate_post_status', 0, 3);
288
+ }
289
+ else
290
+ {
291
+ // Strictly
292
+ add_action('edit_post', 'hyper_cache_invalidate_post', 0);
293
+ }
294
  }
295
  else
296
  {
297
  // If a complete invalidation is required, we do it on post edit.
298
  add_action('edit_post', 'hyper_cache_invalidate', 0);
299
+ add_action('delete_post', 'hyper_cache_invalidate', 0);
300
  }
301
 
302
  // When a comment is received, and it's status is approved, the reference
306
  // Surely some of those hooks are redundant. When a new comment is added (and
307
  // approved) the action "edit_post" is fired (llok at the code before). I need
308
  // to deeply check this code BUT the plugin is protected from redundant invalidations.
309
+ if ($hyper_options['expire_type'] != 'all')
310
  {
311
  add_action('comment_post', 'hyper_cache_invalidate_comment', 10, 2);
312
  add_action('edit_comment', 'hyper_cache_invalidate_comment', 0);
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: cache,chaching
3
  Requires at least: 2.1
4
  Tested up to: 2.6.3
5
- Stable tag: 2.0.2
6
  Donate link: http://www.satollo.com/english/donate
7
  Contributors: satollo,momo360modena
8
 
@@ -10,10 +10,6 @@ Hyper Cache is an extremely aggressive cache for WordPress.
10
 
11
  == Description ==
12
 
13
- _Hyper Cache 2.0 has a lot of new features and was widely rewritten. If you
14
- have problems with it, roll back to version 1.2.6 or 1.1.1
15
- (http://wordpress.org/extend/plugins/hyper-cache/download/)._
16
-
17
  Hyper Cache is a new cache system for WordPress, specifically written for
18
  people which have their blogs on *low resources hosting provider*
19
  (cpu and mysql).
2
  Tags: cache,chaching
3
  Requires at least: 2.1
4
  Tested up to: 2.6.3
5
+ Stable tag: 2.1
6
  Donate link: http://www.satollo.com/english/donate
7
  Contributors: satollo,momo360modena
8
 
10
 
11
  == Description ==
12
 
 
 
 
 
13
  Hyper Cache is a new cache system for WordPress, specifically written for
14
  people which have their blogs on *low resources hosting provider*
15
  (cpu and mysql).