Version Description
- Added disk as method for page caching
- Added support for mirror (origin pull) content delivery networks
- Added options to specify minify group policies per template
- Added options for toggling inline CSS and JS minification to improve minify reliability
- Added option to update Media Library attachment hostnames (when migrating domains etc)
- Added "Empty Cache" buttons to respective tabs
- Added additional file download fallback methods for minify
- Improved cookie handling
- Improved header handling
- Improved reliability of Media Library import
- "Don't cache pages for logged in users" is now the default page cache setting
- Fixed minify bug with RSS feeds
- Fixed minify bug with rewriting of url() URI in CSS
- Addressed more page cache invalidity cases
- Addressed rare occurrence of PHP fatal errors when saving post or comments
- Addressed CSS bug on wp-login.php
- Addressed rare MySQL error when uploading attachments to Media Library
- Modified plugin file/directory structure
- Confirmed compatibility with varnish and squid
Download this release
Release Info
Developer | fredericktownes |
Plugin | W3 Total Cache |
Version | 0.8 |
Comparing to | |
See all releases |
Code changes from version 0.7.5.2 to 0.8
- inc/css/popup.css +1 -1
- inc/define.php +210 -18
- inc/images/logo.png +0 -0
- inc/js/options.js +348 -304
- inc/js/popup.js +806 -392
- inc/options/about.phtml +18 -11
- inc/options/cdn.phtml +35 -8
- inc/options/dbcache.phtml +9 -3
- inc/options/faq.phtml +14 -10
- inc/options/general.phtml +6 -3
- inc/options/install.phtml +6 -6
- inc/options/minify.phtml +70 -40
- inc/options/pgcache.phtml +12 -5
- inc/popup/cdn_export_file.phtml +8 -0
- inc/popup/cdn_export_library.phtml +8 -0
- inc/popup/cdn_import_library.phtml +10 -2
- inc/popup/cdn_rename_domain.phtml +46 -0
- inc/popup/common/header.phtml +3 -3
- ini/_htaccess +67 -0
- ini/apc.ini +11 -11
- ini/php.append.ini +1 -1
- lib/W3/Cache.php +2 -2
- lib/W3/Cache/File.php +36 -31
- lib/W3/Cache/File/Manager.php +73 -0
- lib/W3/Config.php +9 -6
- lib/W3/Db.php +24 -15
- lib/W3/Minify.php +87 -115
- lib/W3/PgCache.php +124 -80
- lib/W3/Plugin.php +10 -6
- lib/W3/Plugin/Cdn.php +269 -88
- lib/W3/Plugin/DbCache.php +1 -1
- lib/W3/Plugin/Minify.php +362 -87
- lib/W3/Plugin/PgCache.php +7 -3
- lib/W3/Plugin/TotalCache.php +366 -160
- lib/W3/Request.php +1 -25
- readme.txt +89 -49
- w3-total-cache-config-default.php +21 -22
- w3-total-cache.php +1 -1
- wp-content/w3tc-cache/_htaccess +0 -8
- wp-content/w3tc/_htaccess +10 -0
- wp-content/w3tc/index.html +0 -0
- wp-content/{w3tc-cache/index.php → w3tc/minify.php} +0 -3
inc/css/popup.css
CHANGED
@@ -86,7 +86,7 @@ a:hover {
|
|
86 |
}
|
87 |
.log {
|
88 |
border: 1px solid #464646;
|
89 |
-
height:
|
90 |
overflow: auto;
|
91 |
}
|
92 |
.log div {
|
86 |
}
|
87 |
.log {
|
88 |
border: 1px solid #464646;
|
89 |
+
height: 279px;
|
90 |
overflow: auto;
|
91 |
}
|
92 |
.log div {
|
inc/define.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define('W3TC_VERSION', '0.
|
4 |
define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION);
|
5 |
define('W3TC_LINK_URL', 'http://www.w3-edge.com/wordpress-plugins/');
|
6 |
define('W3TC_LINK_NAME', 'WordPress Plugins');
|
@@ -10,27 +10,30 @@ if (! defined('W3TC_DIR')) {
|
|
10 |
}
|
11 |
|
12 |
define('W3TC_FILE', 'w3-total-cache/w3-total-cache.php');
|
13 |
-
define('W3TC_CONTENT_DIR', W3TC_DIR . '/wp-content');
|
14 |
define('W3TC_LIB_W3_DIR', W3TC_DIR . '/lib/W3');
|
15 |
define('W3TC_LIB_MINIFY_DIR', W3TC_DIR . '/lib/Minify/');
|
|
|
|
|
16 |
|
17 |
if (! defined('WP_CONTENT_DIR')) {
|
18 |
define('WP_CONTENT_DIR', realpath(W3TC_DIR . '/../..'));
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
define('W3TC_CONFIG_NAME', 'w3-total-cache-config');
|
22 |
define('W3TC_CONFIG_PATH', WP_CONTENT_DIR . '/' . W3TC_CONFIG_NAME . (($w3_blog_id = w3_get_blog_id()) != '' ? '-' . $w3_blog_id : '') . '.php');
|
23 |
define('W3TC_CONFIG_DEFAULT_PATH', W3TC_DIR . '/w3-total-cache-config-default.php');
|
24 |
|
25 |
-
define('W3TC_MINIFY_DIR_NAME', 'wp-content/w3tc-cache');
|
26 |
-
define('W3TC_MINIFY_DIR', ABSPATH . W3TC_MINIFY_DIR_NAME);
|
27 |
-
define('W3TC_MINIFY_CONTENT_DIR', W3TC_DIR . '/' . W3TC_MINIFY_DIR_NAME);
|
28 |
-
|
29 |
define('W3TC_CDN_COMMAND_UPLOAD', 1);
|
30 |
define('W3TC_CDN_COMMAND_DELETE', 2);
|
31 |
define('W3TC_CDN_TABLE_QUEUE', 'w3tc_cdn_queue');
|
32 |
-
define('W3TC_CDN_THEMES_DIR', ABSPATH . 'wp-content/themes/');
|
33 |
-
define('W3TC_CDN_INCLUDES_DIR', ABSPATH . 'wp-includes/');
|
34 |
|
35 |
/**
|
36 |
* W3 writable error
|
@@ -116,17 +119,19 @@ function w3_gzdecode($data)
|
|
116 |
*
|
117 |
* @param string $path
|
118 |
* @param integer $mask
|
|
|
119 |
* @return boolean
|
120 |
*/
|
121 |
-
function w3_mkdir($path, $mask = 0755)
|
122 |
{
|
123 |
-
$
|
124 |
-
$
|
|
|
125 |
foreach ($dirs as $dir) {
|
126 |
if (empty($dir)) {
|
127 |
return false;
|
128 |
}
|
129 |
-
$curr_path .= $dir;
|
130 |
if (! is_dir($curr_path)) {
|
131 |
if (@mkdir($curr_path, $mask)) {
|
132 |
@chmod($curr_path, $mask);
|
@@ -134,11 +139,51 @@ function w3_mkdir($path, $mask = 0755)
|
|
134 |
return false;
|
135 |
}
|
136 |
}
|
137 |
-
$curr_path .= DIRECTORY_SEPARATOR;
|
138 |
}
|
139 |
return true;
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
/**
|
143 |
* Check if content is HTML or XML
|
144 |
*
|
@@ -255,13 +300,54 @@ function w3_get_site_url()
|
|
255 |
|
256 |
if ($site_url === null) {
|
257 |
$site_url = get_option('siteurl');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
261 |
}
|
262 |
}
|
263 |
|
264 |
-
return $
|
265 |
}
|
266 |
|
267 |
/**
|
@@ -317,7 +403,7 @@ function w3_redirect($url = '', $params = '')
|
|
317 |
$query_string = '';
|
318 |
|
319 |
foreach ($merged_params as $param => $value) {
|
320 |
-
$count
|
321 |
$query_string .= urlencode($param) . (! empty($value) ? '=' . urlencode($value) : '') . ($count ? '&' : '');
|
322 |
}
|
323 |
|
@@ -326,6 +412,112 @@ function w3_redirect($url = '', $params = '')
|
|
326 |
|
327 |
$url .= (! empty($parse_url['fragment']) ? '#' . $parse_url['fragment'] : '');
|
328 |
|
329 |
-
header('Location: ' . $url);
|
330 |
exit();
|
331 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
define('W3TC_VERSION', '0.8');
|
4 |
define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION);
|
5 |
define('W3TC_LINK_URL', 'http://www.w3-edge.com/wordpress-plugins/');
|
6 |
define('W3TC_LINK_NAME', 'WordPress Plugins');
|
10 |
}
|
11 |
|
12 |
define('W3TC_FILE', 'w3-total-cache/w3-total-cache.php');
|
|
|
13 |
define('W3TC_LIB_W3_DIR', W3TC_DIR . '/lib/W3');
|
14 |
define('W3TC_LIB_MINIFY_DIR', W3TC_DIR . '/lib/Minify/');
|
15 |
+
define('W3TC_INSTALL_DIR', W3TC_DIR . '/wp-content');
|
16 |
+
define('W3TC_INSTALL_MINIFY_DIR', W3TC_INSTALL_DIR . '/w3tc');
|
17 |
|
18 |
if (! defined('WP_CONTENT_DIR')) {
|
19 |
define('WP_CONTENT_DIR', realpath(W3TC_DIR . '/../..'));
|
20 |
}
|
21 |
|
22 |
+
define('WP_CONTENT_DIR_NAME', basename(WP_CONTENT_DIR));
|
23 |
+
|
24 |
+
define('W3TC_CONTENT_DIR_NAME', WP_CONTENT_DIR_NAME . '/w3tc');
|
25 |
+
define('W3TC_CONTENT_DIR', ABSPATH . W3TC_CONTENT_DIR_NAME);
|
26 |
+
define('W3TC_CACHE_FILE_DIR', W3TC_CONTENT_DIR . '/cache');
|
27 |
+
define('W3TC_CACHE_MINIFY_DIR', W3TC_CONTENT_DIR . '/minify');
|
28 |
+
define('W3TC_LOG_DIR', W3TC_CONTENT_DIR . '/log');
|
29 |
+
|
30 |
define('W3TC_CONFIG_NAME', 'w3-total-cache-config');
|
31 |
define('W3TC_CONFIG_PATH', WP_CONTENT_DIR . '/' . W3TC_CONFIG_NAME . (($w3_blog_id = w3_get_blog_id()) != '' ? '-' . $w3_blog_id : '') . '.php');
|
32 |
define('W3TC_CONFIG_DEFAULT_PATH', W3TC_DIR . '/w3-total-cache-config-default.php');
|
33 |
|
|
|
|
|
|
|
|
|
34 |
define('W3TC_CDN_COMMAND_UPLOAD', 1);
|
35 |
define('W3TC_CDN_COMMAND_DELETE', 2);
|
36 |
define('W3TC_CDN_TABLE_QUEUE', 'w3tc_cdn_queue');
|
|
|
|
|
37 |
|
38 |
/**
|
39 |
* W3 writable error
|
119 |
*
|
120 |
* @param string $path
|
121 |
* @param integer $mask
|
122 |
+
* @param string
|
123 |
* @return boolean
|
124 |
*/
|
125 |
+
function w3_mkdir($path, $mask = 0755, $curr_path = '')
|
126 |
{
|
127 |
+
$path = preg_replace('~[\\\/]+~', '/', $path);
|
128 |
+
$path = trim($path, '/');
|
129 |
+
$dirs = explode('/', $path);
|
130 |
foreach ($dirs as $dir) {
|
131 |
if (empty($dir)) {
|
132 |
return false;
|
133 |
}
|
134 |
+
$curr_path .= ($curr_path == '' ? '' : '/') . $dir;
|
135 |
if (! is_dir($curr_path)) {
|
136 |
if (@mkdir($curr_path, $mask)) {
|
137 |
@chmod($curr_path, $mask);
|
139 |
return false;
|
140 |
}
|
141 |
}
|
|
|
142 |
}
|
143 |
return true;
|
144 |
}
|
145 |
|
146 |
+
/**
|
147 |
+
* Recursive remove dir
|
148 |
+
*
|
149 |
+
* @param $path
|
150 |
+
* @return boolean
|
151 |
+
*/
|
152 |
+
function w3_rmdir($path, $empty = false)
|
153 |
+
{
|
154 |
+
$dir = @opendir($path);
|
155 |
+
if ($dir) {
|
156 |
+
while (($entry = readdir($dir))) {
|
157 |
+
if ($entry != '.' && $entry != '..') {
|
158 |
+
$full_path = $path . '/' . $entry;
|
159 |
+
if (is_dir($full_path)) {
|
160 |
+
$result = @w3_rmdir($full_path);
|
161 |
+
} else {
|
162 |
+
$result = @unlink($full_path);
|
163 |
+
}
|
164 |
+
if (! $result) {
|
165 |
+
@closedir($dir);
|
166 |
+
return false;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
}
|
170 |
+
@closedir($dir);
|
171 |
+
return ($empty ? true : @rmdir($path));
|
172 |
+
}
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Recursive empty dir
|
178 |
+
*
|
179 |
+
* @param $path
|
180 |
+
* @return boolean
|
181 |
+
*/
|
182 |
+
function w3_emptydir($path)
|
183 |
+
{
|
184 |
+
return w3_rmdir($path, true);
|
185 |
+
}
|
186 |
+
|
187 |
/**
|
188 |
* Check if content is HTML or XML
|
189 |
*
|
300 |
|
301 |
if ($site_url === null) {
|
302 |
$site_url = get_option('siteurl');
|
303 |
+
}
|
304 |
+
|
305 |
+
return $site_url;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Get domain URL
|
310 |
+
* @return string
|
311 |
+
*/
|
312 |
+
function w3_get_domain_url()
|
313 |
+
{
|
314 |
+
$siteurl = w3_get_site_url();
|
315 |
+
$parse_url = @parse_url($siteurl);
|
316 |
+
|
317 |
+
if ($parse_url && isset($parse_url['scheme'])) {
|
318 |
+
$scheme = $parse_url['scheme'];
|
319 |
+
if (isset($parse_url['host'])) {
|
320 |
+
$host = $parse_url['host'];
|
321 |
+
$port = (isset($parse_url['port']) ? ':' . $parse_url['port'] : '');
|
322 |
+
return sprintf('%s://%s%s', $scheme, $host, $port);
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Returns blog path
|
331 |
+
* @return string
|
332 |
+
*/
|
333 |
+
function w3_get_site_path()
|
334 |
+
{
|
335 |
+
static $site_path = null;
|
336 |
+
|
337 |
+
if ($site_path === null) {
|
338 |
+
|
339 |
+
$site_url = w3_get_site_url();
|
340 |
+
$domain_url = w3_get_domain_url();
|
341 |
|
342 |
+
$site_path = str_replace($domain_url, '', $site_url);
|
343 |
+
$site_path = trim($site_path, '/');
|
344 |
+
|
345 |
+
if ($site_path != '') {
|
346 |
+
$site_path .= '/';
|
347 |
}
|
348 |
}
|
349 |
|
350 |
+
return $site_path;
|
351 |
}
|
352 |
|
353 |
/**
|
403 |
$query_string = '';
|
404 |
|
405 |
foreach ($merged_params as $param => $value) {
|
406 |
+
$count--;
|
407 |
$query_string .= urlencode($param) . (! empty($value) ? '=' . urlencode($value) : '') . ($count ? '&' : '');
|
408 |
}
|
409 |
|
412 |
|
413 |
$url .= (! empty($parse_url['fragment']) ? '#' . $parse_url['fragment'] : '');
|
414 |
|
415 |
+
@header('Location: ' . $url);
|
416 |
exit();
|
417 |
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Returns caching engine name
|
421 |
+
* @param $engine
|
422 |
+
* @return string
|
423 |
+
*/
|
424 |
+
function w3_get_engine_name($engine)
|
425 |
+
{
|
426 |
+
switch ($engine) {
|
427 |
+
case 'memcached':
|
428 |
+
$engine_name = 'memcached';
|
429 |
+
break;
|
430 |
+
|
431 |
+
case 'apc':
|
432 |
+
$engine_name = 'apc';
|
433 |
+
break;
|
434 |
+
|
435 |
+
case 'file':
|
436 |
+
$engine_name = 'disk';
|
437 |
+
break;
|
438 |
+
|
439 |
+
default:
|
440 |
+
$engine_name = 'N/A';
|
441 |
+
break;
|
442 |
+
}
|
443 |
+
|
444 |
+
return $engine_name;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Converts value to boolean
|
449 |
+
* @param mixed $value
|
450 |
+
* @return boolean
|
451 |
+
*/
|
452 |
+
function w3_to_boolean($value)
|
453 |
+
{
|
454 |
+
if (is_string($value)) {
|
455 |
+
switch (strtolower($value)) {
|
456 |
+
case '+':
|
457 |
+
case '1':
|
458 |
+
case 'y':
|
459 |
+
case 'on':
|
460 |
+
case 'yes':
|
461 |
+
case 'true':
|
462 |
+
case 'enabled':
|
463 |
+
return true;
|
464 |
+
|
465 |
+
case '-':
|
466 |
+
case '0':
|
467 |
+
case 'n':
|
468 |
+
case 'no':
|
469 |
+
case 'off':
|
470 |
+
case 'false':
|
471 |
+
case 'disabled':
|
472 |
+
return false;
|
473 |
+
}
|
474 |
+
}
|
475 |
+
|
476 |
+
return (boolean) $value;
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Download url via GET
|
481 |
+
* @param $url
|
482 |
+
* @return string
|
483 |
+
*/
|
484 |
+
function w3_url_get($url)
|
485 |
+
{
|
486 |
+
if (w3_to_boolean(ini_get('allow_url_fopen'))) {
|
487 |
+
ini_set('user_agent', W3TC_POWERED_BY);
|
488 |
+
return @file_get_contents($url);
|
489 |
+
} elseif (function_exists('curl_init')) {
|
490 |
+
$ch = curl_init();
|
491 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
492 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
493 |
+
curl_setopt($ch, CURLOPT_USERAGENT, W3TC_POWERED_BY);
|
494 |
+
$contents = curl_exec($ch);
|
495 |
+
curl_close($ch);
|
496 |
+
return $contents;
|
497 |
+
} else {
|
498 |
+
$parse_url = @parse_url($url);
|
499 |
+
if (isset($parse_url['host'])) {
|
500 |
+
$host = $parse_url['host'];
|
501 |
+
$port = (isset($parse_url['port']) ? (int) $parse_url['path'] : 80);
|
502 |
+
$path = (isset($parse_url['path']) ? trim($parse_url['path']) : '/');
|
503 |
+
$query = (isset($parse_url['query']) ? trim($parse_url['query']) : '');
|
504 |
+
$request_uri = $path . ($query != '' ? '?' . $query : '');
|
505 |
+
$request = sprintf("GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nUser-Agent: %s\r\n\r\n", $request_uri, $host, W3TC_POWERED_BY);
|
506 |
+
if (($fp = @fsockopen($host, $port))) {
|
507 |
+
$response = '';
|
508 |
+
@fputs($fp, $request);
|
509 |
+
while (! @feof($fp)) {
|
510 |
+
$response .= @fgets($fp, 4096);
|
511 |
+
}
|
512 |
+
@fclose($fp);
|
513 |
+
list (, $contents) = explode("\r\n\r\n", $response, 2);
|
514 |
+
return $contents;
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Send powered by header
|
522 |
+
*/
|
523 |
+
@header('X-Powered-By: ' . W3TC_POWERED_BY);
|
inc/images/logo.png
CHANGED
Binary file
|
inc/js/options.js
CHANGED
@@ -1,308 +1,352 @@
|
|
1 |
-
function w3tc_popup(url, name, width, height)
|
2 |
-
{
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
}
|
12 |
|
13 |
jQuery(function($) {
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
js_enabled();
|
132 |
-
js_file_location_change();
|
133 |
-
});
|
134 |
-
|
135 |
-
function css_file_delete()
|
136 |
-
{
|
137 |
-
$('.css_file_delete').click(function() {
|
138 |
-
if (confirm('Are you sure you want to delete CSS file?')) {
|
139 |
-
$(this).parent().remove();
|
140 |
-
if (! $('#css_files li').size()) {
|
141 |
-
$('#css_files').after('<div id="css_files_empty" class="w3tc-empty">No CSS files added<\/div>').remove();
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
return false;
|
146 |
-
});
|
147 |
-
}
|
148 |
-
|
149 |
-
css_file_delete();
|
150 |
-
|
151 |
-
$('#css_file_add').click(function() {
|
152 |
-
if ($('#css_files_empty').size()) {
|
153 |
-
$('#css_files_empty').after('<ol id="css_files"><\/ol>').remove();
|
154 |
-
}
|
155 |
-
$('#css_files').append('<li><input class="css_enabled" type="text" name="css_files_include[]" value="" size="100" \/> <input class="css_file_delete css_enabled button" type="button" value="Delete" /> <input class="css_file_verify css_enabled button" type="button" value="Verify URI" /><\/li>');
|
156 |
-
css_file_delete();
|
157 |
-
file_verify();
|
158 |
-
css_enabled();
|
159 |
-
});
|
160 |
-
|
161 |
-
$('#minify_form').submit(function() {
|
162 |
-
var js = [], css = [], invalid_js = [], invalid_css = [], duplicate = false, query_js = [], query_css = [];
|
163 |
-
|
164 |
-
$('#js_files :text').each(function() {
|
165 |
-
var v = $(this).val();
|
166 |
-
if (v != '') {
|
167 |
-
for (var i = 0; i < js.length; i++) {
|
168 |
-
if (js[i] == v) {
|
169 |
-
duplicate = true;
|
170 |
-
break;
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
js.push(v);
|
175 |
-
|
176 |
-
var qindex = v.indexOf('?');
|
177 |
-
if (qindex != -1) {
|
178 |
-
if (! /^https?:\/\//.test(v)) {
|
179 |
-
query_js.push(v);
|
180 |
-
}
|
181 |
-
v = v.substr(0, qindex);
|
182 |
-
}
|
183 |
-
|
184 |
-
if (! /\.js$/.test(v)) {
|
185 |
-
invalid_js.push(v);
|
186 |
-
}
|
187 |
-
}
|
188 |
-
});
|
189 |
-
$('#css_files :text').each(function() {
|
190 |
-
var v = $(this).val();
|
191 |
-
if (v != '') {
|
192 |
-
for (var i = 0; i < css.length; i++) {
|
193 |
-
if (css[i] == v) {
|
194 |
-
duplicate = true;
|
195 |
-
break;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
css.push(v);
|
200 |
-
|
201 |
-
var qindex = v.indexOf('?');
|
202 |
-
if (qindex != -1) {
|
203 |
-
if (! /^https?:\/\//.test(v)) {
|
204 |
-
query_css.push(v);
|
205 |
-
}
|
206 |
-
v = v.substr(0, qindex);
|
207 |
-
}
|
208 |
-
|
209 |
-
if (! /\.css$/.test(v)) {
|
210 |
-
invalid_css.push(v);
|
211 |
-
}
|
212 |
-
}
|
213 |
-
});
|
214 |
-
|
215 |
-
if ($('#js_enabled:checked').size()) {
|
216 |
-
if (invalid_js.length && ! confirm('These files have invalid JS file extension:\r\n\r\n' + invalid_js.join('\r\n') + '\r\n\r\nAre you confident this files contain valid JS code?')) {
|
217 |
-
return false;
|
218 |
-
}
|
219 |
-
|
220 |
-
if (query_js.length) {
|
221 |
-
alert('These JS files contain query string in the name:\r\n\r\n' + query_js.join('\r\n'));
|
222 |
-
return false;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
|
226 |
-
if ($('#css_enabled:checked').size()) {
|
227 |
-
if (invalid_css.length && ! confirm('These files have invalid CSS file extension:\r\n\r\n' + invalid_css.join('\r\n') + '\r\n\r\nAre you confident this files contain valid CSS code?')) {
|
228 |
-
return false;
|
229 |
-
}
|
230 |
-
|
231 |
-
if (query_css.length) {
|
232 |
-
alert('These CSS files contain query string in the name:\r\n\r\n' + query_css.join('\r\n'));
|
233 |
-
return false;
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
if (duplicate) {
|
238 |
-
alert('Duplicate files have been found in your minify settings, please check your settings again.');
|
239 |
-
return false;
|
240 |
-
}
|
241 |
-
|
242 |
-
return true;
|
243 |
-
});
|
244 |
-
|
245 |
-
// CDN
|
246 |
-
$('.w3tc-tab').click(function() {
|
247 |
-
$('.w3tc-tab-content').hide();
|
248 |
-
$(this.rel).show();
|
249 |
-
});
|
250 |
-
|
251 |
-
$('#cdn_export_library').click(function() {
|
252 |
-
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_export_library', 'cdn_export_library');
|
253 |
-
});
|
254 |
-
|
255 |
-
$('#cdn_import_library').click(function() {
|
256 |
-
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_import_library', 'cdn_import_library');
|
257 |
-
});
|
258 |
-
|
259 |
-
$('#cdn_queue').click(function() {
|
260 |
-
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_queue', 'cdn_queue');
|
261 |
-
});
|
262 |
-
|
263 |
-
$('.cdn_export').click(function() {
|
264 |
-
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_export&cdn_export_type=' + this.name, 'cdn_export_' + this.name);
|
265 |
-
});
|
266 |
-
|
267 |
-
$('#test_ftp').click(function() {
|
268 |
-
var status = $('#test_ftp_status');
|
269 |
-
status.removeClass('w3tc-error');
|
270 |
-
status.addClass('w3tc-process');
|
271 |
-
status.html('Testing...');
|
272 |
-
$.post('options-general.php', {
|
273 |
-
page: 'w3-total-cache/w3-total-cache.php',
|
274 |
-
w3tc_action: 'cdn_test_ftp',
|
275 |
-
host: $('#cdn_ftp_host').val(),
|
276 |
-
user: $('#cdn_ftp_user').val(),
|
277 |
-
path: $('#cdn_ftp_path').val(),
|
278 |
-
pass: $('#cdn_ftp_pass').val()
|
279 |
-
}, function(data) {
|
280 |
-
status.addClass(data.result ? 'w3tc-success' : 'w3tc-error');
|
281 |
-
status.html(data.error);
|
282 |
-
}, 'json');
|
283 |
-
});
|
284 |
-
|
285 |
-
$('#test_memcached').click(function() {
|
286 |
-
var status = $('#test_memcached_status');
|
287 |
-
status.removeClass('w3tc-error');
|
288 |
-
status.addClass('w3tc-process');
|
289 |
-
status.html('Testing...');
|
290 |
-
$.post('options-general.php', {
|
291 |
-
page: 'w3-total-cache/w3-total-cache.php',
|
292 |
-
w3tc_action: 'test_memcached',
|
293 |
-
servers: $('#memcached_servers').val()
|
294 |
-
}, function(data) {
|
295 |
-
status.addClass(data.result ? 'w3tc-success' : 'w3tc-error');
|
296 |
-
status.html(data.error);
|
297 |
-
}, 'json');
|
298 |
-
});
|
299 |
-
|
300 |
-
var flush_types = ['flush_memcached_pgcache', 'flush_memcached_dbcache', 'flush_memcached_minify'];
|
301 |
-
for (var i = 0; i < flush_types.length; i++) {
|
302 |
-
$('#' + flush_types[i]).click(function(flush_type) {
|
303 |
-
return function() {
|
304 |
-
document.location.href = 'options-general.php?page=w3-total-cache/w3-total-cache.php&' + flush_type;
|
305 |
-
};
|
306 |
-
}(flush_types[i]));
|
307 |
-
}
|
308 |
});
|
1 |
+
function w3tc_popup(url, name, width, height) {
|
2 |
+
if (width === undefined) {
|
3 |
+
width = 800;
|
4 |
+
}
|
5 |
+
if (height === undefined) {
|
6 |
+
height = 600;
|
7 |
+
}
|
8 |
+
|
9 |
+
return window.open(url, name, 'width=' + width + ',height=' + height + ',status=no,toolbar=no,menubar=no,scrollbars=yes');
|
10 |
+
}
|
11 |
+
|
12 |
+
function input_enable(input, enabled) {
|
13 |
+
jQuery(input).each(function() {
|
14 |
+
this.disabled = !enabled;
|
15 |
+
if (enabled) {
|
16 |
+
jQuery(this).next('[type=hidden]').remove();
|
17 |
+
} else {
|
18 |
+
var me = jQuery(this), t = me.attr('type');
|
19 |
+
if ((t != 'radio' && t != 'checkbox') || this.checked) {
|
20 |
+
me.after(jQuery('<input />').attr( {
|
21 |
+
type: 'hidden',
|
22 |
+
name: me.attr('name')
|
23 |
+
}).val(me.val()));
|
24 |
+
}
|
25 |
+
}
|
26 |
+
});
|
27 |
+
}
|
28 |
+
|
29 |
+
function js_file_location_change() {
|
30 |
+
jQuery('.js_file_location').change(function() {
|
31 |
+
jQuery(this).parent().find(':text').attr('name', 'js_files[' + jQuery('#js_groups').val() + '][' + jQuery(this).val() + ']');
|
32 |
+
});
|
33 |
+
}
|
34 |
+
|
35 |
+
function file_verify() {
|
36 |
+
jQuery('.js_file_verify,.css_file_verify').click(function() {
|
37 |
+
var file = jQuery(this).parent().find(':text').val();
|
38 |
+
if (file == '') {
|
39 |
+
alert('Empty file');
|
40 |
+
} else {
|
41 |
+
var url = '';
|
42 |
+
if (/^https?:\/\//.test(file)) {
|
43 |
+
url = file;
|
44 |
+
} else {
|
45 |
+
url = '/' + file;
|
46 |
+
}
|
47 |
+
w3tc_popup(url, 'file_verify');
|
48 |
+
}
|
49 |
+
});
|
50 |
+
}
|
51 |
+
|
52 |
+
function file_validate() {
|
53 |
+
var js = [], css = [], invalid_js = [], invalid_css = [], duplicate = false, query_js = [], query_css = [];
|
54 |
+
|
55 |
+
jQuery('#js_files :text').each(function() {
|
56 |
+
var v = jQuery(this).val();
|
57 |
+
if (v != '') {
|
58 |
+
for ( var i = 0; i < js.length; i++) {
|
59 |
+
if (js[i] == v) {
|
60 |
+
duplicate = true;
|
61 |
+
break;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
js.push(v);
|
66 |
+
|
67 |
+
var qindex = v.indexOf('?');
|
68 |
+
if (qindex != -1) {
|
69 |
+
if (!/^https?:\/\//.test(v)) {
|
70 |
+
query_js.push(v);
|
71 |
+
}
|
72 |
+
v = v.substr(0, qindex);
|
73 |
+
}
|
74 |
+
|
75 |
+
if (!/\.js$/.test(v)) {
|
76 |
+
invalid_js.push(v);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
});
|
80 |
+
|
81 |
+
jQuery('#css_files :text').each(function() {
|
82 |
+
var v = jQuery(this).val();
|
83 |
+
if (v != '') {
|
84 |
+
for ( var i = 0; i < css.length; i++) {
|
85 |
+
if (css[i] == v) {
|
86 |
+
duplicate = true;
|
87 |
+
break;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
css.push(v);
|
92 |
+
|
93 |
+
var qindex = v.indexOf('?');
|
94 |
+
if (qindex != -1) {
|
95 |
+
if (!/^https?:\/\//.test(v)) {
|
96 |
+
query_css.push(v);
|
97 |
+
}
|
98 |
+
v = v.substr(0, qindex);
|
99 |
+
}
|
100 |
+
|
101 |
+
if (!/\.css$/.test(v)) {
|
102 |
+
invalid_css.push(v);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
});
|
106 |
+
|
107 |
+
if (jQuery('#js_enabled:checked').size()) {
|
108 |
+
if (invalid_js.length && !confirm('These files have invalid JS file extension:\r\n\r\n' + invalid_js.join('\r\n') + '\r\n\r\nAre you confident this files contain valid JS code?')) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
if (query_js.length) {
|
113 |
+
alert('These JS files contain query string in the name:\r\n\r\n' + query_js.join('\r\n'));
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
if (jQuery('#css_enabled:checked').size()) {
|
119 |
+
if (invalid_css.length && !confirm('These files have invalid CSS file extension:\r\n\r\n' + invalid_css.join('\r\n') + '\r\n\r\nAre you confident this files contain valid CSS code?')) {
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
|
123 |
+
if (query_css.length) {
|
124 |
+
alert('These CSS files contain query string in the name:\r\n\r\n' + query_css.join('\r\n'));
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
if (duplicate) {
|
130 |
+
alert('Duplicate files have been found in your minify settings, please check your settings again.');
|
131 |
+
return false;
|
132 |
+
}
|
133 |
+
|
134 |
+
return true;
|
135 |
+
}
|
136 |
+
|
137 |
+
function js_file_clear() {
|
138 |
+
if (!jQuery('#js_files :visible').length) {
|
139 |
+
jQuery('#js_files_empty').show();
|
140 |
+
} else {
|
141 |
+
jQuery('#js_files_empty').hide();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
function css_file_clear() {
|
146 |
+
if (!jQuery('#css_files :visible').length) {
|
147 |
+
jQuery('#css_files_empty').show();
|
148 |
+
} else {
|
149 |
+
jQuery('#css_files_empty').hide();
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
function js_enabled() {
|
154 |
+
jQuery('#js_enabled').click(function() {
|
155 |
+
input_enable('.js_enabled', this.checked);
|
156 |
+
});
|
157 |
+
}
|
158 |
+
|
159 |
+
function css_enabled() {
|
160 |
+
jQuery('#css_enabled').click(function() {
|
161 |
+
input_enable('.css_enabled', this.checked);
|
162 |
+
});
|
163 |
+
}
|
164 |
+
|
165 |
+
function js_file_delete() {
|
166 |
+
jQuery('.js_file_delete').click(function() {
|
167 |
+
if (confirm('Are you sure you want to delete JS file?')) {
|
168 |
+
jQuery(this).parent().remove();
|
169 |
+
if (!jQuery('#js_files li').size()) {
|
170 |
+
js_file_clear();
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
return false;
|
175 |
+
});
|
176 |
+
};
|
177 |
+
|
178 |
+
function css_file_delete() {
|
179 |
+
jQuery('.css_file_delete').click(function() {
|
180 |
+
if (confirm('Are you sure you want to delete CSS file?')) {
|
181 |
+
jQuery(this).parent().remove();
|
182 |
+
if (!jQuery('#css_files li').size()) {
|
183 |
+
css_file_clear();
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
return false;
|
188 |
+
});
|
189 |
+
}
|
190 |
+
|
191 |
+
function js_file_add(group, location, file) {
|
192 |
+
jQuery('#js_files').append('<li><input class="js_enabled" type="text" name="js_files[' + group + '][' + location + '][]" value="' + file + '" size="100" \/> <select class="js_file_location js_enabled"><option value="include"' + (location == 'include' ? ' selected="selected"' : '') + '>Embed in: Header</option><option value="include-nb"' + (location == 'include-nb' ? ' selected="selected"' : '') + '>Embed in: Header (non-blocking)</option><option value="include-footer"' + (location == 'include-footer' ? ' selected="selected"' : '') + '>Embed in: Footer</option><option value="include-footer-nb"' + (location == 'include-footer-nb' ? ' selected="selected"' : '') + '>Embed in: Footer (non-blocking)</option></select> <input class="js_file_delete js_enabled button" type="button" value="Delete" /> <input class="js_file_verify js_enabled button" type="button" value="Verify URI" /><\/li>');
|
193 |
+
js_file_clear();
|
194 |
+
js_file_delete();
|
195 |
+
file_verify();
|
196 |
+
js_enabled();
|
197 |
+
js_file_location_change();
|
198 |
+
}
|
199 |
+
|
200 |
+
function css_file_add(group, file) {
|
201 |
+
jQuery('#css_files').append('<li><input class="css_enabled" type="text" name="css_files[' + group + '][include][]" value="' + file + '" size="100" \/> <input class="css_file_delete css_enabled button" type="button" value="Delete" /> <input class="css_file_verify css_enabled button" type="button" value="Verify URI" /><\/li>');
|
202 |
+
css_file_clear();
|
203 |
+
css_file_delete();
|
204 |
+
file_verify();
|
205 |
+
css_enabled();
|
206 |
+
}
|
207 |
+
|
208 |
+
function js_group(group) {
|
209 |
+
jQuery('#js_groups').val(group);
|
210 |
+
jQuery('#js_files :text').each(function() {
|
211 |
+
var input = jQuery(this);
|
212 |
+
if (input.attr('name').indexOf('js_files[' + group) != 0) {
|
213 |
+
input.parent().hide();
|
214 |
+
} else {
|
215 |
+
input.parent().show();
|
216 |
+
}
|
217 |
+
});
|
218 |
+
js_file_clear();
|
219 |
+
}
|
220 |
+
|
221 |
+
function css_group(group) {
|
222 |
+
jQuery('#css_groups').val(group);
|
223 |
+
jQuery('#css_files :text').each(function() {
|
224 |
+
var input = jQuery(this);
|
225 |
+
if (input.attr('name').indexOf('css_files[' + group) != 0) {
|
226 |
+
input.parent().hide();
|
227 |
+
} else {
|
228 |
+
input.parent().show();
|
229 |
+
}
|
230 |
+
});
|
231 |
+
css_file_clear();
|
232 |
}
|
233 |
|
234 |
jQuery(function($) {
|
235 |
+
// general page
|
236 |
+
$('.enabled').click(function() {
|
237 |
+
var checked = false;
|
238 |
+
$('.enabled').each(function() {
|
239 |
+
if (this.checked) {
|
240 |
+
checked = true;
|
241 |
+
}
|
242 |
+
});
|
243 |
+
$('#enabled').each(function() {
|
244 |
+
this.checked = checked;
|
245 |
+
});
|
246 |
+
});
|
247 |
+
|
248 |
+
$('#enabled').click(function() {
|
249 |
+
var checked = this.checked;
|
250 |
+
$('.enabled').each(function() {
|
251 |
+
this.checked = checked;
|
252 |
+
});
|
253 |
+
});
|
254 |
+
|
255 |
+
// minify page
|
256 |
+
input_enable('.html_enabled', $('#html_enabled:checked').size());
|
257 |
+
input_enable('.js_enabled', $('#js_enabled:checked').size());
|
258 |
+
input_enable('.css_enabled', $('#css_enabled:checked').size());
|
259 |
+
|
260 |
+
$('#html_enabled').click(function() {
|
261 |
+
input_enable('.html_enabled', this.checked);
|
262 |
+
});
|
263 |
+
|
264 |
+
file_verify();
|
265 |
+
js_file_location_change();
|
266 |
+
|
267 |
+
js_enabled();
|
268 |
+
css_enabled();
|
269 |
+
|
270 |
+
js_file_delete();
|
271 |
+
css_file_delete();
|
272 |
+
|
273 |
+
js_group('default');
|
274 |
+
css_group('default');
|
275 |
+
|
276 |
+
$('#js_file_add').click(function() {
|
277 |
+
js_file_add($('#js_groups').val(), 'include', '');
|
278 |
+
});
|
279 |
+
|
280 |
+
$('#css_file_add').click(function() {
|
281 |
+
css_file_add($('#css_groups').val(), '');
|
282 |
+
});
|
283 |
+
|
284 |
+
$('#js_groups').change(function() {
|
285 |
+
js_group($(this).val());
|
286 |
+
});
|
287 |
+
|
288 |
+
$('#css_groups').change(function() {
|
289 |
+
css_group($(this).val());
|
290 |
+
});
|
291 |
+
|
292 |
+
$('#minify_form').submit(file_validate);
|
293 |
+
|
294 |
+
// CDN
|
295 |
+
$('.w3tc-tab').click(function() {
|
296 |
+
$('.w3tc-tab-content').hide();
|
297 |
+
$(this.rel).show();
|
298 |
+
});
|
299 |
+
|
300 |
+
$('#cdn_export_library').click(function() {
|
301 |
+
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_export_library', 'cdn_export_library');
|
302 |
+
});
|
303 |
+
|
304 |
+
$('#cdn_import_library').click(function() {
|
305 |
+
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_import_library', 'cdn_import_library');
|
306 |
+
});
|
307 |
+
|
308 |
+
$('#cdn_queue').click(function() {
|
309 |
+
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_queue', 'cdn_queue');
|
310 |
+
});
|
311 |
+
|
312 |
+
$('#cdn_rename_domain').click(function() {
|
313 |
+
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_rename_domain', 'cdn_rename_domain');
|
314 |
+
});
|
315 |
+
|
316 |
+
$('.cdn_export').click(function() {
|
317 |
+
w3tc_popup('options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=cdn_export&cdn_export_type=' + this.name, 'cdn_export_' + this.name);
|
318 |
+
});
|
319 |
+
|
320 |
+
$('#test_ftp').click(function() {
|
321 |
+
var status = $('#test_ftp_status');
|
322 |
+
status.removeClass('w3tc-error');
|
323 |
+
status.addClass('w3tc-process');
|
324 |
+
status.html('Testing...');
|
325 |
+
$.post('options-general.php', {
|
326 |
+
page: 'w3-total-cache/w3-total-cache.php',
|
327 |
+
w3tc_action: 'cdn_test_ftp',
|
328 |
+
host: $('#cdn_ftp_host').val(),
|
329 |
+
user: $('#cdn_ftp_user').val(),
|
330 |
+
path: $('#cdn_ftp_path').val(),
|
331 |
+
pass: $('#cdn_ftp_pass').val()
|
332 |
+
}, function(data) {
|
333 |
+
status.addClass(data.result ? 'w3tc-success' : 'w3tc-error');
|
334 |
+
status.html(data.error);
|
335 |
+
}, 'json');
|
336 |
+
});
|
337 |
+
|
338 |
+
$('#test_memcached').click(function() {
|
339 |
+
var status = $('#test_memcached_status');
|
340 |
+
status.removeClass('w3tc-error');
|
341 |
+
status.addClass('w3tc-process');
|
342 |
+
status.html('Testing...');
|
343 |
+
$.post('options-general.php', {
|
344 |
+
page: 'w3-total-cache/w3-total-cache.php',
|
345 |
+
w3tc_action: 'test_memcached',
|
346 |
+
servers: $('#memcached_servers').val()
|
347 |
+
}, function(data) {
|
348 |
+
status.addClass(data.result ? 'w3tc-success' : 'w3tc-error');
|
349 |
+
status.html(data.error);
|
350 |
+
}, 'json');
|
351 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
});
|
inc/js/popup.js
CHANGED
@@ -1,399 +1,813 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
};
|
121 |
|
122 |
-
var Cdn_Export_Library =
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
};
|
234 |
|
235 |
-
var Cdn_Import_Library =
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
};
|
383 |
|
384 |
-
jQuery(function($)
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
|
|
|
|
|
|
|
|
399 |
});
|
1 |
+
function seconds_to_string(seconds)
|
2 |
+
{
|
3 |
+
var string = '', days = 0, hours = 0, minutes = 0;
|
4 |
+
days = Math.floor(seconds / 86400);
|
5 |
+
if (days) {
|
6 |
+
seconds -= days * 86400;
|
7 |
+
string += days + 'd ';
|
8 |
+
}
|
9 |
+
hours = Math.floor(seconds / 3600);
|
10 |
+
if (hours) {
|
11 |
+
seconds -= hours * 3600;
|
12 |
+
string += hours + 'h ';
|
13 |
+
}
|
14 |
+
minutes = Math.floor(seconds / 60);
|
15 |
+
if (minutes) {
|
16 |
+
seconds -= minutes * 60;
|
17 |
+
string += minutes + 'm ';
|
18 |
+
}
|
19 |
+
|
20 |
+
if (seconds) {
|
21 |
+
string += seconds + 's';
|
22 |
+
}
|
23 |
+
|
24 |
+
return string;
|
25 |
+
}
|
26 |
+
|
27 |
+
var Cdn_Export_File =
|
28 |
+
{
|
29 |
+
paused: 0,
|
30 |
+
limit: 25,
|
31 |
+
offset: 0,
|
32 |
+
files: [],
|
33 |
+
upload_files: [],
|
34 |
+
retry_seconds: 10,
|
35 |
+
seconds_elapsed: 0,
|
36 |
+
timer: null,
|
37 |
+
|
38 |
+
set_progress: function(percent)
|
39 |
+
{
|
40 |
+
jQuery('#cdn_export_file_progress .progress-bar').width(percent + '%');
|
41 |
+
jQuery('#cdn_export_file_progress .progress-value').html(percent + '%');
|
42 |
+
},
|
43 |
+
|
44 |
+
set_status: function(status)
|
45 |
+
{
|
46 |
+
jQuery('#cdn_export_file_status').html(status);
|
47 |
+
},
|
48 |
+
|
49 |
+
set_processed: function(processed)
|
50 |
+
{
|
51 |
+
jQuery('#cdn_export_file_processed').html(processed);
|
52 |
+
},
|
53 |
+
|
54 |
+
set_button_text: function(text)
|
55 |
+
{
|
56 |
+
jQuery('#cdn_export_file_start').val(text);
|
57 |
+
},
|
58 |
+
|
59 |
+
set_last_response: function()
|
60 |
+
{
|
61 |
+
var date = new Date();
|
62 |
+
jQuery('#cdn_export_file_last_response').html(date.toLocaleTimeString() + ' ' + date.toLocaleDateString());
|
63 |
+
},
|
64 |
+
|
65 |
+
set_elapsed: function(text)
|
66 |
+
{
|
67 |
+
jQuery('#cdn_export_file_elapsed').html(text);
|
68 |
+
},
|
69 |
+
|
70 |
+
add_log: function(path, result, error)
|
71 |
+
{
|
72 |
+
jQuery('#cdn_export_file_log').prepend('<div class="log-' + (result == 1 ? 'success' : 'error') + '">' + path + ' <strong>' + error + '</strong></div>');
|
73 |
+
},
|
74 |
+
|
75 |
+
clear_log: function()
|
76 |
+
{
|
77 |
+
jQuery('#cdn_export_library_log').val('');
|
78 |
+
},
|
79 |
+
|
80 |
+
process: function()
|
81 |
+
{
|
82 |
+
if (this.paused) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
this.upload_files = [];
|
87 |
+
|
88 |
+
for ( var i = this.offset, l = this.files.length, j = 0; i < l && j < this.limit; i++, j++) {
|
89 |
+
this.upload_files.push(this.files[i]);
|
90 |
+
}
|
91 |
+
|
92 |
+
var me = this;
|
93 |
+
if (this.upload_files.length) {
|
94 |
+
jQuery.ajax(
|
95 |
+
{
|
96 |
+
type: 'POST',
|
97 |
+
url: 'options-general.php',
|
98 |
+
data:
|
99 |
+
{
|
100 |
+
page: 'w3-total-cache/w3-total-cache.php',
|
101 |
+
w3tc_action: 'cdn_export_process',
|
102 |
+
'files[]': this.upload_files
|
103 |
+
},
|
104 |
+
dataType: 'json',
|
105 |
+
success: function(data)
|
106 |
+
{
|
107 |
+
me.set_last_response();
|
108 |
+
me.process_callback(data);
|
109 |
+
},
|
110 |
+
error: function()
|
111 |
+
{
|
112 |
+
me.set_last_response();
|
113 |
+
me.retry(me.retry_seconds);
|
114 |
+
}
|
115 |
+
});
|
116 |
+
}
|
117 |
+
},
|
118 |
+
|
119 |
+
retry: function(seconds)
|
120 |
+
{
|
121 |
+
if (this.paused) {
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
this.set_status('request failed (retry in ' + seconds + 's)');
|
125 |
+
if (seconds) {
|
126 |
+
var me = this;
|
127 |
+
setTimeout(function()
|
128 |
+
{
|
129 |
+
me.retry(--seconds);
|
130 |
+
}, 1000);
|
131 |
+
} else {
|
132 |
+
this.set_status('processing');
|
133 |
+
this.process();
|
134 |
+
}
|
135 |
+
},
|
136 |
+
|
137 |
+
process_callback: function(data)
|
138 |
+
{
|
139 |
+
var failed = false;
|
140 |
+
for ( var i = 0; i < data.results.length; i++) {
|
141 |
+
this.add_log(data.results[i].remote_path, data.results[i].result, data.results[i].error);
|
142 |
+
if (data.results[i].result == -1) {
|
143 |
+
failed = true;
|
144 |
+
break;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
if (failed) {
|
149 |
+
this.set_progress(0);
|
150 |
+
this.set_processed(1);
|
151 |
+
this.set_status('failed');
|
152 |
+
this.set_button_text('Start');
|
153 |
+
clearInterval(this.timer);
|
154 |
+
} else {
|
155 |
+
this.offset += this.upload_files.length;
|
156 |
+
this.set_progress((this.offset * 100 / files.length).toFixed(0));
|
157 |
+
this.set_processed(this.offset);
|
158 |
+
|
159 |
+
if (this.offset < this.files.length) {
|
160 |
+
this.process();
|
161 |
+
} else {
|
162 |
+
this.set_status('done');
|
163 |
+
this.set_button_text('Start');
|
164 |
+
clearInterval(this.timer);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
},
|
168 |
+
|
169 |
+
timer_callback: function()
|
170 |
+
{
|
171 |
+
this.seconds_elapsed++;
|
172 |
+
this.set_elapsed(seconds_to_string(this.seconds_elapsed));
|
173 |
+
},
|
174 |
+
|
175 |
+
init: function(files, cdn_url)
|
176 |
+
{
|
177 |
+
if (files === undefined) {
|
178 |
+
files = [];
|
179 |
+
}
|
180 |
+
|
181 |
+
this.files = files;
|
182 |
+
|
183 |
+
var me = this;
|
184 |
+
jQuery('#cdn_export_file_start').click(function()
|
185 |
+
{
|
186 |
+
if (this.value == 'Pause') {
|
187 |
+
me.paused = 1;
|
188 |
+
me.set_button_text('Resume');
|
189 |
+
me.set_status('paused');
|
190 |
+
clearInterval(me.timer);
|
191 |
+
} else {
|
192 |
+
if (this.value == 'Start') {
|
193 |
+
me.offset = 0;
|
194 |
+
me.seconds_elapsed = 0;
|
195 |
+
me.clear_log();
|
196 |
+
me.set_elapsed('-');
|
197 |
+
}
|
198 |
+
me.paused = 0;
|
199 |
+
me.set_button_text('Pause');
|
200 |
+
me.set_status('processing');
|
201 |
+
me.timer = setInterval(function()
|
202 |
+
{
|
203 |
+
me.timer_callback();
|
204 |
+
}, 1000);
|
205 |
+
}
|
206 |
+
|
207 |
+
me.process();
|
208 |
+
});
|
209 |
+
}
|
210 |
};
|
211 |
|
212 |
+
var Cdn_Export_Library =
|
213 |
+
{
|
214 |
+
paused: 0,
|
215 |
+
limit: 25,
|
216 |
+
offset: 0,
|
217 |
+
retry_seconds: 10,
|
218 |
+
seconds_elapsed: 0,
|
219 |
+
timer: null,
|
220 |
+
|
221 |
+
set_progress: function(percent)
|
222 |
+
{
|
223 |
+
jQuery('#cdn_export_library_progress .progress-bar').width(percent + '%');
|
224 |
+
jQuery('#cdn_export_library_progress .progress-value').html(percent + '%');
|
225 |
+
},
|
226 |
+
|
227 |
+
set_status: function(status)
|
228 |
+
{
|
229 |
+
jQuery('#cdn_export_library_status').html(status);
|
230 |
+
},
|
231 |
+
|
232 |
+
set_processed: function(processed)
|
233 |
+
{
|
234 |
+
jQuery('#cdn_export_library_processed').html(processed);
|
235 |
+
},
|
236 |
+
|
237 |
+
set_total: function(total)
|
238 |
+
{
|
239 |
+
jQuery('#cdn_export_library_total').html(total);
|
240 |
+
},
|
241 |
+
|
242 |
+
set_button_text: function(text)
|
243 |
+
{
|
244 |
+
jQuery('#cdn_export_library_start').val(text);
|
245 |
+
},
|
246 |
+
|
247 |
+
set_last_response: function()
|
248 |
+
{
|
249 |
+
var date = new Date();
|
250 |
+
jQuery('#cdn_export_library_last_response').html(date.toLocaleTimeString() + ' ' + date.toLocaleDateString());
|
251 |
+
},
|
252 |
+
|
253 |
+
set_elapsed: function(text)
|
254 |
+
{
|
255 |
+
jQuery('#cdn_export_library_elapsed').html(text);
|
256 |
+
},
|
257 |
+
|
258 |
+
add_log: function(path, result, error)
|
259 |
+
{
|
260 |
+
jQuery('#cdn_export_library_log').prepend('<div class="log-' + (result == 1 ? 'success' : 'error') + '">' + path + ' <strong>' + error + '</strong></div>');
|
261 |
+
},
|
262 |
+
|
263 |
+
clear_log: function()
|
264 |
+
{
|
265 |
+
jQuery('#cdn_export_library_log').html('');
|
266 |
+
},
|
267 |
+
|
268 |
+
process: function()
|
269 |
+
{
|
270 |
+
if (this.paused) {
|
271 |
+
return;
|
272 |
+
}
|
273 |
+
|
274 |
+
var me = this;
|
275 |
+
jQuery.ajax(
|
276 |
+
{
|
277 |
+
type: 'POST',
|
278 |
+
url: 'options-general.php',
|
279 |
+
data:
|
280 |
+
{
|
281 |
+
page: 'w3-total-cache/w3-total-cache.php',
|
282 |
+
w3tc_action: 'cdn_export_library_process',
|
283 |
+
limit: this.limit,
|
284 |
+
offset: this.offset
|
285 |
+
},
|
286 |
+
dataType: 'json',
|
287 |
+
success: function(data)
|
288 |
+
{
|
289 |
+
me.set_last_response();
|
290 |
+
me.process_callback(data);
|
291 |
+
},
|
292 |
+
error: function()
|
293 |
+
{
|
294 |
+
me.set_last_response();
|
295 |
+
me.retry(me.retry_seconds);
|
296 |
+
}
|
297 |
+
});
|
298 |
+
},
|
299 |
+
|
300 |
+
retry: function(seconds)
|
301 |
+
{
|
302 |
+
if (this.paused) {
|
303 |
+
return;
|
304 |
+
}
|
305 |
+
this.set_status('request failed (retry in ' + seconds + 's)');
|
306 |
+
if (seconds) {
|
307 |
+
var me = this;
|
308 |
+
setTimeout(function()
|
309 |
+
{
|
310 |
+
me.retry(--seconds);
|
311 |
+
}, 1000);
|
312 |
+
} else {
|
313 |
+
this.set_status('processing');
|
314 |
+
this.process();
|
315 |
+
}
|
316 |
+
},
|
317 |
+
|
318 |
+
process_callback: function(data, status)
|
319 |
+
{
|
320 |
+
this.offset += data.count;
|
321 |
+
|
322 |
+
this.set_total(data.total);
|
323 |
+
this.set_processed(this.offset);
|
324 |
+
this.set_progress((this.offset * 100 / data.total).toFixed(0));
|
325 |
+
|
326 |
+
var failed = false;
|
327 |
+
for ( var i = 0; i < data.results.length; i++) {
|
328 |
+
this.add_log(data.results[i].remote_path, data.results[i].result, data.results[i].error);
|
329 |
+
if (data.results[i].result == -1) {
|
330 |
+
failed = true;
|
331 |
+
break;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
if (failed) {
|
336 |
+
this.set_progress(0);
|
337 |
+
this.set_processed(1);
|
338 |
+
this.set_status('failed');
|
339 |
+
this.set_button_text('Start');
|
340 |
+
clearInterval(this.timer);
|
341 |
+
} else {
|
342 |
+
if (this.offset < data.total) {
|
343 |
+
this.process();
|
344 |
+
} else {
|
345 |
+
this.set_status('done');
|
346 |
+
this.set_button_text('Start');
|
347 |
+
clearInterval(this.timer);
|
348 |
+
}
|
349 |
+
}
|
350 |
+
},
|
351 |
+
|
352 |
+
timer_callback: function()
|
353 |
+
{
|
354 |
+
this.seconds_elapsed++;
|
355 |
+
this.set_elapsed(seconds_to_string(this.seconds_elapsed));
|
356 |
+
},
|
357 |
+
|
358 |
+
init: function()
|
359 |
+
{
|
360 |
+
var me = this;
|
361 |
+
jQuery('#cdn_export_library_start').click(function()
|
362 |
+
{
|
363 |
+
if (this.value == 'Pause') {
|
364 |
+
me.paused = 1;
|
365 |
+
me.set_status('paused');
|
366 |
+
me.set_button_text('Resume');
|
367 |
+
clearInterval(me.timer);
|
368 |
+
} else {
|
369 |
+
if (this.value == 'Start') {
|
370 |
+
me.offset = 0;
|
371 |
+
me.seconds_elapsed = 0;
|
372 |
+
me.clear_log();
|
373 |
+
me.set_elapsed('-');
|
374 |
+
}
|
375 |
+
me.paused = 0;
|
376 |
+
me.set_status('processing');
|
377 |
+
me.set_button_text('Pause');
|
378 |
+
me.timer = setInterval(function()
|
379 |
+
{
|
380 |
+
me.timer_callback();
|
381 |
+
}, 1000);
|
382 |
+
}
|
383 |
+
|
384 |
+
me.process();
|
385 |
+
});
|
386 |
+
}
|
387 |
};
|
388 |
|
389 |
+
var Cdn_Import_Library =
|
390 |
+
{
|
391 |
+
paused: 0,
|
392 |
+
limit: 5,
|
393 |
+
offset: 0,
|
394 |
+
cdn_host: '',
|
395 |
+
retry_seconds: 10,
|
396 |
+
seconds_elapsed: 0,
|
397 |
+
timer: null,
|
398 |
+
|
399 |
+
set_progress: function(percent)
|
400 |
+
{
|
401 |
+
jQuery('#cdn_import_library_progress .progress-bar').width(percent + '%');
|
402 |
+
jQuery('#cdn_import_library_progress .progress-value').html(percent + '%');
|
403 |
+
},
|
404 |
+
|
405 |
+
set_status: function(status)
|
406 |
+
{
|
407 |
+
jQuery('#cdn_import_library_status').html(status);
|
408 |
+
},
|
409 |
+
|
410 |
+
set_processed: function(processed)
|
411 |
+
{
|
412 |
+
jQuery('#cdn_import_library_processed').html(processed);
|
413 |
+
},
|
414 |
+
|
415 |
+
set_total: function(total)
|
416 |
+
{
|
417 |
+
jQuery('#cdn_import_library_total').html(total);
|
418 |
+
},
|
419 |
+
|
420 |
+
set_button_text: function(text)
|
421 |
+
{
|
422 |
+
jQuery('#cdn_import_library_start').val(text);
|
423 |
+
},
|
424 |
+
|
425 |
+
set_last_response: function()
|
426 |
+
{
|
427 |
+
var date = new Date();
|
428 |
+
jQuery('#cdn_import_library_last_response').html(date.toLocaleTimeString() + ' ' + date.toLocaleDateString());
|
429 |
+
},
|
430 |
+
|
431 |
+
set_elapsed: function(text)
|
432 |
+
{
|
433 |
+
jQuery('#cdn_import_library_elapsed').html(text);
|
434 |
+
},
|
435 |
+
|
436 |
+
is_redirect_permanent: function()
|
437 |
+
{
|
438 |
+
return (jQuery('#cdn_import_library_redirect_permanent:checked').size() > 0);
|
439 |
+
},
|
440 |
+
|
441 |
+
is_redirect_cdn: function()
|
442 |
+
{
|
443 |
+
return (jQuery('#cdn_import_library_redirect_cdn:checked').size() > 0);
|
444 |
+
},
|
445 |
+
|
446 |
+
add_log: function(path, result, error)
|
447 |
+
{
|
448 |
+
jQuery('#cdn_import_library_log').prepend('<div class="log-' + (result == 1 ? 'success' : 'error') + '">' + path + ' <strong>' + error + '</strong></div>');
|
449 |
+
},
|
450 |
+
|
451 |
+
clear_log: function()
|
452 |
+
{
|
453 |
+
jQuery('#cdn_import_library_log').html('');
|
454 |
+
},
|
455 |
+
|
456 |
+
add_rule: function(src, dst)
|
457 |
+
{
|
458 |
+
if (/^https?:\/\//.test(src)) {
|
459 |
+
return;
|
460 |
+
}
|
461 |
+
|
462 |
+
if (this.is_redirect_cdn()) {
|
463 |
+
dst = 'http://' + (this.cdn_host ? this.cdn_host : document.location.host) + '/' + dst;
|
464 |
+
} else {
|
465 |
+
dst = '/' + dst;
|
466 |
+
}
|
467 |
+
|
468 |
+
if (src.indexOf('/') != 0) {
|
469 |
+
src = '/' + src;
|
470 |
+
}
|
471 |
+
|
472 |
+
var rules = jQuery('#cdn_import_library_rules');
|
473 |
+
rules.val(rules.val() + 'Redirect ' + (this.is_redirect_permanent() ? '302 ' : '') + src + ' ' + dst + '\r\n');
|
474 |
+
},
|
475 |
+
|
476 |
+
clear_rules: function()
|
477 |
+
{
|
478 |
+
jQuery('#cdn_import_library_rules').val('');
|
479 |
+
},
|
480 |
+
|
481 |
+
process: function()
|
482 |
+
{
|
483 |
+
if (this.paused) {
|
484 |
+
return;
|
485 |
+
}
|
486 |
+
|
487 |
+
var me = this;
|
488 |
+
jQuery.ajax(
|
489 |
+
{
|
490 |
+
type: 'POST',
|
491 |
+
url: 'options-general.php',
|
492 |
+
data:
|
493 |
+
{
|
494 |
+
page: 'w3-total-cache/w3-total-cache.php',
|
495 |
+
w3tc_action: 'cdn_import_library_process',
|
496 |
+
limit: this.limit,
|
497 |
+
offset: this.offset
|
498 |
+
},
|
499 |
+
dataType: 'json',
|
500 |
+
success: function(data)
|
501 |
+
{
|
502 |
+
me.set_last_response();
|
503 |
+
me.process_callback(data);
|
504 |
+
},
|
505 |
+
error: function()
|
506 |
+
{
|
507 |
+
me.set_last_response();
|
508 |
+
me.retry(me.retry_seconds);
|
509 |
+
}
|
510 |
+
});
|
511 |
+
},
|
512 |
+
|
513 |
+
retry: function(seconds)
|
514 |
+
{
|
515 |
+
if (this.paused) {
|
516 |
+
return;
|
517 |
+
}
|
518 |
+
this.set_status('request failed (retry in ' + seconds + 's)');
|
519 |
+
if (seconds) {
|
520 |
+
var me = this;
|
521 |
+
setTimeout(function()
|
522 |
+
{
|
523 |
+
me.retry(--seconds);
|
524 |
+
}, 1000);
|
525 |
+
} else {
|
526 |
+
this.set_status('processing');
|
527 |
+
this.process();
|
528 |
+
}
|
529 |
+
},
|
530 |
+
|
531 |
+
process_callback: function(data)
|
532 |
+
{
|
533 |
+
this.offset += data.count;
|
534 |
+
|
535 |
+
this.set_total(data.total);
|
536 |
+
this.set_processed(this.offset);
|
537 |
+
this.set_progress((this.offset * 100 / data.total).toFixed(0));
|
538 |
+
|
539 |
+
var failed = false;
|
540 |
+
for ( var i = 0; i < data.results.length; i++) {
|
541 |
+
this.add_log(data.results[i].src, data.results[i].result, data.results[i].error);
|
542 |
+
if (data.results[i].result == 1) {
|
543 |
+
this.add_rule(data.results[i].src, data.results[i].dst);
|
544 |
+
} else if (data.results[i].result == -1) {
|
545 |
+
failed = true;
|
546 |
+
break;
|
547 |
+
}
|
548 |
+
}
|
549 |
+
|
550 |
+
if (failed) {
|
551 |
+
this.set_progress(0);
|
552 |
+
this.set_processed(1);
|
553 |
+
this.set_status('failed');
|
554 |
+
this.set_button_text('Start');
|
555 |
+
clearInterval(this.timer);
|
556 |
+
} else {
|
557 |
+
if (this.offset < data.total) {
|
558 |
+
this.process();
|
559 |
+
} else {
|
560 |
+
this.set_status('done');
|
561 |
+
this.set_button_text('Start');
|
562 |
+
clearInterval(this.timer);
|
563 |
+
}
|
564 |
+
}
|
565 |
+
},
|
566 |
+
|
567 |
+
timer_callback: function()
|
568 |
+
{
|
569 |
+
this.seconds_elapsed++;
|
570 |
+
this.set_elapsed(seconds_to_string(this.seconds_elapsed));
|
571 |
+
},
|
572 |
+
|
573 |
+
init: function(cdn_host)
|
574 |
+
{
|
575 |
+
var me = this;
|
576 |
+
this.cdn_host = cdn_host;
|
577 |
+
jQuery('#cdn_import_library_start').click(function()
|
578 |
+
{
|
579 |
+
if (this.value == 'Pause') {
|
580 |
+
me.paused = 1;
|
581 |
+
me.set_button_text('Resume');
|
582 |
+
me.set_status('paused');
|
583 |
+
clearInterval(me.timer);
|
584 |
+
} else {
|
585 |
+
if (this.value == 'Start') {
|
586 |
+
me.offset = 0;
|
587 |
+
me.seconds_elapsed = 0;
|
588 |
+
me.clear_log();
|
589 |
+
me.clear_rules();
|
590 |
+
me.set_elapsed('-');
|
591 |
+
}
|
592 |
+
me.paused = 0;
|
593 |
+
me.set_button_text('Pause');
|
594 |
+
me.set_status('processing');
|
595 |
+
me.timer = setInterval(function()
|
596 |
+
{
|
597 |
+
me.timer_callback();
|
598 |
+
}, 1000);
|
599 |
+
}
|
600 |
+
|
601 |
+
me.process();
|
602 |
+
});
|
603 |
+
}
|
604 |
+
};
|
605 |
+
|
606 |
+
var Cdn_Rename_Domain =
|
607 |
+
{
|
608 |
+
paused: 0,
|
609 |
+
limit: 25,
|
610 |
+
offset: 0,
|
611 |
+
retry_seconds: 10,
|
612 |
+
seconds_elapsed: 0,
|
613 |
+
timer: null,
|
614 |
+
|
615 |
+
set_progress: function(percent)
|
616 |
+
{
|
617 |
+
jQuery('#cdn_rename_domain_progress .progress-bar').width(percent + '%');
|
618 |
+
jQuery('#cdn_rename_domain_progress .progress-value').html(percent + '%');
|
619 |
+
},
|
620 |
+
|
621 |
+
set_status: function(status)
|
622 |
+
{
|
623 |
+
jQuery('cdn_rename_domain_status').html(status);
|
624 |
+
},
|
625 |
+
|
626 |
+
set_processed: function(processed)
|
627 |
+
{
|
628 |
+
jQuery('#cdn_rename_domain_processed').html(processed);
|
629 |
+
},
|
630 |
+
|
631 |
+
set_total: function(total)
|
632 |
+
{
|
633 |
+
jQuery('#cdn_rename_domain_total').html(total);
|
634 |
+
},
|
635 |
+
|
636 |
+
set_button_text: function(text)
|
637 |
+
{
|
638 |
+
jQuery('#cdn_rename_domain_start').val(text);
|
639 |
+
},
|
640 |
+
|
641 |
+
set_last_response: function()
|
642 |
+
{
|
643 |
+
var date = new Date();
|
644 |
+
jQuery('#cdn_rename_domain_last_response').html(date.toLocaleTimeString() + ' ' + date.toLocaleDateString());
|
645 |
+
},
|
646 |
+
|
647 |
+
set_elapsed: function(text)
|
648 |
+
{
|
649 |
+
jQuery('#cdn_rename_domain_elapsed').html(text);
|
650 |
+
},
|
651 |
+
|
652 |
+
add_log: function(path, result, error)
|
653 |
+
{
|
654 |
+
jQuery('#cdn_rename_domain_log').prepend('<div class="log-' + (result == 1 ? 'success' : 'error') + '">' + path + ' <strong>' + error + '</strong></div>');
|
655 |
+
},
|
656 |
+
|
657 |
+
clear_log: function()
|
658 |
+
{
|
659 |
+
jQuery('#cdn_rename_domain_log').html('');
|
660 |
+
},
|
661 |
+
|
662 |
+
get_domain_names: function()
|
663 |
+
{
|
664 |
+
return jQuery('#cdn_rename_domain_names').val();
|
665 |
+
},
|
666 |
+
|
667 |
+
process: function()
|
668 |
+
{
|
669 |
+
if (this.paused) {
|
670 |
+
return;
|
671 |
+
}
|
672 |
+
|
673 |
+
var me = this;
|
674 |
+
jQuery.ajax(
|
675 |
+
{
|
676 |
+
type: 'POST',
|
677 |
+
url: 'options-general.php',
|
678 |
+
data:
|
679 |
+
{
|
680 |
+
page: 'w3-total-cache/w3-total-cache.php',
|
681 |
+
w3tc_action: 'cdn_rename_domain_process',
|
682 |
+
names: this.get_domain_names(),
|
683 |
+
limit: this.limit,
|
684 |
+
offset: this.offset
|
685 |
+
},
|
686 |
+
dataType: 'json',
|
687 |
+
success: function(data)
|
688 |
+
{
|
689 |
+
me.set_last_response();
|
690 |
+
me.process_callback(data);
|
691 |
+
},
|
692 |
+
error: function()
|
693 |
+
{
|
694 |
+
me.set_last_response();
|
695 |
+
me.retry(me.retry_seconds);
|
696 |
+
}
|
697 |
+
});
|
698 |
+
},
|
699 |
+
|
700 |
+
retry: function(seconds)
|
701 |
+
{
|
702 |
+
if (this.paused) {
|
703 |
+
return;
|
704 |
+
}
|
705 |
+
this.set_status('request failed (retry in ' + seconds + 's)');
|
706 |
+
if (seconds) {
|
707 |
+
var me = this;
|
708 |
+
setTimeout(function()
|
709 |
+
{
|
710 |
+
me.retry(--seconds);
|
711 |
+
}, 1000);
|
712 |
+
} else {
|
713 |
+
this.set_status('processing');
|
714 |
+
this.process();
|
715 |
+
}
|
716 |
+
},
|
717 |
+
|
718 |
+
process_callback: function(data)
|
719 |
+
{
|
720 |
+
this.offset += data.count;
|
721 |
+
|
722 |
+
this.set_total(data.total);
|
723 |
+
this.set_processed(this.offset);
|
724 |
+
this.set_progress((this.offset * 100 / data.total).toFixed(0));
|
725 |
+
|
726 |
+
var failed = false;
|
727 |
+
for ( var i = 0; i < data.results.length; i++) {
|
728 |
+
this.add_log(data.results[i].old, data.results[i].result, data.results[i].error);
|
729 |
+
if (data.results[i].result == -1) {
|
730 |
+
failed = true;
|
731 |
+
break;
|
732 |
+
}
|
733 |
+
}
|
734 |
+
|
735 |
+
if (failed) {
|
736 |
+
this.set_progress(0);
|
737 |
+
this.set_processed(1);
|
738 |
+
this.set_status('failed');
|
739 |
+
this.set_button_text('Start');
|
740 |
+
clearInterval(this.timer);
|
741 |
+
} else {
|
742 |
+
if (this.offset < data.total) {
|
743 |
+
this.process();
|
744 |
+
} else {
|
745 |
+
this.set_status('done');
|
746 |
+
this.set_button_text('Start');
|
747 |
+
clearInterval(this.timer);
|
748 |
+
}
|
749 |
+
}
|
750 |
+
},
|
751 |
+
|
752 |
+
timer_callback: function()
|
753 |
+
{
|
754 |
+
this.seconds_elapsed++;
|
755 |
+
this.set_elapsed(seconds_to_string(this.seconds_elapsed));
|
756 |
+
},
|
757 |
+
|
758 |
+
init: function(cdn_host)
|
759 |
+
{
|
760 |
+
var me = this;
|
761 |
+
this.cdn_host = cdn_host;
|
762 |
+
jQuery('#cdn_rename_domain_start').click(function()
|
763 |
+
{
|
764 |
+
if (this.value == 'Pause') {
|
765 |
+
me.paused = 1;
|
766 |
+
me.set_button_text('Resume');
|
767 |
+
me.set_status('paused');
|
768 |
+
clearInterval(me.timer);
|
769 |
+
} else {
|
770 |
+
if (this.value == 'Start') {
|
771 |
+
if (!me.get_domain_names()) {
|
772 |
+
alert('Empty domains to rename!');
|
773 |
+
return;
|
774 |
+
}
|
775 |
+
me.offset = 0;
|
776 |
+
me.seconds_elapsed = 0;
|
777 |
+
me.clear_log();
|
778 |
+
me.set_elapsed('-');
|
779 |
+
}
|
780 |
+
me.paused = 0;
|
781 |
+
me.set_button_text('Pause');
|
782 |
+
me.set_status('processing');
|
783 |
+
me.timer = setInterval(function()
|
784 |
+
{
|
785 |
+
me.timer_callback();
|
786 |
+
}, 1000);
|
787 |
+
}
|
788 |
+
|
789 |
+
me.process();
|
790 |
+
});
|
791 |
+
}
|
792 |
};
|
793 |
|
794 |
+
jQuery(function($)
|
795 |
+
{
|
796 |
+
$('.tab').click(function()
|
797 |
+
{
|
798 |
+
$('.tab').removeClass('tab-selected');
|
799 |
+
$('.tab-content').hide();
|
800 |
+
$(this).addClass('tab-selected');
|
801 |
+
$(this.rel).show();
|
802 |
+
});
|
803 |
+
|
804 |
+
$('.cdn_queue_delete').click(function()
|
805 |
+
{
|
806 |
+
return confirm('Are you sure you want to delete this file from the queue?');
|
807 |
+
});
|
808 |
+
|
809 |
+
$('.cdn_queue_empty').click(function()
|
810 |
+
{
|
811 |
+
return confirm('Are you sure you want to empty the queue?');
|
812 |
+
});
|
813 |
});
|
inc/options/about.phtml
CHANGED
@@ -1,19 +1,26 @@
|
|
1 |
<div id="about">
|
2 |
<h3>About</h3>
|
3 |
|
4 |
-
<p>User experience is an important aspect of every web site and all web sites can benefit from effective caching and file size reduction. We have applied web site optimization methods typically used with high traffic sites and simplified their implementation. Coupling these methods either <a href="http://www.danga.com/memcached/" target="_blank">memcached</a> and/or <a href="http://pecl.php.net/package/APC" target="_blank"><acronym title="Alternative PHP Cache">APC</acronym></a> and the <acronym title="Content Delivery Network">CDN</acronym> of your choosing to provide the following benefits:</p>
|
5 |
<ul>
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
</ul>
|
16 |
-
<p>Your users have less data to download, you can now
|
17 |
<p><strong>Who do I thank for all of this?</strong><br />It's quite difficult to recall all of the innovators that have shared their thoughts, code and experiences in the blogosphere over the years, but here are some names to get you started:</p>
|
18 |
<ul>
|
19 |
<li><a href="http://mrclay.org/" target="_blank">Steve Clay</a></li>
|
1 |
<div id="about">
|
2 |
<h3>About</h3>
|
3 |
|
4 |
+
<p>User experience is an important aspect of every web site and all web sites can benefit from effective caching and file size reduction. We have applied web site optimization methods typically used with high traffic sites and simplified their implementation. Coupling these methods either <a href="http://www.danga.com/memcached/" target="_blank">memcached</a> and/or <a href="http://pecl.php.net/package/APC" target="_blank"><acronym title="Alternative PHP Cache">APC</acronym></a> and the <acronym title="Content Delivery Network">CDN</acronym> of your choosing to provide the following features and benefits:</p>
|
5 |
<ul>
|
6 |
+
<li>Increased visitor time on site</li>
|
7 |
+
<li>Optimized progressive render (pages appear to load instantly)</li>
|
8 |
+
<li>Reduced <acronym title="Hypertext Transfer Protocol">HTTP</acronym> Transactions, <acronym title="Domain Name System">DNS</acronym> lookups and reduced document load time</li>
|
9 |
+
<li>Bandwidth savings via Minify and <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression of <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheet">CSS</acronym>, JavaScript and <acronym title="Really Simple Syndication">RSS</acronym> feeds</li>
|
10 |
+
<li>Increased web server concurrency and increased scale (easily sustain high traffic spikes)</li>
|
11 |
+
<li>Transparent content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) integration with Media Library, theme files and WordPress core</li>
|
12 |
+
<li>Caching of pages / posts in memory or on disk</li>
|
13 |
+
<li>Caching of (minified) <acronym title="Cascading Style Sheet">CSS</acronym> and JavaScript in memory, on disk or on <acronym title="Content Delivery Network">CDN</acronym></li>
|
14 |
+
<li>Caching of database objects in memory</li>
|
15 |
+
<li>Caching of <acronym title="Really Simple Syndication">RSS</acronym> (comments, page and site) feeds in memory or on disk</li>
|
16 |
+
<li>Caching of search results pages (i.e. <acronym title="Uniform Resource Identifier">URI</acronym>s with query string variables) in memory or on disk</li>
|
17 |
+
<li>Minification of posts / pages and <acronym title="Really Simple Syndication">RSS</acronym> feeds</li>
|
18 |
+
<li>Minification (concatenation and white space removal) of inline, external or 3rd party JavaScript / <acronym title="Cascading Style Sheet">CSS</acronym> with automated updates</li>
|
19 |
+
<li>Complete header management including <a href="http://en.wikipedia.org/wiki/HTTP_ETag">Etags</a></li>
|
20 |
+
<li>JavaScript embedding group and location management</li>
|
21 |
+
<li>Import post attachments directly into the Media Library (and <acronym title="Content Delivery Network">CDN</acronym>)</li>
|
22 |
</ul>
|
23 |
+
<p>Your users have less data to download, you can now server more visitors at once without upgrading your equipment and you don't have to change how you do anything; just set it and forget it.</p>
|
24 |
<p><strong>Who do I thank for all of this?</strong><br />It's quite difficult to recall all of the innovators that have shared their thoughts, code and experiences in the blogosphere over the years, but here are some names to get you started:</p>
|
25 |
<ul>
|
26 |
<li><a href="http://mrclay.org/" target="_blank">Steve Clay</a></li>
|
inc/options/cdn.phtml
CHANGED
@@ -1,15 +1,25 @@
|
|
|
|
|
|
|
|
1 |
<h3><acronym title="Content Delivery Network">CDN</acronym> Settings</h3>
|
2 |
|
3 |
<p><acronym title="Content Delivery Network">CDN</acronym> support is currently <span class="w3tc-<?php if ($config->get_boolean('cdn.enabled')): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>.</p>
|
4 |
|
|
|
5 |
<p>
|
6 |
-
You can
|
7 |
-
<input id="cdn_export_library" class="button" type="button" value="export media library to CDN" /> or
|
8 |
-
<input id="cdn_import_library" class="button" type="button" value="import post files to media library & CDN" /> or
|
9 |
-
<input id="cdn_queue" class="button" type="button" value="view unsuccessfull transfers" /> now.
|
10 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
|
|
13 |
<div id="cdn_ftp" class="w3tc-tab-content">
|
14 |
<table class="form-table">
|
15 |
<tr>
|
@@ -47,6 +57,7 @@
|
|
47 |
<input id="test_ftp" class="button" type="button" value="Test FTP server" /> <span id="test_ftp_status" class="w3tc-status w3tc-process"></span>
|
48 |
</p>
|
49 |
</div>
|
|
|
50 |
<table class="form-table">
|
51 |
<tr>
|
52 |
<th style="width: 300px;"><label for="cdn_domain">Replace domain in <acronym title="Uniform Resource Locator">URL</acronym> with:</label></th>
|
@@ -54,6 +65,7 @@
|
|
54 |
<input id="cdn_domain" type="text" name="cdn.domain" value="<?php echo htmlspecialchars($config->get_string('cdn.domain')); ?>" size="40" />
|
55 |
</td>
|
56 |
</tr>
|
|
|
57 |
<tr>
|
58 |
<th><label for="cdn_limit_queue">Re-transfer cycle limit:</label></th>
|
59 |
<td>
|
@@ -61,41 +73,50 @@
|
|
61 |
<span class="description">Number of files processed per cycle.</span>
|
62 |
</td>
|
63 |
</tr>
|
|
|
64 |
<tr>
|
65 |
-
<th
|
66 |
<input type="hidden" name="cdn.includes.enable" value="0" />
|
67 |
<label><input type="checkbox" name="cdn.includes.enable" value="1"<?php checked($config->get_boolean('cdn.includes.enable'), true); ?> /> Host wp-includes/ files</label>
|
68 |
</th>
|
|
|
69 |
<td>
|
70 |
<input class="button cdn_export" type="button" name="includes" value="Upload includes files" />
|
71 |
</td>
|
|
|
72 |
</tr>
|
73 |
<tr>
|
74 |
-
<th
|
75 |
<input type="hidden" name="cdn.theme.enable" value="0" />
|
76 |
<label><input type="checkbox" name="cdn.theme.enable" value="1"<?php checked($config->get_boolean('cdn.theme.enable'), true); ?> /> Host active theme files</label>
|
77 |
</th>
|
|
|
78 |
<td>
|
79 |
<input class="button cdn_export" type="button" name="theme" value="Upload theme files" />
|
80 |
</td>
|
|
|
81 |
</tr>
|
82 |
<tr>
|
83 |
-
<th
|
84 |
<input type="hidden" name="cdn.minify.enable" value="0" />
|
85 |
<label><input type="checkbox" name="cdn.minify.enable" value="1"<?php checked($config->get_boolean('cdn.minify.enable'), true); ?> /> Host minified <acronym title="Cascading Style Sheets">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files</label>
|
86 |
</th>
|
|
|
87 |
<td>
|
88 |
<input class="button cdn_export" type="button" name="minify" value="Upload minify files" />
|
89 |
</td>
|
|
|
90 |
</tr>
|
91 |
<tr>
|
92 |
-
<th
|
93 |
<input type="hidden" name="cdn.custom.enable" value="0" />
|
94 |
<label><input type="checkbox" name="cdn.custom.enable" value="1"<?php checked($config->get_boolean('cdn.custom.enable'), true); ?> /> Host custom files</label>
|
95 |
</th>
|
|
|
96 |
<td>
|
97 |
<input class="button cdn_export" type="button" name="custom" value="Upload custom files" />
|
98 |
</td>
|
|
|
99 |
</tr>
|
100 |
<tr>
|
101 |
<th><label for="cdn_includes_files">Search wp-includes/ directory for files:</label></th>
|
@@ -115,6 +136,11 @@
|
|
115 |
<textarea id="cdn_custom_files" name="cdn.custom.files" cols="30" rows="5"><?php echo htmlspecialchars(implode("\r\n", $config->get_array('cdn.custom.files'))); ?></textarea>
|
116 |
</td>
|
117 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
118 |
<tr>
|
119 |
<th colspan="2">
|
120 |
<input type="hidden" name="cdn.import.external" value="0" />
|
@@ -127,6 +153,7 @@
|
|
127 |
<input id="cdn_import_files" type="text" name="cdn.import.files" value="<?php echo htmlspecialchars($config->get_string('cdn.import.files')); ?>" size="40" />
|
128 |
</td>
|
129 |
</tr>
|
|
|
130 |
</table>
|
131 |
|
132 |
<p class="submit">
|
1 |
+
<?php
|
2 |
+
$cdn_mirror = ($config->get_string('cdn.engine') == 'mirror');
|
3 |
+
?>
|
4 |
<h3><acronym title="Content Delivery Network">CDN</acronym> Settings</h3>
|
5 |
|
6 |
<p><acronym title="Content Delivery Network">CDN</acronym> support is currently <span class="w3tc-<?php if ($config->get_boolean('cdn.enabled')): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>.</p>
|
7 |
|
8 |
+
<?php if ($cdn_mirror): ?>
|
9 |
<p>
|
10 |
+
You can use the <input id="cdn_rename_domain" class="button" type="button" value="domain rename tool" /> now.
|
|
|
|
|
|
|
11 |
</p>
|
12 |
+
<?php else: ?>
|
13 |
+
<p>
|
14 |
+
You can <input id="cdn_export_library" class="button" type="button" value="export media library to CDN" />,
|
15 |
+
use the <input id="cdn_rename_domain" class="button" type="button" value="domain rename tool" />,
|
16 |
+
<input id="cdn_import_library" class="button" type="button" value="import post files to the Media Library & CDN" /> or
|
17 |
+
<input id="cdn_queue" class="button" type="button" value="view unsuccessful FTP transfers" /> now.
|
18 |
+
</p>
|
19 |
+
<?php endif; ?>
|
20 |
|
21 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
22 |
+
<?php if (! $cdn_mirror): ?>
|
23 |
<div id="cdn_ftp" class="w3tc-tab-content">
|
24 |
<table class="form-table">
|
25 |
<tr>
|
57 |
<input id="test_ftp" class="button" type="button" value="Test FTP server" /> <span id="test_ftp_status" class="w3tc-status w3tc-process"></span>
|
58 |
</p>
|
59 |
</div>
|
60 |
+
<?php endif; ?>
|
61 |
<table class="form-table">
|
62 |
<tr>
|
63 |
<th style="width: 300px;"><label for="cdn_domain">Replace domain in <acronym title="Uniform Resource Locator">URL</acronym> with:</label></th>
|
65 |
<input id="cdn_domain" type="text" name="cdn.domain" value="<?php echo htmlspecialchars($config->get_string('cdn.domain')); ?>" size="40" />
|
66 |
</td>
|
67 |
</tr>
|
68 |
+
<?php if (! $cdn_mirror): ?>
|
69 |
<tr>
|
70 |
<th><label for="cdn_limit_queue">Re-transfer cycle limit:</label></th>
|
71 |
<td>
|
73 |
<span class="description">Number of files processed per cycle.</span>
|
74 |
</td>
|
75 |
</tr>
|
76 |
+
<?php endif; ?>
|
77 |
<tr>
|
78 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
79 |
<input type="hidden" name="cdn.includes.enable" value="0" />
|
80 |
<label><input type="checkbox" name="cdn.includes.enable" value="1"<?php checked($config->get_boolean('cdn.includes.enable'), true); ?> /> Host wp-includes/ files</label>
|
81 |
</th>
|
82 |
+
<?php if (! $cdn_mirror): ?>
|
83 |
<td>
|
84 |
<input class="button cdn_export" type="button" name="includes" value="Upload includes files" />
|
85 |
</td>
|
86 |
+
<?php endif; ?>
|
87 |
</tr>
|
88 |
<tr>
|
89 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
90 |
<input type="hidden" name="cdn.theme.enable" value="0" />
|
91 |
<label><input type="checkbox" name="cdn.theme.enable" value="1"<?php checked($config->get_boolean('cdn.theme.enable'), true); ?> /> Host active theme files</label>
|
92 |
</th>
|
93 |
+
<?php if (! $cdn_mirror): ?>
|
94 |
<td>
|
95 |
<input class="button cdn_export" type="button" name="theme" value="Upload theme files" />
|
96 |
</td>
|
97 |
+
<?php endif; ?>
|
98 |
</tr>
|
99 |
<tr>
|
100 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
101 |
<input type="hidden" name="cdn.minify.enable" value="0" />
|
102 |
<label><input type="checkbox" name="cdn.minify.enable" value="1"<?php checked($config->get_boolean('cdn.minify.enable'), true); ?> /> Host minified <acronym title="Cascading Style Sheets">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files</label>
|
103 |
</th>
|
104 |
+
<?php if (! $cdn_mirror): ?>
|
105 |
<td>
|
106 |
<input class="button cdn_export" type="button" name="minify" value="Upload minify files" />
|
107 |
</td>
|
108 |
+
<?php endif; ?>
|
109 |
</tr>
|
110 |
<tr>
|
111 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
112 |
<input type="hidden" name="cdn.custom.enable" value="0" />
|
113 |
<label><input type="checkbox" name="cdn.custom.enable" value="1"<?php checked($config->get_boolean('cdn.custom.enable'), true); ?> /> Host custom files</label>
|
114 |
</th>
|
115 |
+
<?php if (! $cdn_mirror): ?>
|
116 |
<td>
|
117 |
<input class="button cdn_export" type="button" name="custom" value="Upload custom files" />
|
118 |
</td>
|
119 |
+
<?php endif; ?>
|
120 |
</tr>
|
121 |
<tr>
|
122 |
<th><label for="cdn_includes_files">Search wp-includes/ directory for files:</label></th>
|
136 |
<textarea id="cdn_custom_files" name="cdn.custom.files" cols="30" rows="5"><?php echo htmlspecialchars(implode("\r\n", $config->get_array('cdn.custom.files'))); ?></textarea>
|
137 |
</td>
|
138 |
</tr>
|
139 |
+
<tr>
|
140 |
+
<th valign="top"><label for="cdn_reject_ua">Rejected User Agents:</label></th>
|
141 |
+
<td><textarea id="cdn_reject_ua" name="cdn.reject.ua" cols="30" rows="5"><?php echo htmlspecialchars(implode("\r\n", $config->get_array('cdn.reject.ua'))); ?></textarea></td>
|
142 |
+
</tr>
|
143 |
+
<?php if (! $cdn_mirror): ?>
|
144 |
<tr>
|
145 |
<th colspan="2">
|
146 |
<input type="hidden" name="cdn.import.external" value="0" />
|
153 |
<input id="cdn_import_files" type="text" name="cdn.import.files" value="<?php echo htmlspecialchars($config->get_string('cdn.import.files')); ?>" size="40" />
|
154 |
</td>
|
155 |
</tr>
|
156 |
+
<?php endif; ?>
|
157 |
</table>
|
158 |
|
159 |
<p class="submit">
|
inc/options/dbcache.phtml
CHANGED
@@ -1,6 +1,13 @@
|
|
1 |
<h3>Database Caching Settings</h3>
|
2 |
|
3 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
6 |
<table class="form-table">
|
@@ -8,9 +15,8 @@
|
|
8 |
<th style="width: 250px;"><label for="memcached_servers">Memcached Hostname:Port / IP:Port:</label></th>
|
9 |
<td>
|
10 |
<input id="memcached_servers" type="text" name="dbcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $config->get_array('dbcache.memcached.servers'))); ?>" size="100"<?php if (! $dbcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
11 |
-
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
12 |
<input id="test_memcached" class="button" type="button" value="Test"<?php if (! $dbcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
13 |
-
<
|
14 |
<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
|
15 |
</td>
|
16 |
</tr>
|
1 |
<h3>Database Caching Settings</h3>
|
2 |
|
3 |
+
<form action="options-general.php">
|
4 |
+
<p>
|
5 |
+
Database caching is currently <span class="w3tc-<?php if ($dbcache_enabled): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>.
|
6 |
+
<input type="submit" name="flush_dbcache" value="Empty cache"<?php if (! $dbcache_enabled): ?> disabled="disabled"<?php endif; ?> class="button" />
|
7 |
+
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
8 |
+
<input type="hidden" name="tab" value="<?php echo $tab; ?>" />
|
9 |
+
</p>
|
10 |
+
</form>
|
11 |
|
12 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
13 |
<table class="form-table">
|
15 |
<th style="width: 250px;"><label for="memcached_servers">Memcached Hostname:Port / IP:Port:</label></th>
|
16 |
<td>
|
17 |
<input id="memcached_servers" type="text" name="dbcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $config->get_array('dbcache.memcached.servers'))); ?>" size="100"<?php if (! $dbcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
|
|
18 |
<input id="test_memcached" class="button" type="button" value="Test"<?php if (! $dbcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
19 |
+
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
20 |
<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
|
21 |
</td>
|
22 |
</tr>
|
inc/options/faq.phtml
CHANGED
@@ -74,7 +74,7 @@
|
|
74 |
<li><a href="#q60">How can I tell if it's working? Aren't there any statistics at all?</a></li>
|
75 |
<li><a href="#q61">I'm an advanced theme developer and I want to have different combinations of <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> files on different types of pages in my theme; how is this done?</a></li>
|
76 |
<li><a href="#q62">Which features can I use if I haven't yet installed <acronym title="Alternative PHP Cache">APC</acronym> or memcached?</a></li>
|
77 |
-
<li><a href="#q63">How can I
|
78 |
<li><a href="#q64">Why do you set the value of the media attribute of <link> to all?</a></li>
|
79 |
<li><a href="#q65">Why can't I specify other <script> types or encoding?</a></li>
|
80 |
<li><a href="#q66">My theme doesn't call wp_footer(), how do I set this plugin up?</a></li>
|
@@ -89,6 +89,7 @@
|
|
89 |
<li><a href="#q75">Who do you recommend as a <acronym title="Content Delivery Network">CDN</acronym> provider?</a></li>
|
90 |
<li><a href="#q76">Hang on, don't I need to modify my <acronym title="Cascading Style Sheet">CSS</acronym> files so they'll work on the <acronym title="Content Delivery Network">CDN</acronym>?</a></li>
|
91 |
<li><a href="#q77">I don't have time to deal with this, but I know I need it. Will you help me?</a></li>
|
|
|
92 |
</ul>
|
93 |
</li>
|
94 |
<li class="col">
|
@@ -141,7 +142,7 @@
|
|
141 |
<li>Minification (concatenation, white space removal) of inline, external or 3rd party <acronym title="JavaScript">JS</acronym> and <acronym title="Cascading Style Sheet">CSS</acronym> with scheduled updates</li>
|
142 |
<li>Optional embedding of <acronym title="JavaScript">JS</acronym> just above </body></li>
|
143 |
<li>Support for caching pages, posts, feeds, database objects, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> in memory with <acronym title="Alternative PHP Cache">APC</acronym> or memcached or both</li>
|
144 |
-
<li>Caching of RSS/Atom Feeds (Comments, Page and site),
|
145 |
<li>Complete header management including Etags</li>
|
146 |
<li>Increased web server concurrency and reduced resource consumption, increased scale</li>
|
147 |
</ul>
|
@@ -317,13 +318,13 @@
|
|
317 |
On the contrary, as with any other action a user can perform on a site, faster performance will encourage more of it. The cache is so quickly rebuilt in memory that it's no trouble to show visitors the most current version of a post that's experiencing Digg, Slashdot, Drudge Report, Yahoo Buzz or Twitter effect.</p>
|
318 |
<p align="right"><a href="#toc">back to top</a></p>
|
319 |
<p id="q49"><strong>What if I accidentally specify an incorrect path to a <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> file?</strong><br />
|
320 |
-
Unfortunately a 400 bad request error may be generated. So use the "Check
|
321 |
<p align="right"><a href="#toc">back to top</a></p>
|
322 |
<p id="q50"><strong>Does the plugin automatically remove duplicate <acronym title="JavaScript">JS</acronym>?</strong><br />
|
323 |
No. If you include a script in the minfy settings twice or it already exists in your theme we do not automatically remove the extra code. That's tricky business and it's better for us to just let you make the decisions conscientiously.</p>
|
324 |
<p align="right"><a href="#toc">back to top</a></p>
|
325 |
<p id="q51"><strong>I've been using the plugin for some time, I updated one of my other plugins and now it doesn't work anymore. What's up?</strong><br />
|
326 |
-
It's likely the plugin author modified
|
327 |
<!--
|
328 |
<p id="q52" align="right"><a href="#toc">back to top</a></p>
|
329 |
<p><strong>I have some <acronym title="Cascading Style Sheet">CSS</acronym> classes with declarations being overwritten or <acronym title="JavaScript">JS</acronym> with dependencies, do I really have to copy and paste all my <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> file settings around?</strong><br />
|
@@ -360,9 +361,9 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
360 |
Great question, we understand the use case all too well. Right now you cannot create different groups of <acronym title="JavaScript">JS</acronym> and <acronym title="Cascading Style Sheet">CSS</acronym> files for your home, page, post, archive or 404 etc. This feature is coming soon; it did not make the first cut.</p>
|
361 |
<p align="right"><a href="#toc">back to top</a></p>
|
362 |
<p id="q62"><strong>Which features can I use if I haven't yet installed <acronym title="Alternative PHP Cache">APC</acronym> or memcached?</strong><br />
|
363 |
-
Memory caching will not be possible. However you will be able to use minify as well <acronym title="Content Delivery Network">CDN</acronym> functionality without issue. Remember that W3 Total Cache is not compatible with other caching plugins, so you'll want to install <acronym title="Alternative PHP Cache">APC</acronym> and/or memcached as soon as possible.</p>
|
364 |
<p align="right"><a href="#toc">back to top</a></p>
|
365 |
-
<p id="q63"><strong>How can I
|
366 |
If the file exists in your document root (i.e. http://domain.com/favicon.ico), the plugin can take care of that for you using custom upload options. If the file is in your theme directory you can also have the plugin uploaded from there.</p>
|
367 |
<p align="right"><a href="#toc">back to top</a></p>
|
368 |
<p id="q64"><strong>Why do you set the value of the media attribute of <link> to all?</strong><br />
|
@@ -372,11 +373,11 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
372 |
We have not found a use case where this appears to be of any consequence. If you're aware of one <a href="mailto:wordpressexperts@w3-edge.com">please let us know</a>.</p>
|
373 |
<p align="right"><a href="#toc">back to top</a></p>
|
374 |
<p id="q66"><strong>My theme doesn't call wp_footer(), how do I set this plugin up?</strong><br />
|
375 |
-
The calls you'll want to make for the various cases are:</p>
|
376 |
<ul>
|
377 |
<li><?php if (function_exists('w3tc_scripts')){w3tc_scripts('include-footer');} ?><br />
|
378 |
Inserts the footer <acronym title="JavaScript">JS</acronym> group at the location you specify in your theme.</li>
|
379 |
-
<li><?php if (function_exists('w3tc_scripts')){w3tc_scripts('include-
|
380 |
Inserts the footer non-blocking <acronym title="JavaScript">JS</acronym> group at the location you specify in your theme.</li>
|
381 |
<li><?php if (function_exists('w3tc_scripts')){w3tc_scripts('include-footer');w3tc_scripts('include-footer-nb');} ?><br />
|
382 |
Inserts both of the above <acronym title="JavaScript">JS</acronym> groups at the location you specify in your theme.</li>
|
@@ -424,6 +425,9 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
424 |
<p id="q77"><strong>I don't have time to deal with this, but I know I need it. Will you help me?</strong><br />
|
425 |
Yes! Please <a href="mailto:wordpressexperts@w3-edge.com">reach out to us</a> and we'll get you acclimated so you can "set it and forget it."</p>
|
426 |
<p align="right"><a href="#toc">back to top</a></p>
|
|
|
|
|
|
|
427 |
<p id="q78"><strong>Which web servers do you support?</strong><br />
|
428 |
We are aware of no incompatibilities with <a href="http://httpd.apache.org/" target="_blank">apache</a> 1.3+, <a href="http://www.iis.net/" target="_blank">IIS</a> 5+ or <a href="http://litespeedtech.com/products/webserver/overview/" target="_blank">litespeed</a> 4.0.2+. If there's a web server you feel we should be actively testing (e.g. <a href="http://www.lighttpd.net/" target="_blank">lighttpd</a>), we're <a href="mailto:wordpressexperts@w3-edge.com">interested in hearing</a>.</p>
|
429 |
<p align="right"><a href="#toc">back to top</a></p>
|
@@ -432,7 +436,7 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
432 |
<p>If you're larger organization or a web hosting company, consider looking into solutions that exist like <a href="http://www.gear6.com/">Gear6</a> which could be useful now that you have a plugin that makes management memcached pain free.</p>
|
433 |
<p align="right"><a href="#toc">back to top</a></p>
|
434 |
<p id="q80"><strong>Is this plugin compatible with varnish or squid?</strong><br />
|
435 |
-
|
436 |
<p align="right"><a href="#toc">back to top</a></p>
|
437 |
<p id="q81"><strong>My server is state of the art with 15,000 RPM RAID, why do I need to cache anything in memory?</strong><br />
|
438 |
Even if your server was using an array of solid state disks (SSD), your server's <acronym title="Random Access Memory">RAM</acronym> is still going to be faster and introduce less overhead to access than even the fastest solid state drives on a PCIe bus. If you didn't invest in solid state disks for your server, then even worse off - at least an order of magnitude speed difference in read operations in <acronym title="Random Access Memory">RAM</acronym> versus HDD. For write operations delta the latency differences is even more pronounced. <acronym title="Random Access Memory">RAM</acronym> is the winner hands down. We won't even discuss the blocking and arbitration issues that happen with disk arrays under certain circumstances.</p>
|
@@ -463,7 +467,7 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
463 |
If your WordPress installation is works, you're all set.</p>
|
464 |
<p align="right"><a href="#toc">back to top</a></p>
|
465 |
<p id="q87"><strong>And I need mod_rewrite (or equivalent for my web server) installed too, no?</strong><br />
|
466 |
-
That's correct; everything you need for WordPress (i.e. fancy
|
467 |
<p align="right"><a href="#toc">back to top</a></p>
|
468 |
<p id="q88"><strong>How much hardware do I have to throw at something like this before I see a benefit?</strong><br />
|
469 |
This plugin was actually designed with virtual dedicated servers in mind. As long as your server has at least 256M of <acronym title="Random Access Memory">RAM</acronym>, you can get started.</p>
|
74 |
<li><a href="#q60">How can I tell if it's working? Aren't there any statistics at all?</a></li>
|
75 |
<li><a href="#q61">I'm an advanced theme developer and I want to have different combinations of <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> files on different types of pages in my theme; how is this done?</a></li>
|
76 |
<li><a href="#q62">Which features can I use if I haven't yet installed <acronym title="Alternative PHP Cache">APC</acronym> or memcached?</a></li>
|
77 |
+
<li><a href="#q63">How can I host my favicon with my <acronym title="Content Delivery Network">CDN</acronym>?</a></li>
|
78 |
<li><a href="#q64">Why do you set the value of the media attribute of <link> to all?</a></li>
|
79 |
<li><a href="#q65">Why can't I specify other <script> types or encoding?</a></li>
|
80 |
<li><a href="#q66">My theme doesn't call wp_footer(), how do I set this plugin up?</a></li>
|
89 |
<li><a href="#q75">Who do you recommend as a <acronym title="Content Delivery Network">CDN</acronym> provider?</a></li>
|
90 |
<li><a href="#q76">Hang on, don't I need to modify my <acronym title="Cascading Style Sheet">CSS</acronym> files so they'll work on the <acronym title="Content Delivery Network">CDN</acronym>?</a></li>
|
91 |
<li><a href="#q77">I don't have time to deal with this, but I know I need it. Will you help me?</a></li>
|
92 |
+
<li><a href="#q92">What about query string variables on <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym>, do they matter?</a></li>
|
93 |
</ul>
|
94 |
</li>
|
95 |
<li class="col">
|
142 |
<li>Minification (concatenation, white space removal) of inline, external or 3rd party <acronym title="JavaScript">JS</acronym> and <acronym title="Cascading Style Sheet">CSS</acronym> with scheduled updates</li>
|
143 |
<li>Optional embedding of <acronym title="JavaScript">JS</acronym> just above </body></li>
|
144 |
<li>Support for caching pages, posts, feeds, database objects, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> in memory with <acronym title="Alternative PHP Cache">APC</acronym> or memcached or both</li>
|
145 |
+
<li>Caching of RSS/Atom Feeds (Comments, Page and site), <acronym title="Uniform Resource Indicator">URL</acronym>s with query string variables (like search result pages), Database queries, Pages, Posts, <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym></li>
|
146 |
<li>Complete header management including Etags</li>
|
147 |
<li>Increased web server concurrency and reduced resource consumption, increased scale</li>
|
148 |
</ul>
|
318 |
On the contrary, as with any other action a user can perform on a site, faster performance will encourage more of it. The cache is so quickly rebuilt in memory that it's no trouble to show visitors the most current version of a post that's experiencing Digg, Slashdot, Drudge Report, Yahoo Buzz or Twitter effect.</p>
|
319 |
<p align="right"><a href="#toc">back to top</a></p>
|
320 |
<p id="q49"><strong>What if I accidentally specify an incorrect path to a <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> file?</strong><br />
|
321 |
+
Unfortunately a 400 bad request error may be generated. So use the "Check <acronym title="Uniform Resource Indicator">URL</acronym>" button to make sure that you have entered the correct <acronym title="Uniform Resource Indicator">URL</acronym> or path to the file.</p>
|
322 |
<p align="right"><a href="#toc">back to top</a></p>
|
323 |
<p id="q50"><strong>Does the plugin automatically remove duplicate <acronym title="JavaScript">JS</acronym>?</strong><br />
|
324 |
No. If you include a script in the minfy settings twice or it already exists in your theme we do not automatically remove the extra code. That's tricky business and it's better for us to just let you make the decisions conscientiously.</p>
|
325 |
<p align="right"><a href="#toc">back to top</a></p>
|
326 |
<p id="q51"><strong>I've been using the plugin for some time, I updated one of my other plugins and now it doesn't work anymore. What's up?</strong><br />
|
327 |
+
It's likely the plugin author modified their <acronym title="JavaScript">JS</acronym> or <acronym title="Cascading Style Sheet">CSS</acronym> in the new release and any old <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> you optimized with our plugin has introduced duplicate code as a result (creating a conflict). Simply check out the source code, identify any new <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> and update your <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> optimizations our plugin and you're good to go.</p>
|
328 |
<!--
|
329 |
<p id="q52" align="right"><a href="#toc">back to top</a></p>
|
330 |
<p><strong>I have some <acronym title="Cascading Style Sheet">CSS</acronym> classes with declarations being overwritten or <acronym title="JavaScript">JS</acronym> with dependencies, do I really have to copy and paste all my <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> file settings around?</strong><br />
|
361 |
Great question, we understand the use case all too well. Right now you cannot create different groups of <acronym title="JavaScript">JS</acronym> and <acronym title="Cascading Style Sheet">CSS</acronym> files for your home, page, post, archive or 404 etc. This feature is coming soon; it did not make the first cut.</p>
|
362 |
<p align="right"><a href="#toc">back to top</a></p>
|
363 |
<p id="q62"><strong>Which features can I use if I haven't yet installed <acronym title="Alternative PHP Cache">APC</acronym> or memcached?</strong><br />
|
364 |
+
Memory caching will not be possible. However you will be able to use both the page cache and minify in "disk" mode, as well <acronym title="Content Delivery Network">CDN</acronym> functionality without issue. Remember that W3 Total Cache is not compatible with other caching plugins, so you'll want to install <acronym title="Alternative PHP Cache">APC</acronym> and/or memcached as soon as possible.</p>
|
365 |
<p align="right"><a href="#toc">back to top</a></p>
|
366 |
+
<p id="q63"><strong>How can I host my favicon with my <acronym title="Content Delivery Network">CDN</acronym>?</strong><br />
|
367 |
If the file exists in your document root (i.e. http://domain.com/favicon.ico), the plugin can take care of that for you using custom upload options. If the file is in your theme directory you can also have the plugin uploaded from there.</p>
|
368 |
<p align="right"><a href="#toc">back to top</a></p>
|
369 |
<p id="q64"><strong>Why do you set the value of the media attribute of <link> to all?</strong><br />
|
373 |
We have not found a use case where this appears to be of any consequence. If you're aware of one <a href="mailto:wordpressexperts@w3-edge.com">please let us know</a>.</p>
|
374 |
<p align="right"><a href="#toc">back to top</a></p>
|
375 |
<p id="q66"><strong>My theme doesn't call wp_footer(), how do I set this plugin up?</strong><br />
|
376 |
+
If you need to embed JavaScript at the bottom of the page and your theme doesn't use wp_footer(), you'll need to manually update your theme. The calls you'll want to make for the various cases are:</p>
|
377 |
<ul>
|
378 |
<li><?php if (function_exists('w3tc_scripts')){w3tc_scripts('include-footer');} ?><br />
|
379 |
Inserts the footer <acronym title="JavaScript">JS</acronym> group at the location you specify in your theme.</li>
|
380 |
+
<li><?php if (function_exists('w3tc_scripts')){w3tc_scripts('include-footer-nb');} ?><br />
|
381 |
Inserts the footer non-blocking <acronym title="JavaScript">JS</acronym> group at the location you specify in your theme.</li>
|
382 |
<li><?php if (function_exists('w3tc_scripts')){w3tc_scripts('include-footer');w3tc_scripts('include-footer-nb');} ?><br />
|
383 |
Inserts both of the above <acronym title="JavaScript">JS</acronym> groups at the location you specify in your theme.</li>
|
425 |
<p id="q77"><strong>I don't have time to deal with this, but I know I need it. Will you help me?</strong><br />
|
426 |
Yes! Please <a href="mailto:wordpressexperts@w3-edge.com">reach out to us</a> and we'll get you acclimated so you can "set it and forget it."</p>
|
427 |
<p align="right"><a href="#toc">back to top</a></p>
|
428 |
+
<p id="q92"><strong>What about query string variables on <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym>, do they matter?</strong><br />
|
429 |
+
This is definitely a special case. Files like "http://domain.com/wp-content/themes/default/js/script.js?ver=20090102" etc need to be specified with the full <acronym title="Uniform Resource Locator">URL</acronym>. This is an exception to the general rule of specifying a local path to file like: "wp-content/themes/default/js/script.js", which should also work fine. Be sure to click the "Verify <acronym title="Uniform Resource Indicator">URL</acronym>" button to be sure that everything is ok before saving changes.</p>
|
430 |
+
<p align="right"><a href="#toc">back to top</a></p>
|
431 |
<p id="q78"><strong>Which web servers do you support?</strong><br />
|
432 |
We are aware of no incompatibilities with <a href="http://httpd.apache.org/" target="_blank">apache</a> 1.3+, <a href="http://www.iis.net/" target="_blank">IIS</a> 5+ or <a href="http://litespeedtech.com/products/webserver/overview/" target="_blank">litespeed</a> 4.0.2+. If there's a web server you feel we should be actively testing (e.g. <a href="http://www.lighttpd.net/" target="_blank">lighttpd</a>), we're <a href="mailto:wordpressexperts@w3-edge.com">interested in hearing</a>.</p>
|
433 |
<p align="right"><a href="#toc">back to top</a></p>
|
436 |
<p>If you're larger organization or a web hosting company, consider looking into solutions that exist like <a href="http://www.gear6.com/">Gear6</a> which could be useful now that you have a plugin that makes management memcached pain free.</p>
|
437 |
<p align="right"><a href="#toc">back to top</a></p>
|
438 |
<p id="q80"><strong>Is this plugin compatible with varnish or squid?</strong><br />
|
439 |
+
Yes, it is compatible with <a href="http://varnish.projects.linpro.no/" target="_blank">varnish</a> and <a href="http://www.squid-cache.org/" target="_blank">squid</a>, however (with regard to dynamic content) we have yet to find a practical case where either can provide more scale for an individual server than apache 2+ if properly configured.</p>
|
440 |
<p align="right"><a href="#toc">back to top</a></p>
|
441 |
<p id="q81"><strong>My server is state of the art with 15,000 RPM RAID, why do I need to cache anything in memory?</strong><br />
|
442 |
Even if your server was using an array of solid state disks (SSD), your server's <acronym title="Random Access Memory">RAM</acronym> is still going to be faster and introduce less overhead to access than even the fastest solid state drives on a PCIe bus. If you didn't invest in solid state disks for your server, then even worse off - at least an order of magnitude speed difference in read operations in <acronym title="Random Access Memory">RAM</acronym> versus HDD. For write operations delta the latency differences is even more pronounced. <acronym title="Random Access Memory">RAM</acronym> is the winner hands down. We won't even discuss the blocking and arbitration issues that happen with disk arrays under certain circumstances.</p>
|
467 |
If your WordPress installation is works, you're all set.</p>
|
468 |
<p align="right"><a href="#toc">back to top</a></p>
|
469 |
<p id="q87"><strong>And I need mod_rewrite (or equivalent for my web server) installed too, no?</strong><br />
|
470 |
+
That's correct; everything you need for WordPress (i.e. fancy <acronym title="Uniform Resource Locator">URL</acronym>s) will get you started with this plugin also.</p>
|
471 |
<p align="right"><a href="#toc">back to top</a></p>
|
472 |
<p id="q88"><strong>How much hardware do I have to throw at something like this before I see a benefit?</strong><br />
|
473 |
This plugin was actually designed with virtual dedicated servers in mind. As long as your server has at least 256M of <acronym title="Random Access Memory">RAM</acronym>, you can get started.</p>
|
inc/options/general.phtml
CHANGED
@@ -21,10 +21,11 @@ foreach ($link_categories as $link_category) {
|
|
21 |
<form action="options-general.php">
|
22 |
<p>You can
|
23 |
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
|
|
24 |
<input class="button" type="submit" name="flush_all" value="empty all caches" /> at once or
|
25 |
<input class="button" type="submit" name="flush_memcached" value="empty only the memcached cache"<?php if (! $can_empty_memcache): ?> disabled="disabled"<?php endif; ?> /> or
|
26 |
<input class="button" type="submit" name="flush_apc" value="empty only the APC cache"<?php if (! $can_empty_apc): ?> disabled="disabled"<?php endif; ?> /> or
|
27 |
-
<input class="button" type="submit" name="flush_file" value="empty only the
|
28 |
</p>
|
29 |
</form>
|
30 |
|
@@ -37,12 +38,13 @@ foreach ($link_categories as $link_category) {
|
|
37 |
<td>
|
38 |
<input type="hidden" name="pgcache.enabled" value="0" />
|
39 |
<label><input class="enabled" type="checkbox" name="pgcache.enabled" value="1"<?php checked($pgcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
40 |
-
<span class="description">Caching pages will reduce the response time of and increase the concurrency potential of your web server.</span>
|
41 |
</td>
|
42 |
</tr>
|
43 |
<tr>
|
44 |
<th valign="top">Page Caching Method:</th>
|
45 |
<td>
|
|
|
46 |
<label><input type="radio" name="pgcache.engine" value="memcached"<?php checked($config->get_string('pgcache.engine'), 'memcached'); ?> /> Memcached <?php echo $memcache_engine; ?></label><br />
|
47 |
<label><input type="radio" name="pgcache.engine" value="apc"<?php checked($config->get_string('pgcache.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?> /> <acronym title="Alternative PHP Cache">APC</acronym></label><br />
|
48 |
</td>
|
@@ -78,7 +80,7 @@ foreach ($link_categories as $link_category) {
|
|
78 |
<td>
|
79 |
<input type="hidden" name="dbcache.enabled" value="0" />
|
80 |
<label><input class="enabled" type="checkbox" name="dbcache.enabled" value="1"<?php checked($dbcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
81 |
-
<span class="description">Caching database objects
|
82 |
</td>
|
83 |
</tr>
|
84 |
<tr>
|
@@ -104,6 +106,7 @@ foreach ($link_categories as $link_category) {
|
|
104 |
<th><acronym title="Content Delivery Network">CDN</acronym> Type:</th>
|
105 |
<td>
|
106 |
<label><input type="radio" name="cdn.engine" value="ftp"<?php checked($config->get_string('cdn.engine'), 'ftp'); ?> /> <acronym title="File Transfer Protocol">FTP</acronym></label><br />
|
|
|
107 |
<span class="description">Select the <acronym title="Content Delivery Network">CDN</acronym> type you wish to use.</span>
|
108 |
</td>
|
109 |
</tr>
|
21 |
<form action="options-general.php">
|
22 |
<p>You can
|
23 |
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
24 |
+
<input type="hidden" name="tab" value="<?php echo $tab; ?>" />
|
25 |
<input class="button" type="submit" name="flush_all" value="empty all caches" /> at once or
|
26 |
<input class="button" type="submit" name="flush_memcached" value="empty only the memcached cache"<?php if (! $can_empty_memcache): ?> disabled="disabled"<?php endif; ?> /> or
|
27 |
<input class="button" type="submit" name="flush_apc" value="empty only the APC cache"<?php if (! $can_empty_apc): ?> disabled="disabled"<?php endif; ?> /> or
|
28 |
+
<input class="button" type="submit" name="flush_file" value="empty only the disk cache"<?php if (! $can_empty_file): ?> disabled="disabled"<?php endif; ?> />.
|
29 |
</p>
|
30 |
</form>
|
31 |
|
38 |
<td>
|
39 |
<input type="hidden" name="pgcache.enabled" value="0" />
|
40 |
<label><input class="enabled" type="checkbox" name="pgcache.enabled" value="1"<?php checked($pgcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
41 |
+
<span class="description">Caching pages will reduce the response time of and increase the concurrency potential (scale) of your web server.</span>
|
42 |
</td>
|
43 |
</tr>
|
44 |
<tr>
|
45 |
<th valign="top">Page Caching Method:</th>
|
46 |
<td>
|
47 |
+
<label><input type="radio" name="pgcache.engine" value="file"<?php checked($config->get_string('pgcache.engine'), 'file'); ?> /> Disk</label><br />
|
48 |
<label><input type="radio" name="pgcache.engine" value="memcached"<?php checked($config->get_string('pgcache.engine'), 'memcached'); ?> /> Memcached <?php echo $memcache_engine; ?></label><br />
|
49 |
<label><input type="radio" name="pgcache.engine" value="apc"<?php checked($config->get_string('pgcache.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?> /> <acronym title="Alternative PHP Cache">APC</acronym></label><br />
|
50 |
</td>
|
80 |
<td>
|
81 |
<input type="hidden" name="dbcache.enabled" value="0" />
|
82 |
<label><input class="enabled" type="checkbox" name="dbcache.enabled" value="1"<?php checked($dbcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
83 |
+
<span class="description">Caching database objects may decrease the response time of your blog by at least an order of magnitude.</span>
|
84 |
</td>
|
85 |
</tr>
|
86 |
<tr>
|
106 |
<th><acronym title="Content Delivery Network">CDN</acronym> Type:</th>
|
107 |
<td>
|
108 |
<label><input type="radio" name="cdn.engine" value="ftp"<?php checked($config->get_string('cdn.engine'), 'ftp'); ?> /> <acronym title="File Transfer Protocol">FTP</acronym></label><br />
|
109 |
+
<label><input type="radio" name="cdn.engine" value="mirror"<?php checked($config->get_string('cdn.engine'), 'mirror'); ?> /> Mirror (Origin Pull)</label><br />
|
110 |
<span class="description">Select the <acronym title="Content Delivery Network">CDN</acronym> type you wish to use.</span>
|
111 |
</td>
|
112 |
</tr>
|
inc/options/install.phtml
CHANGED
@@ -55,12 +55,12 @@
|
|
55 |
<li>Let's compile:<br />
|
56 |
# ./configure && make && make install</li>
|
57 |
<li>Make sure memcached is starts automatically on server boot:<br />
|
58 |
-
# touch /etc/init.d/memcached<br />
|
59 |
-
# echo '#!/bin/sh -e' >> /etc/init.d/memcached<br />
|
60 |
-
# echo '/usr/local/bin/memcached -d -m 128 -p 11211 -u nobody -l localhost' >> /etc/init.d/memcached<br />
|
61 |
-
# chmod u+x /etc/init.d/memcached</li>
|
62 |
<li>And finally, let's start memcached:<br />
|
63 |
-
# /etc/init.d/memcached</li>
|
64 |
</ol>
|
65 |
<p>For windows users we recommend checking the following sites for more installation tips:</p>
|
66 |
<ul>
|
@@ -142,7 +142,7 @@
|
|
142 |
<p><strong>Note(s):</strong></p>
|
143 |
<ul>
|
144 |
<li>The provided instructions are for CentOS, however we can provide others based on <a href="mailto:wordpressexperts@w3-edge.com">your requests</a>.</li>
|
145 |
-
<li>In the case where the "Rewrite <acronym>URL</acronym> Structure" (in <a href="/wp-admin/options-general.php?page=w3-total-cache/w3-total-cache.php&tab=minify">Minify Settings</a> tab) is desired, and apache is not used, the file located in wp-content/plugins/w3-total-cache/wp-content/w3tc
|
146 |
<li>Restarting the web server will empty your <acronym title="Alternative PHP Cache">APC</acronym> cache, which means it will have to be rebuilt over time and your site's performance will suffer during this period. Still, <acronym title="Alternative PHP Cache">APC</acronym> should be installed in any case to maximize WordPress performance.</li>
|
147 |
<li>Consider using memcached for objects that must persist across web server restarts or that you wish to share amongst your pool of servers (or cluster), e.g.: database objects or page cache.</li>
|
148 |
<li>Some yum or mirrors may not have the necessary packages, in such cases you may have to do a manual installation.</li>
|
55 |
<li>Let's compile:<br />
|
56 |
# ./configure && make && make install</li>
|
57 |
<li>Make sure memcached is starts automatically on server boot:<br />
|
58 |
+
# touch /etc/rc.d/init.d/memcached<br />
|
59 |
+
# echo '#!/bin/sh -e' >> /etc/rc.d/init.d/memcached<br />
|
60 |
+
# echo '/usr/local/bin/memcached -d -m 128 -p 11211 -u nobody -l localhost' >> /etc/rc.d/init.d/memcached<br />
|
61 |
+
# chmod u+x /etc/rc.d/init.d/memcached</li>
|
62 |
<li>And finally, let's start memcached:<br />
|
63 |
+
# /etc/rc.d/init.d/memcached</li>
|
64 |
</ol>
|
65 |
<p>For windows users we recommend checking the following sites for more installation tips:</p>
|
66 |
<ul>
|
142 |
<p><strong>Note(s):</strong></p>
|
143 |
<ul>
|
144 |
<li>The provided instructions are for CentOS, however we can provide others based on <a href="mailto:wordpressexperts@w3-edge.com">your requests</a>.</li>
|
145 |
+
<li>In the case where the "Rewrite <acronym>URL</acronym> Structure" (in <a href="/wp-admin/options-general.php?page=w3-total-cache/w3-total-cache.php&tab=minify">Minify Settings</a> tab) is desired, and apache is not used, the file located in wp-content/plugins/w3-total-cache/wp-content/w3tc/.htaccess contains directives that must be created for the directory: wp-content/w3tc/.</li>
|
146 |
<li>Restarting the web server will empty your <acronym title="Alternative PHP Cache">APC</acronym> cache, which means it will have to be rebuilt over time and your site's performance will suffer during this period. Still, <acronym title="Alternative PHP Cache">APC</acronym> should be installed in any case to maximize WordPress performance.</li>
|
147 |
<li>Consider using memcached for objects that must persist across web server restarts or that you wish to share amongst your pool of servers (or cluster), e.g.: database objects or page cache.</li>
|
148 |
<li>Some yum or mirrors may not have the necessary packages, in such cases you may have to do a manual installation.</li>
|
inc/options/minify.phtml
CHANGED
@@ -1,33 +1,34 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
-
$js_files = array();
|
16 |
$js_groups = $config->get_array('minify.js.groups');
|
17 |
-
$
|
18 |
-
|
19 |
-
foreach ($js_check_groups as $js_check_group) {
|
20 |
-
if (isset($js_groups[$js_check_group]['files'])) {
|
21 |
-
foreach ((array) $js_groups[$js_check_group]['files'] as $file) {
|
22 |
-
$js_files[$file] = $js_check_group;
|
23 |
-
}
|
24 |
-
}
|
25 |
-
}
|
26 |
|
27 |
?>
|
28 |
<h3>Minify Settings</h3>
|
29 |
|
30 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
<form id="minify_form" action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
33 |
<table class="form-table">
|
@@ -35,9 +36,8 @@ foreach ($js_check_groups as $js_check_group) {
|
|
35 |
<th style="width: 250px;"><label for="memcached_servers">Memcached Hostname:Port / IP:Port:</label></th>
|
36 |
<td>
|
37 |
<input id="memcached_servers" type="text" name="minify.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $config->get_array('minify.memcached.servers'))); ?>" size="100"<?php if (! $minify_memcached): ?> disabled="disabled"<?php endif; ?> />
|
38 |
-
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
39 |
<input id="test_memcached" class="button" type="button" value="Test"<?php if (! $minify_memcached): ?> disabled="disabled"<?php endif; ?> />
|
40 |
-
<
|
41 |
<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
|
42 |
</td>
|
43 |
</tr>
|
@@ -78,9 +78,13 @@ foreach ($js_check_groups as $js_check_group) {
|
|
78 |
<td>
|
79 |
<input type="hidden" name="minify.html.enable" value="0" />
|
80 |
<input type="hidden" name="minify.html.reject.admin" value="0" />
|
|
|
|
|
81 |
<input type="hidden" name="minify.html.strip.crlf" value="0" />
|
82 |
<label><input id="html_enabled" type="checkbox" name="minify.html.enable" value="1"<?php checked($config->get_boolean('minify.html.enable'), true); ?> /> Minify</label><br />
|
83 |
<label><input class="html_enabled" type="checkbox" name="minify.html.reject.admin" value="1"<?php checked($config->get_boolean('minify.html.reject.admin'), true); ?> /> Don't Minify <acronym title="Hypertext Markup Language">HTML</acronym> for logged in administrators</label><br />
|
|
|
|
|
84 |
<label><input class="html_enabled" type="checkbox" name="minify.html.strip.crlf" value="1"<?php checked($config->get_boolean('minify.html.strip.crlf'), true); ?> /> Line break removal</label><br />
|
85 |
</td>
|
86 |
</tr>
|
@@ -113,30 +117,56 @@ foreach ($js_check_groups as $js_check_group) {
|
|
113 |
<tr>
|
114 |
<th valign="top"><acronym title="JavaScript">JS</acronym> File Management:</th>
|
115 |
<td>
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
<?php endforeach; ?>
|
121 |
-
|
122 |
-
|
123 |
-
<div id="js_files_empty" class="w3tc-empty">No <acronym title="JavaScript">JS</acronym> files added</div>
|
124 |
-
<?php endif; ?>
|
125 |
<input id="js_file_add" class="js_enabled button" type="button" value="Add a script" />
|
126 |
</td>
|
127 |
</tr>
|
128 |
<tr>
|
129 |
<th valign="top"><acronym title="Cascading Style Sheets">CSS</acronym> File Management:</th>
|
130 |
<td>
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
<?php endforeach; ?>
|
136 |
-
|
137 |
-
|
138 |
-
<div id="css_files_empty" class="w3tc-empty">No <acronym title="Cascading Style Sheets">CSS</acronym> files added</div>
|
139 |
-
<?php endif; ?>
|
140 |
<input id="css_file_add" class="css_enabled button" type="button" value="Add a style sheet" />
|
141 |
</td>
|
142 |
</tr>
|
1 |
<?php
|
2 |
|
3 |
+
$groups = array(
|
4 |
+
'404' => '404',
|
5 |
+
'archive' => 'Archive',
|
6 |
+
'attachment' => 'Attachment',
|
7 |
+
'author' => 'Author',
|
8 |
+
'category' => 'Category',
|
9 |
+
'date' => 'Date',
|
10 |
+
'default' => 'Default',
|
11 |
+
'home' => 'Home',
|
12 |
+
'page' => 'Page',
|
13 |
+
'search' => 'Search',
|
14 |
+
'single' => 'Single',
|
15 |
+
'tag' => 'Tag',
|
16 |
+
);
|
17 |
|
|
|
18 |
$js_groups = $config->get_array('minify.js.groups');
|
19 |
+
$css_groups = $config->get_array('minify.css.groups');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
?>
|
22 |
<h3>Minify Settings</h3>
|
23 |
|
24 |
+
<form action="options-general.php">
|
25 |
+
<p>
|
26 |
+
Minify is currently <span class="w3tc-<?php if ($minify_enabled): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>.
|
27 |
+
<input type="submit" name="flush_minify" value="Empty cache"<?php if (! $minify_enabled): ?> disabled="disabled"<?php endif; ?> class="button" />
|
28 |
+
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
29 |
+
<input type="hidden" name="tab" value="<?php echo $tab; ?>" />
|
30 |
+
</p>
|
31 |
+
</form>
|
32 |
|
33 |
<form id="minify_form" action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
34 |
<table class="form-table">
|
36 |
<th style="width: 250px;"><label for="memcached_servers">Memcached Hostname:Port / IP:Port:</label></th>
|
37 |
<td>
|
38 |
<input id="memcached_servers" type="text" name="minify.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $config->get_array('minify.memcached.servers'))); ?>" size="100"<?php if (! $minify_memcached): ?> disabled="disabled"<?php endif; ?> />
|
|
|
39 |
<input id="test_memcached" class="button" type="button" value="Test"<?php if (! $minify_memcached): ?> disabled="disabled"<?php endif; ?> />
|
40 |
+
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
41 |
<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
|
42 |
</td>
|
43 |
</tr>
|
78 |
<td>
|
79 |
<input type="hidden" name="minify.html.enable" value="0" />
|
80 |
<input type="hidden" name="minify.html.reject.admin" value="0" />
|
81 |
+
<input type="hidden" name="minify.html.inline.css" value="0" />
|
82 |
+
<input type="hidden" name="minify.html.inline.js" value="0" />
|
83 |
<input type="hidden" name="minify.html.strip.crlf" value="0" />
|
84 |
<label><input id="html_enabled" type="checkbox" name="minify.html.enable" value="1"<?php checked($config->get_boolean('minify.html.enable'), true); ?> /> Minify</label><br />
|
85 |
<label><input class="html_enabled" type="checkbox" name="minify.html.reject.admin" value="1"<?php checked($config->get_boolean('minify.html.reject.admin'), true); ?> /> Don't Minify <acronym title="Hypertext Markup Language">HTML</acronym> for logged in administrators</label><br />
|
86 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.inline.css" value="1"<?php checked($config->get_boolean('minify.html.inline.css'), true); ?> /> Inline CSS Minification</label><br />
|
87 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.inline.js" value="1"<?php checked($config->get_boolean('minify.html.inline.js'), true); ?> /> Inline JS Minification</label><br />
|
88 |
<label><input class="html_enabled" type="checkbox" name="minify.html.strip.crlf" value="1"<?php checked($config->get_boolean('minify.html.strip.crlf'), true); ?> /> Line break removal</label><br />
|
89 |
</td>
|
90 |
</tr>
|
117 |
<tr>
|
118 |
<th valign="top"><acronym title="JavaScript">JS</acronym> File Management:</th>
|
119 |
<td>
|
120 |
+
<p>
|
121 |
+
<label>
|
122 |
+
<select id="js_groups" class="js_enabled">
|
123 |
+
<?php foreach ($groups as $groupKey => $groupText): ?>
|
124 |
+
<option value="<?php echo $groupKey; ?>"><?php echo $groupText; ?></option>
|
125 |
+
<?php endforeach; ?>
|
126 |
+
</select>
|
127 |
+
Group:
|
128 |
+
</label>
|
129 |
+
</p>
|
130 |
+
<ol id="js_files">
|
131 |
+
<?php foreach ($js_groups as $js_group => $js_locations): ?>
|
132 |
+
<?php foreach ((array) $js_locations as $js_location => $js_config): ?>
|
133 |
+
<?php if (! empty($js_config['files'])): foreach ((array) $js_config['files'] as $js_file): ?>
|
134 |
+
<li>
|
135 |
+
<input class="js_enabled" type="text" name="js_files[<?php echo htmlspecialchars($js_group); ?>][<?php echo htmlspecialchars($js_location); ?>][]" value="<?php echo htmlspecialchars($js_file); ?>" size="100" /> <select class="js_file_location js_enabled"><option value="include"<?php if ($js_location == 'include'): ?> selected="selected"<?php endif; ?>>Embed in: Header</option><option value="include-nb"<?php if ($js_location == 'include-nb'): ?> selected="selected"<?php endif; ?>>Embed in: Header (non-blocking)</option><option value="include-footer"<?php if ($js_location == 'include-footer'): ?> selected="selected"<?php endif; ?>>Embed in: Footer</option><option value="include-footer-nb"<?php if ($js_location == 'include-footer-nb'): ?> selected="selected"<?php endif; ?>>Embed in: Footer (non-blocking)</option></select> <input class="js_file_delete js_enabled button" type="button" value="Delete" /> <input class="js_file_verify js_enabled button" type="button" value="Verify URI" />
|
136 |
+
</li>
|
137 |
+
<?php endforeach; endif; ?>
|
138 |
<?php endforeach; ?>
|
139 |
+
<?php endforeach; ?>
|
140 |
+
</ol>
|
141 |
+
<div id="js_files_empty" class="w3tc-empty" style="display: none;">No <acronym title="JavaScript">JS</acronym> files added</div>
|
|
|
142 |
<input id="js_file_add" class="js_enabled button" type="button" value="Add a script" />
|
143 |
</td>
|
144 |
</tr>
|
145 |
<tr>
|
146 |
<th valign="top"><acronym title="Cascading Style Sheets">CSS</acronym> File Management:</th>
|
147 |
<td>
|
148 |
+
<p>
|
149 |
+
<label>
|
150 |
+
<select id="css_groups" class="css_enabled">
|
151 |
+
<?php foreach ($groups as $groupKey => $groupText): ?>
|
152 |
+
<option value="<?php echo $groupKey; ?>"><?php echo $groupText; ?></option>
|
153 |
+
<?php endforeach; ?>
|
154 |
+
</select>
|
155 |
+
Group:
|
156 |
+
</label>
|
157 |
+
</p>
|
158 |
+
<ol id="css_files">
|
159 |
+
<?php foreach ($css_groups as $css_group => $css_locations): ?>
|
160 |
+
<?php foreach ((array) $css_locations as $css_location => $css_config): ?>
|
161 |
+
<?php if (! empty($css_config['files'])): foreach ((array) $css_config['files'] as $css_file): ?>
|
162 |
+
<li>
|
163 |
+
<input class="css_enabled" type="text" name="css_files[<?php echo htmlspecialchars($css_group); ?>][<?php echo htmlspecialchars($css_location); ?>][]" value="<?php echo htmlspecialchars($css_file); ?>" size="100" /> <input class="css_file_delete css_enabled button" type="button" value="Delete" /> <input class="css_file_verify css_enabled button" type="button" value="Verify URI" />
|
164 |
+
</li>
|
165 |
+
<?php endforeach; endif; ?>
|
166 |
<?php endforeach; ?>
|
167 |
+
<?php endforeach; ?>
|
168 |
+
</ol>
|
169 |
+
<div id="css_files_empty" class="w3tc-empty" style="display: none;">No <acronym title="Cascading Style Sheets">CSS</acronym> files added</div>
|
|
|
170 |
<input id="css_file_add" class="css_enabled button" type="button" value="Add a style sheet" />
|
171 |
</td>
|
172 |
</tr>
|
inc/options/pgcache.phtml
CHANGED
@@ -1,6 +1,14 @@
|
|
1 |
<h3>Page Cache Settings</h3>
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
6 |
<table class="form-table">
|
@@ -8,9 +16,8 @@
|
|
8 |
<th style="width: 250px;"><label for="memcached_servers">Memcached Hostname:Port / IP:Port:</label></th>
|
9 |
<td>
|
10 |
<input id="memcached_servers" type="text" name="pgcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $config->get_array('pgcache.memcached.servers'))); ?>" size="100"<?php if (! $pgcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
11 |
-
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
12 |
<input id="test_memcached" class="button" type="button" value="Test"<?php if (! $pgcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
13 |
-
<
|
14 |
<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
|
15 |
</td>
|
16 |
</tr>
|
@@ -20,8 +27,8 @@
|
|
20 |
</tr>
|
21 |
<tr>
|
22 |
<th colspan="2">
|
23 |
-
<input type="hidden" name="pgcache.
|
24 |
-
<label><input type="checkbox" name="pgcache.
|
25 |
</th>
|
26 |
</tr>
|
27 |
<tr>
|
1 |
<h3>Page Cache Settings</h3>
|
2 |
|
3 |
+
|
4 |
+
<form action="options-general.php">
|
5 |
+
<p>
|
6 |
+
Page Caching is currently <span class="w3tc-<?php if ($pgcache_enabled): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>.
|
7 |
+
<input type="submit" name="flush_pgcache" value="Empty cache"<?php if (! $pgcache_enabled): ?> disabled="disabled"<?php endif; ?> class="button" />
|
8 |
+
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
9 |
+
<input type="hidden" name="tab" value="<?php echo $tab; ?>" />
|
10 |
+
</p>
|
11 |
+
</form>
|
12 |
|
13 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $tab; ?>" method="post">
|
14 |
<table class="form-table">
|
16 |
<th style="width: 250px;"><label for="memcached_servers">Memcached Hostname:Port / IP:Port:</label></th>
|
17 |
<td>
|
18 |
<input id="memcached_servers" type="text" name="pgcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $config->get_array('pgcache.memcached.servers'))); ?>" size="100"<?php if (! $pgcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
|
|
19 |
<input id="test_memcached" class="button" type="button" value="Test"<?php if (! $pgcache_memcached): ?> disabled="disabled"<?php endif; ?> />
|
20 |
+
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
21 |
<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
|
22 |
</td>
|
23 |
</tr>
|
27 |
</tr>
|
28 |
<tr>
|
29 |
<th colspan="2">
|
30 |
+
<input type="hidden" name="pgcache.reject.logged" value="0" />
|
31 |
+
<label><input type="checkbox" name="pgcache.reject.logged" value="1"<?php checked($config->get_boolean('pgcache.reject.logged'), true); ?> /> Don't cache pages for logged in users</label>
|
32 |
</th>
|
33 |
</tr>
|
34 |
<tr>
|
inc/popup/cdn_export_file.phtml
CHANGED
@@ -24,6 +24,14 @@ jQuery(function() {
|
|
24 |
<td>Status:</td>
|
25 |
<td id="cdn_export_file_status">-</td>
|
26 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</table>
|
28 |
|
29 |
<p>
|
24 |
<td>Status:</td>
|
25 |
<td id="cdn_export_file_status">-</td>
|
26 |
</tr>
|
27 |
+
<tr>
|
28 |
+
<td>Time elapsed:</td>
|
29 |
+
<td id="cdn_export_file_elapsed">-</td>
|
30 |
+
</tr>
|
31 |
+
<tr>
|
32 |
+
<td>Last response:</td>
|
33 |
+
<td id="cdn_export_file_last_response">-</td>
|
34 |
+
</tr>
|
35 |
</table>
|
36 |
|
37 |
<p>
|
inc/popup/cdn_export_library.phtml
CHANGED
@@ -19,6 +19,14 @@ jQuery(function() {
|
|
19 |
<td>Status:</td>
|
20 |
<td id="cdn_export_library_status">-</td>
|
21 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
</table>
|
23 |
|
24 |
<p>
|
19 |
<td>Status:</td>
|
20 |
<td id="cdn_export_library_status">-</td>
|
21 |
</tr>
|
22 |
+
<tr>
|
23 |
+
<td>Time elapsed:</td>
|
24 |
+
<td id="cdn_export_library_elapsed">-</td>
|
25 |
+
</tr>
|
26 |
+
<tr>
|
27 |
+
<td>Last response:</td>
|
28 |
+
<td id="cdn_export_library_last_response">-</td>
|
29 |
+
</tr>
|
30 |
</table>
|
31 |
|
32 |
<p>
|
inc/popup/cdn_import_library.phtml
CHANGED
@@ -21,6 +21,14 @@ jQuery(function() {
|
|
21 |
<td>Status:</td>
|
22 |
<td id="cdn_import_library_status">-</td>
|
23 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
<tr>
|
25 |
<td colspan="2">
|
26 |
<label><input id="cdn_import_library_redirect_permanent" type="checkbox" checked="checked" /> Use permanent redirects</label>
|
@@ -28,7 +36,7 @@ jQuery(function() {
|
|
28 |
</tr>
|
29 |
<tr>
|
30 |
<td colspan="2">
|
31 |
-
<label><input id="cdn_import_library_redirect_cdn" type="checkbox" checked="checked" /> Redirect to CDN</label>
|
32 |
</td>
|
33 |
</tr>
|
34 |
</table>
|
@@ -46,7 +54,7 @@ jQuery(function() {
|
|
46 |
<div id="cdn_import_library_log" class="log"></div>
|
47 |
|
48 |
<p>
|
49 |
-
Add the following directives to your .htaccess file or if there are several hundred
|
50 |
</p>
|
51 |
|
52 |
<p>
|
21 |
<td>Status:</td>
|
22 |
<td id="cdn_import_library_status">-</td>
|
23 |
</tr>
|
24 |
+
<tr>
|
25 |
+
<td>Time elapsed:</td>
|
26 |
+
<td id="cdn_import_library_elapsed">-</td>
|
27 |
+
</tr>
|
28 |
+
<tr>
|
29 |
+
<td>Last response:</td>
|
30 |
+
<td id="cdn_import_library_last_response">-</td>
|
31 |
+
</tr>
|
32 |
<tr>
|
33 |
<td colspan="2">
|
34 |
<label><input id="cdn_import_library_redirect_permanent" type="checkbox" checked="checked" /> Use permanent redirects</label>
|
36 |
</tr>
|
37 |
<tr>
|
38 |
<td colspan="2">
|
39 |
+
<label><input id="cdn_import_library_redirect_cdn" type="checkbox" checked="checked" /> Redirect to <acronym title="Content Delivery Network">CDN</acronym></label>
|
40 |
</td>
|
41 |
</tr>
|
42 |
</table>
|
54 |
<div id="cdn_import_library_log" class="log"></div>
|
55 |
|
56 |
<p>
|
57 |
+
Add the following directives to your .htaccess file or if there are several hundred they should be added directly to your configuration file:
|
58 |
</p>
|
59 |
|
60 |
<p>
|
inc/popup/cdn_rename_domain.phtml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
/*<![CDATA[*/
|
3 |
+
jQuery(function() {
|
4 |
+
Cdn_Rename_Domain.init();
|
5 |
+
});
|
6 |
+
/*]]>*/
|
7 |
+
</script>
|
8 |
+
|
9 |
+
<table cellspacing="5">
|
10 |
+
<tr>
|
11 |
+
<td>Total posts:</td>
|
12 |
+
<td id="cdn_rename_domain_total"><?php echo $total; ?></td>
|
13 |
+
</tr>
|
14 |
+
<tr>
|
15 |
+
<td>Processed:</td>
|
16 |
+
<td id="cdn_rename_domain_processed">0</td>
|
17 |
+
</tr>
|
18 |
+
<tr>
|
19 |
+
<td>Status:</td>
|
20 |
+
<td id="cdn_rename_domain_status">-</td>
|
21 |
+
</tr>
|
22 |
+
<tr>
|
23 |
+
<td>Time elapsed:</td>
|
24 |
+
<td id="cdn_rename_domain_elapsed">-</td>
|
25 |
+
</tr>
|
26 |
+
<tr>
|
27 |
+
<td>Last response:</td>
|
28 |
+
<td id="cdn_rename_domain_last_response">-</td>
|
29 |
+
</tr>
|
30 |
+
<tr>
|
31 |
+
<td>Domains to rename:</td>
|
32 |
+
<td><textarea cols="30" rows="3" id="cdn_rename_domain_names"></textarea></td>
|
33 |
+
</tr>
|
34 |
+
</table>
|
35 |
+
|
36 |
+
<p>
|
37 |
+
<input id="cdn_rename_domain_start" class="button" type="button" value="Start"<?php if (! $total): ?> disabled="disabled"<?php endif; ?> />
|
38 |
+
</p>
|
39 |
+
|
40 |
+
<div id="cdn_rename_domain_progress" class="progress">
|
41 |
+
<div class="progress-value">0%</div>
|
42 |
+
<div class="progress-bar"></div>
|
43 |
+
<div class="clear"></div>
|
44 |
+
</div>
|
45 |
+
|
46 |
+
<div id="cdn_rename_domain_log" class="log"></div>
|
inc/popup/common/header.phtml
CHANGED
@@ -14,9 +14,9 @@
|
|
14 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
15 |
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
16 |
<head>
|
17 |
-
<link rel="stylesheet" type="text/css" href="
|
18 |
-
<script type="text/javascript" src="
|
19 |
-
<script type="text/javascript" src="
|
20 |
<title><?php echo htmlspecialchars($title); ?> - W3 Total Cache</title>
|
21 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
22 |
</head>
|
14 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
15 |
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
16 |
<head>
|
17 |
+
<link rel="stylesheet" type="text/css" href="<?php echo WP_PLUGIN_URL; ?>/w3-total-cache/inc/css/popup.css"></link>
|
18 |
+
<script type="text/javascript" src="<?php echo w3_get_site_url(); ?>/<?php echo WPINC; ?>/js/jquery/jquery.js"></script>
|
19 |
+
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/w3-total-cache/inc/js/popup.js"></script>
|
20 |
<title><?php echo htmlspecialchars($title); ?> - W3 Total Cache</title>
|
21 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
22 |
</head>
|
ini/_htaccess
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Append the contents of this file to this .htaccess to the one in your document root or configuration file to enable http
|
2 |
+
# compression and client-side (browser) caching of files that W3 Total Cache does not handle. This file can also be used
|
3 |
+
# for the self-hosted subdomain used in your CDN settings.
|
4 |
+
|
5 |
+
# BEGIN HTTP Compression
|
6 |
+
<IfModule mod_deflate.c>
|
7 |
+
# Netscape 4.x has some problems...
|
8 |
+
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
9 |
+
# Netscape 4.06-4.08 have some more problems
|
10 |
+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
11 |
+
# MSIE masquerades as Netscape, but it is fine
|
12 |
+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
13 |
+
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
|
14 |
+
# the above regex won't work. You can use the following
|
15 |
+
# workaround to get the desired effect:
|
16 |
+
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
|
17 |
+
# Don't compress media or scripts
|
18 |
+
SetEnvIfNoCase Request_URI \
|
19 |
+
\.(?:php|gif|jpe?g|png|swf|pdf|zip|tar|rar|mp3|mov|rm|ram|wav|wma|wmv|asf|avi|mpg|mpeg|tgz|qt|doc|xls|ppt)$ no-gzip$
|
20 |
+
# Make sure proxies don't deliver the wrong content
|
21 |
+
Header append Vary User-Agent env=!dont-vary
|
22 |
+
# Fragment size to be compressed at one time by zlib
|
23 |
+
#DeflateBufferSize 4096
|
24 |
+
# Fragment size to be compressed at one time by zlib
|
25 |
+
#DeflateCompressionLevel 9
|
26 |
+
# How much memory should be used by zlib for compression
|
27 |
+
#DeflateMemLevel 9
|
28 |
+
# Zlib compression window size
|
29 |
+
#DeflateWindowSize 15
|
30 |
+
# Enable HTTP Compression policy for all except .css, .js and .html documents
|
31 |
+
SetOutputFilter DEFLATE
|
32 |
+
AddOutputFilterByType DEFLATE text/plain text/xml application/xml text/xsd text/xsl application/wlwmanifest+xml image/x-icon
|
33 |
+
</IfModule>
|
34 |
+
# END HTTP Compression
|
35 |
+
|
36 |
+
# BEGIN Headers
|
37 |
+
# Browser caching policy for all except .css, .js and .html documents
|
38 |
+
<IfModule mod_expires.c>
|
39 |
+
ExpiresActive On
|
40 |
+
ExpiresByType text/plain A31536000
|
41 |
+
ExpiresByType text/xml A31536000
|
42 |
+
ExpiresByType application/xml A31536000
|
43 |
+
ExpiresByType text/xsd A31536000
|
44 |
+
ExpiresByType text/xsl A31536000
|
45 |
+
ExpiresByType application/wlwmanifest+xml A31536000
|
46 |
+
ExpiresByType image/png A31536000
|
47 |
+
ExpiresByType image/jpeg A31536000
|
48 |
+
ExpiresByType image/jpg A31536000
|
49 |
+
ExpiresByType image/pjpeg A31536000
|
50 |
+
ExpiresByType image/gif A31536000
|
51 |
+
ExpiresByType image/x-icon A31536000
|
52 |
+
</IfModule>
|
53 |
+
|
54 |
+
<IfModule mod_headers.c>
|
55 |
+
<FilesMatch "\.(ico|xml|xsd|xsl|gif|jpe?g|png|swf|pdf|zip|tar|rar|mp3|mov|rm|ram|wav|wma|wmv|asf|avi|mpg|mpeg|tgz|qt|doc|xls|ppt)$">
|
56 |
+
# Set header information for proxies
|
57 |
+
Header append Vary User-Agent
|
58 |
+
# Ensure client-side caching of objects
|
59 |
+
Header set Cache-Control "max-age=31536000, public"
|
60 |
+
</FilesMatch>
|
61 |
+
</IfModule>
|
62 |
+
|
63 |
+
# Enable Entity Tag
|
64 |
+
<FilesMatch "\.(ico|xml|xsd|xsl|gif|jpe?g|png|swf|pdf|zip|tar|rar|mp3|mov|rm|ram|wav|wma|wmv|asf|avi|mpg|mpeg|tgz|qt|doc|xls|ppt)$">
|
65 |
+
FileETag MTime Size
|
66 |
+
</FilesMatch>
|
67 |
+
# END Headers
|
ini/apc.ini
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
# /etc/php.d/apc.ini
|
2 |
|
3 |
; Enable apc extension module
|
4 |
-
extension=apc.so
|
5 |
; Options for the apc module
|
6 |
-
apc.enabled=1
|
7 |
-
apc.shm_segments=1
|
8 |
-
apc.optimization=0
|
9 |
-
apc.shm_size=128
|
10 |
-
apc.ttl=7200
|
11 |
-
apc.user_ttl=7200
|
12 |
-
apc.num_files_hint=1024
|
13 |
-
apc.mmap_file_mask
|
14 |
-
apc.enable_cli=1
|
15 |
-
apc.cache_by_default=1
|
16 |
apc.apc.stat = 0
|
17 |
apc.include_once_override = 1
|
1 |
# /etc/php.d/apc.ini
|
2 |
|
3 |
; Enable apc extension module
|
4 |
+
extension = apc.so
|
5 |
; Options for the apc module
|
6 |
+
apc.enabled = 1
|
7 |
+
apc.shm_segments = 1
|
8 |
+
apc.optimization = 0
|
9 |
+
apc.shm_size = 128
|
10 |
+
apc.ttl = 7200
|
11 |
+
apc.user_ttl = 7200
|
12 |
+
apc.num_files_hint = 1024
|
13 |
+
apc.mmap_file_mask = /tmp/apc.XXXXXX
|
14 |
+
apc.enable_cli = 1
|
15 |
+
apc.cache_by_default = 1
|
16 |
apc.apc.stat = 0
|
17 |
apc.include_once_override = 1
|
ini/php.append.ini
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
; Use memcache as a session handler
|
2 |
session.save_handler = memcache
|
3 |
; Use a comma separated list of server urls to use for storage:
|
4 |
-
session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
|
1 |
; Use memcache as a session handler
|
2 |
session.save_handler = memcache
|
3 |
; Use a comma separated list of server urls to use for storage:
|
4 |
+
session.save_path = "tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
|
lib/W3/Cache.php
CHANGED
@@ -51,7 +51,7 @@ class W3_Cache
|
|
51 |
|
52 |
case W3_CACHE_FILE:
|
53 |
require_once W3TC_LIB_W3_DIR . '/Cache/File.php';
|
54 |
-
$instances[$instance_key] = & new W3_Cache_File();
|
55 |
break;
|
56 |
|
57 |
default:
|
@@ -61,7 +61,7 @@ class W3_Cache
|
|
61 |
break;
|
62 |
}
|
63 |
}
|
64 |
-
|
65 |
return $instances[$instance_key];
|
66 |
}
|
67 |
}
|
51 |
|
52 |
case W3_CACHE_FILE:
|
53 |
require_once W3TC_LIB_W3_DIR . '/Cache/File.php';
|
54 |
+
$instances[$instance_key] = & new W3_Cache_File($config);
|
55 |
break;
|
56 |
|
57 |
default:
|
61 |
break;
|
62 |
}
|
63 |
}
|
64 |
+
|
65 |
return $instances[$instance_key];
|
66 |
}
|
67 |
}
|
lib/W3/Cache/File.php
CHANGED
@@ -21,30 +21,23 @@ class W3_Cache_File extends W3_Cache_Base
|
|
21 |
*/
|
22 |
var $_cache_dir = '';
|
23 |
|
24 |
-
/**
|
25 |
-
* Current time
|
26 |
-
*
|
27 |
-
* @var integer
|
28 |
-
*/
|
29 |
-
var $_time = 0;
|
30 |
-
|
31 |
/**
|
32 |
* PHP5 constructor
|
33 |
*
|
34 |
* @param array $config
|
35 |
*/
|
36 |
-
function __construct($config)
|
37 |
{
|
38 |
$this->_cache_dir = isset($config['cache_dir']) ? trim($config['cache_dir']) : 'cache';
|
39 |
-
$this->_time = time();
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
* PHP4 constructor
|
44 |
*
|
|
|
45 |
* @return W3_Cache_File
|
46 |
*/
|
47 |
-
function W3_Cache_File()
|
48 |
{
|
49 |
$this->__construct($config);
|
50 |
}
|
@@ -77,11 +70,15 @@ class W3_Cache_File extends W3_Cache_Base
|
|
77 |
function set($key, $var, $expire = 0)
|
78 |
{
|
79 |
$path = $this->_get_path($key);
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
return false;
|
87 |
}
|
@@ -94,21 +91,32 @@ class W3_Cache_File extends W3_Cache_Base
|
|
94 |
*/
|
95 |
function get($key)
|
96 |
{
|
|
|
|
|
97 |
$path = $this->_get_path($key);
|
98 |
-
if (is_readable($path)
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
$
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
-
@fclose($fp);
|
107 |
-
return @unserialize($data);
|
108 |
}
|
109 |
-
@fclose($fp);
|
110 |
}
|
111 |
-
|
|
|
112 |
}
|
113 |
|
114 |
/**
|
@@ -150,6 +158,7 @@ class W3_Cache_File extends W3_Cache_Base
|
|
150 |
*/
|
151 |
function flush()
|
152 |
{
|
|
|
153 |
}
|
154 |
|
155 |
/**
|
@@ -161,11 +170,7 @@ class W3_Cache_File extends W3_Cache_Base
|
|
161 |
function _get_path($key)
|
162 |
{
|
163 |
$hash = md5($key);
|
164 |
-
$path = sprintf('%s/%s/%s/%s', $this->_cache_dir, substr($hash, 0, 2), substr($hash, 2, 2),
|
165 |
-
$dir = dirname($path);
|
166 |
-
if (! is_dir($dir)) {
|
167 |
-
w3_mkdir($dir);
|
168 |
-
}
|
169 |
|
170 |
return $path;
|
171 |
}
|
21 |
*/
|
22 |
var $_cache_dir = '';
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
/**
|
25 |
* PHP5 constructor
|
26 |
*
|
27 |
* @param array $config
|
28 |
*/
|
29 |
+
function __construct($config = array())
|
30 |
{
|
31 |
$this->_cache_dir = isset($config['cache_dir']) ? trim($config['cache_dir']) : 'cache';
|
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
* PHP4 constructor
|
36 |
*
|
37 |
+
*@paran array $config
|
38 |
* @return W3_Cache_File
|
39 |
*/
|
40 |
+
function W3_Cache_File($config = array())
|
41 |
{
|
42 |
$this->__construct($config);
|
43 |
}
|
70 |
function set($key, $var, $expire = 0)
|
71 |
{
|
72 |
$path = $this->_get_path($key);
|
73 |
+
$dir = dirname(str_replace($this->_cache_dir, '', $path));
|
74 |
+
if ((is_dir($dir) || w3_mkdir($dir, 0755, $this->_cache_dir))) {
|
75 |
+
$fp = @fopen($path, 'wb');
|
76 |
+
if ($fp) {
|
77 |
+
@fputs($fp, pack('L', $expire));
|
78 |
+
@fputs($fp, @serialize($var));
|
79 |
+
@fclose($fp);
|
80 |
+
return true;
|
81 |
+
}
|
82 |
}
|
83 |
return false;
|
84 |
}
|
91 |
*/
|
92 |
function get($key)
|
93 |
{
|
94 |
+
$pwd = getcwd();
|
95 |
+
$var = false;
|
96 |
$path = $this->_get_path($key);
|
97 |
+
if (is_readable($path)) {
|
98 |
+
$ftime = @filemtime($path);
|
99 |
+
if ($ftime) {
|
100 |
+
$fp = @fopen($path, 'rb');
|
101 |
+
if ($fp) {
|
102 |
+
$expires = @fread($fp, 4);
|
103 |
+
if ($expires !== false) {
|
104 |
+
list (, $expire) = @unpack('L', $expires);
|
105 |
+
$expire = ($expire && $expire <= W3_CACHE_FILE_EXPIRE_MAX ? $expire : W3_CACHE_FILE_EXPIRE_MAX);
|
106 |
+
if ($ftime > time() - $expire) {
|
107 |
+
$data = '';
|
108 |
+
while (! @feof($fp)) {
|
109 |
+
$data .= @fread($fp, 4096);
|
110 |
+
}
|
111 |
+
$var = @unserialize($data);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
@fclose($fp);
|
115 |
}
|
|
|
|
|
116 |
}
|
|
|
117 |
}
|
118 |
+
|
119 |
+
return $var;
|
120 |
}
|
121 |
|
122 |
/**
|
158 |
*/
|
159 |
function flush()
|
160 |
{
|
161 |
+
return w3_emptydir($this->_cache_dir);
|
162 |
}
|
163 |
|
164 |
/**
|
170 |
function _get_path($key)
|
171 |
{
|
172 |
$hash = md5($key);
|
173 |
+
$path = sprintf('%s/%s/%s/%s', $this->_cache_dir, substr($hash, 0, 2), substr($hash, 2, 2), $hash);
|
|
|
|
|
|
|
|
|
174 |
|
175 |
return $path;
|
176 |
}
|
lib/W3/Cache/File/Manager.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/File.php';
|
4 |
+
|
5 |
+
class W3_Cache_File_Manager
|
6 |
+
{
|
7 |
+
var $_cache_dir = '';
|
8 |
+
|
9 |
+
function __construct($config = array())
|
10 |
+
{
|
11 |
+
$this->_cache_dir = (isset($config['cache_dir']) ? trim($config['cache_dir']) : 'cache');
|
12 |
+
}
|
13 |
+
|
14 |
+
function W3_Cache_File_Manager($config = array())
|
15 |
+
{
|
16 |
+
$this->__construct($config);
|
17 |
+
}
|
18 |
+
|
19 |
+
function clean()
|
20 |
+
{
|
21 |
+
return $this->_clean($this->_cache_dir, true);
|
22 |
+
}
|
23 |
+
|
24 |
+
function _clean($path, $empty = false)
|
25 |
+
{
|
26 |
+
$dir = @opendir($path);
|
27 |
+
if ($dir) {
|
28 |
+
while (($entry = @readdir($dir))) {
|
29 |
+
if ($entry != '.' && $entry != '..') {
|
30 |
+
$full_path = $path . '/' . $entry;
|
31 |
+
if (is_dir($full_path)) {
|
32 |
+
$result = $this->_clean($full_path);
|
33 |
+
} elseif (! $this->is_valid($full_path)) {
|
34 |
+
$result = @unlink($full_path);
|
35 |
+
}
|
36 |
+
if (! $result) {
|
37 |
+
@closedir($dir);
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
@closedir($dir);
|
43 |
+
if (! $empty) {
|
44 |
+
@rmdir($path);
|
45 |
+
}
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
function is_valid($file)
|
52 |
+
{
|
53 |
+
$valid = false;
|
54 |
+
if (is_readable($file)) {
|
55 |
+
$ftime = @filemtime($file);
|
56 |
+
if ($ftime) {
|
57 |
+
$fp = @fopen($file, 'rb');
|
58 |
+
if ($fp) {
|
59 |
+
$expires = @fread($fp, 4);
|
60 |
+
if ($expires !== false) {
|
61 |
+
list (, $expire) = @unpack('L', $expires);
|
62 |
+
$expire = ($expire && $expire <= W3_CACHE_FILE_EXPIRE_MAX ? $expire : W3_CACHE_FILE_EXPIRE_MAX);
|
63 |
+
if ($ftime > (time() - $expire)) {
|
64 |
+
$valid = true;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
@fclose($fp);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
return $valid;
|
72 |
+
}
|
73 |
+
}
|
lib/W3/Config.php
CHANGED
@@ -45,7 +45,6 @@ class W3_Config
|
|
45 |
'pgcache.memcached.servers' => 'array',
|
46 |
'pgcache.lifetime' => 'integer',
|
47 |
'pgcache.compress' => 'boolean',
|
48 |
-
'pgcache.cache.logged' => 'boolean',
|
49 |
'pgcache.cache.query' => 'boolean',
|
50 |
'pgcache.cache.home' => 'boolean',
|
51 |
'pgcache.cache.feed' => 'boolean',
|
@@ -53,6 +52,7 @@ class W3_Config
|
|
53 |
'pgcache.cache.flush' => 'boolean',
|
54 |
'pgcache.cache.headers' => 'array',
|
55 |
'pgcache.accept.files' => 'array',
|
|
|
56 |
'pgcache.reject.uri' => 'array',
|
57 |
'pgcache.reject.ua' => 'array',
|
58 |
'pgcache.reject.cookie' => 'array',
|
@@ -66,10 +66,7 @@ class W3_Config
|
|
66 |
'minify.memcached.engine' => 'string',
|
67 |
'minify.memcached.servers' => 'array',
|
68 |
'minify.rewrite' => 'boolean',
|
69 |
-
'minify.
|
70 |
-
'minify.cache.path' => 'string',
|
71 |
-
'minify.cache.locking' => 'string',
|
72 |
-
'minify.docroot' => 'string',
|
73 |
'minify.fixtime' => 'integer',
|
74 |
'minify.compress' => 'boolean',
|
75 |
'minify.compress.ie6' => 'boolean',
|
@@ -78,8 +75,10 @@ class W3_Config
|
|
78 |
'minify.lifetime' => 'integer',
|
79 |
'minify.upload' => 'boolean',
|
80 |
'minify.html.enable' => 'boolean',
|
81 |
-
'minify.html.strip.crlf' => 'boolean',
|
82 |
'minify.html.reject.admin' => 'boolean',
|
|
|
|
|
|
|
83 |
'minify.css.enable' => 'boolean',
|
84 |
'minify.css.strip.comments' => 'boolean',
|
85 |
'minify.css.strip.crlf' => 'boolean',
|
@@ -90,6 +89,8 @@ class W3_Config
|
|
90 |
'minify.js.strip.comments' => 'boolean',
|
91 |
'minify.js.strip.crlf' => 'boolean',
|
92 |
'minify.js.groups' => 'array',
|
|
|
|
|
93 |
|
94 |
'cdn.enabled' => 'boolean',
|
95 |
'cdn.debug' => 'boolean',
|
@@ -110,6 +111,8 @@ class W3_Config
|
|
110 |
'cdn.ftp.pass' => 'string',
|
111 |
'cdn.ftp.path' => 'string',
|
112 |
'cdn.ftp.pasv' => 'boolean',
|
|
|
|
|
113 |
|
114 |
'common.support.enabled' => 'boolean',
|
115 |
'common.support.type' => 'string',
|
45 |
'pgcache.memcached.servers' => 'array',
|
46 |
'pgcache.lifetime' => 'integer',
|
47 |
'pgcache.compress' => 'boolean',
|
|
|
48 |
'pgcache.cache.query' => 'boolean',
|
49 |
'pgcache.cache.home' => 'boolean',
|
50 |
'pgcache.cache.feed' => 'boolean',
|
52 |
'pgcache.cache.flush' => 'boolean',
|
53 |
'pgcache.cache.headers' => 'array',
|
54 |
'pgcache.accept.files' => 'array',
|
55 |
+
'pgcache.reject.logged' => 'boolean',
|
56 |
'pgcache.reject.uri' => 'array',
|
57 |
'pgcache.reject.ua' => 'array',
|
58 |
'pgcache.reject.cookie' => 'array',
|
66 |
'minify.memcached.engine' => 'string',
|
67 |
'minify.memcached.servers' => 'array',
|
68 |
'minify.rewrite' => 'boolean',
|
69 |
+
'minify.locking' => 'string',
|
|
|
|
|
|
|
70 |
'minify.fixtime' => 'integer',
|
71 |
'minify.compress' => 'boolean',
|
72 |
'minify.compress.ie6' => 'boolean',
|
75 |
'minify.lifetime' => 'integer',
|
76 |
'minify.upload' => 'boolean',
|
77 |
'minify.html.enable' => 'boolean',
|
|
|
78 |
'minify.html.reject.admin' => 'boolean',
|
79 |
+
'minify.html.inline.css' => 'boolean',
|
80 |
+
'minify.html.inline.js' => 'boolean',
|
81 |
+
'minify.html.strip.crlf' => 'boolean',
|
82 |
'minify.css.enable' => 'boolean',
|
83 |
'minify.css.strip.comments' => 'boolean',
|
84 |
'minify.css.strip.crlf' => 'boolean',
|
89 |
'minify.js.strip.comments' => 'boolean',
|
90 |
'minify.js.strip.crlf' => 'boolean',
|
91 |
'minify.js.groups' => 'array',
|
92 |
+
'minify.reject.ua' => 'array',
|
93 |
+
'minify.reject.uri' => 'array',
|
94 |
|
95 |
'cdn.enabled' => 'boolean',
|
96 |
'cdn.debug' => 'boolean',
|
111 |
'cdn.ftp.pass' => 'string',
|
112 |
'cdn.ftp.path' => 'string',
|
113 |
'cdn.ftp.pasv' => 'boolean',
|
114 |
+
'cdn.reject.ua' => 'array',
|
115 |
+
'cdn.reject.uri' => 'array',
|
116 |
|
117 |
'common.support.enabled' => 'boolean',
|
118 |
'common.support.type' => 'string',
|
lib/W3/Db.php
CHANGED
@@ -110,7 +110,7 @@ class W3_Db extends wpdb
|
|
110 |
return false;
|
111 |
}
|
112 |
|
113 |
-
|
114 |
|
115 |
// filter the query, if filters are available
|
116 |
// NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
|
@@ -147,7 +147,7 @@ class W3_Db extends wpdb
|
|
147 |
* Check if query was cached
|
148 |
*/
|
149 |
if (is_array($data)) {
|
150 |
-
|
151 |
$cached = true;
|
152 |
|
153 |
/**
|
@@ -159,8 +159,8 @@ class W3_Db extends wpdb
|
|
159 |
$this->col_info = $data['col_info'];
|
160 |
$this->num_rows = $data['num_rows'];
|
161 |
} else {
|
162 |
-
|
163 |
-
|
164 |
|
165 |
// Perform the query via std mysql_query function..
|
166 |
$this->timer_start();
|
@@ -371,7 +371,7 @@ class W3_Db extends wpdb
|
|
371 |
function get_debug_info()
|
372 |
{
|
373 |
$debug_info = "<!-- W3 Total Cache: Db cache debug info:\r\n";
|
374 |
-
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), $this->_config->get_string('dbcache.engine'));
|
375 |
$debug_info .= sprintf("%s%d\r\n", str_pad('Total queries: ', 20), $this->query_total);
|
376 |
$debug_info .= sprintf("%s%d\r\n", str_pad('Cached queries: ', 20), $this->query_hits);
|
377 |
$debug_info .= sprintf("%s%.3f\r\n", str_pad('Total query time: ', 20), $this->time_total);
|
@@ -400,14 +400,24 @@ class W3_Db extends wpdb
|
|
400 |
|
401 |
if ($cache === null) {
|
402 |
$engine = $this->_config->get_string('dbcache.engine', 'memcached');
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
}
|
412 |
|
413 |
require_once W3TC_LIB_W3_DIR . '/Cache.php';
|
@@ -463,8 +473,7 @@ class W3_Db extends wpdb
|
|
463 |
{
|
464 |
$auto_reject_uri = array(
|
465 |
'wp-login',
|
466 |
-
'wp-register'
|
467 |
-
'wp-signup'
|
468 |
);
|
469 |
|
470 |
foreach ($auto_reject_uri as $uri) {
|
110 |
return false;
|
111 |
}
|
112 |
|
113 |
+
++ $this->query_total;
|
114 |
|
115 |
// filter the query, if filters are available
|
116 |
// NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
|
147 |
* Check if query was cached
|
148 |
*/
|
149 |
if (is_array($data)) {
|
150 |
+
++ $this->query_hits;
|
151 |
$cached = true;
|
152 |
|
153 |
/**
|
159 |
$this->col_info = $data['col_info'];
|
160 |
$this->num_rows = $data['num_rows'];
|
161 |
} else {
|
162 |
+
++ $this->num_queries;
|
163 |
+
++ $this->query_misses;
|
164 |
|
165 |
// Perform the query via std mysql_query function..
|
166 |
$this->timer_start();
|
371 |
function get_debug_info()
|
372 |
{
|
373 |
$debug_info = "<!-- W3 Total Cache: Db cache debug info:\r\n";
|
374 |
+
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), w3_get_engine_name($this->_config->get_string('dbcache.engine')));
|
375 |
$debug_info .= sprintf("%s%d\r\n", str_pad('Total queries: ', 20), $this->query_total);
|
376 |
$debug_info .= sprintf("%s%d\r\n", str_pad('Cached queries: ', 20), $this->query_hits);
|
377 |
$debug_info .= sprintf("%s%.3f\r\n", str_pad('Total query time: ', 20), $this->time_total);
|
400 |
|
401 |
if ($cache === null) {
|
402 |
$engine = $this->_config->get_string('dbcache.engine', 'memcached');
|
403 |
+
|
404 |
+
switch ($engine) {
|
405 |
+
case 'memcached':
|
406 |
+
$engineConfig = array(
|
407 |
+
'engine' => $this->_config->get_string('dbcache.memcached.engine', 'auto'),
|
408 |
+
'servers' => $this->_config->get_array('dbcache.memcached.servers'),
|
409 |
+
'persistant' => true
|
410 |
+
);
|
411 |
+
break;
|
412 |
+
|
413 |
+
case 'file':
|
414 |
+
$engineConfig = array(
|
415 |
+
'cache_dir' => W3TC_CACHE_FILE_DIR
|
416 |
+
);
|
417 |
+
break;
|
418 |
+
|
419 |
+
default:
|
420 |
+
$engineConfig = array();
|
421 |
}
|
422 |
|
423 |
require_once W3TC_LIB_W3_DIR . '/Cache.php';
|
473 |
{
|
474 |
$auto_reject_uri = array(
|
475 |
'wp-login',
|
476 |
+
'wp-register'
|
|
|
477 |
);
|
478 |
|
479 |
foreach ($auto_reject_uri as $uri) {
|
lib/W3/Minify.php
CHANGED
@@ -62,13 +62,10 @@ class W3_Minify
|
|
62 |
'postprocessor'
|
63 |
);
|
64 |
|
65 |
-
if ((
|
66 |
-
|
67 |
-
} elseif (0 === stripos(PHP_OS, 'win')) {
|
68 |
-
Minify::setDocRoot(); // IIS may need help
|
69 |
}
|
70 |
|
71 |
-
// normalize paths in symlinks
|
72 |
foreach ($this->_config->get_array('minify.symlinks') as $link => $target) {
|
73 |
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
|
74 |
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
|
@@ -79,14 +76,14 @@ class W3_Minify
|
|
79 |
$serve_options['debug'] = true;
|
80 |
}
|
81 |
|
82 |
-
if ($this->_config->get('minify.
|
83 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php';
|
84 |
Minify_Logger::setLogger($this);
|
85 |
}
|
86 |
|
87 |
-
if (isset($_GET['f']) || (isset($_GET['g']) && isset($_GET['t']))) {
|
88 |
-
if (isset($_GET['g']) && isset($_GET['t'])) {
|
89 |
-
$serve_options['minApp']['groups'] = $this->
|
90 |
|
91 |
if ($_GET['t'] == 'js' && ((in_array($_GET['g'], array(
|
92 |
'include',
|
@@ -102,7 +99,6 @@ class W3_Minify
|
|
102 |
}
|
103 |
}
|
104 |
|
105 |
-
@header('X-Powered-By: ' . W3TC_POWERED_BY);
|
106 |
Minify::serve('MinApp', $serve_options);
|
107 |
} else {
|
108 |
die('This file cannot be accessed directly');
|
@@ -162,24 +158,10 @@ class W3_Minify
|
|
162 |
} elseif (is_a($cache, 'Minify_Cache_APC') && function_exists('apc_clear_cache')) {
|
163 |
return apc_clear_cache('user');
|
164 |
} elseif (is_a($cache, 'Minify_Cache_File')) {
|
165 |
-
if (!
|
166 |
-
$
|
167 |
-
|
168 |
-
if (! $cache_path) {
|
169 |
-
require_once W3TC_LIB_MINIFY_DIR . '/Solar/Dir.php';
|
170 |
-
$cache_path = Solar_Dir::tmp();
|
171 |
-
}
|
172 |
}
|
173 |
-
|
174 |
-
$dir = dir($cache_path);
|
175 |
-
|
176 |
-
while (($entry = $dir->read()) !== false) {
|
177 |
-
if (strpos($entry, 'minify') === 0) {
|
178 |
-
@unlink($dir->path . '/' . $entry);
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
return true;
|
183 |
}
|
184 |
|
185 |
return false;
|
@@ -202,57 +184,6 @@ class W3_Minify
|
|
202 |
return $instance;
|
203 |
}
|
204 |
|
205 |
-
/**
|
206 |
-
* Returns debug info
|
207 |
-
*/
|
208 |
-
function get_debug_info()
|
209 |
-
{
|
210 |
-
$debug_info = "<!-- W3 Total Cache: Minify debug info:\r\n";
|
211 |
-
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), $this->_config->get_string('minify.engine'));
|
212 |
-
|
213 |
-
$css_groups = $this->_get_groups('css');
|
214 |
-
|
215 |
-
if (count($css_groups)) {
|
216 |
-
$debug_info .= "Stylesheet info:\r\n";
|
217 |
-
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad('Group', 15, ' ', STR_PAD_BOTH), str_pad('Last modified', 19, ' ', STR_PAD_BOTH), str_pad('Size', 12, ' ', STR_PAD_LEFT), 'Path');
|
218 |
-
|
219 |
-
foreach ($css_groups as $css_group => $css_files) {
|
220 |
-
foreach ($css_files as $css_file => $css_file_path) {
|
221 |
-
if (w3_is_url($css_file)) {
|
222 |
-
$css_file_info = sprintf('%s (%s)', $css_file, $css_file_path);
|
223 |
-
} else {
|
224 |
-
$css_file_path = $css_file_info = ABSPATH . ltrim($css_file, '\\/');
|
225 |
-
}
|
226 |
-
|
227 |
-
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad($css_group, 15, ' ', STR_PAD_BOTH), str_pad(date('Y-m-d H:i:s', filemtime($css_file_path)), 19, ' ', STR_PAD_BOTH), str_pad(filesize($css_file_path), 12, ' ', STR_PAD_LEFT), $css_file_info);
|
228 |
-
}
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
$js_groups = $this->_get_groups('js');
|
233 |
-
|
234 |
-
if (count($js_groups)) {
|
235 |
-
$debug_info .= "JavaScript info:\r\n";
|
236 |
-
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad('Group', 15, ' ', STR_PAD_BOTH), str_pad('Last modified', 19, ' ', STR_PAD_BOTH), str_pad('Size', 12, ' ', STR_PAD_LEFT), 'Path');
|
237 |
-
|
238 |
-
foreach ($js_groups as $js_group => $js_files) {
|
239 |
-
foreach ($js_files as $js_file => $js_file_path) {
|
240 |
-
if (w3_is_url($js_file)) {
|
241 |
-
$js_file_info = sprintf('%s (%s)', $js_file, $js_file_path);
|
242 |
-
} else {
|
243 |
-
$js_file_path = $js_file_info = ABSPATH . ltrim($js_file, '\\/');
|
244 |
-
}
|
245 |
-
|
246 |
-
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad($js_group, 15, ' ', STR_PAD_BOTH), str_pad(date('Y-m-d H:i:s', filemtime($js_file_path)), 19, ' ', STR_PAD_BOTH), str_pad(filesize($js_file_path), 12, ' ', STR_PAD_LEFT), $js_file_info);
|
247 |
-
}
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
$debug_info .= '-->';
|
252 |
-
|
253 |
-
return $debug_info;
|
254 |
-
}
|
255 |
-
|
256 |
/**
|
257 |
* Minify stub function
|
258 |
*
|
@@ -271,23 +202,29 @@ class W3_Minify
|
|
271 |
*/
|
272 |
function log($object, $label = null)
|
273 |
{
|
274 |
-
$file =
|
275 |
$data = sprintf("[%s] [%s] %s\n", date('r'), $_SERVER['REQUEST_URI'], $object);
|
276 |
|
277 |
-
|
|
|
278 |
@fputs($fp, $data);
|
279 |
@fclose($fp);
|
|
|
280 |
}
|
|
|
|
|
281 |
}
|
282 |
|
283 |
/**
|
284 |
* Returns minify groups
|
285 |
-
*
|
286 |
* @param string $type
|
287 |
* @return array
|
288 |
*/
|
289 |
-
function
|
290 |
{
|
|
|
|
|
291 |
switch ($type) {
|
292 |
case 'css':
|
293 |
$groups = $this->_config->get_array('minify.css.groups');
|
@@ -298,20 +235,28 @@ class W3_Minify
|
|
298 |
break;
|
299 |
|
300 |
default:
|
301 |
-
return
|
302 |
}
|
303 |
|
304 |
-
|
|
|
|
|
|
|
|
|
305 |
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
|
|
308 |
foreach ((array) $config['files'] as $file) {
|
309 |
if (w3_is_url($file)) {
|
310 |
if (($precached_file = $this->_precache_file($file, $type))) {
|
311 |
-
$result[$
|
312 |
}
|
313 |
} else {
|
314 |
-
$result[$
|
315 |
}
|
316 |
}
|
317 |
}
|
@@ -323,47 +268,78 @@ class W3_Minify
|
|
323 |
/**
|
324 |
* Precaches external file
|
325 |
*
|
326 |
-
* @param string $
|
327 |
* @param string $type
|
328 |
* @return string
|
329 |
*/
|
330 |
-
function _precache_file($
|
331 |
{
|
332 |
-
static $cache_path = null;
|
333 |
-
|
334 |
-
if ($cache_path === null) {
|
335 |
-
$cache_path = $this->_config->get_string('minify.cache.path');
|
336 |
-
|
337 |
-
if (! $cache_path) {
|
338 |
-
require_once W3TC_LIB_MINIFY_DIR . '/Solar/Dir.php';
|
339 |
-
$cache_path = Solar_Dir::tmp();
|
340 |
-
}
|
341 |
-
}
|
342 |
-
|
343 |
$lifetime = $this->_config->get_integer('minify.lifetime', 3600);
|
344 |
-
$file_path = sprintf('%s/minify_%s.%s',
|
345 |
$file_exists = file_exists($file_path);
|
|
|
346 |
|
347 |
if (file_exists($file_path) && @filemtime($file_path) >= (time() - $lifetime)) {
|
348 |
-
return $file_path;
|
349 |
}
|
350 |
|
351 |
-
if (is_dir(
|
352 |
-
if (($file_data =
|
353 |
if (($fp = @fopen($file_path, 'w'))) {
|
354 |
@fputs($fp, $file_data);
|
355 |
@fclose($fp);
|
|
|
|
|
356 |
} else {
|
357 |
$this->log(sprintf('Unable to open file %s for writing', $file_path));
|
358 |
}
|
359 |
} else {
|
360 |
-
$this->log(sprintf('Unable to download URL: %s', $
|
361 |
}
|
362 |
} else {
|
363 |
-
$this->log(sprintf('Cache directory %s is not exists',
|
364 |
}
|
365 |
|
366 |
-
return ($file_exists ? $file_path : false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
}
|
368 |
|
369 |
/**
|
@@ -394,14 +370,10 @@ class W3_Minify
|
|
394 |
|
395 |
default:
|
396 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php';
|
397 |
-
|
398 |
-
|
399 |
-
$cache_path = W3TC_MINIFY_DIR;
|
400 |
-
}
|
401 |
-
if (! is_dir($cache_path)) {
|
402 |
-
$this->log(sprintf('Cache directory %s is not exists', $cache_path));
|
403 |
}
|
404 |
-
$cache = & new Minify_Cache_File(
|
405 |
break;
|
406 |
}
|
407 |
}
|
62 |
'postprocessor'
|
63 |
);
|
64 |
|
65 |
+
if (stripos(PHP_OS, 'win') === 0) {
|
66 |
+
Minify::setDocRoot();
|
|
|
|
|
67 |
}
|
68 |
|
|
|
69 |
foreach ($this->_config->get_array('minify.symlinks') as $link => $target) {
|
70 |
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
|
71 |
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
|
76 |
$serve_options['debug'] = true;
|
77 |
}
|
78 |
|
79 |
+
if ($this->_config->get('minify.debug')) {
|
80 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php';
|
81 |
Minify_Logger::setLogger($this);
|
82 |
}
|
83 |
|
84 |
+
if (isset($_GET['f']) || (isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t']))) {
|
85 |
+
if (isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
|
86 |
+
$serve_options['minApp']['groups'] = $this->get_groups($_GET['gg'], $_GET['t']);
|
87 |
|
88 |
if ($_GET['t'] == 'js' && ((in_array($_GET['g'], array(
|
89 |
'include',
|
99 |
}
|
100 |
}
|
101 |
|
|
|
102 |
Minify::serve('MinApp', $serve_options);
|
103 |
} else {
|
104 |
die('This file cannot be accessed directly');
|
158 |
} elseif (is_a($cache, 'Minify_Cache_APC') && function_exists('apc_clear_cache')) {
|
159 |
return apc_clear_cache('user');
|
160 |
} elseif (is_a($cache, 'Minify_Cache_File')) {
|
161 |
+
if (! is_dir(W3TC_CACHE_MINIFY_DIR)) {
|
162 |
+
$this->log(sprintf('Cache directory %s does not exists', W3TC_CACHE_MINIFY_DIR));
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
+
return w3_emptydir(W3TC_CACHE_MINIFY_DIR);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
return false;
|
184 |
return $instance;
|
185 |
}
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
/**
|
188 |
* Minify stub function
|
189 |
*
|
202 |
*/
|
203 |
function log($object, $label = null)
|
204 |
{
|
205 |
+
$file = W3TC_LOG_DIR . '/minify.log';
|
206 |
$data = sprintf("[%s] [%s] %s\n", date('r'), $_SERVER['REQUEST_URI'], $object);
|
207 |
|
208 |
+
$fp = @fopen($file, 'a');
|
209 |
+
if ($fp) {
|
210 |
@fputs($fp, $data);
|
211 |
@fclose($fp);
|
212 |
+
return true;
|
213 |
}
|
214 |
+
|
215 |
+
return false;
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
* Returns minify groups
|
220 |
+
* @param string $group
|
221 |
* @param string $type
|
222 |
* @return array
|
223 |
*/
|
224 |
+
function get_groups($group, $type)
|
225 |
{
|
226 |
+
$result = array();
|
227 |
+
|
228 |
switch ($type) {
|
229 |
case 'css':
|
230 |
$groups = $this->_config->get_array('minify.css.groups');
|
235 |
break;
|
236 |
|
237 |
default:
|
238 |
+
return $result;
|
239 |
}
|
240 |
|
241 |
+
if (isset($groups['default'])) {
|
242 |
+
$locations = (array) $groups['default'];
|
243 |
+
} else {
|
244 |
+
$locations = array();
|
245 |
+
}
|
246 |
|
247 |
+
if ($group != 'default' && isset($groups[$group])) {
|
248 |
+
$locations = array_merge_recursive($locations, (array) $groups[$group]);
|
249 |
+
}
|
250 |
+
|
251 |
+
foreach ($locations as $location => $config) {
|
252 |
+
if (! empty($config['files'])) {
|
253 |
foreach ((array) $config['files'] as $file) {
|
254 |
if (w3_is_url($file)) {
|
255 |
if (($precached_file = $this->_precache_file($file, $type))) {
|
256 |
+
$result[$location][$file] = $precached_file;
|
257 |
}
|
258 |
} else {
|
259 |
+
$result[$location][$file] = '//' . $file;
|
260 |
}
|
261 |
}
|
262 |
}
|
268 |
/**
|
269 |
* Precaches external file
|
270 |
*
|
271 |
+
* @param string $url
|
272 |
* @param string $type
|
273 |
* @return string
|
274 |
*/
|
275 |
+
function _precache_file($url, $type)
|
276 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
$lifetime = $this->_config->get_integer('minify.lifetime', 3600);
|
278 |
+
$file_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_MINIFY_DIR, md5($url), $type);
|
279 |
$file_exists = file_exists($file_path);
|
280 |
+
$base_url = $this->_get_base_url($url);
|
281 |
|
282 |
if (file_exists($file_path) && @filemtime($file_path) >= (time() - $lifetime)) {
|
283 |
+
return $this->_get_minify_source($file_path, $base_url);
|
284 |
}
|
285 |
|
286 |
+
if (is_dir(W3TC_CACHE_MINIFY_DIR)) {
|
287 |
+
if (($file_data = w3_url_get($url))) {
|
288 |
if (($fp = @fopen($file_path, 'w'))) {
|
289 |
@fputs($fp, $file_data);
|
290 |
@fclose($fp);
|
291 |
+
|
292 |
+
return $this->_get_minify_source($file_path, $base_url);
|
293 |
} else {
|
294 |
$this->log(sprintf('Unable to open file %s for writing', $file_path));
|
295 |
}
|
296 |
} else {
|
297 |
+
$this->log(sprintf('Unable to download URL: %s', $url));
|
298 |
}
|
299 |
} else {
|
300 |
+
$this->log(sprintf('Cache directory %s is not exists', W3TC_CACHE_MINIFY_DIR));
|
301 |
}
|
302 |
|
303 |
+
return ($file_exists ? $this->_get_minify_source($file_path, $base_url) : false);
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Returns minify source
|
308 |
+
* @param $file_path
|
309 |
+
* @param $base_url
|
310 |
+
* @return Minify_Source
|
311 |
+
*/
|
312 |
+
function _get_minify_source($file_path, $base_url)
|
313 |
+
{
|
314 |
+
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Source.php';
|
315 |
+
|
316 |
+
return new Minify_Source(array(
|
317 |
+
'filepath' => $file_path,
|
318 |
+
'minifyOptions' => array(
|
319 |
+
'prependRelativePath' => $base_url
|
320 |
+
)
|
321 |
+
));
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Returns base URL
|
326 |
+
* @param $url
|
327 |
+
* @return string
|
328 |
+
*/
|
329 |
+
function _get_base_url($url)
|
330 |
+
{
|
331 |
+
$parse_url = @parse_url($url);
|
332 |
+
if ($parse_url && isset($parse_url['scheme'])) {
|
333 |
+
$scheme = $parse_url['scheme'];
|
334 |
+
if (isset($parse_url['host'])) {
|
335 |
+
$host = $parse_url['host'];
|
336 |
+
$port = (isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . $parse_url['port'] : '');
|
337 |
+
$path = (isset($parse_url['path']) ? preg_replace('~[^/]+$~', '', $parse_url['path']) : '/');
|
338 |
+
|
339 |
+
return sprintf('%s://%s%s%s', $scheme, $host, $port, $path);
|
340 |
+
}
|
341 |
+
}
|
342 |
+
return false;
|
343 |
}
|
344 |
|
345 |
/**
|
370 |
|
371 |
default:
|
372 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php';
|
373 |
+
if (! is_dir(W3TC_CACHE_MINIFY_DIR)) {
|
374 |
+
$this->log(sprintf('Cache directory %s does not exists', W3TC_CACHE_MINIFY_DIR));
|
|
|
|
|
|
|
|
|
375 |
}
|
376 |
+
$cache = & new Minify_Cache_File(W3TC_CACHE_MINIFY_DIR, $this->_config->get_boolean('minify.locking'));
|
377 |
break;
|
378 |
}
|
379 |
}
|
lib/W3/PgCache.php
CHANGED
@@ -44,6 +44,12 @@ class W3_PgCache
|
|
44 |
*/
|
45 |
var $_time_start = 0;
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* Cache reject reason
|
49 |
*
|
@@ -58,6 +64,8 @@ class W3_PgCache
|
|
58 |
{
|
59 |
require_once W3TC_LIB_W3_DIR . '/Config.php';
|
60 |
$this->_config = W3_Config::instance();
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -78,7 +86,6 @@ class W3_PgCache
|
|
78 |
}
|
79 |
|
80 |
$this->_caching = $this->_can_cache();
|
81 |
-
$this->_compression = ($this->_config->get_boolean('pgcache.compress', true) ? $this->_get_compression() : false);
|
82 |
$this->_page_key = $this->_get_page_key($this->_compression);
|
83 |
|
84 |
if ($this->_caching) {
|
@@ -88,34 +95,31 @@ class W3_PgCache
|
|
88 |
$cache = $this->_get_cache();
|
89 |
|
90 |
if (is_array(($data = $cache->get($this->_page_key)))) {
|
91 |
-
@header('
|
92 |
|
93 |
/**
|
94 |
* Handle 404 error
|
95 |
*/
|
96 |
if ($data['404']) {
|
97 |
-
header('HTTP/1.1 404 Not Found');
|
98 |
-
}
|
99 |
-
$
|
100 |
-
if ($if_modified_since >= $data['time']) {
|
101 |
-
header("HTTP/1.1 304 Not Modified");
|
102 |
-
}
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
-
*
|
107 |
*/
|
108 |
-
|
109 |
-
$
|
110 |
-
$debug_info = $this->_get_debug_info(true, '', true, $time_total, $data['headers']);
|
111 |
-
$this->_append_content($data, "\r\n\r\n" . $debug_info);
|
112 |
}
|
113 |
|
114 |
/**
|
115 |
-
*
|
116 |
*/
|
117 |
-
|
118 |
-
|
|
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
@@ -143,33 +147,30 @@ class W3_PgCache
|
|
143 |
*/
|
144 |
function ob_callback($buffer)
|
145 |
{
|
146 |
-
if (!
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
return gzencode($buffer);
|
159 |
-
|
160 |
-
case 'deflate':
|
161 |
-
return gzdeflate($buffer);
|
162 |
-
}
|
163 |
}
|
164 |
|
165 |
return $buffer;
|
166 |
}
|
167 |
|
168 |
-
/**
|
169 |
-
* Send compression headers first
|
170 |
-
*/
|
171 |
-
$this->_send_compression_headers($this->_compression);
|
172 |
-
|
173 |
/**
|
174 |
* Create data object
|
175 |
*/
|
@@ -177,7 +178,6 @@ class W3_PgCache
|
|
177 |
$page_keys = array();
|
178 |
|
179 |
$cache = $this->_get_cache();
|
180 |
-
$lifetime = $this->_config->get_integer('pgcache.lifetime', 3600);
|
181 |
$time = time();
|
182 |
$is_404 = is_404();
|
183 |
|
@@ -193,11 +193,6 @@ class W3_PgCache
|
|
193 |
'404' => $is_404
|
194 |
);
|
195 |
|
196 |
-
/**
|
197 |
-
* Set headers to cache
|
198 |
-
*/
|
199 |
-
$data['headers'] = $this->_get_data_headers($compression);
|
200 |
-
|
201 |
/**
|
202 |
* Set content to cache
|
203 |
*/
|
@@ -209,14 +204,28 @@ class W3_PgCache
|
|
209 |
$data['content'] = $buffer;
|
210 |
}
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
/**
|
213 |
-
*
|
214 |
*/
|
215 |
-
$
|
216 |
-
|
217 |
-
$cache->set($page_key, $data, $lifetime);
|
218 |
-
|
219 |
$data_array[$compression] = $data;
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
$page_keys[] = $page_key;
|
221 |
}
|
222 |
|
@@ -248,7 +257,7 @@ class W3_PgCache
|
|
248 |
*/
|
249 |
if ($this->_config->get_boolean('pgcache.debug')) {
|
250 |
$time_total = w3_microtime() - $this->_time_start;
|
251 |
-
$debug_info = $this->_get_debug_info(true, '', false, $time_total
|
252 |
$this->_append_content($data_array[$this->_compression], "\r\n\r\n" . $debug_info);
|
253 |
}
|
254 |
|
@@ -285,7 +294,7 @@ class W3_PgCache
|
|
285 |
$map_key = $this->_get_map_key($namespace);
|
286 |
$cache = $this->_get_cache();
|
287 |
|
288 |
-
return $cache->set($map_key, $map, $this->
|
289 |
}
|
290 |
|
291 |
/**
|
@@ -464,7 +473,7 @@ class W3_PgCache
|
|
464 |
/**
|
465 |
* Skip if user is logged in
|
466 |
*/
|
467 |
-
if (
|
468 |
$this->_cache_reject_reason = 'User is logged in';
|
469 |
|
470 |
return false;
|
@@ -479,7 +488,7 @@ class W3_PgCache
|
|
479 |
* @param string $buffer
|
480 |
* @return boolean
|
481 |
*/
|
482 |
-
function _can_cache2(
|
483 |
{
|
484 |
/**
|
485 |
* Skip if caching is disabled
|
@@ -488,12 +497,6 @@ class W3_PgCache
|
|
488 |
return false;
|
489 |
}
|
490 |
|
491 |
-
if (empty($buffer)) {
|
492 |
-
$this->_cache_reject_reason = 'Page is empty';
|
493 |
-
|
494 |
-
return false;
|
495 |
-
}
|
496 |
-
|
497 |
/**
|
498 |
* Don't cache 404 pages
|
499 |
*/
|
@@ -534,15 +537,25 @@ class W3_PgCache
|
|
534 |
static $cache = null;
|
535 |
|
536 |
if ($cache === null) {
|
537 |
-
$engine = $this->_config->get_string('pgcache.engine', '
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
}
|
547 |
|
548 |
require_once W3TC_LIB_W3_DIR . '/Cache.php';
|
@@ -560,9 +573,8 @@ class W3_PgCache
|
|
560 |
function _check_request_uri()
|
561 |
{
|
562 |
$auto_reject_uri = array(
|
563 |
-
'wp-
|
564 |
-
'wp-
|
565 |
-
'robots.txt'
|
566 |
);
|
567 |
|
568 |
foreach ($auto_reject_uri as $uri) {
|
@@ -672,16 +684,19 @@ class W3_PgCache
|
|
672 |
{
|
673 |
$headers = array();
|
674 |
|
675 |
-
if (function_exists('
|
676 |
-
flush();
|
677 |
-
$headers = apache_response_headers();
|
678 |
-
} elseif (function_exists('headers_list')) {
|
679 |
foreach (headers_list() as $header) {
|
680 |
list ($header_name, $header_value) = explode(': ', $header, 2);
|
681 |
$headers[$header_name] = $header_value;
|
682 |
}
|
|
|
|
|
|
|
683 |
}
|
684 |
|
|
|
|
|
|
|
685 |
return $headers;
|
686 |
}
|
687 |
|
@@ -777,7 +792,13 @@ class W3_PgCache
|
|
777 |
*/
|
778 |
function _get_map_key($namespace)
|
779 |
{
|
780 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
781 |
|
782 |
return $key;
|
783 |
}
|
@@ -811,13 +832,12 @@ class W3_PgCache
|
|
811 |
* @param string $reason
|
812 |
* @param boolean $status
|
813 |
* @param double $time
|
814 |
-
* @param array $headers
|
815 |
* @return string
|
816 |
*/
|
817 |
-
function _get_debug_info($cache, $reason, $status, $time
|
818 |
{
|
819 |
$debug_info = "<!-- W3 Total Cache: Page cache debug info:\r\n";
|
820 |
-
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), $this->_config->get_string('pgcache.engine'));
|
821 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Key: ', 20), $this->_page_key);
|
822 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Caching: ', 20), ($cache ? 'enabled' : 'disabled'));
|
823 |
if (! $cache) {
|
@@ -826,6 +846,8 @@ class W3_PgCache
|
|
826 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Status: ', 20), ($status ? 'cached' : 'not cached'));
|
827 |
$debug_info .= sprintf("%s%.3fs\r\n", str_pad('Creation Time: ', 20), $time);
|
828 |
|
|
|
|
|
829 |
if (count($headers)) {
|
830 |
$debug_info .= "Headers info:\r\n";
|
831 |
|
@@ -874,8 +896,30 @@ class W3_PgCache
|
|
874 |
function _send_compression_headers($compression)
|
875 |
{
|
876 |
if ($compression !== false) {
|
877 |
-
header('Content-Encoding: ' . $compression);
|
878 |
-
header('Vary: Accept-Encoding, Cookie');
|
879 |
}
|
880 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
881 |
}
|
44 |
*/
|
45 |
var $_time_start = 0;
|
46 |
|
47 |
+
/**
|
48 |
+
* Lifetime
|
49 |
+
* @var integer
|
50 |
+
*/
|
51 |
+
var $_lifetime = 0;
|
52 |
+
|
53 |
/**
|
54 |
* Cache reject reason
|
55 |
*
|
64 |
{
|
65 |
require_once W3TC_LIB_W3_DIR . '/Config.php';
|
66 |
$this->_config = W3_Config::instance();
|
67 |
+
$this->_lifetime = $this->_config->get_integer('pgcache.lifetime', 3600);
|
68 |
+
$this->_compression = ($this->_config->get_boolean('pgcache.compress', true) ? $this->_get_compression() : false);
|
69 |
}
|
70 |
|
71 |
/**
|
86 |
}
|
87 |
|
88 |
$this->_caching = $this->_can_cache();
|
|
|
89 |
$this->_page_key = $this->_get_page_key($this->_compression);
|
90 |
|
91 |
if ($this->_caching) {
|
95 |
$cache = $this->_get_cache();
|
96 |
|
97 |
if (is_array(($data = $cache->get($this->_page_key)))) {
|
98 |
+
@header('Pragma: public');
|
99 |
|
100 |
/**
|
101 |
* Handle 404 error
|
102 |
*/
|
103 |
if ($data['404']) {
|
104 |
+
@header('HTTP/1.1 404 Not Found');
|
105 |
+
} else {
|
106 |
+
@$this->_conditional_get($data['time'], md5($data['content']));
|
|
|
|
|
|
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
+
* Send cached headers
|
111 |
*/
|
112 |
+
foreach ((array) $data['headers'] as $header_name => $header_value) {
|
113 |
+
@header($header_name . ': ' . $header_value);
|
|
|
|
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
+
* Append debug info to content if debug mode is enabled
|
118 |
*/
|
119 |
+
if ($this->_config->get_boolean('pgcache.debug')) {
|
120 |
+
$time_total = w3_microtime() - $this->_time_start;
|
121 |
+
$debug_info = $this->_get_debug_info(true, '', true, $time_total);
|
122 |
+
$this->_append_content($data, "\r\n\r\n" . $debug_info);
|
123 |
}
|
124 |
|
125 |
/**
|
147 |
*/
|
148 |
function ob_callback($buffer)
|
149 |
{
|
150 |
+
if (! w3_is_xml($buffer)) {
|
151 |
+
return $buffer;
|
152 |
+
}
|
153 |
+
|
154 |
+
if (! $this->_can_cache2()) {
|
155 |
+
$this->_send_compression_headers($this->_compression);
|
156 |
+
|
157 |
+
if ($this->_config->get_boolean('pgcache.debug')) {
|
158 |
+
$time_total = w3_microtime() - $this->_time_start;
|
159 |
+
$debug_info = $this->_get_debug_info(false, $this->_cache_reject_reason, false, $time_total);
|
160 |
+
$buffer .= "\r\n\r\n" . $debug_info;
|
161 |
+
}
|
162 |
+
|
163 |
+
switch ($this->_compression) {
|
164 |
+
case 'gzip':
|
165 |
+
return gzencode($buffer);
|
166 |
|
167 |
+
case 'deflate':
|
168 |
+
return gzdeflate($buffer);
|
|
|
|
|
|
|
|
|
|
|
169 |
}
|
170 |
|
171 |
return $buffer;
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
174 |
/**
|
175 |
* Create data object
|
176 |
*/
|
178 |
$page_keys = array();
|
179 |
|
180 |
$cache = $this->_get_cache();
|
|
|
181 |
$time = time();
|
182 |
$is_404 = is_404();
|
183 |
|
193 |
'404' => $is_404
|
194 |
);
|
195 |
|
|
|
|
|
|
|
|
|
|
|
196 |
/**
|
197 |
* Set content to cache
|
198 |
*/
|
204 |
$data['content'] = $buffer;
|
205 |
}
|
206 |
|
207 |
+
$data_array[$compression] = $data;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* We must compression headers first before ::_get_data_headers() call
|
212 |
+
*/
|
213 |
+
@$this->_conditional_get($time, md5($data_array[$this->_compression]['content']));
|
214 |
+
$this->_send_compression_headers($this->_compression);
|
215 |
+
@header('Pragma: public');
|
216 |
+
|
217 |
+
foreach ($data_array as $compression => $data) {
|
218 |
/**
|
219 |
+
* Set headers to cache
|
220 |
*/
|
221 |
+
$data['headers'] = $this->_get_data_headers($compression);
|
|
|
|
|
|
|
222 |
$data_array[$compression] = $data;
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Cache data
|
226 |
+
*/
|
227 |
+
$page_key = $this->_get_page_key($compression);
|
228 |
+
$cache->set($page_key, $data, $this->_lifetime);
|
229 |
$page_keys[] = $page_key;
|
230 |
}
|
231 |
|
257 |
*/
|
258 |
if ($this->_config->get_boolean('pgcache.debug')) {
|
259 |
$time_total = w3_microtime() - $this->_time_start;
|
260 |
+
$debug_info = $this->_get_debug_info(true, '', false, $time_total);
|
261 |
$this->_append_content($data_array[$this->_compression], "\r\n\r\n" . $debug_info);
|
262 |
}
|
263 |
|
294 |
$map_key = $this->_get_map_key($namespace);
|
295 |
$cache = $this->_get_cache();
|
296 |
|
297 |
+
return $cache->set($map_key, $map, $this->_lifetime);
|
298 |
}
|
299 |
|
300 |
/**
|
473 |
/**
|
474 |
* Skip if user is logged in
|
475 |
*/
|
476 |
+
if ($this->_config->get_boolean('pgcache.reject.logged', true) && ! $this->_check_logged_in()) {
|
477 |
$this->_cache_reject_reason = 'User is logged in';
|
478 |
|
479 |
return false;
|
488 |
* @param string $buffer
|
489 |
* @return boolean
|
490 |
*/
|
491 |
+
function _can_cache2()
|
492 |
{
|
493 |
/**
|
494 |
* Skip if caching is disabled
|
497 |
return false;
|
498 |
}
|
499 |
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
/**
|
501 |
* Don't cache 404 pages
|
502 |
*/
|
537 |
static $cache = null;
|
538 |
|
539 |
if ($cache === null) {
|
540 |
+
$engine = $this->_config->get_string('pgcache.engine', 'file');
|
541 |
+
|
542 |
+
switch ($engine) {
|
543 |
+
case 'memcached':
|
544 |
+
$engineConfig = array(
|
545 |
+
'engine' => $this->_config->get_string('pgcache.memcached.engine', 'auto'),
|
546 |
+
'servers' => $this->_config->get_array('pgcache.memcached.servers'),
|
547 |
+
'persistant' => true
|
548 |
+
);
|
549 |
+
break;
|
550 |
+
|
551 |
+
case 'file':
|
552 |
+
$engineConfig = array(
|
553 |
+
'cache_dir' => W3TC_CACHE_FILE_DIR
|
554 |
+
);
|
555 |
+
break;
|
556 |
+
|
557 |
+
default:
|
558 |
+
$engineConfig = array();
|
559 |
}
|
560 |
|
561 |
require_once W3TC_LIB_W3_DIR . '/Cache.php';
|
573 |
function _check_request_uri()
|
574 |
{
|
575 |
$auto_reject_uri = array(
|
576 |
+
'wp-login',
|
577 |
+
'wp-register'
|
|
|
578 |
);
|
579 |
|
580 |
foreach ($auto_reject_uri as $uri) {
|
684 |
{
|
685 |
$headers = array();
|
686 |
|
687 |
+
if (function_exists('headers_list')) {
|
|
|
|
|
|
|
688 |
foreach (headers_list() as $header) {
|
689 |
list ($header_name, $header_value) = explode(': ', $header, 2);
|
690 |
$headers[$header_name] = $header_value;
|
691 |
}
|
692 |
+
} elseif (function_exists('apache_response_headers')) {
|
693 |
+
flush();
|
694 |
+
$headers = apache_response_headers();
|
695 |
}
|
696 |
|
697 |
+
ksort($headers);
|
698 |
+
reset($headers);
|
699 |
+
|
700 |
return $headers;
|
701 |
}
|
702 |
|
792 |
*/
|
793 |
function _get_map_key($namespace)
|
794 |
{
|
795 |
+
$blog_id = w3_get_blog_id();
|
796 |
+
|
797 |
+
if (empty($blog_id)) {
|
798 |
+
$blog_id = $_SERVER['HTTP_HOST'];
|
799 |
+
}
|
800 |
+
|
801 |
+
$key = sprintf('w3tc_%s_map_%s', md5($blog_id), $namespace);
|
802 |
|
803 |
return $key;
|
804 |
}
|
832 |
* @param string $reason
|
833 |
* @param boolean $status
|
834 |
* @param double $time
|
|
|
835 |
* @return string
|
836 |
*/
|
837 |
+
function _get_debug_info($cache, $reason, $status, $time)
|
838 |
{
|
839 |
$debug_info = "<!-- W3 Total Cache: Page cache debug info:\r\n";
|
840 |
+
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), w3_get_engine_name($this->_config->get_string('pgcache.engine')));
|
841 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Key: ', 20), $this->_page_key);
|
842 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Caching: ', 20), ($cache ? 'enabled' : 'disabled'));
|
843 |
if (! $cache) {
|
846 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Status: ', 20), ($status ? 'cached' : 'not cached'));
|
847 |
$debug_info .= sprintf("%s%.3fs\r\n", str_pad('Creation Time: ', 20), $time);
|
848 |
|
849 |
+
$headers = $this->_get_response_headers();
|
850 |
+
|
851 |
if (count($headers)) {
|
852 |
$debug_info .= "Headers info:\r\n";
|
853 |
|
896 |
function _send_compression_headers($compression)
|
897 |
{
|
898 |
if ($compression !== false) {
|
899 |
+
@header('Content-Encoding: ' . $compression);
|
900 |
+
@header('Vary: Accept-Encoding, Cookie');
|
901 |
}
|
902 |
}
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Conditional get
|
906 |
+
* @param $time
|
907 |
+
* @param $etag
|
908 |
+
* @return void
|
909 |
+
*/
|
910 |
+
function _conditional_get($time, $etag)
|
911 |
+
{
|
912 |
+
require_once W3TC_LIB_MINIFY_DIR . 'HTTP/ConditionalGet.php';
|
913 |
+
|
914 |
+
$cg_options = array(
|
915 |
+
'maxAge' => $this->_lifetime,
|
916 |
+
'contentHash' => $etag
|
917 |
+
);
|
918 |
+
|
919 |
+
if ($this->_compression) {
|
920 |
+
$cg_options['encoding'] = $this->_compression;
|
921 |
+
}
|
922 |
+
|
923 |
+
HTTP_ConditionalGet::check($time, true, $cg_options);
|
924 |
+
}
|
925 |
}
|
lib/W3/Plugin.php
CHANGED
@@ -69,16 +69,20 @@ class W3_Plugin
|
|
69 |
static $locked = null;
|
70 |
|
71 |
if ($locked === null) {
|
72 |
-
$
|
73 |
$config = basename(W3TC_CONFIG_PATH);
|
|
|
74 |
|
75 |
-
$
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
$
|
80 |
-
|
|
|
|
|
81 |
}
|
|
|
82 |
}
|
83 |
}
|
84 |
|
69 |
static $locked = null;
|
70 |
|
71 |
if ($locked === null) {
|
72 |
+
$locked = false;
|
73 |
$config = basename(W3TC_CONFIG_PATH);
|
74 |
+
$config_dir = dirname(W3TC_CONFIG_PATH);
|
75 |
|
76 |
+
$dir = @opendir($config_dir);
|
77 |
|
78 |
+
if ($dir) {
|
79 |
+
while (($entry = @readdir($dir))) {
|
80 |
+
if (strpos($entry, W3TC_CONFIG_NAME) === 0 && $entry !== $config) {
|
81 |
+
$locked = true;
|
82 |
+
break;
|
83 |
+
}
|
84 |
}
|
85 |
+
@closedir($dir);
|
86 |
}
|
87 |
}
|
88 |
|
lib/W3/Plugin/Cdn.php
CHANGED
@@ -58,7 +58,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
58 |
'cron_queue_process'
|
59 |
));
|
60 |
|
61 |
-
if (
|
62 |
ob_start(array(
|
63 |
&$this,
|
64 |
'ob_callback'
|
@@ -135,10 +135,10 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
135 |
{
|
136 |
global $wpdb;
|
137 |
|
|
|
|
|
138 |
$sql = sprintf('DROP TABLE IF EXISTS `%s%s`', $wpdb->prefix, W3TC_CDN_TABLE_QUEUE);
|
139 |
$wpdb->query($sql);
|
140 |
-
|
141 |
-
wp_clear_scheduled_hook('w3_cdn_cron_queue_process');
|
142 |
}
|
143 |
|
144 |
/**
|
@@ -202,16 +202,17 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
202 |
/**
|
203 |
* Cron schedules filter
|
204 |
*
|
|
|
205 |
* @return array
|
206 |
*/
|
207 |
-
function cron_schedules()
|
208 |
{
|
209 |
-
return array(
|
210 |
'every_15_min' => array(
|
211 |
'interval' => 900,
|
212 |
'display' => 'Every 15 minutes'
|
213 |
)
|
214 |
-
);
|
215 |
}
|
216 |
|
217 |
/**
|
@@ -254,20 +255,20 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
254 |
if ($this->_config->get_boolean('cdn.includes.enable', true)) {
|
255 |
$mask = $this->_config->get_string('cdn.includes.files');
|
256 |
if (! empty($mask)) {
|
257 |
-
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(
|
258 |
}
|
259 |
}
|
260 |
|
261 |
if ($this->_config->get_boolean('cdn.theme.enable', true)) {
|
262 |
-
$
|
263 |
$mask = $this->_config->get_string('cdn.theme.files');
|
264 |
if (! empty($mask)) {
|
265 |
-
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(
|
266 |
}
|
267 |
}
|
268 |
|
269 |
if ($this->_config->get_boolean('cdn.minify.enable', true)) {
|
270 |
-
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(' . preg_quote(
|
271 |
}
|
272 |
|
273 |
if ($this->_config->get_boolean('cdn.custom.enable', true)) {
|
@@ -275,6 +276,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
275 |
if (! empty($files)) {
|
276 |
$files_quoted = array();
|
277 |
foreach ($files as $file) {
|
|
|
278 |
$files_quoted[] = preg_quote($file);
|
279 |
}
|
280 |
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(' . implode('|', $files_quoted) . '))~';
|
@@ -305,21 +307,22 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
305 |
{
|
306 |
$files = array();
|
307 |
|
|
|
308 |
$upload_dir = $this->get_upload_dir();
|
309 |
$upload_url = $this->get_upload_url();
|
310 |
|
311 |
if ($upload_dir && $upload_url) {
|
312 |
if (isset($metadata['file'])) {
|
313 |
$file = $this->normalize_attachment_file($metadata['file']);
|
314 |
-
$local_file = $upload_dir . '/' . $file;
|
315 |
-
$remote_file = $upload_url . '/' . $file;
|
316 |
$files[$local_file] = $remote_file;
|
317 |
if (isset($metadata['sizes'])) {
|
318 |
$file_dir = dirname($file);
|
319 |
foreach ((array) $metadata['sizes'] as $size) {
|
320 |
if (isset($size['file'])) {
|
321 |
-
$local_file = $upload_dir . '/' . $file_dir . '/' . $size['file'];
|
322 |
-
$remote_file = $upload_url . '/' . $file_dir . '/' . $size['file'];
|
323 |
$files[$local_file] = $remote_file;
|
324 |
}
|
325 |
}
|
@@ -344,7 +347,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
344 |
global $wpdb;
|
345 |
|
346 |
$table = $wpdb->prefix . W3TC_CDN_TABLE_QUEUE;
|
347 |
-
$sql = sprintf('SELECT id FROM %s WHERE local_path = "%s" remote_path = "%s" AND command != %d', $table, $wpdb->escape($local_path), $wpdb->escape($remote_path), $command);
|
348 |
|
349 |
if (($row = $wpdb->get_row($sql))) {
|
350 |
$sql = sprintf('DELETE FROM %s WHERE id = %d', $table, $row->id);
|
@@ -557,6 +560,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
557 |
$total = 0;
|
558 |
$results = array();
|
559 |
|
|
|
560 |
$upload_dir = $this->get_upload_dir();
|
561 |
$upload_url = $this->get_upload_url();
|
562 |
|
@@ -600,8 +604,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
600 |
$files = array_merge($files, $this->get_metadata_files($metadata));
|
601 |
} elseif (! empty($post->file)) {
|
602 |
$file = $this->normalize_attachment_file($post->file);
|
603 |
-
$local_file = $upload_dir . '/' . $file;
|
604 |
-
$remote_file = $upload_url . '/' . $file;
|
605 |
$files[$local_file] = $remote_file;
|
606 |
}
|
607 |
}
|
@@ -638,7 +642,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
638 |
if ($upload_dir && $upload_url) {
|
639 |
$sql = sprintf('SELECT
|
640 |
ID,
|
641 |
-
post_content
|
|
|
642 |
FROM
|
643 |
%sposts
|
644 |
WHERE
|
@@ -674,15 +679,18 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
674 |
|
675 |
if (preg_match('~(' . $regexp . ')$~', $src)) {
|
676 |
$file = ltrim(str_replace($siteurl, '', $src), '\\/');
|
677 |
-
$file_dir = date('Y/m');
|
678 |
$file_base = basename($file);
|
679 |
$dst = sprintf('%s/%s/%s', $upload_dir, $file_dir, $file_base);
|
|
|
680 |
$dst_path = ABSPATH . $dst;
|
681 |
$dst_url = sprintf('%s/%s/%s/%s', $siteurl, $upload_url, $file_dir, $file_base);
|
682 |
$result = false;
|
683 |
$error = '';
|
684 |
$download_result = null;
|
685 |
|
|
|
|
|
686 |
if (! file_exists($dst_path)) {
|
687 |
if (w3_is_url($file)) {
|
688 |
if ($import_external) {
|
@@ -692,7 +700,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
692 |
}
|
693 |
} elseif (strstr($src, $upload_url) === false) {
|
694 |
$file_path = ABSPATH . $file;
|
695 |
-
$download_result = @copy(
|
696 |
} else {
|
697 |
$error = 'Source file already exists';
|
698 |
}
|
@@ -751,6 +759,91 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
751 |
}
|
752 |
}
|
753 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
/**
|
755 |
* Returns attachments count
|
756 |
*
|
@@ -795,12 +888,22 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
795 |
return $wpdb->get_var($sql);
|
796 |
}
|
797 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
798 |
/**
|
799 |
* Exports includes to CDN
|
800 |
*/
|
801 |
function get_files_includes()
|
802 |
{
|
803 |
-
$files = $this->search_files(
|
804 |
|
805 |
return $files;
|
806 |
}
|
@@ -810,8 +913,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
810 |
*/
|
811 |
function get_files_theme()
|
812 |
{
|
813 |
-
$
|
814 |
-
$files = $this->search_files(
|
815 |
|
816 |
return $files;
|
817 |
}
|
@@ -823,47 +926,15 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
823 |
{
|
824 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
825 |
$minify = W3_Plugin_Minify::instance();
|
826 |
-
|
827 |
-
$css_header_url = $minify->format_group_url('css', 'include');
|
828 |
-
$js_header_url = $minify->format_group_url('js', 'include');
|
829 |
-
$js_header_nb_url = $minify->format_group_url('js', 'include-nb');
|
830 |
-
$js_footer_url = $minify->format_group_url('js', 'include-footer');
|
831 |
-
$js_footer_nb_url = $minify->format_group_url('js', 'include-footer-nb');
|
832 |
-
|
833 |
-
$css_header_file = basename($css_header_url);
|
834 |
-
$js_header_file = basename($js_header_url);
|
835 |
-
$js_header_nb_file = basename($js_header_nb_url);
|
836 |
-
$js_footer_file = basename($js_footer_url);
|
837 |
-
$js_footer_nb_file = basename($js_footer_nb_url);
|
838 |
-
|
839 |
-
$downloads = array(
|
840 |
-
array(
|
841 |
-
'url' => $css_header_url,
|
842 |
-
'file' => $css_header_file
|
843 |
-
),
|
844 |
-
array(
|
845 |
-
'url' => $js_header_url,
|
846 |
-
'file' => $js_header_file
|
847 |
-
),
|
848 |
-
array(
|
849 |
-
'url' => $js_header_nb_url,
|
850 |
-
'file' => $js_header_nb_file
|
851 |
-
),
|
852 |
-
array(
|
853 |
-
'url' => $js_footer_url,
|
854 |
-
'file' => $js_footer_file
|
855 |
-
),
|
856 |
-
array(
|
857 |
-
'url' => $js_footer_nb_url,
|
858 |
-
'file' => $js_footer_nb_file
|
859 |
-
)
|
860 |
-
);
|
861 |
|
862 |
$files = array();
|
|
|
863 |
|
864 |
-
foreach ($
|
865 |
-
|
866 |
-
|
|
|
867 |
}
|
868 |
}
|
869 |
|
@@ -889,14 +960,14 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
889 |
*/
|
890 |
function download($url, $file)
|
891 |
{
|
892 |
-
if (
|
893 |
-
|
|
|
|
|
|
|
894 |
}
|
895 |
|
896 |
-
|
897 |
-
@fclose($fp);
|
898 |
-
|
899 |
-
return true;
|
900 |
}
|
901 |
|
902 |
/**
|
@@ -907,7 +978,9 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
907 |
*/
|
908 |
function format_local_path($file)
|
909 |
{
|
910 |
-
|
|
|
|
|
911 |
}
|
912 |
|
913 |
/**
|
@@ -955,7 +1028,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
955 |
|
956 |
$this->replaced_urls[] = $matches[2];
|
957 |
|
958 |
-
$replacement = sprintf('%shttp://%s/%s', $matches[1], $domain, $matches[4]);
|
959 |
|
960 |
return $replacement;
|
961 |
}
|
@@ -970,29 +1043,28 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
970 |
*/
|
971 |
function search_files($search_dir, $base_dir, $mask = '*.*', $recursive = true)
|
972 |
{
|
973 |
-
static $
|
974 |
|
975 |
$files = array();
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
if (preg_match($regexp, $entry)) {
|
993 |
-
$files[] = $base_dir . '/' . (($p = implode('/', $path)) != '' ? $p . '/' : '') . $entry;
|
994 |
}
|
995 |
}
|
|
|
996 |
}
|
997 |
|
998 |
return $files;
|
@@ -1209,4 +1281,113 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1209 |
|
1210 |
return $debug_info;
|
1211 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1212 |
}
|
58 |
'cron_queue_process'
|
59 |
));
|
60 |
|
61 |
+
if ($this->can_cdn()) {
|
62 |
ob_start(array(
|
63 |
&$this,
|
64 |
'ob_callback'
|
135 |
{
|
136 |
global $wpdb;
|
137 |
|
138 |
+
wp_clear_scheduled_hook('w3_cdn_cron_queue_process');
|
139 |
+
|
140 |
$sql = sprintf('DROP TABLE IF EXISTS `%s%s`', $wpdb->prefix, W3TC_CDN_TABLE_QUEUE);
|
141 |
$wpdb->query($sql);
|
|
|
|
|
142 |
}
|
143 |
|
144 |
/**
|
202 |
/**
|
203 |
* Cron schedules filter
|
204 |
*
|
205 |
+
* @paran array $schedules
|
206 |
* @return array
|
207 |
*/
|
208 |
+
function cron_schedules($schedules)
|
209 |
{
|
210 |
+
return array_merge($schedules, array(
|
211 |
'every_15_min' => array(
|
212 |
'interval' => 900,
|
213 |
'display' => 'Every 15 minutes'
|
214 |
)
|
215 |
+
));
|
216 |
}
|
217 |
|
218 |
/**
|
255 |
if ($this->_config->get_boolean('cdn.includes.enable', true)) {
|
256 |
$mask = $this->_config->get_string('cdn.includes.files');
|
257 |
if (! empty($mask)) {
|
258 |
+
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(' . preg_quote(WPINC) . '/(' . $this->get_regexp_by_mask($mask) . ')))~';
|
259 |
}
|
260 |
}
|
261 |
|
262 |
if ($this->_config->get_boolean('cdn.theme.enable', true)) {
|
263 |
+
$theme_dir = ltrim(str_replace($siteurl, '', get_stylesheet_directory_uri()), '/');
|
264 |
$mask = $this->_config->get_string('cdn.theme.files');
|
265 |
if (! empty($mask)) {
|
266 |
+
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(' . preg_quote($theme_dir) . '/(' . $this->get_regexp_by_mask($mask) . ')))~';
|
267 |
}
|
268 |
}
|
269 |
|
270 |
if ($this->_config->get_boolean('cdn.minify.enable', true)) {
|
271 |
+
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(' . preg_quote(W3TC_CONTENT_DIR_NAME) . '/[a-z0-9-_]+\.include(-footer)?(-nb)?\.(css|js)))~';
|
272 |
}
|
273 |
|
274 |
if ($this->_config->get_boolean('cdn.custom.enable', true)) {
|
276 |
if (! empty($files)) {
|
277 |
$files_quoted = array();
|
278 |
foreach ($files as $file) {
|
279 |
+
$file = ltrim(str_replace($siteurl, '', $file), '/');
|
280 |
$files_quoted[] = preg_quote($file);
|
281 |
}
|
282 |
$regexps[] = '~(["\'])((' . preg_quote($siteurl) . ')?/?(' . implode('|', $files_quoted) . '))~';
|
307 |
{
|
308 |
$files = array();
|
309 |
|
310 |
+
$site_path = w3_get_site_path();
|
311 |
$upload_dir = $this->get_upload_dir();
|
312 |
$upload_url = $this->get_upload_url();
|
313 |
|
314 |
if ($upload_dir && $upload_url) {
|
315 |
if (isset($metadata['file'])) {
|
316 |
$file = $this->normalize_attachment_file($metadata['file']);
|
317 |
+
$local_file = $site_path . $upload_dir . '/' . $file;
|
318 |
+
$remote_file = $site_path . $upload_url . '/' . $file;
|
319 |
$files[$local_file] = $remote_file;
|
320 |
if (isset($metadata['sizes'])) {
|
321 |
$file_dir = dirname($file);
|
322 |
foreach ((array) $metadata['sizes'] as $size) {
|
323 |
if (isset($size['file'])) {
|
324 |
+
$local_file = $site_path . $upload_dir . '/' . $file_dir . '/' . $size['file'];
|
325 |
+
$remote_file = $site_path . $upload_url . '/' . $file_dir . '/' . $size['file'];
|
326 |
$files[$local_file] = $remote_file;
|
327 |
}
|
328 |
}
|
347 |
global $wpdb;
|
348 |
|
349 |
$table = $wpdb->prefix . W3TC_CDN_TABLE_QUEUE;
|
350 |
+
$sql = sprintf('SELECT id FROM %s WHERE local_path = "%s" AND remote_path = "%s" AND command != %d', $table, $wpdb->escape($local_path), $wpdb->escape($remote_path), $command);
|
351 |
|
352 |
if (($row = $wpdb->get_row($sql))) {
|
353 |
$sql = sprintf('DELETE FROM %s WHERE id = %d', $table, $row->id);
|
560 |
$total = 0;
|
561 |
$results = array();
|
562 |
|
563 |
+
$site_path = w3_get_site_path();
|
564 |
$upload_dir = $this->get_upload_dir();
|
565 |
$upload_url = $this->get_upload_url();
|
566 |
|
604 |
$files = array_merge($files, $this->get_metadata_files($metadata));
|
605 |
} elseif (! empty($post->file)) {
|
606 |
$file = $this->normalize_attachment_file($post->file);
|
607 |
+
$local_file = $site_path . $upload_dir . '/' . $file;
|
608 |
+
$remote_file = $site_path . $upload_url . '/' . $file;
|
609 |
$files[$local_file] = $remote_file;
|
610 |
}
|
611 |
}
|
642 |
if ($upload_dir && $upload_url) {
|
643 |
$sql = sprintf('SELECT
|
644 |
ID,
|
645 |
+
post_content,
|
646 |
+
post_date
|
647 |
FROM
|
648 |
%sposts
|
649 |
WHERE
|
679 |
|
680 |
if (preg_match('~(' . $regexp . ')$~', $src)) {
|
681 |
$file = ltrim(str_replace($siteurl, '', $src), '\\/');
|
682 |
+
$file_dir = date('Y/m', strtotime($post->post_date));
|
683 |
$file_base = basename($file);
|
684 |
$dst = sprintf('%s/%s/%s', $upload_dir, $file_dir, $file_base);
|
685 |
+
$dst_dir = dirname($dst);
|
686 |
$dst_path = ABSPATH . $dst;
|
687 |
$dst_url = sprintf('%s/%s/%s/%s', $siteurl, $upload_url, $file_dir, $file_base);
|
688 |
$result = false;
|
689 |
$error = '';
|
690 |
$download_result = null;
|
691 |
|
692 |
+
w3_mkdir($dst_dir, 0755, ABSPATH);
|
693 |
+
|
694 |
if (! file_exists($dst_path)) {
|
695 |
if (w3_is_url($file)) {
|
696 |
if ($import_external) {
|
700 |
}
|
701 |
} elseif (strstr($src, $upload_url) === false) {
|
702 |
$file_path = ABSPATH . $file;
|
703 |
+
$download_result = @copy($file_path, $dst_path);
|
704 |
} else {
|
705 |
$error = 'Source file already exists';
|
706 |
}
|
759 |
}
|
760 |
}
|
761 |
|
762 |
+
/**
|
763 |
+
* Rename domain
|
764 |
+
* @param $names
|
765 |
+
* @param $limit
|
766 |
+
* @param $offset
|
767 |
+
* @param $count
|
768 |
+
* @param $total
|
769 |
+
* @param $results
|
770 |
+
* @return void
|
771 |
+
*/
|
772 |
+
function rename_domain($names, $limit = null, $offset = null, &$count = null, &$total = null, &$results = array())
|
773 |
+
{
|
774 |
+
global $wpdb;
|
775 |
+
|
776 |
+
$count = 0;
|
777 |
+
$total = 0;
|
778 |
+
$results = array();
|
779 |
+
|
780 |
+
$siteurl = w3_get_site_url();
|
781 |
+
$upload_url = $this->get_upload_url();
|
782 |
+
|
783 |
+
foreach ($names as $index => $name) {
|
784 |
+
$names[$index] = str_ireplace('www.', '', $name);
|
785 |
+
}
|
786 |
+
|
787 |
+
if ($upload_url) {
|
788 |
+
$sql = sprintf('SELECT
|
789 |
+
ID,
|
790 |
+
post_content,
|
791 |
+
post_date
|
792 |
+
FROM
|
793 |
+
%sposts
|
794 |
+
WHERE
|
795 |
+
post_status = "publish"
|
796 |
+
AND post_type = "post"
|
797 |
+
AND (post_content LIKE "%%src=%%"
|
798 |
+
OR post_content LIKE "%%href=%%")
|
799 |
+
', $wpdb->prefix);
|
800 |
+
|
801 |
+
if ($limit) {
|
802 |
+
$sql .= sprintf(' LIMIT %d', $limit);
|
803 |
+
|
804 |
+
if ($offset) {
|
805 |
+
$sql .= sprintf(' OFFSET %d', $offset);
|
806 |
+
}
|
807 |
+
}
|
808 |
+
|
809 |
+
$posts = $wpdb->get_results($sql);
|
810 |
+
|
811 |
+
if ($posts) {
|
812 |
+
$count = count($posts);
|
813 |
+
$total = $this->get_rename_posts_count();
|
814 |
+
$names_quoted = array_map('preg_quote', $names);
|
815 |
+
|
816 |
+
foreach ($posts as $post) {
|
817 |
+
$matches = null;
|
818 |
+
$post_content = $post->post_content;
|
819 |
+
$regexp = '~(href|src)=[\'"]?(https?://(www\.)?(' . implode('|', $names_quoted) . ')/' . preg_quote($upload_url) . '([^\'"<>\s]+))[\'"]~';
|
820 |
+
|
821 |
+
if (preg_match_all($regexp, $post_content, $matches, PREG_SET_ORDER)) {
|
822 |
+
foreach ($matches as $match) {
|
823 |
+
$old_url = $match[2];
|
824 |
+
$new_url = sprintf('%s/%s%s', $siteurl, $upload_url, $match[5]);
|
825 |
+
$post_content = str_replace($old_url, $new_url, $post_content);
|
826 |
+
|
827 |
+
$results[] = array(
|
828 |
+
'old' => $old_url,
|
829 |
+
'new' => $new_url,
|
830 |
+
'result' => true,
|
831 |
+
'error' => 'OK'
|
832 |
+
);
|
833 |
+
}
|
834 |
+
}
|
835 |
+
|
836 |
+
if ($post_content != $post->post_content) {
|
837 |
+
wp_update_post(array(
|
838 |
+
'ID' => $post->ID,
|
839 |
+
'post_content' => $post_content
|
840 |
+
));
|
841 |
+
}
|
842 |
+
}
|
843 |
+
}
|
844 |
+
}
|
845 |
+
}
|
846 |
+
|
847 |
/**
|
848 |
* Returns attachments count
|
849 |
*
|
888 |
return $wpdb->get_var($sql);
|
889 |
}
|
890 |
|
891 |
+
/**
|
892 |
+
* Returns rename posts count
|
893 |
+
*
|
894 |
+
* @return integer
|
895 |
+
*/
|
896 |
+
function get_rename_posts_count()
|
897 |
+
{
|
898 |
+
return $this->get_import_posts_count();
|
899 |
+
}
|
900 |
+
|
901 |
/**
|
902 |
* Exports includes to CDN
|
903 |
*/
|
904 |
function get_files_includes()
|
905 |
{
|
906 |
+
$files = $this->search_files(ABSPATH . WPINC, w3_get_site_path() . WPINC, $this->_config->get_string('cdn.includes.files'));
|
907 |
|
908 |
return $files;
|
909 |
}
|
913 |
*/
|
914 |
function get_files_theme()
|
915 |
{
|
916 |
+
$theme_dir = ltrim(str_replace(ABSPATH, '', get_stylesheet_directory()), '/');
|
917 |
+
$files = $this->search_files(get_stylesheet_directory(), w3_get_site_path() . $theme_dir, $this->_config->get_string('cdn.theme.files'));
|
918 |
|
919 |
return $files;
|
920 |
}
|
926 |
{
|
927 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
928 |
$minify = W3_Plugin_Minify::instance();
|
929 |
+
$urls = $minify->get_urls();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
930 |
|
931 |
$files = array();
|
932 |
+
$site_path = w3_get_site_path();
|
933 |
|
934 |
+
foreach ($urls as $url) {
|
935 |
+
$file = basename($url);
|
936 |
+
if ($this->download($url, W3TC_CONTENT_DIR . '/' . $file)) {
|
937 |
+
$files[] = $site_path . W3TC_CONTENT_DIR_NAME . '/' . $file;
|
938 |
}
|
939 |
}
|
940 |
|
960 |
*/
|
961 |
function download($url, $file)
|
962 |
{
|
963 |
+
if (($data = w3_url_get($url)) && ($fp = @fopen($file, 'w'))) {
|
964 |
+
@fputs($fp, $data);
|
965 |
+
@fclose($fp);
|
966 |
+
|
967 |
+
return true;
|
968 |
}
|
969 |
|
970 |
+
return false;
|
|
|
|
|
|
|
971 |
}
|
972 |
|
973 |
/**
|
978 |
*/
|
979 |
function format_local_path($file)
|
980 |
{
|
981 |
+
$site_path = w3_get_site_path();
|
982 |
+
$abspath = ($site_path ? substr(ABSPATH, 0, - strlen($site_path)) : ABSPATH);
|
983 |
+
return $abspath . $file;
|
984 |
}
|
985 |
|
986 |
/**
|
1028 |
|
1029 |
$this->replaced_urls[] = $matches[2];
|
1030 |
|
1031 |
+
$replacement = sprintf('%shttp://%s/%s%s', $matches[1], $domain, w3_get_site_path(), $matches[4]);
|
1032 |
|
1033 |
return $replacement;
|
1034 |
}
|
1043 |
*/
|
1044 |
function search_files($search_dir, $base_dir, $mask = '*.*', $recursive = true)
|
1045 |
{
|
1046 |
+
static $stack = array();
|
1047 |
|
1048 |
$files = array();
|
1049 |
+
$dir = @opendir($search_dir);
|
1050 |
+
|
1051 |
+
if ($dir) {
|
1052 |
+
while (($entry = @readdir($dir))) {
|
1053 |
+
if ($entry != '.' && $entry != '..') {
|
1054 |
+
$path = $search_dir . '/' . $entry;
|
1055 |
+
if (is_dir($path) && $recursive) {
|
1056 |
+
array_push($stack, $entry);
|
1057 |
+
$files = array_merge($files, $this->search_files($path, $base_dir, $mask, $recursive));
|
1058 |
+
array_pop($stack);
|
1059 |
+
} else {
|
1060 |
+
$regexp = '~^' . $this->get_regexp_by_mask($mask) . '$~i';
|
1061 |
+
if (preg_match($regexp, $entry)) {
|
1062 |
+
$files[] = $base_dir . '/' . (($p = implode('/', $stack)) != '' ? $p . '/' : '') . $entry;
|
1063 |
+
}
|
1064 |
+
}
|
|
|
|
|
1065 |
}
|
1066 |
}
|
1067 |
+
@closedir($dir);
|
1068 |
}
|
1069 |
|
1070 |
return $files;
|
1281 |
|
1282 |
return $debug_info;
|
1283 |
}
|
1284 |
+
|
1285 |
+
/**
|
1286 |
+
* Check if we can do CDN logic
|
1287 |
+
* @return boolean
|
1288 |
+
*/
|
1289 |
+
function can_cdn()
|
1290 |
+
{
|
1291 |
+
/**
|
1292 |
+
* Skip if CDN is disabled
|
1293 |
+
*/
|
1294 |
+
if (! $this->_config->get_boolean('cdn.enabled')) {
|
1295 |
+
return false;
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
/**
|
1299 |
+
* Skip if admin
|
1300 |
+
*/
|
1301 |
+
if (defined('WP_ADMIN')) {
|
1302 |
+
return false;
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
/**
|
1306 |
+
* Skip if doint AJAX
|
1307 |
+
*/
|
1308 |
+
if (defined('DOING_AJAX')) {
|
1309 |
+
return false;
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
/**
|
1313 |
+
* Skip if doing cron
|
1314 |
+
*/
|
1315 |
+
if (defined('DOING_CRON')) {
|
1316 |
+
return false;
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
/**
|
1320 |
+
* Skip if APP request
|
1321 |
+
*/
|
1322 |
+
if (defined('APP_REQUEST')) {
|
1323 |
+
return false;
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
/**
|
1327 |
+
* Skip if XMLRPC request
|
1328 |
+
*/
|
1329 |
+
if (defined('XMLRPC_REQUEST')) {
|
1330 |
+
return false;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
/**
|
1334 |
+
* Check User agent
|
1335 |
+
*/
|
1336 |
+
if (! $this->check_ua()) {
|
1337 |
+
return false;
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
/**
|
1341 |
+
* Check request URI
|
1342 |
+
*/
|
1343 |
+
if (! $this->check_request_uri()) {
|
1344 |
+
return false;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
return true;
|
1348 |
+
}
|
1349 |
+
|
1350 |
+
/**
|
1351 |
+
* Checks User Agent
|
1352 |
+
*
|
1353 |
+
* @return boolean
|
1354 |
+
*/
|
1355 |
+
function check_ua()
|
1356 |
+
{
|
1357 |
+
foreach ($this->_config->get_array('cdn.reject.ua') as $ua) {
|
1358 |
+
if (stristr($_SERVER['HTTP_USER_AGENT'], $ua) !== false) {
|
1359 |
+
return false;
|
1360 |
+
}
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
return true;
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
/**
|
1367 |
+
* Checks request URI
|
1368 |
+
*
|
1369 |
+
* @return boolean
|
1370 |
+
*/
|
1371 |
+
function check_request_uri()
|
1372 |
+
{
|
1373 |
+
$auto_reject_uri = array(
|
1374 |
+
'wp-login',
|
1375 |
+
'wp-register'
|
1376 |
+
);
|
1377 |
+
|
1378 |
+
foreach ($auto_reject_uri as $uri) {
|
1379 |
+
if (strstr($_SERVER['REQUEST_URI'], $uri) !== false) {
|
1380 |
+
return false;
|
1381 |
+
}
|
1382 |
+
}
|
1383 |
+
|
1384 |
+
foreach ($this->_config->get_array('cdn.reject.uri') as $expr) {
|
1385 |
+
$expr = trim($expr);
|
1386 |
+
if ($expr != '' && preg_match('@' . $expr . '@i', $_SERVER['REQUEST_URI'])) {
|
1387 |
+
return false;
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
return true;
|
1392 |
+
}
|
1393 |
}
|
lib/W3/Plugin/DbCache.php
CHANGED
@@ -51,7 +51,7 @@ class W3_Plugin_DbCache extends W3_Plugin
|
|
51 |
if (! $this->locked()) {
|
52 |
$file_db = WP_CONTENT_DIR . '/db.php';
|
53 |
|
54 |
-
if (@copy(
|
55 |
@chmod($file_db, 0644);
|
56 |
} else {
|
57 |
w3_writable_error($file_db);
|
51 |
if (! $this->locked()) {
|
52 |
$file_db = WP_CONTENT_DIR . '/db.php';
|
53 |
|
54 |
+
if (@copy(W3TC_INSTALL_DIR . '/db.php', $file_db)) {
|
55 |
@chmod($file_db, 0644);
|
56 |
} else {
|
57 |
w3_writable_error($file_db);
|
lib/W3/Plugin/Minify.php
CHANGED
@@ -25,7 +25,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
25 |
'deactivate'
|
26 |
));
|
27 |
|
28 |
-
if ($this->
|
29 |
ob_start(array(
|
30 |
&$this,
|
31 |
'ob_callback'
|
@@ -61,29 +61,37 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
61 |
function activate()
|
62 |
{
|
63 |
if (! $this->locked()) {
|
64 |
-
if (! is_dir(
|
65 |
-
if (@mkdir(
|
66 |
-
@chmod(
|
67 |
} else {
|
68 |
-
w3_writable_error(
|
69 |
}
|
70 |
}
|
71 |
|
72 |
-
$file_htaccess =
|
73 |
|
74 |
-
if (@copy(
|
75 |
@chmod($file_htaccess, 0644);
|
76 |
} else {
|
77 |
w3_writable_error($file_htaccess);
|
78 |
}
|
79 |
|
80 |
-
$file_index =
|
81 |
|
82 |
-
if (@copy(
|
83 |
@chmod($file_index, 0644);
|
84 |
} else {
|
85 |
w3_writable_error($file_index);
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
}
|
89 |
|
@@ -93,29 +101,8 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
93 |
function deactivate()
|
94 |
{
|
95 |
if (! $this->locked()) {
|
96 |
-
@unlink(
|
97 |
-
@unlink(
|
98 |
-
|
99 |
-
@unlink(W3TC_MINIFY_DIR . '/include.css');
|
100 |
-
|
101 |
-
@unlink(W3TC_MINIFY_DIR . '/include.js');
|
102 |
-
@unlink(W3TC_MINIFY_DIR . '/include-nb.js');
|
103 |
-
|
104 |
-
@unlink(W3TC_MINIFY_DIR . '/include-footer.js');
|
105 |
-
@unlink(W3TC_MINIFY_DIR . '/include-footer-nb.js');
|
106 |
-
|
107 |
-
$dir = @dir(W3TC_MINIFY_DIR);
|
108 |
-
if ($dir) {
|
109 |
-
while (($entry = @$dir->read())) {
|
110 |
-
if (strpos($entry, 'minify_') === 0) {
|
111 |
-
@unlink(W3TC_MINIFY_DIR . DIRECTORY_SEPARATOR . $entry);
|
112 |
-
}
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
@unlink(W3TC_MINIFY_DIR . '/error.log');
|
117 |
-
|
118 |
-
@rmdir(W3TC_MINIFY_DIR);
|
119 |
}
|
120 |
}
|
121 |
|
@@ -147,6 +134,10 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
147 |
|
148 |
$buffer = $this->clean($buffer);
|
149 |
|
|
|
|
|
|
|
|
|
150 |
return $buffer;
|
151 |
}
|
152 |
|
@@ -168,12 +159,14 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
168 |
*/
|
169 |
function clean($content)
|
170 |
{
|
171 |
-
if (
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
177 |
}
|
178 |
|
179 |
if ($this->_config->get_boolean('minify.html.enable', true) && ! ($this->_config->get_boolean('minify.html.reject.admin', true) && current_user_can('manage_options'))) {
|
@@ -196,15 +189,18 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
196 |
$regexps = array();
|
197 |
|
198 |
$groups = $this->_config->get_array('minify.css.groups');
|
199 |
-
$siteurl =
|
200 |
-
|
201 |
-
foreach ($groups as $
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
$
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
208 |
}
|
209 |
}
|
210 |
}
|
@@ -229,22 +225,25 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
229 |
$regexps = array();
|
230 |
|
231 |
$groups = $this->_config->get_array('minify.js.groups');
|
232 |
-
$siteurl =
|
233 |
-
|
234 |
-
foreach ($groups as $
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
$
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
241 |
}
|
242 |
}
|
243 |
}
|
244 |
}
|
245 |
|
246 |
foreach ($regexps as $regexp) {
|
247 |
-
$content = preg_replace('~<script\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]
|
248 |
}
|
249 |
|
250 |
return $content;
|
@@ -268,14 +267,14 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
268 |
'xhtml' => true
|
269 |
);
|
270 |
|
271 |
-
if ($this->_config->get_boolean('minify.css
|
272 |
$options['cssMinifier'] = array(
|
273 |
'Minify_CSS',
|
274 |
'minify'
|
275 |
);
|
276 |
}
|
277 |
|
278 |
-
if ($this->_config->get_boolean('minify.js
|
279 |
$options['jsMinifier'] = array(
|
280 |
'JSMin',
|
281 |
'minify'
|
@@ -297,13 +296,76 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
297 |
return $content;
|
298 |
}
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
/**
|
301 |
* Returns style link
|
302 |
*
|
303 |
* @param string $url
|
304 |
* @param string $import
|
305 |
*/
|
306 |
-
function get_style($url, $import)
|
307 |
{
|
308 |
if ($import) {
|
309 |
return "<style type=\"text/css\" media=\"all\">@import url(\"" . $url . "\");</style>\r\n";
|
@@ -329,10 +391,10 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
329 |
|
330 |
if (! $non_blocking_function) {
|
331 |
$non_blocking_function = true;
|
332 |
-
$script = "<script type=\"text/javascript\"
|
333 |
}
|
334 |
|
335 |
-
$script .= "<script type=\"text/javascript\"
|
336 |
|
337 |
return $script;
|
338 |
}
|
@@ -340,16 +402,24 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
340 |
|
341 |
/**
|
342 |
* returns style link for styles group
|
343 |
-
*
|
344 |
* @param string $group
|
345 |
*/
|
346 |
-
function get_styles($group)
|
347 |
{
|
348 |
$styles = '';
|
349 |
$groups = $this->_config->get_array('minify.css.groups');
|
350 |
|
351 |
-
if (
|
352 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
}
|
354 |
|
355 |
return $styles;
|
@@ -357,16 +427,24 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
357 |
|
358 |
/**
|
359 |
* Returns script linkg for scripts group
|
360 |
-
*
|
361 |
* @param string $group
|
362 |
*/
|
363 |
-
function get_scripts($group)
|
364 |
{
|
365 |
$scripts = '';
|
366 |
$groups = $this->_config->get_array('minify.js.groups');
|
367 |
|
368 |
-
if (
|
369 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
}
|
371 |
|
372 |
return $scripts;
|
@@ -380,7 +458,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
380 |
*/
|
381 |
function get_custom_script($files, $blocking = true)
|
382 |
{
|
383 |
-
return $this->get_script($this->
|
384 |
}
|
385 |
|
386 |
/**
|
@@ -391,34 +469,35 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
391 |
*/
|
392 |
function get_custom_style($files, $import = false)
|
393 |
{
|
394 |
-
return $this->get_style($this->
|
395 |
}
|
396 |
|
397 |
/**
|
398 |
-
* Formats URL
|
399 |
*
|
400 |
-
* @param string $type
|
401 |
* @param string $group
|
|
|
|
|
402 |
* @return string
|
403 |
*/
|
404 |
-
function
|
405 |
{
|
406 |
$siteurl = w3_get_site_url();
|
407 |
|
408 |
-
if ($this->_config->get_boolean('minify.rewrite',
|
409 |
-
return sprintf('%s/%s/%s.%s', $siteurl,
|
410 |
}
|
411 |
|
412 |
-
return sprintf('%s/%s
|
413 |
}
|
414 |
|
415 |
/**
|
416 |
-
* Formats URL
|
417 |
*
|
418 |
* @param string|array $files
|
419 |
* @return string
|
420 |
*/
|
421 |
-
function
|
422 |
{
|
423 |
if (! is_array($files)) {
|
424 |
$files = array(
|
@@ -439,7 +518,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
439 |
}
|
440 |
|
441 |
$siteurl = w3_get_site_url();
|
442 |
-
$url = sprintf('%s/%s
|
443 |
|
444 |
if ($base) {
|
445 |
$url .= sprintf('&b=%s', $base);
|
@@ -447,28 +526,224 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
447 |
|
448 |
return $url;
|
449 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
}
|
451 |
|
452 |
/**
|
453 |
* Prints script link for scripts group
|
454 |
-
*
|
455 |
* @param string $group
|
456 |
*/
|
457 |
-
function w3tc_scripts($group)
|
458 |
{
|
459 |
$w3_plugin_minify = W3_Plugin_Minify::instance();
|
460 |
-
echo $w3_plugin_minify->get_scripts($group);
|
461 |
}
|
462 |
|
463 |
/**
|
464 |
* Prints style link for styles group
|
465 |
-
*
|
466 |
* @param string $group
|
467 |
*/
|
468 |
-
function w3tc_styles($group)
|
469 |
{
|
470 |
$w3_plugin_minify = W3_Plugin_Minify::instance();
|
471 |
-
echo $w3_plugin_minify->get_styles($group);
|
472 |
}
|
473 |
|
474 |
/**
|
25 |
'deactivate'
|
26 |
));
|
27 |
|
28 |
+
if ($this->can_minify()) {
|
29 |
ob_start(array(
|
30 |
&$this,
|
31 |
'ob_callback'
|
61 |
function activate()
|
62 |
{
|
63 |
if (! $this->locked()) {
|
64 |
+
if (! is_dir(W3TC_CONTENT_DIR)) {
|
65 |
+
if (@mkdir(W3TC_CONTENT_DIR, 0755)) {
|
66 |
+
@chmod(W3TC_CONTENT_DIR, 0755);
|
67 |
} else {
|
68 |
+
w3_writable_error(W3TC_CONTENT_DIR);
|
69 |
}
|
70 |
}
|
71 |
|
72 |
+
$file_htaccess = W3TC_CONTENT_DIR . '/.htaccess';
|
73 |
|
74 |
+
if (@copy(W3TC_INSTALL_MINIFY_DIR . '/_htaccess', $file_htaccess)) {
|
75 |
@chmod($file_htaccess, 0644);
|
76 |
} else {
|
77 |
w3_writable_error($file_htaccess);
|
78 |
}
|
79 |
|
80 |
+
$file_index = W3TC_CONTENT_DIR . '/index.html';
|
81 |
|
82 |
+
if (@copy(W3TC_INSTALL_MINIFY_DIR . '/index.html', $file_index)) {
|
83 |
@chmod($file_index, 0644);
|
84 |
} else {
|
85 |
w3_writable_error($file_index);
|
86 |
}
|
87 |
+
|
88 |
+
$file_minify = W3TC_CONTENT_DIR . '/minify.php';
|
89 |
+
|
90 |
+
if (@copy(W3TC_INSTALL_MINIFY_DIR . '/minify.php', $file_minify)) {
|
91 |
+
@chmod($file_minify, 0644);
|
92 |
+
} else {
|
93 |
+
w3_writable_error($file_minify);
|
94 |
+
}
|
95 |
}
|
96 |
}
|
97 |
|
101 |
function deactivate()
|
102 |
{
|
103 |
if (! $this->locked()) {
|
104 |
+
@unlink(W3TC_CONTENT_DIR . '/.htaccess');
|
105 |
+
@unlink(W3TC_CONTENT_DIR . '/index.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
}
|
108 |
|
134 |
|
135 |
$buffer = $this->clean($buffer);
|
136 |
|
137 |
+
if ($this->_config->get_boolean('minify.debug')) {
|
138 |
+
$buffer .= "\r\n\r\n" . $this->get_debug_info();
|
139 |
+
}
|
140 |
+
|
141 |
return $buffer;
|
142 |
}
|
143 |
|
159 |
*/
|
160 |
function clean($content)
|
161 |
{
|
162 |
+
if (! is_feed()) {
|
163 |
+
if ($this->_config->get_boolean('minify.css.enable', true)) {
|
164 |
+
$content = $this->clean_styles($content);
|
165 |
+
}
|
166 |
+
|
167 |
+
if ($this->_config->get_boolean('minify.js.enable', true)) {
|
168 |
+
$content = $this->clean_scripts($content);
|
169 |
+
}
|
170 |
}
|
171 |
|
172 |
if ($this->_config->get_boolean('minify.html.enable', true) && ! ($this->_config->get_boolean('minify.html.reject.admin', true) && current_user_can('manage_options'))) {
|
189 |
$regexps = array();
|
190 |
|
191 |
$groups = $this->_config->get_array('minify.css.groups');
|
192 |
+
$siteurl = w3_get_domain_url();
|
193 |
+
|
194 |
+
foreach ($groups as $group => $locations) {
|
195 |
+
foreach ((array) $locations as $location => $config) {
|
196 |
+
if (! empty($config['files'])) {
|
197 |
+
foreach ((array) $config['files'] as $file) {
|
198 |
+
if (w3_is_url($file) && strstr($file, $siteurl) === false) {
|
199 |
+
$regexps[] = preg_quote($file);
|
200 |
+
} else {
|
201 |
+
$file = ltrim(str_replace($siteurl, '', $file), '/');
|
202 |
+
$regexps[] = '(' . preg_quote($siteurl) . ')?/?' . preg_quote($file);
|
203 |
+
}
|
204 |
}
|
205 |
}
|
206 |
}
|
225 |
$regexps = array();
|
226 |
|
227 |
$groups = $this->_config->get_array('minify.js.groups');
|
228 |
+
$siteurl = w3_get_domain_url();
|
229 |
+
|
230 |
+
foreach ($groups as $group => $locations) {
|
231 |
+
foreach ((array) $locations as $location => $config) {
|
232 |
+
if (! empty($config['files'])) {
|
233 |
+
foreach ((array) $config['files'] as $file) {
|
234 |
+
if (w3_is_url($file) && strstr($file, $siteurl) === false) {
|
235 |
+
$regexps[] = preg_quote($file);
|
236 |
+
} else {
|
237 |
+
$file = ltrim(str_replace($siteurl, '', $file), '/');
|
238 |
+
$regexps[] = '(' . preg_quote($siteurl) . ')?/?' . preg_quote($file);
|
239 |
+
}
|
240 |
}
|
241 |
}
|
242 |
}
|
243 |
}
|
244 |
|
245 |
foreach ($regexps as $regexp) {
|
246 |
+
$content = preg_replace('~<script\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\s*</script>~is', '', $content);
|
247 |
}
|
248 |
|
249 |
return $content;
|
267 |
'xhtml' => true
|
268 |
);
|
269 |
|
270 |
+
if ($this->_config->get_boolean('minify.html.inline.css', false)) {
|
271 |
$options['cssMinifier'] = array(
|
272 |
'Minify_CSS',
|
273 |
'minify'
|
274 |
);
|
275 |
}
|
276 |
|
277 |
+
if ($this->_config->get_boolean('minify.html.inline.js', false)) {
|
278 |
$options['jsMinifier'] = array(
|
279 |
'JSMin',
|
280 |
'minify'
|
296 |
return $content;
|
297 |
}
|
298 |
|
299 |
+
/**
|
300 |
+
* Returns current group
|
301 |
+
* @return string
|
302 |
+
*/
|
303 |
+
function get_group()
|
304 |
+
{
|
305 |
+
static $group = null;
|
306 |
+
|
307 |
+
if ($group === null) {
|
308 |
+
switch (true) {
|
309 |
+
case is_date():
|
310 |
+
$group = 'date';
|
311 |
+
break;
|
312 |
+
|
313 |
+
case is_category():
|
314 |
+
$group = 'category';
|
315 |
+
break;
|
316 |
+
|
317 |
+
case is_tag():
|
318 |
+
$group = 'tag';
|
319 |
+
break;
|
320 |
+
|
321 |
+
case is_author():
|
322 |
+
$group = 'author';
|
323 |
+
break;
|
324 |
+
|
325 |
+
case is_home():
|
326 |
+
$group = 'home';
|
327 |
+
break;
|
328 |
+
|
329 |
+
case is_page():
|
330 |
+
$group = 'page';
|
331 |
+
break;
|
332 |
+
|
333 |
+
case is_search():
|
334 |
+
$group = 'search';
|
335 |
+
break;
|
336 |
+
|
337 |
+
case is_404():
|
338 |
+
$group = '404';
|
339 |
+
break;
|
340 |
+
|
341 |
+
case is_attachment():
|
342 |
+
$group = 'attachment';
|
343 |
+
break;
|
344 |
+
|
345 |
+
case is_archive():
|
346 |
+
$group = 'archive';
|
347 |
+
break;
|
348 |
+
|
349 |
+
case is_single():
|
350 |
+
$group = 'single';
|
351 |
+
break;
|
352 |
+
|
353 |
+
default:
|
354 |
+
$group = 'default';
|
355 |
+
break;
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
return $group;
|
360 |
+
}
|
361 |
+
|
362 |
/**
|
363 |
* Returns style link
|
364 |
*
|
365 |
* @param string $url
|
366 |
* @param string $import
|
367 |
*/
|
368 |
+
function get_style($url, $import = false)
|
369 |
{
|
370 |
if ($import) {
|
371 |
return "<style type=\"text/css\" media=\"all\">@import url(\"" . $url . "\");</style>\r\n";
|
391 |
|
392 |
if (! $non_blocking_function) {
|
393 |
$non_blocking_function = true;
|
394 |
+
$script = "<script type=\"text/javascript\">/*<![CDATA[*/function w3tc_load_js(u){var d=document;var p=d.getElementsByTagName('HEAD')[0];var c=d.createElement('script');c.type='text/javascript';c.src=u;p.appendChild(c);}/*]]>*/</script>";
|
395 |
}
|
396 |
|
397 |
+
$script .= "<script type=\"text/javascript\">/*<![CDATA[*/w3tc_load_js('" . $url . "');/*]]>*/</script>";
|
398 |
|
399 |
return $script;
|
400 |
}
|
402 |
|
403 |
/**
|
404 |
* returns style link for styles group
|
405 |
+
* @param string $location
|
406 |
* @param string $group
|
407 |
*/
|
408 |
+
function get_styles($location, $group = null)
|
409 |
{
|
410 |
$styles = '';
|
411 |
$groups = $this->_config->get_array('minify.css.groups');
|
412 |
|
413 |
+
if (empty($group)) {
|
414 |
+
$group = $this->get_group();
|
415 |
+
}
|
416 |
+
|
417 |
+
if ($group != 'default' && empty($groups[$group][$location]['files'])) {
|
418 |
+
$group = 'default';
|
419 |
+
}
|
420 |
+
|
421 |
+
if (! empty($groups[$group][$location]['files'])) {
|
422 |
+
$styles .= $this->get_style($this->format_url($group, $location, 'css'), isset($groups[$group][$location]['import']) ? (boolean) $groups[$group][$location]['import'] : false);
|
423 |
}
|
424 |
|
425 |
return $styles;
|
427 |
|
428 |
/**
|
429 |
* Returns script linkg for scripts group
|
430 |
+
* @param string $location
|
431 |
* @param string $group
|
432 |
*/
|
433 |
+
function get_scripts($location, $group = null)
|
434 |
{
|
435 |
$scripts = '';
|
436 |
$groups = $this->_config->get_array('minify.js.groups');
|
437 |
|
438 |
+
if (empty($group)) {
|
439 |
+
$group = $this->get_group();
|
440 |
+
}
|
441 |
+
|
442 |
+
if ($group != 'default' && empty($groups[$group][$location]['files'])) {
|
443 |
+
$group = 'default';
|
444 |
+
}
|
445 |
+
|
446 |
+
if (! empty($groups[$group][$location]['files'])) {
|
447 |
+
$scripts .= $this->get_script($this->format_url($group, $location, 'js'), isset($groups[$group][$location]['blocking']) ? (boolean) $groups[$group][$location]['blocking'] : true);
|
448 |
}
|
449 |
|
450 |
return $scripts;
|
458 |
*/
|
459 |
function get_custom_script($files, $blocking = true)
|
460 |
{
|
461 |
+
return $this->get_script($this->format_custom_url($files), $blocking);
|
462 |
}
|
463 |
|
464 |
/**
|
469 |
*/
|
470 |
function get_custom_style($files, $import = false)
|
471 |
{
|
472 |
+
return $this->get_style($this->format_custom_url($files), $import);
|
473 |
}
|
474 |
|
475 |
/**
|
476 |
+
* Formats URL
|
477 |
*
|
|
|
478 |
* @param string $group
|
479 |
+
* @param string $location
|
480 |
+
* @param string $type
|
481 |
* @return string
|
482 |
*/
|
483 |
+
function format_url($group, $location, $type)
|
484 |
{
|
485 |
$siteurl = w3_get_site_url();
|
486 |
|
487 |
+
if ($this->_config->get_boolean('minify.rewrite', true)) {
|
488 |
+
return sprintf('%s/%s/%s.%s.%s', $siteurl, W3TC_CONTENT_DIR_NAME, $group, $location, $type);
|
489 |
}
|
490 |
|
491 |
+
return sprintf('%s/%s/minify.php?gg=%s&g=%s&t=%s', $siteurl, W3TC_CONTENT_DIR_NAME, $group, $location, $type);
|
492 |
}
|
493 |
|
494 |
/**
|
495 |
+
* Formats custom URL
|
496 |
*
|
497 |
* @param string|array $files
|
498 |
* @return string
|
499 |
*/
|
500 |
+
function format_custom_url($files)
|
501 |
{
|
502 |
if (! is_array($files)) {
|
503 |
$files = array(
|
518 |
}
|
519 |
|
520 |
$siteurl = w3_get_site_url();
|
521 |
+
$url = sprintf('%s/%s/minify.php?f=%s', $siteurl, W3TC_CONTENT_DIR_NAME, implode(',', $files));
|
522 |
|
523 |
if ($base) {
|
524 |
$url .= sprintf('&b=%s', $base);
|
526 |
|
527 |
return $url;
|
528 |
}
|
529 |
+
|
530 |
+
/**
|
531 |
+
* Returns array of minify URLs
|
532 |
+
* @return array
|
533 |
+
*/
|
534 |
+
function get_urls()
|
535 |
+
{
|
536 |
+
$files = array();
|
537 |
+
|
538 |
+
$js_groups = $this->_config->get_array('minify.js.groups');
|
539 |
+
$css_groups = $this->_config->get_array('minify.css.groups');
|
540 |
+
|
541 |
+
foreach ($js_groups as $js_group => $js_locations) {
|
542 |
+
foreach ((array) $js_locations as $js_location => $js_config) {
|
543 |
+
if (! empty($js_config['files'])) {
|
544 |
+
$files[] = $this->format_url($js_group, $js_location, 'js');
|
545 |
+
}
|
546 |
+
}
|
547 |
+
}
|
548 |
+
|
549 |
+
foreach ($css_groups as $css_group => $css_locations) {
|
550 |
+
foreach ((array) $css_locations as $css_location => $css_config) {
|
551 |
+
if (! empty($css_config['files'])) {
|
552 |
+
$files[] = $this->format_url($css_group, $css_location, 'css');
|
553 |
+
}
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
return $files;
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Returns debug info
|
562 |
+
*/
|
563 |
+
function get_debug_info()
|
564 |
+
{
|
565 |
+
$group = $this->get_group();
|
566 |
+
|
567 |
+
$debug_info = "<!-- W3 Total Cache: Minify debug info:\r\n";
|
568 |
+
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), w3_get_engine_name($this->_config->get_string('minify.engine')));
|
569 |
+
$debug_info .= sprintf("%s%s\r\n", str_pad('Group: ', 20), $group);
|
570 |
+
|
571 |
+
require_once W3TC_LIB_W3_DIR . '/Minify.php';
|
572 |
+
$w3_minify = W3_Minify::instance();
|
573 |
+
|
574 |
+
$css_groups = $w3_minify->get_groups($group, 'css');
|
575 |
+
|
576 |
+
if (count($css_groups)) {
|
577 |
+
$debug_info .= "Stylesheet info:\r\n";
|
578 |
+
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad('Location', 15, ' ', STR_PAD_BOTH), str_pad('Last modified', 19, ' ', STR_PAD_BOTH), str_pad('Size', 12, ' ', STR_PAD_LEFT), 'Path');
|
579 |
+
|
580 |
+
foreach ($css_groups as $css_group => $css_files) {
|
581 |
+
foreach ($css_files as $css_file => $css_file_path) {
|
582 |
+
if (w3_is_url($css_file)) {
|
583 |
+
$css_file_info = sprintf('%s (%s)', $css_file, $css_file_path);
|
584 |
+
} else {
|
585 |
+
$css_file_path = $css_file_info = ABSPATH . ltrim($css_file, '\\/');
|
586 |
+
}
|
587 |
+
|
588 |
+
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad($css_group, 15, ' ', STR_PAD_BOTH), str_pad(date('Y-m-d H:i:s', filemtime($css_file_path)), 19, ' ', STR_PAD_BOTH), str_pad(filesize($css_file_path), 12, ' ', STR_PAD_LEFT), $css_file_info);
|
589 |
+
}
|
590 |
+
}
|
591 |
+
}
|
592 |
+
|
593 |
+
$js_groups = $w3_minify->get_groups($group, 'js');
|
594 |
+
|
595 |
+
if (count($js_groups)) {
|
596 |
+
$debug_info .= "JavaScript info:\r\n";
|
597 |
+
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad('Location', 15, ' ', STR_PAD_BOTH), str_pad('Last modified', 19, ' ', STR_PAD_BOTH), str_pad('Size', 12, ' ', STR_PAD_LEFT), 'Path');
|
598 |
+
|
599 |
+
foreach ($js_groups as $js_group => $js_files) {
|
600 |
+
foreach ($js_files as $js_file => $js_file_path) {
|
601 |
+
if (w3_is_url($js_file)) {
|
602 |
+
$js_file_info = sprintf('%s (%s)', $js_file, $js_file_path);
|
603 |
+
} else {
|
604 |
+
$js_file_path = $js_file_info = ABSPATH . ltrim($js_file, '\\/');
|
605 |
+
}
|
606 |
+
|
607 |
+
$debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad($js_group, 15, ' ', STR_PAD_BOTH), str_pad(date('Y-m-d H:i:s', filemtime($js_file_path)), 19, ' ', STR_PAD_BOTH), str_pad(filesize($js_file_path), 12, ' ', STR_PAD_LEFT), $js_file_info);
|
608 |
+
}
|
609 |
+
}
|
610 |
+
}
|
611 |
+
|
612 |
+
$debug_info .= '-->';
|
613 |
+
|
614 |
+
return $debug_info;
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Check if we can do minify logic
|
619 |
+
* @return boolean
|
620 |
+
*/
|
621 |
+
function can_minify()
|
622 |
+
{
|
623 |
+
/**
|
624 |
+
* Skip if Minify is disabled
|
625 |
+
*/
|
626 |
+
if (! $this->_config->get_boolean('minify.enabled', true)) {
|
627 |
+
return false;
|
628 |
+
}
|
629 |
+
|
630 |
+
/**
|
631 |
+
* Skip if Admin
|
632 |
+
*/
|
633 |
+
if (defined('WP_ADMIN')) {
|
634 |
+
return false;
|
635 |
+
}
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Skip if doint AJAX
|
639 |
+
*/
|
640 |
+
if (defined('DOING_AJAX')) {
|
641 |
+
return false;
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* Skip if doing cron
|
646 |
+
*/
|
647 |
+
if (defined('DOING_CRON')) {
|
648 |
+
return false;
|
649 |
+
}
|
650 |
+
|
651 |
+
/**
|
652 |
+
* Skip if APP request
|
653 |
+
*/
|
654 |
+
if (defined('APP_REQUEST')) {
|
655 |
+
return false;
|
656 |
+
}
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Skip if XMLRPC request
|
660 |
+
*/
|
661 |
+
if (defined('XMLRPC_REQUEST')) {
|
662 |
+
return false;
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Check User agent
|
667 |
+
*/
|
668 |
+
if (! $this->check_ua()) {
|
669 |
+
return false;
|
670 |
+
}
|
671 |
+
|
672 |
+
/**
|
673 |
+
* Check request URI
|
674 |
+
*/
|
675 |
+
if (! $this->check_request_uri()) {
|
676 |
+
return false;
|
677 |
+
}
|
678 |
+
|
679 |
+
return true;
|
680 |
+
}
|
681 |
+
|
682 |
+
/**
|
683 |
+
* Checks User Agent
|
684 |
+
*
|
685 |
+
* @return boolean
|
686 |
+
*/
|
687 |
+
function check_ua()
|
688 |
+
{
|
689 |
+
foreach ($this->_config->get_array('minify.reject.ua') as $ua) {
|
690 |
+
if (stristr($_SERVER['HTTP_USER_AGENT'], $ua) !== false) {
|
691 |
+
return false;
|
692 |
+
}
|
693 |
+
}
|
694 |
+
|
695 |
+
return true;
|
696 |
+
}
|
697 |
+
|
698 |
+
/**
|
699 |
+
* Checks request URI
|
700 |
+
*
|
701 |
+
* @return boolean
|
702 |
+
*/
|
703 |
+
function check_request_uri()
|
704 |
+
{
|
705 |
+
$auto_reject_uri = array(
|
706 |
+
'wp-login',
|
707 |
+
'wp-register'
|
708 |
+
);
|
709 |
+
|
710 |
+
foreach ($auto_reject_uri as $uri) {
|
711 |
+
if (strstr($_SERVER['REQUEST_URI'], $uri) !== false) {
|
712 |
+
return false;
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
foreach ($this->_config->get_array('minify.reject.uri') as $expr) {
|
717 |
+
$expr = trim($expr);
|
718 |
+
if ($expr != '' && preg_match('@' . $expr . '@i', $_SERVER['REQUEST_URI'])) {
|
719 |
+
return false;
|
720 |
+
}
|
721 |
+
}
|
722 |
+
|
723 |
+
return true;
|
724 |
+
}
|
725 |
}
|
726 |
|
727 |
/**
|
728 |
* Prints script link for scripts group
|
729 |
+
* @param string $location
|
730 |
* @param string $group
|
731 |
*/
|
732 |
+
function w3tc_scripts($location, $group = null)
|
733 |
{
|
734 |
$w3_plugin_minify = W3_Plugin_Minify::instance();
|
735 |
+
echo $w3_plugin_minify->get_scripts($location, $group);
|
736 |
}
|
737 |
|
738 |
/**
|
739 |
* Prints style link for styles group
|
740 |
+
* @param string $location
|
741 |
* @param string $group
|
742 |
*/
|
743 |
+
function w3tc_styles($location, $group = null)
|
744 |
{
|
745 |
$w3_plugin_minify = W3_Plugin_Minify::instance();
|
746 |
+
echo $w3_plugin_minify->get_styles($location, $group);
|
747 |
}
|
748 |
|
749 |
/**
|
lib/W3/Plugin/PgCache.php
CHANGED
@@ -25,7 +25,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
25 |
'deactivate'
|
26 |
));
|
27 |
|
28 |
-
if ($this->_config->get_boolean('pgcache.enabled')) {
|
29 |
add_action('publish_phone', array(
|
30 |
&$this,
|
31 |
'on_post_edit'
|
@@ -115,7 +115,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
115 |
}
|
116 |
|
117 |
if (! $this->locked()) {
|
118 |
-
if (@copy(
|
119 |
@chmod(WP_CONTENT_DIR . '/advanced-cache.php', 0644);
|
120 |
} else {
|
121 |
w3_writable_error(WP_CONTENT_DIR . '/advanced-cache.php');
|
@@ -188,6 +188,8 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
188 |
static $flushed_posts = array();
|
189 |
|
190 |
if (! in_array($post_id, $flushed_posts)) {
|
|
|
|
|
191 |
$w3_pgcache = W3_PgCache::instance();
|
192 |
$w3_pgcache->flush_post($post_id);
|
193 |
|
@@ -220,7 +222,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
220 |
*/
|
221 |
function on_comment_status($comment_id, $status)
|
222 |
{
|
223 |
-
if (
|
224 |
$this->on_comment_change($comment_id);
|
225 |
}
|
226 |
}
|
@@ -233,6 +235,8 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
233 |
static $flushed = false;
|
234 |
|
235 |
if (! $flushed) {
|
|
|
|
|
236 |
$w3_pgcache = W3_PgCache::instance();
|
237 |
$w3_pgcache->flush();
|
238 |
}
|
25 |
'deactivate'
|
26 |
));
|
27 |
|
28 |
+
if ($this->_config->get_boolean('pgcache.enabled', true)) {
|
29 |
add_action('publish_phone', array(
|
30 |
&$this,
|
31 |
'on_post_edit'
|
115 |
}
|
116 |
|
117 |
if (! $this->locked()) {
|
118 |
+
if (@copy(W3TC_INSTALL_DIR . '/advanced-cache.php', WP_CONTENT_DIR . '/advanced-cache.php')) {
|
119 |
@chmod(WP_CONTENT_DIR . '/advanced-cache.php', 0644);
|
120 |
} else {
|
121 |
w3_writable_error(WP_CONTENT_DIR . '/advanced-cache.php');
|
188 |
static $flushed_posts = array();
|
189 |
|
190 |
if (! in_array($post_id, $flushed_posts)) {
|
191 |
+
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
|
192 |
+
|
193 |
$w3_pgcache = W3_PgCache::instance();
|
194 |
$w3_pgcache->flush_post($post_id);
|
195 |
|
222 |
*/
|
223 |
function on_comment_status($comment_id, $status)
|
224 |
{
|
225 |
+
if ($status === 'approve' || $status === '1') {
|
226 |
$this->on_comment_change($comment_id);
|
227 |
}
|
228 |
}
|
235 |
static $flushed = false;
|
236 |
|
237 |
if (! $flushed) {
|
238 |
+
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
|
239 |
+
|
240 |
$w3_pgcache = W3_PgCache::instance();
|
241 |
$w3_pgcache->flush();
|
242 |
}
|
lib/W3/Plugin/TotalCache.php
CHANGED
@@ -52,6 +52,13 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
52 |
'admin_notices'
|
53 |
));
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
if ($this->_config->get_boolean('common.support.enabled', true) && $this->_config->get_string('common.support.type', 'footer') == 'footer') {
|
56 |
add_action('wp_footer', array(
|
57 |
&$this,
|
@@ -59,14 +66,14 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
59 |
));
|
60 |
}
|
61 |
|
62 |
-
@header('X-Powered-By: ' . W3TC_POWERED_BY);
|
63 |
-
|
64 |
if (is_admin()) {
|
65 |
add_action('init', array(
|
66 |
&$this,
|
67 |
'init'
|
68 |
));
|
69 |
-
}
|
|
|
|
|
70 |
ob_start(array(
|
71 |
&$this,
|
72 |
'ob_callback'
|
@@ -124,6 +131,40 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
124 |
*/
|
125 |
function activate()
|
126 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
if (! file_exists(W3TC_CONFIG_PATH)) {
|
128 |
if (@copy(W3TC_CONFIG_DEFAULT_PATH, W3TC_CONFIG_PATH)) {
|
129 |
@chmod(W3TC_CONFIG_PATH, 0644);
|
@@ -131,6 +172,8 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
131 |
w3_writable_error(W3TC_CONFIG_PATH);
|
132 |
}
|
133 |
}
|
|
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -138,7 +181,16 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
138 |
*/
|
139 |
function deactivate()
|
140 |
{
|
|
|
|
|
141 |
@unlink(W3TC_CONFIG_PATH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
/**
|
@@ -152,7 +204,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
152 |
/**
|
153 |
* Run plugin action
|
154 |
*/
|
155 |
-
if (isset($_REQUEST['w3tc_action']) &&
|
156 |
$action = trim($_REQUEST['w3tc_action']);
|
157 |
|
158 |
if (method_exists($this, $action)) {
|
@@ -206,31 +258,34 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
206 |
*/
|
207 |
function admin_notices()
|
208 |
{
|
209 |
-
$notices = array(
|
210 |
-
1 => 'All caches emptied successfully.',
|
211 |
-
2 => 'Memcached cache emptied successfully.',
|
212 |
-
3 => 'APC cache emptied successfully.',
|
213 |
-
4 => 'Disk cache emptied successfully.',
|
214 |
-
5 => 'Plugin configuration updated successfully.'
|
215 |
-
);
|
216 |
-
|
217 |
-
$errors = array(
|
218 |
-
1 => 'Unable to save plugin configuration: config file is not writeable.'
|
219 |
-
);
|
220 |
-
|
221 |
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
222 |
-
$
|
223 |
-
$
|
224 |
|
225 |
-
if (! empty($
|
226 |
-
echo sprintf('<div id="message" class="updated fade"><p>%s</p></div>', $
|
227 |
}
|
228 |
|
229 |
-
if (! empty($
|
230 |
-
echo sprintf('<div id="message" class="error"><p>%s</p></div>', $
|
231 |
}
|
232 |
}
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
/**
|
235 |
* Footer plugin action
|
236 |
*/
|
@@ -289,72 +344,48 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
289 |
* Minify tab
|
290 |
*/
|
291 |
if ($tab == 'minify') {
|
292 |
-
$
|
293 |
-
$
|
294 |
-
$js_files_header_nb = W3_Request::get_array('js_files_include-nb');
|
295 |
-
$js_files_footer = W3_Request::get_array('js_files_include-footer');
|
296 |
-
$js_files_footer_nb = W3_Request::get_array('js_files_include-footer-nb');
|
297 |
-
|
298 |
-
$css_header_files = array();
|
299 |
-
$js_header_files = array();
|
300 |
-
$js_header_nb_files = array();
|
301 |
-
$js_footer_files = array();
|
302 |
-
$js_footer_nb_files = array();
|
303 |
-
|
304 |
-
foreach ($css_files_header as $css_header_file) {
|
305 |
-
if (! empty($css_header_file)) {
|
306 |
-
$css_header_files[] = $css_header_file;
|
307 |
-
}
|
308 |
-
}
|
309 |
|
310 |
-
|
311 |
-
|
312 |
-
$js_header_files[] = $js_header_file;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
|
316 |
-
foreach ($js_files_header_nb as $js_header_nb_file) {
|
317 |
-
if (! empty($js_header_nb_file)) {
|
318 |
-
$js_header_nb_files[] = $js_header_nb_file;
|
319 |
-
}
|
320 |
-
}
|
321 |
|
322 |
-
foreach ($
|
323 |
-
|
324 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
}
|
326 |
}
|
327 |
|
328 |
-
foreach ($
|
329 |
-
|
330 |
-
$
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
}
|
333 |
|
334 |
-
$config->set('minify.
|
335 |
-
|
336 |
-
'files' => $css_header_files
|
337 |
-
)
|
338 |
-
));
|
339 |
-
|
340 |
-
$config->set('minify.js.groups', array(
|
341 |
-
'include' => array(
|
342 |
-
'blocking' => true,
|
343 |
-
'files' => $js_header_files
|
344 |
-
),
|
345 |
-
'include-nb' => array(
|
346 |
-
'blocking' => false,
|
347 |
-
'files' => $js_header_nb_files
|
348 |
-
),
|
349 |
-
'include-footer' => array(
|
350 |
-
'blocking' => true,
|
351 |
-
'files' => $js_footer_files
|
352 |
-
),
|
353 |
-
'include-footer-nb' => array(
|
354 |
-
'blocking' => false,
|
355 |
-
'files' => $js_footer_nb_files
|
356 |
-
)
|
357 |
-
));
|
358 |
}
|
359 |
|
360 |
/**
|
@@ -367,13 +398,21 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
367 |
$this->link_insert($link_category_id);
|
368 |
}
|
369 |
|
370 |
-
if ($tab == 'minify' && $config->get_boolean('minify.upload') && $config->get_boolean('cdn.enabled')) {
|
371 |
$this->cdn_upload_minify();
|
372 |
}
|
373 |
|
374 |
-
|
|
|
|
|
|
|
|
|
375 |
} else {
|
376 |
-
|
|
|
|
|
|
|
|
|
377 |
}
|
378 |
}
|
379 |
|
@@ -394,23 +433,27 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
394 |
|
395 |
$can_empty_memcache = ($pgcache_memcached || $dbcache_memcached || $minify_memcached);
|
396 |
$can_empty_apc = ($config->get_string('dbcache.engine') == 'apc' || $config->get_string('pgcache.engine') == 'apc' || $config->get_string('minify.engine') == 'apc');
|
397 |
-
$
|
398 |
|
399 |
/**
|
400 |
* Flush all caches
|
401 |
*/
|
402 |
if (isset($_REQUEST['flush_all'])) {
|
403 |
if ($can_empty_memcache) {
|
404 |
-
$this->
|
405 |
}
|
406 |
if ($can_empty_apc) {
|
407 |
-
$this->
|
408 |
}
|
409 |
-
if ($
|
410 |
-
$this->
|
411 |
}
|
412 |
|
413 |
-
|
|
|
|
|
|
|
|
|
414 |
}
|
415 |
|
416 |
/**
|
@@ -418,65 +461,83 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
418 |
*/
|
419 |
if (isset($_REQUEST['flush_memcached'])) {
|
420 |
if ($can_empty_memcache) {
|
421 |
-
$this->
|
422 |
}
|
423 |
|
424 |
-
|
|
|
|
|
|
|
|
|
425 |
}
|
426 |
|
427 |
/**
|
428 |
-
* Flush
|
429 |
*/
|
430 |
-
if (isset($_REQUEST['
|
431 |
-
if ($
|
432 |
-
$this->
|
433 |
}
|
434 |
|
435 |
-
|
|
|
|
|
|
|
|
|
436 |
}
|
437 |
|
438 |
/**
|
439 |
-
*
|
440 |
*/
|
441 |
-
if (isset($_REQUEST['
|
442 |
-
if ($
|
443 |
-
$this->
|
444 |
}
|
445 |
|
446 |
-
|
|
|
|
|
|
|
|
|
447 |
}
|
448 |
|
449 |
/**
|
450 |
-
* Flush
|
451 |
*/
|
452 |
-
if (isset($_REQUEST['
|
453 |
-
|
454 |
-
$this->flush_memcached('minify');
|
455 |
-
}
|
456 |
|
457 |
-
|
|
|
|
|
|
|
|
|
458 |
}
|
459 |
|
460 |
/**
|
461 |
-
* Flush
|
462 |
*/
|
463 |
-
if (isset($_REQUEST['
|
464 |
-
|
465 |
-
$this->flush('apc');
|
466 |
-
}
|
467 |
|
468 |
-
|
|
|
|
|
|
|
|
|
469 |
}
|
470 |
|
471 |
/**
|
472 |
-
*
|
473 |
*/
|
474 |
-
if (isset($_REQUEST['
|
475 |
-
|
476 |
-
$this->flush('file');
|
477 |
-
}
|
478 |
|
479 |
-
|
|
|
|
|
|
|
|
|
480 |
}
|
481 |
|
482 |
/**
|
@@ -486,7 +547,10 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
486 |
$setting = sprintf('notes.%s', W3_Request::get_string('hide_note'));
|
487 |
$config->set($setting, false);
|
488 |
$config->save();
|
489 |
-
|
|
|
|
|
|
|
490 |
}
|
491 |
|
492 |
/**
|
@@ -721,6 +785,60 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
721 |
echo ']}';
|
722 |
}
|
723 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
724 |
/**
|
725 |
* CDN export action
|
726 |
*/
|
@@ -961,50 +1079,73 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
961 |
function flush($type)
|
962 |
{
|
963 |
if ($this->_config->get_string('pgcache.engine') == $type) {
|
964 |
-
|
965 |
-
$w3_pgcache = W3_PgCache::instance();
|
966 |
-
$w3_pgcache->flush();
|
967 |
}
|
968 |
|
969 |
if ($this->_config->get_string('dbcache.engine') == $type) {
|
970 |
-
|
971 |
-
$w3_db = W3_Db::instance();
|
972 |
-
$w3_db->flush_cache();
|
973 |
}
|
974 |
|
975 |
if ($this->_config->get_string('minify.engine') == $type) {
|
976 |
-
|
977 |
-
$w3_minify = W3_Minify::instance();
|
978 |
-
$w3_minify->flush();
|
979 |
}
|
980 |
}
|
981 |
|
982 |
/**
|
983 |
* Flush memcached cache
|
984 |
-
*
|
985 |
-
* @param string $type
|
986 |
*/
|
987 |
-
function flush_memcached(
|
988 |
{
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
}
|
1009 |
|
1010 |
/**
|
@@ -1081,15 +1222,15 @@ DATA;
|
|
1081 |
$buffer .= "\r\n\r\n";
|
1082 |
|
1083 |
if ($this->_config->get_boolean('minify.enabled', true)) {
|
1084 |
-
$buffer .= sprintf("Minified using %s\r\n", $this->_config->get_string('minify.engine'
|
1085 |
}
|
1086 |
|
1087 |
if ($this->_config->get_boolean('pgcache.enabled', true)) {
|
1088 |
-
$buffer .= sprintf("Page Caching using %s\r\n", $this->_config->get_string('pgcache.engine'
|
1089 |
}
|
1090 |
|
1091 |
if ($this->_config->get_boolean('dbcache.enabled', true) && is_a($wpdb, 'W3_Db')) {
|
1092 |
-
$buffer .= sprintf("Database Caching %d/%d queries in %.3f seconds using %s\r\n", $wpdb->query_hits, $wpdb->query_total, $wpdb->time_total, $this->_config->get_string('dbcache.engine'
|
1093 |
}
|
1094 |
|
1095 |
if ($this->_config->get_boolean('cdn.enabled', true)) {
|
@@ -1103,13 +1244,78 @@ DATA;
|
|
1103 |
$buffer .= "\r\n\r\n" . $wpdb->get_debug_info();
|
1104 |
}
|
1105 |
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1111 |
}
|
1112 |
|
1113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1114 |
}
|
1115 |
}
|
52 |
'admin_notices'
|
53 |
));
|
54 |
|
55 |
+
if ($this->_config->get_boolean('pgcache.enabled', true) && $this->_config->get_string('pgcache.engine', 'memcached') == 'file') {
|
56 |
+
add_action('w3_cache_file_cleanup', array(
|
57 |
+
&$this,
|
58 |
+
'cache_file_cleanup'
|
59 |
+
));
|
60 |
+
}
|
61 |
+
|
62 |
if ($this->_config->get_boolean('common.support.enabled', true) && $this->_config->get_string('common.support.type', 'footer') == 'footer') {
|
63 |
add_action('wp_footer', array(
|
64 |
&$this,
|
66 |
));
|
67 |
}
|
68 |
|
|
|
|
|
69 |
if (is_admin()) {
|
70 |
add_action('init', array(
|
71 |
&$this,
|
72 |
'init'
|
73 |
));
|
74 |
+
}
|
75 |
+
|
76 |
+
if ($this->can_modify_contents()) {
|
77 |
ob_start(array(
|
78 |
&$this,
|
79 |
'ob_callback'
|
131 |
*/
|
132 |
function activate()
|
133 |
{
|
134 |
+
if (! $this->locked()) {
|
135 |
+
if (! is_dir(W3TC_CONTENT_DIR)) {
|
136 |
+
if (@mkdir(W3TC_CONTENT_DIR, 0755)) {
|
137 |
+
@chmod(W3TC_CONTENT_DIR, 0755);
|
138 |
+
} else {
|
139 |
+
w3_writable_error(W3TC_CONTENT_DIR);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if (! is_dir(W3TC_CACHE_FILE_DIR)) {
|
144 |
+
if (@mkdir(W3TC_CACHE_FILE_DIR, 0755)) {
|
145 |
+
@chmod(W3TC_CACHE_FILE_DIR, 0755);
|
146 |
+
} else {
|
147 |
+
w3_writable_error(W3TC_CACHE_FILE_DIR);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
if (! is_dir(W3TC_CACHE_MINIFY_DIR)) {
|
152 |
+
if (@mkdir(W3TC_CACHE_MINIFY_DIR, 0755)) {
|
153 |
+
@chmod(W3TC_CACHE_MINIFY_DIR, 0755);
|
154 |
+
} else {
|
155 |
+
w3_writable_error(W3TC_CACHE_MINIFY_DIR);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
if (! is_dir(W3TC_LOG_DIR)) {
|
160 |
+
if (@mkdir(W3TC_LOG_DIR, 0755)) {
|
161 |
+
@chmod(W3TC_LOG_DIR, 0755);
|
162 |
+
} else {
|
163 |
+
w3_writable_error(W3TC_LOG_DIR);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
if (! file_exists(W3TC_CONFIG_PATH)) {
|
169 |
if (@copy(W3TC_CONFIG_DEFAULT_PATH, W3TC_CONFIG_PATH)) {
|
170 |
@chmod(W3TC_CONFIG_PATH, 0644);
|
172 |
w3_writable_error(W3TC_CONFIG_PATH);
|
173 |
}
|
174 |
}
|
175 |
+
|
176 |
+
wp_schedule_event(time(), 'twicedaily', 'w3_cache_file_cleanup');
|
177 |
}
|
178 |
|
179 |
/**
|
181 |
*/
|
182 |
function deactivate()
|
183 |
{
|
184 |
+
wp_clear_scheduled_hook('w3_cache_file_cleanup');
|
185 |
+
|
186 |
@unlink(W3TC_CONFIG_PATH);
|
187 |
+
|
188 |
+
if (! $this->locked()) {
|
189 |
+
w3_rmdir(W3TC_LOG_DIR);
|
190 |
+
w3_rmdir(W3TC_CACHE_MINIFY_DIR);
|
191 |
+
w3_rmdir(W3TC_CACHE_FILE_DIR);
|
192 |
+
w3_rmdir(W3TC_CONTENT_DIR);
|
193 |
+
}
|
194 |
}
|
195 |
|
196 |
/**
|
204 |
/**
|
205 |
* Run plugin action
|
206 |
*/
|
207 |
+
if (isset($_REQUEST['w3tc_action']) && current_user_can('manage_options')) {
|
208 |
$action = trim($_REQUEST['w3tc_action']);
|
209 |
|
210 |
if (method_exists($this, $action)) {
|
258 |
*/
|
259 |
function admin_notices()
|
260 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
262 |
+
$notice = W3_Request::get_string('w3tc_notice');
|
263 |
+
$error = W3_Request::get_string('w3tc_error');
|
264 |
|
265 |
+
if (! empty($notice)) {
|
266 |
+
echo sprintf('<div id="message" class="updated fade"><p>%s</p></div>', $notice);
|
267 |
}
|
268 |
|
269 |
+
if (! empty($error)) {
|
270 |
+
echo sprintf('<div id="message" class="error"><p>%s</p></div>', $error);
|
271 |
}
|
272 |
}
|
273 |
|
274 |
+
/**
|
275 |
+
* Does disk cache cleanup
|
276 |
+
* @return void
|
277 |
+
*/
|
278 |
+
function cache_file_cleanup()
|
279 |
+
{
|
280 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/File/Manager.php';
|
281 |
+
|
282 |
+
$w3_cache_file_manager = & new W3_Cache_File_Manager(array(
|
283 |
+
'cache_dir' => W3TC_CACHE_FILE_DIR
|
284 |
+
));
|
285 |
+
|
286 |
+
$w3_cache_file_manager->clean();
|
287 |
+
}
|
288 |
+
|
289 |
/**
|
290 |
* Footer plugin action
|
291 |
*/
|
344 |
* Minify tab
|
345 |
*/
|
346 |
if ($tab == 'minify') {
|
347 |
+
$js_files = W3_Request::get_array('js_files');
|
348 |
+
$css_files = W3_Request::get_array('css_files');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
+
$js_groups = array();
|
351 |
+
$css_groups = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
|
353 |
+
foreach ($js_files as $group => $locations) {
|
354 |
+
foreach ((array) $locations as $location => $files) {
|
355 |
+
switch ($location) {
|
356 |
+
case 'include':
|
357 |
+
$js_groups[$group][$location]['blocking'] = true;
|
358 |
+
break;
|
359 |
+
case 'include-nb':
|
360 |
+
$js_groups[$group][$location]['blocking'] = false;
|
361 |
+
break;
|
362 |
+
case 'include-footer':
|
363 |
+
$js_groups[$group][$location]['blocking'] = true;
|
364 |
+
break;
|
365 |
+
case 'include-footer-nb':
|
366 |
+
$js_groups[$group][$location]['blocking'] = false;
|
367 |
+
break;
|
368 |
+
}
|
369 |
+
foreach ((array) $files as $file) {
|
370 |
+
if (! empty($file)) {
|
371 |
+
$js_groups[$group][$location]['files'][] = $file;
|
372 |
+
}
|
373 |
+
}
|
374 |
}
|
375 |
}
|
376 |
|
377 |
+
foreach ($css_files as $group => $locations) {
|
378 |
+
foreach ((array) $locations as $location => $files) {
|
379 |
+
foreach ((array) $files as $file) {
|
380 |
+
if (! empty($file)) {
|
381 |
+
$css_groups[$group][$location]['files'][] = $file;
|
382 |
+
}
|
383 |
+
}
|
384 |
}
|
385 |
}
|
386 |
|
387 |
+
$config->set('minify.js.groups', $js_groups);
|
388 |
+
$config->set('minify.css.groups', $css_groups);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
}
|
390 |
|
391 |
/**
|
398 |
$this->link_insert($link_category_id);
|
399 |
}
|
400 |
|
401 |
+
if ($tab == 'minify' && $config->get_boolean('minify.upload') && $config->get_boolean('cdn.enabled') && $config->get_string('cdn.engine') != 'mirror') {
|
402 |
$this->cdn_upload_minify();
|
403 |
}
|
404 |
|
405 |
+
if (headers_sent()) {
|
406 |
+
$notes[] = 'Plugin configuration updated successfully.';
|
407 |
+
} else {
|
408 |
+
w3_redirect('', 'w3tc_notice=Plugin configuration updated successfully.');
|
409 |
+
}
|
410 |
} else {
|
411 |
+
if (headers_sent()) {
|
412 |
+
$errors[] = 'Unable to save plugin configuration: config file is not writeable.';
|
413 |
+
} else {
|
414 |
+
w3_redirect('', 'w3tc_error=Unable to save plugin configuration: config file is not writeable.');
|
415 |
+
}
|
416 |
}
|
417 |
}
|
418 |
|
433 |
|
434 |
$can_empty_memcache = ($pgcache_memcached || $dbcache_memcached || $minify_memcached);
|
435 |
$can_empty_apc = ($config->get_string('dbcache.engine') == 'apc' || $config->get_string('pgcache.engine') == 'apc' || $config->get_string('minify.engine') == 'apc');
|
436 |
+
$can_empty_file = ($config->get_string('pgcache.engine') == 'file' || $config->get_string('minify.engine') == 'file');
|
437 |
|
438 |
/**
|
439 |
* Flush all caches
|
440 |
*/
|
441 |
if (isset($_REQUEST['flush_all'])) {
|
442 |
if ($can_empty_memcache) {
|
443 |
+
$this->flush_memcached();
|
444 |
}
|
445 |
if ($can_empty_apc) {
|
446 |
+
$this->flush_apc();
|
447 |
}
|
448 |
+
if ($can_empty_file) {
|
449 |
+
$this->flush_file();
|
450 |
}
|
451 |
|
452 |
+
if (headers_sent()) {
|
453 |
+
$notes[] = 'All caches emptied successfully.';
|
454 |
+
} else {
|
455 |
+
w3_redirect('', 'w3tc_notice=All caches emptied successfully.');
|
456 |
+
}
|
457 |
}
|
458 |
|
459 |
/**
|
461 |
*/
|
462 |
if (isset($_REQUEST['flush_memcached'])) {
|
463 |
if ($can_empty_memcache) {
|
464 |
+
$this->flush_memcached();
|
465 |
}
|
466 |
|
467 |
+
if (headers_sent()) {
|
468 |
+
$notes[] = 'Memcached cache emptied successfully.';
|
469 |
+
} else {
|
470 |
+
w3_redirect('', 'w3tc_notice=Memcached cache emptied successfully.');
|
471 |
+
}
|
472 |
}
|
473 |
|
474 |
/**
|
475 |
+
* Flush APC cache
|
476 |
*/
|
477 |
+
if (isset($_REQUEST['flush_apc'])) {
|
478 |
+
if ($can_empty_apc) {
|
479 |
+
$this->flush_apc();
|
480 |
}
|
481 |
|
482 |
+
if (headers_sent()) {
|
483 |
+
$notes[] = 'APC cache emptied successfully.';
|
484 |
+
} else {
|
485 |
+
w3_redirect('', 'w3tc_notice=APC cache emptied successfully.');
|
486 |
+
}
|
487 |
}
|
488 |
|
489 |
/**
|
490 |
+
* Flish disk cache
|
491 |
*/
|
492 |
+
if (isset($_REQUEST['flush_file'])) {
|
493 |
+
if ($can_empty_file) {
|
494 |
+
$this->flush_file();
|
495 |
}
|
496 |
|
497 |
+
if (headers_sent()) {
|
498 |
+
$notes[] = 'Disk cache emptied successfully.';
|
499 |
+
} else {
|
500 |
+
w3_redirect('', 'w3tc_notice=Disk cache emptied successfully.');
|
501 |
+
}
|
502 |
}
|
503 |
|
504 |
/**
|
505 |
+
* Flush page cache
|
506 |
*/
|
507 |
+
if (isset($_REQUEST['flush_pgcache'])) {
|
508 |
+
$this->flush_pgcache();
|
|
|
|
|
509 |
|
510 |
+
if (headers_sent()) {
|
511 |
+
$notes[] = 'Page cache emptied successfully.';
|
512 |
+
} else {
|
513 |
+
w3_redirect('', 'w3tc_notice=Page cache emptied successfully.');
|
514 |
+
}
|
515 |
}
|
516 |
|
517 |
/**
|
518 |
+
* Flush db cache
|
519 |
*/
|
520 |
+
if (isset($_REQUEST['flush_dbcache'])) {
|
521 |
+
$this->flush_dbcache();
|
|
|
|
|
522 |
|
523 |
+
if (headers_sent()) {
|
524 |
+
$notes[] = 'Database cache emptied successfully.';
|
525 |
+
} else {
|
526 |
+
w3_redirect('', 'w3tc_notice=Database cache emptied successfully.');
|
527 |
+
}
|
528 |
}
|
529 |
|
530 |
/**
|
531 |
+
* Flush minify cache
|
532 |
*/
|
533 |
+
if (isset($_REQUEST['flush_minify'])) {
|
534 |
+
$this->flush_minify();
|
|
|
|
|
535 |
|
536 |
+
if (headers_sent()) {
|
537 |
+
$notes[] = 'Minify cache emptied successfully.';
|
538 |
+
} else {
|
539 |
+
w3_redirect('', 'w3tc_notice=Minify cache emptied successfully.');
|
540 |
+
}
|
541 |
}
|
542 |
|
543 |
/**
|
547 |
$setting = sprintf('notes.%s', W3_Request::get_string('hide_note'));
|
548 |
$config->set($setting, false);
|
549 |
$config->save();
|
550 |
+
|
551 |
+
if (! headers_sent()) {
|
552 |
+
w3_redirect();
|
553 |
+
}
|
554 |
}
|
555 |
|
556 |
/**
|
785 |
echo ']}';
|
786 |
}
|
787 |
|
788 |
+
/**
|
789 |
+
* CDN rename domain action
|
790 |
+
*/
|
791 |
+
function cdn_rename_domain()
|
792 |
+
{
|
793 |
+
require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
|
794 |
+
|
795 |
+
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
796 |
+
|
797 |
+
$total = $w3_plugin_cdn->get_rename_posts_count();
|
798 |
+
|
799 |
+
$title = 'Domain rename tool';
|
800 |
+
|
801 |
+
include W3TC_DIR . '/inc/popup/common/header.phtml';
|
802 |
+
include W3TC_DIR . '/inc/popup/cdn_rename_domain.phtml';
|
803 |
+
include W3TC_DIR . '/inc/popup/common/footer.phtml';
|
804 |
+
}
|
805 |
+
|
806 |
+
/**
|
807 |
+
* CDN rename domain process
|
808 |
+
*/
|
809 |
+
function cdn_rename_domain_process()
|
810 |
+
{
|
811 |
+
set_time_limit(1000);
|
812 |
+
|
813 |
+
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
814 |
+
require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
|
815 |
+
|
816 |
+
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
817 |
+
|
818 |
+
$limit = W3_Request::get_integer('limit');
|
819 |
+
$offset = W3_Request::get_integer('offset');
|
820 |
+
$names = W3_Request::get_array('names');
|
821 |
+
|
822 |
+
$count = null;
|
823 |
+
$total = null;
|
824 |
+
$results = array();
|
825 |
+
|
826 |
+
@$w3_plugin_cdn->rename_domain($names, $limit, $offset, $count, $total, $results);
|
827 |
+
|
828 |
+
echo sprintf("{limit: %d, offset: %d, count: %d, total: %s, results: [\r\n", $limit, $offset, $count, $total);
|
829 |
+
|
830 |
+
$results_count = count($results);
|
831 |
+
foreach ($results as $index => $result) {
|
832 |
+
echo sprintf("\t{old: '%s', new: '%s', result: %d, error: '%s'}", addslashes($result['old']), addslashes($result['new']), addslashes($result['result']), addslashes($result['error']));
|
833 |
+
if ($index < $results_count - 1) {
|
834 |
+
echo ',';
|
835 |
+
}
|
836 |
+
echo "\r\n";
|
837 |
+
}
|
838 |
+
|
839 |
+
echo ']}';
|
840 |
+
}
|
841 |
+
|
842 |
/**
|
843 |
* CDN export action
|
844 |
*/
|
1079 |
function flush($type)
|
1080 |
{
|
1081 |
if ($this->_config->get_string('pgcache.engine') == $type) {
|
1082 |
+
$this->flush_pgcache();
|
|
|
|
|
1083 |
}
|
1084 |
|
1085 |
if ($this->_config->get_string('dbcache.engine') == $type) {
|
1086 |
+
$this->flush_dbcache();
|
|
|
|
|
1087 |
}
|
1088 |
|
1089 |
if ($this->_config->get_string('minify.engine') == $type) {
|
1090 |
+
$this->flush_minify();
|
|
|
|
|
1091 |
}
|
1092 |
}
|
1093 |
|
1094 |
/**
|
1095 |
* Flush memcached cache
|
1096 |
+
* @return void
|
|
|
1097 |
*/
|
1098 |
+
function flush_memcached()
|
1099 |
{
|
1100 |
+
$this->flush('memcached');
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
/**
|
1104 |
+
* Flush APC cache
|
1105 |
+
* @return void
|
1106 |
+
*/
|
1107 |
+
function flush_apc()
|
1108 |
+
{
|
1109 |
+
$this->flush('apc');
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
/**
|
1113 |
+
* Flush file cache
|
1114 |
+
* @return void
|
1115 |
+
*/
|
1116 |
+
function flush_file()
|
1117 |
+
{
|
1118 |
+
$this->flush('file');
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
/**
|
1122 |
+
* Flush page cache
|
1123 |
+
*/
|
1124 |
+
function flush_pgcache()
|
1125 |
+
{
|
1126 |
+
require_once W3TC_DIR . '/lib/W3/PgCache.php';
|
1127 |
+
$w3_pgcache = W3_PgCache::instance();
|
1128 |
+
$w3_pgcache->flush();
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
/**
|
1132 |
+
* Flush page cache
|
1133 |
+
*/
|
1134 |
+
function flush_dbcache()
|
1135 |
+
{
|
1136 |
+
require_once W3TC_DIR . '/lib/W3/Db.php';
|
1137 |
+
$w3_db = W3_Db::instance();
|
1138 |
+
$w3_db->flush_cache();
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
/**
|
1142 |
+
* Flush minify cache
|
1143 |
+
*/
|
1144 |
+
function flush_minify()
|
1145 |
+
{
|
1146 |
+
require_once W3TC_DIR . '/lib/W3/Minify.php';
|
1147 |
+
$w3_minify = W3_Minify::instance();
|
1148 |
+
$w3_minify->flush();
|
1149 |
}
|
1150 |
|
1151 |
/**
|
1222 |
$buffer .= "\r\n\r\n";
|
1223 |
|
1224 |
if ($this->_config->get_boolean('minify.enabled', true)) {
|
1225 |
+
$buffer .= sprintf("Minified using %s\r\n", w3_get_engine_name($this->_config->get_string('minify.engine')));
|
1226 |
}
|
1227 |
|
1228 |
if ($this->_config->get_boolean('pgcache.enabled', true)) {
|
1229 |
+
$buffer .= sprintf("Page Caching using %s\r\n", w3_get_engine_name($this->_config->get_string('pgcache.engine')));
|
1230 |
}
|
1231 |
|
1232 |
if ($this->_config->get_boolean('dbcache.enabled', true) && is_a($wpdb, 'W3_Db')) {
|
1233 |
+
$buffer .= sprintf("Database Caching %d/%d queries in %.3f seconds using %s\r\n", $wpdb->query_hits, $wpdb->query_total, $wpdb->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')));
|
1234 |
}
|
1235 |
|
1236 |
if ($this->_config->get_boolean('cdn.enabled', true)) {
|
1244 |
$buffer .= "\r\n\r\n" . $wpdb->get_debug_info();
|
1245 |
}
|
1246 |
|
1247 |
+
return $buffer;
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
/**
|
1251 |
+
* Check if we can do modify contents
|
1252 |
+
* @return boolean
|
1253 |
+
*/
|
1254 |
+
function can_modify_contents()
|
1255 |
+
{
|
1256 |
+
/**
|
1257 |
+
* Skip if admin
|
1258 |
+
*/
|
1259 |
+
if (defined('WP_ADMIN')) {
|
1260 |
+
return false;
|
1261 |
}
|
1262 |
|
1263 |
+
/**
|
1264 |
+
* Skip if doint AJAX
|
1265 |
+
*/
|
1266 |
+
if (defined('DOING_AJAX')) {
|
1267 |
+
return false;
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
/**
|
1271 |
+
* Skip if doing cron
|
1272 |
+
*/
|
1273 |
+
if (defined('DOING_CRON')) {
|
1274 |
+
return false;
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
/**
|
1278 |
+
* Skip if APP request
|
1279 |
+
*/
|
1280 |
+
if (defined('APP_REQUEST')) {
|
1281 |
+
return false;
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
* Skip if XMLRPC request
|
1286 |
+
*/
|
1287 |
+
if (defined('XMLRPC_REQUEST')) {
|
1288 |
+
return false;
|
1289 |
+
}
|
1290 |
+
|
1291 |
+
/**
|
1292 |
+
* Check request URI
|
1293 |
+
*/
|
1294 |
+
if (! $this->check_request_uri()) {
|
1295 |
+
return false;
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
return true;
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
/**
|
1302 |
+
* Checks request URI
|
1303 |
+
*
|
1304 |
+
* @return boolean
|
1305 |
+
*/
|
1306 |
+
function check_request_uri()
|
1307 |
+
{
|
1308 |
+
$reject_uri = array(
|
1309 |
+
'wp-login',
|
1310 |
+
'wp-register'
|
1311 |
+
);
|
1312 |
+
|
1313 |
+
foreach ($reject_uri as $uri) {
|
1314 |
+
if (strstr($_SERVER['REQUEST_URI'], $uri) !== false) {
|
1315 |
+
return false;
|
1316 |
+
}
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
return true;
|
1320 |
}
|
1321 |
}
|
lib/W3/Request.php
CHANGED
@@ -79,31 +79,7 @@ class W3_Request
|
|
79 |
*/
|
80 |
function get_boolean($key, $default = false)
|
81 |
{
|
82 |
-
|
83 |
-
|
84 |
-
if (is_string($value)) {
|
85 |
-
switch (strtolower($value)) {
|
86 |
-
case '+':
|
87 |
-
case '1':
|
88 |
-
case 'y':
|
89 |
-
case 'on':
|
90 |
-
case 'yes':
|
91 |
-
case 'true':
|
92 |
-
case 'enabled':
|
93 |
-
|
94 |
-
return true;
|
95 |
-
case '-':
|
96 |
-
case '0':
|
97 |
-
case 'n':
|
98 |
-
case 'no':
|
99 |
-
case 'off':
|
100 |
-
case 'false':
|
101 |
-
case 'disabled':
|
102 |
-
return false;
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
return $default;
|
107 |
}
|
108 |
|
109 |
/**
|
79 |
*/
|
80 |
function get_boolean($key, $default = false)
|
81 |
{
|
82 |
+
return w3_to_boolean(W3_Request::get($key, $default));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
readme.txt
CHANGED
@@ -1,52 +1,59 @@
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: fredericktownes
|
3 |
-
Tags: user experience, cache, caching, page cache, css cache, js cache, db cache, database cache, http compression, gzip, deflate, minify, CDN, content delivery network, media library, wp cache, wp super cache, w3 total cache, performance, speed
|
4 |
Requires at least: 2.5
|
5 |
Tested up to: 2.8.4
|
6 |
-
Stable tag: 0.
|
7 |
|
8 |
Dramatically improve the user experience of your blog. Add page caching, database caching, minify and content delivery network functionality and more to WordPress.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
W3 Total Cache improves the user experience of your blog by caching
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
* Transparent content delivery network (CDN) support with automated media library import
|
20 |
-
* Bandwidth savings via Minify and HTTP compression (gzip / deflate) for HTML, CSS and JS
|
21 |
-
* Minification (concatenation, white space removal) of inline, external or 3rd party JS and CSS with scheduled updates
|
22 |
-
* Caching of RSS/Atom feeds (comments, page and site), URIs with query string variables (like search result pages), database objects, pages, posts, CSS and JS in memory with APC or memcached or both
|
23 |
-
* Increased web server concurrency and reduced resource consumption, increased scale
|
24 |
-
* Reduced HTTP Transactions, DNS lookups, reduced document load time
|
25 |
-
* Complete header management including Etags
|
26 |
-
* Optional embedding of JS just above </body>
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
1. Disable and remove any other caching plugin you may be using — most plugins have uninstall procedures you can follow. Make sure wp-content/ has 777 permissions before proceeding, e.g.: `# chmod 777 /var/www/vhosts/domain.com/httpdocs/wp-content/`
|
33 |
-
1. Unzip and upload the plugin to your plugins directory (wp-content/plugins/), when done wp-content/plugins/w3-total-cache/ should exist.
|
34 |
-
1. Ensure that wp-config.php contains the statement below; if you previously used a caching plugin, this statement is likely to exist already: `define('WP_CACHE', true);`
|
35 |
-
1. Locate and activate the plugin on the plugins page, then click the Settings link to proceed to the General Settings tab. Set the permisions of wp-content back to 755, e.g.: `# chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/`
|
36 |
-
1. Select your caching preferences for page, database and minify. If memcached is used this will require you to confirm or modify the default settings and add any additional memcached servers you wish to use. To utilize APC and memcached + memcache installation guides have been provided under the Installation tab. For those in shared hosting environments, contact your provider to see if either of these are supported.
|
37 |
-
1. If you already have a content delivery network provider, proceed to the CDN Settings tab and populate the fields and set your preferences. If you're not running a version of WordPress with the Media Library feature, use the Media Library Import Tool to migrate your post images etc to appropriate locations. If you do not have a CDN provider, you can still improve your site's performance using this feature. Create and use a subdomain on your own server; e.g. static.domain.com and configure options on the CDN tab accordingly.
|
38 |
-
1. On the Minify Settings tab all of the recommended settings are preset. Specify any CSS and JS files in the respective sections, view your site's HTML source and search for .css and .js files. In the case of JS files you can specify the type and location of the embedding using the drop down menu.
|
39 |
-
1. You're done! Get back to blogging!
|
40 |
|
41 |
== Frequently Asked Questions ==
|
42 |
|
43 |
-
=
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
= Why is W3 Total Cache better than other cache plugins? =
|
48 |
|
49 |
-
Most of the popular cache plugins available do a great job and serve their purpose very well. Our plugin remedies numerous performance reducing aspects of any web site going far beyond merely reducing CPU usage and bandwidth consumption for HTML pages alone.
|
50 |
|
51 |
= I've never heard of any of this stuff; my blog is fine, no one complains about the speed. Why should I install this? =
|
52 |
|
@@ -85,6 +92,7 @@ On the contrary, as with any other action a user can perform on a site, faster p
|
|
85 |
That depends on how you use your blog and where most of your readers read your blog (regionally). Here's a short list:</p>
|
86 |
|
87 |
* [NetDNA](http://www.netdna.com/)
|
|
|
88 |
* [SimpleCDN](http://www.simplecdn.com/)
|
89 |
* [Amazon S3](http://aws.amazon.com/s3/)
|
90 |
* [Amazon Cloudfront](http://aws.amazon.com/cloudfront/)
|
@@ -105,6 +113,7 @@ Technically no, a CDN is a high performance cache that stores static assets (you
|
|
105 |
|
106 |
Yes, indirectly - if you have a lot of bloggers working with you, you will find that it feels like you have a server dedicated only to WP Admin once this plugin is enabled; the result, increased productivity.
|
107 |
|
|
|
108 |
= Which web servers do you support? =
|
109 |
|
110 |
We are aware of no incompatibilities with [apache](http://httpd.apache.org/) 1.3+, [IIS](http://www.iis.net/) 5+ or [litespeed](http://litespeedtech.com/products/webserver/overview/) 4.0.2+. If there's a web server you feel we should be actively testing (e.g. [lighttpd](http://www.lighttpd.net/)), we're [interested in hearing](mailto:wordpressexperts@w3-edge.com).
|
@@ -121,59 +130,90 @@ In general, due to the manner in which this plugin works the only issues with yo
|
|
121 |
|
122 |
Install the plugin to read the full FAQ.
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
== Changelog ==
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
= 0.7.5.2 =
|
127 |
-
*
|
128 |
-
* Provided memcache.ini directives updated to improve network throughput
|
129 |
-
* Addressed WordPress MU site-wide activation/deactivation issues
|
130 |
* Added empty (memcached) cache button to each tab
|
|
|
|
|
|
|
131 |
* Fixed bug with parsing memcached server strings
|
132 |
-
* Added warning dialog to minify tab about removal of query strings locally hosted object URIs
|
133 |
* Fixed bug with minify sometimes not creating files as it should
|
134 |
-
*
|
135 |
-
*
|
136 |
|
137 |
= 0.7.5.1 =
|
138 |
-
*
|
|
|
|
|
139 |
* Improved notification handling
|
|
|
|
|
140 |
* Fixed bug with database cache that caused comment counts to become out of date
|
141 |
-
* Added memcached test button for convenience
|
142 |
* Fixed minor issue with URI with CDN functionality enabled
|
143 |
* Removed unnecessary minify options
|
144 |
-
* Improved reliability of Media Library Export
|
145 |
* Minification error dialogs now disabled when JS or CSS minify settings disabled
|
146 |
* Normalized line endings with /n as per minify author's direction
|
147 |
-
*
|
148 |
-
* Improved compatibility with suPHP
|
149 |
-
* Added options to concatenate JS files only in header or footer (for use with obfuscated scripts)
|
150 |
|
151 |
= 0.7.5 =
|
|
|
152 |
* Fixed issue with auto-download/upgrade and additional error checking
|
|
|
153 |
* Improved handling of inline comments and JavaScript in HTML documents
|
154 |
-
*
|
155 |
-
* Memcached engine logic modified to better support clustering and multiple memcached instances
|
156 |
-
* Added handling for magic_quotes set to on
|
157 |
* Addressed privilege control issue
|
158 |
* Resolved warnings thrown in various versions of WordPress
|
159 |
-
*
|
160 |
-
* Improved handing of @import CSS embedding
|
161 |
* Eliminated false negatives in a number of gzip/deflate compression analysis tools
|
162 |
* Total plugin file size reduced
|
163 |
|
164 |
= 0.7 =
|
|
|
165 |
* WordPress MU support bug fixes
|
166 |
* Minor CDN uploader fixes
|
167 |
-
* Added minify support for URIs starting with /
|
168 |
* Minor error message improvements
|
169 |
|
170 |
= 0.6 =
|
|
|
171 |
* Improved error message notifications
|
|
|
172 |
* FAQ and installation instructions corrections/adjustments
|
173 |
-
* Added "Debug Mode" listing all settings and queries with statistics
|
174 |
-
* Resolved bug in minification of feeds
|
175 |
* Support for multiple wordpress installations added
|
176 |
-
*
|
177 |
|
178 |
= 0.5 =
|
179 |
* Initial release
|
1 |
=== Plugin Name ===
|
2 |
Contributors: fredericktownes
|
3 |
+
Tags: user experience, cache, caching, page cache, css cache, js cache, db cache, disk cache, disk caching, database cache, http compression, gzip, deflate, minify, CDN, content delivery network, media library, wp cache, wp super cache, w3 total cache, performance, speed, multiple hosts, CSS, merge, combine, unobtrusive javascript, compress, optimize, optimizer, JavaScript, JS, cascading style sheet, plugin, yslow
|
4 |
Requires at least: 2.5
|
5 |
Tested up to: 2.8.4
|
6 |
+
Stable tag: 0.8
|
7 |
|
8 |
Dramatically improve the user experience of your blog. Add page caching, database caching, minify and content delivery network functionality and more to WordPress.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
Trusted by many popular blogs like: mashable.com, pearsonified.com, webdesignerdepot.com, freelanceswitch.com, briansolis.com, css3.info, tutsplus.com, yoast.com, noupe.com and others — W3 Total Cache improves the user experience of your blog by improving your server performance, caching every aspect of your site, reducing the download time of your theme and providing transparent content delivery network (CDN) integration.
|
13 |
|
14 |
+
Benefits:
|
15 |
|
16 |
+
* At least 10x improvement in site performance (Grade A in YSlow, when fully configured)
|
17 |
+
* "Instant" second page views (browser caching after first page view)
|
18 |
+
* Reduced page load time: increased visitor time on site (visitors view more pages)
|
19 |
+
* Optimized progressive render (pages appear to load instantly)
|
20 |
+
* Improved web server performance (easily sustain high traffic spikes)
|
21 |
+
* Up to 80% Bandwidth savings via Minify and HTTP compression of HTML, CSS, JavaScript and RSS feeds
|
22 |
|
23 |
+
Features:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
* Compatible with shared hosting, virtual private servers and dedicated servers / clusters
|
26 |
+
* Transparent content delivery network (CDN) integration with Media Library, theme files and WordPress itself
|
27 |
+
* Caching of (minified and compressed) pages and posts in memory or on disk
|
28 |
+
* Caching of (minified and compressed) CSS and JavaScript in memory, on disk or on CDN
|
29 |
+
* Caching of RSS (comments, page and site) feeds in memory or on disk
|
30 |
+
* Caching of search results pages (i.e. URIs with query string variables) in memory or on disk
|
31 |
+
* Caching of database objects in memory
|
32 |
+
* Minification of posts and pages and RSS feeds
|
33 |
+
* Minification (combine and remove comments / white space) of inline, embedded or 3rd party JavaScript (with automated updates)
|
34 |
+
* Minification (combine and remove comments / white space) of inline, embedded or 3rd party CSS (with automated updates)
|
35 |
+
* Browser caching of CSS, JavaScript and HTML using future expire headers and entity tags (ETag)
|
36 |
+
* JavaScript grouping by template (home page, post page etc) with embed location management
|
37 |
+
* Non-blocking JavaScript embedding
|
38 |
+
* Import post attachments directly into the Media Library (and CDN)
|
39 |
|
40 |
+
Easily improve the user experience for your readers without having to change WordPress, your theme, your plugins or how you produce your content.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
== Frequently Asked Questions ==
|
43 |
|
44 |
+
= Why does speed matter? =
|
45 |
|
46 |
+
Speed is among the most significant success factors web sites face. In fact, your blog's speed directly affects your income (revenue) — it's a fact. Some high traffic sites conducted some research and uncovered the following:
|
47 |
+
|
48 |
+
* Google.com: +500 ms (speed decrease) -> -20% traffic loss [[1](http://home.blarg.net/~glinden/StanfordDataMining.2006-11-29.ppt)]
|
49 |
+
* Yahoo.com: +400 ms (speed decrease) -> -5-9% full-page traffic loss (visitor left before the page finished loading) [[2](http://www.slideshare.net/stoyan/yslow-20-presentation)]
|
50 |
+
* Amazon.com: +100 ms (speed decrease) -> -1% sales loss [[1](http://home.blarg.net/~glinden/StanfordDataMining.2006-11-29.ppt)]
|
51 |
+
|
52 |
+
A thousandth of a second is not a long time, yet the impact is quite significant. Even if you're not a large company (or just hope to become one), a loss is still a loss. However, there is a solution to this problem, take advantage.
|
53 |
|
54 |
= Why is W3 Total Cache better than other cache plugins? =
|
55 |
|
56 |
+
Most of the popular cache plugins available do a great job and serve their purpose very well. Our plugin remedies numerous performance reducing aspects of any web site going far beyond merely reducing CPU usage (load) and bandwidth consumption for HTML pages alone. Equally important, the plugin requires no theme modifications, modifications to your .htaccess (mod_rewrite rules) or programming compromises to reap the benefits. Setup is easy.
|
57 |
|
58 |
= I've never heard of any of this stuff; my blog is fine, no one complains about the speed. Why should I install this? =
|
59 |
|
92 |
That depends on how you use your blog and where most of your readers read your blog (regionally). Here's a short list:</p>
|
93 |
|
94 |
* [NetDNA](http://www.netdna.com/)
|
95 |
+
* [VPS NET](https://vps.net/cdn-signup)
|
96 |
* [SimpleCDN](http://www.simplecdn.com/)
|
97 |
* [Amazon S3](http://aws.amazon.com/s3/)
|
98 |
* [Amazon Cloudfront](http://aws.amazon.com/cloudfront/)
|
113 |
|
114 |
Yes, indirectly - if you have a lot of bloggers working with you, you will find that it feels like you have a server dedicated only to WP Admin once this plugin is enabled; the result, increased productivity.
|
115 |
|
116 |
+
|
117 |
= Which web servers do you support? =
|
118 |
|
119 |
We are aware of no incompatibilities with [apache](http://httpd.apache.org/) 1.3+, [IIS](http://www.iis.net/) 5+ or [litespeed](http://litespeedtech.com/products/webserver/overview/) 4.0.2+. If there's a web server you feel we should be actively testing (e.g. [lighttpd](http://www.lighttpd.net/)), we're [interested in hearing](mailto:wordpressexperts@w3-edge.com).
|
130 |
|
131 |
Install the plugin to read the full FAQ.
|
132 |
|
133 |
+
== Installation ==
|
134 |
+
|
135 |
+
1. Disable and remove any other caching plugin you may be using — most plugins have uninstall procedures you can follow. Make sure wp-content/ has 777 permissions before proceeding, e.g.: `# chmod 777 /var/www/vhosts/domain.com/httpdocs/wp-content/`
|
136 |
+
1. Unzip and upload the plugin to your plugins directory (wp-content/plugins/), when done wp-content/plugins/w3-total-cache/ should exist.
|
137 |
+
1. Ensure that wp-config.php contains the statement below; if you previously used a caching plugin, this statement is likely to exist already: `define('WP_CACHE', true);`
|
138 |
+
1. Locate and activate the plugin on the plugins page, then click the Settings link to proceed to the General Settings tab. Set the permissions of wp-content back to 755, e.g.: `# chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/`
|
139 |
+
1. Select your caching preferences for page, database and minify. If memcached is used this will require you to confirm or modify the default settings and add any additional memcached servers you wish to use. To utilize APC and memcached + memcache installation guides have been provided under the Installation tab. For those in shared hosting environments, contact your provider to see if either of these is supported.
|
140 |
+
1. If you already have a content delivery network provider, proceed to the CDN Settings tab and populate the fields and set your preferences. If you're not running a version of WordPress with the Media Library feature, use the Media Library Import Tool to migrate your post images etc to appropriate locations. If you do not have a CDN provider, you can still improve your site's performance using this feature. Create and use a subdomain on your own server; e.g. static.domain.com and configure options on the CDN tab accordingly.
|
141 |
+
1. On the Minify Settings tab all of the recommended settings are preset. Specify any CSS and JS files in the respective sections, view your site's HTML source and search for .css and .js files. In the case of JS files you can specify the type and location of the embedding using the drop down menu.
|
142 |
+
1. You're done! Get back to blogging!
|
143 |
+
|
144 |
== Changelog ==
|
145 |
|
146 |
+
= 0.8 =
|
147 |
+
* Added disk as method for page caching
|
148 |
+
* Added support for mirror (origin pull) content delivery networks
|
149 |
+
* Added options to specify minify group policies per template
|
150 |
+
* Added options for toggling inline CSS and JS minification to improve minify reliability
|
151 |
+
* Added option to update Media Library attachment hostnames (when migrating domains etc)
|
152 |
+
* Added "Empty Cache" buttons to respective tabs
|
153 |
+
* Added additional file download fallback methods for minify
|
154 |
+
* Improved cookie handling
|
155 |
+
* Improved header handling
|
156 |
+
* Improved reliability of Media Library import
|
157 |
+
* "Don't cache pages for logged in users" is now the default page cache setting
|
158 |
+
* Fixed minify bug with RSS feeds
|
159 |
+
* Fixed minify bug with rewriting of url() URI in CSS
|
160 |
+
* Addressed more page cache invalidity cases
|
161 |
+
* Addressed rare occurrence of PHP fatal errors when saving post or comments
|
162 |
+
* Addressed CSS bug on wp-login.php
|
163 |
+
* Addressed rare MySQL error when uploading attachments to Media Library
|
164 |
+
* Modified plugin file/directory structure
|
165 |
+
* Confirmed compatibility with varnish and squid
|
166 |
+
|
167 |
= 0.7.5.2 =
|
168 |
+
* Added warning dialog to minify tab about removal of query strings locally hosted object URIs
|
|
|
|
|
169 |
* Added empty (memcached) cache button to each tab
|
170 |
+
* Improved reliability of memcache flush
|
171 |
+
* Minified files now (optionally) upload automatically according to update interval (expiry time)
|
172 |
+
* Changed directory of minify working files to wp-content/w3tc-cache/
|
173 |
* Fixed bug with parsing memcached server strings
|
|
|
174 |
* Fixed bug with minify sometimes not creating files as it should
|
175 |
+
* Addressed WordPress MU site-wide activation/deactivation issues
|
176 |
+
* Provided memcache.ini directives updated to improve network throughput
|
177 |
|
178 |
= 0.7.5.1 =
|
179 |
+
* Added memcached test button for convenience
|
180 |
+
* Added option to concatenate any script to header or footer with non-blocking options for scripts that cannot be minified (e.g. obfuscated scripts)
|
181 |
+
* Added options to concatenate JS files only in header or footer (for use with obfuscated scripts)
|
182 |
* Improved notification handling
|
183 |
+
* Improved compatibility with suPHP
|
184 |
+
* Improved reliability of Media Library Export
|
185 |
* Fixed bug with database cache that caused comment counts to become out of date
|
|
|
186 |
* Fixed minor issue with URI with CDN functionality enabled
|
187 |
* Removed unnecessary minify options
|
|
|
188 |
* Minification error dialogs now disabled when JS or CSS minify settings disabled
|
189 |
* Normalized line endings with /n as per minify author's direction
|
190 |
+
* Resolved a bug in the minify library preventing proper permission notification messages
|
|
|
|
|
191 |
|
192 |
= 0.7.5 =
|
193 |
+
* Added handling for magic_quotes set to on
|
194 |
* Fixed issue with auto-download/upgrade and additional error checking
|
195 |
+
* Fixed a bug preventing minify working properly if either CSS or JS minification was disabled
|
196 |
* Improved handling of inline comments and JavaScript in HTML documents
|
197 |
+
* Improved handing of @import CSS embedding
|
|
|
|
|
198 |
* Addressed privilege control issue
|
199 |
* Resolved warnings thrown in various versions of WordPress
|
200 |
+
* Memcached engine logic modified to better support clustering and multiple memcached instances
|
|
|
201 |
* Eliminated false negatives in a number of gzip/deflate compression analysis tools
|
202 |
* Total plugin file size reduced
|
203 |
|
204 |
= 0.7 =
|
205 |
+
* Added minify support for URIs starting with /
|
206 |
* WordPress MU support bug fixes
|
207 |
* Minor CDN uploader fixes
|
|
|
208 |
* Minor error message improvements
|
209 |
|
210 |
= 0.6 =
|
211 |
+
* Added "Debug Mode" listing all settings and queries with statistics
|
212 |
* Improved error message notifications
|
213 |
+
* Improved cache stability for large objects
|
214 |
* FAQ and installation instructions corrections/adjustments
|
|
|
|
|
215 |
* Support for multiple wordpress installations added
|
216 |
+
* Resolved bug in minification of feeds
|
217 |
|
218 |
= 0.5 =
|
219 |
* Initial release
|
w3-total-cache-config-default.php
CHANGED
@@ -25,14 +25,13 @@ return array(
|
|
25 |
*/
|
26 |
'pgcache.enabled' => true,
|
27 |
'pgcache.debug' => false,
|
28 |
-
'pgcache.engine' => '
|
29 |
'pgcache.memcached.engine' => 'auto',
|
30 |
'pgcache.memcached.servers' => array(
|
31 |
'localhost:11211'
|
32 |
),
|
33 |
'pgcache.lifetime' => 3600,
|
34 |
'pgcache.compress' => true,
|
35 |
-
'pgcache.cache.logged' => true,
|
36 |
'pgcache.cache.query' => true,
|
37 |
'pgcache.cache.home' => true,
|
38 |
'pgcache.cache.feed' => true,
|
@@ -40,18 +39,15 @@ return array(
|
|
40 |
'pgcache.cache.flush' => false,
|
41 |
'pgcache.cache.headers' => array(
|
42 |
'Last-Modified',
|
43 |
-
'Expires',
|
44 |
'Content-Type',
|
45 |
-
'X-Pingback'
|
46 |
-
'ETag',
|
47 |
-
'Cache-Control',
|
48 |
-
'Pragma'
|
49 |
),
|
50 |
'pgcache.accept.files' => array(
|
51 |
'wp-comments-popup.php',
|
52 |
'wp-links-opml.php',
|
53 |
'wp-locations.php'
|
54 |
),
|
|
|
55 |
'pgcache.reject.uri' => array(
|
56 |
'wp-.*\.php',
|
57 |
'index\.php'
|
@@ -79,10 +75,7 @@ return array(
|
|
79 |
'localhost:11211'
|
80 |
),
|
81 |
'minify.rewrite' => true,
|
82 |
-
'minify.
|
83 |
-
'minify.cache.path' => '',
|
84 |
-
'minify.cache.locking' => true,
|
85 |
-
'minify.docroot' => '',
|
86 |
'minify.fixtime' => 0,
|
87 |
'minify.symlinks' => array(),
|
88 |
'minify.compress' => true,
|
@@ -96,26 +89,24 @@ return array(
|
|
96 |
)
|
97 |
),
|
98 |
'minify.lifetime' => 3600,
|
99 |
-
'minify.upload' => true,
|
100 |
'minify.html.enable' => true,
|
101 |
'minify.html.reject.admin' => true,
|
|
|
|
|
102 |
'minify.html.strip.crlf' => false,
|
103 |
'minify.css.enable' => true,
|
104 |
'minify.css.strip.comments' => false,
|
105 |
'minify.css.strip.crlf' => false,
|
106 |
-
'minify.css.groups' => array(
|
107 |
-
'include' => array(
|
108 |
-
'files' => array(
|
109 |
-
'wp-content/themes/default/style.css'
|
110 |
-
)
|
111 |
-
)
|
112 |
-
),
|
113 |
'minify.js.enable' => true,
|
114 |
'minify.js.combine.header' => false,
|
115 |
'minify.js.combine.footer' => false,
|
116 |
'minify.js.strip.comments' => false,
|
117 |
'minify.js.strip.crlf' => false,
|
118 |
'minify.js.groups' => array(),
|
|
|
|
|
119 |
|
120 |
/**
|
121 |
* CDN configuration
|
@@ -141,6 +132,14 @@ return array(
|
|
141 |
'cdn.ftp.pass' => '',
|
142 |
'cdn.ftp.path' => '',
|
143 |
'cdn.ftp.pasv' => false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
/**
|
146 |
* Common configuration
|
@@ -151,8 +150,8 @@ return array(
|
|
151 |
/**
|
152 |
* Notes configuration
|
153 |
*/
|
154 |
-
'notes.defaults' => true,
|
155 |
-
'notes.wp_content_perms' => true,
|
156 |
'notes.cdn_first_time' => true,
|
157 |
-
'notes.no_memcached_nor_apc' => true
|
158 |
);
|
25 |
*/
|
26 |
'pgcache.enabled' => true,
|
27 |
'pgcache.debug' => false,
|
28 |
+
'pgcache.engine' => 'file',
|
29 |
'pgcache.memcached.engine' => 'auto',
|
30 |
'pgcache.memcached.servers' => array(
|
31 |
'localhost:11211'
|
32 |
),
|
33 |
'pgcache.lifetime' => 3600,
|
34 |
'pgcache.compress' => true,
|
|
|
35 |
'pgcache.cache.query' => true,
|
36 |
'pgcache.cache.home' => true,
|
37 |
'pgcache.cache.feed' => true,
|
39 |
'pgcache.cache.flush' => false,
|
40 |
'pgcache.cache.headers' => array(
|
41 |
'Last-Modified',
|
|
|
42 |
'Content-Type',
|
43 |
+
'X-Pingback'
|
|
|
|
|
|
|
44 |
),
|
45 |
'pgcache.accept.files' => array(
|
46 |
'wp-comments-popup.php',
|
47 |
'wp-links-opml.php',
|
48 |
'wp-locations.php'
|
49 |
),
|
50 |
+
'pgcache.reject.logged' => true,
|
51 |
'pgcache.reject.uri' => array(
|
52 |
'wp-.*\.php',
|
53 |
'index\.php'
|
75 |
'localhost:11211'
|
76 |
),
|
77 |
'minify.rewrite' => true,
|
78 |
+
'minify.locking' => true,
|
|
|
|
|
|
|
79 |
'minify.fixtime' => 0,
|
80 |
'minify.symlinks' => array(),
|
81 |
'minify.compress' => true,
|
89 |
)
|
90 |
),
|
91 |
'minify.lifetime' => 3600,
|
92 |
+
'minify.upload' => true,
|
93 |
'minify.html.enable' => true,
|
94 |
'minify.html.reject.admin' => true,
|
95 |
+
'minify.html.inline.css' => false,
|
96 |
+
'minify.html.inline.js' => false,
|
97 |
'minify.html.strip.crlf' => false,
|
98 |
'minify.css.enable' => true,
|
99 |
'minify.css.strip.comments' => false,
|
100 |
'minify.css.strip.crlf' => false,
|
101 |
+
'minify.css.groups' => array(),
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
'minify.js.enable' => true,
|
103 |
'minify.js.combine.header' => false,
|
104 |
'minify.js.combine.footer' => false,
|
105 |
'minify.js.strip.comments' => false,
|
106 |
'minify.js.strip.crlf' => false,
|
107 |
'minify.js.groups' => array(),
|
108 |
+
'minify.reject.ua' => array(),
|
109 |
+
'minify.reject.uri' => array(),
|
110 |
|
111 |
/**
|
112 |
* CDN configuration
|
132 |
'cdn.ftp.pass' => '',
|
133 |
'cdn.ftp.path' => '',
|
134 |
'cdn.ftp.pasv' => false,
|
135 |
+
'cdn.reject.ua' => array(
|
136 |
+
'bot',
|
137 |
+
'ia_archive',
|
138 |
+
'slurp',
|
139 |
+
'crawl',
|
140 |
+
'spider'
|
141 |
+
),
|
142 |
+
'cdn.reject.uri' => array(),
|
143 |
|
144 |
/**
|
145 |
* Common configuration
|
150 |
/**
|
151 |
* Notes configuration
|
152 |
*/
|
153 |
+
'notes.defaults' => true,
|
154 |
+
'notes.wp_content_perms' => true,
|
155 |
'notes.cdn_first_time' => true,
|
156 |
+
'notes.no_memcached_nor_apc' => true
|
157 |
);
|
w3-total-cache.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: Dramatically improve the user experience of your blog. Add transparent page caching, database caching, minify and content delivery network (CDN) functionality and more to WordPress.
|
5 |
-
Version: 0.
|
6 |
Plugin URI: http://www.w3-edge.com/wordpress-plugins/w3-total-cache/
|
7 |
Author: Frederick Townes
|
8 |
Author URI: http://www.linkedin.com/in/w3edge
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: Dramatically improve the user experience of your blog. Add transparent page caching, database caching, minify and content delivery network (CDN) functionality and more to WordPress.
|
5 |
+
Version: 0.8
|
6 |
Plugin URI: http://www.w3-edge.com/wordpress-plugins/w3-total-cache/
|
7 |
Author: Frederick Townes
|
8 |
Author URI: http://www.linkedin.com/in/w3edge
|
wp-content/w3tc-cache/_htaccess
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
# W3 Minify module rewrite rules
|
2 |
-
<IfModule mod_rewrite.c>
|
3 |
-
RewriteEngine On
|
4 |
-
RewriteRule ^([a-z0-9_-]+)\.(css|js)$ index.php?t=$2&g=$1
|
5 |
-
</IfModule>
|
6 |
-
|
7 |
-
# Prevent directory listing
|
8 |
-
Options -Indexes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wp-content/w3tc/_htaccess
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BEGIN W3 Minify module rewrite rules
|
2 |
+
<IfModule mod_rewrite.c>
|
3 |
+
RewriteEngine On
|
4 |
+
RewriteRule ^([a-z0-9-_]+)\.(include(-footer)?(-nb)?)\.(css|js)$ minify.php?gg=$1&g=$2&t=$5
|
5 |
+
</IfModule>
|
6 |
+
# END W3 Minify module rewrite rules
|
7 |
+
|
8 |
+
# BEGIN Prevent directory listing
|
9 |
+
Options -Indexes
|
10 |
+
# END Prevent directory listing
|
wp-content/w3tc/index.html
ADDED
File without changes
|
wp-content/{w3tc-cache/index.php → w3tc/minify.php}
RENAMED
@@ -1,8 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
error_reporting(E_ALL ^ E_NOTICE);
|
4 |
-
ini_set('display_errors', 'On');
|
5 |
-
|
6 |
/**
|
7 |
* W3 Total Cache Minify module
|
8 |
*/
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
/**
|
4 |
* W3 Total Cache Minify module
|
5 |
*/
|