Version Description
Download this release
Release Info
Developer | satollo |
Plugin | Hyper Cache |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.6 to 2.0.0
- advanced-cache.php +101 -37
- de_DE.php +17 -17
- en_US.php +31 -22
- fr_FR.php +16 -16
- it_IT.php +31 -22
- options.php +73 -23
- plugin.php +168 -60
- readme.txt +35 -19
advanced-cache.php
CHANGED
@@ -7,9 +7,22 @@ if (!$hyper_cache_enabled) return false;
|
|
7 |
// Do not cache post request (comments, plugins and so on)
|
8 |
if ($_SERVER["REQUEST_METHOD"] == 'POST') return false;
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
// Do not use or cache pages when a wordpress user is logged on
|
11 |
foreach ($_COOKIE as $n=>$v)
|
12 |
{
|
|
|
|
|
13 |
// wp 2.5 and wp 2.3 have different cookie prefix, skip cache if a post password cookie is present, also
|
14 |
if (substr($n, 0, 14) == 'wordpressuser_' || substr($n, 0, 10) == 'wordpress_' || substr($n, 0, 12) == 'wp-postpass_')
|
15 |
{
|
@@ -17,62 +30,59 @@ foreach ($_COOKIE as $n=>$v)
|
|
17 |
}
|
18 |
}
|
19 |
|
20 |
-
$hyper_uri = $_SERVER['REQUEST_URI'];
|
21 |
-
|
22 |
// Do not cache WP pages, even if those calls typically don't go throught this script
|
23 |
if (strpos($hyper_uri, '/wp-admin/') !== false || strpos($hyper_uri, '/wp-includes/') !== false || strpos($hyper_uri, '/wp-content/') !== false )
|
24 |
{
|
25 |
return false;
|
26 |
}
|
27 |
|
28 |
-
|
29 |
|
30 |
// The name of the file with html and other data
|
31 |
$hyper_cache_name = md5($hyper_uri);
|
32 |
-
$hyper_file = ABSPATH . 'wp-content/hyper-cache/' . $hyper_cache_name . '.dat';
|
33 |
|
34 |
// The file is present?
|
35 |
if (is_file($hyper_file))
|
36 |
{
|
37 |
-
|
38 |
-
$hyper_data = unserialize(file_get_contents($hyper_file));
|
39 |
-
|
40 |
-
// Default timeout
|
41 |
-
if ($hyper_cache_timeout == null)
|
42 |
{
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
if ($hyper_data['location'])
|
49 |
{
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
$hyper_data
|
59 |
-
|
|
|
|
|
|
|
60 |
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
-
|
74 |
-
flush();
|
75 |
-
die();
|
76 |
}
|
77 |
}
|
78 |
|
@@ -161,6 +171,7 @@ function hyper_cache_write(&$data)
|
|
161 |
$data['referer'] = $_SERVER['HTTP_REFERER'];
|
162 |
$data['time'] = time();
|
163 |
$data['host'] = $_SERVER['HTTP_HOST'];
|
|
|
164 |
|
165 |
$file = fopen($hyper_file, 'w');
|
166 |
fwrite($file, serialize($data));
|
@@ -185,4 +196,57 @@ function hyper_cache_compress(&$buffer)
|
|
185 |
|
186 |
return $buffer;
|
187 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
?>
|
7 |
// Do not cache post request (comments, plugins and so on)
|
8 |
if ($_SERVER["REQUEST_METHOD"] == 'POST') return false;
|
9 |
|
10 |
+
$hyper_uri = $_SERVER['REQUEST_URI'];
|
11 |
+
|
12 |
+
// Checks for rejected url
|
13 |
+
if ($hyper_cache_reject)
|
14 |
+
{
|
15 |
+
foreach($hyper_cache_reject as $uri)
|
16 |
+
{
|
17 |
+
if (substr($hyper_uri, 0, strlen($uri)) == $uri) return false;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
// Do not use or cache pages when a wordpress user is logged on
|
22 |
foreach ($_COOKIE as $n=>$v)
|
23 |
{
|
24 |
+
// SHIT!!! This test cookie makes to cache not work!!!
|
25 |
+
if ($n == 'wordpress_test_cookie') continue;
|
26 |
// wp 2.5 and wp 2.3 have different cookie prefix, skip cache if a post password cookie is present, also
|
27 |
if (substr($n, 0, 14) == 'wordpressuser_' || substr($n, 0, 10) == 'wordpress_' || substr($n, 0, 12) == 'wp-postpass_')
|
28 |
{
|
30 |
}
|
31 |
}
|
32 |
|
|
|
|
|
33 |
// Do not cache WP pages, even if those calls typically don't go throught this script
|
34 |
if (strpos($hyper_uri, '/wp-admin/') !== false || strpos($hyper_uri, '/wp-includes/') !== false || strpos($hyper_uri, '/wp-content/') !== false )
|
35 |
{
|
36 |
return false;
|
37 |
}
|
38 |
|
39 |
+
$hyper_uri = $_SERVER['HTTP_HOST'] . $hyper_uri;
|
40 |
|
41 |
// The name of the file with html and other data
|
42 |
$hyper_cache_name = md5($hyper_uri);
|
43 |
+
$hyper_file = ABSPATH . 'wp-content/hyper-cache/' . hyper_mobile_type() . $hyper_cache_name . '.dat';
|
44 |
|
45 |
// The file is present?
|
46 |
if (is_file($hyper_file))
|
47 |
{
|
48 |
+
if (!$hyper_cache_timeout || (time() - filectime($hyper_file)) < $hyper_cache_timeout*60)
|
|
|
|
|
|
|
|
|
49 |
{
|
50 |
+
// Load it and check is it's still valid
|
51 |
+
$hyper_data = unserialize(file_get_contents($hyper_file));
|
52 |
|
53 |
+
// Protect against broken cache files
|
54 |
+
if ($hyper_data != null)
|
|
|
55 |
{
|
56 |
+
|
57 |
+
if ($hyper_data['location'])
|
58 |
+
{
|
59 |
+
header('Location: ' . $hyper_data['location']);
|
60 |
+
flush;
|
61 |
+
die();
|
62 |
+
}
|
63 |
+
|
64 |
+
if ($hyper_data['status'] == 404)
|
65 |
+
{
|
66 |
+
header("HTTP/1.1 404 Not Found");
|
67 |
+
$hyper_data = unserialize(file_get_contents(ABSPATH . 'wp-content/hyper-cache/404.dat'));
|
68 |
+
}
|
69 |
|
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();
|
84 |
+
die();
|
85 |
}
|
|
|
|
|
|
|
86 |
}
|
87 |
}
|
88 |
|
171 |
$data['referer'] = $_SERVER['HTTP_REFERER'];
|
172 |
$data['time'] = time();
|
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));
|
196 |
|
197 |
return $buffer;
|
198 |
}
|
199 |
+
|
200 |
+
|
201 |
+
function hyper_mobile_type()
|
202 |
+
{
|
203 |
+
global $hyper_cache_mobile;
|
204 |
+
|
205 |
+
if (!$hyper_cache_mobile) return '';
|
206 |
+
|
207 |
+
$hyper_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
208 |
+
$hyper_agents = explode(',', "elaine/3.0, iphone, ipod, palm, eudoraweb, blazer, avantgo, windows ce, cellphone, small, mmef20, danger, hiptop, proxinet, newt, palmos, netfront, sharp-tq-gx10, sonyericsson, symbianos, up.browser, up.link, ts21i-10, mot-v, portalmmm, docomo, opera mini, palm, handspring, nokia, kyocera, samsung, motorola, mot, smartphone, blackberry, wap, playstation portable, lg, mmp, opwv, symbian, epoc");
|
209 |
+
foreach ($hyper_agents as $hyper_a)
|
210 |
+
{
|
211 |
+
if (strpos($hyper_agent, $hyper_a) !== false)
|
212 |
+
{
|
213 |
+
if (strpos($hyper_agent, 'iphone') || strpos($hyper_agent, 'ipod'))
|
214 |
+
{
|
215 |
+
return 'iphone';
|
216 |
+
}
|
217 |
+
else
|
218 |
+
{
|
219 |
+
return 'pda';
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
223 |
+
return '';
|
224 |
+
}
|
225 |
+
|
226 |
+
function hyper_cache_clean()
|
227 |
+
{
|
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';
|
234 |
+
if (file_exists($file) && ($time - filectime($file) < $hyper_cache_clean_interval*60)) return;
|
235 |
+
|
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 |
+
{
|
243 |
+
if ($file == '.' || $file == '..') continue;
|
244 |
+
|
245 |
+
$t = filectime($path . '/' . $file);
|
246 |
+
if ($time - $t > $hyper_cache_timeout) @unlink($path . '/' . $file);
|
247 |
+
}
|
248 |
+
closedir($handle);
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
?>
|
de_DE.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$hyper_labels['wp_cache_not_enabled'] = "Das WordPress Cachesystem ist nicht aktiv. Um es zu aktivieren bitte die folgende Zeile Code der Datei wp-config.php hinzufügen. Danke!";
|
4 |
-
$hyper_labels['configuration'] = "Konfiguration";
|
5 |
-
$hyper_labels['activate'] = "Cache aktiv?";
|
6 |
-
$hyper_labels['expire'] = "Ablauf des Cache nach";
|
7 |
-
$hyper_labels['minutes'] = "Minuten";
|
8 |
-
$hyper_labels['invalidate_single_posts'] = "Invalidate single posts";
|
9 |
-
$hyper_labels['invalidate_single_posts_desc'] = "Invalidate only the single cached post when modified (new comment, edited, ...)";
|
10 |
-
$hyper_labels['count'] = "Gecachte Seiten";
|
11 |
-
$hyper_labels['save'] = "Speichern";
|
12 |
-
$hyper_labels['gzip_compression'] = "Gzip compression";
|
13 |
-
$hyper_labels['gzip_compression_desc'] = "Enable gzip compression to serve copressed pages for gzip enabled browsers";
|
14 |
-
$hyper_labels['clear'] = "Cache löschen";
|
15 |
-
$hyper_labels['compress_html'] = "Optimize HTML";
|
16 |
-
|
17 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$hyper_labels['wp_cache_not_enabled'] = "Das WordPress Cachesystem ist nicht aktiv. Um es zu aktivieren bitte die folgende Zeile Code der Datei wp-config.php hinzufügen. Danke!";
|
4 |
+
$hyper_labels['configuration'] = "Konfiguration";
|
5 |
+
$hyper_labels['activate'] = "Cache aktiv?";
|
6 |
+
$hyper_labels['expire'] = "Ablauf des Cache nach";
|
7 |
+
$hyper_labels['minutes'] = "Minuten";
|
8 |
+
$hyper_labels['invalidate_single_posts'] = "Invalidate single posts";
|
9 |
+
$hyper_labels['invalidate_single_posts_desc'] = "Invalidate only the single cached post when modified (new comment, edited, ...)";
|
10 |
+
$hyper_labels['count'] = "Gecachte Seiten";
|
11 |
+
$hyper_labels['save'] = "Speichern";
|
12 |
+
$hyper_labels['gzip_compression'] = "Gzip compression";
|
13 |
+
$hyper_labels['gzip_compression_desc'] = "Enable gzip compression to serve copressed pages for gzip enabled browsers";
|
14 |
+
$hyper_labels['clear'] = "Cache löschen";
|
15 |
+
$hyper_labels['compress_html'] = "Optimize HTML";
|
16 |
+
|
17 |
+
?>
|
en_US.php
CHANGED
@@ -1,22 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$hyper_labels['wp_cache_not_enabled'] = "The wordPress cache system is not enabled. Please, activate it adding the line of code below in the file wp-config.php. Thank you!";
|
4 |
-
$hyper_labels['configuration'] = "Configuration";
|
5 |
-
$hyper_labels['activate'] = "Activate the cache?";
|
6 |
-
$hyper_labels['
|
7 |
-
$hyper_labels['
|
8 |
-
$hyper_labels['
|
9 |
-
$hyper_labels['
|
10 |
-
|
11 |
-
|
12 |
-
$hyper_labels['
|
13 |
-
$hyper_labels['
|
14 |
-
$hyper_labels['clear'] = "Clear the cache";
|
15 |
-
$hyper_labels['compress_html'] = "Optimize HTML";
|
16 |
-
$hyper_labels['compress_html_desc'] = "Try to optimize the HTML removing unuseful spaces. Do not use if you are
|
17 |
-
$hyper_labels['
|
18 |
-
$hyper_labels['
|
19 |
-
$hyper_labels['
|
20 |
-
$hyper_labels['
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$hyper_labels['wp_cache_not_enabled'] = "The wordPress cache system is not enabled. Please, activate it adding the line of code below in the file wp-config.php. Thank you!";
|
4 |
+
$hyper_labels['configuration'] = "Configuration";
|
5 |
+
$hyper_labels['activate'] = "Activate the cache?";
|
6 |
+
$hyper_labels['timeout'] = "Expire a cached page after";
|
7 |
+
$hyper_labels['timeout_desc'] = "minutes (set to zero to never expire)";
|
8 |
+
$hyper_labels['count'] = "Total cached pages (cached redirect is counted too)";
|
9 |
+
$hyper_labels['save'] = "Save";
|
10 |
+
//$hyper_labels['store'] = "Store pages as";
|
11 |
+
//$hyper_labels['folder'] = "Cache folder";
|
12 |
+
$hyper_labels['gzip'] = "Gzip compression";
|
13 |
+
$hyper_labels['gzip_desc'] = "Send gzip compressed pages to enabled browsers";
|
14 |
+
$hyper_labels['clear'] = "Clear the cache";
|
15 |
+
$hyper_labels['compress_html'] = "Optimize HTML";
|
16 |
+
$hyper_labels['compress_html_desc'] = "Try to optimize the HTML removing unuseful spaces. Do not use if you are using <pre> tags in the posts";
|
17 |
+
$hyper_labels['redirects'] = "Cache the WP redirects";
|
18 |
+
$hyper_labels['redirects_desc'] = "Can give problems with some configuration. Try and hope.";
|
19 |
+
$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.";
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
?>
|
fr_FR.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$hyper_labels['wp_cache_not_enabled'] = "Le cache de WordPress n'est pas activé. Merci d'ajouter la ligne suivante dans votre fichier wp-config.php. Merci !";
|
4 |
-
$hyper_labels['configuration'] = "Configuration";
|
5 |
-
$hyper_labels['activate'] = "Activer le cache?";
|
6 |
-
$hyper_labels['expire'] = "Les pages contenues dans le cache expirent après";
|
7 |
-
$hyper_labels['minutes'] = "minutes";
|
8 |
-
$hyper_labels['invalidate_single_posts'] = "Invalidate single posts";
|
9 |
-
$hyper_labels['invalidate_single_posts_desc'] = "Invalidate only the single cached post when modified (new comment, edited, ...)";
|
10 |
-
$hyper_labels['count'] = "Total cached pages (cached redirect is counted too)";
|
11 |
-
$hyper_labels['save'] = "Enregistrer";
|
12 |
-
$hyper_labels['gzip_compression'] = "Gzip compression";
|
13 |
-
$hyper_labels['gzip_compression_desc'] = "Enable gzip compression to serve copressed pages for gzip enabled browsers";
|
14 |
-
$hyper_labels['clear'] = "Effacer le cache";
|
15 |
-
|
16 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$hyper_labels['wp_cache_not_enabled'] = "Le cache de WordPress n'est pas activé. Merci d'ajouter la ligne suivante dans votre fichier wp-config.php. Merci !";
|
4 |
+
$hyper_labels['configuration'] = "Configuration";
|
5 |
+
$hyper_labels['activate'] = "Activer le cache?";
|
6 |
+
$hyper_labels['expire'] = "Les pages contenues dans le cache expirent après";
|
7 |
+
$hyper_labels['minutes'] = "minutes";
|
8 |
+
$hyper_labels['invalidate_single_posts'] = "Invalidate single posts";
|
9 |
+
$hyper_labels['invalidate_single_posts_desc'] = "Invalidate only the single cached post when modified (new comment, edited, ...)";
|
10 |
+
$hyper_labels['count'] = "Total cached pages (cached redirect is counted too)";
|
11 |
+
$hyper_labels['save'] = "Enregistrer";
|
12 |
+
$hyper_labels['gzip_compression'] = "Gzip compression";
|
13 |
+
$hyper_labels['gzip_compression_desc'] = "Enable gzip compression to serve copressed pages for gzip enabled browsers";
|
14 |
+
$hyper_labels['clear'] = "Effacer le cache";
|
15 |
+
|
16 |
+
?>
|
it_IT.php
CHANGED
@@ -1,22 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$hyper_labels['wp_cache_not_enabled'] = "Il sistema di caching di WordPress non è attivo. Attivarlo inserendo la riga sotto nel file wp-config.php. Grazie!";
|
4 |
-
$hyper_labels['configuration'] = "Configurazione";
|
5 |
-
$hyper_labels['activate'] = "Attivare la cache?";
|
6 |
-
$hyper_labels['
|
7 |
-
$hyper_labels['
|
8 |
-
$hyper_labels['
|
9 |
-
$hyper_labels['
|
10 |
-
|
11 |
-
|
12 |
-
$hyper_labels['
|
13 |
-
$hyper_labels['
|
14 |
-
$hyper_labels['clear'] = "
|
15 |
-
$hyper_labels['compress_html'] = "Ottimizza l'HTML";
|
16 |
-
$hyper_labels['compress_html_desc'] = "Cerca di ottimizzare l'HTML (non usare se utilizzate il tag <pre>)";
|
17 |
-
$hyper_labels['
|
18 |
-
$hyper_labels['
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$hyper_labels['wp_cache_not_enabled'] = "Il sistema di caching di WordPress non è attivo. Attivarlo inserendo la riga sotto nel file wp-config.php. Grazie!";
|
4 |
+
$hyper_labels['configuration'] = "Configurazione";
|
5 |
+
$hyper_labels['activate'] = "Attivare la cache?";
|
6 |
+
$hyper_labels['timeout'] = "Durata di una pagina";
|
7 |
+
$hyper_labels['timeout_desc'] = "minuti (imposta a zero per non avere scadenza)";
|
8 |
+
$hyper_labels['count'] = "Numero di pagine in cache";
|
9 |
+
$hyper_labels['save'] = "Salva";
|
10 |
+
//$hyper_labels['store'] = "Store pages as";
|
11 |
+
//$hyper_labels['folder'] = "Cache folder";
|
12 |
+
$hyper_labels['gzip'] = "Compressione gzip";
|
13 |
+
$hyper_labels['gzip_desc'] = "Manda pagine compresse ai browser che le accettano";
|
14 |
+
$hyper_labels['clear'] = "Svuota la cache";
|
15 |
+
$hyper_labels['compress_html'] = "Ottimizza l'HTML";
|
16 |
+
$hyper_labels['compress_html_desc'] = "Cerca di ottimizzare l'HTML (non usare se utilizzate il tag <pre>)";
|
17 |
+
$hyper_labels['redirects'] = "Ottimizza i redirect";
|
18 |
+
$hyper_labels['redirects_desc'] = "Potrebbe creare problemi con alcune configurazioni.";
|
19 |
+
$hyper_labels['mobile'] = "Riconosci i dispositivi mobili";
|
20 |
+
$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.";
|
28 |
+
|
29 |
+
?>
|
30 |
+
|
31 |
+
|
options.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
include(ABSPATH . 'wp-content/plugins/hyper-cache/en_US.php');
|
4 |
-
if (WPLANG) include(ABSPATH . 'wp-content/plugins/hyper-cache/' . WPLANG . '.php');
|
5 |
|
6 |
function hyper_request($name, $default=null)
|
7 |
{
|
@@ -61,11 +61,18 @@ function hyper_field_textarea($name, $label='', $tips='', $attrs='') {
|
|
61 |
echo '</td>';
|
62 |
}
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
67 |
|
68 |
-
|
|
|
|
|
69 |
$options = hyper_request('options');
|
70 |
update_option('hyper', $options);
|
71 |
|
@@ -74,13 +81,33 @@ if (isset($_POST['save'])) {
|
|
74 |
$options['timeout'] = 60;
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
77 |
$buffer = "<?php\n";
|
78 |
-
$buffer .= '$hyper_cache_enabled = ' . ($options['
|
79 |
$buffer .= '$hyper_cache_compress = ' . ($options['compress']?'true':'false') . ";\n";
|
80 |
$buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
|
81 |
$buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
|
82 |
$buffer .= '$hyper_cache_gzip = ' . ($options['gzip']?'true':'false') . ";\n";
|
83 |
$buffer .= '$hyper_cache_redirects = ' . ($options['redirects']?'true':'false') . ";\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
$buffer .= '?>';
|
85 |
$file = fopen(ABSPATH . 'wp-content/hyper-cache-config.php', 'w');
|
86 |
fwrite($file, $buffer);
|
@@ -95,11 +122,21 @@ else
|
|
95 |
$options['timeout'] = 60;
|
96 |
}
|
97 |
}
|
|
|
98 |
?>
|
99 |
<div class="wrap">
|
100 |
<form method="post">
|
101 |
<h2>Hyper Cache</h2>
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
<?php
|
104 |
if (!defined('WP_CACHE') ) {
|
105 |
echo '<div class="alert error" style="margin-top:10px;"><p>';
|
@@ -112,45 +149,58 @@ else
|
|
112 |
<h3><?php echo $hyper_labels['configuration']; ?></h3>
|
113 |
<table class="form-table">
|
114 |
<tr valign="top">
|
115 |
-
<?php hyper_field_checkbox('
|
116 |
</tr>
|
117 |
<tr valign="top">
|
118 |
-
<?php hyper_field_text('timeout', $hyper_labels['
|
119 |
</tr>
|
120 |
-
|
121 |
<tr valign="top">
|
122 |
-
<?php
|
123 |
</tr>
|
|
|
124 |
<tr valign="top">
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
<tr valign="top">
|
128 |
<?php hyper_field_checkbox('compress', $hyper_labels['compress_html'], $hyper_labels['compress_html_desc']); ?>
|
129 |
</tr>
|
130 |
<tr valign="top">
|
131 |
-
<?php hyper_field_checkbox('
|
|
|
|
|
|
|
132 |
</tr>
|
133 |
<tr valign="top">
|
134 |
<?php hyper_field_checkbox('redirects', $hyper_labels['redirects'], $hyper_labels['redirects_desc']); ?>
|
135 |
-
</tr>
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
<tr valign="top">
|
138 |
<th scope="row"><?php echo $hyper_labels['count']; ?></th>
|
139 |
<td><?php echo hyper_count(); ?></td>
|
140 |
</tr>
|
141 |
</table>
|
142 |
|
143 |
-
|
144 |
-
<h3><?php
|
145 |
<table class="form-table">
|
146 |
<tr valign="top">
|
147 |
-
<?php echo hyper_field_textarea('
|
148 |
-
</tr>
|
149 |
-
<tr valign="top">
|
150 |
-
<?php echo hyper_field_checkbox('get', __('cache get with parameters', 'hyper-cache')); ?>
|
151 |
-
</tr>
|
152 |
</table>
|
153 |
-
|
154 |
|
155 |
<p class="submit">
|
156 |
<input class="button" type="submit" name="save" value="<?php echo $hyper_labels['save']; ?>">
|
1 |
<?php
|
2 |
|
3 |
+
@include(ABSPATH . 'wp-content/plugins/hyper-cache/en_US.php');
|
4 |
+
if (WPLANG != '') @include(ABSPATH . 'wp-content/plugins/hyper-cache/' . WPLANG . '.php');
|
5 |
|
6 |
function hyper_request($name, $default=null)
|
7 |
{
|
61 |
echo '</td>';
|
62 |
}
|
63 |
|
64 |
+
$installed = is_dir(ABSPATH . 'wp-content/hyper-cache') && is_file(ABSPATH . 'wp-content/advanced-cache.php') &&
|
65 |
+
filesize(ABSPATH . 'wp-content/advanced-cache.php') == filesize(ABSPATH . 'wp-content/plugins/hyper-cache/advanced-cache.php');
|
66 |
+
|
67 |
+
|
68 |
+
if ($installed && isset($_POST['clear']))
|
69 |
+
{
|
70 |
+
hyper_cache_invalidate();
|
71 |
}
|
72 |
|
73 |
+
|
74 |
+
if ($installed && isset($_POST['save']))
|
75 |
+
{
|
76 |
$options = hyper_request('options');
|
77 |
update_option('hyper', $options);
|
78 |
|
81 |
$options['timeout'] = 60;
|
82 |
}
|
83 |
|
84 |
+
if ($options['clean_interval'] == '' || !is_numeric($options['clean_interval']))
|
85 |
+
{
|
86 |
+
$options['clean_interval'] = 0;
|
87 |
+
}
|
88 |
+
|
89 |
$buffer = "<?php\n";
|
90 |
+
$buffer .= '$hyper_cache_enabled = ' . ($options['enabled']?'true':'false') . ";\n";
|
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 |
+
$buffer .= '$hyper_cache_reject = array(';
|
103 |
+
$reject = explode("\n", $options['reject']);
|
104 |
+
foreach ($reject as $uri)
|
105 |
+
{
|
106 |
+
$buffer .= "'" . addslashes(trim($uri)) . "',";
|
107 |
+
}
|
108 |
+
$buffer = rtrim($buffer, ',');
|
109 |
+
$buffer .= ");\n";
|
110 |
+
}
|
111 |
$buffer .= '?>';
|
112 |
$file = fopen(ABSPATH . 'wp-content/hyper-cache-config.php', 'w');
|
113 |
fwrite($file, $buffer);
|
122 |
$options['timeout'] = 60;
|
123 |
}
|
124 |
}
|
125 |
+
|
126 |
?>
|
127 |
<div class="wrap">
|
128 |
<form method="post">
|
129 |
<h2>Hyper Cache</h2>
|
130 |
|
131 |
+
<?php
|
132 |
+
if (!$installed)
|
133 |
+
{
|
134 |
+
echo '<div class="alert error" style="margin-top:10px;"><p>';
|
135 |
+
echo $hyper_labels['not_activated'];
|
136 |
+
echo '</p></div>';
|
137 |
+
}
|
138 |
+
?>
|
139 |
+
|
140 |
<?php
|
141 |
if (!defined('WP_CACHE') ) {
|
142 |
echo '<div class="alert error" style="margin-top:10px;"><p>';
|
149 |
<h3><?php echo $hyper_labels['configuration']; ?></h3>
|
150 |
<table class="form-table">
|
151 |
<tr valign="top">
|
152 |
+
<?php hyper_field_checkbox('enabled', $hyper_labels['activate']); ?>
|
153 |
</tr>
|
154 |
<tr valign="top">
|
155 |
+
<?php hyper_field_text('timeout', $hyper_labels['timeout'], $hyper_labels['timeout_desc'], 'size="5"'); ?>
|
156 |
</tr>
|
|
|
157 |
<tr valign="top">
|
158 |
+
<?php hyper_field_text('clean_interval', $hyper_labels['clean_interval'], $hyper_labels['clean_interval_desc'], 'size="5"'); ?>
|
159 |
</tr>
|
160 |
+
|
161 |
<tr valign="top">
|
162 |
+
<th scope="row"><label><?php echo $hyper_labels['expire_type']; ?></label></th>
|
163 |
+
<td>
|
164 |
+
<select name="options[expire_type]">
|
165 |
+
<option value="post" <?php echo ($options['expire_type'] == 'post')?'selected':''; ?>>Only the post modified</option>
|
166 |
+
<option value="all" <?php echo ($options['expire_type'] == 'all')?'selected':''; ?>>All the cache</option>
|
167 |
+
<option value="none" <?php echo ($options['expire_type'] == 'none')?'selected':''; ?>>None</option>
|
168 |
+
</select>
|
169 |
+
<?php echo $hyper_labels['expire_type_desc']; ?>
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
|
173 |
<tr valign="top">
|
174 |
<?php hyper_field_checkbox('compress', $hyper_labels['compress_html'], $hyper_labels['compress_html_desc']); ?>
|
175 |
</tr>
|
176 |
<tr valign="top">
|
177 |
+
<?php hyper_field_checkbox('mobile', $hyper_labels['mobile']); ?>
|
178 |
+
</tr>
|
179 |
+
<tr valign="top">
|
180 |
+
<?php hyper_field_checkbox('gzip', $hyper_labels['gzip'], $hyper_labels['gzip_desc']); ?>
|
181 |
</tr>
|
182 |
<tr valign="top">
|
183 |
<?php hyper_field_checkbox('redirects', $hyper_labels['redirects'], $hyper_labels['redirects_desc']); ?>
|
184 |
+
</tr>
|
185 |
+
<!--
|
186 |
+
<tr valign="top">
|
187 |
+
<?php hyper_field_text('folder', $hyper_labels['folder'], $hyper_labels['folder_desc'], 'size="5"'); ?>
|
188 |
+
</tr>
|
189 |
+
-->
|
190 |
<tr valign="top">
|
191 |
<th scope="row"><?php echo $hyper_labels['count']; ?></th>
|
192 |
<td><?php echo hyper_count(); ?></td>
|
193 |
</tr>
|
194 |
</table>
|
195 |
|
196 |
+
|
197 |
+
<h3><?php echo $hyper_labels['advanced_options']; ?></h3>
|
198 |
<table class="form-table">
|
199 |
<tr valign="top">
|
200 |
+
<?php echo hyper_field_textarea('reject', $hyper_labels['reject'], $hyper_labels['reject_desc']); ?>
|
201 |
+
</tr>
|
|
|
|
|
|
|
202 |
</table>
|
203 |
+
|
204 |
|
205 |
<p class="submit">
|
206 |
<input class="button" type="submit" name="save" value="<?php echo $hyper_labels['save']; ?>">
|
plugin.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
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. After an upgrade, DEACTIVATE
|
6 |
-
Version:
|
7 |
Author: Satollo
|
8 |
Author URI: http://www.satollo.com
|
9 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -69,63 +69,96 @@ Version 1.0.4
|
|
69 |
*/
|
70 |
|
71 |
$hyper_options = get_option('hyper');
|
|
|
|
|
72 |
|
73 |
-
|
|
|
|
|
74 |
add_action('activate_hyper-cache/plugin.php', 'hyper_activate');
|
75 |
-
function hyper_activate()
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
hyper_cache_invalidate();
|
80 |
-
|
81 |
-
// Write the advanced-cache.php (so we grant it's the correct version)
|
82 |
$buffer = file_get_contents(dirname(__FILE__) . '/advanced-cache.php');
|
83 |
-
$file = fopen(ABSPATH . 'wp-content/advanced-cache.php', 'w');
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
}
|
88 |
|
89 |
|
90 |
add_action('deactivate_hyper-cache/plugin.php', 'hyper_deactivate');
|
91 |
function hyper_deactivate()
|
92 |
{
|
93 |
-
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
$path = ABSPATH . 'wp-content/' . time();
|
99 |
-
rename(ABSPATH . 'wp-content/hyper-cache', $path);
|
100 |
-
|
101 |
-
hyper_delete_path( $path );
|
102 |
-
}
|
103 |
}
|
104 |
|
105 |
add_action('admin_head', 'hyper_admin_head');
|
106 |
-
function hyper_admin_head()
|
|
|
107 |
add_options_page('Hyper Cache', 'Hyper Cache', 'manage_options', 'hyper-cache/options.php');
|
108 |
}
|
109 |
|
110 |
-
|
|
|
|
|
|
|
|
|
111 |
{
|
112 |
-
global $hyper_options;
|
113 |
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
|
|
116 |
$path = ABSPATH . 'wp-content/' . time();
|
117 |
rename(ABSPATH . 'wp-content/hyper-cache', $path);
|
118 |
mkdir(ABSPATH . 'wp-content/hyper-cache', 0766);
|
119 |
-
hyper_delete_path(
|
120 |
}
|
121 |
|
122 |
function hyper_cache_invalidate_post($post_id)
|
123 |
{
|
|
|
124 |
hyper_delete_by_post($post_id);
|
125 |
}
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
function hyper_cache_invalidate_comment($comment_id, $status=1)
|
128 |
{
|
|
|
129 |
if ($status != 1) return;
|
130 |
hyper_delete_by_comment($comment_id);
|
131 |
//hyper_cache_invalidate();
|
@@ -138,35 +171,86 @@ function hyper_delete_by_comment($comment_id)
|
|
138 |
hyper_delete_by_post($post_id);
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
function hyper_delete_by_post($post_id)
|
142 |
{
|
143 |
-
$
|
144 |
-
|
145 |
-
|
146 |
-
if (file_exists(ABSPATH . 'wp-content/hyper-cache/' . $file . '.dat'))
|
147 |
{
|
148 |
-
|
|
|
149 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
unlink($path . '/' . $file);
|
157 |
}
|
158 |
}
|
159 |
closedir($handle);
|
160 |
-
rmdir($path);
|
161 |
}
|
162 |
}
|
163 |
|
164 |
-
|
|
|
|
|
|
|
165 |
$count = 0;
|
166 |
-
if (!is_dir(ABSPATH . 'wp-content/hyper-cache')) return 0;
|
167 |
-
if ($handle = opendir(ABSPATH . 'wp-content/hyper-cache'))
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
170 |
$count++;
|
171 |
}
|
172 |
}
|
@@ -175,33 +259,46 @@ function hyper_count() {
|
|
175 |
return $count;
|
176 |
}
|
177 |
|
178 |
-
if
|
|
|
|
|
179 |
{
|
180 |
-
|
181 |
-
|
182 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
{
|
184 |
-
|
|
|
185 |
}
|
186 |
else
|
187 |
{
|
|
|
188 |
add_action('edit_post', 'hyper_cache_invalidate', 0);
|
189 |
}
|
190 |
-
add_action('delete_post', 'hyper_cache_invalidate', 0);
|
191 |
-
add_action('publish_phone', 'hyper_cache_invalidate', 0);
|
192 |
-
add_action('switch_theme', 'hyper_cache_invalidate', 0);
|
193 |
-
|
194 |
|
195 |
-
//
|
196 |
-
//
|
197 |
-
//
|
198 |
-
|
|
|
|
|
|
|
|
|
199 |
{
|
200 |
add_action('comment_post', 'hyper_cache_invalidate_comment', 10, 2);
|
201 |
add_action('edit_comment', 'hyper_cache_invalidate_comment', 0);
|
202 |
add_action('wp_set_comment_status', 'hyper_cache_invalidate_comment', 0);
|
203 |
-
|
204 |
-
// No post_id is available
|
205 |
add_action('delete_comment', 'hyper_cache_invalidate_comment', 0);
|
206 |
}
|
207 |
else
|
@@ -209,12 +306,15 @@ if ($hyper_options['cache'] && !$hyper_options['not_expire_on_actions'])
|
|
209 |
add_action('comment_post', 'hyper_cache_invalidate', 0);
|
210 |
add_action('edit_comment', 'hyper_cache_invalidate', 0);
|
211 |
add_action('wp_set_comment_status', 'hyper_cache_invalidate', 0);
|
212 |
-
|
213 |
-
// No post_id is available
|
214 |
add_action('delete_comment', 'hyper_cache_invalidate', 0);
|
215 |
}
|
216 |
}
|
217 |
|
|
|
|
|
|
|
|
|
|
|
218 |
add_filter('redirect_canonical', 'hyper_redirect_canonical', 10, 2);
|
219 |
$hyper_redirect = null;
|
220 |
function hyper_redirect_canonical($redirect_url, $requested_url)
|
@@ -225,4 +325,12 @@ function hyper_redirect_canonical($redirect_url, $requested_url)
|
|
225 |
|
226 |
return $redirect_url;
|
227 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
?>
|
2 |
/*
|
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.0
|
7 |
Author: Satollo
|
8 |
Author URI: http://www.satollo.com
|
9 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
69 |
*/
|
70 |
|
71 |
$hyper_options = get_option('hyper');
|
72 |
+
$hyper_invalidated = false;
|
73 |
+
$hyper_invalidated_post_id = null;
|
74 |
|
75 |
+
// On activation, we try to create files and directories. If something goes wrong
|
76 |
+
// (eg. for wrong permission on file system) the options page will give a
|
77 |
+
// warning.
|
78 |
add_action('activate_hyper-cache/plugin.php', 'hyper_activate');
|
79 |
+
function hyper_activate()
|
80 |
+
{
|
81 |
+
@mkdir(ABSPATH . 'wp-content/hyper-cache', 0766);
|
82 |
+
|
|
|
|
|
|
|
83 |
$buffer = file_get_contents(dirname(__FILE__) . '/advanced-cache.php');
|
84 |
+
$file = @fopen(ABSPATH . 'wp-content/advanced-cache.php', 'w');
|
85 |
+
if ($file)
|
86 |
+
{
|
87 |
+
fwrite($file, $buffer);
|
88 |
+
fclose($file);
|
89 |
+
}
|
90 |
}
|
91 |
|
92 |
|
93 |
add_action('deactivate_hyper-cache/plugin.php', 'hyper_deactivate');
|
94 |
function hyper_deactivate()
|
95 |
{
|
96 |
+
@unlink(ABSPATH . 'wp-content/advanced-cache.php');
|
97 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache-config.php');
|
98 |
|
99 |
+
// We can safely delete the hyper-cache directory, is not more used at this time.
|
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 |
}
|
108 |
|
109 |
+
// Completely invalidate the cache. The hyper-cache directory is renamed
|
110 |
+
// with a random name and re-created to be immediately available to the cache
|
111 |
+
// system. Then the renamed directory is removed.
|
112 |
+
// If the cache has been already invalidated, the function doesn't anything.
|
113 |
+
function hyper_cache_invalidate()
|
114 |
{
|
115 |
+
global $hyper_options, $hyper_invalidated;
|
116 |
|
117 |
+
//hyper_log("Called global invalidate");
|
118 |
+
if ($hyper_invalidated)
|
119 |
+
{
|
120 |
+
//hyper_log("Already invalidated");
|
121 |
+
return;
|
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)
|
132 |
{
|
133 |
+
//hyper_log("Called post invalidate for post id $post_id");
|
134 |
hyper_delete_by_post($post_id);
|
135 |
}
|
136 |
|
137 |
+
function hyper_cache_invalidate_post_status($new, $old, $post)
|
138 |
+
{
|
139 |
+
global $hyper_invalidated;
|
140 |
+
|
141 |
+
$post_id = $post->ID;
|
142 |
+
//hyper_log("Called post status invalidate for post id $post_id from $old to $new");
|
143 |
+
|
144 |
+
// The post is going online or offline
|
145 |
+
if ($new != 'publish' && $old != 'publish') return;
|
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)
|
160 |
{
|
161 |
+
//hyper_log("Called comment invalidate for comment id $comment_id and status $status");
|
162 |
if ($status != 1) return;
|
163 |
hyper_delete_by_comment($comment_id);
|
164 |
//hyper_cache_invalidate();
|
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
|
178 |
+
// been invalidate the function return doing nothing. This behaviour protect
|
179 |
+
// from multi invalidation caused by actions fired by WP.
|
180 |
+
// The invalidation doesn't take place is the post is not in "publish" status.
|
181 |
function hyper_delete_by_post($post_id)
|
182 |
{
|
183 |
+
global $hyper_invalidated_post_id, $hyper_invalidated;
|
184 |
+
|
185 |
+
if ($hyper_invalidated)
|
|
|
186 |
{
|
187 |
+
//hyper_log("Already invalidated");
|
188 |
+
return;
|
189 |
}
|
190 |
+
if ($hyper_invalidated_post_id == $post_id)
|
191 |
+
{
|
192 |
+
//hyper_log("Already invalidated post id $post_id");
|
193 |
+
return;
|
194 |
+
}
|
195 |
+
|
196 |
+
$post = get_post($post_id);
|
197 |
+
//hyper_log("Post status " . $post->post_status);
|
198 |
+
if ($post->post_status != 'publish')
|
199 |
+
{
|
200 |
+
return;
|
201 |
+
}
|
202 |
+
$hyper_invalidated_post_id = $post_id;
|
203 |
+
|
204 |
+
// Post invalidation
|
205 |
+
$link = get_permalink($post_id);
|
206 |
+
//$link = substr($link, strpos($link, '/', 7));
|
207 |
+
$link = substr($link, 7);
|
208 |
+
$file = md5($link);
|
209 |
+
|
210 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache/' . $file . '.dat');
|
211 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache/pda' . $file . '.dat');
|
212 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache/iphone' . $file . '.dat');
|
213 |
+
|
214 |
+
// Home invalidation
|
215 |
+
$link = substr(get_option('home'), 7) . '/';
|
216 |
+
$file = md5($link);
|
217 |
+
|
218 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache/' . $file . '.dat');
|
219 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache/pda' . $file . '.dat');
|
220 |
+
@unlink(ABSPATH . 'wp-content/hyper-cache/iphone' . $file . '.dat');
|
221 |
}
|
222 |
|
223 |
+
// Completely remove a directory and it's content.
|
224 |
+
function hyper_delete_path($path)
|
225 |
+
{
|
226 |
+
if ($path == null) return;
|
227 |
+
|
228 |
+
if ($handle = opendir($path))
|
229 |
+
{
|
230 |
+
while ($file = readdir($handle))
|
231 |
+
{
|
232 |
+
if ($file != '.' && $file != '..')
|
233 |
+
{
|
234 |
unlink($path . '/' . $file);
|
235 |
}
|
236 |
}
|
237 |
closedir($handle);
|
238 |
+
@rmdir($path);
|
239 |
}
|
240 |
}
|
241 |
|
242 |
+
// Counts the number of file in to the hyper cache directory to give an idea of
|
243 |
+
// the number of pages cached.
|
244 |
+
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 |
+
{
|
252 |
+
if ($file != '.' && $file != '..')
|
253 |
+
{
|
254 |
$count++;
|
255 |
}
|
256 |
}
|
259 |
return $count;
|
260 |
}
|
261 |
|
262 |
+
// Intercepts the action that can trigger a cache invalidation if the cache system is enabled
|
263 |
+
// and invalidation is asked for actions (if is not only based on cache timeout)
|
264 |
+
if ($hyper_options['enabled'] && $hyper_options['expire_type'] != 'none')
|
265 |
{
|
266 |
+
|
267 |
+
// We need to invalidate everything for those actions because home page, categories pages,
|
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
|
275 |
+
// the status change. We invalidate the single post if it's status is publish, we
|
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
|
291 |
+
// post is modified, but even other pages can be affected (last comments list,
|
292 |
+
// comment count and so on). We don't care about the latter situation when
|
293 |
+
// the expire type is configured to invalidate the single post page.
|
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);
|
301 |
add_action('wp_set_comment_status', 'hyper_cache_invalidate_comment', 0);
|
|
|
|
|
302 |
add_action('delete_comment', 'hyper_cache_invalidate_comment', 0);
|
303 |
}
|
304 |
else
|
306 |
add_action('comment_post', 'hyper_cache_invalidate', 0);
|
307 |
add_action('edit_comment', 'hyper_cache_invalidate', 0);
|
308 |
add_action('wp_set_comment_status', 'hyper_cache_invalidate', 0);
|
|
|
|
|
309 |
add_action('delete_comment', 'hyper_cache_invalidate', 0);
|
310 |
}
|
311 |
}
|
312 |
|
313 |
+
|
314 |
+
// Capture and register if a redirect is sent back from WP, so the cache
|
315 |
+
// can cache (or ignore) it. Redirects were source of problems for blogs
|
316 |
+
// with more than one host name (eg. domain.com and www.domain.com) comined
|
317 |
+
// with the use of Hyper Cache.
|
318 |
add_filter('redirect_canonical', 'hyper_redirect_canonical', 10, 2);
|
319 |
$hyper_redirect = null;
|
320 |
function hyper_redirect_canonical($redirect_url, $requested_url)
|
325 |
|
326 |
return $redirect_url;
|
327 |
}
|
328 |
+
|
329 |
+
function hyper_log($text)
|
330 |
+
{
|
331 |
+
$file = fopen(dirname(__FILE__) . '/plugin.log', 'a');
|
332 |
+
fwrite($file, $text . "\n");
|
333 |
+
fclose($file);
|
334 |
+
}
|
335 |
+
|
336 |
?>
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Hyper Cache ===
|
2 |
Tags: cache,chaching
|
3 |
Requires at least: 2.1
|
4 |
-
Tested up to: 2.6.
|
5 |
-
Stable tag:
|
6 |
Donate link: http://www.satollo.com/english/donate
|
7 |
Contributors: satollo,momo360modena
|
8 |
|
@@ -10,29 +10,45 @@ Hyper Cache is an extremely aggressive cache for WordPress.
|
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
pages.
|
21 |
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
-
|
|
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
|
|
31 |
|
32 |
-
|
33 |
-
modifications
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
|
|
|
|
36 |
|
37 |
== Installation ==
|
38 |
|
@@ -40,7 +56,7 @@ Thank you to Frank Luef for the german translation.
|
|
40 |
2. Go into the WordPress admin interface and activate the plugin
|
41 |
3. Optional: go to the options page and configure the plugin
|
42 |
|
43 |
-
Before upgrade DEACTIVATE the plugin!
|
44 |
|
45 |
== Frequently Asked Questions ==
|
46 |
|
1 |
=== Hyper Cache ===
|
2 |
Tags: cache,chaching
|
3 |
Requires at least: 2.1
|
4 |
+
Tested up to: 2.6.3
|
5 |
+
Stable tag: 2.0.0
|
6 |
Donate link: http://www.satollo.com/english/donate
|
7 |
Contributors: satollo,momo360modena
|
8 |
|
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).
|
|
|
20 |
|
21 |
+
Hyper Cache has the nice feature to be compatible with the plugin "wp-pda"
|
22 |
+
which enables a blog to be *accessible from mobile devices* showing the
|
23 |
+
contents with a different ad optimized theme.
|
24 |
|
25 |
+
Hyper Cache can manage (both) *plain and gzip compressed pages*, reducing the
|
26 |
+
bandwidth usage and making the pages load faster.
|
27 |
|
28 |
+
Hyper Cache can do *cache autoclean* to reduce the disk usage removing the old
|
29 |
+
cached pages at specified intervals of time.
|
30 |
+
|
31 |
+
Hyper Cache caches the not found requests, the WordPress redirect requests,
|
32 |
+
the feed requests.
|
33 |
+
|
34 |
+
Hyper Cache can be easly translated and the translation tested without compile
|
35 |
+
a language file: just copy the en_US.php file and start to translate.
|
36 |
|
37 |
+
More information on Hyper Cache page (below) or write me to info@satollo.com.
|
38 |
+
|
39 |
+
http://www.satollo.com/english/wordpress/hyper-cache
|
40 |
|
41 |
+
Thanks to:
|
42 |
+
- Amaury Balmer for internationalization and other modifications
|
43 |
+
- Frank Luef for german translation
|
44 |
+
- HypeScience, Martin Steldinger, Giorgio Guglielmino for test and bugs submissions
|
45 |
+
- Ishtiaq to ask me about compatibility with wp-pda
|
46 |
+
- Gene Steinberg to ask for an autoclean system
|
47 |
+
- many others I don't remember
|
48 |
|
49 |
+
To do:
|
50 |
+
- make the cache directory configurable because if you are on NFS the plugin can load too much the server (Deepak Gupta)
|
51 |
+
- execute the cache page so it's possible to insert php code - has many drawbacks I need to evluate well how to implement this feature (RT Cunningham)
|
52 |
|
53 |
== Installation ==
|
54 |
|
56 |
2. Go into the WordPress admin interface and activate the plugin
|
57 |
3. Optional: go to the options page and configure the plugin
|
58 |
|
59 |
+
Before upgrade DEACTIVATE the plugin and then ACTIVATE and RECONFIGURE!
|
60 |
|
61 |
== Frequently Asked Questions ==
|
62 |
|