Version Description
- Added support for Bad Behavior plugin
- Added support for eAccelerator and XCache opcode caches
- Added support for rewriting href attribute of anchors for images that use the CDN
- Added deflate http compression support to minify
- Added setting of file modification time after FTP upload
- Added check of file modification time and file size before FTP upload
- Added check of file hash before uploading to Amazon S3
- Added option to force replacement of uploaded attachments on CDN
- Added option to toggle feed minification
- Added combine only option for CSS minification to overcome invalid CSS files
- Database caching now disabled by default to improve compatibility with some shared hosting environments
- Default page caching method now disk enhanced
- Improved HTTP Compression inter-operability
- Improved compatibility with Multi Site Manager
- Improved apache compatibility
- Improved .htaccess directives
- Improved header management for posts / pages
- Improved notifications
- Improved minify handling of external files
- Improved minify memory limit to avoid blank pages when document size is large
- Improved minify reliability by reducing comment removal options
- Improved Media Library Import versatility
- Improved reliability of plugin activation in WordPress MU
- Improved security handling for some operations
- Improved reliability of handling file names containing spaces in CDN functionality
- Improved non-blocking embedding reliability
- Improved memcached detection by supporting only PECL memcache
- Fixed bug with disk enhanced method of page cache in WordPress MU
- Fixed false match of page cache files in disk enhanced method of page cache
- Fixed a bug with cron anomalies caused by caching of wp_options table
- Fixed missing trailing slash issue when using disk enhanced page caching
- Fixed auto-embed bug CSS and JS when already manually embedded
Download this release
Release Info
Developer | fredericktownes |
Plugin | W3 Total Cache |
Version | 0.8.5.2 |
Comparing to | |
See all releases |
Code changes from version 0.8.5.1 to 0.8.5.2
- inc/css/error.css +23 -23
- inc/css/lightbox.css +15 -15
- inc/css/options.css +62 -38
- inc/css/popup.css +85 -83
- inc/define.php +324 -251
- inc/js/lightbox.js +7 -3
- inc/js/options.js +12 -8
- inc/js/popup.js +1 -1
- inc/lightbox/support_us.phtml +1 -1
- inc/mime.php +50 -0
- inc/options/about.phtml +19 -9
- inc/options/cdn.phtml +161 -126
- inc/options/cdn/cf.phtml +4 -7
- inc/options/cdn/ftp.phtml +13 -13
- inc/options/cdn/mirror.phtml +3 -5
- inc/options/cdn/s3.phtml +4 -7
- inc/options/common/header.phtml +2 -0
- inc/options/dbcache.phtml +57 -42
- inc/options/faq.phtml +78 -42
- inc/options/general.phtml +221 -129
- inc/options/install.phtml +26 -23
- inc/options/minify.phtml +216 -166
- inc/options/pgcache.phtml +132 -117
- inc/options/support.phtml +88 -75
- inc/options/support_email.phtml +1 -1
- inc/popup/cdn_export_file.phtml +1 -0
- inc/popup/cdn_export_library.phtml +1 -0
- inc/popup/cdn_import_library.phtml +2 -1
- inc/popup/cdn_queue.phtml +1 -0
- inc/popup/cdn_rename_domain.phtml +1 -0
- inc/widget/latest.phtml +12 -0
- inc/widget/latest_control.phtml +4 -0
- ini/_htaccess +4 -2
- ini/apc.ini +1 -2
- ini/memcache.ini +5 -3
- lib/Minify/HTTP/ConditionalGet.php +1 -1
- lib/Minify/HTTP/Encoder.php +10 -37
- lib/Minify/Minify.php +20 -7
- lib/Minify/Minify/CSS/UriRewriter.php +3 -0
- lib/Minify/Minify/Cache/Eaccelerator.php +130 -0
- lib/Minify/Minify/Cache/XCache.php +130 -0
- lib/Minify/Minify/CombineOnly.php +28 -0
- lib/Minify/Minify/HTML.php +11 -3
- lib/W3/Cache.php +24 -6
- lib/W3/Cache/Apc.php +1 -1
- lib/W3/Cache/Eaccelerator.php +94 -0
- lib/W3/Cache/File.php +1 -1
- lib/W3/Cache/Memcached.php +103 -46
- lib/W3/Cache/Memcached/Base.php +0 -62
- lib/W3/Cache/Memcached/Client.php +0 -159
- lib/W3/Cache/Memcached/Native.php +0 -145
- lib/W3/Cache/Xcache.php +93 -0
- lib/W3/Cdn/Base.php +7 -6
- lib/W3/Cdn/Ftp.php +28 -9
- lib/W3/Cdn/Mirror.php +2 -1
- lib/W3/Cdn/S3.php +19 -11
- lib/W3/Config.php +60 -49
- lib/W3/Db.php +29 -29
- lib/W3/Minify.php +72 -48
- lib/W3/PgCache.php +127 -104
- lib/W3/Plugin.php +18 -14
- lib/W3/Plugin/Cdn.php +260 -137
- lib/W3/Plugin/DbCache.php +1 -1
- lib/W3/Plugin/Minify.php +139 -98
- lib/W3/Plugin/PgCache.php +109 -82
- lib/W3/Plugin/TotalCache.php +351 -243
- lib/memcached-client.php +0 -977
- readme.txt +151 -85
- w3-total-cache.php +19 -17
- wp-content/advanced-cache.php +15 -12
- wp-content/db.php +2 -1
- wp-content/w3tc/min/index.php +4 -1
inc/css/error.css
CHANGED
@@ -1,49 +1,49 @@
|
|
1 |
* {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
}
|
6 |
|
7 |
html,body {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
body {
|
12 |
-
|
13 |
}
|
14 |
|
15 |
body,input {
|
16 |
-
|
17 |
-
|
18 |
}
|
19 |
|
20 |
a {
|
21 |
-
|
22 |
}
|
23 |
|
24 |
a:hover {
|
25 |
-
|
26 |
}
|
27 |
|
28 |
.button,input[type="button"],input[type="submit"] {
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
}
|
41 |
|
42 |
.button:hover,input[type="button"]:hover,input[type="submit"]:hover {
|
43 |
-
|
44 |
-
|
45 |
}
|
46 |
|
47 |
.button:active,input[type="button"]:active,input[type="submit"]:active {
|
48 |
-
|
49 |
}
|
1 |
* {
|
2 |
+
margin: 0;
|
3 |
+
padding: 0;
|
4 |
+
color: #464646;
|
5 |
}
|
6 |
|
7 |
html,body {
|
8 |
+
height: 100%;
|
9 |
}
|
10 |
|
11 |
body {
|
12 |
+
line-height: 1.4em;
|
13 |
}
|
14 |
|
15 |
body,input {
|
16 |
+
font-family: "Lucida Grande", Verdana, Arial;
|
17 |
+
font-size: 13px;
|
18 |
}
|
19 |
|
20 |
a {
|
21 |
+
color: #21759B;
|
22 |
}
|
23 |
|
24 |
a:hover {
|
25 |
+
color: #D54E21;
|
26 |
}
|
27 |
|
28 |
.button,input[type="button"],input[type="submit"] {
|
29 |
+
font-size: 11px;
|
30 |
+
line-height: 16px;
|
31 |
+
background: #f2f2f2 url(../../../../../wp-admin/images/white-grad.png) repeat-x scroll left top;
|
32 |
+
border: 1px solid #bbb;
|
33 |
+
color: #464646;
|
34 |
+
text-shadow: 0 1px 0 #fff;
|
35 |
+
cursor: pointer;
|
36 |
+
padding: 2px 8px;
|
37 |
+
border-radius: 11px;
|
38 |
+
-webkit-border-radius: 11px;
|
39 |
+
-moz-border-radius: 11px;
|
40 |
}
|
41 |
|
42 |
.button:hover,input[type="button"]:hover,input[type="submit"]:hover {
|
43 |
+
border-color: #666;
|
44 |
+
color: #000;
|
45 |
}
|
46 |
|
47 |
.button:active,input[type="button"]:active,input[type="submit"]:active {
|
48 |
+
background: #f2f2f2 url(../../../../../images/white-grad-active.png) repeat-x scroll left top;
|
49 |
}
|
inc/css/lightbox.css
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
#overlay {
|
2 |
-
|
3 |
}
|
4 |
|
5 |
.lightbox {
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
}
|
13 |
|
14 |
.lightbox-close {
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
}
|
20 |
|
21 |
.lightbox-loader {
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
}
|
26 |
|
27 |
.lightbox th {
|
28 |
-
|
29 |
}
|
1 |
#overlay {
|
2 |
+
background: #666;
|
3 |
}
|
4 |
|
5 |
.lightbox {
|
6 |
+
background: #f9f9f9;
|
7 |
+
padding: 10px 20px;
|
8 |
+
border: 1px solid #bbb;
|
9 |
+
border-radius: 11px;
|
10 |
+
-webkit-border-radius: 11px;
|
11 |
+
-moz-border-radius: 11px;
|
12 |
}
|
13 |
|
14 |
.lightbox-close {
|
15 |
+
cursor: hand;
|
16 |
+
cursor: pointer;
|
17 |
+
text-decoration: underline;
|
18 |
+
float: right;
|
19 |
}
|
20 |
|
21 |
.lightbox-loader {
|
22 |
+
background-image: url(../images/loader.gif);
|
23 |
+
background-position: center center;
|
24 |
+
background-repeat: no-repeat;
|
25 |
}
|
26 |
|
27 |
.lightbox th {
|
28 |
+
width: 80px;
|
29 |
}
|
inc/css/options.css
CHANGED
@@ -1,109 +1,133 @@
|
|
1 |
#icon-w3tc-logo {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
}
|
7 |
|
8 |
.w3tc-options-menu-selected {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
.w3tc-enabled {
|
13 |
-
|
14 |
-
|
15 |
}
|
16 |
|
17 |
.w3tc-disabled {
|
18 |
-
|
19 |
-
|
20 |
}
|
21 |
|
22 |
.w3tc-empty {
|
23 |
-
|
24 |
-
|
25 |
}
|
26 |
|
27 |
.w3tc-success {
|
28 |
-
|
29 |
}
|
30 |
|
31 |
.w3tc-error {
|
32 |
-
|
33 |
}
|
34 |
|
35 |
.w3tc-status {
|
36 |
-
|
37 |
}
|
38 |
|
39 |
#w3tc acronym {
|
40 |
-
|
41 |
}
|
42 |
|
43 |
#w3tc ul {
|
44 |
-
|
45 |
-
|
46 |
}
|
47 |
|
48 |
#w3tc blockquote {
|
49 |
-
|
50 |
}
|
51 |
|
52 |
#w3tc blockquote cite {
|
53 |
-
|
54 |
}
|
55 |
|
56 |
#w3tc h5 {
|
57 |
-
|
58 |
}
|
59 |
|
60 |
#w3tc hr {
|
61 |
-
|
62 |
-
|
63 |
}
|
64 |
|
65 |
#w3tc ul {
|
66 |
-
|
67 |
}
|
68 |
|
69 |
#w3tc #toc a,#qa a {
|
70 |
-
|
71 |
}
|
72 |
|
73 |
#w3tc #toc a:hover,#qa a:hover {
|
74 |
-
|
75 |
}
|
76 |
|
77 |
#w3tc #toc ul {
|
78 |
-
|
79 |
-
|
80 |
}
|
81 |
|
82 |
#w3tc #toc li {
|
83 |
-
|
84 |
-
|
85 |
}
|
86 |
|
87 |
#w3tc #toc li.col {
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
}
|
93 |
|
94 |
#w3tc #toc li.col ul {
|
95 |
-
|
96 |
}
|
97 |
|
98 |
#w3tc #toc li.col ul li {
|
99 |
-
|
100 |
}
|
101 |
|
102 |
#w3tc #qa {
|
103 |
-
|
104 |
-
|
105 |
}
|
106 |
|
107 |
#w3tc #qa,#w3tc #about,#w3tc #install {
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
1 |
#icon-w3tc-logo {
|
2 |
+
background: url(../images/logo.png) no-repeat;
|
3 |
+
float: left;
|
4 |
+
height: 36px;
|
5 |
+
width: 36px
|
6 |
}
|
7 |
|
8 |
.w3tc-options-menu-selected {
|
9 |
+
font-weight: 700
|
10 |
}
|
11 |
|
12 |
.w3tc-enabled {
|
13 |
+
color: #090;
|
14 |
+
font-weight: 700
|
15 |
}
|
16 |
|
17 |
.w3tc-disabled {
|
18 |
+
color: #f00;
|
19 |
+
font-weight: 700
|
20 |
}
|
21 |
|
22 |
.w3tc-empty {
|
23 |
+
font-weight: 700;
|
24 |
+
font-style: italic
|
25 |
}
|
26 |
|
27 |
.w3tc-success {
|
28 |
+
background: #bfb
|
29 |
}
|
30 |
|
31 |
.w3tc-error {
|
32 |
+
background: #f99
|
33 |
}
|
34 |
|
35 |
.w3tc-status {
|
36 |
+
padding: 5px
|
37 |
}
|
38 |
|
39 |
#w3tc acronym {
|
40 |
+
border-bottom: 1px dotted #666
|
41 |
}
|
42 |
|
43 |
#w3tc ul {
|
44 |
+
list-style-type: disc;
|
45 |
+
list-style-position: inside
|
46 |
}
|
47 |
|
48 |
#w3tc blockquote {
|
49 |
+
font-style: italic;
|
50 |
}
|
51 |
|
52 |
#w3tc blockquote cite {
|
53 |
+
font-style: 400
|
54 |
}
|
55 |
|
56 |
#w3tc h5 {
|
57 |
+
margin: 0
|
58 |
}
|
59 |
|
60 |
#w3tc hr {
|
61 |
+
clear: both;
|
62 |
+
margin-top: 10px
|
63 |
}
|
64 |
|
65 |
#w3tc ul {
|
66 |
+
list-style-position: inside
|
67 |
}
|
68 |
|
69 |
#w3tc #toc a,#qa a {
|
70 |
+
text-decoration: none
|
71 |
}
|
72 |
|
73 |
#w3tc #toc a:hover,#qa a:hover {
|
74 |
+
text-decoration: underline
|
75 |
}
|
76 |
|
77 |
#w3tc #toc ul {
|
78 |
+
margin: 0;
|
79 |
+
padding: 0
|
80 |
}
|
81 |
|
82 |
#w3tc #toc li {
|
83 |
+
margin: 0;
|
84 |
+
padding: 0
|
85 |
}
|
86 |
|
87 |
#w3tc #toc li.col {
|
88 |
+
float: left;
|
89 |
+
list-style: none;
|
90 |
+
margin: 0 30px 0 0;
|
91 |
+
width: 30%
|
92 |
}
|
93 |
|
94 |
#w3tc #toc li.col ul {
|
95 |
+
margin-left: 20px
|
96 |
}
|
97 |
|
98 |
#w3tc #toc li.col ul li {
|
99 |
+
list-style: disc
|
100 |
}
|
101 |
|
102 |
#w3tc #qa {
|
103 |
+
clear: both;
|
104 |
+
padding: 10px;
|
105 |
}
|
106 |
|
107 |
#w3tc #qa,#w3tc #about,#w3tc #install {
|
108 |
+
width: 760px;
|
109 |
+
}
|
110 |
+
|
111 |
+
#w3tc fieldset {
|
112 |
+
margin: 1em 0;
|
113 |
+
padding: 0 1em 1em 1em;
|
114 |
+
border: 1px solid #bbb;
|
115 |
+
border-radius: 11px;
|
116 |
+
-webkit-border-radius: 11px;
|
117 |
+
-moz-border-radius: 11px;
|
118 |
+
}
|
119 |
+
|
120 |
+
#w3tc fieldset .submit {
|
121 |
+
margin: 1em 0 0 0;
|
122 |
+
padding: 0;
|
123 |
+
}
|
124 |
+
|
125 |
+
#w3tc legend {
|
126 |
+
color: #999;
|
127 |
+
padding: 0 5px;
|
128 |
+
font-weight: bold;
|
129 |
+
}
|
130 |
+
|
131 |
+
#cdn-general th {
|
132 |
+
width: 400px;
|
133 |
}
|
inc/css/popup.css
CHANGED
@@ -1,175 +1,177 @@
|
|
1 |
* {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
}
|
6 |
|
7 |
html,body {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
body {
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
}
|
15 |
|
16 |
body,td,textarea,input,select {
|
17 |
-
|
18 |
-
|
19 |
}
|
20 |
|
21 |
p {
|
22 |
-
|
23 |
}
|
24 |
|
25 |
h1 {
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
}
|
34 |
|
35 |
a {
|
36 |
-
|
37 |
}
|
38 |
|
39 |
a:hover {
|
40 |
-
|
41 |
}
|
42 |
|
43 |
#content {
|
44 |
-
|
45 |
}
|
46 |
|
47 |
.clear {
|
48 |
-
|
49 |
}
|
50 |
|
51 |
.button,input[type="button"],input[type="submit"] {
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
}
|
64 |
|
65 |
.button:hover,input[type="button"]:hover,input[type="submit"]:hover {
|
66 |
-
|
67 |
-
|
68 |
}
|
69 |
|
70 |
.button:active,input[type="button"]:active,input[type="submit"]:active {
|
71 |
-
|
72 |
}
|
73 |
|
74 |
.progress {
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
}
|
81 |
|
82 |
.progress-value {
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
}
|
91 |
|
92 |
.progress-bar {
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
}
|
98 |
|
99 |
.log {
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
}
|
104 |
|
105 |
.log div {
|
106 |
-
|
107 |
-
|
108 |
}
|
109 |
|
110 |
.log-success {
|
111 |
-
|
112 |
}
|
113 |
|
114 |
.log-error {
|
115 |
-
|
116 |
}
|
117 |
|
118 |
.empty {
|
119 |
-
|
120 |
-
|
121 |
}
|
122 |
|
123 |
.table {
|
124 |
-
|
125 |
-
|
126 |
}
|
127 |
|
128 |
.table td,th {
|
129 |
-
|
130 |
-
|
131 |
}
|
132 |
|
133 |
.table th {
|
134 |
-
|
135 |
}
|
136 |
|
137 |
.queue td {
|
138 |
-
|
139 |
}
|
140 |
|
141 |
.updated,.error {
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
}
|
151 |
|
152 |
.updated {
|
153 |
-
|
154 |
-
|
155 |
}
|
156 |
|
157 |
.error {
|
158 |
-
|
159 |
-
|
160 |
}
|
161 |
|
162 |
.updated p,.error p {
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
}
|
167 |
|
168 |
.tab-selected {
|
169 |
-
|
170 |
}
|
171 |
|
172 |
.rules {
|
173 |
-
|
174 |
-
|
175 |
}
|
1 |
* {
|
2 |
+
margin: 0;
|
3 |
+
padding: 0;
|
4 |
+
color: #464646;
|
5 |
}
|
6 |
|
7 |
html,body {
|
8 |
+
height: 100%;
|
9 |
}
|
10 |
|
11 |
body {
|
12 |
+
line-height: 1em;
|
13 |
+
background: #f9f9f9;
|
14 |
+
padding: 0;
|
15 |
+
margin: 0;
|
16 |
}
|
17 |
|
18 |
body,td,textarea,input,select {
|
19 |
+
font-family: "Lucida Grande", Verdana, Arial;
|
20 |
+
font-size: 13px;
|
21 |
}
|
22 |
|
23 |
p {
|
24 |
+
margin: 1em 0;
|
25 |
}
|
26 |
|
27 |
h1 {
|
28 |
+
font-family: Georgia, "Times New Roman", "Bitstream Charter";
|
29 |
+
font-size: 24px;
|
30 |
+
font-style: italic;
|
31 |
+
font-weight: 400;
|
32 |
+
line-height: 35px;
|
33 |
+
margin: 0 0 0.8em 0;
|
34 |
+
text-shadow: 0 1px 0 #fff;
|
35 |
}
|
36 |
|
37 |
a {
|
38 |
+
color: #21759B;
|
39 |
}
|
40 |
|
41 |
a:hover {
|
42 |
+
color: #D54E21;
|
43 |
}
|
44 |
|
45 |
#content {
|
46 |
+
padding: 10px 50px;
|
47 |
}
|
48 |
|
49 |
.clear {
|
50 |
+
clear: both;
|
51 |
}
|
52 |
|
53 |
.button,input[type="button"],input[type="submit"] {
|
54 |
+
font-size: 11px;
|
55 |
+
line-height: 16px;
|
56 |
+
background: #f2f2f2 url(../../../../../wp-admin/images/white-grad.png) repeat-x scroll left top;
|
57 |
+
border: 1px solid #bbb;
|
58 |
+
color: #464646;
|
59 |
+
text-shadow: 0 1px 0 #fff;
|
60 |
+
cursor: pointer;
|
61 |
+
padding: 2px 8px;
|
62 |
+
border-radius: 11px;
|
63 |
+
-webkit-border-radius: 11px;
|
64 |
+
-moz-border-radius: 11px;
|
65 |
}
|
66 |
|
67 |
.button:hover,input[type="button"]:hover,input[type="submit"]:hover {
|
68 |
+
border-color: #666;
|
69 |
+
color: #000;
|
70 |
}
|
71 |
|
72 |
.button:active,input[type="button"]:active,input[type="submit"]:active {
|
73 |
+
background: #F2F2F2 url(../../../../../wp-admin/images/white-grad-active.png) repeat-x scroll left top;
|
74 |
}
|
75 |
|
76 |
.progress {
|
77 |
+
background: #fff;
|
78 |
+
border: 1px solid #464646;
|
79 |
+
padding: 1px;
|
80 |
+
margin: 1em 0;
|
81 |
+
position: relative;
|
82 |
}
|
83 |
|
84 |
.progress-value {
|
85 |
+
position: absolute;
|
86 |
+
line-height: 30px;
|
87 |
+
font-size: 16px;
|
88 |
+
font-weight: 700;
|
89 |
+
color: #000;
|
90 |
+
text-align: center;
|
91 |
+
width: 100%;
|
92 |
}
|
93 |
|
94 |
.progress-bar {
|
95 |
+
float: left;
|
96 |
+
width: 0;
|
97 |
+
height: 30px;
|
98 |
+
background: #fc2;
|
99 |
}
|
100 |
|
101 |
.log {
|
102 |
+
border: 1px solid #464646;
|
103 |
+
height: 279px;
|
104 |
+
overflow: auto;
|
105 |
}
|
106 |
|
107 |
.log div {
|
108 |
+
padding: 3px;
|
109 |
+
border-bottom: 1px solid #464646;
|
110 |
}
|
111 |
|
112 |
.log-success {
|
113 |
+
background: #bfb;
|
114 |
}
|
115 |
|
116 |
.log-error {
|
117 |
+
background: #f99;
|
118 |
}
|
119 |
|
120 |
.empty {
|
121 |
+
font-weight: 700;
|
122 |
+
font-style: italic;
|
123 |
}
|
124 |
|
125 |
.table {
|
126 |
+
width: 100%;
|
127 |
+
border-collapse: collapse;
|
128 |
}
|
129 |
|
130 |
.table td,th {
|
131 |
+
border: 1px solid #ccc;
|
132 |
+
padding: 3px 2px;
|
133 |
}
|
134 |
|
135 |
.table th {
|
136 |
+
background: #eee;
|
137 |
}
|
138 |
|
139 |
.queue td {
|
140 |
+
font-size: 10px;
|
141 |
}
|
142 |
|
143 |
.updated,.error {
|
144 |
+
-moz-border-radius-bottomleft: 3px;
|
145 |
+
-moz-border-radius-bottomright: 3px;
|
146 |
+
-moz-border-radius-topleft: 3px;
|
147 |
+
-moz-border-radius-topright: 3px;
|
148 |
+
border-style: solid;
|
149 |
+
border-width: 1px;
|
150 |
+
padding: 0 0.6em;
|
151 |
+
margin: 0.5em 0;
|
152 |
}
|
153 |
|
154 |
.updated {
|
155 |
+
background: #ffffe0;
|
156 |
+
border-color: #e6db55;
|
157 |
}
|
158 |
|
159 |
.error {
|
160 |
+
background-color: #ffebe8;
|
161 |
+
border-color: #cc0000;
|
162 |
}
|
163 |
|
164 |
.updated p,.error p {
|
165 |
+
line-height: 1;
|
166 |
+
margin: 0.5em 0;
|
167 |
+
padding: 2px;
|
168 |
}
|
169 |
|
170 |
.tab-selected {
|
171 |
+
font-weight: 700;
|
172 |
}
|
173 |
|
174 |
.rules {
|
175 |
+
width: 100%;
|
176 |
+
font-size: 9px;
|
177 |
}
|
inc/define.php
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define('W3TC_VERSION', '0.8.5.
|
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');
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
}
|
11 |
|
|
|
12 |
define('W3TC_FILE', 'w3-total-cache/w3-total-cache.php');
|
13 |
define('W3TC_LIB_DIR', W3TC_DIR . '/lib');
|
14 |
define('W3TC_LIB_W3_DIR', W3TC_LIB_DIR . '/W3');
|
@@ -17,40 +22,40 @@ define('W3TC_PLUGINS_DIR', W3TC_DIR . '/plugins');
|
|
17 |
define('W3TC_INSTALL_DIR', W3TC_DIR . '/wp-content');
|
18 |
define('W3TC_INSTALL_MINIFY_DIR', W3TC_INSTALL_DIR . '/w3tc/min');
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
define('
|
|
|
25 |
|
26 |
-
define('
|
|
|
|
|
27 |
define('W3TC_CONTENT_DIR', ABSPATH . W3TC_CONTENT_DIR_NAME);
|
28 |
-
define('W3TC_CONTENT_MINIFY_DIR_NAME',
|
29 |
define('W3TC_CONTENT_MINIFY_DIR', ABSPATH . W3TC_CONTENT_DIR_NAME . '/min');
|
30 |
define('W3TC_CACHE_FILE_DBCACHE_DIR', W3TC_CONTENT_DIR . '/dbcache');
|
31 |
define('W3TC_CACHE_FILE_PGCACHE_DIR', W3TC_CONTENT_DIR . '/pgcache');
|
32 |
define('W3TC_CACHE_FILE_MINIFY_DIR', W3TC_CONTENT_DIR . '/min');
|
33 |
define('W3TC_LOG_DIR', W3TC_CONTENT_DIR . '/log');
|
34 |
define('W3TC_TMP_DIR', W3TC_CONTENT_DIR . '/tmp');
|
35 |
-
|
36 |
-
define('
|
37 |
-
|
38 |
define('W3TC_MINIFY_LOG_FILE', W3TC_LOG_DIR . '/minify.log');
|
39 |
-
|
40 |
define('W3TC_CDN_COMMAND_UPLOAD', 1);
|
41 |
define('W3TC_CDN_COMMAND_DELETE', 2);
|
42 |
define('W3TC_CDN_TABLE_QUEUE', 'w3tc_cdn_queue');
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
define('W3TC_EMAIL', 'w3tc@w3-edge.com');
|
48 |
-
define('W3TC_FEED_URL', 'http://feeds.feedburner.com/W3TOTALCACHE');
|
49 |
-
define('W3TC_FEED_ITEMS', 3);
|
50 |
-
define('W3TC_README_URL', 'http://plugins.trac.wordpress.org/browser/w3-total-cache/trunk/readme.txt?format=txt');
|
51 |
-
|
52 |
-
define('W3TC_TWITTER_STATUS', 'I just optimized my #wordpress blog\'s #performance using the W3 Total Cache #plugin by @w3edge. Check it out! http://j.mp/A69xX');
|
53 |
-
define('W3TC_SUPPORT_US_TIMEOUT', 2592000);
|
54 |
|
55 |
/**
|
56 |
* W3 activate error
|
@@ -58,6 +63,7 @@ define('W3TC_SUPPORT_US_TIMEOUT', 2592000);
|
|
58 |
* @param string $error
|
59 |
* @return void
|
60 |
*/
|
|
|
61 |
function w3_activate_error($error)
|
62 |
{
|
63 |
$active_plugins = (array) get_option('active_plugins');
|
@@ -99,7 +105,7 @@ function w3_writable_error($path)
|
|
99 |
$error = sprintf('<strong>%s</strong> could not be created, please run following command:<br /><strong style="color: #f00;">chmod 777 %s</strong><br />then %s.', $path, dirname($path), $reactivate_button);
|
100 |
}
|
101 |
} else {
|
102 |
-
$error = sprintf('<strong>%s</strong> could not be created, <strong>open_basedir</strong> restriction in effect, please check your php.ini settings:<br /><strong style="color: #f00;">open_basedir = "%s"</strong
|
103 |
}
|
104 |
|
105 |
w3_activate_error($error);
|
@@ -176,7 +182,7 @@ function w3_gzdecode($data)
|
|
176 |
*/
|
177 |
function w3_mkdir($path, $mask = 0755, $curr_path = '')
|
178 |
{
|
179 |
-
$path =
|
180 |
$path = trim($path, '/');
|
181 |
$dirs = explode('/', $path);
|
182 |
|
@@ -255,80 +261,95 @@ function w3_is_xml($content)
|
|
255 |
}
|
256 |
|
257 |
/**
|
258 |
-
* Returns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
*
|
260 |
* @return string
|
261 |
*/
|
262 |
-
function
|
263 |
{
|
264 |
-
static $
|
265 |
|
266 |
-
if ($
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
$wpmu = file_exists(ABSPATH . 'wpmu-settings.php');
|
273 |
-
}
|
274 |
-
|
275 |
-
if ($wpmu) {
|
276 |
-
if (defined('VHOST') && VHOST === 'yes') {
|
277 |
-
$id = w3_get_domain($_SERVER['HTTP_HOST']);
|
278 |
} else {
|
279 |
-
|
280 |
-
|
281 |
-
} elseif (isset($GLOBALS['base'])) {
|
282 |
-
$base = $GLOBALS['base'];
|
283 |
-
} else {
|
284 |
-
$base = '/';
|
285 |
-
}
|
286 |
-
|
287 |
-
if (empty($base)) {
|
288 |
-
$base = '/';
|
289 |
-
}
|
290 |
-
|
291 |
-
$id = strtolower($_SERVER['REQUEST_URI']);
|
292 |
|
293 |
-
if (strpos($
|
294 |
-
$
|
295 |
}
|
296 |
|
297 |
-
|
298 |
-
$id = substr($id, 0, $pos);
|
299 |
-
}
|
300 |
|
301 |
-
if (
|
302 |
-
$
|
303 |
-
}
|
304 |
-
|
305 |
-
if ($id != '') {
|
306 |
-
$id = trim($id, '/');
|
307 |
-
|
308 |
-
if (in_array($id, array(
|
309 |
-
'page',
|
310 |
-
'comments',
|
311 |
-
'blog',
|
312 |
-
'wp-admin',
|
313 |
-
'wp-includes',
|
314 |
-
'wp-content',
|
315 |
-
'files',
|
316 |
-
'feed'
|
317 |
-
)) || is_file($id)) {
|
318 |
-
$id = '';
|
319 |
-
} else {
|
320 |
-
$id = $id . '.' . w3_get_domain($_SERVER['HTTP_HOST']);
|
321 |
-
}
|
322 |
}
|
323 |
}
|
|
|
|
|
324 |
}
|
325 |
}
|
326 |
|
327 |
-
return $
|
328 |
}
|
329 |
|
330 |
/**
|
331 |
-
* Returns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
*
|
333 |
* @return string
|
334 |
*/
|
@@ -339,21 +360,11 @@ function w3_get_site_url()
|
|
339 |
if ($site_url === null) {
|
340 |
if (function_exists('get_option')) {
|
341 |
$site_url = get_option('siteurl');
|
342 |
-
$site_url = rtrim($site_url, '/') . '/';
|
343 |
} else {
|
344 |
-
$site_url = sprintf('http://%s
|
345 |
-
|
346 |
-
if (! empty($_SERVER['DOCUMENT_ROOT'])) {
|
347 |
-
$document_root = realpath($_SERVER['DOCUMENT_ROOT']);
|
348 |
-
$abspath = realpath(ABSPATH);
|
349 |
-
$path = str_replace($abspath, '', $document_root);
|
350 |
-
$path = trim($path, '/\\');
|
351 |
-
|
352 |
-
if ($path != '') {
|
353 |
-
$site_url .= $path . '/';
|
354 |
-
}
|
355 |
-
}
|
356 |
}
|
|
|
|
|
357 |
}
|
358 |
|
359 |
return $site_url;
|
@@ -395,21 +406,60 @@ function w3_get_site_url_regexp()
|
|
395 |
*/
|
396 |
function w3_get_site_path()
|
397 |
{
|
398 |
-
|
|
|
|
|
399 |
|
400 |
-
if ($
|
401 |
-
$
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
}
|
|
|
|
|
410 |
}
|
411 |
|
412 |
-
return $
|
413 |
}
|
414 |
|
415 |
/**
|
@@ -423,13 +473,15 @@ function w3_get_domain($host)
|
|
423 |
$host = strtolower($host);
|
424 |
|
425 |
if (strpos($host, 'www.') === 0) {
|
426 |
-
$host =
|
427 |
}
|
428 |
|
429 |
-
if (($pos = strpos($host, ':'))) {
|
430 |
$host = substr($host, 0, $pos);
|
431 |
}
|
432 |
|
|
|
|
|
433 |
return $host;
|
434 |
}
|
435 |
|
@@ -447,7 +499,7 @@ function w3_get_domain_url()
|
|
447 |
$scheme = $parse_url['scheme'];
|
448 |
$host = $parse_url['host'];
|
449 |
$port = (isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '');
|
450 |
-
$domain_url = sprintf('%s://%s%s
|
451 |
|
452 |
return $domain_url;
|
453 |
}
|
@@ -482,8 +534,8 @@ function w3_upload_info()
|
|
482 |
|
483 |
if (empty($upload_info['error'])) {
|
484 |
$site_url = w3_get_site_url();
|
485 |
-
$upload_info['upload_url'] =
|
486 |
-
$upload_info['upload_dir'] =
|
487 |
} else {
|
488 |
$upload_info = false;
|
489 |
}
|
@@ -578,6 +630,14 @@ function w3_get_engine_name($engine)
|
|
578 |
$engine_name = 'apc';
|
579 |
break;
|
580 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
581 |
case 'file':
|
582 |
$engine_name = 'disk';
|
583 |
break;
|
@@ -638,14 +698,17 @@ function w3_to_boolean($value)
|
|
638 |
*/
|
639 |
function w3_url_request($method, $url, $data = '', $auth = '')
|
640 |
{
|
|
|
641 |
$method = strtoupper($method);
|
642 |
|
643 |
-
if (function_exists('curl_init')) {
|
644 |
$ch = curl_init();
|
645 |
|
646 |
curl_setopt($ch, CURLOPT_URL, $url);
|
647 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
648 |
curl_setopt($ch, CURLOPT_USERAGENT, W3TC_POWERED_BY);
|
|
|
|
|
649 |
|
650 |
if ($method == 'POST') {
|
651 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
@@ -658,9 +721,9 @@ function w3_url_request($method, $url, $data = '', $auth = '')
|
|
658 |
|
659 |
$contents = curl_exec($ch);
|
660 |
|
661 |
-
|
662 |
|
663 |
-
|
664 |
} else {
|
665 |
$parse_url = @parse_url($url);
|
666 |
|
@@ -671,7 +734,7 @@ function w3_url_request($method, $url, $data = '', $auth = '')
|
|
671 |
$query = (isset($parse_url['query']) ? $parse_url['query'] : '');
|
672 |
$request_uri = $path . ($query != '' ? '?' . $query : '');
|
673 |
|
674 |
-
$
|
675 |
sprintf('%s %s HTTP/1.1', $method, $request_uri),
|
676 |
sprintf('Host: %s', $host),
|
677 |
sprintf('User-Agent: %s', W3TC_POWERED_BY),
|
@@ -679,32 +742,46 @@ function w3_url_request($method, $url, $data = '', $auth = '')
|
|
679 |
);
|
680 |
|
681 |
if (! empty($data)) {
|
682 |
-
$
|
683 |
}
|
684 |
|
685 |
if (! empty($auth)) {
|
686 |
-
$
|
687 |
}
|
688 |
|
689 |
-
$
|
|
|
690 |
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
}
|
705 |
}
|
706 |
}
|
707 |
-
|
|
|
|
|
|
|
|
|
|
|
708 |
}
|
709 |
|
710 |
/**
|
@@ -731,6 +808,24 @@ function w3_url_post($url, $data = '', $auth = '')
|
|
731 |
return w3_url_request('POST', $url, $data, $auth);
|
732 |
}
|
733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
734 |
/**
|
735 |
* Loads plugins
|
736 |
*
|
@@ -766,6 +861,19 @@ function w3_is_https()
|
|
766 |
return false;
|
767 |
}
|
768 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
/**
|
770 |
* Returns realpath of given path
|
771 |
*
|
@@ -773,7 +881,7 @@ function w3_is_https()
|
|
773 |
*/
|
774 |
function w3_realpath($path)
|
775 |
{
|
776 |
-
$path =
|
777 |
$parts = explode('/', $path);
|
778 |
$absolutes = array();
|
779 |
|
@@ -836,72 +944,6 @@ function w3_check_open_basedir($path)
|
|
836 |
return false;
|
837 |
}
|
838 |
|
839 |
-
/**
|
840 |
-
* Returns PHP info
|
841 |
-
*
|
842 |
-
* @return array
|
843 |
-
*/
|
844 |
-
function w3_phpinfo()
|
845 |
-
{
|
846 |
-
ob_start();
|
847 |
-
phpinfo();
|
848 |
-
$phpinfo = ob_get_clean();
|
849 |
-
|
850 |
-
$phpinfo = preg_replace(array(
|
851 |
-
'#^.*<body>(.*)</body>.*$#ms',
|
852 |
-
'#<h2>PHP License</h2>.*$#ms',
|
853 |
-
'#<h1>Configuration</h1>#',
|
854 |
-
"#\r?\n#",
|
855 |
-
"#</(h1|h2|h3|tr)>#",
|
856 |
-
'# +<#',
|
857 |
-
"#[ \t]+#",
|
858 |
-
'# #',
|
859 |
-
'# +#',
|
860 |
-
'# class=".*?"#',
|
861 |
-
'%'%',
|
862 |
-
'#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' . '<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
|
863 |
-
'#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
|
864 |
-
'#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
|
865 |
-
"# +#",
|
866 |
-
'#<tr>#',
|
867 |
-
'#</tr>#'
|
868 |
-
), array(
|
869 |
-
'$1',
|
870 |
-
'',
|
871 |
-
'',
|
872 |
-
'',
|
873 |
-
'</$1>' . "\n",
|
874 |
-
'<',
|
875 |
-
' ',
|
876 |
-
' ',
|
877 |
-
' ',
|
878 |
-
'',
|
879 |
-
' ',
|
880 |
-
'<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' . "\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
|
881 |
-
'<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
|
882 |
-
'<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . '<tr><td>Zend Egg</td><td>$1</td></tr>',
|
883 |
-
' ',
|
884 |
-
'%S%',
|
885 |
-
'%E%'
|
886 |
-
), $phpinfo);
|
887 |
-
|
888 |
-
$sections = explode('<h2>', strip_tags($phpinfo, '<h2><th><td>'));
|
889 |
-
|
890 |
-
$pi = array();
|
891 |
-
|
892 |
-
foreach ($sections as $section) {
|
893 |
-
$n = substr($section, 0, strpos($section, '</h2>'));
|
894 |
-
$askapache = null;
|
895 |
-
if (preg_match_all('#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', $section, $askapache, PREG_SET_ORDER)) {
|
896 |
-
foreach ($askapache as $m) {
|
897 |
-
$pi[$n][$m[1]] = (! isset($m[3]) || $m[2] == $m[3]) ? $m[2] : array_slice($m, 2);
|
898 |
-
}
|
899 |
-
}
|
900 |
-
}
|
901 |
-
|
902 |
-
return $pi;
|
903 |
-
}
|
904 |
-
|
905 |
/**
|
906 |
* Returns file mime type
|
907 |
*
|
@@ -910,54 +952,7 @@ function w3_phpinfo()
|
|
910 |
*/
|
911 |
function w3_get_mime_type($file)
|
912 |
{
|
913 |
-
$mime_types =
|
914 |
-
'jpg|jpeg|jpe' => 'image/jpeg',
|
915 |
-
'gif' => 'image/gif',
|
916 |
-
'png' => 'image/png',
|
917 |
-
'bmp' => 'image/bmp',
|
918 |
-
'tif|tiff' => 'image/tiff',
|
919 |
-
'ico' => 'image/x-icon',
|
920 |
-
'asf|asx|wax|wmv|wmx' => 'video/asf',
|
921 |
-
'avi' => 'video/avi',
|
922 |
-
'divx' => 'video/divx',
|
923 |
-
'mov|qt' => 'video/quicktime',
|
924 |
-
'mpeg|mpg|mpe' => 'video/mpeg',
|
925 |
-
'txt|c|cc|h' => 'text/plain',
|
926 |
-
'svg' => 'image/svg+xml',
|
927 |
-
'rtx' => 'text/richtext',
|
928 |
-
'css' => 'text/css',
|
929 |
-
'xsl|xsd|xml' => 'text/xml',
|
930 |
-
'htm|html' => 'text/html',
|
931 |
-
'mp3|m4a' => 'audio/mpeg',
|
932 |
-
'mp4|m4v' => 'video/mp4',
|
933 |
-
'ra|ram' => 'audio/x-realaudio',
|
934 |
-
'wav' => 'audio/wav',
|
935 |
-
'ogg' => 'audio/ogg',
|
936 |
-
'mid|midi' => 'audio/midi',
|
937 |
-
'wma' => 'audio/wma',
|
938 |
-
'rtf' => 'application/rtf',
|
939 |
-
'js' => 'application/x-javascript',
|
940 |
-
'pdf' => 'application/pdf',
|
941 |
-
'doc|docx' => 'application/msword',
|
942 |
-
'pot|pps|ppt|pptx' => 'application/vnd.ms-powerpoint',
|
943 |
-
'wri' => 'application/vnd.ms-write',
|
944 |
-
'xla|xls|xlsx|xlt|xlw' => 'application/vnd.ms-excel',
|
945 |
-
'mdb' => 'application/vnd.ms-access',
|
946 |
-
'mpp' => 'application/vnd.ms-project',
|
947 |
-
'swf' => 'application/x-shockwave-flash',
|
948 |
-
'class' => 'application/java',
|
949 |
-
'tar' => 'application/x-tar',
|
950 |
-
'zip' => 'application/zip',
|
951 |
-
'gz|gzip' => 'application/x-gzip',
|
952 |
-
'exe' => 'application/x-msdownload',
|
953 |
-
'odt' => 'application/vnd.oasis.opendocument.text',
|
954 |
-
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
955 |
-
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
956 |
-
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
957 |
-
'odc' => 'application/vnd.oasis.opendocument.chart',
|
958 |
-
'odb' => 'application/vnd.oasis.opendocument.database',
|
959 |
-
'odf' => 'application/vnd.oasis.opendocument.formula'
|
960 |
-
);
|
961 |
|
962 |
$file_ext = strrchr($file, '.');
|
963 |
|
@@ -1026,20 +1021,52 @@ function w3_preg_quote($string, $delimiter = null)
|
|
1026 |
}
|
1027 |
|
1028 |
/**
|
1029 |
-
*
|
1030 |
*
|
1031 |
* @param string $file
|
1032 |
* @return string
|
1033 |
*/
|
1034 |
function w3_normalize_file($file)
|
1035 |
{
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
|
1040 |
return $file;
|
1041 |
}
|
1042 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1043 |
/**
|
1044 |
* Returns true if zlib output compression is enabled otherwise false
|
1045 |
*
|
@@ -1067,6 +1094,48 @@ function w3_stripslashes($var)
|
|
1067 |
return $var;
|
1068 |
}
|
1069 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1070 |
/**
|
1071 |
* Send powered by header
|
1072 |
*/
|
@@ -1084,4 +1153,8 @@ function w3_send_x_powered_by()
|
|
1084 |
@header('X-Powered-By: ' . W3TC_POWERED_BY);
|
1085 |
}
|
1086 |
|
|
|
|
|
|
|
|
|
1087 |
w3_send_x_powered_by();
|
1 |
<?php
|
2 |
|
3 |
+
define('W3TC_VERSION', '0.8.5.2');
|
4 |
define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION);
|
5 |
+
define('W3TC_EMAIL', 'w3tc@w3-edge.com');
|
6 |
define('W3TC_LINK_URL', 'http://www.w3-edge.com/wordpress-plugins/');
|
7 |
define('W3TC_LINK_NAME', 'WordPress Plugins');
|
8 |
+
define('W3TC_FEED_URL', 'http://feeds.feedburner.com/W3TOTALCACHE');
|
9 |
+
define('W3TC_README_URL', 'http://plugins.trac.wordpress.org/browser/w3-total-cache/trunk/readme.txt?format=txt');
|
10 |
+
define('W3TC_TWITTER_STATUS', 'I just optimized my #wordpress blog\'s #performance using the W3 Total Cache #plugin by @w3edge. Check it out! http://j.mp/A69xX');
|
11 |
+
define('W3TC_SUPPORT_US_TIMEOUT', 2592000);
|
12 |
|
13 |
+
define('W3TC_PHP5', PHP_VERSION >= 5);
|
14 |
+
define('W3TC_WIN', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'));
|
|
|
15 |
|
16 |
+
defined('W3TC_DIR') || define('W3TC_DIR', realpath(dirname(__FILE__) . '/..'));
|
17 |
define('W3TC_FILE', 'w3-total-cache/w3-total-cache.php');
|
18 |
define('W3TC_LIB_DIR', W3TC_DIR . '/lib');
|
19 |
define('W3TC_LIB_W3_DIR', W3TC_LIB_DIR . '/W3');
|
22 |
define('W3TC_INSTALL_DIR', W3TC_DIR . '/wp-content');
|
23 |
define('W3TC_INSTALL_MINIFY_DIR', W3TC_INSTALL_DIR . '/w3tc/min');
|
24 |
|
25 |
+
$GLOBALS['w3_reserved_blognames'] = array(
|
26 |
+
'page',
|
27 |
+
'comments',
|
28 |
+
'blog',
|
29 |
+
'wp-admin',
|
30 |
+
'wp-includes',
|
31 |
+
'wp-content',
|
32 |
+
'files',
|
33 |
+
'feed'
|
34 |
+
);
|
35 |
|
36 |
+
define('W3TC_BLOGNAME', w3_get_blogname());
|
37 |
+
define('W3TC_PREFIX', (W3TC_BLOGNAME != '' ? '-' . W3TC_BLOGNAME : ''));
|
38 |
|
39 |
+
defined('WP_CONTENT_DIR') || define('WP_CONTENT_DIR', realpath(W3TC_DIR . '/../..'));
|
40 |
+
define('WP_CONTENT_DIR_NAME', basename(WP_CONTENT_DIR));
|
41 |
+
define('W3TC_CONTENT_DIR_NAME', WP_CONTENT_DIR_NAME . '/w3tc' . W3TC_PREFIX);
|
42 |
define('W3TC_CONTENT_DIR', ABSPATH . W3TC_CONTENT_DIR_NAME);
|
43 |
+
define('W3TC_CONTENT_MINIFY_DIR_NAME', W3TC_CONTENT_DIR_NAME . '/min');
|
44 |
define('W3TC_CONTENT_MINIFY_DIR', ABSPATH . W3TC_CONTENT_DIR_NAME . '/min');
|
45 |
define('W3TC_CACHE_FILE_DBCACHE_DIR', W3TC_CONTENT_DIR . '/dbcache');
|
46 |
define('W3TC_CACHE_FILE_PGCACHE_DIR', W3TC_CONTENT_DIR . '/pgcache');
|
47 |
define('W3TC_CACHE_FILE_MINIFY_DIR', W3TC_CONTENT_DIR . '/min');
|
48 |
define('W3TC_LOG_DIR', W3TC_CONTENT_DIR . '/log');
|
49 |
define('W3TC_TMP_DIR', W3TC_CONTENT_DIR . '/tmp');
|
50 |
+
define('W3TC_CONFIG_PATH', WP_CONTENT_DIR . '/w3-total-cache-config' . W3TC_PREFIX . '.php');
|
51 |
+
define('W3TC_CONFIG_MASTER_PATH', WP_CONTENT_DIR . '/w3-total-cache-config.php');
|
|
|
52 |
define('W3TC_MINIFY_LOG_FILE', W3TC_LOG_DIR . '/minify.log');
|
|
|
53 |
define('W3TC_CDN_COMMAND_UPLOAD', 1);
|
54 |
define('W3TC_CDN_COMMAND_DELETE', 2);
|
55 |
define('W3TC_CDN_TABLE_QUEUE', 'w3tc_cdn_queue');
|
56 |
|
57 |
+
ini_set('pcre.backtrack_limit', 4194304);
|
58 |
+
ini_set('pcre.recursion_limit', 4194304);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
/**
|
61 |
* W3 activate error
|
63 |
* @param string $error
|
64 |
* @return void
|
65 |
*/
|
66 |
+
|
67 |
function w3_activate_error($error)
|
68 |
{
|
69 |
$active_plugins = (array) get_option('active_plugins');
|
105 |
$error = sprintf('<strong>%s</strong> could not be created, please run following command:<br /><strong style="color: #f00;">chmod 777 %s</strong><br />then %s.', $path, dirname($path), $reactivate_button);
|
106 |
}
|
107 |
} else {
|
108 |
+
$error = sprintf('<strong>%s</strong> could not be created, <strong>open_basedir</strong> restriction in effect, please check your php.ini settings:<br /><strong style="color: #f00;">open_basedir = "%s"</strong><br />then %s.', $path, ini_get('open_basedir'), $reactivate_button);
|
109 |
}
|
110 |
|
111 |
w3_activate_error($error);
|
182 |
*/
|
183 |
function w3_mkdir($path, $mask = 0755, $curr_path = '')
|
184 |
{
|
185 |
+
$path = w3_realpath($path);
|
186 |
$path = trim($path, '/');
|
187 |
$dirs = explode('/', $path);
|
188 |
|
261 |
}
|
262 |
|
263 |
/**
|
264 |
+
* Returns true if it's WPMU
|
265 |
+
* @return boolean
|
266 |
+
*/
|
267 |
+
function w3_is_wpmu()
|
268 |
+
{
|
269 |
+
static $wpmu = null;
|
270 |
+
|
271 |
+
if ($wpmu === null) {
|
272 |
+
$wpmu = (w3_is_vhost() || file_exists(ABSPATH . 'wpmu-settings.php'));
|
273 |
+
}
|
274 |
+
|
275 |
+
return $wpmu;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Returns true if WPMU uses vhosts
|
280 |
+
* @return boolean
|
281 |
+
*/
|
282 |
+
function w3_is_vhost()
|
283 |
+
{
|
284 |
+
return (defined('VHOST') && VHOST == 'yes');
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Detect WPMU blogname
|
289 |
*
|
290 |
* @return string
|
291 |
*/
|
292 |
+
function w3_get_blogname()
|
293 |
{
|
294 |
+
static $blogname = null;
|
295 |
|
296 |
+
if ($blogname === null) {
|
297 |
+
if (w3_is_wpmu()) {
|
298 |
+
$domain = w3_get_domain($_SERVER['HTTP_HOST']);
|
299 |
+
|
300 |
+
if (w3_is_vhost()) {
|
301 |
+
$blogname = $domain;
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
} else {
|
303 |
+
$uri = $_SERVER['REQUEST_URI'];
|
304 |
+
$site_path = w3_get_site_path();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
+
if ($site_path != '' && strpos($uri, $site_path) === 0) {
|
307 |
+
$uri = substr_replace($uri, '/', 0, strlen($site_path));
|
308 |
}
|
309 |
|
310 |
+
$blogname = w3_get_blogname_from_uri($uri);
|
|
|
|
|
311 |
|
312 |
+
if ($blogname != '') {
|
313 |
+
$blogname = $blogname . '.' . $domain;
|
314 |
+
} else {
|
315 |
+
$blogname = $domain;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
}
|
317 |
}
|
318 |
+
} else {
|
319 |
+
$blogname = '';
|
320 |
}
|
321 |
}
|
322 |
|
323 |
+
return $blogname;
|
324 |
}
|
325 |
|
326 |
/**
|
327 |
+
* Returns blogname from URI
|
328 |
+
*
|
329 |
+
* @param string $uri
|
330 |
+
* @param string
|
331 |
+
*/
|
332 |
+
function w3_get_blogname_from_uri($uri)
|
333 |
+
{
|
334 |
+
global $w3_reserved_blognames;
|
335 |
+
|
336 |
+
$blogname = '';
|
337 |
+
$matches = null;
|
338 |
+
$uri = strtolower($uri);
|
339 |
+
|
340 |
+
if (preg_match('~^/([a-z0-9-]+)/~', $uri, $matches)) {
|
341 |
+
$blogname = $matches[1];
|
342 |
+
|
343 |
+
if (in_array($blogname, $w3_reserved_blognames) || file_exists($blogname)) {
|
344 |
+
$blogname = '';
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
return $blogname;
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Returns site url
|
353 |
*
|
354 |
* @return string
|
355 |
*/
|
360 |
if ($site_url === null) {
|
361 |
if (function_exists('get_option')) {
|
362 |
$site_url = get_option('siteurl');
|
|
|
363 |
} else {
|
364 |
+
$site_url = sprintf('http://%s%s', $_SERVER['HTTP_HOST'], w3_get_site_path());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
}
|
366 |
+
|
367 |
+
$site_url = rtrim($site_url, '/');
|
368 |
}
|
369 |
|
370 |
return $site_url;
|
406 |
*/
|
407 |
function w3_get_site_path()
|
408 |
{
|
409 |
+
$document_root = w3_get_document_root();
|
410 |
+
$path = str_replace($document_root, '', w3_path(ABSPATH));
|
411 |
+
$path = '/' . ltrim($path, '/');
|
412 |
|
413 |
+
if (substr($path, - 1) != '/') {
|
414 |
+
$path .= '/';
|
415 |
+
}
|
416 |
+
|
417 |
+
return $path;
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Returns blog path
|
422 |
+
*
|
423 |
+
* @return string
|
424 |
+
*/
|
425 |
+
function w3_get_blog_path()
|
426 |
+
{
|
427 |
+
$domain_url = w3_get_domain_url();
|
428 |
+
$site_url = w3_get_site_url();
|
429 |
+
|
430 |
+
$path = str_replace($domain_url, '', $site_url);
|
431 |
+
$path = '/' . ltrim($path, '/');
|
432 |
+
|
433 |
+
if (substr($path, - 1) != '/') {
|
434 |
+
$path .= '/';
|
435 |
+
}
|
436 |
+
|
437 |
+
return $path;
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Returns document root
|
442 |
+
* @return string
|
443 |
+
*/
|
444 |
+
function w3_get_document_root()
|
445 |
+
{
|
446 |
+
static $document_root = null;
|
447 |
+
|
448 |
+
if ($document_root === null) {
|
449 |
+
if (isset($_SERVER['DOCUMENT_ROOT'])) {
|
450 |
+
$document_root = $_SERVER['DOCUMENT_ROOT'];
|
451 |
+
} elseif (isset($_SERVER['SCRIPT_FILENAME'])) {
|
452 |
+
$document_root = substr($_SERVER['SCRIPT_FILENAME'], 0, - strlen($_SERVER['PHP_SELF']));
|
453 |
+
} elseif (isset($_SERVER['PATH_TRANSLATED'])) {
|
454 |
+
$document_root = substr($_SERVER['PATH_TRANSLATED'], 0, - strlen($_SERVER['PHP_SELF']));
|
455 |
+
} else {
|
456 |
+
$document_root = ABSPATH;
|
457 |
}
|
458 |
+
|
459 |
+
$document_root = w3_path($document_root);
|
460 |
}
|
461 |
|
462 |
+
return $document_root;
|
463 |
}
|
464 |
|
465 |
/**
|
473 |
$host = strtolower($host);
|
474 |
|
475 |
if (strpos($host, 'www.') === 0) {
|
476 |
+
$host = substr($host, 4);
|
477 |
}
|
478 |
|
479 |
+
if (($pos = strpos($host, ':')) !== false) {
|
480 |
$host = substr($host, 0, $pos);
|
481 |
}
|
482 |
|
483 |
+
$host = rtrim($host, '.');
|
484 |
+
|
485 |
return $host;
|
486 |
}
|
487 |
|
499 |
$scheme = $parse_url['scheme'];
|
500 |
$host = $parse_url['host'];
|
501 |
$port = (isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '');
|
502 |
+
$domain_url = sprintf('%s://%s%s', $scheme, $host, $port);
|
503 |
|
504 |
return $domain_url;
|
505 |
}
|
534 |
|
535 |
if (empty($upload_info['error'])) {
|
536 |
$site_url = w3_get_site_url();
|
537 |
+
$upload_info['upload_url'] = trim(str_replace($site_url, '', $upload_info['baseurl']), '/');
|
538 |
+
$upload_info['upload_dir'] = trim(str_replace(ABSPATH, '', $upload_info['basedir']), '/');
|
539 |
} else {
|
540 |
$upload_info = false;
|
541 |
}
|
630 |
$engine_name = 'apc';
|
631 |
break;
|
632 |
|
633 |
+
case 'eaccelerator':
|
634 |
+
$engine_name = 'eaccelerator';
|
635 |
+
break;
|
636 |
+
|
637 |
+
case 'xcache':
|
638 |
+
$engine_name = 'xcache';
|
639 |
+
break;
|
640 |
+
|
641 |
case 'file':
|
642 |
$engine_name = 'disk';
|
643 |
break;
|
698 |
*/
|
699 |
function w3_url_request($method, $url, $data = '', $auth = '')
|
700 |
{
|
701 |
+
$status = 0;
|
702 |
$method = strtoupper($method);
|
703 |
|
704 |
+
if (! function_exists('curl_init')) {
|
705 |
$ch = curl_init();
|
706 |
|
707 |
curl_setopt($ch, CURLOPT_URL, $url);
|
708 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
709 |
curl_setopt($ch, CURLOPT_USERAGENT, W3TC_POWERED_BY);
|
710 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
711 |
+
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
|
712 |
|
713 |
if ($method == 'POST') {
|
714 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
721 |
|
722 |
$contents = curl_exec($ch);
|
723 |
|
724 |
+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
725 |
|
726 |
+
curl_close($ch);
|
727 |
} else {
|
728 |
$parse_url = @parse_url($url);
|
729 |
|
734 |
$query = (isset($parse_url['query']) ? $parse_url['query'] : '');
|
735 |
$request_uri = $path . ($query != '' ? '?' . $query : '');
|
736 |
|
737 |
+
$request_headers_array = array(
|
738 |
sprintf('%s %s HTTP/1.1', $method, $request_uri),
|
739 |
sprintf('Host: %s', $host),
|
740 |
sprintf('User-Agent: %s', W3TC_POWERED_BY),
|
742 |
);
|
743 |
|
744 |
if (! empty($data)) {
|
745 |
+
$request_headers_array[] = sprintf('Content-Length: %d', strlen($data));
|
746 |
}
|
747 |
|
748 |
if (! empty($auth)) {
|
749 |
+
$request_headers_array[] = sprintf('Authorization: Basic %s', base64_encode($auth));
|
750 |
}
|
751 |
|
752 |
+
$request_headers = implode("\r\n", $request_headers_array);
|
753 |
+
$request = $request_headers . "\r\n\r\n" . $data;
|
754 |
|
755 |
+
$fp = @fsockopen($host, $port);
|
756 |
+
|
757 |
+
if (! $fp) {
|
758 |
+
return false;
|
759 |
+
}
|
760 |
+
|
761 |
+
$response = '';
|
762 |
+
@fputs($fp, $request);
|
763 |
+
|
764 |
+
while (! @feof($fp)) {
|
765 |
+
$response .= @fgets($fp, 4096);
|
766 |
+
}
|
767 |
+
|
768 |
+
@fclose($fp);
|
769 |
+
|
770 |
+
list ($response_headers, $contents) = explode("\r\n\r\n", $response, 2);
|
771 |
+
|
772 |
+
$matches = null;
|
773 |
+
|
774 |
+
if (preg_match('~^HTTP/1.[01] (\d+)~', $response_headers, $matches)) {
|
775 |
+
$status = (int) $matches[1];
|
776 |
}
|
777 |
}
|
778 |
}
|
779 |
+
|
780 |
+
if ($status == 200) {
|
781 |
+
return $contents;
|
782 |
+
}
|
783 |
+
|
784 |
+
return false;
|
785 |
}
|
786 |
|
787 |
/**
|
808 |
return w3_url_request('POST', $url, $data, $auth);
|
809 |
}
|
810 |
|
811 |
+
/**
|
812 |
+
* Downloads data to a file
|
813 |
+
*
|
814 |
+
* @param string $url
|
815 |
+
* @param string $file
|
816 |
+
* @return boolean
|
817 |
+
*/
|
818 |
+
function w3_download($url, $file)
|
819 |
+
{
|
820 |
+
$data = w3_url_get($url);
|
821 |
+
|
822 |
+
if ($data !== false) {
|
823 |
+
return @file_put_contents($file, $data);
|
824 |
+
}
|
825 |
+
|
826 |
+
return false;
|
827 |
+
}
|
828 |
+
|
829 |
/**
|
830 |
* Loads plugins
|
831 |
*
|
861 |
return false;
|
862 |
}
|
863 |
|
864 |
+
/**
|
865 |
+
* Converts win path to unix
|
866 |
+
* @param string $path
|
867 |
+
* @return string
|
868 |
+
*/
|
869 |
+
function w3_path($path)
|
870 |
+
{
|
871 |
+
$path = preg_replace('~[/\\\]+~', '/', $path);
|
872 |
+
$path = rtrim($path, '/');
|
873 |
+
|
874 |
+
return $path;
|
875 |
+
}
|
876 |
+
|
877 |
/**
|
878 |
* Returns realpath of given path
|
879 |
*
|
881 |
*/
|
882 |
function w3_realpath($path)
|
883 |
{
|
884 |
+
$path = w3_path($path);
|
885 |
$parts = explode('/', $path);
|
886 |
$absolutes = array();
|
887 |
|
944 |
return false;
|
945 |
}
|
946 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
947 |
/**
|
948 |
* Returns file mime type
|
949 |
*
|
952 |
*/
|
953 |
function w3_get_mime_type($file)
|
954 |
{
|
955 |
+
$mime_types = include W3TC_DIR . '/inc/mime.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
956 |
|
957 |
$file_ext = strrchr($file, '.');
|
958 |
|
1021 |
}
|
1022 |
|
1023 |
/**
|
1024 |
+
* Converts file path to relative
|
1025 |
*
|
1026 |
* @param string $file
|
1027 |
* @return string
|
1028 |
*/
|
1029 |
function w3_normalize_file($file)
|
1030 |
{
|
1031 |
+
if (w3_is_url($file)) {
|
1032 |
+
if (strstr($file, '?') === false) {
|
1033 |
+
$domain_url_regexp = '~' . w3_get_domain_url_regexp() . '~i';
|
1034 |
+
$file = preg_replace($domain_url_regexp, '', $file);
|
1035 |
+
}
|
1036 |
+
} else {
|
1037 |
+
$abspath = w3_path(ABSPATH);
|
1038 |
+
$file = w3_path($file);
|
1039 |
+
$file = str_replace($abspath, '', $file);
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
$file = ltrim($file, '/');
|
1043 |
|
1044 |
return $file;
|
1045 |
}
|
1046 |
|
1047 |
+
/**
|
1048 |
+
* Translates URL to local path
|
1049 |
+
* @param string $url
|
1050 |
+
* @return string
|
1051 |
+
*/
|
1052 |
+
function w3_translate_file($url)
|
1053 |
+
{
|
1054 |
+
if (! w3_is_url($url)) {
|
1055 |
+
$url = w3_get_domain_url() . '/' . ltrim($url, '/\\');
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
$site_url_regexp = '~' . w3_get_site_url_regexp() . '~i';
|
1059 |
+
|
1060 |
+
if (preg_match($site_url_regexp, $url) && strstr($url, '?') === false) {
|
1061 |
+
$url = preg_replace($site_url_regexp, '', $url);
|
1062 |
+
$url = w3_get_site_path() . ltrim($url, '/\\');
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
$url = ltrim($url, '/');
|
1066 |
+
|
1067 |
+
return $url;
|
1068 |
+
}
|
1069 |
+
|
1070 |
/**
|
1071 |
* Returns true if zlib output compression is enabled otherwise false
|
1072 |
*
|
1094 |
return $var;
|
1095 |
}
|
1096 |
|
1097 |
+
if (! function_exists('file_put_contents')) {
|
1098 |
+
if (! defined('FILE_APPEND')) {
|
1099 |
+
define('FILE_APPEND', 8);
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
/**
|
1103 |
+
* Puts contents to the file
|
1104 |
+
*
|
1105 |
+
* @param string $filename
|
1106 |
+
* @param string $data
|
1107 |
+
* @param integer $flags
|
1108 |
+
* @return boolean
|
1109 |
+
*/
|
1110 |
+
function file_put_contents($filename, $data, $flags = 0)
|
1111 |
+
{
|
1112 |
+
$fp = fopen($filename, ($flags & FILE_APPEND ? 'a' : 'w'));
|
1113 |
+
|
1114 |
+
if ($fp) {
|
1115 |
+
fputs($fp, $data);
|
1116 |
+
fclose($fp);
|
1117 |
+
|
1118 |
+
return true;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
return false;
|
1122 |
+
}
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
/**
|
1126 |
+
* Cleanup .htaccess rules
|
1127 |
+
* @param string $rules
|
1128 |
+
* @return string
|
1129 |
+
*/
|
1130 |
+
function w3_clean_rules($rules)
|
1131 |
+
{
|
1132 |
+
$rules = preg_replace('~[\r\n]+~', "\n", $rules);
|
1133 |
+
$rules = preg_replace('~^\s+~m', '', $rules);
|
1134 |
+
$rules = trim($rules);
|
1135 |
+
|
1136 |
+
return $rules;
|
1137 |
+
}
|
1138 |
+
|
1139 |
/**
|
1140 |
* Send powered by header
|
1141 |
*/
|
1153 |
@header('X-Powered-By: ' . W3TC_POWERED_BY);
|
1154 |
}
|
1155 |
|
1156 |
+
if (w3_is_wpmu()) {
|
1157 |
+
unset($_GET['sitewide']);
|
1158 |
+
}
|
1159 |
+
|
1160 |
w3_send_x_powered_by();
|
inc/js/lightbox.js
CHANGED
@@ -176,16 +176,20 @@ var Overlay = {
|
|
176 |
|
177 |
function w3tc_lightbox_support_us() {
|
178 |
Lightbox.open( {
|
179 |
-
width:
|
180 |
height: 200,
|
181 |
url: 'options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=support_us',
|
182 |
callback: function(lightbox) {
|
183 |
-
jQuery('.
|
184 |
lightbox.close();
|
185 |
w3tc_lightbox_tweet();
|
186 |
return false;
|
187 |
});
|
188 |
|
|
|
|
|
|
|
|
|
189 |
jQuery('form').submit(function() {
|
190 |
if (jQuery('select :selected', this).val() == '') {
|
191 |
alert('Please select link location!');
|
@@ -240,7 +244,7 @@ function w3tc_lightbox_tweet() {
|
|
240 |
}
|
241 |
|
242 |
jQuery(function($) {
|
243 |
-
$('.
|
244 |
w3tc_lightbox_tweet();
|
245 |
return false;
|
246 |
});
|
176 |
|
177 |
function w3tc_lightbox_support_us() {
|
178 |
Lightbox.open( {
|
179 |
+
width: 590,
|
180 |
height: 200,
|
181 |
url: 'options-general.php?page=w3-total-cache/w3-total-cache.php&w3tc_action=support_us',
|
182 |
callback: function(lightbox) {
|
183 |
+
jQuery('.button-tweet', lightbox.container).click(function(event) {
|
184 |
lightbox.close();
|
185 |
w3tc_lightbox_tweet();
|
186 |
return false;
|
187 |
});
|
188 |
|
189 |
+
jQuery('.button-rating', lightbox.container).click(function() {
|
190 |
+
window.open('http://wordpress.org/extend/plugins/w3-total-cache/', '_blank');
|
191 |
+
});
|
192 |
+
|
193 |
jQuery('form').submit(function() {
|
194 |
if (jQuery('select :selected', this).val() == '') {
|
195 |
alert('Please select link location!');
|
244 |
}
|
245 |
|
246 |
jQuery(function($) {
|
247 |
+
$('.button-tweet').click(function() {
|
248 |
w3tc_lightbox_tweet();
|
249 |
return false;
|
250 |
});
|
inc/js/options.js
CHANGED
@@ -53,16 +53,16 @@ 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] ==
|
60 |
duplicate = true;
|
61 |
break;
|
62 |
}
|
63 |
}
|
64 |
|
65 |
-
js.push(
|
66 |
|
67 |
var qindex = v.indexOf('?');
|
68 |
if (qindex != -1) {
|
@@ -79,16 +79,16 @@ function file_validate() {
|
|
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] ==
|
86 |
duplicate = true;
|
87 |
break;
|
88 |
}
|
89 |
}
|
90 |
|
91 |
-
css.push(
|
92 |
|
93 |
var qindex = v.indexOf('?');
|
94 |
if (qindex != -1) {
|
@@ -252,6 +252,10 @@ jQuery(function($) {
|
|
252 |
});
|
253 |
});
|
254 |
|
|
|
|
|
|
|
|
|
255 |
// minify page
|
256 |
input_enable('.html_enabled', $('#html_enabled:checked').size());
|
257 |
input_enable('.js_enabled', $('#js_enabled:checked').size());
|
@@ -270,8 +274,8 @@ jQuery(function($) {
|
|
270 |
js_file_delete();
|
271 |
css_file_delete();
|
272 |
|
273 |
-
js_group('
|
274 |
-
css_group('
|
275 |
|
276 |
$('#js_file_add').click(function() {
|
277 |
js_file_add($('#js_groups').val(), 'include', '');
|
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(), n = jQuery(this).attr('name'), c = v + n;
|
57 |
if (v != '') {
|
58 |
for ( var i = 0; i < js.length; i++) {
|
59 |
+
if (js[i] == c) {
|
60 |
duplicate = true;
|
61 |
break;
|
62 |
}
|
63 |
}
|
64 |
|
65 |
+
js.push(c);
|
66 |
|
67 |
var qindex = v.indexOf('?');
|
68 |
if (qindex != -1) {
|
79 |
});
|
80 |
|
81 |
jQuery('#css_files :text').each(function() {
|
82 |
+
var v = jQuery(this).val(), n = jQuery(this).attr('name'), c = v + n;
|
83 |
if (v != '') {
|
84 |
for ( var i = 0; i < css.length; i++) {
|
85 |
+
if (css[i] == c) {
|
86 |
duplicate = true;
|
87 |
break;
|
88 |
}
|
89 |
}
|
90 |
|
91 |
+
css.push(c);
|
92 |
|
93 |
var qindex = v.indexOf('?');
|
94 |
if (qindex != -1) {
|
252 |
});
|
253 |
});
|
254 |
|
255 |
+
jQuery('.button-rating').click(function() {
|
256 |
+
window.open('http://wordpress.org/extend/plugins/w3-total-cache/', '_blank');
|
257 |
+
});
|
258 |
+
|
259 |
// minify page
|
260 |
input_enable('.html_enabled', $('#html_enabled:checked').size());
|
261 |
input_enable('.js_enabled', $('#js_enabled:checked').size());
|
274 |
js_file_delete();
|
275 |
css_file_delete();
|
276 |
|
277 |
+
js_group($('#js_groups').val());
|
278 |
+
css_group($('#css_groups').val());
|
279 |
|
280 |
$('#js_file_add').click(function() {
|
281 |
js_file_add($('#js_groups').val(), 'include', '');
|
inc/js/popup.js
CHANGED
@@ -64,7 +64,7 @@ var Cdn_Export_File = {
|
|
64 |
},
|
65 |
|
66 |
clear_log: function() {
|
67 |
-
jQuery('#
|
68 |
},
|
69 |
|
70 |
process: function() {
|
64 |
},
|
65 |
|
66 |
clear_log: function() {
|
67 |
+
jQuery('#cdn_export_file_log').html('');
|
68 |
},
|
69 |
|
70 |
process: function() {
|
inc/lightbox/support_us.phtml
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
<option value="<?php echo $support_id; ?>"><?php echo htmlspecialchars($support_name); ?></option>
|
13 |
<?php endforeach; ?>
|
14 |
</select>
|
15 |
-
</label
|
16 |
</p>
|
17 |
|
18 |
<div style="text-align:center;">
|
12 |
<option value="<?php echo $support_id; ?>"><?php echo htmlspecialchars($support_name); ?></option>
|
13 |
<?php endforeach; ?>
|
14 |
</select>
|
15 |
+
</label>, tell your friends with a <input type="button" class="button button-tweet" value="tweet" /> and give us a great <input type="button" class="button button-rating" value="rating" />.
|
16 |
</p>
|
17 |
|
18 |
<div style="text-align:center;">
|
inc/mime.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
return array(
|
4 |
+
'jpg|jpeg|jpe' => 'image/jpeg',
|
5 |
+
'gif' => 'image/gif',
|
6 |
+
'png' => 'image/png',
|
7 |
+
'bmp' => 'image/bmp',
|
8 |
+
'tif|tiff' => 'image/tiff',
|
9 |
+
'ico' => 'image/x-icon',
|
10 |
+
'asf|asx|wax|wmv|wmx' => 'video/asf',
|
11 |
+
'avi' => 'video/avi',
|
12 |
+
'divx' => 'video/divx',
|
13 |
+
'mov|qt' => 'video/quicktime',
|
14 |
+
'mpeg|mpg|mpe' => 'video/mpeg',
|
15 |
+
'txt|c|cc|h' => 'text/plain',
|
16 |
+
'svg' => 'image/svg+xml',
|
17 |
+
'rtx' => 'text/richtext',
|
18 |
+
'css' => 'text/css',
|
19 |
+
'xsl|xsd|xml' => 'text/xml',
|
20 |
+
'htm|html' => 'text/html',
|
21 |
+
'mp3|m4a' => 'audio/mpeg',
|
22 |
+
'mp4|m4v' => 'video/mp4',
|
23 |
+
'ra|ram' => 'audio/x-realaudio',
|
24 |
+
'wav' => 'audio/wav',
|
25 |
+
'ogg' => 'audio/ogg',
|
26 |
+
'mid|midi' => 'audio/midi',
|
27 |
+
'wma' => 'audio/wma',
|
28 |
+
'rtf' => 'application/rtf',
|
29 |
+
'js' => 'application/x-javascript',
|
30 |
+
'pdf' => 'application/pdf',
|
31 |
+
'doc|docx' => 'application/msword',
|
32 |
+
'pot|pps|ppt|pptx' => 'application/vnd.ms-powerpoint',
|
33 |
+
'wri' => 'application/vnd.ms-write',
|
34 |
+
'xla|xls|xlsx|xlt|xlw' => 'application/vnd.ms-excel',
|
35 |
+
'mdb' => 'application/vnd.ms-access',
|
36 |
+
'mpp' => 'application/vnd.ms-project',
|
37 |
+
'swf' => 'application/x-shockwave-flash',
|
38 |
+
'class' => 'application/java',
|
39 |
+
'tar' => 'application/x-tar',
|
40 |
+
'zip' => 'application/zip',
|
41 |
+
'gz|gzip' => 'application/x-gzip',
|
42 |
+
'exe' => 'application/x-msdownload',
|
43 |
+
'odt' => 'application/vnd.oasis.opendocument.text',
|
44 |
+
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
45 |
+
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
46 |
+
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
47 |
+
'odc' => 'application/vnd.oasis.opendocument.chart',
|
48 |
+
'odb' => 'application/vnd.oasis.opendocument.database',
|
49 |
+
'odf' => 'application/vnd.oasis.opendocument.formula'
|
50 |
+
);
|
inc/options/about.phtml
CHANGED
@@ -3,39 +3,49 @@
|
|
3 |
<div id="about">
|
4 |
<h3>About</h3>
|
5 |
|
6 |
-
<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
|
|
|
7 |
<ul>
|
|
|
8 |
<li>Increased visitor time on site</li>
|
9 |
-
<li>Optimized progressive render (pages appear to
|
10 |
<li>Reduced <acronym title="Hypertext Transfer Protocol">HTTP</acronym> Transactions, <acronym title="Domain Name System">DNS</acronym> lookups and reduced document load time</li>
|
11 |
-
<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
|
12 |
<li>Increased web server concurrency and increased scale (easily sustain high traffic spikes)</li>
|
13 |
<li>Transparent content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) integration with Media Library, theme files and WordPress core</li>
|
14 |
<li>Caching of pages / posts in memory or on disk</li>
|
15 |
<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>
|
16 |
-
<li>Caching of database objects in memory</li>
|
17 |
-
<li>Caching of
|
18 |
<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>
|
19 |
-
<li>Minification of posts / pages and
|
20 |
<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>
|
21 |
<li>Complete header management including <a href="http://en.wikipedia.org/wiki/HTTP_ETag">Etags</a></li>
|
22 |
<li>JavaScript embedding group and location management</li>
|
23 |
<li>Import post attachments directly into the Media Library (and <acronym title="Content Delivery Network">CDN</acronym>)</li>
|
24 |
</ul>
|
25 |
-
|
26 |
-
<p
|
|
|
|
|
|
|
|
|
|
|
27 |
<ul>
|
|
|
28 |
<li><a href="http://mrclay.org/" target="_blank">Steve Clay</a></li>
|
29 |
<li><a href="http://wonko.com/" target="_blank">Ryan Grove</a></li>
|
30 |
<li><a href="http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/" target="_blank">Nicholas Zakas</a> </li>
|
31 |
-
<li><a href="http://stevesouders.com/" target="_blank">Steve Souders</a></li>
|
32 |
<li><a href="http://rtdean.livejournal.com/" target="_blank">Ryan Dean</a></li>
|
33 |
<li><a href="http://gravitonic.com/" target="_blank">Andrei Zmievski</a></li>
|
34 |
<li>George Schlossnagle</li>
|
35 |
<li>Daniel Cowgill</li>
|
36 |
<li><a href="http://toys.lerdorf.com/" target="_blank">Rasmus Lerdorf</a></li>
|
37 |
<li><a href="http://t3.dotgnu.info/" target="_blank">Gopal Vijayaraghavan</a></li>
|
|
|
|
|
38 |
</ul>
|
|
|
39 |
<p>Please reach out to all of these people and support their projects if you're so inclined.</p>
|
40 |
</div>
|
41 |
|
3 |
<div id="about">
|
4 |
<h3>About</h3>
|
5 |
|
6 |
+
<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 opcode caching and the <acronym title="Content Delivery Network">CDN</acronym> of your choosing to provide the following features and benefits:</p>
|
7 |
+
|
8 |
<ul>
|
9 |
+
<li>Improved Google search engine ranking</li>
|
10 |
<li>Increased visitor time on site</li>
|
11 |
+
<li>Optimized progressive render (pages appear to render immediately)</li>
|
12 |
<li>Reduced <acronym title="Hypertext Transfer Protocol">HTTP</acronym> Transactions, <acronym title="Domain Name System">DNS</acronym> lookups and reduced document load time</li>
|
13 |
+
<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 feeds</li>
|
14 |
<li>Increased web server concurrency and increased scale (easily sustain high traffic spikes)</li>
|
15 |
<li>Transparent content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) integration with Media Library, theme files and WordPress core</li>
|
16 |
<li>Caching of pages / posts in memory or on disk</li>
|
17 |
<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>
|
18 |
+
<li>Caching of database objects in memory or disk</li>
|
19 |
+
<li>Caching of feeds (site, categories, tags, comments) in memory or on disk</li>
|
20 |
<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>
|
21 |
+
<li>Minification of posts / pages and feeds</li>
|
22 |
<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>
|
23 |
<li>Complete header management including <a href="http://en.wikipedia.org/wiki/HTTP_ETag">Etags</a></li>
|
24 |
<li>JavaScript embedding group and location management</li>
|
25 |
<li>Import post attachments directly into the Media Library (and <acronym title="Content Delivery Network">CDN</acronym>)</li>
|
26 |
</ul>
|
27 |
+
|
28 |
+
<p>Your users have less data to download, you can now server more visitors at once without upgrading your hardware and you don't have to change how you do anything; just set it and forget it.</p>
|
29 |
+
|
30 |
+
<h4>Who do I thank for all of this?</h4>
|
31 |
+
|
32 |
+
<p>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>
|
33 |
+
|
34 |
<ul>
|
35 |
+
<li><a href="http://stevesouders.com/" target="_blank">Steve Souders</a></li>
|
36 |
<li><a href="http://mrclay.org/" target="_blank">Steve Clay</a></li>
|
37 |
<li><a href="http://wonko.com/" target="_blank">Ryan Grove</a></li>
|
38 |
<li><a href="http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/" target="_blank">Nicholas Zakas</a> </li>
|
|
|
39 |
<li><a href="http://rtdean.livejournal.com/" target="_blank">Ryan Dean</a></li>
|
40 |
<li><a href="http://gravitonic.com/" target="_blank">Andrei Zmievski</a></li>
|
41 |
<li>George Schlossnagle</li>
|
42 |
<li>Daniel Cowgill</li>
|
43 |
<li><a href="http://toys.lerdorf.com/" target="_blank">Rasmus Lerdorf</a></li>
|
44 |
<li><a href="http://t3.dotgnu.info/" target="_blank">Gopal Vijayaraghavan</a></li>
|
45 |
+
<li><a href="http://eaccelerator.net/" target="_blank">Bart Vanbraban</a></li>
|
46 |
+
<li><a href="http://xcache.lighttpd.net/" target="_blank">mOo</a></li>
|
47 |
</ul>
|
48 |
+
|
49 |
<p>Please reach out to all of these people and support their projects if you're so inclined.</p>
|
50 |
</div>
|
51 |
|
inc/options/cdn.phtml
CHANGED
@@ -6,141 +6,176 @@
|
|
6 |
|
7 |
<?php if ($cdn_mirror): ?>
|
8 |
<p>
|
9 |
-
You can
|
|
|
10 |
</p>
|
11 |
<?php else: ?>
|
12 |
<p>
|
13 |
You can <input id="cdn_export_library" class="button" type="button" value="export media library to CDN" />,
|
14 |
-
|
15 |
-
<input id="
|
16 |
-
<input id="
|
17 |
</p>
|
18 |
<?php endif; ?>
|
19 |
|
20 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
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 |
-
<th style="width: 300px;"><label for="cdn_includes_files">wp-includes file types to upload:</label></th>
|
91 |
-
<td>
|
92 |
-
<input id="cdn_includes_files" type="text" name="cdn.includes.files" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.includes.files')); ?>" size="40" /><br />
|
93 |
-
<span class="description">Specify the file types within the WordPress core to host with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
94 |
-
</td>
|
95 |
-
</tr>
|
96 |
-
<tr>
|
97 |
-
<th><label for="cdn_theme_files">Theme file types to upload:</label></th>
|
98 |
-
<td>
|
99 |
-
<input id="cdn_theme_files" type="text" name="cdn.theme.files" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.theme.files')); ?>" size="40" /><br />
|
100 |
-
<span class="description">Specify the file types in the active theme to host with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
101 |
-
</td>
|
102 |
-
</tr>
|
103 |
-
<tr>
|
104 |
-
<th valign="top"><label for="cdn_custom_files">Custom file list:</label></th>
|
105 |
-
<td>
|
106 |
-
<textarea id="cdn_custom_files" name="cdn.custom.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('cdn.custom.files'))); ?></textarea><br />
|
107 |
-
<span class="description">Specify any files outside of theme or other common directories to host with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
108 |
-
</td>
|
109 |
-
</tr>
|
110 |
-
<tr>
|
111 |
-
<th valign="top"><label for="cdn_reject_ua">Rejected user agents:</label></th>
|
112 |
-
<td>
|
113 |
-
<textarea id="cdn_reject_ua" name="cdn.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('cdn.reject.ua'))); ?></textarea><br />
|
114 |
-
<span class="description">Specify user agents that should not access files hosted with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
115 |
-
</td>
|
116 |
-
</tr>
|
117 |
-
<tr>
|
118 |
-
<th valign="top"><label for="cdn_reject_files">Rejected files:</label></th>
|
119 |
-
<td>
|
120 |
-
<textarea id="cdn_reject_files" name="cdn.reject.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('cdn.reject.files'))); ?></textarea><br />
|
121 |
-
<span class="description">Specify the path of files that should not use the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
122 |
-
</td>
|
123 |
-
</tr>
|
124 |
-
<?php if (! $cdn_mirror): ?>
|
125 |
-
<tr>
|
126 |
-
<th colspan="2">
|
127 |
-
<input type="hidden" name="cdn.import.external" value="0" />
|
128 |
-
<label><input type="checkbox" name="cdn.import.external" value="1"<?php checked($this->_config->get_boolean('cdn.import.external'), true); ?> /> Import external media library attachments</label>
|
129 |
-
</th>
|
130 |
-
</tr>
|
131 |
-
<tr>
|
132 |
-
<th><label for="cdn_import_files">File types to import:</label></th>
|
133 |
-
<td>
|
134 |
-
<input id="cdn_import_files" type="text" name="cdn.import.files" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.import.files')); ?>" size="40" /><br />
|
135 |
-
<span class="description">Automatically import files hosted with 3rd parties of these types (if used in your posts / pages) to your media library.</span>
|
136 |
-
</td>
|
137 |
-
</tr>
|
138 |
-
<?php endif; ?>
|
139 |
-
</table>
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
</form>
|
145 |
|
146 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
6 |
|
7 |
<?php if ($cdn_mirror): ?>
|
8 |
<p>
|
9 |
+
You can <input id="cdn_rename_domain" class="button" type="button" value="modify attachment URLs" />,
|
10 |
+
<input id="cdn_import_library" class="button" type="button" value="import attachments into the Media Library" /> 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 |
+
<input id="cdn_import_library" class="button" type="button" value="import attachments into the Media Library" />,
|
16 |
+
<input id="cdn_queue" class="button" type="button" value="view unsuccessful file transfers" /> or
|
17 |
+
<input id="cdn_rename_domain" class="button" type="button" value="modify attachment URLs" /> now.
|
18 |
</p>
|
19 |
<?php endif; ?>
|
20 |
|
21 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
22 |
+
<fieldset id="cdn-general">
|
23 |
+
<legend>General</legend>
|
24 |
+
|
25 |
+
<table class="form-table">
|
26 |
+
<tr>
|
27 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
28 |
+
<input type="hidden" name="cdn.includes.enable" value="0" />
|
29 |
+
<label><input type="checkbox" name="cdn.includes.enable" value="1"<?php checked($this->_config->get_boolean('cdn.includes.enable'), true); ?> /> Host wp-includes/ files</label><br />
|
30 |
+
<span class="description">If checked, WordPress static core file types specified in the "wp-includes file types to upload" field below will be hosted with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
31 |
+
</th>
|
32 |
+
<?php if (! $cdn_mirror): ?>
|
33 |
+
<td>
|
34 |
+
<input class="button cdn_export" type="button" name="includes" value="Upload includes files" />
|
35 |
+
</td>
|
36 |
+
<?php endif; ?>
|
37 |
+
</tr>
|
38 |
+
<tr>
|
39 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
40 |
+
<input type="hidden" name="cdn.theme.enable" value="0" />
|
41 |
+
<label><input type="checkbox" name="cdn.theme.enable" value="1"<?php checked($this->_config->get_boolean('cdn.theme.enable'), true); ?> /> Host active theme files</label><br />
|
42 |
+
<span class="description">If checked, all active theme file types specified in the "theme file types to upload" field below will be hosted with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
43 |
+
</th>
|
44 |
+
<?php if (! $cdn_mirror): ?>
|
45 |
+
<td>
|
46 |
+
<input class="button cdn_export" type="button" name="theme" value="Upload theme files" />
|
47 |
+
</td>
|
48 |
+
<?php endif; ?>
|
49 |
+
</tr>
|
50 |
+
<tr>
|
51 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
52 |
+
<input type="hidden" name="cdn.minify.enable" value="0"<?php if (! W3TC_PHP5 || ! $minify_enabled): ?> disabled="disabled"<?php endif; ?> />
|
53 |
+
<label><input type="checkbox" name="cdn.minify.enable" value="1"<?php checked($this->_config->get_boolean('cdn.minify.enable'), true); ?><?php if (! W3TC_PHP5 || ! $minify_enabled): ?> disabled="disabled"<?php endif; ?> /> Host minified <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files</label><br />
|
54 |
+
<span class="description">If checked, minified <acronym>CSS</acronym> and <acronym>JS</acronym> files will be hosted with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
55 |
+
</th>
|
56 |
+
<?php if (! $cdn_mirror): ?>
|
57 |
+
<td>
|
58 |
+
<input class="button cdn_export" type="button" name="minify" value="Upload minify files"<?php if (! W3TC_PHP5 || ! $minify_enabled): ?> disabled="disabled"<?php endif; ?> />
|
59 |
+
</td>
|
60 |
+
<?php endif; ?>
|
61 |
+
</tr>
|
62 |
+
<tr>
|
63 |
+
<th<?php if ($cdn_mirror): ?> colspan="2"<?php endif; ?>>
|
64 |
+
<input type="hidden" name="cdn.custom.enable" value="0" />
|
65 |
+
<label><input type="checkbox" name="cdn.custom.enable" value="1"<?php checked($this->_config->get_boolean('cdn.custom.enable'), true); ?> /> Host custom files</label><br />
|
66 |
+
<span class="description">If checked, any file names or paths specified in the "custom file list" field below will be hosted with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
67 |
+
</th>
|
68 |
+
<?php if (! $cdn_mirror): ?>
|
69 |
+
<td>
|
70 |
+
<input class="button cdn_export" type="button" name="custom" value="Upload custom files" />
|
71 |
+
</td>
|
72 |
+
<?php endif; ?>
|
73 |
+
</tr>
|
74 |
+
<?php if (! $cdn_mirror): ?>
|
75 |
+
<tr>
|
76 |
+
<th colspan="2">
|
77 |
+
<input type="hidden" name="cdn.force.rewrite" value="0" />
|
78 |
+
<label><input type="checkbox" name="cdn.force.rewrite" value="1"<?php checked($this->_config->get_boolean('cdn.force.rewrite'), true); ?> /> Force over-writing of existing files</label><br />
|
79 |
+
<span class="description">If modified files are not always detected and replaced, use this option to over-write them.</span>
|
80 |
+
</th>
|
81 |
+
</tr>
|
82 |
+
<tr>
|
83 |
+
<th colspan="2">
|
84 |
+
<input type="hidden" name="cdn.import.external" value="0" />
|
85 |
+
<label><input type="checkbox" name="cdn.import.external" value="1"<?php checked($this->_config->get_boolean('cdn.import.external'), true); ?> /> Import external media library attachments</label><br />
|
86 |
+
<span class="description">Download attachments hosted elsewhere into your media library and deliver them via <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
87 |
+
</th>
|
88 |
+
</tr>
|
89 |
+
<?php endif; ?>
|
90 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
+
<p class="submit">
|
93 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
94 |
+
</p>
|
95 |
+
</fieldset>
|
96 |
+
|
97 |
+
<fieldset>
|
98 |
+
<legend>Configuration</legend>
|
99 |
+
|
100 |
+
<table class="form-table">
|
101 |
+
<?php
|
102 |
+
switch ($cdn_engine) {
|
103 |
+
case 'mirror':
|
104 |
+
case 'ftp':
|
105 |
+
case 's3':
|
106 |
+
case 'cf':
|
107 |
+
include W3TC_DIR . '/inc/options/cdn/' . $cdn_engine . '.phtml';
|
108 |
+
break;
|
109 |
+
}
|
110 |
+
?>
|
111 |
+
</table>
|
112 |
+
|
113 |
+
<p class="submit">
|
114 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
115 |
+
</p>
|
116 |
+
</fieldset>
|
117 |
+
|
118 |
+
<fieldset>
|
119 |
+
<legend>Advanced</legend>
|
120 |
+
|
121 |
+
<table class="form-table">
|
122 |
+
<?php if (! $cdn_mirror): ?>
|
123 |
+
<tr>
|
124 |
+
<th><label for="cdn_limit_queue">Re-transfer cycle limit:</label></th>
|
125 |
+
<td>
|
126 |
+
<input id="cdn_limit_queue" type="text" name="cdn.queue.limit" value="<?php echo htmlspecialchars($this->_config->get_integer('cdn.queue.limit')); ?>" size="10" /><br />
|
127 |
+
<span class="description">Number of files processed per upload attempt.</span>
|
128 |
+
</td>
|
129 |
+
</tr>
|
130 |
+
<?php endif; ?>
|
131 |
+
<tr>
|
132 |
+
<th style="width: 300px;"><label for="cdn_includes_files">wp-includes file types to upload:</label></th>
|
133 |
+
<td>
|
134 |
+
<input id="cdn_includes_files" type="text" name="cdn.includes.files" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.includes.files')); ?>" size="100" /><br />
|
135 |
+
<span class="description">Specify the file types within the WordPress core to host with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
136 |
+
</td>
|
137 |
+
</tr>
|
138 |
+
<tr>
|
139 |
+
<th><label for="cdn_theme_files">Theme file types to upload:</label></th>
|
140 |
+
<td>
|
141 |
+
<input id="cdn_theme_files" type="text" name="cdn.theme.files" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.theme.files')); ?>" size="100" /><br />
|
142 |
+
<span class="description">Specify the file types in the active theme to host with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
143 |
+
</td>
|
144 |
+
</tr>
|
145 |
+
<tr>
|
146 |
+
<th><label for="cdn_import_files">File types to import:</label></th>
|
147 |
+
<td>
|
148 |
+
<input id="cdn_import_files" type="text" name="cdn.import.files" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.import.files')); ?>" size="100" /><br />
|
149 |
+
<span class="description">Automatically import files hosted with 3rd parties of these types (if used in your posts / pages) to your media library.</span>
|
150 |
+
</td>
|
151 |
+
</tr>
|
152 |
+
<tr>
|
153 |
+
<th valign="top"><label for="cdn_custom_files">Custom file list:</label></th>
|
154 |
+
<td>
|
155 |
+
<textarea id="cdn_custom_files" name="cdn.custom.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('cdn.custom.files'))); ?></textarea><br />
|
156 |
+
<span class="description">Specify any files outside of theme or other common directories to host with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
157 |
+
</td>
|
158 |
+
</tr>
|
159 |
+
<tr>
|
160 |
+
<th valign="top"><label for="cdn_reject_ua">Rejected user agents:</label></th>
|
161 |
+
<td>
|
162 |
+
<textarea id="cdn_reject_ua" name="cdn.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('cdn.reject.ua'))); ?></textarea><br />
|
163 |
+
<span class="description">Specify user agents that should not access files hosted with the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
164 |
+
</td>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<th valign="top"><label for="cdn_reject_files">Rejected files:</label></th>
|
168 |
+
<td>
|
169 |
+
<textarea id="cdn_reject_files" name="cdn.reject.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('cdn.reject.files'))); ?></textarea><br />
|
170 |
+
<span class="description">Specify the path of files that should not use the <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
171 |
+
</td>
|
172 |
+
</tr>
|
173 |
+
</table>
|
174 |
+
|
175 |
+
<p class="submit">
|
176 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
177 |
+
</p>
|
178 |
+
</fieldset>
|
179 |
</form>
|
180 |
|
181 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
inc/options/cdn/cf.phtml
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
<table class="form-table">
|
2 |
<tr>
|
3 |
<th style="width:300px;"><label for="cdn_cf_key">Access key:</label></th>
|
4 |
<td>
|
@@ -20,14 +19,12 @@
|
|
20 |
</td>
|
21 |
</tr>
|
22 |
<tr>
|
23 |
-
<th><label for="cdn_cf_id">Replace
|
24 |
<td>
|
25 |
<input id="cdn_cf_id" type="text" name="cdn.cf.id" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.cf.id')); ?>" size="18" style="text-align:right;" />.cloudfront.net or <label for="cdn_cf_cname">CNAME:</label> <input id="cdn_cf_cname" type="text" name="cdn.cf.cname" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.cf.cname')); ?>" size="30" /><br />
|
26 |
<span class="description">If you have already added a <a href="http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?CNAMEs.html" target="_blank">CNAME</a> to your <acronym title="Domain Name System">DNS</acronym> Zone, enter it here.</span>
|
27 |
</td>
|
28 |
</tr>
|
29 |
-
|
30 |
-
<
|
31 |
-
|
32 |
-
<span id="test_cf_status" class="w3tc-status w3tc-process"></span>
|
33 |
-
</p>
|
|
|
1 |
<tr>
|
2 |
<th style="width:300px;"><label for="cdn_cf_key">Access key:</label></th>
|
3 |
<td>
|
19 |
</td>
|
20 |
</tr>
|
21 |
<tr>
|
22 |
+
<th><label for="cdn_cf_id">Replace site's hostname with:</label></th>
|
23 |
<td>
|
24 |
<input id="cdn_cf_id" type="text" name="cdn.cf.id" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.cf.id')); ?>" size="18" style="text-align:right;" />.cloudfront.net or <label for="cdn_cf_cname">CNAME:</label> <input id="cdn_cf_cname" type="text" name="cdn.cf.cname" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.cf.cname')); ?>" size="30" /><br />
|
25 |
<span class="description">If you have already added a <a href="http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?CNAMEs.html" target="_blank">CNAME</a> to your <acronym title="Domain Name System">DNS</acronym> Zone, enter it here.</span>
|
26 |
</td>
|
27 |
</tr>
|
28 |
+
<tr>
|
29 |
+
<th colspan="2"><input id="test_cf" class="button" type="button" value="Test CloudFront upload" /> <span id="test_cf_status" class="w3tc-status w3tc-process"></span></th>
|
30 |
+
</tr>
|
|
|
|
inc/options/cdn/ftp.phtml
CHANGED
@@ -1,8 +1,15 @@
|
|
1 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<tr>
|
3 |
<th style="width:300px;"><label for="cdn_ftp_host"><acronym title="File Transfer Protocol">FTP</acronym> hostname:</label></th>
|
4 |
<td>
|
5 |
-
<input id="cdn_ftp_host" type="text" name="cdn.ftp.host" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.ftp.host')); ?>" size="30" />
|
|
|
6 |
</td>
|
7 |
</tr>
|
8 |
<tr>
|
@@ -25,19 +32,12 @@
|
|
25 |
</td>
|
26 |
</tr>
|
27 |
<tr>
|
28 |
-
<th
|
29 |
-
<input type="hidden" name="cdn.ftp.pasv" value="0" />
|
30 |
-
<label><input type="checkbox" name="cdn.ftp.pasv" value="1"<?php checked($this->_config->get_boolean('cdn.ftp.pasv'), true); ?> /> Use passive <acronym title="File Transfer Protocol">FTP</acronym> mode</label>
|
31 |
-
</th>
|
32 |
-
</tr>
|
33 |
-
<tr>
|
34 |
-
<th><label for="cdn_ftp_domain">Replace default hostname with:</label></th>
|
35 |
<td>
|
36 |
<input id="cdn_ftp_domain" type="text" name="cdn.ftp.domain" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.ftp.domain')); ?>" size="30" /><br />
|
37 |
<span class="description">Enter the hostname of your FTP server configured above, this value will replace your blog's hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.</span>
|
38 |
</td>
|
39 |
</tr>
|
40 |
-
|
41 |
-
<
|
42 |
-
|
43 |
-
</p>
|
1 |
+
<tr>
|
2 |
+
<th colspan="2">
|
3 |
+
<input type="hidden" name="cdn.ftp.pasv" value="0" />
|
4 |
+
<label><input id="cdn_ftp_pasv" type="checkbox" name="cdn.ftp.pasv" value="1"<?php checked($this->_config->get_boolean('cdn.ftp.pasv'), true); ?> /> Use passive <acronym title="File Transfer Protocol">FTP</acronym> mode</label><br />
|
5 |
+
<span class="description">Enable this option only if there are connectivity issues, otherwise it's not recommended.</span>
|
6 |
+
</th>
|
7 |
+
</tr>
|
8 |
<tr>
|
9 |
<th style="width:300px;"><label for="cdn_ftp_host"><acronym title="File Transfer Protocol">FTP</acronym> hostname:</label></th>
|
10 |
<td>
|
11 |
+
<input id="cdn_ftp_host" type="text" name="cdn.ftp.host" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.ftp.host')); ?>" size="30" /><br />
|
12 |
+
<span class="description">Specify the server's address, e.g.: "ftp.domain.com". Use "127.0.0.1" if using a sub-domain on the same server as your site.</span>
|
13 |
</td>
|
14 |
</tr>
|
15 |
<tr>
|
32 |
</td>
|
33 |
</tr>
|
34 |
<tr>
|
35 |
+
<th><label for="cdn_ftp_domain">Replace site's hostname with:</label></th>
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
<td>
|
37 |
<input id="cdn_ftp_domain" type="text" name="cdn.ftp.domain" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.ftp.domain')); ?>" size="30" /><br />
|
38 |
<span class="description">Enter the hostname of your FTP server configured above, this value will replace your blog's hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.</span>
|
39 |
</td>
|
40 |
</tr>
|
41 |
+
<tr>
|
42 |
+
<th colspan="2"><input id="test_ftp" class="button" type="button" value="Test FTP server" /> <span id="test_ftp_status" class="w3tc-status w3tc-process"></span></th>
|
43 |
+
</tr>
|
|
inc/options/cdn/mirror.phtml
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
-
<table class="form-table">
|
2 |
<tr>
|
3 |
-
<th style="width:300px;"><label for="cdn_mirror_domain">Replace
|
4 |
<td>
|
5 |
<input id="cdn_mirror_domain" type="text" name="cdn.mirror.domain" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.mirror.domain')); ?>" size="30" /><br />
|
6 |
-
<span class="description">Enter the hostname provided by your <acronym>CDN</acronym> provider, this value will replace your
|
7 |
</td>
|
8 |
-
</tr>
|
9 |
-
</table>
|
|
|
1 |
<tr>
|
2 |
+
<th style="width:300px;"><label for="cdn_mirror_domain">Replace site's hostname with:</label></th>
|
3 |
<td>
|
4 |
<input id="cdn_mirror_domain" type="text" name="cdn.mirror.domain" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.mirror.domain')); ?>" size="30" /><br />
|
5 |
+
<span class="description">Enter the hostname provided by your <acronym>CDN</acronym> provider, this value will replace your site's hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.</span>
|
6 |
</td>
|
7 |
+
</tr>
|
|
inc/options/cdn/s3.phtml
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
<table class="form-table">
|
2 |
<tr>
|
3 |
<th style="width:300px;"><label for="cdn_s3_key">Access key:</label></th>
|
4 |
<td>
|
@@ -20,7 +19,7 @@
|
|
20 |
</td>
|
21 |
</tr>
|
22 |
<tr>
|
23 |
-
<th>Replace
|
24 |
<td>
|
25 |
<?php if (($cdn_s3_bucket = $this->_config->get_string('cdn.s3.bucket')) != ''): ?>
|
26 |
<?php echo htmlspecialchars($cdn_s3_bucket); ?>.s3.amazonaws.com
|
@@ -29,8 +28,6 @@
|
|
29 |
<?php endif; ?>
|
30 |
</td>
|
31 |
</tr>
|
32 |
-
|
33 |
-
<
|
34 |
-
|
35 |
-
<span id="test_s3_status" class="w3tc-status w3tc-process"></span>
|
36 |
-
</p>
|
|
|
1 |
<tr>
|
2 |
<th style="width:300px;"><label for="cdn_s3_key">Access key:</label></th>
|
3 |
<td>
|
19 |
</td>
|
20 |
</tr>
|
21 |
<tr>
|
22 |
+
<th>Replace site's hostname with:</th>
|
23 |
<td>
|
24 |
<?php if (($cdn_s3_bucket = $this->_config->get_string('cdn.s3.bucket')) != ''): ?>
|
25 |
<?php echo htmlspecialchars($cdn_s3_bucket); ?>.s3.amazonaws.com
|
28 |
<?php endif; ?>
|
29 |
</td>
|
30 |
</tr>
|
31 |
+
<tr>
|
32 |
+
<th><input id="test_s3" class="button" type="button" value="Test S3 upload" /> <span id="test_s3_status" class="w3tc-status w3tc-process"></span></th>
|
33 |
+
</tr>
|
|
|
|
inc/options/common/header.phtml
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
<?php if ($this->_support_reminder): ?>
|
2 |
<script type="text/javascript">
|
3 |
/*<![CDATA[*/
|
1 |
+
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/w3-total-cache/inc/js/options.js"></script>
|
2 |
+
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/w3-total-cache/inc/js/lightbox.js"></script>
|
3 |
<?php if ($this->_support_reminder): ?>
|
4 |
<script type="text/javascript">
|
5 |
/*<![CDATA[*/
|
inc/options/dbcache.phtml
CHANGED
@@ -12,49 +12,64 @@
|
|
12 |
</form>
|
13 |
|
14 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
<tr>
|
28 |
-
<th style="width: 250px;"><label for="dbcache_lifetime">Maximum lifetime of cache objects:</label></th>
|
29 |
-
<td><input id="dbcache_lifetime" type="text" name="dbcache.lifetime" value="<?php echo $this->_config->get_integer('dbcache.lifetime'); ?>" size="8" /> seconds
|
30 |
-
<br /><span class="description">Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.</span>
|
31 |
-
</td>
|
32 |
-
</tr>
|
33 |
-
<tr>
|
34 |
-
<th><label for="dbcache_file_gc">Garbage collection interval:</label></th>
|
35 |
-
<td><input id="dbcache_file_gc" type="text" name="dbcache.file.gc" value="<?php echo $this->_config->get_integer('dbcache.file.gc'); ?>" size="8" /> seconds
|
36 |
-
<br /><span class="description">If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.</span>
|
37 |
-
</td>
|
38 |
-
</tr>
|
39 |
-
<tr>
|
40 |
-
<th colspan="2">
|
41 |
-
<input type="hidden" name="dbcache.reject.logged" value="0" />
|
42 |
-
<label><input type="checkbox" name="dbcache.reject.logged" value="1"<?php checked($this->_config->get_boolean('dbcache.reject.logged'), true); ?> /> Don't cache queries for logged in users</label>
|
43 |
-
<br /><span class="description">Enabling this option is recommended to allow default WordPress behavior.</span>
|
44 |
-
</th>
|
45 |
-
</tr>
|
46 |
-
<tr>
|
47 |
-
<th valign="top"><label for="dbcache_reject_sql">Ignored query stems:</label></th>
|
48 |
-
<td>
|
49 |
-
<textarea id="dbcache_reject_sql" name="dbcache.reject.sql" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('dbcache.reject.sql'))); ?></textarea><br />
|
50 |
-
<span class="description">Do not cache queries that contain these input contents. The entered prefix (set in wp-config.php) will be replaced with current database prefix (default: wp_).</span>
|
51 |
-
</td>
|
52 |
-
</tr>
|
53 |
-
</table>
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
</form>
|
59 |
|
60 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
12 |
</form>
|
13 |
|
14 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
15 |
+
<fieldset>
|
16 |
+
<legend>General</legend>
|
17 |
+
|
18 |
+
<table class="form-table">
|
19 |
+
<tr>
|
20 |
+
<th colspan="2">
|
21 |
+
<input type="hidden" name="dbcache.reject.logged" value="0" />
|
22 |
+
<label><input type="checkbox" name="dbcache.reject.logged" value="1"<?php checked($this->_config->get_boolean('dbcache.reject.logged'), true); ?> /> Don't cache queries for logged in users</label>
|
23 |
+
<br /><span class="description">Enabling this option is recommended to allow default WordPress behavior.</span>
|
24 |
+
</th>
|
25 |
+
</tr>
|
26 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
<p class="submit">
|
29 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
30 |
+
</p>
|
31 |
+
</fieldset>
|
32 |
+
|
33 |
+
<fieldset>
|
34 |
+
<legend>Advanced</legend>
|
35 |
+
|
36 |
+
<table class="form-table">
|
37 |
+
<?php if ($this->_config->get_string('dbcache.engine') == 'memcached'): ?>
|
38 |
+
<tr>
|
39 |
+
<th><label for="memcached_servers">Memcached hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:</label></th>
|
40 |
+
<td>
|
41 |
+
<input id="memcached_servers" type="text" name="dbcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $this->_config->get_array('dbcache.memcached.servers'))); ?>" size="100" />
|
42 |
+
<input id="test_memcached" class="button" type="button" value="Test" />
|
43 |
+
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
44 |
+
<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>
|
45 |
+
</td>
|
46 |
+
</tr>
|
47 |
+
<?php endif; ?>
|
48 |
+
<tr>
|
49 |
+
<th style="width: 250px;"><label for="dbcache_lifetime">Maximum lifetime of cache objects:</label></th>
|
50 |
+
<td><input id="dbcache_lifetime" type="text" name="dbcache.lifetime" value="<?php echo $this->_config->get_integer('dbcache.lifetime'); ?>" size="8" /> seconds
|
51 |
+
<br /><span class="description">Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.</span>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
<tr>
|
55 |
+
<th><label for="dbcache_file_gc">Garbage collection interval:</label></th>
|
56 |
+
<td><input id="dbcache_file_gc" type="text" name="dbcache.file.gc" value="<?php echo $this->_config->get_integer('dbcache.file.gc'); ?>" size="8" /> seconds
|
57 |
+
<br /><span class="description">If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.</span>
|
58 |
+
</td>
|
59 |
+
</tr>
|
60 |
+
<tr>
|
61 |
+
<th valign="top"><label for="dbcache_reject_sql">Ignored query stems:</label></th>
|
62 |
+
<td>
|
63 |
+
<textarea id="dbcache_reject_sql" name="dbcache.reject.sql" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('dbcache.reject.sql'))); ?></textarea><br />
|
64 |
+
<span class="description">Do not cache queries that contain these terms. Any entered prefix (set in wp-config.php) will be replaced with current database prefix (default: wp_).</span>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
</table>
|
68 |
+
|
69 |
+
<p class="submit">
|
70 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
71 |
+
</p>
|
72 |
+
</fieldset>
|
73 |
</form>
|
74 |
|
75 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
inc/options/faq.phtml
CHANGED
@@ -27,7 +27,7 @@
|
|
27 |
<li><a href="#q16">I understand the database caching and the page caching, but what's minify all about?</a></li>
|
28 |
<li><a href="#q17">What do you use to minify?</a></li>
|
29 |
<li><a href="#q18">What's the point of downloading and caching 3rd party files (e.g. <acronym title="JavaScript">JS</acronym>)?</a></li>
|
30 |
-
|
31 |
<li><a href="#q20">Will this plugin break my theme by changing the order of conditional statements or the like?</a></li>
|
32 |
<li><a href="#q21">Will this speed up <acronym title="WordPress">WP</acronym> Admin?</a></li>
|
33 |
<li><a href="#q22">Does this plugin modify how the WordPress core works?</a></li>
|
@@ -39,7 +39,7 @@
|
|
39 |
<li><a href="#q28">Ok I get it, this all sounds nice and everything, but is this perfect?</a></li>
|
40 |
<li><a href="#q29">Seriously, tell me what the downside is, there must be something?</a></li>
|
41 |
<li><a href="#q30">If this plugin does everything you claim, why would you give it away free? Cui Bono?</a></li>
|
42 |
-
<li><a href="#q31">Who in the world uses memcached or
|
43 |
<li><a href="#q32">I don't understand what a <acronym title="Content Delivery Network">CDN</acronym> has to do with caching, that's completely different, no?</a></li>
|
44 |
<li><a href="#q33">We run many blogs on many servers here at my company, is this plugin still for me?</a></li>
|
45 |
<li><a href="#q34">So you appear to know what you're talking about, will there be any negative effect on my SEO rankings?</a></li>
|
@@ -77,7 +77,7 @@
|
|
77 |
<li><a href="#q59">What's this thing doing? Where are the statistics?</a></li>
|
78 |
<li><a href="#q60">How can I tell if it's working? Aren't there any statistics at all?</a></li>
|
79 |
<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>
|
80 |
-
<li><a href="#q62">Which features can I use if I haven't yet installed
|
81 |
<li><a href="#q63">How can I host my favicon with my <acronym title="Content Delivery Network">CDN</acronym>?</a></li>
|
82 |
<li><a href="#q64">Why do you set the value of the media attribute of <link> to all?</a></li>
|
83 |
<li><a href="#q65">Why can't I specify other <script> types or encoding?</a></li>
|
@@ -99,6 +99,10 @@
|
|
99 |
<li><a href="#q97">I see garbage characters instead of the normal web site, what's going on here?</a></li>
|
100 |
<li><a href="#q98">What is the purpose of the "Media Library Import" tool and how do I use it?</a></li>
|
101 |
<li><a href="#q99">I'm getting blank pages or 500 error codes when trying to upgrade on WordPress MU</a></li>
|
|
|
|
|
|
|
|
|
102 |
</ul>
|
103 |
</li>
|
104 |
<li class="col">
|
@@ -108,7 +112,7 @@
|
|
108 |
<li><a href="#q79">Do I need to enable mod_gzip, mod_rewrite or install any <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression software on my server?</a></li>
|
109 |
<li><a href="#q80">Is this plugin compatible with varnish or squid?</a></li>
|
110 |
<li><a href="#q81">My server is state of the art with 15,000 <acronym title="Rotations per Minute">RPM</acronym> <acronym title="Redundant Array of Independent Disks">RAID</acronym>, why do I need to cache anything in memory?</a></li>
|
111 |
-
<li><a href="#q82">Why would I choose
|
112 |
<li><a href="#q83">I already use <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression on my server, why does it matter if I minify my code?</a></li>
|
113 |
<li><a href="#q84">How much memory (<acronym title="Random Access Memory">RAM</acronym>) do I need to delegate to caching?</a></li>
|
114 |
<li><a href="#q85">What version of <acronym title="Hypertext Preprocessor">PHP</acronym> do I need for this thing?</a></li>
|
@@ -150,8 +154,8 @@
|
|
150 |
<li>Bandwidth savings via <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression (<acronym title="GNU zip">gzip</acronym> / deflate) for <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym></li>
|
151 |
<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>
|
152 |
<li>Optional embedding of <acronym title="JavaScript">JS</acronym> just above </body></li>
|
153 |
-
<li>Support for caching pages, posts, feeds, database objects, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> in memory with
|
154 |
-
<li>Caching of
|
155 |
<li>Complete header management including Etags</li>
|
156 |
<li>Increased web server concurrency and reduced resource consumption, increased scale</li>
|
157 |
</ul>
|
@@ -199,17 +203,16 @@
|
|
199 |
<li><a href="http://www.procata.com/cachetest/" target="_blank">Web Caching Tests</a></li>
|
200 |
<li><a href="http://www.port80software.com/tools/compresscheck.asp" target="_blank">Port80 Compression Check</a> (minify requires <acronym title="Microsoft Internet Explorer">MSIE</acronym>6 support to be enabled)</li>
|
201 |
<li><a href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">A simple online web page compression / deflate / <acronym title="GNU zip">gzip</acronym> test tool</a></li>
|
202 |
-
<li><a href="http://www.websiteoptimization.com/services/analyze/" target="_blank">Web Page Analyzer</a></li>
|
203 |
</ul>
|
204 |
<p align="right"><a href="#toc">back to top</a></p>
|
205 |
<p id="q13"><strong>Does this plugin work with WordPress <acronym title="Multi-User">MU</acronym>?</strong><br />
|
206 |
Indeed it does.</p>
|
207 |
<p align="right"><a href="#toc">back to top</a></p>
|
208 |
<p id="q14"><strong>Does this plugin work with BuddyPress (bbPress)?</strong><br />
|
209 |
-
|
210 |
<p align="right"><a href="#toc">back to top</a></p>
|
211 |
<p id="q15"><strong>Which WordPress versions are supported?</strong><br />
|
212 |
-
To use all features in the suite, a minimum version of 2.
|
213 |
<p align="right"><a href="#toc">back to top</a></p>
|
214 |
<p id="q16"><strong>I understand the database caching and the page caching, but what's minify all about?</strong><br />
|
215 |
We'll just quote the fine folks at yahoo on this one:</p>
|
@@ -225,9 +228,11 @@
|
|
225 |
<p id="q18"><strong>What's the point of downloading and caching 3rd party files (e.g. <acronym title="JavaScript">JS</acronym>)?</strong><br />
|
226 |
With the various hosted 3rd party applications available (from web site statistics to social media sharing widgets), the problems we've noticed are: additional <acronym title="Hypertext Transfer Protocol">HTTP</acronym> transactions, <acronym title="Domain Name System">DNS</acronym> lookups and latencies from busy servers that we can't control and often un-minified files with no <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression all add up to a very slow page load and poor user experience. With your own copy of external files, updated as frequently as you wish, none of these problems exist.</p>
|
227 |
<p align="right"><a href="#toc">back to top</a></p>
|
|
|
228 |
<p id="q19"><strong>Will you support other memory or </strong><a href="http://en.wikipedia.org/wiki/PHP_accelerator" target="_blank"><strong>opcode caches</strong></a><strong>?</strong><br />
|
229 |
Possibly, we just <a href="mailto:wordpressexperts@w3-edge.com">need to know which</a> others are popular in the WordPress community and we will address them.</p>
|
230 |
<p align="right"><a href="#toc">back to top</a></p>
|
|
|
231 |
<p id="q20"><strong>Will this plugin break my theme by changing the order of conditional statements or the like?</strong><br />
|
232 |
No, the plugin looks for conditional statements in your markup used for <acronym title="Cascading Style Sheet">CSS</acronym> (and sometimes <acronym title="JavaScript">JS</acronym>) and makes sure that the minified files precede it, so keep that in mind.</p>
|
233 |
<p align="right"><a href="#toc">back to top</a></p>
|
@@ -266,7 +271,7 @@
|
|
266 |
<li><a href="http://code.google.com/speed/articles/" target="_blank">Google</a> and <a href="http://developer.yahoo.com/yui/" target="_blank">Yahoo</a> offer quite a bit, but they did not offer a WordPress solution yet. This is our contribution to speeding up the web (starting with the blogosphere).</li>
|
267 |
</ul>
|
268 |
<p align="right"><a href="#toc">back to top</a></p>
|
269 |
-
<p id="q31"><strong>Who in the world uses memcached or
|
270 |
Great question! Basically anyone that needs to make their application scale. For example, <a href="http://www.wordpress.com/" target="_blank">WordPress.com</a>, <a href="http://twitter.com" target="_blank">Twitter</a>, <a href="http://www.facebook.com/" target="_blank">Facebook</a>, LiveJournal (the inventors of the software) and so on all use some sort of memory cache to increase application performance.</p>
|
271 |
<p align="right"><a href="#toc">back to top</a></p>
|
272 |
<p id="q32"><strong>I don't understand what a <acronym title="Content Delivery Network">CDN</acronym> has to do with caching, that's completely different, no?</strong><br />
|
@@ -300,23 +305,25 @@
|
|
300 |
<p id="q41"><strong>Who do I thank for all of this?</strong><br />
|
301 |
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>
|
302 |
<ul>
|
|
|
303 |
<li><a href="http://mrclay.org/" target="_blank">Steve Clay</a></li>
|
304 |
<li><a href="http://wonko.com/" target="_blank">Ryan Grove</a></li>
|
305 |
<li><a href="http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/" target="_blank">Nicholas Zakas</a> </li>
|
306 |
-
<li><a href="http://stevesouders.com/" target="_blank">Steve Souders</a></li>
|
307 |
<li><a href="http://rtdean.livejournal.com/" target="_blank">Ryan Dean</a></li>
|
308 |
<li><a href="http://gravitonic.com/" target="_blank">Andrei Zmievski</a></li>
|
309 |
<li>George Schlossnagle</li>
|
310 |
<li>Daniel Cowgill</li>
|
311 |
<li><a href="http://toys.lerdorf.com/" target="_blank">Rasmus Lerdorf</a></li>
|
312 |
<li><a href="http://t3.dotgnu.info/" target="_blank">Gopal Vijayaraghavan</a></li>
|
|
|
|
|
313 |
</ul>
|
314 |
<p>Please reach out to all of these people and support their projects if you're so inclined.</p>
|
315 |
<p align="right"><a href="#toc">back to top</a></p>
|
316 |
<p id="q42"><strong>How do I find the <acronym title="JavaScript">JS</acronym> and <acronym title="Cascading Style Sheet">CSS</acronym> to optimize (minify) them with this plugin?</strong><br />
|
317 |
View your page source in your browser and search for any <style>, <link> or <script> tags that contain external <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> files and one by one add them to the minify settings page. Do not include any <acronym title="Cascading Style Sheet">CSS</acronym> in conditional statements (unless you know what you are doing) like:</p>
|
318 |
<p><!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="/wp-content/themes/default/lte.css" media="screen,projection" /><![endif]--></p>
|
319 |
-
<p>The plugin will
|
320 |
<p align="right"><a href="#toc">back to top</a></p>
|
321 |
<p id="q43"><strong>I've used the plugin to optimize all my theme's <acronym title="JavaScript">JS</acronym> and plugins <acronym title="JavaScript">JS</acronym>, but there are some function calls, where do those go?</strong><br />
|
322 |
Just place them above </head> if that's where your embed is done or above </body> if that's where you need them. Wherever they need to be to be called after the <acronym title="JavaScript">JS</acronym> that needs them, it'll be fine.</p>
|
@@ -331,7 +338,7 @@
|
|
331 |
<p>Now go to the General Settings tab and click the checkbox and save the settings to enable <acronym title="Content Delivery Network">CDN</acronym> functionality and empty the cache for the changes to take effect.</p>
|
332 |
<p align="right"><a href="#toc">back to top</a></p>
|
333 |
<p id="q94"><strong>How do I use an Origin Pull (Mirror) <acronym title="Content Delivery Network">CDN</acronym>?</strong><br />
|
334 |
-
Login to your <acronym title="Content Delivery Network">CDN</acronym> providers control panel or account management area. Following any set up steps they provide, create a new "pull zone" or "bucket" for your site's domain name. If there's a set up wizard or any troubleshooting tips your provider offers, be sure to review them. In the <acronym title="Content Delivery Network">CDN</acronym> Settings tab of the plugin, enter the hostname your <acronym title="Content Delivery Network">CDN</acronym> provider provided in the "replace
|
335 |
<p>Now go to the General Settings tab and click the checkbox and save the settings to enable <acronym title="Content Delivery Network">CDN</acronym> functionality and empty the cache for the changes to take effect.</p>
|
336 |
<p align="right"><a href="#toc">back to top</a></p>
|
337 |
<p id="q45"><strong>In the past, I always had to modify my theme to run dynamic code. Don't I need to do that again for this plugin?</strong><br />
|
@@ -388,7 +395,7 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
388 |
<p id="q61"><strong>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?</strong><br />
|
389 |
On the minify settings tab, use the drop-down selection menu to define the <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> files that appear on all pages using the "Default" group first. Then specify unie files for the other pages.</p>
|
390 |
<p align="right"><a href="#toc">back to top</a></p>
|
391 |
-
<p id="q62"><strong>Which features can I use if I haven't yet installed
|
392 |
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.</p>
|
393 |
<p align="right"><a href="#toc">back to top</a></p>
|
394 |
<p id="q63"><strong>How can I host my favicon with my <acronym title="Content Delivery Network">CDN</acronym>?</strong><br />
|
@@ -400,15 +407,23 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
400 |
<p id="q65"><strong>Why can't I specify other <script> types or encoding?</strong><br />
|
401 |
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>
|
402 |
<p align="right"><a href="#toc">back to top</a></p>
|
403 |
-
<p id="q66"><strong>My theme doesn't call wp_footer(), how do I set this plugin up?</strong><br />
|
404 |
-
|
405 |
<ul>
|
406 |
-
<li><?php if (function_exists('
|
407 |
-
Inserts the
|
408 |
-
<li><?php if (function_exists('w3tc_scripts'))
|
409 |
-
Inserts the
|
410 |
-
<li><?php if (function_exists('w3tc_scripts'))
|
411 |
-
Inserts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
</ul>
|
413 |
<p align="right"><a href="#toc">back to top</a></p>
|
414 |
<p id="q67"><strong>Is this plugin compatible with other popular caching plugins?</strong><br />
|
@@ -438,17 +453,15 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
438 |
<p id="q75"><strong>Who do you recommend as a <acronym title="Content Delivery Network">CDN</acronym> provider?</strong><br />
|
439 |
That depends on how you use your blog and where most of your readers read your blog (regionally). Here's a short list:</p>
|
440 |
<ul>
|
441 |
-
<li><a href="http://
|
442 |
-
<li><a href="http://
|
443 |
-
<li><a href="http://
|
444 |
-
<li><a href="
|
445 |
-
<li><a href="http://
|
446 |
-
<li><a href="http://
|
447 |
-
<li><a href="http://
|
448 |
-
<li><a href="http://
|
449 |
-
<li><a href="http://
|
450 |
-
<li><a href="http://www.simplecdn.com/" target="_blank">Simple<acronym title="Content Delivery Network">CDN</acronym></a></li>
|
451 |
-
<li><a href="http://www.voxel.net/products-services/voxcast-cdn" target="_blank">Voxel</a></li>
|
452 |
</ul>
|
453 |
<p align="right"><a href="#toc">back to top</a></p>
|
454 |
<p id="q76"><strong>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>?</strong><br />
|
@@ -464,7 +477,7 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
464 |
Yes. Follow these steps:</p>
|
465 |
<ol>
|
466 |
<li>Enable dynamic loading of ratings by checking GD Star Rating -> Settings -> Features "Cache support option"</li>
|
467 |
-
<li>If Database cache enabled in W3 Total Cache add "wp_gdsr" to "Ignored query stems"
|
468 |
<li>Empty all caches</li>
|
469 |
</ol>
|
470 |
<p align="right"><a href="#toc">back to top</a></p>
|
@@ -482,6 +495,29 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
482 |
<p id="q99"><strong>I'm getting blank pages or 500 error codes when trying to upgrade on WordPress MU</strong><br />
|
483 |
First, make sure the plugin is not active (disabled) site-wide. Then make sure it's deactivated site-wide. Now you should be able to successful upgrade without breaking your site.</p>
|
484 |
<p align="right"><a href="#toc">back to top</a></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
<p id="q78"><strong>Which web servers do you support?</strong><br />
|
486 |
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>
|
487 |
<p align="right"><a href="#toc">back to top</a></p>
|
@@ -495,20 +531,20 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
495 |
<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 />
|
496 |
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>
|
497 |
<p align="right"><a href="#toc">back to top</a></p>
|
498 |
-
<p id="q82"><strong>Why would I choose
|
499 |
-
There's no straight answer for this one. Since WordPress is a PHP-based application, we encourage everyone to install
|
500 |
-
<p
|
501 |
<ul>
|
502 |
<li>If you frequently restart your web server (e.g. apache) especially during high traffic periods, you will lose your cache and your site will slow down as it rebuilds the cache (which happens very quickly). However if you use memcached you would not lose your cache if your web server is restarted.</li>
|
503 |
-
<li>More importantly,
|
504 |
</ul>
|
505 |
-
<p>It would appear that using <acronym title="Alternative PHP Cache">APC</acronym>
|
506 |
<p align="right"><a href="#toc">back to top</a></p>
|
507 |
<p id="q83"><strong>I already use <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression on my server, why does it matter if I minify my code?</strong><br />
|
508 |
Let's say you had a file of 10240 bytes, which becomes 2048 bytes when compressed, savings of ~80% (typical for <acronym title="Cascading Style Sheet">CSS</acronym> files). That same file will now have an <strong>additional</strong> ~3x-10x transfer speed improvement when minified. That's a big return from a small operation. The larger your files, the more significant the proportional performance gains.</p>
|
509 |
<p align="right"><a href="#toc">back to top</a></p>
|
510 |
<p id="q84"><strong>How much memory (<acronym title="Random Access Memory">RAM</acronym>) do I need to delegate to caching?</strong><br />
|
511 |
-
Probably the hardest question of all. At the time of this writing the default WordPress install and theme will consume about 50MB of memory in an
|
512 |
<ul>
|
513 |
<li>Number of typically requested pages per day (if your blog is popular this number is quite large)</li>
|
514 |
<li>Size of minified <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> and <acronym title="Hypertext Markup Language">HTML</acronym> pages (smaller is better)</li>
|
@@ -519,7 +555,7 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
519 |
<p>For those that don't want or have time to learn anything new to get started, sample configuration files are included with the plugin containing inline comments for you.</p>
|
520 |
<p align="right"><a href="#toc">back to top</a></p>
|
521 |
<p id="q85"><strong>What version of <acronym title="Hypertext Preprocessor">PHP</acronym> do I need for this thing?</strong><br />
|
522 |
-
Version 4.3 is supported for some modules, however version 5 preferred (it's much much faster especially with
|
523 |
<p align="right"><a href="#toc">back to top</a></p>
|
524 |
<p id="q86"><strong>What version of mySQL is needed?</strong><br />
|
525 |
If your WordPress installation is works, you're all set.</p>
|
@@ -537,7 +573,7 @@ No, you can drag and drop them into the desired order on the minify settings pag
|
|
537 |
</strong>Yes.</p>
|
538 |
<p align="right"><a href="#toc">back to top</a></p>
|
539 |
<p id="q91"><strong>What is the intended impact of this plugin on the web hosting landscape?</strong><br />
|
540 |
-
We feel that shared or virtual hosting providers will begin offering secure containers (similar to what <a href="http://mediatemple.net/" target="_blank">mediatemple.net</a> does for mySQL and Ruby etc) for
|
541 |
<p>One day hopefully this plugin will contribute to making web servers greener and reduce the ecological footprint of the web by reducing the computational effort required to deliver high performance rich user experiences.</p>
|
542 |
<p align="right"><a href="#toc">back to top</a></p>
|
543 |
</div>
|
27 |
<li><a href="#q16">I understand the database caching and the page caching, but what's minify all about?</a></li>
|
28 |
<li><a href="#q17">What do you use to minify?</a></li>
|
29 |
<li><a href="#q18">What's the point of downloading and caching 3rd party files (e.g. <acronym title="JavaScript">JS</acronym>)?</a></li>
|
30 |
+
<!--<li><a href="#q19">Will you support other memory or opcode caches</a>?</li>-->
|
31 |
<li><a href="#q20">Will this plugin break my theme by changing the order of conditional statements or the like?</a></li>
|
32 |
<li><a href="#q21">Will this speed up <acronym title="WordPress">WP</acronym> Admin?</a></li>
|
33 |
<li><a href="#q22">Does this plugin modify how the WordPress core works?</a></li>
|
39 |
<li><a href="#q28">Ok I get it, this all sounds nice and everything, but is this perfect?</a></li>
|
40 |
<li><a href="#q29">Seriously, tell me what the downside is, there must be something?</a></li>
|
41 |
<li><a href="#q30">If this plugin does everything you claim, why would you give it away free? Cui Bono?</a></li>
|
42 |
+
<li><a href="#q31">Who in the world uses memcached or opcode caching etc anyway?</a></li>
|
43 |
<li><a href="#q32">I don't understand what a <acronym title="Content Delivery Network">CDN</acronym> has to do with caching, that's completely different, no?</a></li>
|
44 |
<li><a href="#q33">We run many blogs on many servers here at my company, is this plugin still for me?</a></li>
|
45 |
<li><a href="#q34">So you appear to know what you're talking about, will there be any negative effect on my SEO rankings?</a></li>
|
77 |
<li><a href="#q59">What's this thing doing? Where are the statistics?</a></li>
|
78 |
<li><a href="#q60">How can I tell if it's working? Aren't there any statistics at all?</a></li>
|
79 |
<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>
|
80 |
+
<li><a href="#q62">Which features can I use if I haven't yet installed an opcode cache or memcached?</a></li>
|
81 |
<li><a href="#q63">How can I host my favicon with my <acronym title="Content Delivery Network">CDN</acronym>?</a></li>
|
82 |
<li><a href="#q64">Why do you set the value of the media attribute of <link> to all?</a></li>
|
83 |
<li><a href="#q65">Why can't I specify other <script> types or encoding?</a></li>
|
99 |
<li><a href="#q97">I see garbage characters instead of the normal web site, what's going on here?</a></li>
|
100 |
<li><a href="#q98">What is the purpose of the "Media Library Import" tool and how do I use it?</a></li>
|
101 |
<li><a href="#q99">I'm getting blank pages or 500 error codes when trying to upgrade on WordPress MU</a></li>
|
102 |
+
<li><a href="#q100">How can I embed the minified CSS file at the location I choose?</a></li>
|
103 |
+
<li><a href="#q101">Is this plugin comptatible with TDO Mini Forms?</a></li>
|
104 |
+
<li><a href="#q102">My YSlow score is low because doesn't recognize my <acronym title="Content Delivery Network">CDN</acronym>, what can I do?</a></li>
|
105 |
+
<li><a href="#q103">What is the purpose of the "modify attachment <acronym title="Uniform Resource Indicator">URL</acronym>s" button?</a></li>
|
106 |
</ul>
|
107 |
</li>
|
108 |
<li class="col">
|
112 |
<li><a href="#q79">Do I need to enable mod_gzip, mod_rewrite or install any <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression software on my server?</a></li>
|
113 |
<li><a href="#q80">Is this plugin compatible with varnish or squid?</a></li>
|
114 |
<li><a href="#q81">My server is state of the art with 15,000 <acronym title="Rotations per Minute">RPM</acronym> <acronym title="Redundant Array of Independent Disks">RAID</acronym>, why do I need to cache anything in memory?</a></li>
|
115 |
+
<li><a href="#q82">Why would I choose an opcode cache over memcached or vice versa?</a></li>
|
116 |
<li><a href="#q83">I already use <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression on my server, why does it matter if I minify my code?</a></li>
|
117 |
<li><a href="#q84">How much memory (<acronym title="Random Access Memory">RAM</acronym>) do I need to delegate to caching?</a></li>
|
118 |
<li><a href="#q85">What version of <acronym title="Hypertext Preprocessor">PHP</acronym> do I need for this thing?</a></li>
|
154 |
<li>Bandwidth savings via <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression (<acronym title="GNU zip">gzip</acronym> / deflate) for <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym></li>
|
155 |
<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>
|
156 |
<li>Optional embedding of <acronym title="JavaScript">JS</acronym> just above </body></li>
|
157 |
+
<li>Support for caching pages, posts, feeds, database objects, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> in memory with an opcode cache or memcached or both</li>
|
158 |
+
<li>Caching of 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>
|
159 |
<li>Complete header management including Etags</li>
|
160 |
<li>Increased web server concurrency and reduced resource consumption, increased scale</li>
|
161 |
</ul>
|
203 |
<li><a href="http://www.procata.com/cachetest/" target="_blank">Web Caching Tests</a></li>
|
204 |
<li><a href="http://www.port80software.com/tools/compresscheck.asp" target="_blank">Port80 Compression Check</a> (minify requires <acronym title="Microsoft Internet Explorer">MSIE</acronym>6 support to be enabled)</li>
|
205 |
<li><a href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">A simple online web page compression / deflate / <acronym title="GNU zip">gzip</acronym> test tool</a></li>
|
|
|
206 |
</ul>
|
207 |
<p align="right"><a href="#toc">back to top</a></p>
|
208 |
<p id="q13"><strong>Does this plugin work with WordPress <acronym title="Multi-User">MU</acronym>?</strong><br />
|
209 |
Indeed it does.</p>
|
210 |
<p align="right"><a href="#toc">back to top</a></p>
|
211 |
<p id="q14"><strong>Does this plugin work with BuddyPress (bbPress)?</strong><br />
|
212 |
+
Yes.</p>
|
213 |
<p align="right"><a href="#toc">back to top</a></p>
|
214 |
<p id="q15"><strong>Which WordPress versions are supported?</strong><br />
|
215 |
+
To use all features in the suite, a minimum version of 2.6 is required. Earlier versions will benefit from our Media Library Importer to get them back on the upgrade path and into a <acronym title="Content Delivery Network">CDN</acronym> of their choosing.</p>
|
216 |
<p align="right"><a href="#toc">back to top</a></p>
|
217 |
<p id="q16"><strong>I understand the database caching and the page caching, but what's minify all about?</strong><br />
|
218 |
We'll just quote the fine folks at yahoo on this one:</p>
|
228 |
<p id="q18"><strong>What's the point of downloading and caching 3rd party files (e.g. <acronym title="JavaScript">JS</acronym>)?</strong><br />
|
229 |
With the various hosted 3rd party applications available (from web site statistics to social media sharing widgets), the problems we've noticed are: additional <acronym title="Hypertext Transfer Protocol">HTTP</acronym> transactions, <acronym title="Domain Name System">DNS</acronym> lookups and latencies from busy servers that we can't control and often un-minified files with no <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression all add up to a very slow page load and poor user experience. With your own copy of external files, updated as frequently as you wish, none of these problems exist.</p>
|
230 |
<p align="right"><a href="#toc">back to top</a></p>
|
231 |
+
<!--
|
232 |
<p id="q19"><strong>Will you support other memory or </strong><a href="http://en.wikipedia.org/wiki/PHP_accelerator" target="_blank"><strong>opcode caches</strong></a><strong>?</strong><br />
|
233 |
Possibly, we just <a href="mailto:wordpressexperts@w3-edge.com">need to know which</a> others are popular in the WordPress community and we will address them.</p>
|
234 |
<p align="right"><a href="#toc">back to top</a></p>
|
235 |
+
-->
|
236 |
<p id="q20"><strong>Will this plugin break my theme by changing the order of conditional statements or the like?</strong><br />
|
237 |
No, the plugin looks for conditional statements in your markup used for <acronym title="Cascading Style Sheet">CSS</acronym> (and sometimes <acronym title="JavaScript">JS</acronym>) and makes sure that the minified files precede it, so keep that in mind.</p>
|
238 |
<p align="right"><a href="#toc">back to top</a></p>
|
271 |
<li><a href="http://code.google.com/speed/articles/" target="_blank">Google</a> and <a href="http://developer.yahoo.com/yui/" target="_blank">Yahoo</a> offer quite a bit, but they did not offer a WordPress solution yet. This is our contribution to speeding up the web (starting with the blogosphere).</li>
|
272 |
</ul>
|
273 |
<p align="right"><a href="#toc">back to top</a></p>
|
274 |
+
<p id="q31"><strong>Who in the world uses memcached or an opcode cache etc anyway?</strong><br />
|
275 |
Great question! Basically anyone that needs to make their application scale. For example, <a href="http://www.wordpress.com/" target="_blank">WordPress.com</a>, <a href="http://twitter.com" target="_blank">Twitter</a>, <a href="http://www.facebook.com/" target="_blank">Facebook</a>, LiveJournal (the inventors of the software) and so on all use some sort of memory cache to increase application performance.</p>
|
276 |
<p align="right"><a href="#toc">back to top</a></p>
|
277 |
<p id="q32"><strong>I don't understand what a <acronym title="Content Delivery Network">CDN</acronym> has to do with caching, that's completely different, no?</strong><br />
|
305 |
<p id="q41"><strong>Who do I thank for all of this?</strong><br />
|
306 |
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>
|
307 |
<ul>
|
308 |
+
<li><a href="http://stevesouders.com/" target="_blank">Steve Souders</a></li>
|
309 |
<li><a href="http://mrclay.org/" target="_blank">Steve Clay</a></li>
|
310 |
<li><a href="http://wonko.com/" target="_blank">Ryan Grove</a></li>
|
311 |
<li><a href="http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/" target="_blank">Nicholas Zakas</a> </li>
|
|
|
312 |
<li><a href="http://rtdean.livejournal.com/" target="_blank">Ryan Dean</a></li>
|
313 |
<li><a href="http://gravitonic.com/" target="_blank">Andrei Zmievski</a></li>
|
314 |
<li>George Schlossnagle</li>
|
315 |
<li>Daniel Cowgill</li>
|
316 |
<li><a href="http://toys.lerdorf.com/" target="_blank">Rasmus Lerdorf</a></li>
|
317 |
<li><a href="http://t3.dotgnu.info/" target="_blank">Gopal Vijayaraghavan</a></li>
|
318 |
+
<li><a href="http://eaccelerator.net/" target="_blank">Bart Vanbraban</a></li>
|
319 |
+
<li><a href="http://xcache.lighttpd.net/" target="_blank">mOo</a></li>
|
320 |
</ul>
|
321 |
<p>Please reach out to all of these people and support their projects if you're so inclined.</p>
|
322 |
<p align="right"><a href="#toc">back to top</a></p>
|
323 |
<p id="q42"><strong>How do I find the <acronym title="JavaScript">JS</acronym> and <acronym title="Cascading Style Sheet">CSS</acronym> to optimize (minify) them with this plugin?</strong><br />
|
324 |
View your page source in your browser and search for any <style>, <link> or <script> tags that contain external <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> files and one by one add them to the minify settings page. Do not include any <acronym title="Cascading Style Sheet">CSS</acronym> in conditional statements (unless you know what you are doing) like:</p>
|
325 |
<p><!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="/wp-content/themes/default/lte.css" media="screen,projection" /><![endif]--></p>
|
326 |
+
<p>The plugin will combine, minify, <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compress and check for updates to these files automatically from now on. If you have any <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> that are inline consider making them external files so that you can use them with minify.</p>
|
327 |
<p align="right"><a href="#toc">back to top</a></p>
|
328 |
<p id="q43"><strong>I've used the plugin to optimize all my theme's <acronym title="JavaScript">JS</acronym> and plugins <acronym title="JavaScript">JS</acronym>, but there are some function calls, where do those go?</strong><br />
|
329 |
Just place them above </head> if that's where your embed is done or above </body> if that's where you need them. Wherever they need to be to be called after the <acronym title="JavaScript">JS</acronym> that needs them, it'll be fine.</p>
|
338 |
<p>Now go to the General Settings tab and click the checkbox and save the settings to enable <acronym title="Content Delivery Network">CDN</acronym> functionality and empty the cache for the changes to take effect.</p>
|
339 |
<p align="right"><a href="#toc">back to top</a></p>
|
340 |
<p id="q94"><strong>How do I use an Origin Pull (Mirror) <acronym title="Content Delivery Network">CDN</acronym>?</strong><br />
|
341 |
+
Login to your <acronym title="Content Delivery Network">CDN</acronym> providers control panel or account management area. Following any set up steps they provide, create a new "pull zone" or "bucket" for your site's domain name. If there's a set up wizard or any troubleshooting tips your provider offers, be sure to review them. In the <acronym title="Content Delivery Network">CDN</acronym> Settings tab of the plugin, enter the hostname your <acronym title="Content Delivery Network">CDN</acronym> provider provided in the "replace site's hostname with" field. You should always do a quick check by opening a test file from the <acronym title="Content Delivery Network">CDN</acronym> hostname, e.g. http://cdn.domain.com/favicon.ico. Troubleshoot with yoru <acronym title="Content Delivery Network">CDN</acronym> provider until this test is successful.</p>
|
342 |
<p>Now go to the General Settings tab and click the checkbox and save the settings to enable <acronym title="Content Delivery Network">CDN</acronym> functionality and empty the cache for the changes to take effect.</p>
|
343 |
<p align="right"><a href="#toc">back to top</a></p>
|
344 |
<p id="q45"><strong>In the past, I always had to modify my theme to run dynamic code. Don't I need to do that again for this plugin?</strong><br />
|
395 |
<p id="q61"><strong>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?</strong><br />
|
396 |
On the minify settings tab, use the drop-down selection menu to define the <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym title="JavaScript">JS</acronym> files that appear on all pages using the "Default" group first. Then specify unie files for the other pages.</p>
|
397 |
<p align="right"><a href="#toc">back to top</a></p>
|
398 |
+
<p id="q62"><strong>Which features can I use if I haven't yet installed an opcode cache or memcached?</strong><br />
|
399 |
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.</p>
|
400 |
<p align="right"><a href="#toc">back to top</a></p>
|
401 |
<p id="q63"><strong>How can I host my favicon with my <acronym title="Content Delivery Network">CDN</acronym>?</strong><br />
|
407 |
<p id="q65"><strong>Why can't I specify other <script> types or encoding?</strong><br />
|
408 |
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>
|
409 |
<p align="right"><a href="#toc">back to top</a></p>
|
410 |
+
<p id="q66"><strong>My theme doesn't call wp_footer() or wp_head(), how do I set this plugin up?</strong><br />
|
411 |
+
You'll need to manually update your theme to include your <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> minify groups. The calls you'll want to make for the various cases are:</p>
|
412 |
<ul>
|
413 |
+
<li><?php if (function_exists('w3tc_styles')): w3tc_styles('include'); endif; ?><br />
|
414 |
+
Inserts the <head> <acronym title="Cascading Style Sheet">CSS</acronym> group at the location you choose. Multiple occurrences are allowed.</li>
|
415 |
+
<li><?php if (function_exists('w3tc_scripts')): w3tc_scripts('include'); endif; ?><br />
|
416 |
+
Inserts the <head> blocking <acronym title="JavaScript">JS</acronym> group at the location you choose.</li>
|
417 |
+
<li><?php if (function_exists('w3tc_scripts')): w3tc_scripts('include-nb'); endif; ?><br />
|
418 |
+
Inserts the <head> non-blocking <acronym title="JavaScript">JS</acronym> groups at the location you choose.</li>
|
419 |
+
<li><?php if (function_exists('w3tc_scripts')): w3tc_scripts('include');w3tc_scripts('include-nb'); endif; ?><br />
|
420 |
+
Inserts both the blocking and non-blocking <head> <acronym title="JavaScript">JS</acronym> group at the location you choose.</li>
|
421 |
+
<li><?php if (function_exists('w3tc_scripts')): w3tc_scripts('include-footer'); endif; ?><br />
|
422 |
+
Inserts the footer <acronym title="JavaScript">JS</acronym> group at the location you choose.</li>
|
423 |
+
<li><?php if (function_exists('w3tc_scripts')): w3tc_scripts('include-footer-nb'); endif; ?><br />
|
424 |
+
Inserts the footer non-blocking <acronym title="JavaScript">JS</acronym> group at the location you choose.</li>
|
425 |
+
<li><?php if (function_exists('w3tc_scripts')): w3tc_scripts('include-footer');w3tc_scripts('include-footer-nb'); endif; ?><br />
|
426 |
+
Inserts both the blocking and non-blocking <acronym title="JavaScript">JS</acronym> groups at the location you choose.</li>
|
427 |
</ul>
|
428 |
<p align="right"><a href="#toc">back to top</a></p>
|
429 |
<p id="q67"><strong>Is this plugin compatible with other popular caching plugins?</strong><br />
|
453 |
<p id="q75"><strong>Who do you recommend as a <acronym title="Content Delivery Network">CDN</acronym> provider?</strong><br />
|
454 |
That depends on how you use your blog and where most of your readers read your blog (regionally). Here's a short list:</p>
|
455 |
<ul>
|
456 |
+
<li><a href="http://bit.ly/acaXXt" target="_blank">MaxCDN</a></li>
|
457 |
+
<li><a href="http://bit.ly/9hpX8T" target="_blank">Rackspace Cloud Files</a></li>
|
458 |
+
<li><a href="http://bit.ly/bnVs0a" target="_blank">Cotendo</a></li>
|
459 |
+
<li><a href="http://bit.ly/d5hfFt" target="_blank">VPS NET</a></li>
|
460 |
+
<li><a href="http://bit.ly/ao1sGt" target="_blank">Cloudfront</a></li>
|
461 |
+
<li><a href="http://bit.ly/bIjSWC" target="_blank">EdgeCast</a></li>
|
462 |
+
<li><a href="http://bit.ly/a5GBLV" target="_blank">Akamai</a></li>
|
463 |
+
<li><a href="http://bit.ly/aCW04j" target="_blank">Limelight Networks</a></li>
|
464 |
+
<li><a href="http://bit.ly/93EAKK" target="_blank">Simple<acronym title="Content Delivery Network">CDN</acronym></a></li>
|
|
|
|
|
465 |
</ul>
|
466 |
<p align="right"><a href="#toc">back to top</a></p>
|
467 |
<p id="q76"><strong>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>?</strong><br />
|
477 |
Yes. Follow these steps:</p>
|
478 |
<ol>
|
479 |
<li>Enable dynamic loading of ratings by checking GD Star Rating -> Settings -> Features "Cache support option"</li>
|
480 |
+
<li>If Database cache enabled in W3 Total Cache add "wp_gdsr" to "Ignored query stems" field in the Database Cache settings tab, otherwise ratings will not updated after voting</li>
|
481 |
<li>Empty all caches</li>
|
482 |
</ol>
|
483 |
<p align="right"><a href="#toc">back to top</a></p>
|
495 |
<p id="q99"><strong>I'm getting blank pages or 500 error codes when trying to upgrade on WordPress MU</strong><br />
|
496 |
First, make sure the plugin is not active (disabled) site-wide. Then make sure it's deactivated site-wide. Now you should be able to successful upgrade without breaking your site.</p>
|
497 |
<p align="right"><a href="#toc">back to top</a></p>
|
498 |
+
<p id="q100"><strong>How can I embed the minified CSS file at the location I choose?</strong></p>
|
499 |
+
<ul>
|
500 |
+
<li><?php if (function_exists('w3tc_styles')){w3tc_styles('include');} ?><br />
|
501 |
+
Inserts the minified CSS files at the location you specify in your theme. More than one instance per template is ok; e.g. embedding in multiple conditional statements.</li>
|
502 |
+
</ul>
|
503 |
+
<p align="right"><a href="#toc">back to top</a></p>
|
504 |
+
<p id="q101"><strong>Is this plugin comptatible with TDO Mini Forms?</strong><br />
|
505 |
+
Captcha and recaptcha will work fine, however you will need to prevent any pages with forms from being cached. Add the page's URI to the "Never cache the following pages" box on the Page Cache Settings tab.</p>
|
506 |
+
<p align="right"><a href="#toc">back to top</a></p>
|
507 |
+
<p id="q102"><strong>My YSlow score is low because it doesn't recognize my <acronym title="Content Delivery Network">CDN</acronym>, what can I do?</strong><br />
|
508 |
+
Rule 2 says to use a content delivery network (<acronym title="Content Delivery Network">CDN</acronym>). The score for this rule is computed by checking the hostname of each component against the list of known <acronym title="Content Delivery Network">CDN</acronym>s. Unfortunately, the list of "known <acronym title="Content Delivery Network">CDN</acronym>s" are the ones used by Yahoo!. Most likely these are not relevant to your web site, except for potentially yui.yahooapis.com. If you want an accurate score for your web site, you can add your <acronym title="Content Delivery Network">CDN</acronym> hostnames to YSlow using Firefox's preferences. Here are the steps to follow:</p>
|
509 |
+
<ul>
|
510 |
+
<li>Go to about:config in Firefox. You'll see the current list of preferences.</li>
|
511 |
+
<li>Right-click in the window and choose New and String to create a new string preference.</li>
|
512 |
+
<li>Enter extensions.yslow.cdnHostnames for the preference name.</li>
|
513 |
+
<li>For the string value, enter the hostname of your <acronym title="Content Delivery Network">CDN</acronym>, for example, mycdn.com. Do not use quotes. If you have multiple <acronym title="Content Delivery Network">CDN</acronym> hostnames, separate them with commas.</li>
|
514 |
+
</ul>
|
515 |
+
<p>If you specify <acronym title="Content Delivery Network">CDN</acronym> hostnames in your preferences, they'll be shown under the details for Rule 2 in the Performance view.</p>
|
516 |
+
<p align="right"><a href="#toc">back to top</a></p>
|
517 |
+
<p id="q103"><strong>What is the purpose of the "modify attachment <acronym title="Uniform Resource Indicator">URL</acronym>s" button?</strong><br />
|
518 |
+
If the domain name of your site has changed, this tool is useful in updating your posts and pages to use the current addresses. For example, if your site used to be www.domain.com, and you decided to change it to domain.com, the result would either be many "broken" images or many unncessary redirects (which slow down the visitor's browsing experience). You can use this tool to correct this and similar cases. Correcting the <acronym title="Uniform Resource Indicator">URL</acronym>s of your images also allows the plugin to do a better job of determining which images are actually hosted with the <acronym title="Content Delivery Network">CDN</acronym></p>
|
519 |
+
<p>As always, it never hurts to back up your database first.</p>
|
520 |
+
<p align="right"><a href="#toc">back to top</a></p>
|
521 |
<p id="q78"><strong>Which web servers do you support?</strong><br />
|
522 |
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>
|
523 |
<p align="right"><a href="#toc">back to top</a></p>
|
531 |
<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 />
|
532 |
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>
|
533 |
<p align="right"><a href="#toc">back to top</a></p>
|
534 |
+
<p id="q82"><strong>Why would I choose opcode caching over memcached or vice versa?</strong><br />
|
535 |
+
There's no straight answer for this one. Since WordPress is a PHP-based application, we encourage everyone to install an opcode cache and realize a minimum of 10x performance gain. It will obviously make our plugin faster as well, so again please check out the installation instructions if you do not already use an opcode cache. Once installed, you can select an opcode cache as the method and get back to blogging.</p>
|
536 |
+
<p>Opcode caching does have a couple weaknesses:</p>
|
537 |
<ul>
|
538 |
<li>If you frequently restart your web server (e.g. apache) especially during high traffic periods, you will lose your cache and your site will slow down as it rebuilds the cache (which happens very quickly). However if you use memcached you would not lose your cache if your web server is restarted.</li>
|
539 |
+
<li>More importantly, opcode caching is best suited for single server environments because the cache is only accessible to the local server, it cannot be shared with other servers in a multi-server (cluster) environment.</li>
|
540 |
</ul>
|
541 |
+
<p>It would appear that using <acronym title="Alternative PHP Cache">APC</acronym> database caching, but your mileage may vary. So depending on what software you install and how you manage your server, you can choose the options to fit your needs. If you need help with the install on your dedicated or virtual dedicated linux-based server ask us!</p>
|
542 |
<p align="right"><a href="#toc">back to top</a></p>
|
543 |
<p id="q83"><strong>I already use <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression on my server, why does it matter if I minify my code?</strong><br />
|
544 |
Let's say you had a file of 10240 bytes, which becomes 2048 bytes when compressed, savings of ~80% (typical for <acronym title="Cascading Style Sheet">CSS</acronym> files). That same file will now have an <strong>additional</strong> ~3x-10x transfer speed improvement when minified. That's a big return from a small operation. The larger your files, the more significant the proportional performance gains.</p>
|
545 |
<p align="right"><a href="#toc">back to top</a></p>
|
546 |
<p id="q84"><strong>How much memory (<acronym title="Random Access Memory">RAM</acronym>) do I need to delegate to caching?</strong><br />
|
547 |
+
Probably the hardest question of all. At the time of this writing the default WordPress install and theme will consume about 50MB of memory in an opcode cache while running our plugin. Keep in mind that the following factors will determine the minimum size of your cache beyond this noted 50MB:</p>
|
548 |
<ul>
|
549 |
<li>Number of typically requested pages per day (if your blog is popular this number is quite large)</li>
|
550 |
<li>Size of minified <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> and <acronym title="Hypertext Markup Language">HTML</acronym> pages (smaller is better)</li>
|
555 |
<p>For those that don't want or have time to learn anything new to get started, sample configuration files are included with the plugin containing inline comments for you.</p>
|
556 |
<p align="right"><a href="#toc">back to top</a></p>
|
557 |
<p id="q85"><strong>What version of <acronym title="Hypertext Preprocessor">PHP</acronym> do I need for this thing?</strong><br />
|
558 |
+
Version 4.3 is supported for some modules, however version 5 preferred (it's much much faster especially with an opcode cache). It is likely version 3.0 of WordPress will no longer support <acronym title="Hypertext Preprocessor">PHP</acronym> 4.3.</p>
|
559 |
<p align="right"><a href="#toc">back to top</a></p>
|
560 |
<p id="q86"><strong>What version of mySQL is needed?</strong><br />
|
561 |
If your WordPress installation is works, you're all set.</p>
|
573 |
</strong>Yes.</p>
|
574 |
<p align="right"><a href="#toc">back to top</a></p>
|
575 |
<p id="q91"><strong>What is the intended impact of this plugin on the web hosting landscape?</strong><br />
|
576 |
+
We feel that shared or virtual hosting providers will begin offering secure containers (similar to what <a href="http://mediatemple.net/" target="_blank">mediatemple.net</a> does for mySQL and Ruby etc) for opcode caching and memcached. Whoever brings this offering to market first will lower the bar for more web sites/applications (and startups) to build better performing applications with greater ease. The same hosting provider would also possess a new value added service, thereby realizing a competitive advantage in a highly competitive marketplace. Not to mention be able to increase the density of domains per server (or cluster) without shortchanging customers.</p>
|
577 |
<p>One day hopefully this plugin will contribute to making web servers greener and reduce the ecological footprint of the web by reducing the computational effort required to deliver high performance rich user experiences.</p>
|
578 |
<p align="right"><a href="#toc">back to top</a></p>
|
579 |
</div>
|
inc/options/general.phtml
CHANGED
@@ -4,155 +4,247 @@
|
|
4 |
|
5 |
<p>The plugin is currently <span class="w3tc-<?php if ($enabled): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>. If an option is disabled it means that either your current installation is not compatible or installation is required.</p>
|
6 |
|
7 |
-
<p><label><input id="enabled" type="checkbox" name="enabled" value="1"<?php checked($enabled, true); ?> /> Deselect this option to disable all caching functionality.</label></p>
|
8 |
-
|
9 |
<form action="options-general.php">
|
10 |
<p>You can
|
11 |
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
12 |
<input type="hidden" name="tab" value="<?php echo $this->_tab; ?>" />
|
13 |
<input class="button" type="submit" name="flush_all" value="empty all caches" /> at once or
|
14 |
-
<input class="button" type="submit" name="flush_memcached" value="empty only the memcached cache"<?php if (! $can_empty_memcache): ?> disabled="disabled"<?php endif; ?> /> or
|
15 |
-
<input class="button" type="submit" name="
|
16 |
-
<input class="button" type="submit" name="flush_file" value="empty only the disk cache"<?php if (! $can_empty_file): ?> disabled="disabled"<?php endif; ?> />.
|
17 |
</p>
|
18 |
</form>
|
19 |
|
20 |
-
<p>Enable page caching to decrease the response time of your blog.</p>
|
21 |
-
|
22 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
23 |
-
<
|
24 |
-
|
25 |
-
<th valign="top">Page Caching:</th>
|
26 |
-
<td>
|
27 |
-
<input type="hidden" name="pgcache.enabled" value="0" />
|
28 |
-
<label><input class="enabled" type="checkbox" name="pgcache.enabled" value="1"<?php checked($pgcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
29 |
-
<span class="description">Caching pages will reduce the response time of your site and increase the concurrency (scale) of your web server.</span>
|
30 |
-
</td>
|
31 |
-
</tr>
|
32 |
-
<tr>
|
33 |
-
<th valign="top">Page Caching Method:</th>
|
34 |
-
<td>
|
35 |
-
<select name="pgcache.engine">
|
36 |
-
<option value="file_pgcache"<?php selected($this->_config->get_string('pgcache.engine'), 'file_pgcache'); ?>>Disk (enhanced)</option>
|
37 |
-
<option value="file"<?php selected($this->_config->get_string('pgcache.engine'), 'file'); ?>>Disk (basic)</option>
|
38 |
-
<option value="memcached"<?php selected($this->_config->get_string('pgcache.engine'), 'memcached'); ?>>Memcached<?php echo $memcache_engine; ?></option>
|
39 |
-
<option value="apc"<?php selected($this->_config->get_string('pgcache.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?>>Alternative PHP Cache (APC)</option>
|
40 |
-
</select>
|
41 |
-
</td>
|
42 |
-
</tr>
|
43 |
-
</table>
|
44 |
-
|
45 |
-
<p>Enable minify to combine, remove white space / comments and compress (<acronym title="GNU zip">gzip</acronym> / deflate) your (theme's / plugin's / external) <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files.</p>
|
46 |
-
|
47 |
-
<table class="form-table">
|
48 |
-
<tr>
|
49 |
-
<th valign="top">Minify:</th>
|
50 |
-
<td>
|
51 |
-
<input type="hidden" name="minify.enabled" value="0"<?php if (! W3TC_PHP5): ?> disabled="disabled"<?php endif; ?> />
|
52 |
-
<label><input class="enabled" type="checkbox" name="minify.enabled" value="1"<?php checked($minify_enabled, true); ?><?php if (! W3TC_PHP5): ?> disabled="disabled"<?php endif; ?> /> <strong>Enable</strong></label><br />
|
53 |
-
<span class="description">Minification can decrease file size of <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> and feeds respectively by ~10% on average.</span>
|
54 |
-
</td>
|
55 |
-
</tr>
|
56 |
-
<tr>
|
57 |
-
<th valign="top">Minify Caching Method:</th>
|
58 |
-
<td>
|
59 |
-
<select name="minify.engine"<?php if (! W3TC_PHP5): ?> disabled="disabled"<?php endif; ?>>
|
60 |
-
<option value="file"<?php selected($this->_config->get_string('minify.engine'), 'file'); ?>>Disk</option>
|
61 |
-
<option value="memcached"<?php selected($this->_config->get_string('minify.engine'), 'memcached'); ?>>Memcached<?php echo $memcache_engine; ?></option>
|
62 |
-
<option value="apc"<?php selected($this->_config->get_string('minify.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?>>Alternative PHP Cache (APC)</option>
|
63 |
-
</select>
|
64 |
-
</td>
|
65 |
-
</tr>
|
66 |
-
</table>
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
<th valign="top">Database Caching:</th>
|
73 |
-
<td>
|
74 |
-
<input type="hidden" name="dbcache.enabled" value="0" />
|
75 |
-
<label><input class="enabled" type="checkbox" name="dbcache.enabled" value="1"<?php checked($dbcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
76 |
-
<span class="description">Caching database objects may decrease the response time of your blog by up to 100x.</span>
|
77 |
-
</td>
|
78 |
-
</tr>
|
79 |
-
<tr>
|
80 |
-
<th valign="top">Database Caching Method:</th>
|
81 |
-
<td>
|
82 |
-
<select name="dbcache.engine">
|
83 |
-
<option value="file"<?php selected($this->_config->get_string('dbcache.engine'), 'file'); ?>>Disk</option>
|
84 |
-
<option value="memcached"<?php selected($this->_config->get_string('dbcache.engine'), 'memcached'); ?>>Memcached<?php echo $memcache_engine; ?></option>
|
85 |
-
<option value="apc"<?php selected($this->_config->get_string('dbcache.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?>>Alternative PHP Cache (APC)</option>
|
86 |
-
</select>
|
87 |
-
</td>
|
88 |
-
</tr>
|
89 |
-
</table>
|
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 |
|
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 |
</form>
|
157 |
|
158 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
4 |
|
5 |
<p>The plugin is currently <span class="w3tc-<?php if ($enabled): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>. If an option is disabled it means that either your current installation is not compatible or installation is required.</p>
|
6 |
|
|
|
|
|
7 |
<form action="options-general.php">
|
8 |
<p>You can
|
9 |
<input type="hidden" name="page" value="<?php echo W3TC_FILE; ?>" />
|
10 |
<input type="hidden" name="tab" value="<?php echo $this->_tab; ?>" />
|
11 |
<input class="button" type="submit" name="flush_all" value="empty all caches" /> at once or
|
12 |
+
<input class="button" type="submit" name="flush_memcached" value="empty only the memcached cache(s)"<?php if (! $can_empty_memcache): ?> disabled="disabled"<?php endif; ?> /> or
|
13 |
+
<input class="button" type="submit" name="flush_opcode" value="empty only the opcode cache"<?php if (! $can_empty_opcode): ?> disabled="disabled"<?php endif; ?> /> or
|
14 |
+
<input class="button" type="submit" name="flush_file" value="empty only the disk cache(s)"<?php if (! $can_empty_file): ?> disabled="disabled"<?php endif; ?> />.
|
15 |
</p>
|
16 |
</form>
|
17 |
|
|
|
|
|
18 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
19 |
+
<fieldset>
|
20 |
+
<legend>General</legend>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
<p>
|
23 |
+
<label>
|
24 |
+
<input id="enabled" type="checkbox" name="enabled" value="1"<?php checked($enabled, true); ?> />
|
25 |
+
Deselect this option to disable all caching functionality.
|
26 |
+
</label>
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<p class="submit">
|
30 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
31 |
+
</p>
|
32 |
+
</fieldset>
|
33 |
|
34 |
+
<fieldset>
|
35 |
+
<legend>Page Caching</legend>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
<p>Enable page caching to decrease the response time of your blog.</p>
|
38 |
+
|
39 |
+
<table class="form-table">
|
40 |
+
<tr>
|
41 |
+
<th valign="top">Page Caching:</th>
|
42 |
+
<td>
|
43 |
+
<input type="hidden" name="pgcache.enabled" value="0" />
|
44 |
+
<label><input class="enabled" type="checkbox" name="pgcache.enabled" value="1"<?php checked($pgcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
45 |
+
<span class="description">Caching pages will reduce the response time of your site and increase the concurrency (scale) of your web server.</span>
|
46 |
+
</td>
|
47 |
+
</tr>
|
48 |
+
<tr>
|
49 |
+
<th valign="top">Page Caching Method:</th>
|
50 |
+
<td>
|
51 |
+
<select name="pgcache.engine">
|
52 |
+
<optgroup label="Shared Server (disk enhanced is best):">
|
53 |
+
<option value="file_pgcache"<?php selected($this->_config->get_string('pgcache.engine'), 'file_pgcache'); ?>>Disk (enhanced)</option>
|
54 |
+
<option value="file"<?php selected($this->_config->get_string('pgcache.engine'), 'file'); ?>>Disk (basic)</option>
|
55 |
+
</optgroup>
|
56 |
+
<optgroup label="Dedicated / Virtual Server:">
|
57 |
+
<option value="apc"<?php selected($this->_config->get_string('pgcache.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?>>Opcode: Alternative PHP Cache (APC)</option>
|
58 |
+
<option value="eaccelerator"<?php selected($this->_config->get_string('pgcache.engine'), 'eaccelerator'); ?><?php if (! $check_eaccelerator): ?> disabled="disabled"<?php endif; ?>>Opcode: eAccelerator</option>
|
59 |
+
<option value="xcache"<?php selected($this->_config->get_string('pgcache.engine'), 'xcache'); ?><?php if (! $check_xcache): ?> disabled="disabled"<?php endif; ?>>Opcode: XCache</option>
|
60 |
+
</optgroup>
|
61 |
+
<optgroup label="Multiple Servers:">
|
62 |
+
<option value="memcached"<?php selected($this->_config->get_string('pgcache.engine'), 'memcached'); ?><?php if (! $check_memcached): ?> disabled="disabled"<?php endif; ?>>Memcached</option>
|
63 |
+
</optgroup>
|
64 |
+
</select>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
</table>
|
68 |
+
|
69 |
+
<p class="submit">
|
70 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
71 |
+
</p>
|
72 |
+
</fieldset>
|
73 |
+
|
74 |
+
<fieldset>
|
75 |
+
<legend>Minify</legend>
|
76 |
+
|
77 |
+
<p>Reduce load time by decreasing the size and number of <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files. Automatically remove unncessary data from <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym>, feed, page and post <acronym title="Hypertext Markup Language">HTML</acronym>.</p>
|
78 |
|
79 |
+
<table class="form-table">
|
80 |
+
<tr>
|
81 |
+
<th valign="top">Minify:</th>
|
82 |
+
<td>
|
83 |
+
<input type="hidden" name="minify.enabled" value="0"<?php if (! W3TC_PHP5): ?> disabled="disabled"<?php endif; ?> />
|
84 |
+
<label><input class="enabled" type="checkbox" name="minify.enabled" value="1"<?php checked($minify_enabled, true); ?><?php if (! W3TC_PHP5): ?> disabled="disabled"<?php endif; ?> /> <strong>Enable</strong></label><br />
|
85 |
+
<span class="description">Minification can decrease file size of <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> and feeds respectively by ~10% on average.</span>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
<tr>
|
89 |
+
<th valign="top">Minify Caching Method:</th>
|
90 |
+
<td>
|
91 |
+
<select name="minify.engine"<?php if (! W3TC_PHP5): ?> disabled="disabled"<?php endif; ?>>
|
92 |
+
<optgroup label="Shared Server (disk is best):">
|
93 |
+
<option value="file"<?php selected($this->_config->get_string('minify.engine'), 'file'); ?>>Disk</option>
|
94 |
+
</optgroup>
|
95 |
+
<optgroup label="Dedicated / Virtual Server:">
|
96 |
+
<option value="apc"<?php selected($this->_config->get_string('minify.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?>>Opcode: Alternative PHP Cache (APC)</option>
|
97 |
+
<option value="eaccelerator"<?php selected($this->_config->get_string('minify.engine'), 'eaccelerator'); ?><?php if (! $check_eaccelerator): ?> disabled="disabled"<?php endif; ?>>Opcode: eAccelerator</option>
|
98 |
+
<option value="xcache"<?php selected($this->_config->get_string('minify.engine'), 'xcache'); ?><?php if (! $check_xcache): ?> disabled="disabled"<?php endif; ?>>Opcode: XCache</option>
|
99 |
+
</optgroup>
|
100 |
+
<optgroup label="Multiple Servers:">
|
101 |
+
<option value="memcached"<?php selected($this->_config->get_string('minify.engine'), 'memcached'); ?><?php if (! $check_memcached): ?> disabled="disabled"<?php endif; ?>>Memcached</option>
|
102 |
+
</optgroup>
|
103 |
+
</select>
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
</table>
|
107 |
+
|
108 |
+
<p class="submit">
|
109 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
110 |
+
</p>
|
111 |
+
</fieldset>
|
112 |
|
113 |
+
<fieldset>
|
114 |
+
<legend>Database Caching</legend>
|
115 |
|
116 |
+
<p>Enable database caching to reduce post, page and feed creation time.</p>
|
117 |
+
|
118 |
+
<table class="form-table">
|
119 |
+
<tr>
|
120 |
+
<th valign="top">Database Caching:</th>
|
121 |
+
<td>
|
122 |
+
<input type="hidden" name="dbcache.enabled" value="0" />
|
123 |
+
<label><input class="enabled" type="checkbox" name="dbcache.enabled" value="1"<?php checked($dbcache_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
124 |
+
<span class="description">Caching database objects may decrease the response time of your blog by up to 100x.</span>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
<tr>
|
128 |
+
<th valign="top">Database Caching Method:</th>
|
129 |
+
<td>
|
130 |
+
<select name="dbcache.engine">
|
131 |
+
<optgroup label="Shared Server:">
|
132 |
+
<option value="file"<?php selected($this->_config->get_string('dbcache.engine'), 'file'); ?>>Disk</option>
|
133 |
+
</optgroup>
|
134 |
+
<optgroup label="Dedicated / Virtual Server:">
|
135 |
+
<option value="apc"<?php selected($this->_config->get_string('dbcache.engine'), 'apc'); ?><?php if (! $check_apc): ?> disabled="disabled"<?php endif; ?>>Opcode: Alternative PHP Cache (APC)</option>
|
136 |
+
<option value="eaccelerator"<?php selected($this->_config->get_string('dbcache.engine'), 'eaccelerator'); ?><?php if (! $check_eaccelerator): ?> disabled="disabled"<?php endif; ?>>Opcode: eAccelerator</option>
|
137 |
+
<option value="xcache"<?php selected($this->_config->get_string('dbcache.engine'), 'xcache'); ?><?php if (! $check_xcache): ?> disabled="disabled"<?php endif; ?>>Opcode: XCache</option>
|
138 |
+
</optgroup>
|
139 |
+
<optgroup label="Multiple Servers:">
|
140 |
+
<option value="memcached"<?php selected($this->_config->get_string('dbcache.engine'), 'memcached'); ?><?php if (! $check_memcached): ?> disabled="disabled"<?php endif; ?>>Memcached</option>
|
141 |
+
</optgroup>
|
142 |
+
</select>
|
143 |
+
</td>
|
144 |
+
</tr>
|
145 |
+
</table>
|
146 |
|
147 |
+
<p class="submit">
|
148 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
149 |
+
</p>
|
150 |
+
</fieldset>
|
151 |
|
152 |
+
<fieldset>
|
153 |
+
<legend>Content Delivery Network</legend>
|
154 |
+
|
155 |
+
<p>Host static files with your <acronym title="Content Delivery Network">CDN</acronym> provider to reduce load time.</p>
|
156 |
+
|
157 |
+
<table class="form-table">
|
158 |
+
<tr>
|
159 |
+
<th><acronym title="Content Delivery Network">CDN</acronym>:</th>
|
160 |
+
<td>
|
161 |
+
<input type="hidden" name="cdn.enabled" value="0" />
|
162 |
+
<label><input class="enabled" type="checkbox" name="cdn.enabled" value="1"<?php checked($cdn_enabled, true); ?> /> <strong>Enable</strong></label><br />
|
163 |
+
<span class="description">Theme files, media library attachments, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> files etc will appear to load instantly for siite visitors.</span>
|
164 |
+
</td>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<th><acronym title="Content Delivery Network">CDN</acronym> Type:</th>
|
168 |
+
<td>
|
169 |
+
<select name="cdn.engine">
|
170 |
+
<optgroup label="Origin Pull (mirror is best):">
|
171 |
+
<option value="mirror"<?php selected($this->_config->get_string('cdn.engine'), 'mirror'); ?>>Mirror</option>
|
172 |
+
</optgroup>
|
173 |
+
<optgroup label="Origin Push:">
|
174 |
+
<option value="cf"<?php selected($this->_config->get_string('cdn.engine'), 'cf'); ?><?php if (! W3TC_PHP5 || ! $check_curl): ?> disabled="disabled"<?php endif; ?>>Amazon CloudFront</option>
|
175 |
+
<option value="s3"<?php selected($this->_config->get_string('cdn.engine'), 's3'); ?><?php if (! W3TC_PHP5 || ! $check_curl): ?> disabled="disabled"<?php endif; ?>>Amazon Simple Storage Service (S3)</option>
|
176 |
+
<option value="ftp"<?php selected($this->_config->get_string('cdn.engine'), 'ftp'); ?>>Self-hosted / File Transfer Protocol Upload</option>
|
177 |
+
</optgroup>
|
178 |
+
</select><br />
|
179 |
+
<span class="description">Select the <acronym title="Content Delivery Network">CDN</acronym> type you wish to use.</span>
|
180 |
+
</td>
|
181 |
+
</tr>
|
182 |
+
</table>
|
183 |
|
184 |
+
<p class="submit">
|
185 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
186 |
+
</p>
|
187 |
+
</fieldset>
|
188 |
|
189 |
+
<fieldset>
|
190 |
+
<legend>Support Us</legend>
|
191 |
+
|
192 |
+
<p>We're working to make WordPress better. Please support us, here's how:</p>
|
193 |
+
|
194 |
+
<p>
|
195 |
+
<label>Link to us:
|
196 |
+
<select name="common.support">
|
197 |
+
<option value="">select one</option>
|
198 |
+
<?php foreach ($supports as $support_id => $support_name): ?>
|
199 |
+
<option value="<?php echo $support_id; ?>"<?php selected($support, $support_id); ?>><?php echo htmlspecialchars($support_name); ?></option>
|
200 |
+
<?php endforeach; ?>
|
201 |
+
</select>
|
202 |
+
</label>, tell your friends with a <input type="button" class="button button-tweet" value="tweet" /> and give us a great <input type="button" class="button button-rating" value="rating" />.
|
203 |
+
</p>
|
204 |
|
205 |
+
<p>If you want to manually place a link, here is the code:</p>
|
206 |
+
<p><textarea cols="80" rows="4">Performance Optimization <a href="http://www.w3-edge.com/wordpress-plugins/" rel="external">WordPress Plugins</a> by W3 EDGE</textarea></p>
|
207 |
+
|
208 |
+
<p class="submit">
|
209 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
210 |
+
</p>
|
211 |
+
</fieldset>
|
212 |
+
|
213 |
+
<fieldset>
|
214 |
+
<legend>Debug</legend>
|
215 |
+
|
216 |
+
<p>Detailed information about each cache will be appended in (publicly available) <acronym title="Hypertext Markup Language">HTML</acronym> comments in the page's source code. Performance in this mode will not be optimal, use sparingly and disable when not in use.</p>
|
217 |
+
|
218 |
+
<table class="form-table">
|
219 |
+
<tr>
|
220 |
+
<th valign="top">Debug Mode:</th>
|
221 |
+
<td>
|
222 |
+
<label><input type="checkbox" name="debug[]" value="pgcache"<?php checked($this->_config->get_boolean('pgcache.debug'), true); ?> /> Page Cache</label><br />
|
223 |
+
<label><input type="checkbox" name="debug[]" value="minify"<?php checked($this->_config->get_boolean('minify.debug'), true); ?> /> Minify</label><br />
|
224 |
+
<label><input type="checkbox" name="debug[]" value="dbcache"<?php checked($this->_config->get_boolean('dbcache.debug'), true); ?> /> Database Cache</label><br />
|
225 |
+
<label><input type="checkbox" name="debug[]" value="cdn"<?php checked($this->_config->get_boolean('cdn.debug'), true); ?> /> Content Delivery Network</label><br />
|
226 |
+
<span class="description">If selected, detailed caching information will be appear at the end of each page in a <acronym title="Hypertext Markup Language">HTML</acronym> comment. View a page's source code to review.</span>
|
227 |
+
</td>
|
228 |
+
</tr>
|
229 |
+
</table>
|
230 |
+
|
231 |
+
<p class="submit">
|
232 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
233 |
+
</p>
|
234 |
+
</fieldset>
|
235 |
+
|
236 |
+
<fieldset>
|
237 |
+
<legend>Miscellaneous</legend>
|
238 |
+
|
239 |
+
<p>
|
240 |
+
<input type="hidden" name="widget.latest.enabled" value="0" />
|
241 |
+
<label><input type="checkbox" name="widget.latest.enabled" value="1"<?php checked($this->_config->get_boolean('widget.latest.enabled'), true); ?> /> Enable dashboard news widget</label><br />
|
242 |
+
</p>
|
243 |
+
|
244 |
+
<p class="submit">
|
245 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
246 |
+
</p>
|
247 |
+
</fieldset>
|
248 |
</form>
|
249 |
|
250 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
inc/options/install.phtml
CHANGED
@@ -1,23 +1,24 @@
|
|
1 |
<?php include W3TC_DIR . '/inc/options/common/header.phtml'; ?>
|
2 |
|
3 |
<div id="install">
|
4 |
-
<h3>Installation</h3>
|
5 |
|
6 |
<ol>
|
7 |
-
<li>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/ using your web hosting control panel or your <acronym title="Secure Shell">SSH</acronym> account.</li>
|
8 |
-
<li>Ensure that wp-config.php (typically found in the root directory) contains the statement: define('WP_CACHE', true); If you previously used a caching plugin, this statement is likely to exist already.</li>
|
9 |
<li>Set the permissions of wp-content back to 755, e.g.: # chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/</li>
|
10 |
<li>On the "<a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=general">General Settings</a>" tab and select your caching methods for page, database and minify. In most cases, "disk enhanced" mode for page cache, "disk" mode for minify and "disk" mode for database caching are "good" settings.</li>
|
11 |
-
<li>Optional
|
12 |
-
<li>Optional
|
|
|
13 |
<li>You're done! Get back to blogging!</li>
|
14 |
</ol>
|
15 |
Check out the <acronym title="Frequently Asked Questions">FAQ</acronym> for more details on <a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=faq">usage</a>.
|
16 |
<hr />
|
|
|
|
|
17 |
<p><strong>Server Preparation:</strong><br />
|
18 |
<em>Time required: ~1 minute</em></p>
|
19 |
<ol>
|
20 |
-
<li><a href="http://www.google.com/search?q=installing%20yum&output=search&tbs=qdr:y&tbo=1" target="_blank">Install yum</a>
|
21 |
# yum update</li>
|
22 |
<li>Install <acronym title="PHP Extension Community Library">PECL</acronym>:<br />
|
23 |
# yum install php-pear</li>
|
@@ -35,10 +36,10 @@
|
|
35 |
<em>Time required: 2 minutes</em></p>
|
36 |
<ol>
|
37 |
<li>Try to install with yum:<br />
|
38 |
-
# yum install libevent<br />
|
39 |
<br />
|
40 |
If this succeeds skip to #5. If this fails, then let's compile. Download and extract the <a href="http://www.monkey.org/~provos/libevent/" target="_blank">latest stable version</a>:<br />
|
41 |
-
# cd /usr/local/src && wget <a href="http://monkey.org/~provos/libevent-1.4.
|
42 |
<li>Let's compile:<br />
|
43 |
# ./configure && make && make install</li>
|
44 |
<li>In the output you should see:<br />
|
@@ -51,7 +52,7 @@
|
|
51 |
<li>Configure your server for the new install:<br />
|
52 |
# ldconfig -v</li>
|
53 |
<li>Now find the <a href="http://www.danga.com/memcached/download.bml" target="_blank">latest stable memcached</a>, download and extract:<br />
|
54 |
-
# cd /usr/local/src && wget <a href="http://memcached.googlecode.com/files/memcached-1.4.
|
55 |
<li>Let's compile:<br />
|
56 |
# ./configure && make && make install</li>
|
57 |
<li>Make sure memcached is starts automatically on server boot:<br />
|
@@ -63,11 +64,6 @@
|
|
63 |
<li>And finally, let's start memcached:<br />
|
64 |
# /etc/init.d/memcached</li>
|
65 |
</ol>
|
66 |
-
<p>For windows users we recommend checking the following sites for more installation tips:</p>
|
67 |
-
<ul>
|
68 |
-
<li><a href="http://pureform.wordpress.com/2008/01/10/installing-memcache-on-windows-for-php/" target="_blank">Installing memcache on Windows for <acronym title="Hypertext Preprocessor">PHP</acronym></a></li>
|
69 |
-
<li><a href="http://pecl4win.php.net/ext.php/php_memcache.dll" target="_blank"><acronym title="PHP Extension Community Library">PECL</acronym> memcached Extensions</a> </li>
|
70 |
-
</ul>
|
71 |
<hr />
|
72 |
<p id="memcache"><strong><acronym title="PHP Extension Community Library">PECL</acronym> Memcache Module Installation:</strong><br />
|
73 |
<em>Time required: 1 minute</em></p>
|
@@ -85,8 +81,12 @@
|
|
85 |
<li>You're done! Memcache should now be available. If the following command retuns anything, you're all set:<br />
|
86 |
# php -r 'phpinfo();' | grep 'memcache'</li>
|
87 |
</ol>
|
|
|
|
|
|
|
|
|
88 |
<hr />
|
89 |
-
<p id="APC"><strong><acronym title="PHP Extension Community Library">PECL</acronym> <acronym title="Alternative PHP Cache">APC</acronym> Installation:</strong><br />
|
90 |
<em>Time required: 1 minute</em></p>
|
91 |
<ol>
|
92 |
<li>Install <acronym title="Alternative PHP Cache">APC</acronym> using the <acronym title="PHP Extension Community Library">PECL</acronym> command (and skip to #5 if successful):<br />
|
@@ -106,17 +106,16 @@
|
|
106 |
<li>You're done! <acronym title="Alternative PHP Cache">APC</acronym> should now be available. If the following command retuns anything, you're all set:<br />
|
107 |
# php -r 'phpinfo();' | grep 'apc'</li>
|
108 |
</ol>
|
109 |
-
<p>For windows users we recommend checking the following
|
110 |
<ul>
|
111 |
-
<li><a href="http://www.sitebuddy.com/PHP/Accelerators/apc_windows_binaries_builds" target="_blank"><acronym title="Alternative PHP Cache">APC</acronym> binaries for <acronym title="Hypertext Preprocessor">PHP</acronym> 5.x (windows builds)</a
|
112 |
-
<li><a href="http://pecl4win.php.net/ext.php/php_apc.dll" target="_blank"><acronym title="PHP Extension Community Library">PECL</acronym> <acronym title="Alternative PHP Cache">APC</acronym> Extensions</a> </li>
|
113 |
</ul>
|
114 |
<hr />
|
115 |
<p id="eAccelerator"><strong>eAccelerator Installation:</strong><br />
|
116 |
<em>Time required: 1 minute</em></p>
|
117 |
<ol>
|
118 |
-
<li>If using <acronym title="Hypertext Preprocessor">PHP</acronym> v5.2+, download the <a href="http://
|
119 |
-
# cd /usr/local/src && wget <a href="http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6
|
120 |
<li>Note the path returned for the following command:<br />
|
121 |
# whereis php-config</li>
|
122 |
<li>Use the output from #2 to modify the --with-php-config flag in the following compile command:<br />
|
@@ -130,11 +129,15 @@
|
|
130 |
<li>You're done! eAccelerator should now be available. If the following command retuns anything, you're all set:<br />
|
131 |
# php -r 'phpinfo();' | grep 'eaccelerator'</li>
|
132 |
</ol>
|
|
|
|
|
|
|
|
|
133 |
<hr />
|
134 |
<p id="XCache"><strong>XCache Installation:</strong><br />
|
135 |
<em>Time required: 1 minute</em></p>
|
136 |
<ol>
|
137 |
-
<li>Download the <a href="http://xcache.lighttpd.net/
|
138 |
# cd /usr/local/src && wget <a href="http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz" target="_blank">http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz</a> && tar -xzf xcache-1.3.0.tar.gz && cd xcache-1.3.0</li>
|
139 |
<li>Note the path returned for the following command:<br />
|
140 |
# whereis php-config</li>
|
@@ -146,7 +149,7 @@
|
|
146 |
# cp /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/xcache.ini /etc/php.d/</li>
|
147 |
<li>Restart apache when ready:<br />
|
148 |
# /etc/init.d/httpd restart</li>
|
149 |
-
<li>You're done!
|
150 |
# php -r 'phpinfo();' | grep 'xcache'</li>
|
151 |
</ol>
|
152 |
<hr />
|
@@ -154,7 +157,7 @@
|
|
154 |
<ul>
|
155 |
<li>The provided instructions are for 32-bit CentOS, however we can provide others based on <a href="mailto:wordpressexperts@w3-edge.com">your requests</a>.</li>
|
156 |
<li>In the case where Apache is not used, the .htaccess file located in the root directory of the WordPress installation, wp-content/w3tc/pgcache/.htaccess and wp-content/w3tc/min/.htaccess contain directives that must be re-created for your web server software.</li>
|
157 |
-
<li>Restarting the web server will empty
|
158 |
<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>
|
159 |
<li>Some yum or mirrors may not have the necessary packages, in such cases you may have to do a manual installation.</li>
|
160 |
</ul>
|
1 |
<?php include W3TC_DIR . '/inc/options/common/header.phtml'; ?>
|
2 |
|
3 |
<div id="install">
|
4 |
+
<h3>Plugin Installation</h3>
|
5 |
|
6 |
<ol>
|
|
|
|
|
7 |
<li>Set the permissions of wp-content back to 755, e.g.: # chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/</li>
|
8 |
<li>On the "<a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=general">General Settings</a>" tab and select your caching methods for page, database and minify. In most cases, "disk enhanced" mode for page cache, "disk" mode for minify and "disk" mode for database caching are "good" settings.</li>
|
9 |
+
<li><em>Optional:</em> If you already have a content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) provider, proceed to the "<a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=cdn"><acronym title="Content Delivery Network">CDN</acronym> Settings</a>" tab and populate the fields and set your preferences. If you do not use the Media Library, you will need to import your images etc into the default locations. Use the Media Library Import Tool on the <acronym title="Content Delivery Network">CDN</acronym> Setting tab to perform this task. If you do not have a <acronym title="Content Delivery Network">CDN</acronym> provider, you can still improve your site's performance using the "Self-hosted" method. On your own server, create a subdomain and matching <acronym title="Domain Name System">DNS</acronym> Zone record; e.g. static.domain.com and configure <acronym title="File Transfer Protocol">FTP</acronym> options on the <acronym title="Content Delivery Network">CDN</acronym> tab accordingly. Be sure to <acronym title="File Transfer Protocol">FTP</acronym> upload the appropriate files, using the available upload buttons.</li>
|
10 |
+
<li><em>Optional:</em> On the "<a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=minify">Minify Settings</a>" tab all of the recommended settings are preset. View your site's <acronym title="Hypertext Markup Language">HTML</acronym> source and search for .css and .js files and then specify any <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files in the respective section. In the case of <acronym title="JavaScript">JS</acronym> files you can (optionally) specify the type and location of the embedding using the drop down menu. See the plugin's <a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=faq">FAQ</a> for more information on usage.</li>
|
11 |
+
<li><em>Optional:</em> On the "<a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=dbcache">Database Cache Settings</a>" tab the recommended settings are preset. If you're using a shared hosting account use the "disk" method with caution; in either of these cases the response time of the disk may not be fast enough, so this option is disabled by default.</li>
|
12 |
<li>You're done! Get back to blogging!</li>
|
13 |
</ol>
|
14 |
Check out the <acronym title="Frequently Asked Questions">FAQ</acronym> for more details on <a href="options-general.php?page=w3-total-cache/w3-total-cache.php&tab=faq">usage</a>.
|
15 |
<hr />
|
16 |
+
<h3>(Optional) Software Installation for Dedicated / Virtual Dedicated / Multiple Servers</h3>
|
17 |
+
|
18 |
<p><strong>Server Preparation:</strong><br />
|
19 |
<em>Time required: ~1 minute</em></p>
|
20 |
<ol>
|
21 |
+
<li><a href="http://www.google.com/search?q=installing%20yum&output=search&tbs=qdr:y&tbo=1" target="_blank">Install yum</a> if you don't already have it. Then, if you like, you can update all of your installed software, but do so only if you have the experience and time to double check configurations afterwards:<br />
|
22 |
# yum update</li>
|
23 |
<li>Install <acronym title="PHP Extension Community Library">PECL</acronym>:<br />
|
24 |
# yum install php-pear</li>
|
36 |
<em>Time required: 2 minutes</em></p>
|
37 |
<ol>
|
38 |
<li>Try to install with yum:<br />
|
39 |
+
# yum install libevent libevent-devel<br />
|
40 |
<br />
|
41 |
If this succeeds skip to #5. If this fails, then let's compile. Download and extract the <a href="http://www.monkey.org/~provos/libevent/" target="_blank">latest stable version</a>:<br />
|
42 |
+
# cd /usr/local/src && wget <a href="http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz" target="_blank">http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz</a> && tar -xzf libevent-1.4.13-stable.tar.gz && cd libevent-1.4.13-stable</li>
|
43 |
<li>Let's compile:<br />
|
44 |
# ./configure && make && make install</li>
|
45 |
<li>In the output you should see:<br />
|
52 |
<li>Configure your server for the new install:<br />
|
53 |
# ldconfig -v</li>
|
54 |
<li>Now find the <a href="http://www.danga.com/memcached/download.bml" target="_blank">latest stable memcached</a>, download and extract:<br />
|
55 |
+
# cd /usr/local/src && wget <a href="http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz" target="_blank">http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz</a> && tar -xzf memcached-1.4.4.tar.gz && cd memcached-1.4.4</li>
|
56 |
<li>Let's compile:<br />
|
57 |
# ./configure && make && make install</li>
|
58 |
<li>Make sure memcached is starts automatically on server boot:<br />
|
64 |
<li>And finally, let's start memcached:<br />
|
65 |
# /etc/init.d/memcached</li>
|
66 |
</ol>
|
|
|
|
|
|
|
|
|
|
|
67 |
<hr />
|
68 |
<p id="memcache"><strong><acronym title="PHP Extension Community Library">PECL</acronym> Memcache Module Installation:</strong><br />
|
69 |
<em>Time required: 1 minute</em></p>
|
81 |
<li>You're done! Memcache should now be available. If the following command retuns anything, you're all set:<br />
|
82 |
# php -r 'phpinfo();' | grep 'memcache'</li>
|
83 |
</ol>
|
84 |
+
<p>For windows users we recommend checking the following site(s) for more installation tips:</p>
|
85 |
+
<ul>
|
86 |
+
<li><a href="http://pureform.wordpress.com/2008/01/10/installing-memcache-on-windows-for-php/" target="_blank">Installing memcache on Windows for <acronym title="Hypertext Preprocessor">PHP</acronym></a></li>
|
87 |
+
</ul>
|
88 |
<hr />
|
89 |
+
<p id="APC"><strong><acronym title="PHP Extension Community Library">PECL</acronym> Alternative PHP Cache (<acronym title="Alternative PHP Cache">APC</acronym>) Installation (Recommended):</strong><br />
|
90 |
<em>Time required: 1 minute</em></p>
|
91 |
<ol>
|
92 |
<li>Install <acronym title="Alternative PHP Cache">APC</acronym> using the <acronym title="PHP Extension Community Library">PECL</acronym> command (and skip to #5 if successful):<br />
|
106 |
<li>You're done! <acronym title="Alternative PHP Cache">APC</acronym> should now be available. If the following command retuns anything, you're all set:<br />
|
107 |
# php -r 'phpinfo();' | grep 'apc'</li>
|
108 |
</ol>
|
109 |
+
<p>For windows users we recommend checking the following site(s) for more installation tips:</p>
|
110 |
<ul>
|
111 |
+
<li><a href="http://www.sitebuddy.com/PHP/Accelerators/apc_windows_binaries_builds" target="_blank"><acronym title="Alternative PHP Cache">APC</acronym> binaries for <acronym title="Hypertext Preprocessor">PHP</acronym> 5.x (windows builds)</a></li>
|
|
|
112 |
</ul>
|
113 |
<hr />
|
114 |
<p id="eAccelerator"><strong>eAccelerator Installation:</strong><br />
|
115 |
<em>Time required: 1 minute</em></p>
|
116 |
<ol>
|
117 |
+
<li>If using <acronym title="Hypertext Preprocessor">PHP</acronym> v5.2+, download the <a href="http://eaccelerator.net/" target="_blank">latest compatible version</a> and extract:<br />
|
118 |
+
# cd /usr/local/src && wget <a href="http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2" target="_blank">http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2</a> && tar -xjf eaccelerator-0.9.6.tar.bz2 && cd eaccelerator-0.9.6</li>
|
119 |
<li>Note the path returned for the following command:<br />
|
120 |
# whereis php-config</li>
|
121 |
<li>Use the output from #2 to modify the --with-php-config flag in the following compile command:<br />
|
129 |
<li>You're done! eAccelerator should now be available. If the following command retuns anything, you're all set:<br />
|
130 |
# php -r 'phpinfo();' | grep 'eaccelerator'</li>
|
131 |
</ol>
|
132 |
+
<p>For windows users we recommend checking the following site(s) for more installation tips:</p>
|
133 |
+
<ul>
|
134 |
+
<li><a href="http://www.sitebuddy.com/PHP/Accelerators/eAccelerator_windows_binaries_builds" target="_blank">eAccelerator binaries for <acronym title="Hypertext Preprocessor">PHP</acronym> 5.x (windows builds)</a></li>
|
135 |
+
</ul>
|
136 |
<hr />
|
137 |
<p id="XCache"><strong>XCache Installation:</strong><br />
|
138 |
<em>Time required: 1 minute</em></p>
|
139 |
<ol>
|
140 |
+
<li>Download the <a href="http://xcache.lighttpd.net/wiki/ReleaseArchive" target="_blank">latest compatible version</a> and extract:<br />
|
141 |
# cd /usr/local/src && wget <a href="http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz" target="_blank">http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz</a> && tar -xzf xcache-1.3.0.tar.gz && cd xcache-1.3.0</li>
|
142 |
<li>Note the path returned for the following command:<br />
|
143 |
# whereis php-config</li>
|
149 |
# cp /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/xcache.ini /etc/php.d/</li>
|
150 |
<li>Restart apache when ready:<br />
|
151 |
# /etc/init.d/httpd restart</li>
|
152 |
+
<li>You're done! XCache should now be available. If the following command retuns anything, you're all set:<br />
|
153 |
# php -r 'phpinfo();' | grep 'xcache'</li>
|
154 |
</ol>
|
155 |
<hr />
|
157 |
<ul>
|
158 |
<li>The provided instructions are for 32-bit CentOS, however we can provide others based on <a href="mailto:wordpressexperts@w3-edge.com">your requests</a>.</li>
|
159 |
<li>In the case where Apache is not used, the .htaccess file located in the root directory of the WordPress installation, wp-content/w3tc/pgcache/.htaccess and wp-content/w3tc/min/.htaccess contain directives that must be re-created for your web server software.</li>
|
160 |
+
<li>Restarting the web server will empty the opcode cache, which means it will have to be rebuilt over time and your site's performance will suffer during this period. Still, an opcode cache should be installed in any case to maximize WordPress performance.</li>
|
161 |
<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>
|
162 |
<li>Some yum or mirrors may not have the necessary packages, in such cases you may have to do a manual installation.</li>
|
163 |
</ul>
|
inc/options/minify.phtml
CHANGED
@@ -12,174 +12,224 @@
|
|
12 |
</form>
|
13 |
|
14 |
<form id="minify_form" action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<?php if ($this->_config->get_string('minify.engine') == 'memcached'): ?>
|
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 |
-
<span class="description">If <acronym title="Content Delivery Network">CDN</acronym> is enabled (and not using the origin pull method), your minified files will be automatically uploaded.</span>
|
53 |
-
</th>
|
54 |
-
</tr>
|
55 |
-
<tr>
|
56 |
-
<th style="width: 250px;"><label for="minify_maxage">Maximum lifetime of cache objects:</label></th>
|
57 |
-
<td><input id="minify_maxage" type="text" name="minify.maxage" value="<?php echo $this->_config->get_integer('minify.maxage'); ?>" size="8" /> seconds
|
58 |
-
<br /><span class="description">Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.</span>
|
59 |
-
</td>
|
60 |
-
</tr>
|
61 |
-
<tr>
|
62 |
-
<th><label for="minify_lifetime">Update external files every:</label></th>
|
63 |
-
<td><input id="minify_lifetime" type="text" name="minify.lifetime" value="<?php echo $this->_config->get_integer('minify.lifetime'); ?>" size="8" /> seconds<br />
|
64 |
-
<span class="description">Specify the interval between download and update of external files in the minify cache. Hint: 6 hours is 21600 seconds. 12 hours is 43200 seconds. 24 hours is 86400 seconds.</span></td>
|
65 |
-
</tr>
|
66 |
-
<tr>
|
67 |
-
<th><label for="minify_file_gc">Garbage collection interval:</label></th>
|
68 |
-
<td><input id="minify_file_gc" type="text" name="minify.file.gc" value="<?php echo $this->_config->get_integer('minify.file.gc'); ?>" size="8"<?php if ($this->_config->get_string('minify.engine') != 'file'): ?> disabled="disabled"<?php endif; ?> /> seconds
|
69 |
-
<br /><span class="description">If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.</span>
|
70 |
-
</td>
|
71 |
-
</tr>
|
72 |
-
<tr>
|
73 |
-
<th valign="top"><acronym title="Hypertext Markup Language">HTML</acronym> settings:</th>
|
74 |
-
<td>
|
75 |
-
<input type="hidden" name="minify.html.enable" value="0" />
|
76 |
-
<input type="hidden" name="minify.html.reject.admin" value="0" />
|
77 |
-
<input type="hidden" name="minify.html.inline.css" value="0" />
|
78 |
-
<input type="hidden" name="minify.html.inline.js" value="0" />
|
79 |
-
<input type="hidden" name="minify.html.strip.crlf" value="0" />
|
80 |
-
<label><input id="html_enabled" type="checkbox" name="minify.html.enable" value="1"<?php checked($this->_config->get_boolean('minify.html.enable'), true); ?> /> Minify</label><br />
|
81 |
-
<label><input class="html_enabled" type="checkbox" name="minify.html.reject.admin" value="1"<?php checked($this->_config->get_boolean('minify.html.reject.admin'), true); ?> /> Don't Minify <acronym title="Hypertext Markup Language">HTML</acronym> for logged in administrators</label><br />
|
82 |
-
<label><input class="html_enabled" type="checkbox" name="minify.html.inline.css" value="1"<?php checked($this->_config->get_boolean('minify.html.inline.css'), true); ?> /> Inline <acronym title="Cascading Style Sheet">CSS</acronym> Minification</label><br />
|
83 |
-
<label><input class="html_enabled" type="checkbox" name="minify.html.inline.js" value="1"<?php checked($this->_config->get_boolean('minify.html.inline.js'), true); ?> /> Inline <acronym title="JavaScript">JS</acronym> Minification</label><br />
|
84 |
-
<label><input class="html_enabled" type="checkbox" name="minify.html.strip.crlf" value="1"<?php checked($this->_config->get_boolean('minify.html.strip.crlf'), true); ?> /> Line break removal</label><br />
|
85 |
-
</td>
|
86 |
-
</tr>
|
87 |
-
<tr>
|
88 |
-
<th valign="top"><acronym title="JavaScript">JS</acronym> minify settings:</th>
|
89 |
-
<td>
|
90 |
-
<input type="hidden" name="minify.js.enable" value="0" />
|
91 |
-
<input type="hidden" name="minify.js.combine.header" value="0" />
|
92 |
-
<input type="hidden" name="minify.js.combine.footer" value="0" />
|
93 |
-
<input type="hidden" name="minify.js.strip.comments" value="0" />
|
94 |
-
<input type="hidden" name="minify.js.strip.crlf" value="0" />
|
95 |
-
<label><input id="js_enabled" type="checkbox" name="minify.js.enable" value="1"<?php checked($this->_config->get_boolean('minify.js.enable'), true); ?> /> Minify</label><br />
|
96 |
-
<label><input class="js_enabled" type="checkbox" name="minify.js.combine.header" value="1"<?php checked($this->_config->get_boolean('minify.js.combine.header'), true); ?> /> Only combine (Head)</label><br />
|
97 |
-
<label><input class="js_enabled" type="checkbox" name="minify.js.combine.footer" value="1"<?php checked($this->_config->get_boolean('minify.js.combine.footer'), true); ?> /> Only combine (Footer)</label><br />
|
98 |
-
<label><input class="js_enabled" type="checkbox" name="minify.js.strip.comments" value="1"<?php checked($this->_config->get_boolean('minify.js.strip.comments'), true); ?> /> Comment removal</label><br />
|
99 |
-
<label><input class="js_enabled" type="checkbox" name="minify.js.strip.crlf" value="1"<?php checked($this->_config->get_boolean('minify.js.strip.crlf'), true); ?> /> Line break removal</label><br />
|
100 |
-
</td>
|
101 |
-
</tr>
|
102 |
-
<tr>
|
103 |
-
<th valign="top"><acronym title="Cascading Style Sheet">CSS</acronym> minify settings:</th>
|
104 |
-
<td>
|
105 |
-
<input type="hidden" name="minify.css.enable" value="0" />
|
106 |
-
<input type="hidden" name="minify.css.strip.comments" value="0" />
|
107 |
-
<input type="hidden" name="minify.css.strip.crlf" value="0" />
|
108 |
-
<label><input id="css_enabled" type="checkbox" name="minify.css.enable" value="1"<?php checked($this->_config->get_boolean('minify.css.enable'), true); ?> /> Minify</label><br />
|
109 |
-
<label><input class="css_enabled" type="checkbox" name="minify.css.strip.comments" value="1"<?php checked($this->_config->get_boolean('minify.css.strip.comments'), true); ?> /> Comment removal</label><br />
|
110 |
-
<label><input class="css_enabled" type="checkbox" name="minify.css.strip.crlf" value="1"<?php checked($this->_config->get_boolean('minify.css.strip.crlf'), true); ?> /> Line break removal</label><br />
|
111 |
-
</td>
|
112 |
-
</tr>
|
113 |
-
<tr>
|
114 |
-
<th valign="top"><label for="minify_reject_ua">Rejected user agents:</label></th>
|
115 |
-
<td>
|
116 |
-
<textarea id="minify_reject_ua" name="minify.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('minify.reject.ua'))); ?></textarea><br />
|
117 |
-
<span class="description">Specify user agents that will never receive minified content.</span>
|
118 |
-
</td>
|
119 |
-
</tr>
|
120 |
-
<tr>
|
121 |
-
<th valign="top"><acronym title="JavaScript">JS</acronym> file management:</th>
|
122 |
-
<td>
|
123 |
-
<p>
|
124 |
-
<label>
|
125 |
-
<select id="js_groups" class="js_enabled" name="js_group">
|
126 |
-
<?php foreach ($groups as $group_key => $group_text): ?>
|
127 |
-
<option value="<?php echo $group_key; ?>"<?php selected($group_key, $js_group); ?>><?php echo htmlspecialchars($group_text); ?></option>
|
128 |
-
<?php endforeach; ?>
|
129 |
-
</select>
|
130 |
-
Group:
|
131 |
-
</label><br />
|
132 |
-
<span class="description">Add scripts used in all templates to the default group. Use the menu above to manage scripts unique to a specific template.</span>
|
133 |
-
</p>
|
134 |
-
<ol id="js_files">
|
135 |
-
<?php foreach ($js_groups as $js_group => $js_locations): ?>
|
136 |
-
<?php foreach ((array) $js_locations as $js_location => $js_config): ?>
|
137 |
-
<?php if (! empty($js_config['files'])): foreach ((array) $js_config['files'] as $js_file): ?>
|
138 |
-
<li>
|
139 |
-
<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" />
|
140 |
-
</li>
|
141 |
-
<?php endforeach; endif; ?>
|
142 |
-
<?php endforeach; ?>
|
143 |
-
<?php endforeach; ?>
|
144 |
-
</ol>
|
145 |
-
<div id="js_files_empty" class="w3tc-empty" style="display: none;">No <acronym title="JavaScript">JS</acronym> files added</div>
|
146 |
-
<input id="js_file_add" class="js_enabled button" type="button" value="Add a script" />
|
147 |
-
</td>
|
148 |
-
</tr>
|
149 |
-
<tr>
|
150 |
-
<th valign="top"><acronym title="Cascading Style Sheet">CSS</acronym> file management:</th>
|
151 |
-
<td>
|
152 |
-
<p>
|
153 |
-
<label>
|
154 |
-
<select id="css_groups" class="css_enabled" name="css_group">
|
155 |
-
<?php foreach ($groups as $group_key => $group_text): ?>
|
156 |
-
<option value="<?php echo $group_key; ?>"<?php selected($group_key, $css_group); ?>><?php echo htmlspecialchars($group_text); ?></option>
|
157 |
-
<?php endforeach; ?>
|
158 |
-
</select>
|
159 |
-
Group:
|
160 |
-
</label><br />
|
161 |
-
<span class="description">Add style sheets used in all templates to the default group. Use the menu above to manage style sheets unique to a specific template.</span>
|
162 |
-
</p>
|
163 |
-
<ol id="css_files">
|
164 |
-
<?php foreach ($css_groups as $css_group => $css_locations): ?>
|
165 |
-
<?php foreach ((array) $css_locations as $css_location => $css_config): ?>
|
166 |
-
<?php if (! empty($css_config['files'])): foreach ((array) $css_config['files'] as $css_file): ?>
|
167 |
-
<li>
|
168 |
-
<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" />
|
169 |
-
</li>
|
170 |
-
<?php endforeach; endif; ?>
|
171 |
-
<?php endforeach; ?>
|
172 |
-
<?php endforeach; ?>
|
173 |
-
</ol>
|
174 |
-
<div id="css_files_empty" class="w3tc-empty" style="display: none;">No <acronym title="Cascading Style Sheet">CSS</acronym> files added</div>
|
175 |
-
<input id="css_file_add" class="css_enabled button" type="button" value="Add a style sheet" />
|
176 |
-
</td>
|
177 |
-
</tr>
|
178 |
-
</table>
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
183 |
</form>
|
184 |
|
185 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
12 |
</form>
|
13 |
|
14 |
<form id="minify_form" action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
15 |
+
<fieldset>
|
16 |
+
<legend>General</legend>
|
17 |
+
|
18 |
+
<table class="form-table">
|
19 |
+
<tr>
|
20 |
+
<th colspan="2">
|
21 |
+
<input type="hidden" name="minify.rewrite" value="0" />
|
22 |
+
<label><input type="checkbox" name="minify.rewrite" value="1"<?php checked($this->_config->get_boolean('minify.rewrite'), true); ?> /> Rewrite <acronym title="Uniform Resource Locator">URL</acronym> structure</label><br />
|
23 |
+
<span class="description">If disabled, <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> embeddings will use GET variables instead of "fancy links."</span>
|
24 |
+
</th>
|
25 |
+
</tr>
|
26 |
+
<tr>
|
27 |
+
<th colspan="2">
|
28 |
+
<input type="hidden" name="minify.upload" value="0" />
|
29 |
+
<label><input type="checkbox" name="minify.upload" value="1"<?php checked($this->_config->get_boolean('minify.upload'), true); ?> /> Automatically upload modified files</label><br />
|
30 |
+
<span class="description">If <acronym title="Content Delivery Network">CDN</acronym> is enabled (and not using the origin pull method), your minified files will be automatically uploaded.</span>
|
31 |
+
</th>
|
32 |
+
</tr>
|
33 |
+
<tr>
|
34 |
+
<th><label for="minify_compression"><acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression:</label></th>
|
35 |
+
<td>
|
36 |
+
<select id="minify_compression" name="minify.compression">
|
37 |
+
<option value="">None (not recommended)</option>
|
38 |
+
<option value="gzip"<?php selected($this->_config->get_string('minify.compression'), 'gzip'); ?><?php if (! $minify_gzip): ?> disabled="disabled"<?php endif; ?>>gzip (good)</option>
|
39 |
+
<option value="deflate"<?php selected($this->_config->get_string('minify.compression'), 'deflate'); ?><?php if (! $minify_deflate): ?> disabled="disabled"<?php endif; ?>>deflate (not recommended)</option>
|
40 |
+
<option value="gzip,deflate"<?php selected($this->_config->get_string('minify.compression'), 'gzip,deflate'); ?><?php if (! $minify_gzip || ! $minify_deflate): ?> disabled="disabled"<?php endif; ?>>gzip and deflate (best)</option>
|
41 |
+
</select><br />
|
42 |
+
<span class="description">Use <acronym>HTTP</acronym> compression to automatically reduce the load time of HTML documents in browsers that support it.</span>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
</table>
|
46 |
+
|
47 |
+
<p class="submit">
|
48 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
49 |
+
</p>
|
50 |
+
</fieldset>
|
51 |
+
|
52 |
+
<fieldset>
|
53 |
+
<legend><acronym title="Hypertext Markup Language">HTML</acronym></legend>
|
54 |
+
|
55 |
+
<table class="form-table">
|
56 |
+
<tr>
|
57 |
+
<th valign="top"><acronym title="Hypertext Markup Language">HTML</acronym> minify settings:</th>
|
58 |
+
<td>
|
59 |
+
<input type="hidden" name="minify.html.enable" value="0" />
|
60 |
+
<input type="hidden" name="minify.html.reject.admin" value="0" />
|
61 |
+
<input type="hidden" name="minify.html.reject.feed" value="0" />
|
62 |
+
<input type="hidden" name="minify.html.inline.css" value="0" />
|
63 |
+
<input type="hidden" name="minify.html.inline.js" value="0" />
|
64 |
+
<input type="hidden" name="minify.html.strip.crlf" value="0" />
|
65 |
+
<label><input id="html_enabled" type="checkbox" name="minify.html.enable" value="1"<?php checked($this->_config->get_boolean('minify.html.enable'), true); ?> /> Enable</label><br />
|
66 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.reject.admin" value="1"<?php checked($this->_config->get_boolean('minify.html.reject.admin'), true); ?> /> Don't minify <acronym title="Hypertext Markup Language">HTML</acronym> for logged in administrators</label><br />
|
67 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.reject.feed" value="1"<?php checked($this->_config->get_boolean('minify.html.reject.feed'), true); ?> /> Don't minify feeds</label><br />
|
68 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.inline.css" value="1"<?php checked($this->_config->get_boolean('minify.html.inline.css'), true); ?> /> Inline <acronym title="Cascading Style Sheet">CSS</acronym> minification</label><br />
|
69 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.inline.js" value="1"<?php checked($this->_config->get_boolean('minify.html.inline.js'), true); ?> /> Inline <acronym title="JavaScript">JS</acronym> minification</label><br />
|
70 |
+
<label><input class="html_enabled" type="checkbox" name="minify.html.strip.crlf" value="1"<?php checked($this->_config->get_boolean('minify.html.strip.crlf'), true); ?> /> Line break removal</label><br />
|
71 |
+
</td>
|
72 |
+
</tr>
|
73 |
+
</table>
|
74 |
+
|
75 |
+
<p class="submit">
|
76 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
77 |
+
</p>
|
78 |
+
</fieldset>
|
79 |
+
|
80 |
+
<fieldset>
|
81 |
+
<legend>JavaScript</legend>
|
82 |
+
|
83 |
+
<table class="form-table">
|
84 |
+
<tr>
|
85 |
+
<th valign="top"><acronym title="JavaScript">JS</acronym> minify settings:</th>
|
86 |
+
<td>
|
87 |
+
<input type="hidden" name="minify.js.enable" value="0" />
|
88 |
+
<input type="hidden" name="minify.js.combine.header" value="0" />
|
89 |
+
<input type="hidden" name="minify.js.combine.footer" value="0" />
|
90 |
+
<input type="hidden" name="minify.js.strip.comments" value="0" />
|
91 |
+
<input type="hidden" name="minify.js.strip.crlf" value="0" />
|
92 |
+
<label><input id="js_enabled" type="checkbox" name="minify.js.enable" value="1"<?php checked($this->_config->get_boolean('minify.js.enable'), true); ?> /> Enable</label><br />
|
93 |
+
<label><input class="js_enabled" type="checkbox" name="minify.js.combine.header" value="1"<?php checked($this->_config->get_boolean('minify.js.combine.header'), true); ?> /> Only combine (Head)</label><br />
|
94 |
+
<label><input class="js_enabled" type="checkbox" name="minify.js.combine.footer" value="1"<?php checked($this->_config->get_boolean('minify.js.combine.footer'), true); ?> /> Only combine (Footer)</label><br />
|
95 |
+
<label><input class="js_enabled" type="checkbox" name="minify.js.strip.comments" value="1"<?php checked($this->_config->get_boolean('minify.js.strip.comments'), true); ?> /> Comment removal</label><br />
|
96 |
+
<label><input class="js_enabled" type="checkbox" name="minify.js.strip.crlf" value="1"<?php checked($this->_config->get_boolean('minify.js.strip.crlf'), true); ?> /> Line break removal</label><br />
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
<tr>
|
100 |
+
<th valign="top"><acronym title="JavaScript">JS</acronym> file management:</th>
|
101 |
+
<td>
|
102 |
+
<p>
|
103 |
+
<label>
|
104 |
+
<select id="js_groups" class="js_enabled" name="js_group">
|
105 |
+
<?php foreach ($groups as $group_key => $group_text): ?>
|
106 |
+
<option value="<?php echo $group_key; ?>"<?php selected($group_key, $js_group); ?>><?php echo htmlspecialchars($group_text); ?></option>
|
107 |
+
<?php endforeach; ?>
|
108 |
+
</select>
|
109 |
+
Group:
|
110 |
+
</label><br />
|
111 |
+
<span class="description">Add scripts used in all templates to the default group. Use the menu above to manage scripts unique to a specific template.</span>
|
112 |
+
</p>
|
113 |
+
<ol id="js_files">
|
114 |
+
<?php foreach ($js_groups as $js_group => $js_locations): ?>
|
115 |
+
<?php foreach ((array) $js_locations as $js_location => $js_config): ?>
|
116 |
+
<?php if (! empty($js_config['files'])): foreach ((array) $js_config['files'] as $js_file): ?>
|
117 |
+
<li>
|
118 |
+
<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" />
|
119 |
+
</li>
|
120 |
+
<?php endforeach; endif; ?>
|
121 |
+
<?php endforeach; ?>
|
122 |
+
<?php endforeach; ?>
|
123 |
+
</ol>
|
124 |
+
<div id="js_files_empty" class="w3tc-empty" style="display: none;">No <acronym title="JavaScript">JS</acronym> files added</div>
|
125 |
+
<input id="js_file_add" class="js_enabled button" type="button" value="Add a script" />
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
</table>
|
129 |
+
|
130 |
+
<p class="submit">
|
131 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
132 |
+
</p>
|
133 |
+
</fieldset>
|
134 |
+
|
135 |
+
<fieldset>
|
136 |
+
<legend>Cascading Style Sheets</legend>
|
137 |
+
|
138 |
+
<table class="form-table">
|
139 |
+
<tr>
|
140 |
+
<th valign="top"><acronym title="Cascading Style Sheet">CSS</acronym> minify settings:</th>
|
141 |
+
<td>
|
142 |
+
<input type="hidden" name="minify.css.enable" value="0" />
|
143 |
+
<input type="hidden" name="minify.css.combine" value="0" />
|
144 |
+
<input type="hidden" name="minify.css.strip.comments" value="0" />
|
145 |
+
<input type="hidden" name="minify.css.strip.crlf" value="0" />
|
146 |
+
<label><input id="css_enabled" type="checkbox" name="minify.css.enable" value="1"<?php checked($this->_config->get_boolean('minify.css.enable'), true); ?> /> Enable</label><br />
|
147 |
+
<label><input class="css_enabled" type="checkbox" name="minify.css.combine" value="1"<?php checked($this->_config->get_boolean('minify.css.combine'), true); ?> /> Combine only</label><br />
|
148 |
+
<label><input class="css_enabled" type="checkbox" name="minify.css.strip.comments" value="1"<?php checked($this->_config->get_boolean('minify.css.strip.comments'), true); ?> /> Comment removal</label><br />
|
149 |
+
<label><input class="css_enabled" type="checkbox" name="minify.css.strip.crlf" value="1"<?php checked($this->_config->get_boolean('minify.css.strip.crlf'), true); ?> /> Line break removal</label><br />
|
150 |
+
</td>
|
151 |
+
</tr>
|
152 |
+
<tr>
|
153 |
+
<th valign="top"><acronym title="Cascading Style Sheet">CSS</acronym> file management:</th>
|
154 |
+
<td>
|
155 |
+
<p>
|
156 |
+
<label>
|
157 |
+
<select id="css_groups" class="css_enabled" name="css_group">
|
158 |
+
<?php foreach ($groups as $group_key => $group_text): ?>
|
159 |
+
<option value="<?php echo $group_key; ?>"<?php selected($group_key, $css_group); ?>><?php echo htmlspecialchars($group_text); ?></option>
|
160 |
+
<?php endforeach; ?>
|
161 |
+
</select>
|
162 |
+
Group:
|
163 |
+
</label><br />
|
164 |
+
<span class="description">Add style sheets used in all templates to the default group. Use the menu above to manage style sheets unique to a specific template.</span>
|
165 |
+
</p>
|
166 |
+
<ol id="css_files">
|
167 |
+
<?php foreach ($css_groups as $css_group => $css_locations): ?>
|
168 |
+
<?php foreach ((array) $css_locations as $css_location => $css_config): ?>
|
169 |
+
<?php if (! empty($css_config['files'])): foreach ((array) $css_config['files'] as $css_file): ?>
|
170 |
+
<li>
|
171 |
+
<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" />
|
172 |
+
</li>
|
173 |
+
<?php endforeach; endif; ?>
|
174 |
+
<?php endforeach; ?>
|
175 |
+
<?php endforeach; ?>
|
176 |
+
</ol>
|
177 |
+
<div id="css_files_empty" class="w3tc-empty" style="display: none;">No <acronym title="Cascading Style Sheet">CSS</acronym> files added</div>
|
178 |
+
<input id="css_file_add" class="css_enabled button" type="button" value="Add a style sheet" />
|
179 |
+
</td>
|
180 |
+
</tr>
|
181 |
+
</table>
|
182 |
+
|
183 |
+
<p class="submit">
|
184 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
185 |
+
</p>
|
186 |
+
</fieldset>
|
187 |
+
|
188 |
+
<fieldset>
|
189 |
+
<legend>Advanced</legend>
|
190 |
+
|
191 |
+
<table class="form-table">
|
192 |
<?php if ($this->_config->get_string('minify.engine') == 'memcached'): ?>
|
193 |
+
<tr>
|
194 |
+
<th><label for="memcached_servers">Memcached hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:</label></th>
|
195 |
+
<td>
|
196 |
+
<input id="memcached_servers" type="text" name="minify.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $this->_config->get_array('minify.memcached.servers'))); ?>" size="100" />
|
197 |
+
<input id="test_memcached" class="button" type="button" value="Test" />
|
198 |
+
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
199 |
+
<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>
|
200 |
+
</td>
|
201 |
+
</tr>
|
202 |
+
<?php endif; ?>
|
203 |
+
<tr>
|
204 |
+
<th style="width: 250px;"><label for="minify_maxage">Maximum lifetime of cache objects:</label></th>
|
205 |
+
<td><input id="minify_maxage" type="text" name="minify.maxage" value="<?php echo $this->_config->get_integer('minify.maxage'); ?>" size="8" /> seconds
|
206 |
+
<br /><span class="description">Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.</span>
|
207 |
+
</td>
|
208 |
+
</tr>
|
209 |
+
<tr>
|
210 |
+
<th><label for="minify_lifetime">Update external files every:</label></th>
|
211 |
+
<td><input id="minify_lifetime" type="text" name="minify.lifetime" value="<?php echo $this->_config->get_integer('minify.lifetime'); ?>" size="8" /> seconds<br />
|
212 |
+
<span class="description">Specify the interval between download and update of external files in the minify cache. Hint: 6 hours is 21600 seconds. 12 hours is 43200 seconds. 24 hours is 86400 seconds.</span></td>
|
213 |
+
</tr>
|
214 |
+
<tr>
|
215 |
+
<th><label for="minify_file_gc">Garbage collection interval:</label></th>
|
216 |
+
<td><input id="minify_file_gc" type="text" name="minify.file.gc" value="<?php echo $this->_config->get_integer('minify.file.gc'); ?>" size="8"<?php if ($this->_config->get_string('minify.engine') != 'file'): ?> disabled="disabled"<?php endif; ?> /> seconds
|
217 |
+
<br /><span class="description">If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.</span>
|
218 |
+
</td>
|
219 |
+
</tr>
|
220 |
+
<tr>
|
221 |
+
<th valign="top"><label for="minify_reject_ua">Rejected user agents:</label></th>
|
222 |
+
<td>
|
223 |
+
<textarea id="minify_reject_ua" name="minify.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('minify.reject.ua'))); ?></textarea><br />
|
224 |
+
<span class="description">Specify user agents that will never receive minified content.</span>
|
225 |
+
</td>
|
226 |
+
</tr>
|
227 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
+
<p class="submit">
|
230 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
231 |
+
</p>
|
232 |
+
</fieldset>
|
233 |
</form>
|
234 |
|
235 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
inc/options/pgcache.phtml
CHANGED
@@ -12,124 +12,139 @@
|
|
12 |
</form>
|
13 |
|
14 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
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 |
-
<input type="hidden" name="pgcache.cache.home" value="0" />
|
61 |
-
<label><input type="checkbox" name="pgcache.cache.home" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.home'), true); ?> /> Cache the home page</label><br />
|
62 |
-
<span class="description">For many blogs this is your most visited page, it is recommended that you cache it.</span>
|
63 |
-
</th>
|
64 |
-
</tr>
|
65 |
-
<tr>
|
66 |
-
<th colspan="2">
|
67 |
-
<input type="hidden" name="pgcache.cache.feed" value="0" />
|
68 |
-
<label><input type="checkbox" name="pgcache.cache.feed" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.feed'), true); ?> /> Cache <acronym title="Really Simple Syndication">RSS</acronym> / Atom feeds (site, post, post comments)</label><br />
|
69 |
-
<span class="description">Even if using a feed proxy service (like <a href="http://en.wikipedia.org/wiki/FeedBurner" target="_blank">FeedBurner</a>), enabling this option is recommended.</span>
|
70 |
-
</th>
|
71 |
-
</tr>
|
72 |
-
<tr>
|
73 |
-
<th colspan="2">
|
74 |
-
<input type="hidden" name="pgcache.cache.query" value="0"<?php if ($this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> />
|
75 |
-
<label><input type="checkbox" name="pgcache.cache.query" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.query'), true); ?><?php if ($this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> /> Cache <acronym title="Uniform Resource Identifier">URI</acronym>s with query string variables</label><br />
|
76 |
-
<span class="description">Search result (and similar) pages will be cached if enabled.</span>
|
77 |
-
</th>
|
78 |
-
</tr>
|
79 |
-
<tr>
|
80 |
-
<th valign="top"><label for="pgcache_reject_ua">Rejected User Agents:</label></th>
|
81 |
-
<td>
|
82 |
-
<textarea id="pgcache_reject_ua" name="pgcache.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.ua'))); ?></textarea><br />
|
83 |
-
<span class="description">Never send cached pages to these user agents.</span>
|
84 |
-
</td>
|
85 |
-
</tr>
|
86 |
-
<tr>
|
87 |
-
<th valign="top"><label for="pgcache_reject_cookie">Rejected Cookies:</label></th>
|
88 |
-
<td>
|
89 |
-
<textarea id="pgcache_reject_cookie" name="pgcache.reject.cookie" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.cookie'))); ?></textarea><br />
|
90 |
-
<span class="description">Never cache pages that use the specified cookies.</span>
|
91 |
-
</td>
|
92 |
-
</tr>
|
93 |
-
<tr>
|
94 |
-
<th valign="top"><label for="pgcache_reject_uri">Never cache the following pages:</label></th>
|
95 |
-
<td>
|
96 |
-
<textarea id="pgcache_reject_uri" name="pgcache.reject.uri" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.uri'))); ?></textarea><br />
|
97 |
-
<span class="description">Always ignore the specified pages / directories.</span>
|
98 |
-
</td>
|
99 |
-
</tr>
|
100 |
-
<tr>
|
101 |
-
<th valign="top"><label for="pgcache_accept_files">Caching exception list:</label></th>
|
102 |
-
<td>
|
103 |
-
<textarea id="pgcache_accept_files" name="pgcache.accept.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.accept.files'))); ?></textarea><br />
|
104 |
-
<span class="description">Cache the specified pages / directories even if listed in the "never cache the following pages" field.</span>
|
105 |
-
</td>
|
106 |
-
</tr>
|
107 |
-
<tr>
|
108 |
-
<th valign="top"><label for="pgcache_cache_headers">Specify page headers:</label></th>
|
109 |
-
<td>
|
110 |
-
<textarea id="pgcache_cache_headers" name="pgcache.cache.headers" cols="40" rows="5"<?php if (! W3TC_PHP5 || $this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?>><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.cache.headers'))); ?></textarea><br />
|
111 |
-
<span class="description">Specify additional page headers to cache.</span>
|
112 |
-
</td>
|
113 |
-
</tr>
|
114 |
-
<tr>
|
115 |
-
<th valign="top"><label for="pgcache_mobile_agents">Mobile user agents:</label></th>
|
116 |
-
<td>
|
117 |
-
<textarea id="pgcache_mobile_agents" name="pgcache.mobile.agents" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.mobile.agents'))); ?></textarea><br />
|
118 |
-
<span class="description">Specify which mobile devices to detect.</span>
|
119 |
-
</td>
|
120 |
-
</tr>
|
121 |
-
<tr>
|
122 |
-
<th><label for="pgcache_mobile_redirect">Redirect mobile users to:</label></th>
|
123 |
-
<td>
|
124 |
-
<input id="pgcache_mobile_redirect" type="text" name="pgcache.mobile.redirect" value="<?php echo htmlspecialchars($this->_config->get_string('pgcache.mobile.redirect')); ?>" size="100" />
|
125 |
-
<br /><span class="description">If you have a mobile version of your site hosted on another domain, enter the domain name above. The user agents specified in the "Mobile user agents" box will be directed to this domain.</span>
|
126 |
-
</td>
|
127 |
-
</tr>
|
128 |
-
</table>
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
</form>
|
134 |
|
135 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
12 |
</form>
|
13 |
|
14 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post">
|
15 |
+
<fieldset>
|
16 |
+
<legend>General</legend>
|
17 |
+
|
18 |
+
<table class="form-table">
|
19 |
+
<tr>
|
20 |
+
<th colspan="2">
|
21 |
+
<input type="hidden" name="pgcache.reject.logged" value="0" />
|
22 |
+
<label><input type="checkbox" name="pgcache.reject.logged" value="1"<?php checked($this->_config->get_boolean('pgcache.reject.logged'), true); ?> /> Don't cache pages for logged in users</label><br />
|
23 |
+
<span class="description">Users that have signed in to WordPress (e.g. administrators) will never view cached pages if enabled.</span>
|
24 |
+
</th>
|
25 |
+
</tr>
|
26 |
+
<tr>
|
27 |
+
<th colspan="2">
|
28 |
+
<input type="hidden" name="pgcache.cache.home" value="0" />
|
29 |
+
<label><input type="checkbox" name="pgcache.cache.home" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.home'), true); ?> /> Cache the home page</label><br />
|
30 |
+
<span class="description">For many blogs this is your most visited page, it is recommended that you cache it.</span>
|
31 |
+
</th>
|
32 |
+
</tr>
|
33 |
+
<tr>
|
34 |
+
<th colspan="2">
|
35 |
+
<input type="hidden" name="pgcache.cache.feed" value="0" />
|
36 |
+
<label><input type="checkbox" name="pgcache.cache.feed" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.feed'), true); ?> /> Cache <acronym title="Really Simple Syndication">RSS</acronym> / Atom feeds (site, categories, tags, comments)</label><br />
|
37 |
+
<span class="description">Even if using a feed proxy service (like <a href="http://en.wikipedia.org/wiki/FeedBurner" target="_blank">FeedBurner</a>), enabling this option is still recommended.</span>
|
38 |
+
</th>
|
39 |
+
</tr>
|
40 |
+
<tr>
|
41 |
+
<th colspan="2">
|
42 |
+
<input type="hidden" name="pgcache.cache.query" value="0"<?php if ($this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> />
|
43 |
+
<label><input type="checkbox" name="pgcache.cache.query" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.query'), true); ?><?php if ($this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> /> Cache <acronym title="Uniform Resource Identifier">URI</acronym>s with query string variables</label><br />
|
44 |
+
<span class="description">Search result (and similar) pages will be cached if enabled.</span>
|
45 |
+
</th>
|
46 |
+
</tr>
|
47 |
+
<tr>
|
48 |
+
<th><label for="pgcache_compression"><acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression:</label></th>
|
49 |
+
<td>
|
50 |
+
<select id="pgcache_compression" name="pgcache.compression">
|
51 |
+
<option value="">None (not recommended)</option>
|
52 |
+
<option value="gzip"<?php selected($this->_config->get_string('pgcache.compression'), 'gzip'); ?><?php if (! $pgcache_gzip): ?> disabled="disabled"<?php endif; ?>>gzip (good)</option>
|
53 |
+
<option value="deflate"<?php selected($this->_config->get_string('pgcache.compression'), 'deflate'); ?><?php if (! $pgcache_deflate): ?> disabled="disabled"<?php endif; ?>>deflate (not recommended)</option>
|
54 |
+
<option value="gzip,deflate"<?php selected($this->_config->get_string('pgcache.compression'), 'gzip,deflate'); ?><?php if (! $pgcache_gzip || ! $pgcache_deflate): ?> disabled="disabled"<?php endif; ?>>gzip and deflate (best)</option>
|
55 |
+
</select><br />
|
56 |
+
<span class="description">Use <acronym>HTTP</acronym> compression to automatically reduce the load time of HTML documents in browsers that support it.</span>
|
57 |
+
</td>
|
58 |
+
</tr>
|
59 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
<p class="submit">
|
62 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
63 |
+
</p>
|
64 |
+
</fieldset>
|
65 |
+
|
66 |
+
<fieldset>
|
67 |
+
<legend>Advanced</legend>
|
68 |
+
|
69 |
+
<table class="form-table">
|
70 |
+
<?php if ($this->_config->get_string('pgcache.engine') == 'memcached'): ?>
|
71 |
+
<tr>
|
72 |
+
<th><label for="memcached_servers">Memcached hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:</label></th>
|
73 |
+
<td>
|
74 |
+
<input id="memcached_servers" type="text" name="pgcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $this->_config->get_array('pgcache.memcached.servers'))); ?>" size="100" />
|
75 |
+
<input id="test_memcached" class="button" type="button" value="Test" />
|
76 |
+
<span id="test_memcached_status" class="w3tc-status w3tc-process"></span>
|
77 |
+
<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>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
<?php endif; ?>
|
81 |
+
<tr>
|
82 |
+
<th style="width: 250px;"><label for="pgcache_lifetime">Maximum lifetime of cache objects:</label></th>
|
83 |
+
<td><input id="pgcache_lifetime" type="text" name="pgcache.lifetime" value="<?php echo $this->_config->get_integer('pgcache.lifetime'); ?>" size="8" /> seconds
|
84 |
+
<br /><span class="description">Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.</span>
|
85 |
+
</td>
|
86 |
+
</tr>
|
87 |
+
<tr>
|
88 |
+
<th><label for="pgcache_file_gc">Garbage collection interval:</label></th>
|
89 |
+
<td><input id="pgcache_file_gc" type="text" name="pgcache.file.gc" value="<?php echo $this->_config->get_integer('pgcache.file.gc'); ?>" size="8"<?php if ($this->_config->get_string('pgcache.engine') != 'file' && $this->_config->get_string('pgcache.engine') != 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> /> seconds
|
90 |
+
<br /><span class="description">If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.</span>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<tr>
|
94 |
+
<th valign="top"><label for="pgcache_reject_ua">Rejected User Agents:</label></th>
|
95 |
+
<td>
|
96 |
+
<textarea id="pgcache_reject_ua" name="pgcache.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.ua'))); ?></textarea><br />
|
97 |
+
<span class="description">Never send cache pages for these user agents.</span>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
<tr>
|
101 |
+
<th valign="top"><label for="pgcache_reject_cookie">Rejected Cookies:</label></th>
|
102 |
+
<td>
|
103 |
+
<textarea id="pgcache_reject_cookie" name="pgcache.reject.cookie" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.cookie'))); ?></textarea><br />
|
104 |
+
<span class="description">Never cache pages that use the specified cookies.</span>
|
105 |
+
</td>
|
106 |
+
</tr>
|
107 |
+
<tr>
|
108 |
+
<th valign="top"><label for="pgcache_reject_uri">Never cache the following pages:</label></th>
|
109 |
+
<td>
|
110 |
+
<textarea id="pgcache_reject_uri" name="pgcache.reject.uri" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.uri'))); ?></textarea><br />
|
111 |
+
<span class="description">Always ignore the specified pages / directories.</span>
|
112 |
+
</td>
|
113 |
+
</tr>
|
114 |
+
<tr>
|
115 |
+
<th valign="top"><label for="pgcache_accept_files">Caching exception list:</label></th>
|
116 |
+
<td>
|
117 |
+
<textarea id="pgcache_accept_files" name="pgcache.accept.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.accept.files'))); ?></textarea><br />
|
118 |
+
<span class="description">Cache the specified pages / directories even if listed in the "never cache the following pages" field.</span>
|
119 |
+
</td>
|
120 |
+
</tr>
|
121 |
+
<tr>
|
122 |
+
<th valign="top"><label for="pgcache_cache_headers">Specify page headers:</label></th>
|
123 |
+
<td>
|
124 |
+
<textarea id="pgcache_cache_headers" name="pgcache.cache.headers" cols="40" rows="5"<?php if (! W3TC_PHP5 || $this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?>><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.cache.headers'))); ?></textarea><br />
|
125 |
+
<span class="description">Specify additional page headers to cache.</span>
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
<tr>
|
129 |
+
<th valign="top"><label for="pgcache_mobile_agents">Mobile user agents:</label></th>
|
130 |
+
<td>
|
131 |
+
<textarea id="pgcache_mobile_agents" name="pgcache.mobile.agents" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.mobile.agents'))); ?></textarea><br />
|
132 |
+
<span class="description">Specify which mobile devices to detect for redirection to the domain name specified below.</span>
|
133 |
+
</td>
|
134 |
+
</tr>
|
135 |
+
<tr>
|
136 |
+
<th><label for="pgcache_mobile_redirect">Redirect mobile users to:</label></th>
|
137 |
+
<td>
|
138 |
+
<input id="pgcache_mobile_redirect" type="text" name="pgcache.mobile.redirect" value="<?php echo htmlspecialchars($this->_config->get_string('pgcache.mobile.redirect')); ?>" size="100" />
|
139 |
+
<br /><span class="description">If you have a mobile version of your site hosted on another domain, enter the domain name above. The user agents specified in the "Mobile user agents" box will be directed to this domain.</span>
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
</table>
|
143 |
+
|
144 |
+
<p class="submit">
|
145 |
+
<input type="submit" name="Submit" class="button-primary" value="Save changes" />
|
146 |
+
</p>
|
147 |
+
</fieldset>
|
148 |
</form>
|
149 |
|
150 |
<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>
|
inc/options/support.phtml
CHANGED
@@ -3,82 +3,95 @@
|
|
3 |
<h3>Support</h3>
|
4 |
|
5 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post" enctype="multipart/form-data" id="support_form">
|
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 |
<input type="submit" name="Submit" class="button-primary" value="Submit request" />
|
83 |
</p>
|
84 |
</form>
|
3 |
<h3>Support</h3>
|
4 |
|
5 |
<form action="options-general.php?page=<?php echo urldecode(W3TC_FILE); ?>&tab=<?php echo $this->_tab; ?>" method="post" enctype="multipart/form-data" id="support_form">
|
6 |
+
<p>
|
7 |
+
Request professional services or notify us of any bugs you have identified:
|
8 |
+
</p>
|
9 |
+
|
10 |
+
<fieldset>
|
11 |
+
<legend>Required information</legend>
|
12 |
+
|
13 |
+
<table class="form-table">
|
14 |
+
<tr>
|
15 |
+
<th valign="top"><label for="support_request_type">Request type:</label></th>
|
16 |
+
<td><select id="support_request_type" name="request_type">
|
17 |
+
<option value="">-- Choose Type --</option>
|
18 |
+
<?php foreach ($request_types as $_request_type): ?>
|
19 |
+
<option value="<?php echo $_request_type; ?>"<?php selected($_request_type, $request_type); ?>><?php echo $_request_type; ?></option>
|
20 |
+
<?php endforeach; ?>
|
21 |
+
</select></td>
|
22 |
+
</tr>
|
23 |
+
<tr>
|
24 |
+
<th><label for="support_url">Blog <acronym title="Uniform Resource Locator">URL</acronym>:</label></th>
|
25 |
+
<td><input id="support_url" type="text" name="url" value="<?php echo htmlspecialchars($url); ?>" size="80" /></td>
|
26 |
+
</tr>
|
27 |
+
<tr>
|
28 |
+
<th><label for="support_name">Name:</label></th>
|
29 |
+
<td><input id="support_name" type="text" name="name" value="<?php echo htmlspecialchars($name); ?>" size="80" /></td>
|
30 |
+
</tr>
|
31 |
+
<tr>
|
32 |
+
<th><label for="support_email">E-Mail:</label></th>
|
33 |
+
<td><input id="support_email" type="text" name="email" value="<?php echo htmlspecialchars($email); ?>" size="80" /></td>
|
34 |
+
</tr>
|
35 |
+
<tr>
|
36 |
+
<th valign="top"><label for="support_description">Issue description:</label></th>
|
37 |
+
<td><textarea id="support_description" name="description" cols="80" rows="8"><?php echo htmlspecialchars($description); ?></textarea></td>
|
38 |
+
</tr>
|
39 |
+
<tr>
|
40 |
+
<th><label for="support_template">Attach template:</label></th>
|
41 |
+
<td><select id="support_template" name="templates[]" multiple="multiple" size="10" style="height: auto;">
|
42 |
+
<?php foreach ($template_files as $template_file): ?>
|
43 |
+
<option value="<?php echo htmlspecialchars($template_file); ?>"<?php if (in_array($template_file, $templates)): ?> selected="selected"<?php endif; ?>><?php echo htmlspecialchars($template_file); ?></option>
|
44 |
+
<?php endforeach; ?>
|
45 |
+
</select></td>
|
46 |
+
</tr>
|
47 |
+
<tr>
|
48 |
+
<th><label for="support_file">Attach file:</label></th>
|
49 |
+
<td>
|
50 |
+
<input id="support_file" type="file" name="files[]" value="" /><br />
|
51 |
+
<a href="#" id="support_more_files">Attach more files</a>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
</table>
|
55 |
+
</fieldset>
|
56 |
+
|
57 |
+
<fieldset>
|
58 |
+
<legend>Additional information</legend>
|
59 |
+
|
60 |
+
<table class="form-table">
|
61 |
+
<tr>
|
62 |
+
<th><label for="support_wp_login"><acronym title="WordPress">WP</acronym> Admin login:</label></th>
|
63 |
+
<td><input id="support_wp_login" type="text" name="wp_login" value="<?php echo htmlspecialchars($wp_login); ?>" size="40" /></td>
|
64 |
+
</tr>
|
65 |
+
<tr>
|
66 |
+
<th><label for="support_wp_password"><acronym title="WordPress">WP</acronym> Admin password:</label></th>
|
67 |
+
<td><input id="support_wp_password" type="text" name="wp_password" value="<?php echo htmlspecialchars($wp_password); ?>" size="40" /></td>
|
68 |
+
</tr>
|
69 |
+
<tr>
|
70 |
+
<th><label for="support_ftp_host"><acronym title="Secure Shell">SSH</acronym> / <acronym title="File Transfer Protocol">FTP</acronym> host:</label></th>
|
71 |
+
<td><input id="support_ftp_host" type="text" name="ftp_host" value="<?php echo htmlspecialchars($ftp_host); ?>" size="40" /></td>
|
72 |
+
</tr>
|
73 |
+
<tr>
|
74 |
+
<th><label for="support_ftp_login"><acronym title="Secure Shell">SSH</acronym> / <acronym title="File Transfer Protocol">FTP</acronym> login:</label></th>
|
75 |
+
<td><input id="support_ftp_login" type="text" name="ftp_login" value="<?php echo htmlspecialchars($ftp_login); ?>" size="40" /></td>
|
76 |
+
</tr>
|
77 |
+
<tr>
|
78 |
+
<th><label for="support_ftp_password"><acronym title="Secure Shell">SSH</acronym> / <acronym title="File Transfer Protocol">FTP</acronym> password:</label></th>
|
79 |
+
<td><input id="support_ftp_password" type="text" name="ftp_password" value="<?php echo htmlspecialchars($ftp_password); ?>" size="40" /></td>
|
80 |
+
</tr>
|
81 |
+
</table>
|
82 |
+
</fieldset>
|
83 |
+
|
84 |
+
<fieldset>
|
85 |
+
<legend>Notes</legend>
|
86 |
|
87 |
+
<ul>
|
88 |
+
<li>All submitted data will not be saved and is used solely for the purposes your support request. You will not be added to a mailing list, solicited without your permission, nor will your site be administered after this support case is closed.</li>
|
89 |
+
<li>Instead of providing your primary administrative or <acronym title="Secure Shell">SSH</acronym> / <acronym title="File Transfer Protocol">FTP</acronym> accounts, create a new administrator account that can be disabled when the support case is closed.</li>
|
90 |
+
<li>Please add the domain w3-edge.com to your <a href="http://en.wikipedia.org/wiki/Whitelist" target="_blank">email whitelist</a> as soon as possible.</li>
|
91 |
+
</ul>
|
92 |
+
</fieldset>
|
93 |
+
|
94 |
+
<p>
|
95 |
<input type="submit" name="Submit" class="button-primary" value="Submit request" />
|
96 |
</p>
|
97 |
</form>
|
inc/options/support_email.phtml
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
<?php echo nl2br(htmlspecialchars($description)); ?>
|
14 |
</p>
|
15 |
<hr />
|
16 |
-
<font size="-1" color="#
|
17 |
E-mail sent from IP: <?php echo htmlspecialchars($_SERVER['REMOTE_ADDR']); ?><br />
|
18 |
User Agent: <?php echo htmlspecialchars($_SERVER['HTTP_USER_AGENT']); ?>
|
19 |
</font>
|
13 |
<?php echo nl2br(htmlspecialchars($description)); ?>
|
14 |
</p>
|
15 |
<hr />
|
16 |
+
<font size="-1" color="#ccc">
|
17 |
E-mail sent from IP: <?php echo htmlspecialchars($_SERVER['REMOTE_ADDR']); ?><br />
|
18 |
User Agent: <?php echo htmlspecialchars($_SERVER['HTTP_USER_AGENT']); ?>
|
19 |
</font>
|
inc/popup/cdn_export_file.phtml
CHANGED
@@ -13,6 +13,7 @@ jQuery(function() {
|
|
13 |
});
|
14 |
</script>
|
15 |
|
|
|
16 |
<table cellspacing="5">
|
17 |
<tr>
|
18 |
<td>Total files:</td>
|
13 |
});
|
14 |
</script>
|
15 |
|
16 |
+
<p>This tool will upload files of the selected type to content delivery network provider.</p>
|
17 |
<table cellspacing="5">
|
18 |
<tr>
|
19 |
<td>Total files:</td>
|
inc/popup/cdn_export_library.phtml
CHANGED
@@ -8,6 +8,7 @@ jQuery(function() {
|
|
8 |
/*]]>*/
|
9 |
</script>
|
10 |
|
|
|
11 |
<table cellspacing="5">
|
12 |
<tr>
|
13 |
<td>Total media library attachments:</td>
|
8 |
/*]]>*/
|
9 |
</script>
|
10 |
|
11 |
+
<p>This tool will upload files of the selected type to content delivery network provider.</p>
|
12 |
<table cellspacing="5">
|
13 |
<tr>
|
14 |
<td>Total media library attachments:</td>
|
inc/popup/cdn_import_library.phtml
CHANGED
@@ -10,6 +10,7 @@ jQuery(function() {
|
|
10 |
/*]]>*/
|
11 |
</script>
|
12 |
|
|
|
13 |
<table cellspacing="5">
|
14 |
<tr>
|
15 |
<td>Total posts:</td>
|
@@ -38,7 +39,7 @@ jQuery(function() {
|
|
38 |
</tr>
|
39 |
<tr>
|
40 |
<td colspan="2">
|
41 |
-
<label><input id="cdn_import_library_redirect_cdn" type="checkbox"
|
42 |
</td>
|
43 |
</tr>
|
44 |
</table>
|
10 |
/*]]>*/
|
11 |
</script>
|
12 |
|
13 |
+
<p>This tool will copy post or page attachments into the Media Library allowing WordPress to work as intended.</p>
|
14 |
<table cellspacing="5">
|
15 |
<tr>
|
16 |
<td>Total posts:</td>
|
39 |
</tr>
|
40 |
<tr>
|
41 |
<td colspan="2">
|
42 |
+
<label><input id="cdn_import_library_redirect_cdn" type="checkbox" /> Redirect to <acronym title="Content Delivery Network">CDN</acronym></label>
|
43 |
</td>
|
44 |
</tr>
|
45 |
</table>
|
inc/popup/cdn_queue.phtml
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php include W3TC_DIR . '/inc/popup/common/header.phtml'; ?>
|
2 |
|
|
|
3 |
<p id="w3tc-options-menu">
|
4 |
<a href="#cdn_queue_upload" rel="#cdn_queue_upload" class="tab<?php if ($cdn_queue_tab == 'upload'): ?> tab-selected<?php endif; ?>">Upload queue</a> |
|
5 |
<a href="#cdn_queue_delete" rel="#cdn_queue_delete" class="tab<?php if ($cdn_queue_tab == 'delete'): ?> tab-selected<?php endif; ?>">Delete queue</a>
|
1 |
<?php include W3TC_DIR . '/inc/popup/common/header.phtml'; ?>
|
2 |
|
3 |
+
<p>This tool lists the pending file uploads and deletions.</p>
|
4 |
<p id="w3tc-options-menu">
|
5 |
<a href="#cdn_queue_upload" rel="#cdn_queue_upload" class="tab<?php if ($cdn_queue_tab == 'upload'): ?> tab-selected<?php endif; ?>">Upload queue</a> |
|
6 |
<a href="#cdn_queue_delete" rel="#cdn_queue_delete" class="tab<?php if ($cdn_queue_tab == 'delete'): ?> tab-selected<?php endif; ?>">Delete queue</a>
|
inc/popup/cdn_rename_domain.phtml
CHANGED
@@ -8,6 +8,7 @@ jQuery(function() {
|
|
8 |
/*]]>*/
|
9 |
</script>
|
10 |
|
|
|
11 |
<table cellspacing="5">
|
12 |
<tr>
|
13 |
<td>Total posts:</td>
|
8 |
/*]]>*/
|
9 |
</script>
|
10 |
|
11 |
+
<p>This tool allows you to modify the URL of Media Library attachments. Use it if the "WordPress address (<acronym title="Uniform Resource Indicator">URL</acronym>)" value has been changed in the past.</p>
|
12 |
<table cellspacing="5">
|
13 |
<tr>
|
14 |
<td>Total posts:</td>
|
inc/widget/latest.phtml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php foreach ($items as $item): ?>
|
2 |
+
<h4>
|
3 |
+
<a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a>
|
4 |
+
</h4>
|
5 |
+
<p>
|
6 |
+
<?php echo $item['description']; ?>
|
7 |
+
</p>
|
8 |
+
<?php endforeach; ?>
|
9 |
+
|
10 |
+
<p style="text-align: center;">
|
11 |
+
<a href="<?php echo W3TC_FEED_URL; ?>" target="_blank">View Feed</a>
|
12 |
+
</p>
|
inc/widget/latest_control.phtml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
<label for="w3tc_latest">How many items would you like to display?</label>
|
3 |
+
<input id="w3tc_latest" type="text" name="w3tc_latest_items" value="<?php echo $this->_config->get_integer('widget.latest.items'); ?>" size="5" />
|
4 |
+
</p>
|
ini/_htaccess
CHANGED
@@ -8,6 +8,7 @@ AddType application/x-javascript .js
|
|
8 |
AddType application/x-shockwave-flash .swf
|
9 |
AddType image/bmp .bmp
|
10 |
AddType image/gif .gif
|
|
|
11 |
AddType image/jpeg .jpeg
|
12 |
AddType image/jpg .jpg
|
13 |
AddType image/png .png
|
@@ -65,6 +66,7 @@ ExpiresByType application/x-shockwave-flash A259200
|
|
65 |
ExpiresByType application/wlwmanifest+xml A259200
|
66 |
ExpiresByType image/bmp A259200
|
67 |
ExpiresByType image/gif A259200
|
|
|
68 |
ExpiresByType image/jpeg A259200
|
69 |
ExpiresByType image/jpg A259200
|
70 |
ExpiresByType image/png A259200
|
@@ -81,7 +83,7 @@ ExpiresByType text/xsd A259200
|
|
81 |
ExpiresByType text/xsl A259200
|
82 |
</IfModule>
|
83 |
|
84 |
-
<FilesMatch "\.(bmp|css|ico|html?|js|tiff?|gif|jpe?g|png|svgz?|swf|txt|xsd|xsl|xml)$">
|
85 |
<IfModule mod_headers.c>
|
86 |
# Set Pragma header
|
87 |
Header set Pragma "public"
|
@@ -105,7 +107,7 @@ RewriteCond %{REQUEST_FILENAME} !^.*\.css [NC]
|
|
105 |
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [NC]
|
106 |
RewriteCond %{REQUEST_FILENAME} !^.*\.html? [NC]
|
107 |
RewriteCond %{REQUEST_FILENAME} !^.*\.js [NC]
|
108 |
-
RewriteCond %{REQUEST_FILENAME} !^.*\.jpe?g [NC]
|
109 |
RewriteCond %{REQUEST_FILENAME} !^.*\.png [NC]
|
110 |
RewriteCond %{REQUEST_FILENAME} !^.*\.svgz? [NC]
|
111 |
RewriteCond %{REQUEST_FILENAME} !^.*\.swf [NC]
|
8 |
AddType application/x-shockwave-flash .swf
|
9 |
AddType image/bmp .bmp
|
10 |
AddType image/gif .gif
|
11 |
+
AddType image/pjpeg .pjpeg
|
12 |
AddType image/jpeg .jpeg
|
13 |
AddType image/jpg .jpg
|
14 |
AddType image/png .png
|
66 |
ExpiresByType application/wlwmanifest+xml A259200
|
67 |
ExpiresByType image/bmp A259200
|
68 |
ExpiresByType image/gif A259200
|
69 |
+
ExpiresByType image/pjpeg A259200
|
70 |
ExpiresByType image/jpeg A259200
|
71 |
ExpiresByType image/jpg A259200
|
72 |
ExpiresByType image/png A259200
|
83 |
ExpiresByType text/xsl A259200
|
84 |
</IfModule>
|
85 |
|
86 |
+
<FilesMatch "\.(bmp|css|ico|html?|js|tiff?|gif|p?jpe?g|png|svgz?|swf|txt|xsd|xsl|xml)$">
|
87 |
<IfModule mod_headers.c>
|
88 |
# Set Pragma header
|
89 |
Header set Pragma "public"
|
107 |
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [NC]
|
108 |
RewriteCond %{REQUEST_FILENAME} !^.*\.html? [NC]
|
109 |
RewriteCond %{REQUEST_FILENAME} !^.*\.js [NC]
|
110 |
+
RewriteCond %{REQUEST_FILENAME} !^.*\.p?jpe?g [NC]
|
111 |
RewriteCond %{REQUEST_FILENAME} !^.*\.png [NC]
|
112 |
RewriteCond %{REQUEST_FILENAME} !^.*\.svgz? [NC]
|
113 |
RewriteCond %{REQUEST_FILENAME} !^.*\.swf [NC]
|
ini/apc.ini
CHANGED
@@ -6,7 +6,6 @@ apc.enabled = 1
|
|
6 |
apc.shm_segments = 1
|
7 |
apc.shm_size = 32
|
8 |
apc.optimization = 0
|
9 |
-
apc.max_file_size = 1000
|
10 |
apc.num_files_hint = 4096
|
11 |
apc.ttl = 7200
|
12 |
apc.user_ttl = 7200
|
@@ -17,7 +16,7 @@ apc.mmap_file_mask = "/tmp/apc.XXXXXX"
|
|
17 |
apc.slam_defense = 0
|
18 |
apc.file_update_protection = 2
|
19 |
apc.enable_cli = 0
|
20 |
-
apc.max_file_size =
|
21 |
apc.stat = 1
|
22 |
apc.write_lock = 1
|
23 |
apc.report_autofilter = 0
|
6 |
apc.shm_segments = 1
|
7 |
apc.shm_size = 32
|
8 |
apc.optimization = 0
|
|
|
9 |
apc.num_files_hint = 4096
|
10 |
apc.ttl = 7200
|
11 |
apc.user_ttl = 7200
|
16 |
apc.slam_defense = 0
|
17 |
apc.file_update_protection = 2
|
18 |
apc.enable_cli = 0
|
19 |
+
apc.max_file_size = 5M
|
20 |
apc.stat = 1
|
21 |
apc.write_lock = 1
|
22 |
apc.report_autofilter = 0
|
ini/memcache.ini
CHANGED
@@ -3,6 +3,8 @@
|
|
3 |
extension = memcache.so
|
4 |
|
5 |
memcache.allow_failover = 1
|
6 |
-
memcache.
|
7 |
-
memcache.
|
8 |
-
memcache.
|
|
|
|
3 |
extension = memcache.so
|
4 |
|
5 |
memcache.allow_failover = 1
|
6 |
+
memcache.max_failover_attempts = 20
|
7 |
+
memcache.chunk_size = 32768
|
8 |
+
memcache.default_port = 11211
|
9 |
+
memcache.hash_strategy = standard
|
10 |
+
memcache.hash_function = crc32
|
lib/Minify/HTTP/ConditionalGet.php
CHANGED
@@ -150,7 +150,7 @@ class HTTP_ConditionalGet {
|
|
150 |
} elseif (isset($spec['contentHash'])) { // Use the hash as the ETag
|
151 |
$this->_setEtag($spec['contentHash'] . $etagAppend, $scope);
|
152 |
}
|
153 |
-
$this->_headers['Cache-Control'] = "max-age={$maxAge}, {$scope}, must-revalidate";
|
154 |
// invalidate cache if disabled, otherwise check
|
155 |
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
|
156 |
? false
|
150 |
} elseif (isset($spec['contentHash'])) { // Use the hash as the ETag
|
151 |
$this->_setEtag($spec['contentHash'] . $etagAppend, $scope);
|
152 |
}
|
153 |
+
$this->_headers['Cache-Control'] = "max-age={$maxAge}, {$scope}, must-revalidate, proxy-revalidate";
|
154 |
// invalidate cache if disabled, otherwise check
|
155 |
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
|
156 |
? false
|
lib/Minify/HTTP/Encoder.php
CHANGED
@@ -59,7 +59,7 @@ class HTTP_Encoder {
|
|
59 |
*
|
60 |
* @var bool
|
61 |
*/
|
62 |
-
public static $encodeToIe6 =
|
63 |
|
64 |
|
65 |
/**
|
@@ -96,7 +96,7 @@ class HTTP_Encoder {
|
|
96 |
$this->_headers['Content-Type'] = $spec['type'];
|
97 |
}
|
98 |
if (isset($spec['method'])
|
99 |
-
&& in_array($spec['method'], array('gzip', 'deflate', '
|
100 |
{
|
101 |
$this->_encodeMethod = array($spec['method'], $spec['method']);
|
102 |
} else {
|
@@ -182,15 +182,11 @@ class HTTP_Encoder {
|
|
182 |
* compress. Deflate is always smallest and generally faster, but is
|
183 |
* rarely sent by servers, so client support could be buggier.
|
184 |
*
|
185 |
-
* @param bool $allowCompress allow the older compress encoding
|
186 |
-
*
|
187 |
-
* @param bool $allowDeflate allow the more recent deflate encoding
|
188 |
-
*
|
189 |
* @return array two values, 1st is the actual encoding method, 2nd is the
|
190 |
* alias of that method to use in the Content-Encoding header (some browsers
|
191 |
* call gzip "x-gzip" etc.)
|
192 |
*/
|
193 |
-
public static function getAcceptedEncoding($
|
194 |
{
|
195 |
// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
196 |
|
@@ -201,41 +197,18 @@ class HTTP_Encoder {
|
|
201 |
{
|
202 |
return array('', '');
|
203 |
}
|
204 |
-
|
205 |
-
|
206 |
-
if (0 === strpos($ae, 'gzip,') // most browsers
|
207 |
-
|| 0 === strpos($ae, 'deflate, gzip,') // opera
|
208 |
-
) {
|
209 |
return array('gzip', 'gzip');
|
210 |
}
|
211 |
-
|
212 |
-
if (
|
213 |
-
|
214 |
-
,$ae
|
215 |
-
,$m)) {
|
216 |
-
return array('gzip', $m[1]);
|
217 |
-
}
|
218 |
-
if ($allowDeflate) {
|
219 |
-
// deflate checks
|
220 |
-
$aeRev = strrev($ae);
|
221 |
-
if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
|
222 |
-
|| 0 === strpos($aeRev, 'etalfed,') // gecko
|
223 |
-
|| 0 === strpos($ae, 'deflate,') // opera
|
224 |
-
// slow parsing
|
225 |
-
|| preg_match(
|
226 |
-
'@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
|
227 |
-
return array('deflate', 'deflate');
|
228 |
-
}
|
229 |
-
}
|
230 |
-
if ($allowCompress && preg_match(
|
231 |
-
'@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
232 |
-
,$ae
|
233 |
-
,$m)) {
|
234 |
-
return array('compress', $m[1]);
|
235 |
}
|
|
|
236 |
return array('', '');
|
237 |
}
|
238 |
-
|
239 |
/**
|
240 |
* Encode (compress) the content
|
241 |
*
|
59 |
*
|
60 |
* @var bool
|
61 |
*/
|
62 |
+
public static $encodeToIe6 = true;
|
63 |
|
64 |
|
65 |
/**
|
96 |
$this->_headers['Content-Type'] = $spec['type'];
|
97 |
}
|
98 |
if (isset($spec['method'])
|
99 |
+
&& in_array($spec['method'], array('gzip', 'deflate', '')))
|
100 |
{
|
101 |
$this->_encodeMethod = array($spec['method'], $spec['method']);
|
102 |
} else {
|
182 |
* compress. Deflate is always smallest and generally faster, but is
|
183 |
* rarely sent by servers, so client support could be buggier.
|
184 |
*
|
|
|
|
|
|
|
|
|
185 |
* @return array two values, 1st is the actual encoding method, 2nd is the
|
186 |
* alias of that method to use in the Content-Encoding header (some browsers
|
187 |
* call gzip "x-gzip" etc.)
|
188 |
*/
|
189 |
+
public static function getAcceptedEncoding($compressions = 'gzip')
|
190 |
{
|
191 |
// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
192 |
|
197 |
{
|
198 |
return array('', '');
|
199 |
}
|
200 |
+
|
201 |
+
if (stristr($compressions, 'gzip') && stristr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode')) {
|
|
|
|
|
|
|
202 |
return array('gzip', 'gzip');
|
203 |
}
|
204 |
+
|
205 |
+
if (stristr($compressions, 'deflate') && stristr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate')) {
|
206 |
+
return array('deflate', 'deflate');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
}
|
208 |
+
|
209 |
return array('', '');
|
210 |
}
|
211 |
+
|
212 |
/**
|
213 |
* Encode (compress) the content
|
214 |
*
|
lib/Minify/Minify.php
CHANGED
@@ -207,7 +207,7 @@ class Minify {
|
|
207 |
}
|
208 |
|
209 |
// determine encoding
|
210 |
-
if (self::$_options['encodeOutput']) {
|
211 |
if (self::$_options['encodeMethod'] !== null) {
|
212 |
// controller specifically requested this
|
213 |
$contentEncoding = self::$_options['encodeMethod'];
|
@@ -217,7 +217,7 @@ class Minify {
|
|
217 |
// depending on what the client accepts, $contentEncoding may be
|
218 |
// 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
|
219 |
// getAcceptedEncoding(false, false) leaves out compress and deflate as options.
|
220 |
-
list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(
|
221 |
}
|
222 |
} else {
|
223 |
self::$_options['encodeMethod'] = ''; // identity (no encoding)
|
@@ -274,7 +274,7 @@ class Minify {
|
|
274 |
// memory.
|
275 |
$cacheId = self::_getCacheId();
|
276 |
$fullCacheId = (self::$_options['encodeMethod'])
|
277 |
-
? $cacheId . '
|
278 |
: $cacheId;
|
279 |
// check cache for valid entry
|
280 |
$cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
|
@@ -284,8 +284,13 @@ class Minify {
|
|
284 |
// generate & cache content
|
285 |
$content = self::_combineMinify();
|
286 |
self::$_cache->store($cacheId, $content);
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
290 |
}
|
291 |
} else {
|
@@ -293,9 +298,17 @@ class Minify {
|
|
293 |
$cacheIsReady = false;
|
294 |
$content = self::_combineMinify();
|
295 |
}
|
296 |
-
if (! $cacheIsReady
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
// still need to encode
|
298 |
-
$content = gzencode($content, self::$_options['encodeLevel']);
|
299 |
}
|
300 |
|
301 |
// add headers
|
207 |
}
|
208 |
|
209 |
// determine encoding
|
210 |
+
if (self::$_options['encodeOutput'] != '') {
|
211 |
if (self::$_options['encodeMethod'] !== null) {
|
212 |
// controller specifically requested this
|
213 |
$contentEncoding = self::$_options['encodeMethod'];
|
217 |
// depending on what the client accepts, $contentEncoding may be
|
218 |
// 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
|
219 |
// getAcceptedEncoding(false, false) leaves out compress and deflate as options.
|
220 |
+
list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(self::$_options['encodeOutput']);
|
221 |
}
|
222 |
} else {
|
223 |
self::$_options['encodeMethod'] = ''; // identity (no encoding)
|
274 |
// memory.
|
275 |
$cacheId = self::_getCacheId();
|
276 |
$fullCacheId = (self::$_options['encodeMethod'])
|
277 |
+
? $cacheId . self::$_options['encodeMethod']
|
278 |
: $cacheId;
|
279 |
// check cache for valid entry
|
280 |
$cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
|
284 |
// generate & cache content
|
285 |
$content = self::_combineMinify();
|
286 |
self::$_cache->store($cacheId, $content);
|
287 |
+
|
288 |
+
if (stristr(self::$_options['encodeOutput'], 'gzip') && function_exists('gzencode')) {
|
289 |
+
self::$_cache->store($cacheId . '.gzip', gzencode($content, self::$_options['encodeLevel']));
|
290 |
+
}
|
291 |
+
|
292 |
+
if (stristr(self::$_options['encodeOutput'], 'deflate') && function_exists('gzdeflate')) {
|
293 |
+
self::$_cache->store($cacheId . '.deflate', gzdeflate($content, self::$_options['encodeLevel']));
|
294 |
}
|
295 |
}
|
296 |
} else {
|
298 |
$cacheIsReady = false;
|
299 |
$content = self::_combineMinify();
|
300 |
}
|
301 |
+
if (! $cacheIsReady) {
|
302 |
+
switch (self::$_options['encodeMethod']) {
|
303 |
+
case 'gzip':
|
304 |
+
$content = gzencode($content, self::$_options['encodeLevel']);
|
305 |
+
break;
|
306 |
+
|
307 |
+
case 'deflate':
|
308 |
+
$content = gzdeflate($content, self::$_options['encodeLevel']);
|
309 |
+
break;
|
310 |
+
}
|
311 |
// still need to encode
|
|
|
312 |
}
|
313 |
|
314 |
// add headers
|
lib/Minify/Minify/CSS/UriRewriter.php
CHANGED
@@ -252,6 +252,7 @@ class Minify_CSS_UriRewriter {
|
|
252 |
break;
|
253 |
}
|
254 |
}
|
|
|
255 |
// strip doc root
|
256 |
$path = substr($path, strlen($realDocRoot));
|
257 |
|
@@ -269,6 +270,8 @@ class Minify_CSS_UriRewriter {
|
|
269 |
} while ($changed);
|
270 |
|
271 |
self::$debugText .= "traversals removed : {$uri}\n\n";
|
|
|
|
|
272 |
|
273 |
return $uri;
|
274 |
}
|
252 |
break;
|
253 |
}
|
254 |
}
|
255 |
+
|
256 |
// strip doc root
|
257 |
$path = substr($path, strlen($realDocRoot));
|
258 |
|
270 |
} while ($changed);
|
271 |
|
272 |
self::$debugText .= "traversals removed : {$uri}\n\n";
|
273 |
+
|
274 |
+
$uri = str_replace(w3_get_site_path(), w3_get_blog_path(), $uri);
|
275 |
|
276 |
return $uri;
|
277 |
}
|
lib/Minify/Minify/Cache/Eaccelerator.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Minify_Cache_Eaccelerator
|
4 |
+
* @package Minify
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* eAccelerator-based cache class for Minify
|
9 |
+
*
|
10 |
+
* <code>
|
11 |
+
* Minify::setCache(new Minify_Cache_Eaccelerator());
|
12 |
+
* </code>
|
13 |
+
*
|
14 |
+
* @package Minify
|
15 |
+
* @author Chris Edwards
|
16 |
+
**/
|
17 |
+
class Minify_Cache_Eaccelerator {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Create a Minify_Cache_Eaccelerator object, to be passed to
|
21 |
+
* Minify::setCache().
|
22 |
+
*
|
23 |
+
*
|
24 |
+
* @param int $expire seconds until expiration (default = 0
|
25 |
+
* meaning the item will not get an expiration date)
|
26 |
+
*
|
27 |
+
* @return null
|
28 |
+
*/
|
29 |
+
public function __construct($expire = 0)
|
30 |
+
{
|
31 |
+
$this->_exp = $expire;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Write data to cache.
|
36 |
+
*
|
37 |
+
* @param string $id cache id
|
38 |
+
*
|
39 |
+
* @param string $data
|
40 |
+
*
|
41 |
+
* @return bool success
|
42 |
+
*/
|
43 |
+
public function store($id, $data)
|
44 |
+
{
|
45 |
+
return eaccelerator_put($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get the size of a cache entry
|
50 |
+
*
|
51 |
+
* @param string $id cache id
|
52 |
+
*
|
53 |
+
* @return int size in bytes
|
54 |
+
*/
|
55 |
+
public function getSize($id)
|
56 |
+
{
|
57 |
+
return $this->_fetch($id)
|
58 |
+
? strlen($this->_data)
|
59 |
+
: false;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Does a valid cache entry exist?
|
64 |
+
*
|
65 |
+
* @param string $id cache id
|
66 |
+
*
|
67 |
+
* @param int $srcMtime mtime of the original source file(s)
|
68 |
+
*
|
69 |
+
* @return bool exists
|
70 |
+
*/
|
71 |
+
public function isValid($id, $srcMtime)
|
72 |
+
{
|
73 |
+
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Send the cached content to output
|
78 |
+
*
|
79 |
+
* @param string $id cache id
|
80 |
+
*/
|
81 |
+
public function display($id)
|
82 |
+
{
|
83 |
+
echo $this->_fetch($id)
|
84 |
+
? $this->_data
|
85 |
+
: '';
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Fetch the cached content
|
90 |
+
*
|
91 |
+
* @param string $id cache id
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public function fetch($id)
|
96 |
+
{
|
97 |
+
return $this->_fetch($id)
|
98 |
+
? $this->_data
|
99 |
+
: '';
|
100 |
+
}
|
101 |
+
|
102 |
+
private $_exp = null;
|
103 |
+
|
104 |
+
// cache of most recently fetched id
|
105 |
+
private $_lm = null;
|
106 |
+
private $_data = null;
|
107 |
+
private $_id = null;
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Fetch data and timestamp from apc, store in instance
|
111 |
+
*
|
112 |
+
* @param string $id
|
113 |
+
*
|
114 |
+
* @return bool success
|
115 |
+
*/
|
116 |
+
private function _fetch($id)
|
117 |
+
{
|
118 |
+
if ($this->_id === $id) {
|
119 |
+
return true;
|
120 |
+
}
|
121 |
+
$ret = eaccelerator_get($id);
|
122 |
+
if (false === $ret) {
|
123 |
+
$this->_id = null;
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
127 |
+
$this->_id = $id;
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
}
|
lib/Minify/Minify/Cache/XCache.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Minify_Cache_XCache
|
4 |
+
* @package Minify
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* XCache-based cache class for Minify
|
9 |
+
*
|
10 |
+
* <code>
|
11 |
+
* Minify::setCache(new Minify_Cache_XCache());
|
12 |
+
* </code>
|
13 |
+
*
|
14 |
+
* @package Minify
|
15 |
+
* @author Chris Edwards
|
16 |
+
**/
|
17 |
+
class Minify_Cache_XCache {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Create a Minify_Cache_XCache object, to be passed to
|
21 |
+
* Minify::setCache().
|
22 |
+
*
|
23 |
+
*
|
24 |
+
* @param int $expire seconds until expiration (default = 0
|
25 |
+
* meaning the item will not get an expiration date)
|
26 |
+
*
|
27 |
+
* @return null
|
28 |
+
*/
|
29 |
+
public function __construct($expire = 0)
|
30 |
+
{
|
31 |
+
$this->_exp = $expire;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Write data to cache.
|
36 |
+
*
|
37 |
+
* @param string $id cache id
|
38 |
+
*
|
39 |
+
* @param string $data
|
40 |
+
*
|
41 |
+
* @return bool success
|
42 |
+
*/
|
43 |
+
public function store($id, $data)
|
44 |
+
{
|
45 |
+
return xcache_set($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get the size of a cache entry
|
50 |
+
*
|
51 |
+
* @param string $id cache id
|
52 |
+
*
|
53 |
+
* @return int size in bytes
|
54 |
+
*/
|
55 |
+
public function getSize($id)
|
56 |
+
{
|
57 |
+
return $this->_fetch($id)
|
58 |
+
? strlen($this->_data)
|
59 |
+
: false;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Does a valid cache entry exist?
|
64 |
+
*
|
65 |
+
* @param string $id cache id
|
66 |
+
*
|
67 |
+
* @param int $srcMtime mtime of the original source file(s)
|
68 |
+
*
|
69 |
+
* @return bool exists
|
70 |
+
*/
|
71 |
+
public function isValid($id, $srcMtime)
|
72 |
+
{
|
73 |
+
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Send the cached content to output
|
78 |
+
*
|
79 |
+
* @param string $id cache id
|
80 |
+
*/
|
81 |
+
public function display($id)
|
82 |
+
{
|
83 |
+
echo $this->_fetch($id)
|
84 |
+
? $this->_data
|
85 |
+
: '';
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Fetch the cached content
|
90 |
+
*
|
91 |
+
* @param string $id cache id
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public function fetch($id)
|
96 |
+
{
|
97 |
+
return $this->_fetch($id)
|
98 |
+
? $this->_data
|
99 |
+
: '';
|
100 |
+
}
|
101 |
+
|
102 |
+
private $_exp = null;
|
103 |
+
|
104 |
+
// cache of most recently fetched id
|
105 |
+
private $_lm = null;
|
106 |
+
private $_data = null;
|
107 |
+
private $_id = null;
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Fetch data and timestamp from apc, store in instance
|
111 |
+
*
|
112 |
+
* @param string $id
|
113 |
+
*
|
114 |
+
* @return bool success
|
115 |
+
*/
|
116 |
+
private function _fetch($id)
|
117 |
+
{
|
118 |
+
if ($this->_id === $id) {
|
119 |
+
return true;
|
120 |
+
}
|
121 |
+
$ret = xcache_get($id);
|
122 |
+
if (false === $ret) {
|
123 |
+
$this->_id = null;
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
127 |
+
$this->_id = $id;
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
}
|
lib/Minify/Minify/CombineOnly.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Combine only minifier
|
5 |
+
*/
|
6 |
+
class Minify_CombineOnly
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* Minifies content
|
10 |
+
* @param string $content
|
11 |
+
* @param array $options
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public static function minify($content, $options = array())
|
15 |
+
{
|
16 |
+
if (isset($options['currentDir'])) {
|
17 |
+
require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/UriRewriter.php';
|
18 |
+
|
19 |
+
$content = Minify_CSS_UriRewriter::rewrite($content, $options['currentDir'], isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT'], isset($options['symlinks']) ? $options['symlinks'] : array());
|
20 |
+
} elseif (isset($options['prependRelativePath'])) {
|
21 |
+
require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/UriRewriter.php';
|
22 |
+
|
23 |
+
$content = Minify_CSS_UriRewriter::prepend($content, $options['prependRelativePath']);
|
24 |
+
}
|
25 |
+
|
26 |
+
return $content;
|
27 |
+
}
|
28 |
+
}
|
lib/Minify/Minify/HTML.php
CHANGED
@@ -265,9 +265,17 @@ class Minify_HTML {
|
|
265 |
|
266 |
protected function _removeCdata($str)
|
267 |
{
|
268 |
-
|
269 |
-
|
270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
protected function _needsCdata($str)
|
265 |
|
266 |
protected function _removeCdata($str)
|
267 |
{
|
268 |
+
if (false !== strpos($str, '<![CDATA[')) {
|
269 |
+
$str = str_replace('//<![CDATA[', '', $str);
|
270 |
+
$str = str_replace('/*<![CDATA[*/', '', $str);
|
271 |
+
$str = str_replace('<![CDATA[', '', $str);
|
272 |
+
|
273 |
+
$str = str_replace('//]]>', '', $str);
|
274 |
+
$str = str_replace('/*]]>*/', '', $str);
|
275 |
+
$str = str_replace(']]>', '', $str);
|
276 |
+
}
|
277 |
+
|
278 |
+
return $str;
|
279 |
}
|
280 |
|
281 |
protected function _needsCdata($str)
|
lib/W3/Cache.php
CHANGED
@@ -7,19 +7,27 @@
|
|
7 |
/**
|
8 |
* W3 Cache engine types
|
9 |
*/
|
10 |
-
if (!
|
11 |
define('W3_CACHE_MEMCACHED', 'memcached');
|
12 |
}
|
13 |
|
14 |
-
if (!
|
15 |
define('W3_CACHE_APC', 'apc');
|
16 |
}
|
17 |
|
18 |
-
if (!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
define('W3_CACHE_FILE', 'file');
|
20 |
}
|
21 |
|
22 |
-
if (!
|
23 |
define('W3_CACHE_FILE_PGCACHE', 'file_pgcache');
|
24 |
}
|
25 |
|
@@ -41,11 +49,11 @@ class W3_Cache
|
|
41 |
|
42 |
$instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
|
43 |
|
44 |
-
if (!
|
45 |
switch ($engine) {
|
46 |
case W3_CACHE_MEMCACHED:
|
47 |
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
|
48 |
-
$instances[$instance_key] = & W3_Cache_Memcached
|
49 |
break;
|
50 |
|
51 |
case W3_CACHE_APC:
|
@@ -53,6 +61,16 @@ class W3_Cache
|
|
53 |
$instances[$instance_key] = & new W3_Cache_Apc();
|
54 |
break;
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
case W3_CACHE_FILE:
|
57 |
require_once W3TC_LIB_W3_DIR . '/Cache/File.php';
|
58 |
$instances[$instance_key] = & new W3_Cache_File($config);
|
7 |
/**
|
8 |
* W3 Cache engine types
|
9 |
*/
|
10 |
+
if (!defined('W3_CACHE_MEMCACHED')) {
|
11 |
define('W3_CACHE_MEMCACHED', 'memcached');
|
12 |
}
|
13 |
|
14 |
+
if (!defined('W3_CACHE_APC')) {
|
15 |
define('W3_CACHE_APC', 'apc');
|
16 |
}
|
17 |
|
18 |
+
if (!defined('W3_CACHE_EACCELERATOR')) {
|
19 |
+
define('W3_CACHE_EACCELERATOR', 'eaccelerator');
|
20 |
+
}
|
21 |
+
|
22 |
+
if (!defined('W3_CACHE_XCACHE')) {
|
23 |
+
define('W3_CACHE_XCACHE', 'xcache');
|
24 |
+
}
|
25 |
+
|
26 |
+
if (!defined('W3_CACHE_FILE')) {
|
27 |
define('W3_CACHE_FILE', 'file');
|
28 |
}
|
29 |
|
30 |
+
if (!defined('W3_CACHE_FILE_PGCACHE')) {
|
31 |
define('W3_CACHE_FILE_PGCACHE', 'file_pgcache');
|
32 |
}
|
33 |
|
49 |
|
50 |
$instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
|
51 |
|
52 |
+
if (!isset($instances[$instance_key])) {
|
53 |
switch ($engine) {
|
54 |
case W3_CACHE_MEMCACHED:
|
55 |
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
|
56 |
+
$instances[$instance_key] = & new W3_Cache_Memcached($config);
|
57 |
break;
|
58 |
|
59 |
case W3_CACHE_APC:
|
61 |
$instances[$instance_key] = & new W3_Cache_Apc();
|
62 |
break;
|
63 |
|
64 |
+
case W3_CACHE_EACCELERATOR:
|
65 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/Eaccelerator.php';
|
66 |
+
$instances[$instance_key] = & new W3_Cache_Eaccelerator();
|
67 |
+
break;
|
68 |
+
|
69 |
+
case W3_CACHE_XCACHE:
|
70 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/Xcache.php';
|
71 |
+
$instances[$instance_key] = & new W3_Cache_Xcache();
|
72 |
+
break;
|
73 |
+
|
74 |
case W3_CACHE_FILE:
|
75 |
require_once W3TC_LIB_W3_DIR . '/Cache/File.php';
|
76 |
$instances[$instance_key] = & new W3_Cache_File($config);
|
lib/W3/Cache/Apc.php
CHANGED
@@ -48,7 +48,7 @@ class W3_Cache_Apc extends W3_Cache_Base
|
|
48 |
*/
|
49 |
function get($key)
|
50 |
{
|
51 |
-
return unserialize(apc_fetch($key));
|
52 |
}
|
53 |
|
54 |
/**
|
48 |
*/
|
49 |
function get($key)
|
50 |
{
|
51 |
+
return @unserialize(apc_fetch($key));
|
52 |
}
|
53 |
|
54 |
/**
|
lib/W3/Cache/Eaccelerator.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* eAccelerator class
|
5 |
+
*/
|
6 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/Base.php';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class W3_Cache_Eaccelerator
|
10 |
+
*/
|
11 |
+
class W3_Cache_Eaccelerator extends W3_Cache_Base
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Adds data
|
15 |
+
*
|
16 |
+
* @param string $key
|
17 |
+
* @param mixed $var
|
18 |
+
* @param integer $expire
|
19 |
+
* @return boolean
|
20 |
+
*/
|
21 |
+
function add($key, $var, $expire = 0)
|
22 |
+
{
|
23 |
+
if ($this->get($key) === false) {
|
24 |
+
return $this->set($key, $var, $expire);
|
25 |
+
}
|
26 |
+
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Sets data
|
32 |
+
*
|
33 |
+
* @param string $key
|
34 |
+
* @param mixed $var
|
35 |
+
* @param integer $expire
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
function set($key, $var, $expire = 0)
|
39 |
+
{
|
40 |
+
return eaccelerator_put($key, serialize($var), $expire);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns data
|
45 |
+
*
|
46 |
+
* @param string $key
|
47 |
+
* @return mixed
|
48 |
+
*/
|
49 |
+
function get($key)
|
50 |
+
{
|
51 |
+
return @unserialize(eaccelerator_get($key));
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Replaces data
|
56 |
+
*
|
57 |
+
* @param string $key
|
58 |
+
* @param mixed $var
|
59 |
+
* @param integer $expire
|
60 |
+
* @return boolean
|
61 |
+
*/
|
62 |
+
function replace($key, $var, $expire = 0)
|
63 |
+
{
|
64 |
+
if ($this->get($key) !== false) {
|
65 |
+
return $this->set($key, $var, $expire);
|
66 |
+
}
|
67 |
+
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Deletes data
|
73 |
+
*
|
74 |
+
* @param string $key
|
75 |
+
* @return boolean
|
76 |
+
*/
|
77 |
+
function delete($key)
|
78 |
+
{
|
79 |
+
return eaccelerator_rm($key);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Flushes all data
|
84 |
+
*
|
85 |
+
* @return boolean
|
86 |
+
*/
|
87 |
+
function flush()
|
88 |
+
{
|
89 |
+
@eaccelerator_clean();
|
90 |
+
@eaccelerator_clear();
|
91 |
+
|
92 |
+
return true;
|
93 |
+
}
|
94 |
+
}
|
lib/W3/Cache/File.php
CHANGED
@@ -34,7 +34,7 @@ class W3_Cache_File extends W3_Cache_Base
|
|
34 |
/**
|
35 |
* PHP4 constructor
|
36 |
*
|
37 |
-
|
38 |
* @return W3_Cache_File
|
39 |
*/
|
40 |
function W3_Cache_File($config = array())
|
34 |
/**
|
35 |
* PHP4 constructor
|
36 |
*
|
37 |
+
* @paran array $config
|
38 |
* @return W3_Cache_File
|
39 |
*/
|
40 |
function W3_Cache_File($config = array())
|
lib/W3/Cache/Memcached.php
CHANGED
@@ -1,66 +1,123 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Memcached
|
5 |
*/
|
6 |
-
|
7 |
-
/**
|
8 |
-
* W3 Cache memcached types
|
9 |
-
*/
|
10 |
-
if (! defined('W3_CACHE_MEMCACHED_AUTO')) {
|
11 |
-
define('W3_CACHE_MEMCACHED_AUTO', 'auto');
|
12 |
-
}
|
13 |
-
|
14 |
-
if (! defined('W3_CACHE_MEMCACHED_NATIVE')) {
|
15 |
-
define('W3_CACHE_MEMCACHED_NATIVE', 'native');
|
16 |
-
}
|
17 |
-
|
18 |
-
if (! defined('W3_CACHE_MEMCACHED_CLIENT')) {
|
19 |
-
define('W3_CACHE_MEMCACHED_CLIENT', 'client');
|
20 |
-
}
|
21 |
|
22 |
/**
|
23 |
* Class W3_Cache_Memcached
|
24 |
*/
|
25 |
-
class W3_Cache_Memcached
|
26 |
{
|
27 |
/**
|
28 |
-
*
|
29 |
*
|
30 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
31 |
*/
|
32 |
-
function
|
33 |
{
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
if (! isset($instances[$instance_key])) {
|
39 |
-
if ($engine == W3_CACHE_MEMCACHED_AUTO) {
|
40 |
-
$engine = (class_exists('Memcache') ? W3_CACHE_MEMCACHED_NATIVE : W3_CACHE_MEMCACHED_CLIENT);
|
41 |
-
}
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$instances[$instance_key] = & new W3_Cache_Memcached_Native($config);
|
47 |
-
break;
|
48 |
-
|
49 |
-
case W3_CACHE_MEMCACHED_CLIENT:
|
50 |
-
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached/Client.php';
|
51 |
-
$instances[$instance_key] = & new W3_Cache_Memcached_Client($config);
|
52 |
-
break;
|
53 |
-
|
54 |
-
default:
|
55 |
-
trigger_error('Incorrect memcached engine', E_USER_WARNING);
|
56 |
-
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached/Base.php';
|
57 |
-
$instances[$instance_key] = & new W3_Cache_Memcached_Base();
|
58 |
-
break;
|
59 |
}
|
60 |
-
|
61 |
-
|
62 |
}
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PECL Memcached class
|
5 |
*/
|
6 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/Base.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
/**
|
9 |
* Class W3_Cache_Memcached
|
10 |
*/
|
11 |
+
class W3_Cache_Memcached extends W3_Cache_Base
|
12 |
{
|
13 |
/**
|
14 |
+
* Memcache object
|
15 |
*
|
16 |
+
* @var Memcache
|
17 |
+
*/
|
18 |
+
var $_memcache = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* PHP5 constructor
|
22 |
*/
|
23 |
+
function __construct($config)
|
24 |
{
|
25 |
+
$this->_memcache = & new Memcache();
|
26 |
|
27 |
+
if (!empty($config['servers'])) {
|
28 |
+
$persistant = isset($config['persistant']) ? (boolean) $config['persistant'] : false;
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
foreach ((array) $config['servers'] as $server) {
|
31 |
+
list($ip, $port) = explode(':', $server);
|
32 |
+
$this->_memcache->addServer(trim($ip), (integer) trim($port), $persistant);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
+
} else {
|
35 |
+
return false;
|
36 |
}
|
37 |
|
38 |
+
if (!empty($config['compress_threshold'])) {
|
39 |
+
$this->_memcache->setCompressThreshold((integer) $config['compress_threshold']);
|
40 |
+
}
|
41 |
+
|
42 |
+
return true;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* PHP4 constructor
|
47 |
+
*/
|
48 |
+
function W3_Cache_Memcached($config)
|
49 |
+
{
|
50 |
+
$this->__construct($config);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Adds data
|
55 |
+
*
|
56 |
+
* @param string $key
|
57 |
+
* @param mixed $var
|
58 |
+
* @param integer $expire
|
59 |
+
* @return boolean
|
60 |
+
*/
|
61 |
+
function add($key, $var, $expire = 0)
|
62 |
+
{
|
63 |
+
return @$this->_memcache->add($key, $var, false, $expire);
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Sets data
|
68 |
+
*
|
69 |
+
* @param string $key
|
70 |
+
* @param mixed $var
|
71 |
+
* @param integer $expire
|
72 |
+
* @return boolean
|
73 |
+
*/
|
74 |
+
function set($key, $var, $expire = 0)
|
75 |
+
{
|
76 |
+
return @$this->_memcache->set($key, $var, false, $expire);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Returns data
|
81 |
+
*
|
82 |
+
* @param string $key
|
83 |
+
* @return mixed
|
84 |
+
*/
|
85 |
+
function get($key)
|
86 |
+
{
|
87 |
+
return @$this->_memcache->get($key);
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Replaces data
|
92 |
+
*
|
93 |
+
* @param string $key
|
94 |
+
* @param mixed $var
|
95 |
+
* @param integer $expire
|
96 |
+
* @return boolean
|
97 |
+
*/
|
98 |
+
function replace($key, $var, $expire = 0)
|
99 |
+
{
|
100 |
+
return @$this->_memcache->replace($key, $var, false, $expire);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Deletes data
|
105 |
+
*
|
106 |
+
* @param string $key
|
107 |
+
* @return boolean
|
108 |
+
*/
|
109 |
+
function delete($key)
|
110 |
+
{
|
111 |
+
return @$this->_memcache->delete($key);
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Flushes all data
|
116 |
+
*
|
117 |
+
* @return boolean
|
118 |
+
*/
|
119 |
+
function flush()
|
120 |
+
{
|
121 |
+
return @$this->_memcache->flush();
|
122 |
}
|
123 |
}
|
lib/W3/Cache/Memcached/Base.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Base memcached class
|
5 |
-
*/
|
6 |
-
require_once W3TC_LIB_W3_DIR . '/Cache/Base.php';
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class W3_Cache_Memcached_Base
|
10 |
-
*/
|
11 |
-
class W3_Cache_Memcached_Base extends W3_Cache_Base
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* Server config
|
15 |
-
*
|
16 |
-
* @var array
|
17 |
-
*/
|
18 |
-
var $config = array();
|
19 |
-
|
20 |
-
/**
|
21 |
-
* PHP5 Constructor
|
22 |
-
*
|
23 |
-
* @param array $config
|
24 |
-
*/
|
25 |
-
function __construct($config)
|
26 |
-
{
|
27 |
-
$this->config = $config;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* PHP4 Constructor
|
32 |
-
*
|
33 |
-
* @param array $config
|
34 |
-
* @return W3_Cache_Memcached_Base
|
35 |
-
*/
|
36 |
-
function W3_Cache_Memcached_Base($config)
|
37 |
-
{
|
38 |
-
$this->__construct($config);
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Inits the engine
|
43 |
-
*
|
44 |
-
* @abstract
|
45 |
-
* @return boolean
|
46 |
-
*/
|
47 |
-
function connect()
|
48 |
-
{
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Disconnects from the memcached server
|
54 |
-
*
|
55 |
-
* @abstract
|
56 |
-
* @return bool
|
57 |
-
*/
|
58 |
-
function disconnect()
|
59 |
-
{
|
60 |
-
return false;
|
61 |
-
}
|
62 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/W3/Cache/Memcached/Client.php
DELETED
@@ -1,159 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* PHP memcached client
|
5 |
-
*/
|
6 |
-
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached/Base.php';
|
7 |
-
require_once W3TC_LIB_DIR . '/memcached-client.php';
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class W3_Cache_Memcached_Client
|
11 |
-
*/
|
12 |
-
class W3_Cache_Memcached_Client extends W3_Cache_Memcached_Base
|
13 |
-
{
|
14 |
-
/**
|
15 |
-
* Memcached object
|
16 |
-
*
|
17 |
-
* @var memcached
|
18 |
-
*/
|
19 |
-
var $_memcached = null;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Conects to the server
|
23 |
-
*
|
24 |
-
* @return boolean
|
25 |
-
*/
|
26 |
-
function connect()
|
27 |
-
{
|
28 |
-
if (empty($this->config['servers'])) {
|
29 |
-
return false;
|
30 |
-
}
|
31 |
-
|
32 |
-
$servers = array();
|
33 |
-
|
34 |
-
foreach ($this->config['servers'] as $server) {
|
35 |
-
list ($host, $port) = explode(':', $server);
|
36 |
-
$servers[] = sprintf('%s:%d', trim($host), trim($port));
|
37 |
-
}
|
38 |
-
|
39 |
-
$this->_memcached = & new memcached_client(array(
|
40 |
-
'servers' => $servers,
|
41 |
-
'persistant' => false,
|
42 |
-
'debug' => false,
|
43 |
-
'compress_threshold' => (! empty($this->config['compress_threshold']) ? (integer) $this->config['compress_threshold'] : 0)
|
44 |
-
));
|
45 |
-
|
46 |
-
return true;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Disconnects from servers
|
51 |
-
*
|
52 |
-
* @return boolean
|
53 |
-
*/
|
54 |
-
function disconnect()
|
55 |
-
{
|
56 |
-
if (is_object($this->_memcached)) {
|
57 |
-
$this->_memcached->disconnect_all();
|
58 |
-
return true;
|
59 |
-
}
|
60 |
-
|
61 |
-
return false;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Adds data
|
66 |
-
*
|
67 |
-
* @param string $key
|
68 |
-
* @param mixed $var
|
69 |
-
* @param integer $expire
|
70 |
-
* @return boolean
|
71 |
-
*/
|
72 |
-
function add($key, $var, $expire = 0)
|
73 |
-
{
|
74 |
-
if (is_object($this->_memcached)) {
|
75 |
-
return $this->_memcached->add($key, $var, $expire);
|
76 |
-
}
|
77 |
-
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Sets data
|
83 |
-
*
|
84 |
-
* @param string $key
|
85 |
-
* @param mixed $var
|
86 |
-
* @param integer $expire
|
87 |
-
* @return boolean
|
88 |
-
*/
|
89 |
-
function set($key, $var, $expire = 0)
|
90 |
-
{
|
91 |
-
if (is_object($this->_memcached)) {
|
92 |
-
return $this->_memcached->set($key, $var, $expire);
|
93 |
-
}
|
94 |
-
|
95 |
-
return false;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Returns data
|
100 |
-
*
|
101 |
-
* @param string $key
|
102 |
-
* @return mixed
|
103 |
-
*/
|
104 |
-
function get($key)
|
105 |
-
{
|
106 |
-
if (is_object($this->_memcached)) {
|
107 |
-
return $this->_memcached->get($key);
|
108 |
-
}
|
109 |
-
|
110 |
-
return false;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Replaces data
|
115 |
-
*
|
116 |
-
* @param string $key
|
117 |
-
* @param mixed $var
|
118 |
-
* @param integer $expire
|
119 |
-
* @return boolean
|
120 |
-
*/
|
121 |
-
function replace($key, $var, $expire = 0)
|
122 |
-
{
|
123 |
-
if (is_object($this->_memcached)) {
|
124 |
-
return $this->_memcached->replace($key, $var, $expire);
|
125 |
-
}
|
126 |
-
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Deletes data
|
132 |
-
*
|
133 |
-
* @param string $key
|
134 |
-
* @return boolean
|
135 |
-
*/
|
136 |
-
function delete($key)
|
137 |
-
{
|
138 |
-
if (is_object($this->_memcached)) {
|
139 |
-
return $this->_memcached->delete($key);
|
140 |
-
}
|
141 |
-
|
142 |
-
return false;
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Fluhes all data
|
147 |
-
*
|
148 |
-
* @todo
|
149 |
-
* @return boolean
|
150 |
-
*/
|
151 |
-
function flush()
|
152 |
-
{
|
153 |
-
if (is_object($this->_memcached)) {
|
154 |
-
return $this->_memcached->flush_all();
|
155 |
-
}
|
156 |
-
|
157 |
-
return false;
|
158 |
-
}
|
159 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/W3/Cache/Memcached/Native.php
DELETED
@@ -1,145 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* PECL Memcached class
|
5 |
-
*/
|
6 |
-
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached/Base.php';
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class W3_Cache_Memcached_Native
|
10 |
-
*/
|
11 |
-
class W3_Cache_Memcached_Native extends W3_Cache_Memcached_Base
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* Memcache object
|
15 |
-
*
|
16 |
-
* @var Memcache
|
17 |
-
*/
|
18 |
-
var $_memcache = null;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* PHP5 constructor
|
22 |
-
*
|
23 |
-
*/
|
24 |
-
function __construct($config)
|
25 |
-
{
|
26 |
-
parent::__construct($config);
|
27 |
-
|
28 |
-
$this->_memcache = & new Memcache();
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* PHP4 constructor
|
33 |
-
*
|
34 |
-
*/
|
35 |
-
function W3_Cache_Memcached_Native($config)
|
36 |
-
{
|
37 |
-
$this->__construct($config);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Connects to the server
|
42 |
-
*
|
43 |
-
* @return boolean
|
44 |
-
*/
|
45 |
-
function connect()
|
46 |
-
{
|
47 |
-
if (! empty($this->config['servers'])) {
|
48 |
-
$persistant = isset($this->config['persistant']) ? (boolean) $this->config['persistant'] : false;
|
49 |
-
|
50 |
-
foreach ((array) $this->config['servers'] as $server) {
|
51 |
-
list ($ip, $port) = explode(':', $server);
|
52 |
-
$this->_memcache->addServer(trim($ip), (integer) trim($port), $persistant);
|
53 |
-
}
|
54 |
-
} else {
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
|
58 |
-
if (! empty($this->config['compress_threshold'])) {
|
59 |
-
$this->_memcache->setCompressThreshold((integer) $this->config['compress_threshold']);
|
60 |
-
}
|
61 |
-
|
62 |
-
return true;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Disconnects from the server
|
67 |
-
*
|
68 |
-
* @return boolean
|
69 |
-
*/
|
70 |
-
function disconnect()
|
71 |
-
{
|
72 |
-
return @$this->_memcache->close();
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Adds data
|
77 |
-
*
|
78 |
-
* @param string $key
|
79 |
-
* @param mixed $var
|
80 |
-
* @param integer $expire
|
81 |
-
* @return boolean
|
82 |
-
*/
|
83 |
-
function add($key, $var, $expire = 0)
|
84 |
-
{
|
85 |
-
return @$this->_memcache->add($key, $var, false, $expire);
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Sets data
|
90 |
-
*
|
91 |
-
* @param string $key
|
92 |
-
* @param mixed $var
|
93 |
-
* @param integer $expire
|
94 |
-
* @return boolean
|
95 |
-
*/
|
96 |
-
function set($key, $var, $expire = 0)
|
97 |
-
{
|
98 |
-
return @$this->_memcache->set($key, $var, false, $expire);
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Returns data
|
103 |
-
*
|
104 |
-
* @param string $key
|
105 |
-
* @return mixed
|
106 |
-
*/
|
107 |
-
function get($key)
|
108 |
-
{
|
109 |
-
return @$this->_memcache->get($key);
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Replaces data
|
114 |
-
*
|
115 |
-
* @param string $key
|
116 |
-
* @param mixed $var
|
117 |
-
* @param integer $expire
|
118 |
-
* @return boolean
|
119 |
-
*/
|
120 |
-
function replace($key, $var, $expire = 0)
|
121 |
-
{
|
122 |
-
return @$this->_memcache->replace($key, $var, false, $expire);
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Deletes data
|
127 |
-
*
|
128 |
-
* @param string $key
|
129 |
-
* @return boolean
|
130 |
-
*/
|
131 |
-
function delete($key)
|
132 |
-
{
|
133 |
-
return @$this->_memcache->delete($key);
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Flushes all data
|
138 |
-
*
|
139 |
-
* @return boolean
|
140 |
-
*/
|
141 |
-
function flush()
|
142 |
-
{
|
143 |
-
return @$this->_memcache->flush();
|
144 |
-
}
|
145 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/W3/Cache/Xcache.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* XCache class
|
5 |
+
*/
|
6 |
+
require_once W3TC_LIB_W3_DIR . '/Cache/Base.php';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class W3_Cache_Xcache
|
10 |
+
*/
|
11 |
+
class W3_Cache_Xcache extends W3_Cache_Base
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Adds data
|
15 |
+
*
|
16 |
+
* @param string $key
|
17 |
+
* @param mixed $var
|
18 |
+
* @param integer $expire
|
19 |
+
* @return boolean
|
20 |
+
*/
|
21 |
+
function add($key, $var, $expire = 0)
|
22 |
+
{
|
23 |
+
if ($this->get($key) === false) {
|
24 |
+
return $this->set($key, $var, $expire);
|
25 |
+
}
|
26 |
+
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Sets data
|
32 |
+
*
|
33 |
+
* @param string $key
|
34 |
+
* @param mixed $var
|
35 |
+
* @param integer $expire
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
function set($key, $var, $expire = 0)
|
39 |
+
{
|
40 |
+
return xcache_set($key, serialize($var), $expire);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns data
|
45 |
+
*
|
46 |
+
* @param string $key
|
47 |
+
* @return mixed
|
48 |
+
*/
|
49 |
+
function get($key)
|
50 |
+
{
|
51 |
+
return @unserialize(xcache_get($key));
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Replaces data
|
56 |
+
*
|
57 |
+
* @param string $key
|
58 |
+
* @param mixed $var
|
59 |
+
* @param integer $expire
|
60 |
+
* @return boolean
|
61 |
+
*/
|
62 |
+
function replace($key, $var, $expire = 0)
|
63 |
+
{
|
64 |
+
if ($this->get($key) !== false) {
|
65 |
+
return $this->set($key, $var, $expire);
|
66 |
+
}
|
67 |
+
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Deletes data
|
73 |
+
*
|
74 |
+
* @param string $key
|
75 |
+
* @return boolean
|
76 |
+
*/
|
77 |
+
function delete($key)
|
78 |
+
{
|
79 |
+
return xcache_unset($key);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Flushes all data
|
84 |
+
*
|
85 |
+
* @return boolean
|
86 |
+
*/
|
87 |
+
function flush()
|
88 |
+
{
|
89 |
+
xcache_clear_cache(XC_TYPE_VAR, 0);
|
90 |
+
|
91 |
+
return true;
|
92 |
+
}
|
93 |
+
}
|
lib/W3/Cdn/Base.php
CHANGED
@@ -30,7 +30,7 @@ class W3_Cdn_Base
|
|
30 |
|
31 |
/**
|
32 |
* PHP5 Constructor
|
33 |
-
|
34 |
* @param array $config
|
35 |
*/
|
36 |
function __construct($config)
|
@@ -40,7 +40,7 @@ class W3_Cdn_Base
|
|
40 |
|
41 |
/**
|
42 |
* PHP4 Constructor
|
43 |
-
|
44 |
* @param array $config
|
45 |
*/
|
46 |
function W3_Cdn_Base($config)
|
@@ -53,9 +53,10 @@ class W3_Cdn_Base
|
|
53 |
*
|
54 |
* @param array $files
|
55 |
* @param array $results
|
|
|
56 |
* @return boolean
|
57 |
*/
|
58 |
-
function upload($files, &$results)
|
59 |
{
|
60 |
$results = $this->get_results($files, W3_CDN_RESULT_HALT, 'Not implemented.');
|
61 |
return false;
|
@@ -88,7 +89,7 @@ class W3_Cdn_Base
|
|
88 |
|
89 |
/**
|
90 |
* Returns CDN domain
|
91 |
-
|
92 |
* @return string
|
93 |
*/
|
94 |
function get_domain()
|
@@ -98,7 +99,7 @@ class W3_Cdn_Base
|
|
98 |
|
99 |
/**
|
100 |
* Returns via string
|
101 |
-
|
102 |
* @return string
|
103 |
*/
|
104 |
function get_via()
|
@@ -108,7 +109,7 @@ class W3_Cdn_Base
|
|
108 |
|
109 |
/**
|
110 |
* Formats object URL
|
111 |
-
|
112 |
* @param string $path
|
113 |
* @return string
|
114 |
*/
|
30 |
|
31 |
/**
|
32 |
* PHP5 Constructor
|
33 |
+
*
|
34 |
* @param array $config
|
35 |
*/
|
36 |
function __construct($config)
|
40 |
|
41 |
/**
|
42 |
* PHP4 Constructor
|
43 |
+
*
|
44 |
* @param array $config
|
45 |
*/
|
46 |
function W3_Cdn_Base($config)
|
53 |
*
|
54 |
* @param array $files
|
55 |
* @param array $results
|
56 |
+
* @param boolean $force_rewrite
|
57 |
* @return boolean
|
58 |
*/
|
59 |
+
function upload($files, &$results, $force_rewrite = false)
|
60 |
{
|
61 |
$results = $this->get_results($files, W3_CDN_RESULT_HALT, 'Not implemented.');
|
62 |
return false;
|
89 |
|
90 |
/**
|
91 |
* Returns CDN domain
|
92 |
+
*
|
93 |
* @return string
|
94 |
*/
|
95 |
function get_domain()
|
99 |
|
100 |
/**
|
101 |
* Returns via string
|
102 |
+
*
|
103 |
* @return string
|
104 |
*/
|
105 |
function get_via()
|
109 |
|
110 |
/**
|
111 |
* Formats object URL
|
112 |
+
*
|
113 |
* @param string $path
|
114 |
* @return string
|
115 |
*/
|
lib/W3/Cdn/Ftp.php
CHANGED
@@ -77,14 +77,27 @@ class W3_Cdn_Ftp extends W3_Cdn_Base
|
|
77 |
@ftp_close($this->_ftp);
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
/**
|
81 |
* Uploads files to FTP
|
82 |
*
|
83 |
* @param array $files
|
84 |
* @param array $results
|
|
|
85 |
* @return boolean
|
86 |
*/
|
87 |
-
function upload($files, &$results)
|
88 |
{
|
89 |
$count = 0;
|
90 |
$error = null;
|
@@ -126,13 +139,22 @@ class W3_Cdn_Ftp extends W3_Cdn_Base
|
|
126 |
}
|
127 |
|
128 |
$remote_file = basename($remote_path);
|
|
|
129 |
|
130 |
-
if (
|
131 |
-
$
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
$result = @ftp_put($this->_ftp, $remote_file, $local_path, FTP_BINARY);
|
|
|
|
|
136 |
$results[] = $this->get_result($local_path, $remote_path, ($result ? W3_CDN_RESULT_OK : W3_CDN_RESULT_ERROR), ($result ? 'OK' : 'Unable to upload file'));
|
137 |
|
138 |
if ($result) {
|
@@ -198,10 +220,7 @@ class W3_Cdn_Ftp extends W3_Cdn_Base
|
|
198 |
$tmp_file = 'test_file_' . $rand;
|
199 |
$tmp_path = $upload_info['path'] . '/' . $tmp_file;
|
200 |
|
201 |
-
if (
|
202 |
-
@fputs($fp, $rand);
|
203 |
-
@fclose($fp);
|
204 |
-
} else {
|
205 |
$error = sprintf('Unable to create file: %s.', $tmp_path);
|
206 |
return false;
|
207 |
}
|
@@ -244,7 +263,7 @@ class W3_Cdn_Ftp extends W3_Cdn_Base
|
|
244 |
|
245 |
/**
|
246 |
* Returns CDN domain
|
247 |
-
|
248 |
* @return string
|
249 |
*/
|
250 |
function get_domain()
|
77 |
@ftp_close($this->_ftp);
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
+
* Sends MDTM command
|
82 |
+
* @param string $remote_file
|
83 |
+
* @return boolean
|
84 |
+
*/
|
85 |
+
function _mdtm($remote_file, $mtime)
|
86 |
+
{
|
87 |
+
$command = sprintf('MDTM %s %s', date('YmdHis', $mtime), $remote_file);
|
88 |
+
|
89 |
+
return @ftp_raw($this->_ftp, $command);
|
90 |
+
}
|
91 |
+
|
92 |
/**
|
93 |
* Uploads files to FTP
|
94 |
*
|
95 |
* @param array $files
|
96 |
* @param array $results
|
97 |
+
* @param boolean $force_rewrite
|
98 |
* @return boolean
|
99 |
*/
|
100 |
+
function upload($files, &$results, $force_rewrite = false)
|
101 |
{
|
102 |
$count = 0;
|
103 |
$error = null;
|
139 |
}
|
140 |
|
141 |
$remote_file = basename($remote_path);
|
142 |
+
$mtime = @filemtime($local_path);
|
143 |
|
144 |
+
if (! $force_rewrite) {
|
145 |
+
$size = @filesize($local_path);
|
146 |
+
$ftp_size = @ftp_size($this->_ftp, $remote_file);
|
147 |
+
$ftp_mtime = @ftp_mdtm($this->_ftp, $remote_file);
|
148 |
+
|
149 |
+
if ($size === $ftp_size && $mtime === $ftp_mtime) {
|
150 |
+
$results[] = $this->get_result($local_path, $remote_path, W3_CDN_RESULT_ERROR, 'File already exists');
|
151 |
+
continue;
|
152 |
+
}
|
153 |
}
|
154 |
|
155 |
$result = @ftp_put($this->_ftp, $remote_file, $local_path, FTP_BINARY);
|
156 |
+
$this->_mdtm($remote_file, $mtime);
|
157 |
+
|
158 |
$results[] = $this->get_result($local_path, $remote_path, ($result ? W3_CDN_RESULT_OK : W3_CDN_RESULT_ERROR), ($result ? 'OK' : 'Unable to upload file'));
|
159 |
|
160 |
if ($result) {
|
220 |
$tmp_file = 'test_file_' . $rand;
|
221 |
$tmp_path = $upload_info['path'] . '/' . $tmp_file;
|
222 |
|
223 |
+
if (! @file_put_contents($tmp_path, $rand)) {
|
|
|
|
|
|
|
224 |
$error = sprintf('Unable to create file: %s.', $tmp_path);
|
225 |
return false;
|
226 |
}
|
263 |
|
264 |
/**
|
265 |
* Returns CDN domain
|
266 |
+
*
|
267 |
* @return string
|
268 |
*/
|
269 |
function get_domain()
|
lib/W3/Cdn/Mirror.php
CHANGED
@@ -15,9 +15,10 @@ class W3_Cdn_Mirror extends W3_Cdn_Base
|
|
15 |
*
|
16 |
* @param array $files
|
17 |
* @param array $results
|
|
|
18 |
* @return boolean
|
19 |
*/
|
20 |
-
function upload($files, &$results)
|
21 |
{
|
22 |
$results = $this->get_results($files, W3_CDN_RESULT_OK, 'OK');
|
23 |
|
15 |
*
|
16 |
* @param array $files
|
17 |
* @param array $results
|
18 |
+
* @param boolean $force_rewrite
|
19 |
* @return boolean
|
20 |
*/
|
21 |
+
function upload($files, &$results, $force_rewrite = false)
|
22 |
{
|
23 |
$results = $this->get_results($files, W3_CDN_RESULT_OK, 'OK');
|
24 |
|
lib/W3/Cdn/S3.php
CHANGED
@@ -7,14 +7,14 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
7 |
{
|
8 |
/**
|
9 |
* S3 object
|
10 |
-
|
11 |
* @var S3
|
12 |
*/
|
13 |
var $_s3 = null;
|
14 |
|
15 |
/**
|
16 |
* Inits S3 object
|
17 |
-
|
18 |
* @param string $error
|
19 |
* @return boolean
|
20 |
*/
|
@@ -48,9 +48,10 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
48 |
*
|
49 |
* @param array $files
|
50 |
* @param array $results
|
|
|
51 |
* @return boolean
|
52 |
*/
|
53 |
-
function upload($files, &$results)
|
54 |
{
|
55 |
$count = 0;
|
56 |
$error = null;
|
@@ -66,11 +67,18 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
66 |
continue;
|
67 |
}
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
$result = @$this->_s3->putObjectFile($local_path, $this->_config['bucket'], $remote_path, S3::ACL_PUBLIC_READ);
|
@@ -185,7 +193,7 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
185 |
|
186 |
/**
|
187 |
* Returns CDN domain
|
188 |
-
|
189 |
* @return string
|
190 |
*/
|
191 |
function get_domain()
|
@@ -201,7 +209,7 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
201 |
|
202 |
/**
|
203 |
* Returns via string
|
204 |
-
|
205 |
* @return string
|
206 |
*/
|
207 |
function get_via()
|
@@ -213,7 +221,7 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
213 |
|
214 |
/**
|
215 |
* Creates bucket
|
216 |
-
|
217 |
* @param string $error
|
218 |
* @return boolean
|
219 |
*/
|
7 |
{
|
8 |
/**
|
9 |
* S3 object
|
10 |
+
*
|
11 |
* @var S3
|
12 |
*/
|
13 |
var $_s3 = null;
|
14 |
|
15 |
/**
|
16 |
* Inits S3 object
|
17 |
+
*
|
18 |
* @param string $error
|
19 |
* @return boolean
|
20 |
*/
|
48 |
*
|
49 |
* @param array $files
|
50 |
* @param array $results
|
51 |
+
* @param boolean $force_rewrite
|
52 |
* @return boolean
|
53 |
*/
|
54 |
+
function upload($files, &$results, $force_rewrite = false)
|
55 |
{
|
56 |
$count = 0;
|
57 |
$error = null;
|
67 |
continue;
|
68 |
}
|
69 |
|
70 |
+
if (! $force_rewrite) {
|
71 |
+
$info = @$this->_s3->getObjectInfo($this->_config['bucket'], $remote_path);
|
72 |
+
|
73 |
+
if ($info) {
|
74 |
+
$hash = @md5_file($local_path);
|
75 |
+
$s3_hash = (isset($info['hash']) ? $info['hash'] : '');
|
76 |
+
|
77 |
+
if ($hash === $s3_hash) {
|
78 |
+
$results[] = $this->get_result($local_path, $remote_path, W3_CDN_RESULT_ERROR, 'Object already exists');
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
}
|
82 |
}
|
83 |
|
84 |
$result = @$this->_s3->putObjectFile($local_path, $this->_config['bucket'], $remote_path, S3::ACL_PUBLIC_READ);
|
193 |
|
194 |
/**
|
195 |
* Returns CDN domain
|
196 |
+
*
|
197 |
* @return string
|
198 |
*/
|
199 |
function get_domain()
|
209 |
|
210 |
/**
|
211 |
* Returns via string
|
212 |
+
*
|
213 |
* @return string
|
214 |
*/
|
215 |
function get_via()
|
221 |
|
222 |
/**
|
223 |
* Creates bucket
|
224 |
+
*
|
225 |
* @param string $error
|
226 |
* @return boolean
|
227 |
*/
|
lib/W3/Config.php
CHANGED
@@ -31,8 +31,8 @@ class W3_Config
|
|
31 |
'dbcache.debug' => 'boolean',
|
32 |
'dbcache.engine' => 'string',
|
33 |
'dbcache.file.gc' => 'integer',
|
34 |
-
'dbcache.memcached.engine' => 'string',
|
35 |
'dbcache.memcached.servers' => 'array',
|
|
|
36 |
'dbcache.reject.logged' => 'boolean',
|
37 |
'dbcache.reject.uri' => 'array',
|
38 |
'dbcache.reject.cookie' => 'array',
|
@@ -43,8 +43,8 @@ class W3_Config
|
|
43 |
'pgcache.debug' => 'boolean',
|
44 |
'pgcache.engine' => 'string',
|
45 |
'pgcache.file.gc' => 'integer',
|
46 |
-
'pgcache.memcached.engine' => 'string',
|
47 |
'pgcache.memcached.servers' => 'array',
|
|
|
48 |
'pgcache.lifetime' => 'integer',
|
49 |
'pgcache.compression' => 'string',
|
50 |
'pgcache.cache.query' => 'boolean',
|
@@ -66,12 +66,11 @@ class W3_Config
|
|
66 |
'minify.engine' => 'string',
|
67 |
'minify.file.locking' => 'boolean',
|
68 |
'minify.file.gc' => 'integer',
|
69 |
-
'minify.memcached.engine' => 'string',
|
70 |
'minify.memcached.servers' => 'array',
|
|
|
71 |
'minify.rewrite' => 'boolean',
|
72 |
'minify.fixtime' => 'integer',
|
73 |
-
'minify.
|
74 |
-
'minify.compress.ie6' => 'boolean',
|
75 |
'minify.options' => 'array',
|
76 |
'minify.symlinks' => 'array',
|
77 |
'minify.maxage' => 'integer',
|
@@ -79,10 +78,12 @@ class W3_Config
|
|
79 |
'minify.upload' => 'boolean',
|
80 |
'minify.html.enable' => 'boolean',
|
81 |
'minify.html.reject.admin' => 'boolean',
|
|
|
82 |
'minify.html.inline.css' => 'boolean',
|
83 |
'minify.html.inline.js' => 'boolean',
|
84 |
'minify.html.strip.crlf' => 'boolean',
|
85 |
'minify.css.enable' => 'boolean',
|
|
|
86 |
'minify.css.strip.comments' => 'boolean',
|
87 |
'minify.css.strip.crlf' => 'boolean',
|
88 |
'minify.css.groups' => 'array',
|
@@ -107,7 +108,8 @@ class W3_Config
|
|
107 |
'cdn.custom.files' => 'array',
|
108 |
'cdn.import.external' => 'boolean',
|
109 |
'cdn.import.files' => 'string',
|
110 |
-
'cdn.limit
|
|
|
111 |
'cdn.mirror.domain' => 'string',
|
112 |
'cdn.ftp.host' => 'string',
|
113 |
'cdn.ftp.user' => 'string',
|
@@ -130,11 +132,12 @@ class W3_Config
|
|
130 |
'common.support' => 'string',
|
131 |
'common.install' => 'integer',
|
132 |
'common.tweeted' => 'integer',
|
133 |
-
|
|
|
|
|
134 |
|
135 |
'notes.defaults' => 'boolean',
|
136 |
'notes.wp_content_perms' => 'boolean',
|
137 |
-
'notes.cdn_first_time' => 'boolean',
|
138 |
'notes.php_is_old' => 'boolean',
|
139 |
'notes.theme_changed' => 'boolean',
|
140 |
'notes.wp_upgraded' => 'boolean',
|
@@ -152,14 +155,14 @@ class W3_Config
|
|
152 |
);
|
153 |
|
154 |
var $_defaults = array(
|
155 |
-
'dbcache.enabled' =>
|
156 |
'dbcache.debug' => false,
|
157 |
'dbcache.engine' => 'file',
|
158 |
'dbcache.file.gc' => 3600,
|
159 |
-
'dbcache.memcached.engine' => 'auto',
|
160 |
'dbcache.memcached.servers' => array(
|
161 |
-
'
|
162 |
),
|
|
|
163 |
'dbcache.reject.logged' => true,
|
164 |
'dbcache.reject.uri' => array(),
|
165 |
'dbcache.reject.cookie' => array(),
|
@@ -170,12 +173,12 @@ class W3_Config
|
|
170 |
|
171 |
'pgcache.enabled' => true,
|
172 |
'pgcache.debug' => false,
|
173 |
-
'pgcache.engine' => '
|
174 |
'pgcache.file.gc' => 3600,
|
175 |
-
'pgcache.memcached.engine' => 'auto',
|
176 |
'pgcache.memcached.servers' => array(
|
177 |
-
'
|
178 |
),
|
|
|
179 |
'pgcache.lifetime' => 3600,
|
180 |
'pgcache.compression' => 'gzip',
|
181 |
'pgcache.cache.query' => true,
|
@@ -273,7 +276,6 @@ class W3_Config
|
|
273 |
'SEC',
|
274 |
'SGH',
|
275 |
'SHARP-TQ-GX10',
|
276 |
-
'SIE',
|
277 |
'SPH',
|
278 |
'Sagem',
|
279 |
'Samsung',
|
@@ -316,14 +318,13 @@ class W3_Config
|
|
316 |
'minify.engine' => 'file',
|
317 |
'minify.file.locking' => true,
|
318 |
'minify.file.gc' => 86400,
|
319 |
-
'minify.memcached.engine' => 'auto',
|
320 |
'minify.memcached.servers' => array(
|
321 |
-
'
|
322 |
),
|
|
|
323 |
'minify.rewrite' => true,
|
324 |
'minify.fixtime' => 0,
|
325 |
-
'minify.
|
326 |
-
'minify.compress.ie6' => true,
|
327 |
'minify.options' => array(
|
328 |
'bubbleCssImports' => false,
|
329 |
'minApp' => array(
|
@@ -335,12 +336,14 @@ class W3_Config
|
|
335 |
'minify.maxage' => 86400,
|
336 |
'minify.lifetime' => 86400,
|
337 |
'minify.upload' => true,
|
338 |
-
'minify.html.enable' =>
|
339 |
-
'minify.html.reject.admin' =>
|
|
|
340 |
'minify.html.inline.css' => false,
|
341 |
'minify.html.inline.js' => false,
|
342 |
'minify.html.strip.crlf' => false,
|
343 |
'minify.css.enable' => true,
|
|
|
344 |
'minify.css.strip.comments' => false,
|
345 |
'minify.css.strip.crlf' => false,
|
346 |
'minify.css.groups' => array(),
|
@@ -357,17 +360,19 @@ class W3_Config
|
|
357 |
'cdn.debug' => false,
|
358 |
'cdn.engine' => 'ftp',
|
359 |
'cdn.includes.enable' => true,
|
360 |
-
'cdn.includes.files' => '
|
361 |
'cdn.theme.enable' => true,
|
362 |
'cdn.theme.files' => '*.css;*.js;*.gif;*.png;*.jpg;*.ico',
|
363 |
'cdn.minify.enable' => true,
|
364 |
'cdn.custom.enable' => true,
|
365 |
'cdn.custom.files' => array(
|
366 |
-
'favicon.ico'
|
|
|
367 |
),
|
368 |
'cdn.import.external' => false,
|
369 |
'cdn.import.files' => '*.jpg;*.png;*.gif;*.avi;*.wmv;*.mpg;*.wav;*.mp3;*.txt;*.rtf;*.doc;*.xls;*.rar;*.zip;*.tar;*.gz;*.exe',
|
370 |
-
'cdn.limit
|
|
|
371 |
'cdn.mirror.domain' => '',
|
372 |
'cdn.ftp.host' => '',
|
373 |
'cdn.ftp.user' => '',
|
@@ -392,11 +397,12 @@ class W3_Config
|
|
392 |
'common.support' => '',
|
393 |
'common.install' => 0,
|
394 |
'common.tweeted' => 0,
|
395 |
-
|
|
|
|
|
396 |
|
397 |
'notes.defaults' => true,
|
398 |
'notes.wp_content_perms' => true,
|
399 |
-
'notes.cdn_first_time' => true,
|
400 |
'notes.php_is_old' => true,
|
401 |
'notes.theme_changed' => false,
|
402 |
'notes.wp_upgraded' => false,
|
@@ -457,8 +463,12 @@ class W3_Config
|
|
457 |
case 'pgcache.engine':
|
458 |
case 'dbcache.engine':
|
459 |
case 'minify.engine':
|
460 |
-
|
461 |
-
|
|
|
|
|
|
|
|
|
462 |
}
|
463 |
break;
|
464 |
|
@@ -466,7 +476,8 @@ class W3_Config
|
|
466 |
* Disable compression if compression functions don't exist
|
467 |
*/
|
468 |
case 'pgcache.compression':
|
469 |
-
|
|
|
470 |
return '';
|
471 |
}
|
472 |
break;
|
@@ -484,7 +495,7 @@ class W3_Config
|
|
484 |
* Don't support additional headers in some cases
|
485 |
*/
|
486 |
case 'pgcache.cache.headers':
|
487 |
-
if (!
|
488 |
return array();
|
489 |
}
|
490 |
break;
|
@@ -493,17 +504,7 @@ class W3_Config
|
|
493 |
* Disabled minify when PHP5 is not installed
|
494 |
*/
|
495 |
case 'minify.enabled':
|
496 |
-
if (!
|
497 |
-
return false;
|
498 |
-
}
|
499 |
-
break;
|
500 |
-
|
501 |
-
/**
|
502 |
-
* Disable minify compressions if zlib is not installed
|
503 |
-
*/
|
504 |
-
case 'minify.compress':
|
505 |
-
case 'minify.compress.ie6':
|
506 |
-
if (! function_exists('gzencode')) {
|
507 |
return false;
|
508 |
}
|
509 |
break;
|
@@ -512,7 +513,7 @@ class W3_Config
|
|
512 |
* Disable CDN minify when PHP5 is not installed or minify is disabled
|
513 |
*/
|
514 |
case 'cdn.minify.enable':
|
515 |
-
if (!
|
516 |
return false;
|
517 |
}
|
518 |
break;
|
@@ -521,7 +522,7 @@ class W3_Config
|
|
521 |
* Check CDN engines
|
522 |
*/
|
523 |
case 'cdn.engine':
|
524 |
-
if (($value == 's3' || $value == 'cf') && (!
|
525 |
return 'mirror';
|
526 |
}
|
527 |
break;
|
@@ -617,7 +618,7 @@ class W3_Config
|
|
617 |
if (file_exists($file) && is_readable($file)) {
|
618 |
$config = @include $file;
|
619 |
|
620 |
-
if (!
|
621 |
return false;
|
622 |
}
|
623 |
|
@@ -643,7 +644,7 @@ class W3_Config
|
|
643 |
foreach ($this->_keys as $key => $type) {
|
644 |
$request_key = str_replace('.', '_', $key);
|
645 |
|
646 |
-
if (!
|
647 |
continue;
|
648 |
}
|
649 |
|
@@ -713,7 +714,9 @@ class W3_Config
|
|
713 |
{
|
714 |
@fputs($fp, str_repeat("\t", $this->_tabs));
|
715 |
|
716 |
-
if (
|
|
|
|
|
717 |
@fputs($fp, sprintf("'%s' => ", addslashes($key)));
|
718 |
}
|
719 |
|
@@ -721,11 +724,11 @@ class W3_Config
|
|
721 |
case 'object':
|
722 |
case 'array':
|
723 |
@fputs($fp, "array(\r\n");
|
724 |
-
|
725 |
foreach ((array) $value as $k => $v) {
|
726 |
$this->_write($fp, $k, $v);
|
727 |
}
|
728 |
-
|
729 |
@fputs($fp, sprintf("%s),\r\n", str_repeat("\t", $this->_tabs)));
|
730 |
return;
|
731 |
|
@@ -764,6 +767,14 @@ class W3_Config
|
|
764 |
return $this->read(W3TC_CONFIG_PATH);
|
765 |
}
|
766 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
767 |
/**
|
768 |
* Loads config dfefaults
|
769 |
*/
|
@@ -794,7 +805,7 @@ class W3_Config
|
|
794 |
{
|
795 |
static $instances = array();
|
796 |
|
797 |
-
if (!
|
798 |
$class = __CLASS__;
|
799 |
$instances[0] = & new $class($check_config);
|
800 |
}
|
31 |
'dbcache.debug' => 'boolean',
|
32 |
'dbcache.engine' => 'string',
|
33 |
'dbcache.file.gc' => 'integer',
|
|
|
34 |
'dbcache.memcached.servers' => 'array',
|
35 |
+
'dbcache.memcached.persistant' => 'boolean',
|
36 |
'dbcache.reject.logged' => 'boolean',
|
37 |
'dbcache.reject.uri' => 'array',
|
38 |
'dbcache.reject.cookie' => 'array',
|
43 |
'pgcache.debug' => 'boolean',
|
44 |
'pgcache.engine' => 'string',
|
45 |
'pgcache.file.gc' => 'integer',
|
|
|
46 |
'pgcache.memcached.servers' => 'array',
|
47 |
+
'pgcache.memcached.persistant' => 'boolean',
|
48 |
'pgcache.lifetime' => 'integer',
|
49 |
'pgcache.compression' => 'string',
|
50 |
'pgcache.cache.query' => 'boolean',
|
66 |
'minify.engine' => 'string',
|
67 |
'minify.file.locking' => 'boolean',
|
68 |
'minify.file.gc' => 'integer',
|
|
|
69 |
'minify.memcached.servers' => 'array',
|
70 |
+
'minify.memcached.persistant' => 'boolean',
|
71 |
'minify.rewrite' => 'boolean',
|
72 |
'minify.fixtime' => 'integer',
|
73 |
+
'minify.compression' => 'string',
|
|
|
74 |
'minify.options' => 'array',
|
75 |
'minify.symlinks' => 'array',
|
76 |
'minify.maxage' => 'integer',
|
78 |
'minify.upload' => 'boolean',
|
79 |
'minify.html.enable' => 'boolean',
|
80 |
'minify.html.reject.admin' => 'boolean',
|
81 |
+
'minify.html.reject.feed' => 'boolean',
|
82 |
'minify.html.inline.css' => 'boolean',
|
83 |
'minify.html.inline.js' => 'boolean',
|
84 |
'minify.html.strip.crlf' => 'boolean',
|
85 |
'minify.css.enable' => 'boolean',
|
86 |
+
'minify.css.combine' => 'boolean',
|
87 |
'minify.css.strip.comments' => 'boolean',
|
88 |
'minify.css.strip.crlf' => 'boolean',
|
89 |
'minify.css.groups' => 'array',
|
108 |
'cdn.custom.files' => 'array',
|
109 |
'cdn.import.external' => 'boolean',
|
110 |
'cdn.import.files' => 'string',
|
111 |
+
'cdn.queue.limit' => 'integer',
|
112 |
+
'cdn.force.rewrite' => 'boolean',
|
113 |
'cdn.mirror.domain' => 'string',
|
114 |
'cdn.ftp.host' => 'string',
|
115 |
'cdn.ftp.user' => 'string',
|
132 |
'common.support' => 'string',
|
133 |
'common.install' => 'integer',
|
134 |
'common.tweeted' => 'integer',
|
135 |
+
|
136 |
+
'widget.latest.enabled' => 'boolean',
|
137 |
+
'widget.latest.items' => 'integer',
|
138 |
|
139 |
'notes.defaults' => 'boolean',
|
140 |
'notes.wp_content_perms' => 'boolean',
|
|
|
141 |
'notes.php_is_old' => 'boolean',
|
142 |
'notes.theme_changed' => 'boolean',
|
143 |
'notes.wp_upgraded' => 'boolean',
|
155 |
);
|
156 |
|
157 |
var $_defaults = array(
|
158 |
+
'dbcache.enabled' => false,
|
159 |
'dbcache.debug' => false,
|
160 |
'dbcache.engine' => 'file',
|
161 |
'dbcache.file.gc' => 3600,
|
|
|
162 |
'dbcache.memcached.servers' => array(
|
163 |
+
'127.0.0.1:11211'
|
164 |
),
|
165 |
+
'dbcache.memcached.persistant' => true,
|
166 |
'dbcache.reject.logged' => true,
|
167 |
'dbcache.reject.uri' => array(),
|
168 |
'dbcache.reject.cookie' => array(),
|
173 |
|
174 |
'pgcache.enabled' => true,
|
175 |
'pgcache.debug' => false,
|
176 |
+
'pgcache.engine' => 'file_pgcache',
|
177 |
'pgcache.file.gc' => 3600,
|
|
|
178 |
'pgcache.memcached.servers' => array(
|
179 |
+
'127.0.0.1:11211'
|
180 |
),
|
181 |
+
'pgcache.memcached.persistant' => true,
|
182 |
'pgcache.lifetime' => 3600,
|
183 |
'pgcache.compression' => 'gzip',
|
184 |
'pgcache.cache.query' => true,
|
276 |
'SEC',
|
277 |
'SGH',
|
278 |
'SHARP-TQ-GX10',
|
|
|
279 |
'SPH',
|
280 |
'Sagem',
|
281 |
'Samsung',
|
318 |
'minify.engine' => 'file',
|
319 |
'minify.file.locking' => true,
|
320 |
'minify.file.gc' => 86400,
|
|
|
321 |
'minify.memcached.servers' => array(
|
322 |
+
'127.0.0.1:11211'
|
323 |
),
|
324 |
+
'minify.memcached.persistant' => true,
|
325 |
'minify.rewrite' => true,
|
326 |
'minify.fixtime' => 0,
|
327 |
+
'minify.compression' => 'gzip',
|
|
|
328 |
'minify.options' => array(
|
329 |
'bubbleCssImports' => false,
|
330 |
'minApp' => array(
|
336 |
'minify.maxage' => 86400,
|
337 |
'minify.lifetime' => 86400,
|
338 |
'minify.upload' => true,
|
339 |
+
'minify.html.enable' => false,
|
340 |
+
'minify.html.reject.admin' => false,
|
341 |
+
'minify.html.reject.feed' => false,
|
342 |
'minify.html.inline.css' => false,
|
343 |
'minify.html.inline.js' => false,
|
344 |
'minify.html.strip.crlf' => false,
|
345 |
'minify.css.enable' => true,
|
346 |
+
'minify.css.combine' => false,
|
347 |
'minify.css.strip.comments' => false,
|
348 |
'minify.css.strip.crlf' => false,
|
349 |
'minify.css.groups' => array(),
|
360 |
'cdn.debug' => false,
|
361 |
'cdn.engine' => 'ftp',
|
362 |
'cdn.includes.enable' => true,
|
363 |
+
'cdn.includes.files' => '*.css;*.js;*.gif;*.png;*.jpg',
|
364 |
'cdn.theme.enable' => true,
|
365 |
'cdn.theme.files' => '*.css;*.js;*.gif;*.png;*.jpg;*.ico',
|
366 |
'cdn.minify.enable' => true,
|
367 |
'cdn.custom.enable' => true,
|
368 |
'cdn.custom.files' => array(
|
369 |
+
'favicon.ico',
|
370 |
+
'wp-content/gallery/*'
|
371 |
),
|
372 |
'cdn.import.external' => false,
|
373 |
'cdn.import.files' => '*.jpg;*.png;*.gif;*.avi;*.wmv;*.mpg;*.wav;*.mp3;*.txt;*.rtf;*.doc;*.xls;*.rar;*.zip;*.tar;*.gz;*.exe',
|
374 |
+
'cdn.queue.limit' => 25,
|
375 |
+
'cdn.force.rewrite' => false,
|
376 |
'cdn.mirror.domain' => '',
|
377 |
'cdn.ftp.host' => '',
|
378 |
'cdn.ftp.user' => '',
|
397 |
'common.support' => '',
|
398 |
'common.install' => 0,
|
399 |
'common.tweeted' => 0,
|
400 |
+
|
401 |
+
'widget.latest.enabled' => true,
|
402 |
+
'widget.latest.items' => 3,
|
403 |
|
404 |
'notes.defaults' => true,
|
405 |
'notes.wp_content_perms' => true,
|
|
|
406 |
'notes.php_is_old' => true,
|
407 |
'notes.theme_changed' => false,
|
408 |
'notes.wp_upgraded' => false,
|
463 |
case 'pgcache.engine':
|
464 |
case 'dbcache.engine':
|
465 |
case 'minify.engine':
|
466 |
+
switch (true) {
|
467 |
+
case ($value == 'apc' && !function_exists('apc_store')):
|
468 |
+
case ($value == 'eaccelerator' && !function_exists('eaccelerator_put')):
|
469 |
+
case ($value == 'xcache' && !function_exists('xcache_set')):
|
470 |
+
case ($value == 'memcached' && !class_exists('Memcache')):
|
471 |
+
return 'file';
|
472 |
}
|
473 |
break;
|
474 |
|
476 |
* Disable compression if compression functions don't exist
|
477 |
*/
|
478 |
case 'pgcache.compression':
|
479 |
+
case 'minify.compression':
|
480 |
+
if ((stristr($value, 'gzip') && !function_exists('gzencode')) || (stristr($value, 'deflate') && !function_exists('gzdeflate'))) {
|
481 |
return '';
|
482 |
}
|
483 |
break;
|
495 |
* Don't support additional headers in some cases
|
496 |
*/
|
497 |
case 'pgcache.cache.headers':
|
498 |
+
if (!W3TC_PHP5 || ($this->get_boolean('pgcache.enabled') && $this->get_string('pgcache.engine') == 'file_pgcache')) {
|
499 |
return array();
|
500 |
}
|
501 |
break;
|
504 |
* Disabled minify when PHP5 is not installed
|
505 |
*/
|
506 |
case 'minify.enabled':
|
507 |
+
if (!W3TC_PHP5) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
return false;
|
509 |
}
|
510 |
break;
|
513 |
* Disable CDN minify when PHP5 is not installed or minify is disabled
|
514 |
*/
|
515 |
case 'cdn.minify.enable':
|
516 |
+
if (!W3TC_PHP5 || !$this->get_boolean('minify.enabled')) {
|
517 |
return false;
|
518 |
}
|
519 |
break;
|
522 |
* Check CDN engines
|
523 |
*/
|
524 |
case 'cdn.engine':
|
525 |
+
if (($value == 's3' || $value == 'cf') && (!W3TC_PHP5 || !function_exists('curl_init'))) {
|
526 |
return 'mirror';
|
527 |
}
|
528 |
break;
|
618 |
if (file_exists($file) && is_readable($file)) {
|
619 |
$config = @include $file;
|
620 |
|
621 |
+
if (!is_array($config)) {
|
622 |
return false;
|
623 |
}
|
624 |
|
644 |
foreach ($this->_keys as $key => $type) {
|
645 |
$request_key = str_replace('.', '_', $key);
|
646 |
|
647 |
+
if (!isset($request[$request_key])) {
|
648 |
continue;
|
649 |
}
|
650 |
|
714 |
{
|
715 |
@fputs($fp, str_repeat("\t", $this->_tabs));
|
716 |
|
717 |
+
if (is_numeric($key)) {
|
718 |
+
@fputs($fp, sprintf("%d => ", $key));
|
719 |
+
} else {
|
720 |
@fputs($fp, sprintf("'%s' => ", addslashes($key)));
|
721 |
}
|
722 |
|
724 |
case 'object':
|
725 |
case 'array':
|
726 |
@fputs($fp, "array(\r\n");
|
727 |
+
++$this->_tabs;
|
728 |
foreach ((array) $value as $k => $v) {
|
729 |
$this->_write($fp, $k, $v);
|
730 |
}
|
731 |
+
--$this->_tabs;
|
732 |
@fputs($fp, sprintf("%s),\r\n", str_repeat("\t", $this->_tabs)));
|
733 |
return;
|
734 |
|
767 |
return $this->read(W3TC_CONFIG_PATH);
|
768 |
}
|
769 |
|
770 |
+
/**
|
771 |
+
* Loads master config (for WPMU)
|
772 |
+
*/
|
773 |
+
function load_master()
|
774 |
+
{
|
775 |
+
return $this->read(W3TC_CONFIG_MASTER_PATH);
|
776 |
+
}
|
777 |
+
|
778 |
/**
|
779 |
* Loads config dfefaults
|
780 |
*/
|
805 |
{
|
806 |
static $instances = array();
|
807 |
|
808 |
+
if (!isset($instances[0])) {
|
809 |
$class = __CLASS__;
|
810 |
$instances[0] = & new $class($check_config);
|
811 |
}
|
lib/W3/Db.php
CHANGED
@@ -107,11 +107,11 @@ class W3_Db extends wpdb
|
|
107 |
*/
|
108 |
function query($query)
|
109 |
{
|
110 |
-
if (
|
111 |
return false;
|
112 |
}
|
113 |
|
114 |
-
|
115 |
|
116 |
// Filter the query, if filters are available
|
117 |
// NOTE: Some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
|
@@ -148,7 +148,7 @@ class W3_Db extends wpdb
|
|
148 |
* Check if query was cached
|
149 |
*/
|
150 |
if (is_array($data)) {
|
151 |
-
|
152 |
$cached = true;
|
153 |
|
154 |
/**
|
@@ -160,8 +160,8 @@ class W3_Db extends wpdb
|
|
160 |
$this->col_info = $data['col_info'];
|
161 |
$this->num_rows = $data['num_rows'];
|
162 |
} else {
|
163 |
-
|
164 |
-
|
165 |
|
166 |
// Perform the query via std mysql_query function..
|
167 |
$this->timer_start();
|
@@ -255,7 +255,7 @@ class W3_Db extends wpdb
|
|
255 |
/**
|
256 |
* Skip if disabled
|
257 |
*/
|
258 |
-
if (
|
259 |
$cache_reject_reason = 'database caching is disabled';
|
260 |
return false;
|
261 |
}
|
@@ -303,7 +303,7 @@ class W3_Db extends wpdb
|
|
303 |
/**
|
304 |
* Skip if SQL is rejected
|
305 |
*/
|
306 |
-
if (
|
307 |
$cache_reject_reason = 'query is rejected';
|
308 |
return false;
|
309 |
}
|
@@ -311,7 +311,7 @@ class W3_Db extends wpdb
|
|
311 |
/**
|
312 |
* Skip if request URI is rejected
|
313 |
*/
|
314 |
-
if (
|
315 |
$cache_reject_reason = 'request URI is rejected';
|
316 |
return false;
|
317 |
}
|
@@ -319,7 +319,7 @@ class W3_Db extends wpdb
|
|
319 |
/**
|
320 |
* Skip if cookie is rejected
|
321 |
*/
|
322 |
-
if (
|
323 |
$cache_reject_reason = 'cookie is rejected';
|
324 |
return false;
|
325 |
}
|
@@ -327,7 +327,7 @@ class W3_Db extends wpdb
|
|
327 |
/**
|
328 |
* Skip if user is logged in
|
329 |
*/
|
330 |
-
if ($this->_config->get_boolean('dbcache.reject.logged') &&
|
331 |
$cache_reject_reason = 'user is logged in';
|
332 |
return false;
|
333 |
}
|
@@ -356,7 +356,7 @@ class W3_Db extends wpdb
|
|
356 |
{
|
357 |
static $instances = array();
|
358 |
|
359 |
-
if (!
|
360 |
$class = __CLASS__;
|
361 |
$instances[0] = & new $class(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
362 |
}
|
@@ -388,15 +388,14 @@ class W3_Db extends wpdb
|
|
388 |
{
|
389 |
static $cache = array();
|
390 |
|
391 |
-
if (!
|
392 |
$engine = $this->_config->get_string('dbcache.engine');
|
393 |
|
394 |
switch ($engine) {
|
395 |
case 'memcached':
|
396 |
$engineConfig = array(
|
397 |
-
'engine' => $this->_config->get_string('dbcache.memcached.engine'),
|
398 |
'servers' => $this->_config->get_array('dbcache.memcached.servers'),
|
399 |
-
'persistant' =>
|
400 |
);
|
401 |
break;
|
402 |
|
@@ -426,17 +425,18 @@ class W3_Db extends wpdb
|
|
426 |
function _check_sql($sql)
|
427 |
{
|
428 |
$auto_reject_strings = array(
|
429 |
-
'^\s*insert',
|
430 |
-
'^\s*delete',
|
431 |
-
'^\s*update',
|
432 |
-
'^\s*replace',
|
433 |
-
'^\s*create',
|
434 |
-
'^\s*alter',
|
435 |
-
'^\s*show',
|
436 |
-
'^\s*set',
|
437 |
-
'
|
438 |
-
'
|
439 |
-
'
|
|
|
440 |
);
|
441 |
|
442 |
if (preg_match('@' . implode('|', $auto_reject_strings) . '@is', $sql)) {
|
@@ -540,13 +540,13 @@ class W3_Db extends wpdb
|
|
540 |
*/
|
541 |
function _get_cache_key($sql)
|
542 |
{
|
543 |
-
$
|
544 |
|
545 |
-
if (
|
546 |
-
$
|
547 |
}
|
548 |
|
549 |
-
return sprintf('w3tc_%s_sql_%s', md5($
|
550 |
}
|
551 |
|
552 |
/**
|
107 |
*/
|
108 |
function query($query)
|
109 |
{
|
110 |
+
if (!$this->ready) {
|
111 |
return false;
|
112 |
}
|
113 |
|
114 |
+
++$this->query_total;
|
115 |
|
116 |
// Filter the query, if filters are available
|
117 |
// NOTE: Some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
|
148 |
* Check if query was cached
|
149 |
*/
|
150 |
if (is_array($data)) {
|
151 |
+
++$this->query_hits;
|
152 |
$cached = true;
|
153 |
|
154 |
/**
|
160 |
$this->col_info = $data['col_info'];
|
161 |
$this->num_rows = $data['num_rows'];
|
162 |
} else {
|
163 |
+
++$this->num_queries;
|
164 |
+
++$this->query_misses;
|
165 |
|
166 |
// Perform the query via std mysql_query function..
|
167 |
$this->timer_start();
|
255 |
/**
|
256 |
* Skip if disabled
|
257 |
*/
|
258 |
+
if (!$this->_config->get_boolean('dbcache.enabled')) {
|
259 |
$cache_reject_reason = 'database caching is disabled';
|
260 |
return false;
|
261 |
}
|
303 |
/**
|
304 |
* Skip if SQL is rejected
|
305 |
*/
|
306 |
+
if (!$this->_check_sql($sql)) {
|
307 |
$cache_reject_reason = 'query is rejected';
|
308 |
return false;
|
309 |
}
|
311 |
/**
|
312 |
* Skip if request URI is rejected
|
313 |
*/
|
314 |
+
if (!$this->_check_request_uri()) {
|
315 |
$cache_reject_reason = 'request URI is rejected';
|
316 |
return false;
|
317 |
}
|
319 |
/**
|
320 |
* Skip if cookie is rejected
|
321 |
*/
|
322 |
+
if (!$this->_check_cookies()) {
|
323 |
$cache_reject_reason = 'cookie is rejected';
|
324 |
return false;
|
325 |
}
|
327 |
/**
|
328 |
* Skip if user is logged in
|
329 |
*/
|
330 |
+
if ($this->_config->get_boolean('dbcache.reject.logged') && !$this->_check_logged_in()) {
|
331 |
$cache_reject_reason = 'user is logged in';
|
332 |
return false;
|
333 |
}
|
356 |
{
|
357 |
static $instances = array();
|
358 |
|
359 |
+
if (!isset($instances[0])) {
|
360 |
$class = __CLASS__;
|
361 |
$instances[0] = & new $class(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
362 |
}
|
388 |
{
|
389 |
static $cache = array();
|
390 |
|
391 |
+
if (!isset($cache[0])) {
|
392 |
$engine = $this->_config->get_string('dbcache.engine');
|
393 |
|
394 |
switch ($engine) {
|
395 |
case 'memcached':
|
396 |
$engineConfig = array(
|
|
|
397 |
'servers' => $this->_config->get_array('dbcache.memcached.servers'),
|
398 |
+
'persistant' => $this->_config->get_boolean('dbcache.memcached.persistant')
|
399 |
);
|
400 |
break;
|
401 |
|
425 |
function _check_sql($sql)
|
426 |
{
|
427 |
$auto_reject_strings = array(
|
428 |
+
'^\s*insert\b',
|
429 |
+
'^\s*delete\b',
|
430 |
+
'^\s*update\b',
|
431 |
+
'^\s*replace\b',
|
432 |
+
'^\s*create\b',
|
433 |
+
'^\s*alter\b',
|
434 |
+
'^\s*show\b',
|
435 |
+
'^\s*set\b',
|
436 |
+
'\bsql_calc_found_rows\b',
|
437 |
+
'\bfound_rows\(\)',
|
438 |
+
'\bautoload\s+=\s+\'yes\'',
|
439 |
+
'\bw3tc_request_data\b'
|
440 |
);
|
441 |
|
442 |
if (preg_match('@' . implode('|', $auto_reject_strings) . '@is', $sql)) {
|
540 |
*/
|
541 |
function _get_cache_key($sql)
|
542 |
{
|
543 |
+
$blogname = w3_get_blogname();
|
544 |
|
545 |
+
if ($blogname == '') {
|
546 |
+
$blogname = $_SERVER['HTTP_HOST'];
|
547 |
}
|
548 |
|
549 |
+
return sprintf('w3tc_%s_sql_%s', md5($blogname), md5($sql));
|
550 |
}
|
551 |
|
552 |
/**
|
lib/W3/Minify.php
CHANGED
@@ -50,18 +50,14 @@ class W3_Minify
|
|
50 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify.php';
|
51 |
require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
|
52 |
|
53 |
-
HTTP_Encoder::$encodeToIe6 =
|
54 |
|
55 |
Minify::$uploaderHoursBehind = $this->_config->get_integer('minify.fixtime');
|
56 |
Minify::setCache($this->_get_cache());
|
57 |
|
58 |
$serve_options = $this->_config->get_array('minify.options');
|
59 |
$serve_options['maxAge'] = $this->_config->get_integer('minify.maxage');
|
60 |
-
$serve_options['encodeOutput'] = $this->_config->
|
61 |
-
$serve_options['postprocessor'] = array(
|
62 |
-
&$this,
|
63 |
-
'postprocessor'
|
64 |
-
);
|
65 |
|
66 |
if (stripos(PHP_OS, 'win') === 0) {
|
67 |
Minify::setDocRoot();
|
@@ -86,17 +82,32 @@ class W3_Minify
|
|
86 |
if (isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
|
87 |
$serve_options['minApp']['groups'] = $this->get_groups($_GET['gg'], $_GET['t']);
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
'include
|
94 |
-
'include-
|
95 |
-
|
96 |
-
$
|
97 |
-
$
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
/**
|
@@ -169,12 +180,12 @@ class W3_Minify
|
|
169 |
|
170 |
$cache = & $this->_get_cache();
|
171 |
|
172 |
-
if (is_a($cache, '
|
173 |
return $this->_memcached->flush();
|
174 |
} elseif (is_a($cache, 'Minify_Cache_APC') && function_exists('apc_clear_cache')) {
|
175 |
return apc_clear_cache('user');
|
176 |
} elseif (is_a($cache, 'Minify_Cache_File')) {
|
177 |
-
if (!
|
178 |
$this->log(sprintf('Cache directory %s does not exists', W3TC_CACHE_FILE_MINIFY_DIR));
|
179 |
}
|
180 |
|
@@ -196,7 +207,7 @@ class W3_Minify
|
|
196 |
{
|
197 |
static $instances = array();
|
198 |
|
199 |
-
if (!
|
200 |
$class = __CLASS__;
|
201 |
$instances[0] = & new $class();
|
202 |
}
|
@@ -224,14 +235,7 @@ class W3_Minify
|
|
224 |
{
|
225 |
$data = sprintf("[%s] [%s] %s\n", date('r'), $_SERVER['REQUEST_URI'], $object);
|
226 |
|
227 |
-
|
228 |
-
if ($fp) {
|
229 |
-
@fputs($fp, $data);
|
230 |
-
@fclose($fp);
|
231 |
-
return true;
|
232 |
-
}
|
233 |
-
|
234 |
-
return false;
|
235 |
}
|
236 |
|
237 |
/**
|
@@ -267,18 +271,20 @@ class W3_Minify
|
|
267 |
$locations = array_merge_recursive($locations, (array) $groups[$group]);
|
268 |
}
|
269 |
|
|
|
|
|
270 |
foreach ($locations as $location => $config) {
|
271 |
-
if (!
|
272 |
foreach ((array) $config['files'] as $file) {
|
|
|
|
|
273 |
if (w3_is_url($file)) {
|
274 |
-
|
|
|
|
|
275 |
$result[$location][$file] = $precached_file;
|
276 |
}
|
277 |
} else {
|
278 |
-
if (w3_get_blog_id()) {
|
279 |
-
// for WPMU we have to remove blog path
|
280 |
-
$file = str_replace(w3_get_site_path(), '', $file);
|
281 |
-
}
|
282 |
$result[$location][$file] = '//' . $file;
|
283 |
}
|
284 |
}
|
@@ -301,20 +307,13 @@ class W3_Minify
|
|
301 |
$file_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_FILE_MINIFY_DIR, md5($url), $type);
|
302 |
$file_exists = file_exists($file_path);
|
303 |
|
304 |
-
if (file_exists
|
305 |
return $this->_get_minify_source($file_path, $url);
|
306 |
}
|
307 |
|
308 |
if (is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
|
309 |
-
if (($
|
310 |
-
|
311 |
-
@fputs($fp, $file_data);
|
312 |
-
@fclose($fp);
|
313 |
-
|
314 |
-
return $this->_get_minify_source($file_path, $url);
|
315 |
-
} else {
|
316 |
-
$this->log(sprintf('Unable to open file %s for writing', $file_path));
|
317 |
-
}
|
318 |
} else {
|
319 |
$this->log(sprintf('Unable to download URL: %s', $url));
|
320 |
}
|
@@ -325,6 +324,20 @@ class W3_Minify
|
|
325 |
return ($file_exists ? $this->_get_minify_source($file_path, $url) : false);
|
326 |
}
|
327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
/**
|
329 |
* Returns minify source
|
330 |
* @param $file_path
|
@@ -352,14 +365,14 @@ class W3_Minify
|
|
352 |
{
|
353 |
static $cache = array();
|
354 |
|
355 |
-
if (!
|
356 |
switch ($this->_config->get_string('minify.engine')) {
|
357 |
case 'memcached':
|
358 |
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
|
359 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Memcache.php';
|
360 |
-
$this->_memcached = & W3_Cache_Memcached
|
361 |
'servers' => $this->_config->get_array('minify.memcached.servers'),
|
362 |
-
'persistant' =>
|
363 |
));
|
364 |
$cache[0] = & new Minify_Cache_Memcache($this->_memcached);
|
365 |
break;
|
@@ -369,9 +382,20 @@ class W3_Minify
|
|
369 |
$cache[0] = & new Minify_Cache_APC();
|
370 |
break;
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
default:
|
373 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php';
|
374 |
-
if (!
|
375 |
$this->log(sprintf('Cache directory %s does not exist', W3TC_CACHE_FILE_MINIFY_DIR));
|
376 |
}
|
377 |
$cache[0] = & new Minify_Cache_File(W3TC_CACHE_FILE_MINIFY_DIR, $this->_config->get_boolean('minify.file.locking'));
|
50 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify.php';
|
51 |
require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
|
52 |
|
53 |
+
HTTP_Encoder::$encodeToIe6 = true;
|
54 |
|
55 |
Minify::$uploaderHoursBehind = $this->_config->get_integer('minify.fixtime');
|
56 |
Minify::setCache($this->_get_cache());
|
57 |
|
58 |
$serve_options = $this->_config->get_array('minify.options');
|
59 |
$serve_options['maxAge'] = $this->_config->get_integer('minify.maxage');
|
60 |
+
$serve_options['encodeOutput'] = $this->_config->get_string('minify.compression');
|
|
|
|
|
|
|
|
|
61 |
|
62 |
if (stripos(PHP_OS, 'win') === 0) {
|
63 |
Minify::setDocRoot();
|
82 |
if (isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
|
83 |
$serve_options['minApp']['groups'] = $this->get_groups($_GET['gg'], $_GET['t']);
|
84 |
|
85 |
+
/**
|
86 |
+
* Handle combine option
|
87 |
+
*/
|
88 |
+
switch (true) {
|
89 |
+
case ($_GET['t'] == 'js' && $_GET['g'] == 'include') && $this->_config->get_boolean('minify.js.combine.header'):
|
90 |
+
case ($_GET['t'] == 'js' && $_GET['g'] == 'include-nb') && $this->_config->get_boolean('minify.js.combine.header'):
|
91 |
+
case ($_GET['t'] == 'js' && $_GET['g'] == 'include-footer') && $this->_config->get_boolean('minify.js.combine.footer'):
|
92 |
+
case ($_GET['t'] == 'js' && $_GET['g'] == 'include-footer-nb') && $this->_config->get_boolean('minify.js.combine.footer'):
|
93 |
+
$serve_options['minifiers']['application/x-javascript'] = array(
|
94 |
+
$this,
|
95 |
+
'minify_stub'
|
96 |
+
);
|
97 |
+
break;
|
98 |
+
|
99 |
+
case ($_GET['t'] == 'css' && $_GET['g'] == 'include') && $this->_config->get_boolean('minify.css.combine'):
|
100 |
+
$serve_options['minifiers']['text/css'] = array(
|
101 |
+
$this,
|
102 |
+
'minify_stub'
|
103 |
+
);
|
104 |
+
break;
|
105 |
+
|
106 |
+
default:
|
107 |
+
$serve_options['postprocessor'] = array(
|
108 |
+
&$this,
|
109 |
+
'postprocessor'
|
110 |
+
);
|
111 |
}
|
112 |
|
113 |
/**
|
180 |
|
181 |
$cache = & $this->_get_cache();
|
182 |
|
183 |
+
if (is_a($cache, 'W3_Cache_Memcached') && class_exists('Memcache')) {
|
184 |
return $this->_memcached->flush();
|
185 |
} elseif (is_a($cache, 'Minify_Cache_APC') && function_exists('apc_clear_cache')) {
|
186 |
return apc_clear_cache('user');
|
187 |
} elseif (is_a($cache, 'Minify_Cache_File')) {
|
188 |
+
if (!is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
|
189 |
$this->log(sprintf('Cache directory %s does not exists', W3TC_CACHE_FILE_MINIFY_DIR));
|
190 |
}
|
191 |
|
207 |
{
|
208 |
static $instances = array();
|
209 |
|
210 |
+
if (!isset($instances[0])) {
|
211 |
$class = __CLASS__;
|
212 |
$instances[0] = & new $class();
|
213 |
}
|
235 |
{
|
236 |
$data = sprintf("[%s] [%s] %s\n", date('r'), $_SERVER['REQUEST_URI'], $object);
|
237 |
|
238 |
+
return @file_put_contents(W3TC_MINIFY_LOG_FILE, $data, FILE_APPEND);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
|
241 |
/**
|
271 |
$locations = array_merge_recursive($locations, (array) $groups[$group]);
|
272 |
}
|
273 |
|
274 |
+
$site_url = w3_get_site_url();
|
275 |
+
|
276 |
foreach ($locations as $location => $config) {
|
277 |
+
if (!empty($config['files'])) {
|
278 |
foreach ((array) $config['files'] as $file) {
|
279 |
+
$file = $this->_normalize_file($file);
|
280 |
+
|
281 |
if (w3_is_url($file)) {
|
282 |
+
$precached_file = $this->_precache_file($file, $type);
|
283 |
+
|
284 |
+
if ($precached_file) {
|
285 |
$result[$location][$file] = $precached_file;
|
286 |
}
|
287 |
} else {
|
|
|
|
|
|
|
|
|
288 |
$result[$location][$file] = '//' . $file;
|
289 |
}
|
290 |
}
|
307 |
$file_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_FILE_MINIFY_DIR, md5($url), $type);
|
308 |
$file_exists = file_exists($file_path);
|
309 |
|
310 |
+
if ($file_exists && @filemtime($file_path) >= (time() - $lifetime)) {
|
311 |
return $this->_get_minify_source($file_path, $url);
|
312 |
}
|
313 |
|
314 |
if (is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
|
315 |
+
if (w3_download($url, $file_path) !== false) {
|
316 |
+
return $this->_get_minify_source($file_path, $url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
} else {
|
318 |
$this->log(sprintf('Unable to download URL: %s', $url));
|
319 |
}
|
324 |
return ($file_exists ? $this->_get_minify_source($file_path, $url) : false);
|
325 |
}
|
326 |
|
327 |
+
/**
|
328 |
+
* Normalizes URL
|
329 |
+
* @param string $url
|
330 |
+
* @return string
|
331 |
+
*/
|
332 |
+
function _normalize_file($url)
|
333 |
+
{
|
334 |
+
$url = preg_replace('~\?ver=[0-9\.]+$~', '', $url);
|
335 |
+
$url = w3_normalize_file($url);
|
336 |
+
$url = w3_translate_file($url);
|
337 |
+
|
338 |
+
return $url;
|
339 |
+
}
|
340 |
+
|
341 |
/**
|
342 |
* Returns minify source
|
343 |
* @param $file_path
|
365 |
{
|
366 |
static $cache = array();
|
367 |
|
368 |
+
if (!isset($cache[0])) {
|
369 |
switch ($this->_config->get_string('minify.engine')) {
|
370 |
case 'memcached':
|
371 |
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
|
372 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Memcache.php';
|
373 |
+
$this->_memcached = & new W3_Cache_Memcached(array(
|
374 |
'servers' => $this->_config->get_array('minify.memcached.servers'),
|
375 |
+
'persistant' => $this->_config->get_boolean('minify.memcached.persistant')
|
376 |
));
|
377 |
$cache[0] = & new Minify_Cache_Memcache($this->_memcached);
|
378 |
break;
|
382 |
$cache[0] = & new Minify_Cache_APC();
|
383 |
break;
|
384 |
|
385 |
+
case 'eaccelerator':
|
386 |
+
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Eaccelerator.php';
|
387 |
+
$cache[0] = & new Minify_Cache_Eaccelerator();
|
388 |
+
break;
|
389 |
+
|
390 |
+
case 'xcache':
|
391 |
+
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/XCache.php';
|
392 |
+
$cache[0] = & new Minify_Cache_XCache();
|
393 |
+
break;
|
394 |
+
|
395 |
+
case 'file':
|
396 |
default:
|
397 |
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php';
|
398 |
+
if (!is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
|
399 |
$this->log(sprintf('Cache directory %s does not exist', W3TC_CACHE_FILE_MINIFY_DIR));
|
400 |
}
|
401 |
$cache[0] = & new Minify_Cache_File(W3TC_CACHE_FILE_MINIFY_DIR, $this->_config->get_boolean('minify.file.locking'));
|
lib/W3/PgCache.php
CHANGED
@@ -124,7 +124,12 @@ class W3_PgCache
|
|
124 |
$cache = & $this->_get_cache();
|
125 |
$data = $cache->get($page_key);
|
126 |
|
127 |
-
if ($data
|
|
|
|
|
|
|
|
|
|
|
128 |
if ($this->_enhanced_mode) {
|
129 |
$is_404 = false;
|
130 |
$headers = array();
|
@@ -142,22 +147,10 @@ class W3_PgCache
|
|
142 |
*/
|
143 |
$etag = md5($content);
|
144 |
|
145 |
-
if ($is_404) {
|
146 |
-
/**
|
147 |
-
* Send 404 header
|
148 |
-
*/
|
149 |
-
$this->_send_headers_404();
|
150 |
-
} else {
|
151 |
-
/**
|
152 |
-
* Send 304 header if content is not modified
|
153 |
-
*/
|
154 |
-
$this->_send_headers_304($time, $etag);
|
155 |
-
}
|
156 |
-
|
157 |
/**
|
158 |
* Send headers
|
159 |
*/
|
160 |
-
$this->_send_headers($time, $etag, $compression, $headers);
|
161 |
|
162 |
/**
|
163 |
* Append debug info
|
@@ -191,7 +184,7 @@ class W3_PgCache
|
|
191 |
function ob_callback($buffer)
|
192 |
{
|
193 |
if ($buffer != '') {
|
194 |
-
if ($
|
195 |
$compression = $this->_get_compression();
|
196 |
$compressions = $this->_get_compressions();
|
197 |
|
@@ -253,17 +246,10 @@ class W3_PgCache
|
|
253 |
*/
|
254 |
$etag = md5($buffer);
|
255 |
|
256 |
-
if (! $is_404) {
|
257 |
-
/**
|
258 |
-
* Send 304 header if content is not modified
|
259 |
-
*/
|
260 |
-
$this->_send_headers_304($time, $etag);
|
261 |
-
}
|
262 |
-
|
263 |
/**
|
264 |
* Send headers
|
265 |
*/
|
266 |
-
$this->_send_headers($time, $etag, $compression);
|
267 |
|
268 |
/**
|
269 |
* Append debug info
|
@@ -307,7 +293,7 @@ class W3_PgCache
|
|
307 |
*/
|
308 |
function flush_post($post_id)
|
309 |
{
|
310 |
-
if (
|
311 |
$post_id = $this->_detect_post_id();
|
312 |
}
|
313 |
|
@@ -342,7 +328,7 @@ class W3_PgCache
|
|
342 |
{
|
343 |
static $instances = array();
|
344 |
|
345 |
-
if (!
|
346 |
$class = __CLASS__;
|
347 |
$instances[0] = & new $class();
|
348 |
}
|
@@ -360,7 +346,7 @@ class W3_PgCache
|
|
360 |
/**
|
361 |
* Skip if disabled
|
362 |
*/
|
363 |
-
if (
|
364 |
$this->cache_reject_reason = 'page caching is disabled';
|
365 |
return false;
|
366 |
}
|
@@ -384,7 +370,7 @@ class W3_PgCache
|
|
384 |
/**
|
385 |
* Skip if there is query in the request uri
|
386 |
*/
|
387 |
-
if (
|
388 |
$this->cache_reject_reason = 'request URI contains query';
|
389 |
return false;
|
390 |
}
|
@@ -392,7 +378,7 @@ class W3_PgCache
|
|
392 |
/**
|
393 |
* Check request URI
|
394 |
*/
|
395 |
-
if (!
|
396 |
$this->cache_reject_reason = 'request URI is rejected';
|
397 |
return false;
|
398 |
}
|
@@ -400,7 +386,7 @@ class W3_PgCache
|
|
400 |
/**
|
401 |
* Check User Agent
|
402 |
*/
|
403 |
-
if (
|
404 |
$this->cache_reject_reason = 'user agent is rejected';
|
405 |
return false;
|
406 |
}
|
@@ -408,7 +394,7 @@ class W3_PgCache
|
|
408 |
/**
|
409 |
* Check WordPress cookies
|
410 |
*/
|
411 |
-
if (
|
412 |
$this->cache_reject_reason = 'cookie is rejected';
|
413 |
return false;
|
414 |
}
|
@@ -416,7 +402,7 @@ class W3_PgCache
|
|
416 |
/**
|
417 |
* Skip if user is logged in
|
418 |
*/
|
419 |
-
if ($this->_config->get_boolean('pgcache.reject.logged') &&
|
420 |
$this->cache_reject_reason = 'user is logged in';
|
421 |
|
422 |
return false;
|
@@ -436,14 +422,14 @@ class W3_PgCache
|
|
436 |
/**
|
437 |
* Skip if caching is disabled
|
438 |
*/
|
439 |
-
if (
|
440 |
return false;
|
441 |
}
|
442 |
|
443 |
/**
|
444 |
* Don't cache 404 pages
|
445 |
*/
|
446 |
-
if (
|
447 |
$this->cache_reject_reason = 'page is 404';
|
448 |
|
449 |
return false;
|
@@ -452,7 +438,7 @@ class W3_PgCache
|
|
452 |
/**
|
453 |
* Don't cache homepage
|
454 |
*/
|
455 |
-
if (
|
456 |
$this->cache_reject_reason = 'page is home';
|
457 |
|
458 |
return false;
|
@@ -461,7 +447,7 @@ class W3_PgCache
|
|
461 |
/**
|
462 |
* Don't cache feed
|
463 |
*/
|
464 |
-
if (
|
465 |
$this->cache_reject_reason = 'page is feed';
|
466 |
|
467 |
return false;
|
@@ -479,15 +465,14 @@ class W3_PgCache
|
|
479 |
{
|
480 |
static $cache = array();
|
481 |
|
482 |
-
if (!
|
483 |
$engine = $this->_config->get_string('pgcache.engine');
|
484 |
|
485 |
switch ($engine) {
|
486 |
case 'memcached':
|
487 |
$engineConfig = array(
|
488 |
-
'engine' => $this->_config->get_string('pgcache.memcached.engine'),
|
489 |
'servers' => $this->_config->get_array('pgcache.memcached.servers'),
|
490 |
-
'persistant' =>
|
491 |
);
|
492 |
break;
|
493 |
|
@@ -612,7 +597,7 @@ class W3_PgCache
|
|
612 |
*/
|
613 |
function _get_compression()
|
614 |
{
|
615 |
-
if (!
|
616 |
$compressions = $this->_get_compressions();
|
617 |
|
618 |
foreach ($compressions as $compression) {
|
@@ -663,7 +648,7 @@ class W3_PgCache
|
|
663 |
$headers_list = headers_list();
|
664 |
if ($headers_list) {
|
665 |
foreach ($headers_list as $header) {
|
666 |
-
list
|
667 |
$headers[$header_name] = $header_value;
|
668 |
}
|
669 |
}
|
@@ -672,6 +657,24 @@ class W3_PgCache
|
|
672 |
return $headers;
|
673 |
}
|
674 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
675 |
/**
|
676 |
* Returns array of data headers
|
677 |
*
|
@@ -704,36 +707,34 @@ class W3_PgCache
|
|
704 |
function _get_page_key($request_uri, $compression)
|
705 |
{
|
706 |
if ($this->_config->get_string('pgcache.engine') == 'file_pgcache') {
|
707 |
-
$
|
708 |
-
$
|
709 |
-
$
|
710 |
-
$
|
711 |
|
712 |
-
if (
|
713 |
-
$
|
714 |
}
|
715 |
|
716 |
-
if (substr($
|
717 |
-
$
|
718 |
}
|
719 |
|
720 |
-
$
|
721 |
|
722 |
-
|
723 |
-
|
724 |
-
if (! empty($compression)) {
|
725 |
$key .= '.' . $compression;
|
726 |
}
|
727 |
} else {
|
728 |
-
$
|
729 |
|
730 |
-
if (
|
731 |
-
$
|
732 |
}
|
733 |
|
734 |
-
$key = sprintf('w3tc_%s_page_%s', md5($
|
735 |
|
736 |
-
if (!
|
737 |
$key .= '_' . $compression;
|
738 |
}
|
739 |
}
|
@@ -779,7 +780,7 @@ class W3_PgCache
|
|
779 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), w3_get_engine_name($this->_config->get_string('pgcache.engine')));
|
780 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Key: ', 20), $page_key);
|
781 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Caching: ', 20), ($cache ? 'enabled' : 'disabled'));
|
782 |
-
if (
|
783 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Reject reason: ', 20), $reason);
|
784 |
}
|
785 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Status: ', 20), ($status ? 'cached' : 'not cached'));
|
@@ -837,7 +838,7 @@ class W3_PgCache
|
|
837 |
*/
|
838 |
function _headers($headers)
|
839 |
{
|
840 |
-
if (!
|
841 |
foreach ($headers as $name => $value) {
|
842 |
$header = ($name == 'Status' ? $value : $name . ': ' . $value);
|
843 |
@header($header);
|
@@ -851,76 +852,79 @@ class W3_PgCache
|
|
851 |
|
852 |
/**
|
853 |
* Sends headers
|
|
|
854 |
* @param string $etag
|
855 |
* @param integer $time
|
856 |
* @param string $compression
|
857 |
* @param array $custom_headers
|
858 |
* @return boolean
|
859 |
*/
|
860 |
-
function _send_headers($time, $etag, $compression, $custom_headers = array())
|
861 |
{
|
|
|
|
|
862 |
$curr_time = time();
|
863 |
$expires = $time + $this->_lifetime;
|
864 |
$max_age = ($expires > $curr_time ? $expires - $curr_time : 0);
|
865 |
|
866 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
867 |
'Pragma' => 'public',
|
868 |
'Expires' => $this->_gmdate($expires),
|
869 |
'Last-Modified' => $this->_gmdate($time),
|
870 |
-
'Cache-Control' => 'max-age
|
871 |
-
);
|
872 |
-
|
873 |
-
$headers = array_merge($headers, $custom_headers);
|
874 |
-
|
875 |
-
$headers = array_merge($headers, array(
|
876 |
'Vary' => 'Cookie',
|
877 |
'Etag' => $etag
|
878 |
));
|
879 |
|
880 |
if ($compression) {
|
|
|
|
|
|
|
881 |
$headers = array_merge($headers, array(
|
882 |
'Vary' => 'Accept-Encoding, Cookie',
|
883 |
'Content-Encoding' => $compression
|
884 |
));
|
885 |
}
|
886 |
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
if ($this->_check_modified_since($time) || $this->_check_match($etag)) {
|
900 |
-
$headers = array(
|
901 |
-
'Status' => 'HTTP/1.1 304 Not Modified',
|
902 |
-
'Etag' => $etag,
|
903 |
-
'Last-Modified' => $this->_gmdate($time)
|
904 |
-
);
|
905 |
-
|
906 |
-
if ($this->_headers($headers)) {
|
907 |
-
exit();
|
908 |
-
}
|
909 |
}
|
910 |
-
}
|
911 |
-
|
912 |
-
/**
|
913 |
-
* Sends 404 header
|
914 |
-
*
|
915 |
-
* @return boolean
|
916 |
-
*/
|
917 |
-
function _send_headers_404()
|
918 |
-
{
|
919 |
-
$headers = array(
|
920 |
-
'Status' => 'HTTP/1.1 404 Not Found'
|
921 |
-
);
|
922 |
|
923 |
-
return $
|
924 |
}
|
925 |
|
926 |
/**
|
@@ -948,7 +952,7 @@ class W3_PgCache
|
|
948 |
*/
|
949 |
function _check_modified_since($time)
|
950 |
{
|
951 |
-
if (!
|
952 |
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
953 |
|
954 |
// IE has tacked on extra data to this header, strip it
|
@@ -969,7 +973,7 @@ class W3_PgCache
|
|
969 |
*/
|
970 |
function _check_match($etag)
|
971 |
{
|
972 |
-
if (!
|
973 |
$if_none_match = (get_magic_quotes_gpc() ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : $_SERVER['HTTP_IF_NONE_MATCH']);
|
974 |
$client_etags = explode(',', $if_none_match);
|
975 |
|
@@ -994,4 +998,23 @@ class W3_PgCache
|
|
994 |
{
|
995 |
return gmdate('D, d M Y H:i:s \G\M\T', $time);
|
996 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
997 |
}
|
124 |
$cache = & $this->_get_cache();
|
125 |
$data = $cache->get($page_key);
|
126 |
|
127 |
+
if ($data) {
|
128 |
+
/**
|
129 |
+
* Do Bad Behavior check
|
130 |
+
*/
|
131 |
+
$this->_bad_behavior();
|
132 |
+
|
133 |
if ($this->_enhanced_mode) {
|
134 |
$is_404 = false;
|
135 |
$headers = array();
|
147 |
*/
|
148 |
$etag = md5($content);
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
/**
|
151 |
* Send headers
|
152 |
*/
|
153 |
+
$this->_send_headers($is_404, $time, $etag, $compression, $headers);
|
154 |
|
155 |
/**
|
156 |
* Append debug info
|
184 |
function ob_callback($buffer)
|
185 |
{
|
186 |
if ($buffer != '') {
|
187 |
+
if (w3_is_xml($buffer) && $this->_can_cache2()) {
|
188 |
$compression = $this->_get_compression();
|
189 |
$compressions = $this->_get_compressions();
|
190 |
|
246 |
*/
|
247 |
$etag = md5($buffer);
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
/**
|
250 |
* Send headers
|
251 |
*/
|
252 |
+
$this->_send_headers($is_404, $time, $etag, $compression, $headers);
|
253 |
|
254 |
/**
|
255 |
* Append debug info
|
293 |
*/
|
294 |
function flush_post($post_id)
|
295 |
{
|
296 |
+
if (!$post_id) {
|
297 |
$post_id = $this->_detect_post_id();
|
298 |
}
|
299 |
|
328 |
{
|
329 |
static $instances = array();
|
330 |
|
331 |
+
if (!isset($instances[0])) {
|
332 |
$class = __CLASS__;
|
333 |
$instances[0] = & new $class();
|
334 |
}
|
346 |
/**
|
347 |
* Skip if disabled
|
348 |
*/
|
349 |
+
if (!$this->_config->get_boolean('pgcache.enabled')) {
|
350 |
$this->cache_reject_reason = 'page caching is disabled';
|
351 |
return false;
|
352 |
}
|
370 |
/**
|
371 |
* Skip if there is query in the request uri
|
372 |
*/
|
373 |
+
if (!$this->_config->get_boolean('pgcache.cache.query') && strstr($_SERVER['REQUEST_URI'], '?') !== false) {
|
374 |
$this->cache_reject_reason = 'request URI contains query';
|
375 |
return false;
|
376 |
}
|
378 |
/**
|
379 |
* Check request URI
|
380 |
*/
|
381 |
+
if (!in_array($_SERVER['PHP_SELF'], $this->_config->get_array('pgcache.accept.files')) && !$this->_check_request_uri()) {
|
382 |
$this->cache_reject_reason = 'request URI is rejected';
|
383 |
return false;
|
384 |
}
|
386 |
/**
|
387 |
* Check User Agent
|
388 |
*/
|
389 |
+
if (!$this->_check_ua()) {
|
390 |
$this->cache_reject_reason = 'user agent is rejected';
|
391 |
return false;
|
392 |
}
|
394 |
/**
|
395 |
* Check WordPress cookies
|
396 |
*/
|
397 |
+
if (!$this->_check_cookies()) {
|
398 |
$this->cache_reject_reason = 'cookie is rejected';
|
399 |
return false;
|
400 |
}
|
402 |
/**
|
403 |
* Skip if user is logged in
|
404 |
*/
|
405 |
+
if ($this->_config->get_boolean('pgcache.reject.logged') && !$this->_check_logged_in()) {
|
406 |
$this->cache_reject_reason = 'user is logged in';
|
407 |
|
408 |
return false;
|
422 |
/**
|
423 |
* Skip if caching is disabled
|
424 |
*/
|
425 |
+
if (!$this->_caching) {
|
426 |
return false;
|
427 |
}
|
428 |
|
429 |
/**
|
430 |
* Don't cache 404 pages
|
431 |
*/
|
432 |
+
if (!$this->_config->get_boolean('pgcache.cache.404') && function_exists('is_404') && is_404()) {
|
433 |
$this->cache_reject_reason = 'page is 404';
|
434 |
|
435 |
return false;
|
438 |
/**
|
439 |
* Don't cache homepage
|
440 |
*/
|
441 |
+
if (!$this->_config->get_boolean('pgcache.cache.home') && function_exists('is_home') && is_home()) {
|
442 |
$this->cache_reject_reason = 'page is home';
|
443 |
|
444 |
return false;
|
447 |
/**
|
448 |
* Don't cache feed
|
449 |
*/
|
450 |
+
if (!$this->_config->get_boolean('pgcache.cache.feed') && function_exists('is_feed') && is_feed()) {
|
451 |
$this->cache_reject_reason = 'page is feed';
|
452 |
|
453 |
return false;
|
465 |
{
|
466 |
static $cache = array();
|
467 |
|
468 |
+
if (!isset($cache[0])) {
|
469 |
$engine = $this->_config->get_string('pgcache.engine');
|
470 |
|
471 |
switch ($engine) {
|
472 |
case 'memcached':
|
473 |
$engineConfig = array(
|
|
|
474 |
'servers' => $this->_config->get_array('pgcache.memcached.servers'),
|
475 |
+
'persistant' => $this->_config->get_boolean('pgcache.memcached.persistant')
|
476 |
);
|
477 |
break;
|
478 |
|
597 |
*/
|
598 |
function _get_compression()
|
599 |
{
|
600 |
+
if (!w3_zlib_output_compression() && !headers_sent() && !$this->_is_buggy_ie()) {
|
601 |
$compressions = $this->_get_compressions();
|
602 |
|
603 |
foreach ($compressions as $compression) {
|
648 |
$headers_list = headers_list();
|
649 |
if ($headers_list) {
|
650 |
foreach ($headers_list as $header) {
|
651 |
+
list($header_name, $header_value) = explode(': ', $header, 2);
|
652 |
$headers[$header_name] = $header_value;
|
653 |
}
|
654 |
}
|
657 |
return $headers;
|
658 |
}
|
659 |
|
660 |
+
/**
|
661 |
+
* Checks for buggy IE6 that doesn't support compression
|
662 |
+
*
|
663 |
+
* @return boolean
|
664 |
+
*/
|
665 |
+
function _is_buggy_ie()
|
666 |
+
{
|
667 |
+
$ua = $_SERVER['HTTP_USER_AGENT'];
|
668 |
+
|
669 |
+
if (strpos($ua, 'Mozilla/4.0 (compatible; MSIE ') === 0 && strpos($ua, 'Opera') === false) {
|
670 |
+
$version = (float) substr($ua, 30);
|
671 |
+
|
672 |
+
return ($version < 6 || ($version == 6 && strpos($ua, 'SV1') === false));
|
673 |
+
}
|
674 |
+
|
675 |
+
return false;
|
676 |
+
}
|
677 |
+
|
678 |
/**
|
679 |
* Returns array of data headers
|
680 |
*
|
707 |
function _get_page_key($request_uri, $compression)
|
708 |
{
|
709 |
if ($this->_config->get_string('pgcache.engine') == 'file_pgcache') {
|
710 |
+
$key = preg_replace('~[/\\\]+~', '/', $key);
|
711 |
+
$key = preg_replace('~\?.*$~', '', $request_uri);
|
712 |
+
$key = str_replace(w3_get_site_path(), '/', $key);
|
713 |
+
$key = str_replace('/index.php', '/', $key);
|
714 |
|
715 |
+
if ($key == '') {
|
716 |
+
$key = '/';
|
717 |
}
|
718 |
|
719 |
+
if (substr($key, -1) == '/') {
|
720 |
+
$key .= '_default_.html';
|
721 |
}
|
722 |
|
723 |
+
$key = ltrim($key, '/');
|
724 |
|
725 |
+
if (!empty($compression)) {
|
|
|
|
|
726 |
$key .= '.' . $compression;
|
727 |
}
|
728 |
} else {
|
729 |
+
$blogname = w3_get_blogname();
|
730 |
|
731 |
+
if ($blogname == '') {
|
732 |
+
$blogname = $_SERVER['HTTP_HOST'];
|
733 |
}
|
734 |
|
735 |
+
$key = sprintf('w3tc_%s_page_%s', md5($blogname), md5($request_uri));
|
736 |
|
737 |
+
if (!empty($compression)) {
|
738 |
$key .= '_' . $compression;
|
739 |
}
|
740 |
}
|
780 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), w3_get_engine_name($this->_config->get_string('pgcache.engine')));
|
781 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Key: ', 20), $page_key);
|
782 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Caching: ', 20), ($cache ? 'enabled' : 'disabled'));
|
783 |
+
if (!$cache) {
|
784 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Reject reason: ', 20), $reason);
|
785 |
}
|
786 |
$debug_info .= sprintf("%s%s\r\n", str_pad('Status: ', 20), ($status ? 'cached' : 'not cached'));
|
838 |
*/
|
839 |
function _headers($headers)
|
840 |
{
|
841 |
+
if (!headers_sent()) {
|
842 |
foreach ($headers as $name => $value) {
|
843 |
$header = ($name == 'Status' ? $value : $name . ': ' . $value);
|
844 |
@header($header);
|
852 |
|
853 |
/**
|
854 |
* Sends headers
|
855 |
+
* @param boolean $is_404
|
856 |
* @param string $etag
|
857 |
* @param integer $time
|
858 |
* @param string $compression
|
859 |
* @param array $custom_headers
|
860 |
* @return boolean
|
861 |
*/
|
862 |
+
function _send_headers($is_404, $time, $etag, $compression, $custom_headers = array())
|
863 |
{
|
864 |
+
$exit = false;
|
865 |
+
$headers = array();
|
866 |
$curr_time = time();
|
867 |
$expires = $time + $this->_lifetime;
|
868 |
$max_age = ($expires > $curr_time ? $expires - $curr_time : 0);
|
869 |
|
870 |
+
if ($is_404) {
|
871 |
+
/**
|
872 |
+
* Add 404 header
|
873 |
+
*/
|
874 |
+
$headers = array_merge($headers, array(
|
875 |
+
'Status' => 'HTTP/1.1 404 Not Found'
|
876 |
+
));
|
877 |
+
} elseif ($this->_check_modified_since($time) || $this->_check_match($etag)) {
|
878 |
+
/**
|
879 |
+
* Add 304 header
|
880 |
+
*/
|
881 |
+
$headers = array_merge($headers, array(
|
882 |
+
'Status' => 'HTTP/1.1 304 Not Modified'
|
883 |
+
));
|
884 |
+
|
885 |
+
/**
|
886 |
+
* Don't send content if it isn't modified
|
887 |
+
*/
|
888 |
+
$exit = true;
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Add default headers
|
893 |
+
*/
|
894 |
+
$headers = array_merge($headers, array(
|
895 |
'Pragma' => 'public',
|
896 |
'Expires' => $this->_gmdate($expires),
|
897 |
'Last-Modified' => $this->_gmdate($time),
|
898 |
+
'Cache-Control' => sprintf('max-age=%d, public, must-revalidate, proxy-revalidate', $max_age),
|
|
|
|
|
|
|
|
|
|
|
899 |
'Vary' => 'Cookie',
|
900 |
'Etag' => $etag
|
901 |
));
|
902 |
|
903 |
if ($compression) {
|
904 |
+
/**
|
905 |
+
* Add Content-Encoding header
|
906 |
+
*/
|
907 |
$headers = array_merge($headers, array(
|
908 |
'Vary' => 'Accept-Encoding, Cookie',
|
909 |
'Content-Encoding' => $compression
|
910 |
));
|
911 |
}
|
912 |
|
913 |
+
/**
|
914 |
+
* Add custom headers
|
915 |
+
*/
|
916 |
+
$headers = array_merge($headers, $custom_headers);
|
917 |
+
|
918 |
+
/**
|
919 |
+
* Send headers to client
|
920 |
+
*/
|
921 |
+
$result = $this->_headers($headers);
|
922 |
+
|
923 |
+
if ($exit) {
|
924 |
+
exit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
925 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
926 |
|
927 |
+
return $result;
|
928 |
}
|
929 |
|
930 |
/**
|
952 |
*/
|
953 |
function _check_modified_since($time)
|
954 |
{
|
955 |
+
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
956 |
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
957 |
|
958 |
// IE has tacked on extra data to this header, strip it
|
973 |
*/
|
974 |
function _check_match($etag)
|
975 |
{
|
976 |
+
if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
977 |
$if_none_match = (get_magic_quotes_gpc() ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : $_SERVER['HTTP_IF_NONE_MATCH']);
|
978 |
$client_etags = explode(',', $if_none_match);
|
979 |
|
998 |
{
|
999 |
return gmdate('D, d M Y H:i:s \G\M\T', $time);
|
1000 |
}
|
1001 |
+
|
1002 |
+
/**
|
1003 |
+
* Bad Behavior support
|
1004 |
+
* @return void
|
1005 |
+
*/
|
1006 |
+
function _bad_behavior()
|
1007 |
+
{
|
1008 |
+
if (file_exists(WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php')) {
|
1009 |
+
$bb_file = WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php';
|
1010 |
+
} elseif (file_exists(WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php')) {
|
1011 |
+
$bb_file = WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php';
|
1012 |
+
} else {
|
1013 |
+
$bb_file = false;
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
if ($bb_file) {
|
1017 |
+
require_once $bb_file;
|
1018 |
+
}
|
1019 |
+
}
|
1020 |
}
|
lib/W3/Plugin.php
CHANGED
@@ -67,26 +67,30 @@ class W3_Plugin
|
|
67 |
*/
|
68 |
function locked()
|
69 |
{
|
70 |
-
global $blog_id;
|
71 |
static $locked = null;
|
72 |
|
73 |
if ($locked === null) {
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
87 |
}
|
88 |
}
|
89 |
}
|
|
|
|
|
90 |
}
|
91 |
}
|
92 |
|
67 |
*/
|
68 |
function locked()
|
69 |
{
|
|
|
70 |
static $locked = null;
|
71 |
|
72 |
if ($locked === null) {
|
73 |
+
if (w3_is_wpmu()) {
|
74 |
+
if (isset($_GET['sitewide'])) {
|
75 |
+
$locked = false;
|
76 |
+
} else {
|
77 |
+
global $blog_id;
|
78 |
+
|
79 |
+
$blogs = get_blog_list();
|
80 |
+
|
81 |
+
foreach ($blogs as $blog) {
|
82 |
+
if ($blog['blog_id'] != $blog_id) {
|
83 |
+
$active_plugins = get_blog_option($blog['blog_id'], 'active_plugins');
|
84 |
+
|
85 |
+
if (in_array(W3TC_FILE, $active_plugins)) {
|
86 |
+
$locked = true;
|
87 |
+
break;
|
88 |
+
}
|
89 |
}
|
90 |
}
|
91 |
}
|
92 |
+
} else {
|
93 |
+
$locked = false;
|
94 |
}
|
95 |
}
|
96 |
|
lib/W3/Plugin/Cdn.php
CHANGED
@@ -46,6 +46,11 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
46 |
|
47 |
if ($this->_config->get_boolean('cdn.enabled')) {
|
48 |
if ($this->_config->get_string('cdn.engine') != 'mirror') {
|
|
|
|
|
|
|
|
|
|
|
49 |
add_action('delete_attachment', array(
|
50 |
&$this,
|
51 |
'delete_attachment'
|
@@ -80,7 +85,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
80 |
{
|
81 |
static $instances = array();
|
82 |
|
83 |
-
if (!
|
84 |
$class = __CLASS__;
|
85 |
$instances[0] = & new $class();
|
86 |
}
|
@@ -97,7 +102,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
97 |
|
98 |
$upload_info = w3_upload_info();
|
99 |
|
100 |
-
if (
|
101 |
$upload_path = get_option('upload_path');
|
102 |
$upload_path = trim($upload_path);
|
103 |
|
@@ -127,7 +132,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
127 |
|
128 |
$wpdb->query($sql);
|
129 |
|
130 |
-
if (
|
131 |
$error = sprintf('Unable to create table <strong>%s%s</strong>: %s', $wpdb->prefix, W3TC_CDN_TABLE_QUEUE, $wpdb->last_error);
|
132 |
|
133 |
w3_activate_error($error);
|
@@ -155,7 +160,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
155 |
function schedule()
|
156 |
{
|
157 |
if ($this->_config->get_boolean('cdn.enabled') && $this->_config->get_string('cdn.engine') != 'mirror') {
|
158 |
-
if (!
|
159 |
wp_schedule_event(time(), 'every_15_min', 'w3_cdn_cron_queue_process');
|
160 |
}
|
161 |
} else {
|
@@ -178,23 +183,23 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
178 |
*/
|
179 |
function cron_queue_process()
|
180 |
{
|
181 |
-
$
|
182 |
-
$this->queue_process($
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
-
* On attachment
|
187 |
*
|
188 |
* @param integer $attachment_id
|
189 |
*/
|
190 |
-
function
|
191 |
{
|
192 |
$files = $this->get_attachment_files($attachment_id);
|
193 |
-
$files = apply_filters('
|
194 |
|
195 |
$results = array();
|
196 |
|
197 |
-
$this->
|
198 |
}
|
199 |
|
200 |
/**
|
@@ -206,7 +211,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
206 |
function generate_attachment_metadata($metadata)
|
207 |
{
|
208 |
$files = $this->get_metadata_files($metadata);
|
209 |
-
$files = apply_filters('
|
210 |
|
211 |
$results = array();
|
212 |
|
@@ -215,6 +220,21 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
215 |
return $metadata;
|
216 |
}
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
/**
|
219 |
* Cron schedules filter
|
220 |
*
|
@@ -239,17 +259,26 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
239 |
*/
|
240 |
function get_attachment_files($attachment_id)
|
241 |
{
|
242 |
-
$
|
|
|
243 |
|
244 |
-
if (
|
245 |
-
$
|
246 |
-
|
247 |
-
|
248 |
-
$
|
249 |
-
$this->normalize_attachment_file($
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
-
|
253 |
return $files;
|
254 |
}
|
255 |
|
@@ -336,15 +365,15 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
336 |
if ($upload_info) {
|
337 |
if (isset($metadata['file'])) {
|
338 |
$file = $this->normalize_attachment_file($metadata['file']);
|
339 |
-
|
340 |
-
$remote_file = $upload_info['upload_url'] . '/' . $file;
|
341 |
-
$files[$local_file] = $remote_file;
|
342 |
if (isset($metadata['sizes'])) {
|
343 |
$file_dir = dirname($file);
|
|
|
344 |
foreach ((array) $metadata['sizes'] as $size) {
|
345 |
if (isset($size['file'])) {
|
346 |
$local_file = $upload_info['upload_dir'] . '/' . $file_dir . '/' . $size['file'];
|
347 |
$remote_file = $upload_info['upload_url'] . '/' . $file_dir . '/' . $size['file'];
|
|
|
348 |
$files[$local_file] = $remote_file;
|
349 |
}
|
350 |
}
|
@@ -462,9 +491,11 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
462 |
function queue_process($limit)
|
463 |
{
|
464 |
$commands = $this->queue_get($limit);
|
|
|
465 |
|
466 |
if (count($commands)) {
|
467 |
$cdn = & $this->get_cdn();
|
|
|
468 |
foreach ($commands as $command => $queue) {
|
469 |
$files = array();
|
470 |
$results = array();
|
@@ -477,7 +508,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
477 |
|
478 |
switch ($command) {
|
479 |
case W3TC_CDN_COMMAND_UPLOAD:
|
480 |
-
$cdn->upload($files, $results);
|
481 |
break;
|
482 |
|
483 |
case W3TC_CDN_COMMAND_DELETE:
|
@@ -507,6 +538,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
507 |
function upload($files, $queue_failed, &$results)
|
508 |
{
|
509 |
$upload = array();
|
|
|
510 |
|
511 |
foreach ($files as $local_file => $remote_file) {
|
512 |
$local_path = $this->format_local_path($local_file);
|
@@ -515,7 +547,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
515 |
}
|
516 |
|
517 |
$cdn = & $this->get_cdn();
|
518 |
-
|
|
|
519 |
if ($queue_failed) {
|
520 |
foreach ($results as $result) {
|
521 |
if ($result['result'] != W3_CDN_RESULT_OK) {
|
@@ -549,7 +582,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
549 |
}
|
550 |
|
551 |
$cdn = & $this->get_cdn();
|
552 |
-
if (
|
553 |
if ($queue_failed) {
|
554 |
foreach ($results as $result) {
|
555 |
if ($result['result'] != W3_CDN_RESULT_OK) {
|
@@ -614,14 +647,14 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
614 |
$files = array();
|
615 |
|
616 |
foreach ($posts as $post) {
|
617 |
-
if (!
|
618 |
$metadata = @unserialize($post->metadata);
|
619 |
} else {
|
620 |
$metadata = array();
|
621 |
}
|
622 |
if (isset($metadata['file'])) {
|
623 |
$files = array_merge($files, $this->get_metadata_files($metadata));
|
624 |
-
} elseif (!
|
625 |
$file = $this->normalize_attachment_file($post->file);
|
626 |
$local_file = $upload_info['upload_dir'] . '/' . $file;
|
627 |
$remote_file = $upload_info['upload_url'] . '/' . $file;
|
@@ -658,6 +691,9 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
658 |
$upload_info = w3_upload_info();
|
659 |
|
660 |
if ($upload_info) {
|
|
|
|
|
|
|
661 |
$sql = sprintf('SELECT
|
662 |
ID,
|
663 |
post_content,
|
@@ -684,56 +720,123 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
684 |
if ($posts) {
|
685 |
$count = count($posts);
|
686 |
$total = $this->get_import_posts_count();
|
687 |
-
$regexp = $this->get_regexp_by_mask($this->_config->get_string('cdn.import.files'));
|
688 |
$import_external = $this->_config->get_boolean('cdn.import.external');
|
689 |
|
690 |
foreach ($posts as $post) {
|
691 |
$matches = null;
|
|
|
|
|
692 |
$post_content = $post->post_content;
|
693 |
|
|
|
|
|
|
|
694 |
if (preg_match_all('~(href|src)=[\'"]?([^\'"<>\s]+)[\'"]?~', $post_content, $matches, PREG_SET_ORDER)) {
|
695 |
foreach ($matches as $match) {
|
696 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
697 |
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
717 |
} else {
|
718 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
719 |
}
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
// file is already in wp-content/uploads dir
|
725 |
-
} else {
|
726 |
-
$error = 'Source file already exists';
|
727 |
-
}
|
728 |
-
|
729 |
-
if ($download_result !== null) {
|
730 |
if ($download_result) {
|
731 |
-
$title = $
|
732 |
$guid = $upload_info['upload_url'] . '/' . $title;
|
733 |
-
$mime_type = w3_get_mime_type($
|
734 |
|
735 |
$GLOBALS['wp_rewrite'] = & new WP_Rewrite();
|
736 |
|
|
|
|
|
|
|
737 |
$id = wp_insert_attachment(array(
|
738 |
'post_mime_type' => $mime_type,
|
739 |
'guid' => $guid,
|
@@ -741,34 +844,59 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
741 |
'post_content' => ''
|
742 |
), $dst_path);
|
743 |
|
744 |
-
if (!
|
|
|
|
|
|
|
745 |
require_once ABSPATH . 'wp-admin/includes/image.php';
|
746 |
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $dst_path));
|
747 |
|
748 |
-
$
|
|
|
|
|
|
|
|
|
749 |
$result = true;
|
750 |
-
$error = 'OK';
|
751 |
} else {
|
752 |
$error = 'Unable to insert attachment';
|
753 |
}
|
754 |
-
} else {
|
755 |
-
$error = 'Unable to download file';
|
756 |
}
|
757 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
758 |
} else {
|
759 |
-
$error = '
|
760 |
}
|
761 |
-
|
762 |
-
$
|
763 |
-
'src' => $src,
|
764 |
-
'dst' => $dst,
|
765 |
-
'result' => $result,
|
766 |
-
'error' => $error
|
767 |
-
);
|
768 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
}
|
770 |
}
|
771 |
|
|
|
|
|
|
|
772 |
if ($post_content != $post->post_content) {
|
773 |
wp_update_post(array(
|
774 |
'ID' => $post->ID,
|
@@ -955,7 +1083,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
955 |
|
956 |
foreach ($urls as $url) {
|
957 |
$file = basename($url);
|
958 |
-
if (
|
959 |
$files[] = W3TC_CONTENT_MINIFY_DIR_NAME . '/' . $file;
|
960 |
}
|
961 |
}
|
@@ -989,25 +1117,6 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
989 |
return $files;
|
990 |
}
|
991 |
|
992 |
-
/**
|
993 |
-
* Downloads URL
|
994 |
-
*
|
995 |
-
* @param string $url
|
996 |
-
* @param string $file
|
997 |
-
* @return boolean
|
998 |
-
*/
|
999 |
-
function download($url, $file)
|
1000 |
-
{
|
1001 |
-
if (($data = w3_url_get($url)) && ($fp = @fopen($file, 'w'))) {
|
1002 |
-
@fputs($fp, $data);
|
1003 |
-
@fclose($fp);
|
1004 |
-
|
1005 |
-
return true;
|
1006 |
-
}
|
1007 |
-
|
1008 |
-
return false;
|
1009 |
-
}
|
1010 |
-
|
1011 |
/**
|
1012 |
* Formats local file path
|
1013 |
*
|
@@ -1027,7 +1136,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1027 |
*/
|
1028 |
function format_remote_path($file)
|
1029 |
{
|
1030 |
-
return
|
1031 |
}
|
1032 |
|
1033 |
/**
|
@@ -1041,57 +1150,64 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1041 |
global $wpdb;
|
1042 |
static $queue = null, $reject_files = null;
|
1043 |
|
1044 |
-
|
1045 |
-
return $matches[0];
|
1046 |
-
}
|
1047 |
|
1048 |
-
|
1049 |
-
$sql = sprintf('SELECT remote_path FROM %s', $wpdb->prefix . W3TC_CDN_TABLE_QUEUE);
|
1050 |
-
$queue = $wpdb->get_col($sql);
|
1051 |
-
}
|
1052 |
-
|
1053 |
-
if ($reject_files === null) {
|
1054 |
-
$reject_files = $this->_config->get_array('cdn.reject.files');
|
1055 |
-
}
|
1056 |
|
1057 |
/**
|
1058 |
-
*
|
1059 |
*/
|
1060 |
-
if (
|
1061 |
-
return $
|
1062 |
}
|
1063 |
|
1064 |
/**
|
1065 |
-
*
|
1066 |
*/
|
|
|
|
|
|
|
|
|
1067 |
foreach ($reject_files as $reject_file) {
|
1068 |
if ($reject_file != '') {
|
1069 |
$reject_file = w3_normalize_file($reject_file);
|
1070 |
$reject_file_regexp = '~^' . $this->get_regexp_by_mask($reject_file) . '$~i';
|
1071 |
|
1072 |
-
if (preg_match($reject_file_regexp, $
|
1073 |
-
return $
|
1074 |
}
|
1075 |
}
|
1076 |
}
|
1077 |
|
1078 |
/**
|
1079 |
-
*
|
1080 |
*/
|
1081 |
-
$
|
|
|
|
|
|
|
1082 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1083 |
$cdn = & $this->get_cdn();
|
1084 |
-
$url = $cdn->format_url($path);
|
1085 |
|
1086 |
-
|
1087 |
-
|
1088 |
-
}
|
1089 |
|
1090 |
-
$
|
1091 |
|
1092 |
-
|
|
|
|
|
|
|
|
|
1093 |
|
1094 |
-
return $
|
1095 |
}
|
1096 |
|
1097 |
/**
|
@@ -1139,19 +1255,26 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1139 |
*/
|
1140 |
function get_regexp_by_mask($mask)
|
1141 |
{
|
1142 |
-
$
|
|
|
|
|
|
|
1143 |
'\*',
|
1144 |
'\?',
|
1145 |
-
'\[',
|
1146 |
-
'\]',
|
1147 |
';'
|
1148 |
), array(
|
1149 |
-
'
|
1150 |
-
'
|
1151 |
-
'[',
|
1152 |
-
']',
|
1153 |
'|'
|
1154 |
-
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1155 |
|
1156 |
return $regexp;
|
1157 |
}
|
@@ -1186,7 +1309,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1186 |
{
|
1187 |
static $cdn = array();
|
1188 |
|
1189 |
-
if (!
|
1190 |
$engine = $this->_config->get_string('cdn.engine');
|
1191 |
$engine_config = array();
|
1192 |
|
@@ -1203,7 +1326,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1203 |
'user' => $this->_config->get_string('cdn.ftp.user'),
|
1204 |
'pass' => $this->_config->get_string('cdn.ftp.pass'),
|
1205 |
'path' => $this->_config->get_string('cdn.ftp.path'),
|
1206 |
-
'pasv' => $this->_config->get_boolean('
|
1207 |
'domain' => $this->_config->get_string('cdn.ftp.domain')
|
1208 |
);
|
1209 |
break;
|
@@ -1248,8 +1371,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1248 |
if (count($this->replaced_urls)) {
|
1249 |
$debug_info .= "Replaced URLs:\r\n";
|
1250 |
|
1251 |
-
foreach ($this->replaced_urls as $
|
1252 |
-
$debug_info .= sprintf("%s\r\n", $
|
1253 |
}
|
1254 |
}
|
1255 |
|
@@ -1267,7 +1390,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1267 |
/**
|
1268 |
* Skip if CDN is disabled
|
1269 |
*/
|
1270 |
-
if (
|
1271 |
$this->cdn_reject_reason = 'CDN is disabled';
|
1272 |
|
1273 |
return false;
|
@@ -1285,7 +1408,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1285 |
/**
|
1286 |
* Check User agent
|
1287 |
*/
|
1288 |
-
if (
|
1289 |
$this->cdn_reject_reason = 'user agent is rejected';
|
1290 |
|
1291 |
return false;
|
@@ -1294,7 +1417,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1294 |
/**
|
1295 |
* Check request URI
|
1296 |
*/
|
1297 |
-
if (
|
1298 |
$this->cdn_reject_reason = 'request URI is rejected';
|
1299 |
|
1300 |
return false;
|
46 |
|
47 |
if ($this->_config->get_boolean('cdn.enabled')) {
|
48 |
if ($this->_config->get_string('cdn.engine') != 'mirror') {
|
49 |
+
add_action('add_attachment', array(
|
50 |
+
&$this,
|
51 |
+
'add_attachment'
|
52 |
+
));
|
53 |
+
|
54 |
add_action('delete_attachment', array(
|
55 |
&$this,
|
56 |
'delete_attachment'
|
85 |
{
|
86 |
static $instances = array();
|
87 |
|
88 |
+
if (!isset($instances[0])) {
|
89 |
$class = __CLASS__;
|
90 |
$instances[0] = & new $class();
|
91 |
}
|
102 |
|
103 |
$upload_info = w3_upload_info();
|
104 |
|
105 |
+
if (!$upload_info) {
|
106 |
$upload_path = get_option('upload_path');
|
107 |
$upload_path = trim($upload_path);
|
108 |
|
132 |
|
133 |
$wpdb->query($sql);
|
134 |
|
135 |
+
if (!$wpdb->result) {
|
136 |
$error = sprintf('Unable to create table <strong>%s%s</strong>: %s', $wpdb->prefix, W3TC_CDN_TABLE_QUEUE, $wpdb->last_error);
|
137 |
|
138 |
w3_activate_error($error);
|
160 |
function schedule()
|
161 |
{
|
162 |
if ($this->_config->get_boolean('cdn.enabled') && $this->_config->get_string('cdn.engine') != 'mirror') {
|
163 |
+
if (!wp_next_scheduled('w3_cdn_cron_queue_process')) {
|
164 |
wp_schedule_event(time(), 'every_15_min', 'w3_cdn_cron_queue_process');
|
165 |
}
|
166 |
} else {
|
183 |
*/
|
184 |
function cron_queue_process()
|
185 |
{
|
186 |
+
$queue_limit = $this->_config->get_integer('cdn.queue.limit');
|
187 |
+
$this->queue_process($queue_limit);
|
188 |
}
|
189 |
|
190 |
/**
|
191 |
+
* On attachment add action
|
192 |
*
|
193 |
* @param integer $attachment_id
|
194 |
*/
|
195 |
+
function add_attachment($attachment_id)
|
196 |
{
|
197 |
$files = $this->get_attachment_files($attachment_id);
|
198 |
+
$files = apply_filters('w3tc_cdn_add_attachment', $files);
|
199 |
|
200 |
$results = array();
|
201 |
|
202 |
+
$this->upload($files, true, $results);
|
203 |
}
|
204 |
|
205 |
/**
|
211 |
function generate_attachment_metadata($metadata)
|
212 |
{
|
213 |
$files = $this->get_metadata_files($metadata);
|
214 |
+
$files = apply_filters('w3tc_cdn_generate_attachment_metadata', $files);
|
215 |
|
216 |
$results = array();
|
217 |
|
220 |
return $metadata;
|
221 |
}
|
222 |
|
223 |
+
/**
|
224 |
+
* On attachment delete action
|
225 |
+
*
|
226 |
+
* @param integer $attachment_id
|
227 |
+
*/
|
228 |
+
function delete_attachment($attachment_id)
|
229 |
+
{
|
230 |
+
$files = $this->get_attachment_files($attachment_id);
|
231 |
+
$files = apply_filters('w3tc_cdn_delete_attachment', $files);
|
232 |
+
|
233 |
+
$results = array();
|
234 |
+
|
235 |
+
$this->delete($files, true, $results);
|
236 |
+
}
|
237 |
+
|
238 |
/**
|
239 |
* Cron schedules filter
|
240 |
*
|
259 |
*/
|
260 |
function get_attachment_files($attachment_id)
|
261 |
{
|
262 |
+
$files = array();
|
263 |
+
$upload_info = w3_upload_info();
|
264 |
|
265 |
+
if ($upload_info) {
|
266 |
+
$attached_file = get_post_meta($attachment_id, '_wp_attached_file', true);
|
267 |
+
$attachment_metadata = get_post_meta($attachment_id, '_wp_attachment_metadata', true);
|
268 |
+
|
269 |
+
if ($attached_file) {
|
270 |
+
$file = $this->normalize_attachment_file($attached_file);
|
271 |
+
|
272 |
+
$local_file = $upload_info['upload_dir'] . '/' . $file;
|
273 |
+
$remote_file = $upload_info['upload_url'] . '/' . $file;
|
274 |
+
|
275 |
+
$files[$local_file] = $remote_file;
|
276 |
+
}
|
277 |
+
|
278 |
+
if ($attachment_metadata) {
|
279 |
+
$files = array_merge($files, $this->get_metadata_files($attachment_metadata));
|
280 |
+
}
|
281 |
}
|
|
|
282 |
return $files;
|
283 |
}
|
284 |
|
365 |
if ($upload_info) {
|
366 |
if (isset($metadata['file'])) {
|
367 |
$file = $this->normalize_attachment_file($metadata['file']);
|
368 |
+
|
|
|
|
|
369 |
if (isset($metadata['sizes'])) {
|
370 |
$file_dir = dirname($file);
|
371 |
+
|
372 |
foreach ((array) $metadata['sizes'] as $size) {
|
373 |
if (isset($size['file'])) {
|
374 |
$local_file = $upload_info['upload_dir'] . '/' . $file_dir . '/' . $size['file'];
|
375 |
$remote_file = $upload_info['upload_url'] . '/' . $file_dir . '/' . $size['file'];
|
376 |
+
|
377 |
$files[$local_file] = $remote_file;
|
378 |
}
|
379 |
}
|
491 |
function queue_process($limit)
|
492 |
{
|
493 |
$commands = $this->queue_get($limit);
|
494 |
+
$force_rewrite = $this->_config->get_boolean('cdn.force.rewrite');
|
495 |
|
496 |
if (count($commands)) {
|
497 |
$cdn = & $this->get_cdn();
|
498 |
+
|
499 |
foreach ($commands as $command => $queue) {
|
500 |
$files = array();
|
501 |
$results = array();
|
508 |
|
509 |
switch ($command) {
|
510 |
case W3TC_CDN_COMMAND_UPLOAD:
|
511 |
+
$cdn->upload($files, $results, $force_rewrite);
|
512 |
break;
|
513 |
|
514 |
case W3TC_CDN_COMMAND_DELETE:
|
538 |
function upload($files, $queue_failed, &$results)
|
539 |
{
|
540 |
$upload = array();
|
541 |
+
$force_rewrite = $this->_config->get_boolean('cdn.force.rewrite');
|
542 |
|
543 |
foreach ($files as $local_file => $remote_file) {
|
544 |
$local_path = $this->format_local_path($local_file);
|
547 |
}
|
548 |
|
549 |
$cdn = & $this->get_cdn();
|
550 |
+
|
551 |
+
if (!$cdn->upload($upload, $results, $force_rewrite)) {
|
552 |
if ($queue_failed) {
|
553 |
foreach ($results as $result) {
|
554 |
if ($result['result'] != W3_CDN_RESULT_OK) {
|
582 |
}
|
583 |
|
584 |
$cdn = & $this->get_cdn();
|
585 |
+
if (!$cdn->delete($delete, $results)) {
|
586 |
if ($queue_failed) {
|
587 |
foreach ($results as $result) {
|
588 |
if ($result['result'] != W3_CDN_RESULT_OK) {
|
647 |
$files = array();
|
648 |
|
649 |
foreach ($posts as $post) {
|
650 |
+
if (!empty($post->metadata)) {
|
651 |
$metadata = @unserialize($post->metadata);
|
652 |
} else {
|
653 |
$metadata = array();
|
654 |
}
|
655 |
if (isset($metadata['file'])) {
|
656 |
$files = array_merge($files, $this->get_metadata_files($metadata));
|
657 |
+
} elseif (!empty($post->file)) {
|
658 |
$file = $this->normalize_attachment_file($post->file);
|
659 |
$local_file = $upload_info['upload_dir'] . '/' . $file;
|
660 |
$remote_file = $upload_info['upload_url'] . '/' . $file;
|
691 |
$upload_info = w3_upload_info();
|
692 |
|
693 |
if ($upload_info) {
|
694 |
+
/**
|
695 |
+
* Search for posts with links or images
|
696 |
+
*/
|
697 |
$sql = sprintf('SELECT
|
698 |
ID,
|
699 |
post_content,
|
720 |
if ($posts) {
|
721 |
$count = count($posts);
|
722 |
$total = $this->get_import_posts_count();
|
723 |
+
$regexp = '~(' . $this->get_regexp_by_mask($this->_config->get_string('cdn.import.files')) . ')$~';
|
724 |
$import_external = $this->_config->get_boolean('cdn.import.external');
|
725 |
|
726 |
foreach ($posts as $post) {
|
727 |
$matches = null;
|
728 |
+
$replaced = array();
|
729 |
+
$attachments = array();
|
730 |
$post_content = $post->post_content;
|
731 |
|
732 |
+
/**
|
733 |
+
* Search for all link and image sources
|
734 |
+
*/
|
735 |
if (preg_match_all('~(href|src)=[\'"]?([^\'"<>\s]+)[\'"]?~', $post_content, $matches, PREG_SET_ORDER)) {
|
736 |
foreach ($matches as $match) {
|
737 |
+
list($search, $attribute, $origin) = $match;
|
738 |
+
|
739 |
+
/**
|
740 |
+
* Check if $search is already replaced
|
741 |
+
*/
|
742 |
+
if (isset($replaced[$search])) {
|
743 |
+
continue;
|
744 |
+
}
|
745 |
+
|
746 |
+
$error = '';
|
747 |
+
$result = false;
|
748 |
|
749 |
+
$src = w3_normalize_file($origin);
|
750 |
+
$dst = '';
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Check if file exists in the library
|
754 |
+
*/
|
755 |
+
if (stristr($origin, $upload_info['baseurl']) === false) {
|
756 |
+
/**
|
757 |
+
* Check file extension
|
758 |
+
*/
|
759 |
+
if (preg_match($regexp, $src)) {
|
760 |
+
/**
|
761 |
+
* Check for alredy uploaded attachment
|
762 |
+
*/
|
763 |
+
if (isset($attachments[$src])) {
|
764 |
+
list($dst, $dst_url) = $attachments[$src];
|
765 |
+
$result = true;
|
766 |
+
} else {
|
767 |
+
$upload_subdir = date('Y/m', strtotime($post->post_date));
|
768 |
+
$upload_dir = sprintf('%s/%s', $upload_info['upload_dir'], $upload_subdir);
|
769 |
+
$upload_url = sprintf('%s/%s', $upload_info['upload_url'], $upload_subdir);
|
770 |
+
|
771 |
+
$src_filename = pathinfo($src, PATHINFO_FILENAME);
|
772 |
+
$src_extension = pathinfo($src, PATHINFO_EXTENSION);
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Get available filename
|
776 |
+
*/
|
777 |
+
for ($i = 0;; $i++) {
|
778 |
+
$dst = sprintf('%s/%s%s%s', $upload_dir, $src_filename, ($i ? $i : ''), ($src_extension ? '.' . $src_extension : ''));
|
779 |
+
$dst_path = ABSPATH . $dst;
|
780 |
+
|
781 |
+
if (!file_exists($dst_path)) {
|
782 |
+
break;
|
783 |
+
}
|
784 |
+
}
|
785 |
+
|
786 |
+
$dst_basename = basename($dst);
|
787 |
+
$dst_dirname = dirname($dst);
|
788 |
+
$dst_url = sprintf('%s%s/%s', $site_url, $upload_url, $dst_basename);
|
789 |
+
|
790 |
+
w3_mkdir($dst_dirname, 0755, ABSPATH);
|
791 |
+
|
792 |
+
$download_result = false;
|
793 |
+
|
794 |
+
/**
|
795 |
+
* Check if file is remote URL
|
796 |
+
*/
|
797 |
+
if (w3_is_url($src)) {
|
798 |
+
/**
|
799 |
+
* Download file
|
800 |
+
*/
|
801 |
+
if ($import_external) {
|
802 |
+
$download_result = w3_download($src, $dst_path);
|
803 |
+
|
804 |
+
if (!$download_result) {
|
805 |
+
$error = 'Unable to download file';
|
806 |
+
}
|
807 |
+
} else {
|
808 |
+
$error = 'External file import is disabled';
|
809 |
+
}
|
810 |
} else {
|
811 |
+
/**
|
812 |
+
* Otherwise copy file from local path
|
813 |
+
*/
|
814 |
+
$src_path = ABSPATH . $src;
|
815 |
+
|
816 |
+
if (file_exists($src_path)) {
|
817 |
+
$download_result = @copy($src_path, $dst_path);
|
818 |
+
|
819 |
+
if (!$download_result) {
|
820 |
+
$error = 'Unable to copy file';
|
821 |
+
}
|
822 |
+
} else {
|
823 |
+
$error = 'Source file doesn\'t exists';
|
824 |
+
}
|
825 |
}
|
826 |
+
|
827 |
+
/**
|
828 |
+
* Check if download or copy was successful
|
829 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
if ($download_result) {
|
831 |
+
$title = $dst_basename;
|
832 |
$guid = $upload_info['upload_url'] . '/' . $title;
|
833 |
+
$mime_type = w3_get_mime_type($dst_basename);
|
834 |
|
835 |
$GLOBALS['wp_rewrite'] = & new WP_Rewrite();
|
836 |
|
837 |
+
/**
|
838 |
+
* Insert attachment
|
839 |
+
*/
|
840 |
$id = wp_insert_attachment(array(
|
841 |
'post_mime_type' => $mime_type,
|
842 |
'guid' => $guid,
|
844 |
'post_content' => ''
|
845 |
), $dst_path);
|
846 |
|
847 |
+
if (!is_wp_error($id)) {
|
848 |
+
/**
|
849 |
+
* Generate attachment metadata and upload to CDN
|
850 |
+
*/
|
851 |
require_once ABSPATH . 'wp-admin/includes/image.php';
|
852 |
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $dst_path));
|
853 |
|
854 |
+
$attachments[$src] = array(
|
855 |
+
$dst,
|
856 |
+
$dst_url
|
857 |
+
);
|
858 |
+
|
859 |
$result = true;
|
|
|
860 |
} else {
|
861 |
$error = 'Unable to insert attachment';
|
862 |
}
|
|
|
|
|
863 |
}
|
864 |
}
|
865 |
+
|
866 |
+
/**
|
867 |
+
* If attachment was successfully created then replace links
|
868 |
+
*/
|
869 |
+
if ($result) {
|
870 |
+
$replace = sprintf('%s="%s"', $attribute, $dst_url);
|
871 |
+
|
872 |
+
// replace $search with $replace
|
873 |
+
$post_content = str_replace($search, $replace, $post_content);
|
874 |
+
|
875 |
+
$replaced[$search] = $replace;
|
876 |
+
$error = 'OK';
|
877 |
+
}
|
878 |
} else {
|
879 |
+
$error = 'File type rejected';
|
880 |
}
|
881 |
+
} else {
|
882 |
+
$error = 'File already exists in the media library';
|
|
|
|
|
|
|
|
|
|
|
883 |
}
|
884 |
+
|
885 |
+
/**
|
886 |
+
* Add new entry to the log file
|
887 |
+
*/
|
888 |
+
$results[] = array(
|
889 |
+
'src' => $src,
|
890 |
+
'dst' => $dst,
|
891 |
+
'result' => $result,
|
892 |
+
'error' => $error
|
893 |
+
);
|
894 |
}
|
895 |
}
|
896 |
|
897 |
+
/**
|
898 |
+
* If post content was chenged then update DB
|
899 |
+
*/
|
900 |
if ($post_content != $post->post_content) {
|
901 |
wp_update_post(array(
|
902 |
'ID' => $post->ID,
|
1083 |
|
1084 |
foreach ($urls as $url) {
|
1085 |
$file = basename($url);
|
1086 |
+
if (w3_download($url, W3TC_CONTENT_MINIFY_DIR . '/' . $file) !== false) {
|
1087 |
$files[] = W3TC_CONTENT_MINIFY_DIR_NAME . '/' . $file;
|
1088 |
}
|
1089 |
}
|
1117 |
return $files;
|
1118 |
}
|
1119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1120 |
/**
|
1121 |
* Formats local file path
|
1122 |
*
|
1136 |
*/
|
1137 |
function format_remote_path($file)
|
1138 |
{
|
1139 |
+
return ltrim(w3_get_blog_path(), '/') . $file;
|
1140 |
}
|
1141 |
|
1142 |
/**
|
1150 |
global $wpdb;
|
1151 |
static $queue = null, $reject_files = null;
|
1152 |
|
1153 |
+
list($match, $quote, $url, $site_url, $path) = $matches;
|
|
|
|
|
1154 |
|
1155 |
+
$path = ltrim($path, '/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1156 |
|
1157 |
/**
|
1158 |
+
* Check if URL was already replaced
|
1159 |
*/
|
1160 |
+
if (isset($this->replaced_urls[$url])) {
|
1161 |
+
return $quote . $this->replaced_urls[$url];
|
1162 |
}
|
1163 |
|
1164 |
/**
|
1165 |
+
* Check URL for rejected files
|
1166 |
*/
|
1167 |
+
if ($reject_files === null) {
|
1168 |
+
$reject_files = $this->_config->get_array('cdn.reject.files');
|
1169 |
+
}
|
1170 |
+
|
1171 |
foreach ($reject_files as $reject_file) {
|
1172 |
if ($reject_file != '') {
|
1173 |
$reject_file = w3_normalize_file($reject_file);
|
1174 |
$reject_file_regexp = '~^' . $this->get_regexp_by_mask($reject_file) . '$~i';
|
1175 |
|
1176 |
+
if (preg_match($reject_file_regexp, $path)) {
|
1177 |
+
return $quote . $url;
|
1178 |
}
|
1179 |
}
|
1180 |
}
|
1181 |
|
1182 |
/**
|
1183 |
+
* Don't replace URL for files that are in the CDN queue
|
1184 |
*/
|
1185 |
+
if ($queue === null) {
|
1186 |
+
$sql = sprintf('SELECT remote_path FROM %s', $wpdb->prefix . W3TC_CDN_TABLE_QUEUE);
|
1187 |
+
$queue = $wpdb->get_col($sql);
|
1188 |
+
}
|
1189 |
|
1190 |
+
if (in_array($path, $queue)) {
|
1191 |
+
return $quote . $url;
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
/**
|
1195 |
+
* Do replacement
|
1196 |
+
*/
|
1197 |
$cdn = & $this->get_cdn();
|
|
|
1198 |
|
1199 |
+
$blog_path = w3_get_blog_path();
|
1200 |
+
$new_path = $blog_path . $path;
|
|
|
1201 |
|
1202 |
+
$new_url = $cdn->format_url($new_path);
|
1203 |
|
1204 |
+
if ($new_url) {
|
1205 |
+
$this->replaced_urls[$url] = $new_url;
|
1206 |
+
|
1207 |
+
return $quote . $new_url;
|
1208 |
+
}
|
1209 |
|
1210 |
+
return $quote . $url;
|
1211 |
}
|
1212 |
|
1213 |
/**
|
1255 |
*/
|
1256 |
function get_regexp_by_mask($mask)
|
1257 |
{
|
1258 |
+
$mask = trim($mask);
|
1259 |
+
$mask = w3_preg_quote($mask);
|
1260 |
+
|
1261 |
+
$mask = str_replace(array(
|
1262 |
'\*',
|
1263 |
'\?',
|
|
|
|
|
1264 |
';'
|
1265 |
), array(
|
1266 |
+
'@ASTERISK@',
|
1267 |
+
'@QUESTION@',
|
|
|
|
|
1268 |
'|'
|
1269 |
+
), $mask);
|
1270 |
+
|
1271 |
+
$regexp = str_replace(array(
|
1272 |
+
'@ASTERISK@',
|
1273 |
+
'@QUESTION@'
|
1274 |
+
), array(
|
1275 |
+
'[^\\?\\*:\\|"<>]*',
|
1276 |
+
'[^\\?\\*:\\|"<>]'
|
1277 |
+
), $mask);
|
1278 |
|
1279 |
return $regexp;
|
1280 |
}
|
1309 |
{
|
1310 |
static $cdn = array();
|
1311 |
|
1312 |
+
if (!isset($cdn[0])) {
|
1313 |
$engine = $this->_config->get_string('cdn.engine');
|
1314 |
$engine_config = array();
|
1315 |
|
1326 |
'user' => $this->_config->get_string('cdn.ftp.user'),
|
1327 |
'pass' => $this->_config->get_string('cdn.ftp.pass'),
|
1328 |
'path' => $this->_config->get_string('cdn.ftp.path'),
|
1329 |
+
'pasv' => $this->_config->get_boolean('cdn.ftp.pasv'),
|
1330 |
'domain' => $this->_config->get_string('cdn.ftp.domain')
|
1331 |
);
|
1332 |
break;
|
1371 |
if (count($this->replaced_urls)) {
|
1372 |
$debug_info .= "Replaced URLs:\r\n";
|
1373 |
|
1374 |
+
foreach ($this->replaced_urls as $old_url => $new_url) {
|
1375 |
+
$debug_info .= sprintf("%s => %s\r\n", $old_url, $new_url);
|
1376 |
}
|
1377 |
}
|
1378 |
|
1390 |
/**
|
1391 |
* Skip if CDN is disabled
|
1392 |
*/
|
1393 |
+
if (!$this->_config->get_boolean('cdn.enabled')) {
|
1394 |
$this->cdn_reject_reason = 'CDN is disabled';
|
1395 |
|
1396 |
return false;
|
1408 |
/**
|
1409 |
* Check User agent
|
1410 |
*/
|
1411 |
+
if (!$this->check_ua()) {
|
1412 |
$this->cdn_reject_reason = 'user agent is rejected';
|
1413 |
|
1414 |
return false;
|
1417 |
/**
|
1418 |
* Check request URI
|
1419 |
*/
|
1420 |
+
if (!$this->check_request_uri()) {
|
1421 |
$this->cdn_reject_reason = 'request URI is rejected';
|
1422 |
|
1423 |
return false;
|
lib/W3/Plugin/DbCache.php
CHANGED
@@ -173,7 +173,7 @@ class W3_Plugin_DbCache extends W3_Plugin
|
|
173 |
|
174 |
/**
|
175 |
* Does disk cache cleanup
|
176 |
-
|
177 |
* @return void
|
178 |
*/
|
179 |
function cleanup()
|
173 |
|
174 |
/**
|
175 |
* Does disk cache cleanup
|
176 |
+
*
|
177 |
* @return void
|
178 |
*/
|
179 |
function cleanup()
|
lib/W3/Plugin/Minify.php
CHANGED
@@ -17,6 +17,18 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
17 |
*/
|
18 |
var $minify_reject_reason = '';
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
/**
|
21 |
* Runs plugin
|
22 |
*/
|
@@ -49,11 +61,6 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
49 |
&$this,
|
50 |
'ob_callback'
|
51 |
));
|
52 |
-
|
53 |
-
add_action('wp_footer', array(
|
54 |
-
&$this,
|
55 |
-
'footer'
|
56 |
-
));
|
57 |
}
|
58 |
}
|
59 |
|
@@ -66,7 +73,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
66 |
{
|
67 |
static $instances = array();
|
68 |
|
69 |
-
if (!
|
70 |
$class = __CLASS__;
|
71 |
$instances[0] = & new $class();
|
72 |
}
|
@@ -79,28 +86,26 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
79 |
*/
|
80 |
function activate()
|
81 |
{
|
82 |
-
if (!
|
83 |
-
if (
|
84 |
-
|
85 |
-
@chmod(W3TC_CONTENT_DIR, 0755);
|
86 |
-
} else {
|
87 |
-
w3_writable_error(W3TC_CONTENT_DIR);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
$file_index = W3TC_CONTENT_MINIFY_DIR . '/index.php';
|
92 |
-
|
93 |
-
if (@copy(W3TC_INSTALL_MINIFY_DIR . '/index.php', $file_index)) {
|
94 |
-
@chmod($file_index, 0644);
|
95 |
} else {
|
96 |
-
w3_writable_error(
|
97 |
-
}
|
98 |
-
|
99 |
-
if ($this->_config->get_boolean('minify.rewrite') && ! $this->write_rules()) {
|
100 |
-
w3_writable_error(W3TC_CONTENT_MINIFY_DIR . '/.htaccess');
|
101 |
}
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
$this->schedule();
|
105 |
}
|
106 |
|
@@ -111,11 +116,9 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
111 |
{
|
112 |
$this->unschedule();
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$this->remove_rules();
|
118 |
-
}
|
119 |
}
|
120 |
|
121 |
/**
|
@@ -124,7 +127,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
124 |
function schedule()
|
125 |
{
|
126 |
if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_string('minify.engine') == 'file') {
|
127 |
-
if (!
|
128 |
wp_schedule_event(time(), 'w3_minify_cleanup', 'w3_minify_cleanup');
|
129 |
}
|
130 |
} else {
|
@@ -185,21 +188,40 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
185 |
*/
|
186 |
function ob_callback($buffer)
|
187 |
{
|
188 |
-
if ($buffer != '' && w3_is_xml($buffer)) {
|
189 |
$head_prepend = '';
|
|
|
190 |
|
191 |
-
if ($this->_config->get_boolean('minify.css.enable')) {
|
192 |
$head_prepend .= $this->get_styles('include');
|
193 |
}
|
194 |
|
195 |
if ($this->_config->get_boolean('minify.js.enable')) {
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
198 |
|
199 |
-
if (
|
200 |
$buffer = preg_replace('~<head(\s+[^<>]+)*>~Ui', '\\0' . $head_prepend, $buffer, 1);
|
201 |
}
|
202 |
|
|
|
|
|
|
|
|
|
203 |
$buffer = $this->clean($buffer);
|
204 |
|
205 |
if ($this->_config->get_boolean('minify.debug')) {
|
@@ -210,16 +232,6 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
210 |
return $buffer;
|
211 |
}
|
212 |
|
213 |
-
/**
|
214 |
-
* Footer action
|
215 |
-
*/
|
216 |
-
function footer()
|
217 |
-
{
|
218 |
-
if ($this->_config->get_boolean('minify.js.enable')) {
|
219 |
-
echo $this->get_scripts('include-footer') . $this->get_scripts('include-footer-nb');
|
220 |
-
}
|
221 |
-
}
|
222 |
-
|
223 |
/**
|
224 |
* Cleans content
|
225 |
*
|
@@ -228,9 +240,10 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
228 |
*/
|
229 |
function clean($content)
|
230 |
{
|
231 |
-
if (!
|
232 |
if ($this->_config->get_boolean('minify.css.enable')) {
|
233 |
$content = $this->clean_styles($content);
|
|
|
234 |
}
|
235 |
|
236 |
if ($this->_config->get_boolean('minify.js.enable')) {
|
@@ -238,12 +251,10 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
238 |
}
|
239 |
}
|
240 |
|
241 |
-
if ($this->_config->get_boolean('minify.html.enable') && !
|
242 |
$content = $this->minify_html($content);
|
243 |
}
|
244 |
|
245 |
-
$content = preg_replace('~<style[^<>]*>\s*</style>~', '', $content);
|
246 |
-
|
247 |
return $content;
|
248 |
}
|
249 |
|
@@ -262,9 +273,9 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
262 |
|
263 |
foreach ($groups as $group => $locations) {
|
264 |
foreach ((array) $locations as $location => $config) {
|
265 |
-
if (!
|
266 |
foreach ((array) $config['files'] as $file) {
|
267 |
-
if (w3_is_url($file) && !
|
268 |
// external CSS files
|
269 |
$regexps[] = w3_preg_quote($file);
|
270 |
} else {
|
@@ -300,9 +311,9 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
300 |
|
301 |
foreach ($groups as $group => $locations) {
|
302 |
foreach ((array) $locations as $location => $config) {
|
303 |
-
if (!
|
304 |
foreach ((array) $config['files'] as $file) {
|
305 |
-
if (w3_is_url($file) && !
|
306 |
// external JS files
|
307 |
$regexps[] = w3_preg_quote($file);
|
308 |
} else {
|
@@ -433,12 +444,12 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
433 |
} else {
|
434 |
$script = '';
|
435 |
|
436 |
-
if (
|
437 |
$non_blocking_function = true;
|
438 |
-
$script = "<script type=\"text/javascript\"
|
439 |
}
|
440 |
|
441 |
-
$script .= "<script type=\"text/javascript\"
|
442 |
|
443 |
return $script;
|
444 |
}
|
@@ -463,7 +474,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
463 |
$group = 'default';
|
464 |
}
|
465 |
|
466 |
-
if (!
|
467 |
$styles .= $this->get_style($this->format_url($group, $location, 'css'), isset($groups[$group][$location]['import']) ? (boolean) $groups[$group][$location]['import'] : false);
|
468 |
}
|
469 |
|
@@ -489,7 +500,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
489 |
$group = 'default';
|
490 |
}
|
491 |
|
492 |
-
if (!
|
493 |
$scripts .= $this->get_script($this->format_url($group, $location, 'js'), isset($groups[$group][$location]['blocking']) ? (boolean) $groups[$group][$location]['blocking'] : true);
|
494 |
}
|
495 |
|
@@ -531,10 +542,10 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
531 |
$site_url_ssl = w3_get_site_url_ssl();
|
532 |
|
533 |
if ($this->_config->get_boolean('minify.rewrite')) {
|
534 |
-
return sprintf('%s
|
535 |
}
|
536 |
|
537 |
-
return sprintf('%s
|
538 |
}
|
539 |
|
540 |
/**
|
@@ -545,7 +556,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
545 |
*/
|
546 |
function format_custom_url($files)
|
547 |
{
|
548 |
-
if (!
|
549 |
$files = array(
|
550 |
(string) $files
|
551 |
);
|
@@ -564,7 +575,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
564 |
}
|
565 |
|
566 |
$site_url_ssl = w3_get_site_url_ssl();
|
567 |
-
$url = sprintf('%s
|
568 |
|
569 |
if ($base) {
|
570 |
$url .= sprintf('&b=%s', $base);
|
@@ -587,7 +598,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
587 |
|
588 |
foreach ($js_groups as $js_group => $js_locations) {
|
589 |
foreach ((array) $js_locations as $js_location => $js_config) {
|
590 |
-
if (!
|
591 |
$files[] = $this->format_url($js_group, $js_location, 'js');
|
592 |
}
|
593 |
}
|
@@ -595,7 +606,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
595 |
|
596 |
foreach ($css_groups as $css_group => $css_locations) {
|
597 |
foreach ((array) $css_locations as $css_location => $css_config) {
|
598 |
-
if (!
|
599 |
$files[] = $this->format_url($css_group, $css_location, 'css');
|
600 |
}
|
601 |
}
|
@@ -674,7 +685,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
674 |
/**
|
675 |
* Skip if Minify is disabled
|
676 |
*/
|
677 |
-
if (
|
678 |
$this->minify_reject_reason = 'minify is disabled';
|
679 |
|
680 |
return false;
|
@@ -728,7 +739,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
728 |
/**
|
729 |
* Check User agent
|
730 |
*/
|
731 |
-
if (
|
732 |
$this->minify_reject_reason = 'user agent is rejected';
|
733 |
|
734 |
return false;
|
@@ -737,7 +748,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
737 |
/**
|
738 |
* Check request URI
|
739 |
*/
|
740 |
-
if (
|
741 |
$this->minify_reject_reason = 'request URI is rejected';
|
742 |
|
743 |
return false;
|
@@ -746,6 +757,22 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
746 |
return true;
|
747 |
}
|
748 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
749 |
/**
|
750 |
* Checks User Agent
|
751 |
*
|
@@ -797,55 +824,72 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
797 |
*/
|
798 |
function generate_rules()
|
799 |
{
|
|
|
|
|
|
|
|
|
800 |
$rules = '';
|
801 |
$rules .= "# BEGIN W3TC Minify\n";
|
802 |
|
803 |
-
if ($
|
804 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
805 |
$rules .= "<IfModule mod_mime.c>\n";
|
806 |
-
|
807 |
-
$
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
|
|
|
|
|
|
|
|
813 |
$rules .= "</IfModule>\n";
|
814 |
|
815 |
-
$rules .= "<IfModule
|
816 |
-
$rules .= " SetEnvIfNoCase
|
|
|
|
|
|
|
817 |
$rules .= "</IfModule>\n";
|
818 |
}
|
819 |
|
820 |
$rules .= "<IfModule mod_expires.c>\n";
|
821 |
$rules .= " ExpiresActive On\n";
|
822 |
-
$rules .= " ExpiresByType text/css M" . $
|
823 |
-
$rules .= " ExpiresByType application/x-javascript M" . $
|
824 |
$rules .= "</IfModule>\n";
|
825 |
|
826 |
$rules .= "<IfModule mod_headers.c>\n";
|
827 |
$rules .= " Header set Pragma public\n";
|
828 |
$rules .= " Header set X-Powered-By \"" . W3TC_POWERED_BY . "\"\n";
|
829 |
$rules .= " Header set Vary \"Accept-Encoding\"\n";
|
830 |
-
$rules .= " Header append Cache-Control \"public, must-revalidate\"\n";
|
831 |
$rules .= "</IfModule>\n";
|
832 |
}
|
833 |
|
834 |
$rules .= "<IfModule mod_rewrite.c>\n";
|
835 |
-
|
836 |
$rules .= " RewriteEngine On\n";
|
837 |
|
838 |
-
if ($
|
839 |
-
if ($this->_config->get_boolean('minify.compress')) {
|
840 |
-
$rules .= " SetEnvIfNoCase Accept-Encoding gzip APPEND_EXT=.gz\n";
|
841 |
-
}
|
842 |
-
|
843 |
$rules .= " RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -f\n";
|
844 |
$rules .= " RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]\n";
|
845 |
}
|
846 |
|
847 |
$rules .= " RewriteRule ^([a-z0-9\\-_]+)\\.(include(-footer)?(-nb)?)\\.(css|js)$ index.php?gg=$1&g=$2&t=$5 [L]\n";
|
848 |
-
|
849 |
$rules .= "</IfModule>\n";
|
850 |
|
851 |
$rules .= "# END W3TC Minify\n\n";
|
@@ -874,14 +918,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
874 |
|
875 |
$data = trim($this->generate_rules() . $data);
|
876 |
|
877 |
-
|
878 |
-
@fputs($fp, $data);
|
879 |
-
@fclose($fp);
|
880 |
-
|
881 |
-
return true;
|
882 |
-
}
|
883 |
-
|
884 |
-
return false;
|
885 |
}
|
886 |
|
887 |
/**
|
@@ -892,7 +929,7 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
892 |
*/
|
893 |
function erase_rules($data)
|
894 |
{
|
895 |
-
$data = preg_replace('~# BEGIN W3TC Minify.*# END W3TC Minify~
|
896 |
$data = trim($data);
|
897 |
|
898 |
return $data;
|
@@ -918,9 +955,9 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
918 |
function check_rules()
|
919 |
{
|
920 |
$path = W3TC_CACHE_FILE_MINIFY_DIR . '/.htaccess';
|
921 |
-
$search =
|
922 |
|
923 |
-
return (($data = @file_get_contents($path)) && strstr($data, $search) !== false);
|
924 |
}
|
925 |
}
|
926 |
|
@@ -933,6 +970,8 @@ class W3_Plugin_Minify extends W3_Plugin
|
|
933 |
function w3tc_scripts($location, $group = null)
|
934 |
{
|
935 |
$w3_plugin_minify = & W3_Plugin_Minify::instance();
|
|
|
|
|
936 |
echo $w3_plugin_minify->get_scripts($location, $group);
|
937 |
}
|
938 |
|
@@ -945,6 +984,8 @@ function w3tc_scripts($location, $group = null)
|
|
945 |
function w3tc_styles($location, $group = null)
|
946 |
{
|
947 |
$w3_plugin_minify = & W3_Plugin_Minify::instance();
|
|
|
|
|
948 |
echo $w3_plugin_minify->get_styles($location, $group);
|
949 |
}
|
950 |
|
17 |
*/
|
18 |
var $minify_reject_reason = '';
|
19 |
|
20 |
+
/**
|
21 |
+
* Array of printed styles
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
var $printed_styles = array();
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Array of printed scripts
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
var $printed_scripts = array();
|
31 |
+
|
32 |
/**
|
33 |
* Runs plugin
|
34 |
*/
|
61 |
&$this,
|
62 |
'ob_callback'
|
63 |
));
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
}
|
66 |
|
73 |
{
|
74 |
static $instances = array();
|
75 |
|
76 |
+
if (!isset($instances[0])) {
|
77 |
$class = __CLASS__;
|
78 |
$instances[0] = & new $class();
|
79 |
}
|
86 |
*/
|
87 |
function activate()
|
88 |
{
|
89 |
+
if (!is_dir(W3TC_CONTENT_MINIFY_DIR)) {
|
90 |
+
if (@mkdir(W3TC_CONTENT_MINIFY_DIR, 0755)) {
|
91 |
+
@chmod(W3TC_CONTENT_MINIFY_DIR, 0755);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
} else {
|
93 |
+
w3_writable_error(W3TC_CONTENT_MINIFY_DIR);
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
}
|
96 |
|
97 |
+
$file_index = W3TC_CONTENT_MINIFY_DIR . '/index.php';
|
98 |
+
|
99 |
+
if (@copy(W3TC_INSTALL_MINIFY_DIR . '/index.php', $file_index)) {
|
100 |
+
@chmod($file_index, 0644);
|
101 |
+
} else {
|
102 |
+
w3_writable_error($file_index);
|
103 |
+
}
|
104 |
+
|
105 |
+
if ($this->_config->get_boolean('minify.rewrite') && !$this->write_rules()) {
|
106 |
+
w3_writable_error(W3TC_CONTENT_MINIFY_DIR . '/.htaccess');
|
107 |
+
}
|
108 |
+
|
109 |
$this->schedule();
|
110 |
}
|
111 |
|
116 |
{
|
117 |
$this->unschedule();
|
118 |
|
119 |
+
@unlink(W3TC_CONTENT_MINIFY_DIR . '/index.php');
|
120 |
+
|
121 |
+
$this->remove_rules();
|
|
|
|
|
122 |
}
|
123 |
|
124 |
/**
|
127 |
function schedule()
|
128 |
{
|
129 |
if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_string('minify.engine') == 'file') {
|
130 |
+
if (!wp_next_scheduled('w3_minify_cleanup')) {
|
131 |
wp_schedule_event(time(), 'w3_minify_cleanup', 'w3_minify_cleanup');
|
132 |
}
|
133 |
} else {
|
188 |
*/
|
189 |
function ob_callback($buffer)
|
190 |
{
|
191 |
+
if ($buffer != '' && w3_is_xml($buffer) && $this->can_minify2()) {
|
192 |
$head_prepend = '';
|
193 |
+
$body_append = '';
|
194 |
|
195 |
+
if ($this->_config->get_boolean('minify.css.enable') && !in_array('include', $this->printed_styles)) {
|
196 |
$head_prepend .= $this->get_styles('include');
|
197 |
}
|
198 |
|
199 |
if ($this->_config->get_boolean('minify.js.enable')) {
|
200 |
+
if (!in_array('include', $this->printed_scripts)) {
|
201 |
+
$head_prepend .= $this->get_scripts('include');
|
202 |
+
}
|
203 |
+
|
204 |
+
if (!in_array('include-nb', $this->printed_scripts)) {
|
205 |
+
$head_prepend .= $this->get_scripts('include-nb');
|
206 |
+
}
|
207 |
+
|
208 |
+
if (!in_array('include-footer', $this->printed_scripts)) {
|
209 |
+
$body_append .= $this->get_scripts('include-footer');
|
210 |
+
}
|
211 |
+
|
212 |
+
if (!in_array('include-footer-nb', $this->printed_scripts)) {
|
213 |
+
$body_append .= $this->get_scripts('include-footer-nb');
|
214 |
+
}
|
215 |
}
|
216 |
|
217 |
+
if ($head_prepend != '') {
|
218 |
$buffer = preg_replace('~<head(\s+[^<>]+)*>~Ui', '\\0' . $head_prepend, $buffer, 1);
|
219 |
}
|
220 |
|
221 |
+
if ($body_append != '') {
|
222 |
+
$buffer = preg_replace('~<\\/body>~', $body_append . '\\0', $buffer, 1);
|
223 |
+
}
|
224 |
+
|
225 |
$buffer = $this->clean($buffer);
|
226 |
|
227 |
if ($this->_config->get_boolean('minify.debug')) {
|
232 |
return $buffer;
|
233 |
}
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
/**
|
236 |
* Cleans content
|
237 |
*
|
240 |
*/
|
241 |
function clean($content)
|
242 |
{
|
243 |
+
if (!is_feed()) {
|
244 |
if ($this->_config->get_boolean('minify.css.enable')) {
|
245 |
$content = $this->clean_styles($content);
|
246 |
+
$content = preg_replace('~<style[^<>]*>\s*</style>~', '', $content);
|
247 |
}
|
248 |
|
249 |
if ($this->_config->get_boolean('minify.js.enable')) {
|
251 |
}
|
252 |
}
|
253 |
|
254 |
+
if ($this->_config->get_boolean('minify.html.enable') && !($this->_config->get_boolean('minify.html.reject.admin') && current_user_can('manage_options'))) {
|
255 |
$content = $this->minify_html($content);
|
256 |
}
|
257 |
|
|
|
|
|
258 |
return $content;
|
259 |
}
|
260 |
|
273 |
|
274 |
foreach ($groups as $group => $locations) {
|
275 |
foreach ((array) $locations as $location => $config) {
|
276 |
+
if (!empty($config['files'])) {
|
277 |
foreach ((array) $config['files'] as $file) {
|
278 |
+
if (w3_is_url($file) && !preg_match('~' . $domain_url_regexp . '~i', $file)) {
|
279 |
// external CSS files
|
280 |
$regexps[] = w3_preg_quote($file);
|
281 |
} else {
|
311 |
|
312 |
foreach ($groups as $group => $locations) {
|
313 |
foreach ((array) $locations as $location => $config) {
|
314 |
+
if (!empty($config['files'])) {
|
315 |
foreach ((array) $config['files'] as $file) {
|
316 |
+
if (w3_is_url($file) && !preg_match('~' . $domain_url_regexp . '~i', $file)) {
|
317 |
// external JS files
|
318 |
$regexps[] = w3_preg_quote($file);
|
319 |
} else {
|
444 |
} else {
|
445 |
$script = '';
|
446 |
|
447 |
+
if (!$non_blocking_function) {
|
448 |
$non_blocking_function = true;
|
449 |
+
$script = "<script type=\"text/javascript\">function w3tc_load_js(u){var d=document,p=d.getElementsByTagName('HEAD')[0],c=d.createElement('script');c.type='text/javascript';c.src=u;p.appendChild(c);}</script>";
|
450 |
}
|
451 |
|
452 |
+
$script .= "<script type=\"text/javascript\">w3tc_load_js('" . $url . "');</script>";
|
453 |
|
454 |
return $script;
|
455 |
}
|
474 |
$group = 'default';
|
475 |
}
|
476 |
|
477 |
+
if (!empty($groups[$group][$location]['files'])) {
|
478 |
$styles .= $this->get_style($this->format_url($group, $location, 'css'), isset($groups[$group][$location]['import']) ? (boolean) $groups[$group][$location]['import'] : false);
|
479 |
}
|
480 |
|
500 |
$group = 'default';
|
501 |
}
|
502 |
|
503 |
+
if (!empty($groups[$group][$location]['files'])) {
|
504 |
$scripts .= $this->get_script($this->format_url($group, $location, 'js'), isset($groups[$group][$location]['blocking']) ? (boolean) $groups[$group][$location]['blocking'] : true);
|
505 |
}
|
506 |
|
542 |
$site_url_ssl = w3_get_site_url_ssl();
|
543 |
|
544 |
if ($this->_config->get_boolean('minify.rewrite')) {
|
545 |
+
return sprintf('%s/%s/%s.%s.%s', $site_url_ssl, W3TC_CONTENT_MINIFY_DIR_NAME, $group, $location, $type);
|
546 |
}
|
547 |
|
548 |
+
return sprintf('%s/%s/index.php?gg=%s&g=%s&t=%s', $site_url_ssl, W3TC_CONTENT_MINIFY_DIR_NAME, $group, $location, $type);
|
549 |
}
|
550 |
|
551 |
/**
|
556 |
*/
|
557 |
function format_custom_url($files)
|
558 |
{
|
559 |
+
if (!is_array($files)) {
|
560 |
$files = array(
|
561 |
(string) $files
|
562 |
);
|
575 |
}
|
576 |
|
577 |
$site_url_ssl = w3_get_site_url_ssl();
|
578 |
+
$url = sprintf('%s/%s/minify.php?f=%s', $site_url_ssl, W3TC_CONTENT_DIR_NAME, implode(',', $files));
|
579 |
|
580 |
if ($base) {
|
581 |
$url .= sprintf('&b=%s', $base);
|
598 |
|
599 |
foreach ($js_groups as $js_group => $js_locations) {
|
600 |
foreach ((array) $js_locations as $js_location => $js_config) {
|
601 |
+
if (!empty($js_config['files'])) {
|
602 |
$files[] = $this->format_url($js_group, $js_location, 'js');
|
603 |
}
|
604 |
}
|
606 |
|
607 |
foreach ($css_groups as $css_group => $css_locations) {
|
608 |
foreach ((array) $css_locations as $css_location => $css_config) {
|
609 |
+
if (!empty($css_config['files'])) {
|
610 |
$files[] = $this->format_url($css_group, $css_location, 'css');
|
611 |
}
|
612 |
}
|
685 |
/**
|
686 |
* Skip if Minify is disabled
|
687 |
*/
|
688 |
+
if (!$this->_config->get_boolean('minify.enabled')) {
|
689 |
$this->minify_reject_reason = 'minify is disabled';
|
690 |
|
691 |
return false;
|
739 |
/**
|
740 |
* Check User agent
|
741 |
*/
|
742 |
+
if (!$this->check_ua()) {
|
743 |
$this->minify_reject_reason = 'user agent is rejected';
|
744 |
|
745 |
return false;
|
748 |
/**
|
749 |
* Check request URI
|
750 |
*/
|
751 |
+
if (!$this->check_request_uri()) {
|
752 |
$this->minify_reject_reason = 'request URI is rejected';
|
753 |
|
754 |
return false;
|
757 |
return true;
|
758 |
}
|
759 |
|
760 |
+
/**
|
761 |
+
* Check if we can do minify logic
|
762 |
+
*
|
763 |
+
* @return boolean
|
764 |
+
*/
|
765 |
+
function can_minify2()
|
766 |
+
{
|
767 |
+
if ($this->_config->get_boolean('minify.html.reject.feed') && function_exists('is_feed') && is_feed()) {
|
768 |
+
$this->minify_reject_reason = 'feed is rejected';
|
769 |
+
|
770 |
+
return false;
|
771 |
+
}
|
772 |
+
|
773 |
+
return true;
|
774 |
+
}
|
775 |
+
|
776 |
/**
|
777 |
* Checks User Agent
|
778 |
*
|
824 |
*/
|
825 |
function generate_rules()
|
826 |
{
|
827 |
+
$compressions = array();
|
828 |
+
$engine = $this->_config->get_string('minify.engine');
|
829 |
+
$lifetime = $this->_config->get_integer('minify.lifetime');
|
830 |
+
|
831 |
$rules = '';
|
832 |
$rules .= "# BEGIN W3TC Minify\n";
|
833 |
|
834 |
+
if ($engine == 'file') {
|
835 |
+
$compression = $this->_config->get_string('minify.compression');
|
836 |
+
|
837 |
+
if ($compression != '') {
|
838 |
+
if (stristr($compression, 'gzip') !== false) {
|
839 |
+
$compressions[] = 'gzip';
|
840 |
+
}
|
841 |
+
|
842 |
+
if (stristr($compression, 'deflate') !== false) {
|
843 |
+
$compressions[] = 'deflate';
|
844 |
+
}
|
845 |
+
}
|
846 |
+
|
847 |
+
if (count($compressions)) {
|
848 |
$rules .= "<IfModule mod_mime.c>\n";
|
849 |
+
|
850 |
+
foreach ($compressions as $_compression) {
|
851 |
+
$rules .= " AddEncoding " . $_compression . " ." . $_compression . "\n";
|
852 |
+
$rules .= " <Files *.css." . $_compression . ">\n";
|
853 |
+
$rules .= " ForceType text/css\n";
|
854 |
+
$rules .= " </Files>\n";
|
855 |
+
$rules .= " <Files *.js." . $_compression . ">\n";
|
856 |
+
$rules .= " ForceType application/x-javascript\n";
|
857 |
+
$rules .= " </Files>\n";
|
858 |
+
}
|
859 |
+
|
860 |
$rules .= "</IfModule>\n";
|
861 |
|
862 |
+
$rules .= "<IfModule mod_setenvif.c>\n";
|
863 |
+
$rules .= " SetEnvIfNoCase Accept-Encoding (" . implode('|', $compressions) . ") APPEND_EXT=.$1\n";
|
864 |
+
$rules .= " <IfModule mod_deflate.c>\n";
|
865 |
+
$rules .= " SetEnvIfNoCase Request_URI \\.(" . implode('|', $compressions) . ")$ no-gzip\n";
|
866 |
+
$rules .= " </IfModule>\n";
|
867 |
$rules .= "</IfModule>\n";
|
868 |
}
|
869 |
|
870 |
$rules .= "<IfModule mod_expires.c>\n";
|
871 |
$rules .= " ExpiresActive On\n";
|
872 |
+
$rules .= " ExpiresByType text/css M" . $lifetime . "\n";
|
873 |
+
$rules .= " ExpiresByType application/x-javascript M" . $lifetime . "\n";
|
874 |
$rules .= "</IfModule>\n";
|
875 |
|
876 |
$rules .= "<IfModule mod_headers.c>\n";
|
877 |
$rules .= " Header set Pragma public\n";
|
878 |
$rules .= " Header set X-Powered-By \"" . W3TC_POWERED_BY . "\"\n";
|
879 |
$rules .= " Header set Vary \"Accept-Encoding\"\n";
|
880 |
+
$rules .= " Header append Cache-Control \"public, must-revalidate, proxy-revalidate\"\n";
|
881 |
$rules .= "</IfModule>\n";
|
882 |
}
|
883 |
|
884 |
$rules .= "<IfModule mod_rewrite.c>\n";
|
|
|
885 |
$rules .= " RewriteEngine On\n";
|
886 |
|
887 |
+
if ($engine == 'file') {
|
|
|
|
|
|
|
|
|
888 |
$rules .= " RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -f\n";
|
889 |
$rules .= " RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]\n";
|
890 |
}
|
891 |
|
892 |
$rules .= " RewriteRule ^([a-z0-9\\-_]+)\\.(include(-footer)?(-nb)?)\\.(css|js)$ index.php?gg=$1&g=$2&t=$5 [L]\n";
|
|
|
893 |
$rules .= "</IfModule>\n";
|
894 |
|
895 |
$rules .= "# END W3TC Minify\n\n";
|
918 |
|
919 |
$data = trim($this->generate_rules() . $data);
|
920 |
|
921 |
+
return @file_put_contents($path, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
922 |
}
|
923 |
|
924 |
/**
|
929 |
*/
|
930 |
function erase_rules($data)
|
931 |
{
|
932 |
+
$data = preg_replace('~# BEGIN W3TC Minify.*# END W3TC Minify~Us', '', $data);
|
933 |
$data = trim($data);
|
934 |
|
935 |
return $data;
|
955 |
function check_rules()
|
956 |
{
|
957 |
$path = W3TC_CACHE_FILE_MINIFY_DIR . '/.htaccess';
|
958 |
+
$search = $this->generate_rules();
|
959 |
|
960 |
+
return (($data = @file_get_contents($path)) && strstr(w3_clean_rules($data), w3_clean_rules($search)) !== false);
|
961 |
}
|
962 |
}
|
963 |
|
970 |
function w3tc_scripts($location, $group = null)
|
971 |
{
|
972 |
$w3_plugin_minify = & W3_Plugin_Minify::instance();
|
973 |
+
$w3_plugin_minify->printed_scripts[] = $location;
|
974 |
+
|
975 |
echo $w3_plugin_minify->get_scripts($location, $group);
|
976 |
}
|
977 |
|
984 |
function w3tc_styles($location, $group = null)
|
985 |
{
|
986 |
$w3_plugin_minify = & W3_Plugin_Minify::instance();
|
987 |
+
$w3_plugin_minify->printed_styles[] = $location;
|
988 |
+
|
989 |
echo $w3_plugin_minify->get_styles($location, $group);
|
990 |
}
|
991 |
|
lib/W3/Plugin/PgCache.php
CHANGED
@@ -109,7 +109,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
109 |
{
|
110 |
static $instances = array();
|
111 |
|
112 |
-
if (!
|
113 |
$class = __CLASS__;
|
114 |
$instances[0] = & new $class();
|
115 |
}
|
@@ -122,33 +122,33 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
122 |
*/
|
123 |
function activate()
|
124 |
{
|
125 |
-
if (
|
126 |
-
|
127 |
-
$error = sprintf('<strong>%swp-config.php</strong> could not be written, please edit config and add:<br /><strong style="color:#f00;">define(\'WP_CACHE\', true);</strong> before <strong style="color:#f00;">require_once(ABSPATH . \'wp-settings.php\');</strong><br />then re-activate plugin.', ABSPATH);
|
128 |
-
|
129 |
-
w3_activate_error($error);
|
130 |
-
}
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
-
if (
|
139 |
-
|
140 |
-
$this->_config->save();
|
141 |
-
} else {
|
142 |
-
if (! $this->write_rules_core()) {
|
143 |
-
w3_writable_error(ABSPATH . '.htaccess');
|
144 |
-
}
|
145 |
-
|
146 |
-
if (! $this->write_rules_cache()) {
|
147 |
-
w3_writable_error(W3TC_CACHE_FILE_PGCACHE_DIR . '/.htaccess');
|
148 |
-
}
|
149 |
}
|
150 |
}
|
151 |
-
|
|
|
|
|
152 |
if (@copy(W3TC_INSTALL_DIR . '/advanced-cache.php', WP_CONTENT_DIR . '/advanced-cache.php')) {
|
153 |
@chmod(WP_CONTENT_DIR . '/advanced-cache.php', 0644);
|
154 |
} else {
|
@@ -166,12 +166,15 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
166 |
{
|
167 |
$this->unschedule();
|
168 |
|
169 |
-
if (
|
170 |
-
$this->remove_rules_cache();
|
171 |
-
$this->remove_rules_core();
|
172 |
-
|
173 |
@unlink(WP_CONTENT_DIR . '/advanced-cache.php');
|
174 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
|
177 |
/**
|
@@ -180,7 +183,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
180 |
function schedule()
|
181 |
{
|
182 |
if ($this->_config->get_boolean('pgcache.enabled') && ($this->_config->get_string('pgcache.engine') == 'file' || $this->_config->get_string('pgcache.engine') == 'file_pgcache')) {
|
183 |
-
if (!
|
184 |
wp_schedule_event(time(), 'w3_pgcache_cleanup', 'w3_pgcache_cleanup');
|
185 |
}
|
186 |
} else {
|
@@ -211,18 +214,18 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
211 |
return true;
|
212 |
}
|
213 |
|
214 |
-
|
215 |
-
|
216 |
-
}
|
217 |
|
218 |
-
if (
|
219 |
return false;
|
220 |
}
|
221 |
|
222 |
$config_data = preg_replace('~<\?(php)?~', "\\0\r\n/** Enable W3 Total Cache **/\r\ndefine('WP_CACHE', true); // Added by W3 Total Cache\r\n", $config_data, 1);
|
223 |
|
224 |
-
|
225 |
-
|
|
|
226 |
|
227 |
$updated = true;
|
228 |
|
@@ -303,7 +306,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
303 |
{
|
304 |
static $flushed_posts = array();
|
305 |
|
306 |
-
if (!
|
307 |
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
|
308 |
|
309 |
$w3_pgcache = & W3_PgCache::instance();
|
@@ -324,7 +327,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
324 |
|
325 |
if ($comment_id) {
|
326 |
$comment = get_comment($comment_id, ARRAY_A);
|
327 |
-
$post_id = !
|
328 |
}
|
329 |
|
330 |
$this->on_post_change($post_id);
|
@@ -350,7 +353,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
350 |
{
|
351 |
static $flushed = false;
|
352 |
|
353 |
-
if (
|
354 |
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
|
355 |
|
356 |
$w3_pgcache = & W3_PgCache::instance();
|
@@ -365,6 +368,8 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
365 |
*/
|
366 |
function generate_rules_core()
|
367 |
{
|
|
|
|
|
368 |
/**
|
369 |
* Auto reject cookies
|
370 |
*/
|
@@ -395,32 +400,46 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
395 |
/**
|
396 |
* Reject cache for home page
|
397 |
*/
|
398 |
-
if (
|
399 |
$reject_uris[] = '^(\/|\/index.php)$';
|
400 |
}
|
401 |
|
402 |
/**
|
403 |
* Reject cache for feeds
|
404 |
*/
|
405 |
-
if (
|
406 |
$reject_uris[] = 'feed';
|
407 |
}
|
408 |
|
409 |
/**
|
410 |
* Custom config
|
411 |
*/
|
412 |
-
$reject_cookies
|
413 |
-
$reject_uris
|
414 |
$reject_user_agents = $this->_config->get_array('pgcache.reject.ua');
|
415 |
$accept_files = $this->_config->get_array('pgcache.accept.files');
|
416 |
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
/**
|
418 |
* Generate directives
|
419 |
*/
|
420 |
$rules = '';
|
421 |
$rules .= "# BEGIN W3 Total Cache\n";
|
422 |
|
423 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
|
425 |
$compression = $this->_config->get_string('pgcache.compression');
|
426 |
|
@@ -436,10 +455,16 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
436 |
}
|
437 |
|
438 |
if (count($compressions)) {
|
439 |
-
$
|
440 |
}
|
441 |
}
|
442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
$rules .= " RewriteEngine On\n";
|
444 |
|
445 |
$mobile_redirect = $this->_config->get_string('pgcache.mobile.redirect');
|
@@ -447,33 +472,50 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
447 |
if ($mobile_redirect != '') {
|
448 |
$mobile_agents = $this->_config->get_array('pgcache.mobile.agents');
|
449 |
|
450 |
-
$rules .= " RewriteCond %{HTTP_USER_AGENT} " . implode('|', array_map('w3_preg_quote', $mobile_agents)) . " [NC]\n";
|
451 |
$rules .= " RewriteRule .* " . $mobile_redirect . " [R,L]\n";
|
452 |
}
|
453 |
|
454 |
-
$rules .= " RewriteCond %{REQUEST_URI}
|
|
|
455 |
|
456 |
if (count($accept_files)) {
|
457 |
-
$rules .= " [OR]\n RewriteCond %{REQUEST_URI} " . implode('|', array_map('w3_preg_quote', $accept_files)) . " [NC]\n";
|
458 |
} else {
|
459 |
$rules .= "\n";
|
460 |
}
|
461 |
|
462 |
$rules .= " RewriteCond %{REQUEST_METHOD} !=POST\n";
|
463 |
$rules .= " RewriteCond %{QUERY_STRING} =\"\"\n";
|
464 |
-
$rules .= " RewriteCond %{HTTP_COOKIE} !" . implode('|', array_map('w3_preg_quote', $reject_cookies)) . " [NC]\n";
|
465 |
|
466 |
if (count($reject_user_agents)) {
|
467 |
-
$rules .= " RewriteCond %{HTTP_USER_AGENT} !" . implode('|', array_map('w3_preg_quote', $reject_user_agents)) . " [NC]\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
}
|
469 |
|
470 |
-
$rules .= " RewriteCond " .
|
471 |
-
$rules .= " RewriteRule (.*) " . str_replace(ABSPATH, '',
|
472 |
$rules .= "</IfModule>\n";
|
473 |
|
474 |
$rules .= "# END W3 Total Cache\n\n";
|
475 |
|
476 |
-
if (
|
477 |
$rules .= "# BEGIN WordPress\n";
|
478 |
$rules .= "<IfModule mod_rewrite.c>\n";
|
479 |
$rules .= " RewriteEngine On\n";
|
@@ -545,7 +587,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
545 |
}
|
546 |
|
547 |
$rules .= " Header set Pragma public\n";
|
548 |
-
$rules .= " Header append Cache-Control \"public, must-revalidate\"\n";
|
549 |
$rules .= "</IfModule>\n";
|
550 |
|
551 |
$rules .= "# END W3 Total Cache\n\n";
|
@@ -575,14 +617,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
575 |
|
576 |
$data = trim($this->generate_rules_core() . $data);
|
577 |
|
578 |
-
|
579 |
-
@fputs($fp, $data);
|
580 |
-
@fclose($fp);
|
581 |
-
|
582 |
-
return true;
|
583 |
-
}
|
584 |
-
|
585 |
-
return false;
|
586 |
}
|
587 |
|
588 |
/**
|
@@ -606,14 +641,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
606 |
|
607 |
$data = trim($this->generate_rules_cache() . $data);
|
608 |
|
609 |
-
|
610 |
-
@fputs($fp, $data);
|
611 |
-
@fclose($fp);
|
612 |
-
|
613 |
-
return true;
|
614 |
-
}
|
615 |
-
|
616 |
-
return false;
|
617 |
}
|
618 |
|
619 |
/**
|
@@ -624,7 +652,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
624 |
*/
|
625 |
function erase_rules_w3tc($data)
|
626 |
{
|
627 |
-
$data = preg_replace('~# BEGIN W3 Total Cache.*# END W3 Total Cache~
|
628 |
$data = trim($data);
|
629 |
|
630 |
return $data;
|
@@ -638,7 +666,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
638 |
*/
|
639 |
function erase_rules_wpsc($data)
|
640 |
{
|
641 |
-
$data = preg_replace('~# BEGIN WPSuperCache.*# END WPSuperCache~
|
642 |
$data = trim($data);
|
643 |
|
644 |
return $data;
|
@@ -657,12 +685,7 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
657 |
if (($data = @file_get_contents($path)) !== false) {
|
658 |
$data = $this->erase_rules_w3tc($data);
|
659 |
|
660 |
-
|
661 |
-
@fputs($fp, $data);
|
662 |
-
@fclose($fp);
|
663 |
-
|
664 |
-
return true;
|
665 |
-
}
|
666 |
}
|
667 |
} else {
|
668 |
return true;
|
@@ -691,9 +714,9 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
691 |
function check_rules_core()
|
692 |
{
|
693 |
$path = ABSPATH . '.htaccess';
|
694 |
-
$search =
|
695 |
|
696 |
-
return (($data = @file_get_contents($path)) && strstr($data, $search) !== false && $this->check_rules_wp());
|
697 |
}
|
698 |
|
699 |
/**
|
@@ -704,9 +727,9 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
704 |
function check_rules_cache()
|
705 |
{
|
706 |
$path = W3TC_CACHE_FILE_PGCACHE_DIR . '/.htaccess';
|
707 |
-
$search =
|
708 |
|
709 |
-
return (($data = @file_get_contents($path)) && strstr($data, $search) !== false);
|
710 |
}
|
711 |
|
712 |
/**
|
@@ -716,8 +739,12 @@ class W3_Plugin_PgCache extends W3_Plugin
|
|
716 |
*/
|
717 |
function check_rules_wp()
|
718 |
{
|
|
|
|
|
|
|
|
|
719 |
$path = ABSPATH . '/.htaccess';
|
720 |
|
721 |
-
return (($data = @file_get_contents($path)) && preg_match('~# BEGIN WordPress.*# END WordPress~s', $data));
|
722 |
}
|
723 |
}
|
109 |
{
|
110 |
static $instances = array();
|
111 |
|
112 |
+
if (!isset($instances[0])) {
|
113 |
$class = __CLASS__;
|
114 |
$instances[0] = & new $class();
|
115 |
}
|
122 |
*/
|
123 |
function activate()
|
124 |
{
|
125 |
+
if (!$this->update_wp_config()) {
|
126 |
+
$error = sprintf('<strong>%swp-config.php</strong> could not be written, please edit config and add:<br /><strong style="color:#f00;">define(\'WP_CACHE\', true);</strong> before <strong style="color:#f00;">require_once(ABSPATH . \'wp-settings.php\');</strong><br />then re-activate plugin.', ABSPATH);
|
|
|
|
|
|
|
|
|
127 |
|
128 |
+
w3_activate_error($error);
|
129 |
+
}
|
130 |
+
|
131 |
+
if ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'file_pgcache') {
|
132 |
+
/**
|
133 |
+
* Disable enchanged mode if permalink structure is disabled
|
134 |
+
*/
|
135 |
+
$permalink_structure = get_option('permalink_structure');
|
136 |
+
|
137 |
+
if ($permalink_structure == '') {
|
138 |
+
$this->_config->set('pgcache.engine', 'file');
|
139 |
+
$this->_config->save();
|
140 |
+
} else {
|
141 |
+
if (!w3_is_wpmu() && !$this->write_rules_core()) {
|
142 |
+
w3_writable_error(ABSPATH . '.htaccess');
|
143 |
+
}
|
144 |
|
145 |
+
if (!$this->write_rules_cache()) {
|
146 |
+
w3_writable_error(W3TC_CACHE_FILE_PGCACHE_DIR . '/.htaccess');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
}
|
149 |
+
}
|
150 |
+
|
151 |
+
if (!$this->locked()) {
|
152 |
if (@copy(W3TC_INSTALL_DIR . '/advanced-cache.php', WP_CONTENT_DIR . '/advanced-cache.php')) {
|
153 |
@chmod(WP_CONTENT_DIR . '/advanced-cache.php', 0644);
|
154 |
} else {
|
166 |
{
|
167 |
$this->unschedule();
|
168 |
|
169 |
+
if (!$this->locked()) {
|
|
|
|
|
|
|
170 |
@unlink(WP_CONTENT_DIR . '/advanced-cache.php');
|
171 |
}
|
172 |
+
|
173 |
+
$this->remove_rules_cache();
|
174 |
+
|
175 |
+
if (!w3_is_wpmu()) {
|
176 |
+
$this->remove_rules_core();
|
177 |
+
}
|
178 |
}
|
179 |
|
180 |
/**
|
183 |
function schedule()
|
184 |
{
|
185 |
if ($this->_config->get_boolean('pgcache.enabled') && ($this->_config->get_string('pgcache.engine') == 'file' || $this->_config->get_string('pgcache.engine') == 'file_pgcache')) {
|
186 |
+
if (!wp_next_scheduled('w3_pgcache_cleanup')) {
|
187 |
wp_schedule_event(time(), 'w3_pgcache_cleanup', 'w3_pgcache_cleanup');
|
188 |
}
|
189 |
} else {
|
214 |
return true;
|
215 |
}
|
216 |
|
217 |
+
$config_path = ABSPATH . 'wp-config.php';
|
218 |
+
$config_data = @file_get_contents($config_path);
|
|
|
219 |
|
220 |
+
if (!$config_data) {
|
221 |
return false;
|
222 |
}
|
223 |
|
224 |
$config_data = preg_replace('~<\?(php)?~', "\\0\r\n/** Enable W3 Total Cache **/\r\ndefine('WP_CACHE', true); // Added by W3 Total Cache\r\n", $config_data, 1);
|
225 |
|
226 |
+
if (!@file_put_contents($config_path, $config_data)) {
|
227 |
+
return false;
|
228 |
+
}
|
229 |
|
230 |
$updated = true;
|
231 |
|
306 |
{
|
307 |
static $flushed_posts = array();
|
308 |
|
309 |
+
if (!in_array($post_id, $flushed_posts)) {
|
310 |
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
|
311 |
|
312 |
$w3_pgcache = & W3_PgCache::instance();
|
327 |
|
328 |
if ($comment_id) {
|
329 |
$comment = get_comment($comment_id, ARRAY_A);
|
330 |
+
$post_id = !empty($comment['comment_post_ID']) ? (int) $comment['comment_post_ID'] : 0;
|
331 |
}
|
332 |
|
333 |
$this->on_post_change($post_id);
|
353 |
{
|
354 |
static $flushed = false;
|
355 |
|
356 |
+
if (!$flushed) {
|
357 |
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
|
358 |
|
359 |
$w3_pgcache = & W3_PgCache::instance();
|
368 |
*/
|
369 |
function generate_rules_core()
|
370 |
{
|
371 |
+
global $w3_reserved_blognames;
|
372 |
+
|
373 |
/**
|
374 |
* Auto reject cookies
|
375 |
*/
|
400 |
/**
|
401 |
* Reject cache for home page
|
402 |
*/
|
403 |
+
if (!$this->_config->get_boolean('pgcache.cache.home')) {
|
404 |
$reject_uris[] = '^(\/|\/index.php)$';
|
405 |
}
|
406 |
|
407 |
/**
|
408 |
* Reject cache for feeds
|
409 |
*/
|
410 |
+
if (!$this->_config->get_boolean('pgcache.cache.feed')) {
|
411 |
$reject_uris[] = 'feed';
|
412 |
}
|
413 |
|
414 |
/**
|
415 |
* Custom config
|
416 |
*/
|
417 |
+
$reject_cookies = array_merge($reject_cookies, $this->_config->get_array('pgcache.reject.cookie'));
|
418 |
+
$reject_uris = array_merge($reject_uris, $this->_config->get_array('pgcache.reject.uri'));
|
419 |
$reject_user_agents = $this->_config->get_array('pgcache.reject.ua');
|
420 |
$accept_files = $this->_config->get_array('pgcache.accept.files');
|
421 |
|
422 |
+
/**
|
423 |
+
* WPMU support
|
424 |
+
*/
|
425 |
+
$is_wpmu = w3_is_wpmu();
|
426 |
+
$is_vhost = w3_is_vhost();
|
427 |
+
|
428 |
/**
|
429 |
* Generate directives
|
430 |
*/
|
431 |
$rules = '';
|
432 |
$rules .= "# BEGIN W3 Total Cache\n";
|
433 |
|
434 |
+
$setenvif_rules = '';
|
435 |
+
|
436 |
+
if ($is_wpmu) {
|
437 |
+
$setenvif_rules .= " SetEnvIfNoCase Host ^(www\\.)?([a-z0-9\\-\\.]+\\.[a-z]+)\\.?(:[0-9]+)?$ DOMAIN=$2\n";
|
438 |
+
|
439 |
+
if (!$is_vhost) {
|
440 |
+
$setenvif_rules .= " SetEnvIfNoCase Request_URI ^" . w3_get_site_path() . "([a-z0-9\\-]+)/ BLOGNAME=$1\n";
|
441 |
+
}
|
442 |
+
}
|
443 |
|
444 |
$compression = $this->_config->get_string('pgcache.compression');
|
445 |
|
455 |
}
|
456 |
|
457 |
if (count($compressions)) {
|
458 |
+
$setenvif_rules .= " SetEnvIfNoCase Accept-Encoding (" . implode('|', $compressions) . ") APPEND_EXT=.$1\n";
|
459 |
}
|
460 |
}
|
461 |
|
462 |
+
if ($setenvif_rules != '') {
|
463 |
+
$rules .= "<IfModule mod_setenvif.c>\n" . $setenvif_rules .= "</IfModule>\n";
|
464 |
+
}
|
465 |
+
|
466 |
+
$rules .= "<IfModule mod_rewrite.c>\n";
|
467 |
+
|
468 |
$rules .= " RewriteEngine On\n";
|
469 |
|
470 |
$mobile_redirect = $this->_config->get_string('pgcache.mobile.redirect');
|
472 |
if ($mobile_redirect != '') {
|
473 |
$mobile_agents = $this->_config->get_array('pgcache.mobile.agents');
|
474 |
|
475 |
+
$rules .= " RewriteCond %{HTTP_USER_AGENT} (" . implode('|', array_map('w3_preg_quote', $mobile_agents)) . ") [NC]\n";
|
476 |
$rules .= " RewriteRule .* " . $mobile_redirect . " [R,L]\n";
|
477 |
}
|
478 |
|
479 |
+
$rules .= " RewriteCond %{REQUEST_URI} \\/$\n";
|
480 |
+
$rules .= " RewriteCond %{REQUEST_URI} !(" . implode('|', $reject_uris) . ")";
|
481 |
|
482 |
if (count($accept_files)) {
|
483 |
+
$rules .= " [OR]\n RewriteCond %{REQUEST_URI} (" . implode('|', array_map('w3_preg_quote', $accept_files)) . ") [NC]\n";
|
484 |
} else {
|
485 |
$rules .= "\n";
|
486 |
}
|
487 |
|
488 |
$rules .= " RewriteCond %{REQUEST_METHOD} !=POST\n";
|
489 |
$rules .= " RewriteCond %{QUERY_STRING} =\"\"\n";
|
490 |
+
$rules .= " RewriteCond %{HTTP_COOKIE} !(" . implode('|', array_map('w3_preg_quote', $reject_cookies)) . ") [NC]\n";
|
491 |
|
492 |
if (count($reject_user_agents)) {
|
493 |
+
$rules .= " RewriteCond %{HTTP_USER_AGENT} !(" . implode('|', array_map('w3_preg_quote', $reject_user_agents)) . ") [NC]\n";
|
494 |
+
}
|
495 |
+
|
496 |
+
if ($is_wpmu) {
|
497 |
+
if ($is_vhost) {
|
498 |
+
$replacement = '/w3tc-%{ENV:DOMAIN}/';
|
499 |
+
} else {
|
500 |
+
$rules .= " RewriteCond %{ENV:BLOGNAME} !^(" . implode('|', $w3_reserved_blognames) . ")$\n";
|
501 |
+
$rules .= " RewriteCond %{ENV:BLOGNAME} !-f\n";
|
502 |
+
$rules .= " RewriteCond %{ENV:BLOGNAME} !-d\n";
|
503 |
+
|
504 |
+
$replacement = '/w3tc-%{ENV:BLOGNAME}.%{ENV:DOMAIN}/';
|
505 |
+
}
|
506 |
+
|
507 |
+
$cache_dir = preg_replace('~/w3tc.*/~U', $replacement, W3TC_CACHE_FILE_PGCACHE_DIR, 1);
|
508 |
+
} else {
|
509 |
+
$cache_dir = W3TC_CACHE_FILE_PGCACHE_DIR;
|
510 |
}
|
511 |
|
512 |
+
$rules .= " RewriteCond " . w3_path($cache_dir) . "/$1/_default_.html%{ENV:APPEND_EXT} -f\n";
|
513 |
+
$rules .= " RewriteRule (.*) " . str_replace(ABSPATH, '', $cache_dir) . "/$1/_default_.html%{ENV:APPEND_EXT} [L]\n";
|
514 |
$rules .= "</IfModule>\n";
|
515 |
|
516 |
$rules .= "# END W3 Total Cache\n\n";
|
517 |
|
518 |
+
if (!$this->check_rules_wp()) {
|
519 |
$rules .= "# BEGIN WordPress\n";
|
520 |
$rules .= "<IfModule mod_rewrite.c>\n";
|
521 |
$rules .= " RewriteEngine On\n";
|
587 |
}
|
588 |
|
589 |
$rules .= " Header set Pragma public\n";
|
590 |
+
$rules .= " Header append Cache-Control \"public, must-revalidate, proxy-revalidate\"\n";
|
591 |
$rules .= "</IfModule>\n";
|
592 |
|
593 |
$rules .= "# END W3 Total Cache\n\n";
|
617 |
|
618 |
$data = trim($this->generate_rules_core() . $data);
|
619 |
|
620 |
+
return @file_put_contents($path, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
}
|
622 |
|
623 |
/**
|
641 |
|
642 |
$data = trim($this->generate_rules_cache() . $data);
|
643 |
|
644 |
+
return @file_put_contents($path, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
645 |
}
|
646 |
|
647 |
/**
|
652 |
*/
|
653 |
function erase_rules_w3tc($data)
|
654 |
{
|
655 |
+
$data = preg_replace('~# BEGIN W3 Total Cache.*# END W3 Total Cache~Us', '', $data);
|
656 |
$data = trim($data);
|
657 |
|
658 |
return $data;
|
666 |
*/
|
667 |
function erase_rules_wpsc($data)
|
668 |
{
|
669 |
+
$data = preg_replace('~# BEGIN WPSuperCache.*# END WPSuperCache~Us', '', $data);
|
670 |
$data = trim($data);
|
671 |
|
672 |
return $data;
|
685 |
if (($data = @file_get_contents($path)) !== false) {
|
686 |
$data = $this->erase_rules_w3tc($data);
|
687 |
|
688 |
+
return @file_put_contents($path, $data);
|
|
|
|
|
|
|
|
|
|
|
689 |
}
|
690 |
} else {
|
691 |
return true;
|
714 |
function check_rules_core()
|
715 |
{
|
716 |
$path = ABSPATH . '.htaccess';
|
717 |
+
$search = $this->generate_rules_core();
|
718 |
|
719 |
+
return (($data = @file_get_contents($path)) && strstr(w3_clean_rules($data), w3_clean_rules($search)) !== false && $this->check_rules_wp());
|
720 |
}
|
721 |
|
722 |
/**
|
727 |
function check_rules_cache()
|
728 |
{
|
729 |
$path = W3TC_CACHE_FILE_PGCACHE_DIR . '/.htaccess';
|
730 |
+
$search = $this->generate_rules_cache();
|
731 |
|
732 |
+
return (($data = @file_get_contents($path)) && strstr(w3_clean_rules($data), w3_clean_rules($search)) !== false);
|
733 |
}
|
734 |
|
735 |
/**
|
739 |
*/
|
740 |
function check_rules_wp()
|
741 |
{
|
742 |
+
if (function_exists('is_site_admin')) {
|
743 |
+
return true;
|
744 |
+
}
|
745 |
+
|
746 |
$path = ABSPATH . '/.htaccess';
|
747 |
|
748 |
+
return (($data = @file_get_contents($path)) && preg_match('~# BEGIN WordPress.*# END WordPress~s', w3_clean_rules($data)));
|
749 |
}
|
750 |
}
|
lib/W3/Plugin/TotalCache.php
CHANGED
@@ -70,11 +70,6 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
70 |
'favorite_actions'
|
71 |
));
|
72 |
|
73 |
-
add_action('admin_notices', array(
|
74 |
-
&$this,
|
75 |
-
'admin_notices'
|
76 |
-
));
|
77 |
-
|
78 |
add_action('init', array(
|
79 |
&$this,
|
80 |
'init'
|
@@ -85,7 +80,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
85 |
'in_plugin_update_message'
|
86 |
));
|
87 |
|
88 |
-
if ($this->_config->get_boolean('
|
89 |
add_action('wp_dashboard_setup', array(
|
90 |
&$this,
|
91 |
'wp_dashboard_setup'
|
@@ -165,7 +160,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
165 |
{
|
166 |
static $instances = array();
|
167 |
|
168 |
-
if (!
|
169 |
$class = __CLASS__;
|
170 |
$instances[0] = & new $class();
|
171 |
}
|
@@ -173,66 +168,77 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
173 |
return $instances[0];
|
174 |
}
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
/**
|
177 |
* Activate plugin action
|
178 |
*/
|
179 |
function activate()
|
180 |
{
|
181 |
-
if (!
|
182 |
-
if (
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
w3_writable_error(W3TC_CONTENT_DIR);
|
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 |
-
if (
|
232 |
$this->_config->set('common.install', time());
|
233 |
}
|
234 |
|
235 |
-
if (
|
|
|
|
|
|
|
|
|
236 |
w3_writable_error(W3TC_CONFIG_PATH);
|
237 |
}
|
238 |
|
@@ -244,6 +250,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
244 |
|
245 |
/**
|
246 |
* Deactivate plugin action
|
|
|
247 |
*/
|
248 |
function deactivate()
|
249 |
{
|
@@ -251,13 +258,12 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
251 |
|
252 |
delete_option('w3tc_request_data');
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
}
|
261 |
}
|
262 |
|
263 |
/**
|
@@ -298,7 +304,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
298 |
*/
|
299 |
if (isset($_REQUEST['flush_all'])) {
|
300 |
$this->flush_memcached();
|
301 |
-
$this->
|
302 |
$this->flush_file();
|
303 |
|
304 |
$this->redirect(array(
|
@@ -320,11 +326,11 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
320 |
/**
|
321 |
* Flush APC cache
|
322 |
*/
|
323 |
-
if (isset($_REQUEST['
|
324 |
-
$this->
|
325 |
|
326 |
$this->redirect(array(
|
327 |
-
'note' => '
|
328 |
), true);
|
329 |
}
|
330 |
|
@@ -346,8 +352,9 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
346 |
$this->flush_pgcache();
|
347 |
|
348 |
$this->_config->set('notes.need_empty_pgcache', false);
|
|
|
349 |
|
350 |
-
if (
|
351 |
$this->redirect(array(
|
352 |
'error' => 'config_save'
|
353 |
), true);
|
@@ -377,7 +384,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
377 |
|
378 |
$this->_config->set('notes.need_empty_minify', false);
|
379 |
|
380 |
-
if (
|
381 |
$this->redirect(array(
|
382 |
'error' => 'config_save'
|
383 |
), true);
|
@@ -396,7 +403,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
396 |
|
397 |
$this->_config->set($setting, false);
|
398 |
|
399 |
-
if (
|
400 |
$this->redirect(array(
|
401 |
'error' => 'config_save'
|
402 |
), true);
|
@@ -479,7 +486,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
479 |
|
480 |
$this->_config->set('common.support', $support);
|
481 |
|
482 |
-
if (
|
483 |
$this->redirect(array(
|
484 |
'error' => 'config_save'
|
485 |
));
|
@@ -495,7 +502,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
495 |
/**
|
496 |
* Run plugin action
|
497 |
*/
|
498 |
-
if (isset($_REQUEST['w3tc_action'])
|
499 |
$action = trim($_REQUEST['w3tc_action']);
|
500 |
|
501 |
if (method_exists($this, $action)) {
|
@@ -516,12 +523,10 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
516 |
exit();
|
517 |
}
|
518 |
|
519 |
-
$this->_support_reminder = ($this->_config->get_boolean('notes.support_us') && $this->_config->get_integer('common.install') < (time() - W3TC_SUPPORT_US_TIMEOUT) &&
|
520 |
|
521 |
wp_enqueue_style('w3tc-options', WP_PLUGIN_URL . '/w3-total-cache/inc/css/options.css');
|
522 |
wp_enqueue_style('w3tc-lightbox', WP_PLUGIN_URL . '/w3-total-cache/inc/css/lightbox.css');
|
523 |
-
wp_enqueue_script('w3tc-options', WP_PLUGIN_URL . '/w3-total-cache/inc/js/options.js');
|
524 |
-
wp_enqueue_script('w3tc-lightbox', WP_PLUGIN_URL . '/w3-total-cache/inc/js/lightbox.js');
|
525 |
}
|
526 |
|
527 |
/**
|
@@ -529,37 +534,65 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
529 |
*/
|
530 |
function wp_dashboard_setup()
|
531 |
{
|
532 |
-
wp_add_dashboard_widget('
|
533 |
&$this,
|
534 |
'widget_latest'
|
|
|
|
|
|
|
535 |
));
|
536 |
}
|
537 |
|
538 |
/**
|
539 |
-
* Prints
|
540 |
*/
|
541 |
function widget_latest()
|
542 |
{
|
543 |
global $wp_version;
|
544 |
|
|
|
|
|
|
|
545 |
if ($wp_version >= 2.8) {
|
546 |
include_once (ABSPATH . WPINC . '/feed.php');
|
547 |
$feed = fetch_feed(W3TC_FEED_URL);
|
548 |
-
$items = $feed->get_items(0, W3TC_FEED_ITEMS);
|
549 |
|
550 |
-
|
551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
}
|
553 |
} else {
|
554 |
include_once (ABSPATH . WPINC . '/rss.php');
|
555 |
$rss = fetch_rss(W3TC_FEED_URL);
|
556 |
-
$items = array_slice($rss->items, 0, W3TC_FEED_ITEMS);
|
557 |
|
558 |
-
|
559 |
-
|
560 |
}
|
561 |
}
|
|
|
|
|
|
|
562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
564 |
|
565 |
/**
|
@@ -572,10 +605,23 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
572 |
'options'
|
573 |
));
|
574 |
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
579 |
}
|
580 |
|
581 |
/**
|
@@ -662,7 +708,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
662 |
'config_save' => 'Plugin configuration successfully updated.',
|
663 |
'flush_all' => 'All caches successfully emptied.',
|
664 |
'flush_memcached' => 'Memcached cache(s) successfully emptied.',
|
665 |
-
'
|
666 |
'flush_file' => 'Disk cache successfully emptied.',
|
667 |
'flush_pgcache' => 'Page cache successfully emptied.',
|
668 |
'flush_dbcache' => 'Database cache successfully emptied.',
|
@@ -695,7 +741,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
695 |
/**
|
696 |
* Check config file
|
697 |
*/
|
698 |
-
if (!
|
699 |
$errors[] = sprintf('<strong>W3 Total Cache Error:</strong> Default settings are in use. The configuration file could not be read or doesn\'t exist. Please %s to create the file.', $this->button_link('save your settings', sprintf('options-general.php?page=%s&tab=%s&save_config', W3TC_FILE, $this->_tab)));
|
700 |
}
|
701 |
|
@@ -754,7 +800,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
754 |
}
|
755 |
|
756 |
if ($this->_config->get_boolean('minify.enabled')) {
|
757 |
-
$texts[] = sprintf('check your %s to maintain the desired user experience', $this->
|
758 |
}
|
759 |
|
760 |
if (count($texts)) {
|
@@ -842,7 +888,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
842 |
|
843 |
foreach ($changelog as $index => $line) {
|
844 |
if (preg_match('~^\s*\*\s*~', $line)) {
|
845 |
-
if (
|
846 |
echo '<ul style="list-style: disc; margin-left: 20px;">';
|
847 |
$ul = true;
|
848 |
}
|
@@ -883,9 +929,9 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
883 |
* Check for page cache availability
|
884 |
*/
|
885 |
if ($this->_config->get_boolean('pgcache.enabled')) {
|
886 |
-
if (
|
887 |
$this->_errors[] = sprintf('Page caching is not available: advanced-cache.php is not installed. Either the <strong>%s</strong> directory is not write-able or you have another caching plugin installed. This error message will automatically disappear once the change is successfully made.', WP_CONTENT_DIR);
|
888 |
-
} elseif (!
|
889 |
$this->_errors[] = sprintf('Page caching is not available: please add: <strong>define(\'WP_CACHE\', true);</strong> to <strong>%swp-config.php</strong>. This error message will automatically disappear once the change is successfully made.', ABSPATH);
|
890 |
} else {
|
891 |
switch ($this->_config->get_string('pgcache.engine')) {
|
@@ -893,27 +939,23 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
893 |
require_once W3TC_LIB_W3_DIR . '/Plugin/PgCache.php';
|
894 |
$w3_plugin_pgcache = & W3_Plugin_PgCache::instance();
|
895 |
|
896 |
-
if ($this->_config->get_boolean('notes.pgcache_rules_core') &&
|
897 |
-
if (
|
898 |
$this->_errors[] = sprintf('Enhanced mode page cache is not operational. Your .htaccess rules could not be modified. Please verify <strong>%s.htaccess</strong> has the following rules: <pre>%s</pre> %s', ABSPATH, htmlspecialchars($w3_plugin_pgcache->generate_rules_core()), $this->button_hide_note('Hide this message', 'pgcache_rules_core'));
|
899 |
} else {
|
900 |
$this->_errors[] = sprintf('You\'ve selected disk caching with enhanced mode however the .htaccess file is not properly configured. Please run <strong>chmod 777 %s.htaccess</strong>, then %s. To manually modify your server configuration for enhanced mode append the following code: <pre>%s</pre> and %s.', ABSPATH, $this->button_link('try again', sprintf('options-general.php?page=%s&tab=%s&pgcache_write_rules_core', W3TC_FILE, $this->_tab)), htmlspecialchars($w3_plugin_pgcache->generate_rules_core()), $this->button_hide_note('hide this message', 'pgcache_rules_core'));
|
901 |
}
|
902 |
}
|
903 |
|
904 |
-
if ($this->_config->get_boolean('notes.pgcache_rules_cache') &&
|
905 |
-
|
906 |
-
$this->_errors[] = sprintf('Enhanced mode page cache is not operational. Your .htaccess rules could not be modified. Please verify <strong>%s/.htaccess</strong> has the following rules: <pre>%s</pre> %s', W3TC_CACHE_FILE_PGCACHE_DIR, htmlspecialchars($w3_plugin_pgcache->generate_rules_cache()), $this->button_hide_note('Hide this message', 'pgcache_rules_cache'));
|
907 |
-
} else {
|
908 |
-
$this->_errors[] = sprintf('You\'ve selected disk caching with enhanced mode however the .htaccess file is not properly configured. Please run <strong>chmod 777 %s/.htaccess</strong>, then %s. To manually modify your server configuration for enhanced mode append the following code: <pre>%s</pre> and %s.', W3TC_CACHE_FILE_PGCACHE_DIR, $this->button_link('try again', sprintf('options-general.php?page=%s&tab=%s&pgcache_write_rules_cache', W3TC_FILE, $this->_tab)), htmlspecialchars($w3_plugin_pgcache->generate_rules_cache()), $this->button_hide_note('hide this message', 'pgcache_rules_cache'));
|
909 |
-
}
|
910 |
}
|
911 |
break;
|
912 |
|
913 |
case 'memcached':
|
914 |
$pgcache_memcached_servers = $this->_config->get_array('pgcache.memcached.servers');
|
915 |
|
916 |
-
if (
|
917 |
$this->_errors[] = sprintf('Page caching is not working properly. Memcached server(s): <strong>%s</strong> may not running or not responding. This error message will automatically disappear once the issue is resolved.', implode(', ', $pgcache_memcached_servers));
|
918 |
}
|
919 |
break;
|
@@ -931,12 +973,8 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
931 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
932 |
$w3_plugin_minify = & W3_Plugin_Minify::instance();
|
933 |
|
934 |
-
if ($this->_config->get_boolean('notes.minify_rules') &&
|
935 |
-
|
936 |
-
$this->_errors[] = sprintf('Minify is not operational. Your .htaccess rules could not be modified. Please verify <strong>%s/.htaccess</strong> has the following rules: <pre>%s</pre> %s', W3TC_CACHE_FILE_MINIFY_DIR, htmlspecialchars($w3_plugin_minify->generate_rules()), $this->button_hide_note('Hide this message', 'minify_rules'));
|
937 |
-
} else {
|
938 |
-
$this->_errors[] = sprintf('The "Rewrite URL Structure" feature, requires rewrite rules be present. Please run <strong>chmod 777 %s/.htaccess</strong>, then %s. To manually modify your server configuration for minify append the following code: <pre>%s</pre> and %s.', W3TC_CACHE_FILE_MINIFY_DIR, $this->button_link('try again', sprintf('options-general.php?page=%s&tab=%s&minify_write_rules', W3TC_FILE, $this->_tab)), htmlspecialchars($w3_plugin_minify->generate_rules()), $this->button_hide_note('hide this message', 'minify_rules'));
|
939 |
-
}
|
940 |
}
|
941 |
}
|
942 |
break;
|
@@ -944,8 +982,8 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
944 |
case 'memcached':
|
945 |
$minify_memcached_servers = $this->_config->get_array('minify.memcached.servers');
|
946 |
|
947 |
-
if (
|
948 |
-
$this->_errors[] = sprintf('Minify is not working properly. Memcached server(s): <strong>%s</strong>may not running or not responding. This error message will automatically disappear once the issue is resolved.', implode(', ', $minify_memcached_servers));
|
949 |
}
|
950 |
break;
|
951 |
}
|
@@ -955,12 +993,12 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
955 |
* Check for database cache availability
|
956 |
*/
|
957 |
if ($this->_config->get_boolean('dbcache.enabled')) {
|
958 |
-
if (
|
959 |
$this->_errors[] = sprintf('Database caching is not available: db.php is not installed. Either the <strong>%s</strong> directory is not write-able or you have another caching plugin installed. This error message will automatically disappear once the change is successfully made.', WP_CONTENT_DIR);
|
960 |
} elseif ($this->_config->get_string('pgcache.engine') == 'memcached') {
|
961 |
$dbcache_memcached_servers = $this->_config->get_array('dbcache.memcached.servers');
|
962 |
|
963 |
-
if (
|
964 |
$this->_errors[] = sprintf('Database caching is not working properly. Memcached server(s): <strong>%s</strong> may not running or not responding. This error message will automatically disappear once the issue is successfully resolved.', implode(', ', $dbcache_memcached_servers));
|
965 |
}
|
966 |
}
|
@@ -969,21 +1007,21 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
969 |
/**
|
970 |
* Check PHP version
|
971 |
*/
|
972 |
-
if (!
|
973 |
$this->_notes[] = sprintf('Unfortunately, <strong>PHP5</strong> is required for full functionality of this plugin; incompatible features are automatically disabled. Please upgrade if possible. %s', $this->button_hide_note('Hide this message', 'php_is_old'));
|
974 |
}
|
975 |
|
976 |
/**
|
977 |
* Check CURL extension
|
978 |
*/
|
979 |
-
if ($this->_config->get_boolean('notes.no_curl') && $this->_config->get_boolean('cdn.enabled') && !
|
980 |
$this->_notes[] = sprintf('The <strong>CURL PHP</strong> extension is not available. Please install it to enable S3 or CloudFront functionality. %s', $this->button_hide_note('Hide this message', 'no_curl'));
|
981 |
}
|
982 |
|
983 |
/**
|
984 |
* Check Zlib extension
|
985 |
*/
|
986 |
-
if ($this->_config->get_boolean('notes.no_zlib') && (!
|
987 |
$this->_notes[] = sprintf('Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Please notify your server administrator and ask for it to be installed. %s', $this->button_hide_note('Hide this message', 'no_zlib'));
|
988 |
}
|
989 |
|
@@ -1004,7 +1042,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1004 |
/**
|
1005 |
* Check wp-content permissions
|
1006 |
*/
|
1007 |
-
if (!
|
1008 |
$wp_content_stat = stat(WP_CONTENT_DIR);
|
1009 |
$wp_content_mode = ($wp_content_stat['mode'] & 0777);
|
1010 |
|
@@ -1093,17 +1131,22 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1093 |
$enabled = ($pgcache_enabled || $dbcache_enabled || $minify_enabled || $cdn_enabled);
|
1094 |
|
1095 |
$check_apc = function_exists('apc_store');
|
|
|
|
|
1096 |
$check_curl = function_exists('curl_init');
|
|
|
1097 |
|
1098 |
$pgcache_engine = $this->_config->get_string('pgcache.engine');
|
1099 |
$dbcache_engine = $this->_config->get_string('dbcache.engine');
|
1100 |
$minify_engine = $this->_config->get_string('minify.engine');
|
1101 |
|
1102 |
$can_empty_memcache = ($pgcache_engine == 'memcached' || $dbcache_engine == 'memcached' || $minify_engine == 'memcached');
|
1103 |
-
$can_empty_apc = $check_apc && ($pgcache_engine == 'apc' || $dbcache_engine == 'apc' || $minify_engine == 'apc');
|
1104 |
-
$can_empty_file = ($pgcache_engine == 'file' || $pgcache_engine == 'file_pgcache' || $dbcache_engine == 'file' || $minify_engine == 'file');
|
1105 |
|
1106 |
-
$
|
|
|
|
|
|
|
|
|
1107 |
|
1108 |
$debug = ($this->_config->get_boolean('dbcache.debug') || $this->_config->get_boolean('pgcache.debug') || $this->_config->get_boolean('minify.debug') || $this->_config->get_boolean('cdn.debug'));
|
1109 |
|
@@ -1131,10 +1174,15 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1131 |
function options_minify()
|
1132 |
{
|
1133 |
$minify_enabled = $this->_config->get_boolean('minify.enabled');
|
|
|
|
|
1134 |
|
1135 |
$groups = $this->minify_get_groups();
|
1136 |
|
|
|
1137 |
$js_groups = $this->_config->get_array('minify.js.groups');
|
|
|
|
|
1138 |
$css_groups = $this->_config->get_array('minify.css.groups');
|
1139 |
|
1140 |
include W3TC_DIR . '/inc/options/minify.phtml';
|
@@ -1161,10 +1209,6 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1161 |
|
1162 |
$minify_enabled = $this->_config->get_boolean('minify.enabled');
|
1163 |
|
1164 |
-
if ($this->_config->get_boolean('notes.cdn_first_time')) {
|
1165 |
-
$this->_notes[] = sprintf('It appears this is the first time you are using CDN feature. Unless you wish to first import attachments in your posts that are not already in the media library, please start a <strong>"manual export to <acronym title="Content Delivery Network">CDN</acronym>"</strong> and only enable this module after pending attachments have been successfully uploaded. %s', $this->button_hide_note('Hide this message', 'cdn_first_time'));
|
1166 |
-
}
|
1167 |
-
|
1168 |
include W3TC_DIR . '/inc/options/cdn.phtml';
|
1169 |
}
|
1170 |
|
@@ -1231,6 +1275,11 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1231 |
{
|
1232 |
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
1233 |
|
|
|
|
|
|
|
|
|
|
|
1234 |
/**
|
1235 |
* Read config
|
1236 |
*/
|
@@ -1241,12 +1290,12 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1241 |
* General tab
|
1242 |
*/
|
1243 |
if ($this->_tab == 'general') {
|
1244 |
-
$debug = W3_Request::
|
1245 |
|
1246 |
-
$config->set('dbcache.debug', $debug);
|
1247 |
-
$config->set('pgcache.debug', $debug);
|
1248 |
-
$config->set('minify.debug', $debug);
|
1249 |
-
$config->set('cdn.debug', $debug);
|
1250 |
|
1251 |
/**
|
1252 |
* Page cache tab
|
@@ -1268,17 +1317,20 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1268 |
/**
|
1269 |
* Minify tab
|
1270 |
*/
|
1271 |
-
|
1272 |
if ($this->_tab == 'minify') {
|
1273 |
$groups = $this->minify_get_groups();
|
|
|
|
|
1274 |
$js_files = W3_Request::get_array('js_files');
|
|
|
|
|
1275 |
$css_files = W3_Request::get_array('css_files');
|
1276 |
|
1277 |
$js_groups = array();
|
1278 |
$css_groups = array();
|
1279 |
|
1280 |
foreach ($js_files as $group => $locations) {
|
1281 |
-
if (!
|
1282 |
continue;
|
1283 |
}
|
1284 |
|
@@ -1298,22 +1350,22 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1298 |
break;
|
1299 |
}
|
1300 |
foreach ((array) $files as $file) {
|
1301 |
-
if (!
|
1302 |
-
$js_groups[$group][$location]['files'][] =
|
1303 |
}
|
1304 |
}
|
1305 |
}
|
1306 |
}
|
1307 |
|
1308 |
foreach ($css_files as $group => $locations) {
|
1309 |
-
if (!
|
1310 |
continue;
|
1311 |
}
|
1312 |
|
1313 |
foreach ((array) $locations as $location => $files) {
|
1314 |
foreach ((array) $files as $file) {
|
1315 |
-
if (!
|
1316 |
-
$css_groups[$group][$location]['files'][] =
|
1317 |
}
|
1318 |
}
|
1319 |
}
|
@@ -1321,47 +1373,67 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1321 |
|
1322 |
$config->set('minify.js.groups', $js_groups);
|
1323 |
$config->set('minify.css.groups', $css_groups);
|
|
|
|
|
|
|
|
|
|
|
1324 |
}
|
1325 |
|
1326 |
/**
|
1327 |
* Handle settings change that require pgcache and minify empty
|
1328 |
*/
|
1329 |
$pgcache_dependencies = array(
|
1330 |
-
'dbcache.debug',
|
1331 |
'pgcache.debug',
|
1332 |
-
'
|
1333 |
'minify.enabled',
|
1334 |
-
'
|
1335 |
-
'minify.rewrite',
|
1336 |
-
'minify.options',
|
1337 |
-
'minify.html.enable',
|
1338 |
-
'minify.html.reject.admin',
|
1339 |
-
'minify.html.inline.css',
|
1340 |
-
'minify.html.inline.js',
|
1341 |
-
'minify.html.strip.crlf',
|
1342 |
-
'minify.css.enable',
|
1343 |
-
'minify.css.groups',
|
1344 |
-
'minify.js.enable',
|
1345 |
-
'minify.js.groups',
|
1346 |
-
'cdn.enabled',
|
1347 |
-
'cdn.debug',
|
1348 |
-
'cdn.engine',
|
1349 |
-
'cdn.includes.enable',
|
1350 |
-
'cdn.includes.files',
|
1351 |
-
'cdn.theme.enable',
|
1352 |
-
'cdn.theme.files',
|
1353 |
-
'cdn.minify.enable',
|
1354 |
-
'cdn.custom.enable',
|
1355 |
-
'cdn.custom.files',
|
1356 |
-
'cdn.ftp.domain',
|
1357 |
-
'cdn.s3.bucket',
|
1358 |
-
'cdn.cf.id',
|
1359 |
-
'cdn.cf.cname',
|
1360 |
-
'common.support'
|
1361 |
);
|
1362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1363 |
$minify_dependencies = array(
|
1364 |
'minify.debug',
|
|
|
1365 |
'minify.css.strip.comments',
|
1366 |
'minify.css.strip.crlf',
|
1367 |
'minify.css.groups',
|
@@ -1469,42 +1541,45 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1469 |
}
|
1470 |
|
1471 |
/**
|
1472 |
-
*
|
1473 |
*/
|
1474 |
-
if (
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
if ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'file_pgcache') {
|
1480 |
$w3_plugin_pgcache->write_rules_core();
|
1481 |
-
|
1482 |
-
|
|
|
|
|
|
|
1483 |
$w3_plugin_pgcache->remove_rules_core();
|
1484 |
-
$w3_plugin_pgcache->remove_rules_cache();
|
1485 |
}
|
|
|
|
|
1486 |
}
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
}
|
1499 |
}
|
1500 |
|
1501 |
-
$this->redirect(array(
|
1502 |
'note' => 'config_save'
|
1503 |
-
));
|
1504 |
} else {
|
1505 |
-
$this->redirect(array(
|
1506 |
'error' => 'config_save'
|
1507 |
-
));
|
1508 |
}
|
1509 |
}
|
1510 |
|
@@ -1521,7 +1596,6 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1521 |
$request_type = W3_Request::get_string('request_type');
|
1522 |
$description = W3_Request::get_string('description');
|
1523 |
$templates = W3_Request::get_array('templates');
|
1524 |
-
$attachments = array();
|
1525 |
$wp_login = W3_Request::get_string('wp_login');
|
1526 |
$wp_password = W3_Request::get_string('wp_password');
|
1527 |
$ftp_host = W3_Request::get_string('ftp_host');
|
@@ -1558,7 +1632,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1558 |
)));
|
1559 |
}
|
1560 |
|
1561 |
-
if (!
|
1562 |
$this->redirect(array_merge($params, array(
|
1563 |
'error' => 'support_request_email'
|
1564 |
)));
|
@@ -1613,36 +1687,34 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1613 |
/**
|
1614 |
* Add attachments
|
1615 |
*/
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
}
|
1620 |
-
}
|
1621 |
-
|
1622 |
-
if (! empty($_FILES['files'])) {
|
1623 |
-
$files = (array) $_FILES['files'];
|
1624 |
-
for ($i = 0, $l = count($files); $i < $l; $i++) {
|
1625 |
-
if (isset($files['tmp_name'][$i]) && isset($files['name'][$i]) && isset($files['error'][$i]) && $files['error'][$i] == UPLOAD_ERR_OK) {
|
1626 |
-
$path = W3TC_TMP_DIR . '/' . $files['name'][$i];
|
1627 |
-
if (@move_uploaded_file($files['tmp_name'][$i], $path)) {
|
1628 |
-
$attachments[] = $path;
|
1629 |
-
}
|
1630 |
-
}
|
1631 |
-
}
|
1632 |
-
}
|
1633 |
|
1634 |
/**
|
1635 |
* Attach server info
|
1636 |
*/
|
1637 |
$server_info = print_r($this->get_server_info(), true);
|
1638 |
$server_info = str_replace("\n", "\r\n", $server_info);
|
1639 |
-
$path = W3TC_TMP_DIR . '/server_info.txt';
|
1640 |
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1646 |
}
|
1647 |
|
1648 |
/**
|
@@ -1652,14 +1724,38 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1652 |
$attachments[] = W3TC_MINIFY_LOG_FILE;
|
1653 |
}
|
1654 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1655 |
$data = array();
|
1656 |
|
1657 |
-
if (!
|
1658 |
$data['WP Admin login'] = $wp_login;
|
1659 |
$data['WP Admin password'] = $wp_password;
|
1660 |
}
|
1661 |
|
1662 |
-
if (!
|
1663 |
$data['SSH / FTP host'] = $ftp_host;
|
1664 |
$data['SSH / FTP login'] = $ftp_login;
|
1665 |
$data['SSH / FTP password'] = $ftp_password;
|
@@ -1706,6 +1802,8 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1706 |
'phpmailer_init'
|
1707 |
));
|
1708 |
|
|
|
|
|
1709 |
$result = @wp_mail(W3TC_EMAIL, $subject, $body, implode("\n", $headers), $attachments);
|
1710 |
|
1711 |
/**
|
@@ -1770,12 +1868,17 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1770 |
*
|
1771 |
* @param string $text
|
1772 |
* @param string $note
|
|
|
1773 |
* @return string
|
1774 |
*/
|
1775 |
-
function button_hide_note($text, $note)
|
1776 |
{
|
1777 |
$url = sprintf('options-general.php?page=%s&tab=%s&hide_note=%s', W3TC_FILE, $this->_tab, $note);
|
1778 |
|
|
|
|
|
|
|
|
|
1779 |
return $this->button_link($text, $url);
|
1780 |
}
|
1781 |
|
@@ -1822,7 +1925,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1822 |
switch ($cdn_queue_action) {
|
1823 |
case 'delete':
|
1824 |
$cdn_queue_id = W3_Request::get_integer('cdn_queue_id');
|
1825 |
-
if (!
|
1826 |
$w3_plugin_cdn->queue_delete($cdn_queue_id);
|
1827 |
$notes[] = 'File successfully deleted from the queue.';
|
1828 |
}
|
@@ -1830,7 +1933,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1830 |
|
1831 |
case 'empty':
|
1832 |
$cdn_queue_type = W3_Request::get_integer('cdn_queue_type');
|
1833 |
-
if (!
|
1834 |
$w3_plugin_cdn->queue_empty($cdn_queue_type);
|
1835 |
$notes[] = 'Queue successfully emptied.';
|
1836 |
}
|
@@ -1838,7 +1941,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1838 |
}
|
1839 |
|
1840 |
$queue = $w3_plugin_cdn->queue_get();
|
1841 |
-
$title = 'Unsuccessful
|
1842 |
|
1843 |
include W3TC_DIR . '/inc/popup/cdn_queue.phtml';
|
1844 |
}
|
@@ -1853,7 +1956,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1853 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
1854 |
|
1855 |
$total = $w3_plugin_cdn->get_attachments_count();
|
1856 |
-
$title = 'Media
|
1857 |
|
1858 |
include W3TC_DIR . '/inc/popup/cdn_export_library.phtml';
|
1859 |
}
|
@@ -1906,7 +2009,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1906 |
$total = $w3_plugin_cdn->get_import_posts_count();
|
1907 |
$cdn_host = $cdn->get_domain();
|
1908 |
|
1909 |
-
$title = 'Media
|
1910 |
|
1911 |
include W3TC_DIR . '/inc/popup/cdn_import_library.phtml';
|
1912 |
}
|
@@ -1957,7 +2060,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
1957 |
|
1958 |
$total = $w3_plugin_cdn->get_rename_posts_count();
|
1959 |
|
1960 |
-
$title = '
|
1961 |
|
1962 |
include W3TC_DIR . '/inc/popup/cdn_rename_domain.phtml';
|
1963 |
}
|
@@ -2012,17 +2115,17 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2012 |
|
2013 |
switch ($cdn_export_type) {
|
2014 |
case 'includes':
|
2015 |
-
$title = 'Includes export';
|
2016 |
$files = $w3_plugin_cdn->get_files_includes();
|
2017 |
break;
|
2018 |
|
2019 |
case 'theme':
|
2020 |
-
$title = 'Theme export';
|
2021 |
$files = $w3_plugin_cdn->get_files_theme();
|
2022 |
break;
|
2023 |
|
2024 |
case 'minify':
|
2025 |
-
$title = 'Minify export';
|
2026 |
$files = $w3_plugin_cdn->get_files_minify();
|
2027 |
break;
|
2028 |
|
@@ -2103,7 +2206,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2103 |
$user = W3_Request::get_string('user');
|
2104 |
$pass = W3_Request::get_string('pass');
|
2105 |
$path = W3_Request::get_string('path');
|
2106 |
-
$pasv = W3_Request::
|
2107 |
|
2108 |
$w3_cdn_ftp = & W3_Cdn::instance('ftp', array(
|
2109 |
'host' => $host,
|
@@ -2250,10 +2353,10 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2250 |
|
2251 |
$key = md5(serialize($servers));
|
2252 |
|
2253 |
-
if (!
|
2254 |
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
|
2255 |
|
2256 |
-
$memcached = & W3_Cache_Memcached
|
2257 |
'servers' => $servers,
|
2258 |
'persistant' => false
|
2259 |
));
|
@@ -2347,8 +2450,9 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2347 |
{
|
2348 |
if ($this->_config->get_string('pgcache.engine') == $type && $this->_config->get_boolean('pgcache.enabled')) {
|
2349 |
$this->_config->set('notes.need_empty_pgcache', false);
|
|
|
2350 |
|
2351 |
-
if (
|
2352 |
$this->redirect(array(
|
2353 |
'error' => 'config_save'
|
2354 |
));
|
@@ -2364,7 +2468,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2364 |
if ($this->_config->get_string('minify.engine') == $type && $this->_config->get_boolean('minify.enabled')) {
|
2365 |
$this->_config->set('notes.need_empty_minify', false);
|
2366 |
|
2367 |
-
if (
|
2368 |
$this->redirect(array(
|
2369 |
'error' => 'config_save'
|
2370 |
));
|
@@ -2388,9 +2492,11 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2388 |
* Flush APC cache
|
2389 |
* @return void
|
2390 |
*/
|
2391 |
-
function
|
2392 |
{
|
2393 |
$this->flush('apc');
|
|
|
|
|
2394 |
}
|
2395 |
|
2396 |
/**
|
@@ -2468,12 +2574,12 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2468 |
|
2469 |
if ($buffer != '' && w3_is_xml($buffer)) {
|
2470 |
$date = date('Y-m-d H:i:s');
|
2471 |
-
$host = (!
|
2472 |
|
2473 |
if ($this->is_supported()) {
|
2474 |
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", $host, $date);
|
2475 |
} else {
|
2476 |
-
$buffer .= "\r\n<!--
|
2477 |
|
2478 |
if ($this->_config->get_boolean('minify.enabled')) {
|
2479 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
@@ -2560,7 +2666,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2560 |
/**
|
2561 |
* Check request URI
|
2562 |
*/
|
2563 |
-
if (
|
2564 |
return false;
|
2565 |
}
|
2566 |
|
@@ -2624,6 +2730,7 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2624 |
'wp' => array(
|
2625 |
'version' => $wp_version,
|
2626 |
'db_version' => $wp_db_version,
|
|
|
2627 |
'url' => w3_get_domain_url(),
|
2628 |
'path' => ABSPATH,
|
2629 |
'email' => get_option('admin_email'),
|
@@ -2632,11 +2739,6 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2632 |
'plugins' => $wordpress_plugins_active,
|
2633 |
'wp_cache' => (defined('WP_CACHE') ? 'true' : 'false')
|
2634 |
),
|
2635 |
-
'w3tc' => array(
|
2636 |
-
'version' => W3TC_VERSION,
|
2637 |
-
'config' => $w3tc_config
|
2638 |
-
),
|
2639 |
-
'php' => w3_phpinfo(),
|
2640 |
'mysql' => array(
|
2641 |
'version' => $mysql_version,
|
2642 |
'variables' => $mysql_variables
|
@@ -2752,14 +2854,20 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
2752 |
*/
|
2753 |
function redirect($params = array(), $check_referer = false)
|
2754 |
{
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2763 |
}
|
2764 |
|
2765 |
w3_redirect($url, $params);
|
70 |
'favorite_actions'
|
71 |
));
|
72 |
|
|
|
|
|
|
|
|
|
|
|
73 |
add_action('init', array(
|
74 |
&$this,
|
75 |
'init'
|
80 |
'in_plugin_update_message'
|
81 |
));
|
82 |
|
83 |
+
if ($this->_config->get_boolean('widget.latest.enabled')) {
|
84 |
add_action('wp_dashboard_setup', array(
|
85 |
&$this,
|
86 |
'wp_dashboard_setup'
|
160 |
{
|
161 |
static $instances = array();
|
162 |
|
163 |
+
if (!isset($instances[0])) {
|
164 |
$class = __CLASS__;
|
165 |
$instances[0] = & new $class();
|
166 |
}
|
168 |
return $instances[0];
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
+
* Check for buggy site-wide activation
|
173 |
+
*/
|
174 |
+
function wpmu_check()
|
175 |
+
{
|
176 |
+
$sitewide_plugins = (array) @unserialize(get_site_option('active_sitewide_plugins'));
|
177 |
+
$plugins = (array) @unserialize(get_option('active_plugins'));
|
178 |
+
}
|
179 |
+
|
180 |
/**
|
181 |
* Activate plugin action
|
182 |
*/
|
183 |
function activate()
|
184 |
{
|
185 |
+
if (!is_dir(W3TC_CONTENT_DIR)) {
|
186 |
+
if (@mkdir(W3TC_CONTENT_DIR, 0755)) {
|
187 |
+
@chmod(W3TC_CONTENT_DIR, 0755);
|
188 |
+
} else {
|
189 |
+
w3_writable_error(W3TC_CONTENT_DIR);
|
|
|
|
|
190 |
}
|
191 |
+
}
|
192 |
+
|
193 |
+
if (!is_dir(W3TC_CACHE_FILE_DBCACHE_DIR)) {
|
194 |
+
if (@mkdir(W3TC_CACHE_FILE_DBCACHE_DIR, 0755)) {
|
195 |
+
@chmod(W3TC_CACHE_FILE_DBCACHE_DIR, 0755);
|
196 |
+
} else {
|
197 |
+
w3_writable_error(W3TC_CACHE_FILE_DBCACHE_DIR);
|
198 |
}
|
199 |
+
}
|
200 |
+
|
201 |
+
if (!is_dir(W3TC_CACHE_FILE_PGCACHE_DIR)) {
|
202 |
+
if (@mkdir(W3TC_CACHE_FILE_PGCACHE_DIR, 0755)) {
|
203 |
+
@chmod(W3TC_CACHE_FILE_PGCACHE_DIR, 0755);
|
204 |
+
} else {
|
205 |
+
w3_writable_error(W3TC_CACHE_FILE_PGCACHE_DIR);
|
206 |
}
|
207 |
+
}
|
208 |
+
|
209 |
+
if (!is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
|
210 |
+
if (@mkdir(W3TC_CACHE_FILE_MINIFY_DIR, 0755)) {
|
211 |
+
@chmod(W3TC_CACHE_FILE_MINIFY_DIR, 0755);
|
212 |
+
} else {
|
213 |
+
w3_writable_error(W3TC_CACHE_FILE_MINIFY_DIR);
|
214 |
}
|
215 |
+
}
|
216 |
+
|
217 |
+
if (!is_dir(W3TC_LOG_DIR)) {
|
218 |
+
if (@mkdir(W3TC_LOG_DIR, 0755)) {
|
219 |
+
@chmod(W3TC_LOG_DIR, 0755);
|
220 |
+
} else {
|
221 |
+
w3_writable_error(W3TC_LOG_DIR);
|
222 |
}
|
223 |
+
}
|
224 |
+
|
225 |
+
if (!is_dir(W3TC_TMP_DIR)) {
|
226 |
+
if (@mkdir(W3TC_TMP_DIR, 0755)) {
|
227 |
+
@chmod(W3TC_TMP_DIR, 0755);
|
228 |
+
} else {
|
229 |
+
w3_writable_error(W3TC_TMP_DIR);
|
230 |
}
|
231 |
}
|
232 |
|
233 |
+
if (!$this->_config->get_integer('common.install')) {
|
234 |
$this->_config->set('common.install', time());
|
235 |
}
|
236 |
|
237 |
+
if (w3_is_wpmu()) {
|
238 |
+
$this->_config->load_master();
|
239 |
+
}
|
240 |
+
|
241 |
+
if (!$this->_config->save()) {
|
242 |
w3_writable_error(W3TC_CONFIG_PATH);
|
243 |
}
|
244 |
|
250 |
|
251 |
/**
|
252 |
* Deactivate plugin action
|
253 |
+
* @todo Complete plugin uninstall on site wide activation
|
254 |
*/
|
255 |
function deactivate()
|
256 |
{
|
258 |
|
259 |
delete_option('w3tc_request_data');
|
260 |
|
261 |
+
w3_rmdir(W3TC_TMP_DIR);
|
262 |
+
w3_rmdir(W3TC_LOG_DIR);
|
263 |
+
w3_rmdir(W3TC_CACHE_FILE_MINIFY_DIR);
|
264 |
+
w3_rmdir(W3TC_CACHE_FILE_PGCACHE_DIR);
|
265 |
+
w3_rmdir(W3TC_CACHE_FILE_DBCACHE_DIR);
|
266 |
+
w3_rmdir(W3TC_CONTENT_DIR);
|
|
|
267 |
}
|
268 |
|
269 |
/**
|
304 |
*/
|
305 |
if (isset($_REQUEST['flush_all'])) {
|
306 |
$this->flush_memcached();
|
307 |
+
$this->flush_opcode();
|
308 |
$this->flush_file();
|
309 |
|
310 |
$this->redirect(array(
|
326 |
/**
|
327 |
* Flush APC cache
|
328 |
*/
|
329 |
+
if (isset($_REQUEST['flush_opcode'])) {
|
330 |
+
$this->flush_opcode();
|
331 |
|
332 |
$this->redirect(array(
|
333 |
+
'note' => 'flush_opcode'
|
334 |
), true);
|
335 |
}
|
336 |
|
352 |
$this->flush_pgcache();
|
353 |
|
354 |
$this->_config->set('notes.need_empty_pgcache', false);
|
355 |
+
$this->_config->set('notes.plugins_updated', false);
|
356 |
|
357 |
+
if (!$this->_config->save()) {
|
358 |
$this->redirect(array(
|
359 |
'error' => 'config_save'
|
360 |
), true);
|
384 |
|
385 |
$this->_config->set('notes.need_empty_minify', false);
|
386 |
|
387 |
+
if (!$this->_config->save()) {
|
388 |
$this->redirect(array(
|
389 |
'error' => 'config_save'
|
390 |
), true);
|
403 |
|
404 |
$this->_config->set($setting, false);
|
405 |
|
406 |
+
if (!$this->_config->save()) {
|
407 |
$this->redirect(array(
|
408 |
'error' => 'config_save'
|
409 |
), true);
|
486 |
|
487 |
$this->_config->set('common.support', $support);
|
488 |
|
489 |
+
if (!$this->_config->save()) {
|
490 |
$this->redirect(array(
|
491 |
'error' => 'config_save'
|
492 |
));
|
502 |
/**
|
503 |
* Run plugin action
|
504 |
*/
|
505 |
+
if (isset($_REQUEST['w3tc_action'])) {
|
506 |
$action = trim($_REQUEST['w3tc_action']);
|
507 |
|
508 |
if (method_exists($this, $action)) {
|
523 |
exit();
|
524 |
}
|
525 |
|
526 |
+
$this->_support_reminder = ($this->_config->get_boolean('notes.support_us') && $this->_config->get_integer('common.install') < (time() - W3TC_SUPPORT_US_TIMEOUT) && !$this->is_supported());
|
527 |
|
528 |
wp_enqueue_style('w3tc-options', WP_PLUGIN_URL . '/w3-total-cache/inc/css/options.css');
|
529 |
wp_enqueue_style('w3tc-lightbox', WP_PLUGIN_URL . '/w3-total-cache/inc/css/lightbox.css');
|
|
|
|
|
530 |
}
|
531 |
|
532 |
/**
|
534 |
*/
|
535 |
function wp_dashboard_setup()
|
536 |
{
|
537 |
+
wp_add_dashboard_widget('w3tc_latest', 'The Latest from W3 EDGE', array(
|
538 |
&$this,
|
539 |
'widget_latest'
|
540 |
+
), array(
|
541 |
+
&$this,
|
542 |
+
'widget_latest_control'
|
543 |
));
|
544 |
}
|
545 |
|
546 |
/**
|
547 |
+
* Prints latest widget contents
|
548 |
*/
|
549 |
function widget_latest()
|
550 |
{
|
551 |
global $wp_version;
|
552 |
|
553 |
+
$items = array();
|
554 |
+
$items_count = $this->_config->get_integer('widget.latest.items');
|
555 |
+
|
556 |
if ($wp_version >= 2.8) {
|
557 |
include_once (ABSPATH . WPINC . '/feed.php');
|
558 |
$feed = fetch_feed(W3TC_FEED_URL);
|
|
|
559 |
|
560 |
+
if (!is_wp_error($feed)) {
|
561 |
+
$feed_items = $feed->get_items(0, $items_count);
|
562 |
+
|
563 |
+
foreach ($feed_items as $feed_item) {
|
564 |
+
$items[] = array(
|
565 |
+
'link' => $feed_item->get_link(),
|
566 |
+
'title' => $feed_item->get_title(),
|
567 |
+
'description' => $feed_item->get_description()
|
568 |
+
);
|
569 |
+
}
|
570 |
}
|
571 |
} else {
|
572 |
include_once (ABSPATH . WPINC . '/rss.php');
|
573 |
$rss = fetch_rss(W3TC_FEED_URL);
|
|
|
574 |
|
575 |
+
if (is_object($rss)) {
|
576 |
+
$items = array_slice($rss->items, 0, $items_count);
|
577 |
}
|
578 |
}
|
579 |
+
|
580 |
+
include W3TC_DIR . '/inc/widget/latest.phtml';
|
581 |
+
}
|
582 |
|
583 |
+
/**
|
584 |
+
* Latest widget control
|
585 |
+
*/
|
586 |
+
function widget_latest_control($widget_id, $form_inputs = array())
|
587 |
+
{
|
588 |
+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
589 |
+
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
590 |
+
|
591 |
+
$this->_config->set('widget.latest.items', W3_Request::get_integer('w3tc_latest_items', 3));
|
592 |
+
$this->_config->save();
|
593 |
+
} else {
|
594 |
+
include W3TC_DIR . '/inc/widget/latest_control.phtml';
|
595 |
+
}
|
596 |
}
|
597 |
|
598 |
/**
|
605 |
'options'
|
606 |
));
|
607 |
|
608 |
+
if (current_user_can('manage_options')) {
|
609 |
+
/**
|
610 |
+
* Only admin can modify W3TC settings
|
611 |
+
*/
|
612 |
+
add_action('load-' . $page, array(
|
613 |
+
&$this,
|
614 |
+
'load'
|
615 |
+
));
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Only admin can see W3TC notices and errors
|
619 |
+
*/
|
620 |
+
add_action('admin_notices', array(
|
621 |
+
&$this,
|
622 |
+
'admin_notices'
|
623 |
+
));
|
624 |
+
}
|
625 |
}
|
626 |
|
627 |
/**
|
708 |
'config_save' => 'Plugin configuration successfully updated.',
|
709 |
'flush_all' => 'All caches successfully emptied.',
|
710 |
'flush_memcached' => 'Memcached cache(s) successfully emptied.',
|
711 |
+
'flush_opcode' => 'Opcode cache(s) successfully emptied.',
|
712 |
'flush_file' => 'Disk cache successfully emptied.',
|
713 |
'flush_pgcache' => 'Page cache successfully emptied.',
|
714 |
'flush_dbcache' => 'Database cache successfully emptied.',
|
741 |
/**
|
742 |
* Check config file
|
743 |
*/
|
744 |
+
if (!file_exists(W3TC_CONFIG_PATH)) {
|
745 |
$errors[] = sprintf('<strong>W3 Total Cache Error:</strong> Default settings are in use. The configuration file could not be read or doesn\'t exist. Please %s to create the file.', $this->button_link('save your settings', sprintf('options-general.php?page=%s&tab=%s&save_config', W3TC_FILE, $this->_tab)));
|
746 |
}
|
747 |
|
800 |
}
|
801 |
|
802 |
if ($this->_config->get_boolean('minify.enabled')) {
|
803 |
+
$texts[] = sprintf('check your %s to maintain the desired user experience', $this->button_hide_note('minify settings', 'plugins_updated', sprintf('options-general.php?page=%s&tab=minify', W3TC_FILE)));
|
804 |
}
|
805 |
|
806 |
if (count($texts)) {
|
888 |
|
889 |
foreach ($changelog as $index => $line) {
|
890 |
if (preg_match('~^\s*\*\s*~', $line)) {
|
891 |
+
if (!$ul) {
|
892 |
echo '<ul style="list-style: disc; margin-left: 20px;">';
|
893 |
$ul = true;
|
894 |
}
|
929 |
* Check for page cache availability
|
930 |
*/
|
931 |
if ($this->_config->get_boolean('pgcache.enabled')) {
|
932 |
+
if (!$this->check_advanced_cache()) {
|
933 |
$this->_errors[] = sprintf('Page caching is not available: advanced-cache.php is not installed. Either the <strong>%s</strong> directory is not write-able or you have another caching plugin installed. This error message will automatically disappear once the change is successfully made.', WP_CONTENT_DIR);
|
934 |
+
} elseif (!defined('WP_CACHE')) {
|
935 |
$this->_errors[] = sprintf('Page caching is not available: please add: <strong>define(\'WP_CACHE\', true);</strong> to <strong>%swp-config.php</strong>. This error message will automatically disappear once the change is successfully made.', ABSPATH);
|
936 |
} else {
|
937 |
switch ($this->_config->get_string('pgcache.engine')) {
|
939 |
require_once W3TC_LIB_W3_DIR . '/Plugin/PgCache.php';
|
940 |
$w3_plugin_pgcache = & W3_Plugin_PgCache::instance();
|
941 |
|
942 |
+
if ($this->_config->get_boolean('notes.pgcache_rules_core') && !$w3_plugin_pgcache->check_rules_core()) {
|
943 |
+
if (w3_is_wpmu()) {
|
944 |
$this->_errors[] = sprintf('Enhanced mode page cache is not operational. Your .htaccess rules could not be modified. Please verify <strong>%s.htaccess</strong> has the following rules: <pre>%s</pre> %s', ABSPATH, htmlspecialchars($w3_plugin_pgcache->generate_rules_core()), $this->button_hide_note('Hide this message', 'pgcache_rules_core'));
|
945 |
} else {
|
946 |
$this->_errors[] = sprintf('You\'ve selected disk caching with enhanced mode however the .htaccess file is not properly configured. Please run <strong>chmod 777 %s.htaccess</strong>, then %s. To manually modify your server configuration for enhanced mode append the following code: <pre>%s</pre> and %s.', ABSPATH, $this->button_link('try again', sprintf('options-general.php?page=%s&tab=%s&pgcache_write_rules_core', W3TC_FILE, $this->_tab)), htmlspecialchars($w3_plugin_pgcache->generate_rules_core()), $this->button_hide_note('hide this message', 'pgcache_rules_core'));
|
947 |
}
|
948 |
}
|
949 |
|
950 |
+
if ($this->_config->get_boolean('notes.pgcache_rules_cache') && !$w3_plugin_pgcache->check_rules_cache()) {
|
951 |
+
$this->_errors[] = sprintf('You\'ve selected disk caching with enhanced mode however the .htaccess file is not properly configured. Please run <strong>chmod 777 %s/.htaccess</strong>, then %s. To manually modify your server configuration for enhanced mode append the following code: <pre>%s</pre> and %s.', W3TC_CACHE_FILE_PGCACHE_DIR, $this->button_link('try again', sprintf('options-general.php?page=%s&tab=%s&pgcache_write_rules_cache', W3TC_FILE, $this->_tab)), htmlspecialchars($w3_plugin_pgcache->generate_rules_cache()), $this->button_hide_note('hide this message', 'pgcache_rules_cache'));
|
|
|
|
|
|
|
|
|
952 |
}
|
953 |
break;
|
954 |
|
955 |
case 'memcached':
|
956 |
$pgcache_memcached_servers = $this->_config->get_array('pgcache.memcached.servers');
|
957 |
|
958 |
+
if (!$this->is_memcache_available($pgcache_memcached_servers)) {
|
959 |
$this->_errors[] = sprintf('Page caching is not working properly. Memcached server(s): <strong>%s</strong> may not running or not responding. This error message will automatically disappear once the issue is resolved.', implode(', ', $pgcache_memcached_servers));
|
960 |
}
|
961 |
break;
|
973 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
974 |
$w3_plugin_minify = & W3_Plugin_Minify::instance();
|
975 |
|
976 |
+
if ($this->_config->get_boolean('notes.minify_rules') && !$w3_plugin_minify->check_rules()) {
|
977 |
+
$this->_errors[] = sprintf('The "Rewrite URL Structure" feature, requires rewrite rules be present. Please run <strong>chmod 777 %s/.htaccess</strong>, then %s. To manually modify your server configuration for minify append the following code: <pre>%s</pre> and %s.', W3TC_CACHE_FILE_MINIFY_DIR, $this->button_link('try again', sprintf('options-general.php?page=%s&tab=%s&minify_write_rules', W3TC_FILE, $this->_tab)), htmlspecialchars($w3_plugin_minify->generate_rules()), $this->button_hide_note('hide this message', 'minify_rules'));
|
|
|
|
|
|
|
|
|
978 |
}
|
979 |
}
|
980 |
break;
|
982 |
case 'memcached':
|
983 |
$minify_memcached_servers = $this->_config->get_array('minify.memcached.servers');
|
984 |
|
985 |
+
if (!$this->is_memcache_available($minify_memcached_servers)) {
|
986 |
+
$this->_errors[] = sprintf('Minify is not working properly. Memcached server(s): <strong>%s</strong> may not running or not responding. This error message will automatically disappear once the issue is resolved.', implode(', ', $minify_memcached_servers));
|
987 |
}
|
988 |
break;
|
989 |
}
|
993 |
* Check for database cache availability
|
994 |
*/
|
995 |
if ($this->_config->get_boolean('dbcache.enabled')) {
|
996 |
+
if (!$this->check_db()) {
|
997 |
$this->_errors[] = sprintf('Database caching is not available: db.php is not installed. Either the <strong>%s</strong> directory is not write-able or you have another caching plugin installed. This error message will automatically disappear once the change is successfully made.', WP_CONTENT_DIR);
|
998 |
} elseif ($this->_config->get_string('pgcache.engine') == 'memcached') {
|
999 |
$dbcache_memcached_servers = $this->_config->get_array('dbcache.memcached.servers');
|
1000 |
|
1001 |
+
if (!$this->is_memcache_available($dbcache_memcached_servers)) {
|
1002 |
$this->_errors[] = sprintf('Database caching is not working properly. Memcached server(s): <strong>%s</strong> may not running or not responding. This error message will automatically disappear once the issue is successfully resolved.', implode(', ', $dbcache_memcached_servers));
|
1003 |
}
|
1004 |
}
|
1007 |
/**
|
1008 |
* Check PHP version
|
1009 |
*/
|
1010 |
+
if (!W3TC_PHP5 && $this->_config->get_boolean('notes.php_is_old')) {
|
1011 |
$this->_notes[] = sprintf('Unfortunately, <strong>PHP5</strong> is required for full functionality of this plugin; incompatible features are automatically disabled. Please upgrade if possible. %s', $this->button_hide_note('Hide this message', 'php_is_old'));
|
1012 |
}
|
1013 |
|
1014 |
/**
|
1015 |
* Check CURL extension
|
1016 |
*/
|
1017 |
+
if ($this->_config->get_boolean('notes.no_curl') && $this->_config->get_boolean('cdn.enabled') && !function_exists('curl_init')) {
|
1018 |
$this->_notes[] = sprintf('The <strong>CURL PHP</strong> extension is not available. Please install it to enable S3 or CloudFront functionality. %s', $this->button_hide_note('Hide this message', 'no_curl'));
|
1019 |
}
|
1020 |
|
1021 |
/**
|
1022 |
* Check Zlib extension
|
1023 |
*/
|
1024 |
+
if ($this->_config->get_boolean('notes.no_zlib') && (!function_exists('gzencode') || !function_exists('gzdeflate'))) {
|
1025 |
$this->_notes[] = sprintf('Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Please notify your server administrator and ask for it to be installed. %s', $this->button_hide_note('Hide this message', 'no_zlib'));
|
1026 |
}
|
1027 |
|
1042 |
/**
|
1043 |
* Check wp-content permissions
|
1044 |
*/
|
1045 |
+
if (!W3TC_WIN && $this->_config->get_boolean('notes.wp_content_perms')) {
|
1046 |
$wp_content_stat = stat(WP_CONTENT_DIR);
|
1047 |
$wp_content_mode = ($wp_content_stat['mode'] & 0777);
|
1048 |
|
1131 |
$enabled = ($pgcache_enabled || $dbcache_enabled || $minify_enabled || $cdn_enabled);
|
1132 |
|
1133 |
$check_apc = function_exists('apc_store');
|
1134 |
+
$check_eaccelerator = function_exists('eaccelerator_put');
|
1135 |
+
$check_xcache = function_exists('xcache_set');
|
1136 |
$check_curl = function_exists('curl_init');
|
1137 |
+
$check_memcached = class_exists('Memcache');
|
1138 |
|
1139 |
$pgcache_engine = $this->_config->get_string('pgcache.engine');
|
1140 |
$dbcache_engine = $this->_config->get_string('dbcache.engine');
|
1141 |
$minify_engine = $this->_config->get_string('minify.engine');
|
1142 |
|
1143 |
$can_empty_memcache = ($pgcache_engine == 'memcached' || $dbcache_engine == 'memcached' || $minify_engine == 'memcached');
|
|
|
|
|
1144 |
|
1145 |
+
$can_empty_opcode = ($pgcache_engine == 'apc' || $pgcache_engine == 'eaccelerator' || $pgcache_engine == 'xcache');
|
1146 |
+
$can_empty_opcode = $can_empty_opcode || ($dbcache_engine == 'apc' || $dbcache_engine == 'eaccelerator' || $dbcache_engine == 'xcache');
|
1147 |
+
$can_empty_opcode = $can_empty_opcode || ($minify_engine == 'apc' || $minify_engine == 'eaccelerator' || $minify_engine == 'xcache');
|
1148 |
+
|
1149 |
+
$can_empty_file = ($pgcache_engine == 'file' || $pgcache_engine == 'file_pgcache' || $dbcache_engine == 'file' || $minify_engine == 'file');
|
1150 |
|
1151 |
$debug = ($this->_config->get_boolean('dbcache.debug') || $this->_config->get_boolean('pgcache.debug') || $this->_config->get_boolean('minify.debug') || $this->_config->get_boolean('cdn.debug'));
|
1152 |
|
1174 |
function options_minify()
|
1175 |
{
|
1176 |
$minify_enabled = $this->_config->get_boolean('minify.enabled');
|
1177 |
+
$minify_gzip = function_exists('gzencode');
|
1178 |
+
$minify_deflate = function_exists('gzdeflate');
|
1179 |
|
1180 |
$groups = $this->minify_get_groups();
|
1181 |
|
1182 |
+
$js_group = W3_Request::get_string('js_group', 'default');
|
1183 |
$js_groups = $this->_config->get_array('minify.js.groups');
|
1184 |
+
|
1185 |
+
$css_group = W3_Request::get_string('css_group', 'default');
|
1186 |
$css_groups = $this->_config->get_array('minify.css.groups');
|
1187 |
|
1188 |
include W3TC_DIR . '/inc/options/minify.phtml';
|
1209 |
|
1210 |
$minify_enabled = $this->_config->get_boolean('minify.enabled');
|
1211 |
|
|
|
|
|
|
|
|
|
1212 |
include W3TC_DIR . '/inc/options/cdn.phtml';
|
1213 |
}
|
1214 |
|
1275 |
{
|
1276 |
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
1277 |
|
1278 |
+
/**
|
1279 |
+
* Redirect params
|
1280 |
+
*/
|
1281 |
+
$params = array();
|
1282 |
+
|
1283 |
/**
|
1284 |
* Read config
|
1285 |
*/
|
1290 |
* General tab
|
1291 |
*/
|
1292 |
if ($this->_tab == 'general') {
|
1293 |
+
$debug = W3_Request::get_array('debug');
|
1294 |
|
1295 |
+
$config->set('dbcache.debug', in_array('dbcache', $debug));
|
1296 |
+
$config->set('pgcache.debug', in_array('pgcache', $debug));
|
1297 |
+
$config->set('minify.debug', in_array('minify', $debug));
|
1298 |
+
$config->set('cdn.debug', in_array('cdn', $debug));
|
1299 |
|
1300 |
/**
|
1301 |
* Page cache tab
|
1317 |
/**
|
1318 |
* Minify tab
|
1319 |
*/
|
|
|
1320 |
if ($this->_tab == 'minify') {
|
1321 |
$groups = $this->minify_get_groups();
|
1322 |
+
|
1323 |
+
$js_group = W3_Request::get_string('js_group');
|
1324 |
$js_files = W3_Request::get_array('js_files');
|
1325 |
+
|
1326 |
+
$css_group = W3_Request::get_string('css_group');
|
1327 |
$css_files = W3_Request::get_array('css_files');
|
1328 |
|
1329 |
$js_groups = array();
|
1330 |
$css_groups = array();
|
1331 |
|
1332 |
foreach ($js_files as $group => $locations) {
|
1333 |
+
if (!array_key_exists($group, $groups)) {
|
1334 |
continue;
|
1335 |
}
|
1336 |
|
1350 |
break;
|
1351 |
}
|
1352 |
foreach ((array) $files as $file) {
|
1353 |
+
if (!empty($file)) {
|
1354 |
+
$js_groups[$group][$location]['files'][] = w3_normalize_file($file);
|
1355 |
}
|
1356 |
}
|
1357 |
}
|
1358 |
}
|
1359 |
|
1360 |
foreach ($css_files as $group => $locations) {
|
1361 |
+
if (!array_key_exists($group, $groups)) {
|
1362 |
continue;
|
1363 |
}
|
1364 |
|
1365 |
foreach ((array) $locations as $location => $files) {
|
1366 |
foreach ((array) $files as $file) {
|
1367 |
+
if (!empty($file)) {
|
1368 |
+
$css_groups[$group][$location]['files'][] = w3_normalize_file($file);
|
1369 |
}
|
1370 |
}
|
1371 |
}
|
1373 |
|
1374 |
$config->set('minify.js.groups', $js_groups);
|
1375 |
$config->set('minify.css.groups', $css_groups);
|
1376 |
+
|
1377 |
+
$params = array_merge($params, array(
|
1378 |
+
'js_group' => $js_group,
|
1379 |
+
'css_group' => $css_group
|
1380 |
+
));
|
1381 |
}
|
1382 |
|
1383 |
/**
|
1384 |
* Handle settings change that require pgcache and minify empty
|
1385 |
*/
|
1386 |
$pgcache_dependencies = array(
|
|
|
1387 |
'pgcache.debug',
|
1388 |
+
'dbcache.enabled',
|
1389 |
'minify.enabled',
|
1390 |
+
'cdn.enabled'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1391 |
);
|
1392 |
|
1393 |
+
if ($config->get_boolean('dbcache.enabled')) {
|
1394 |
+
$pgcache_dependencies = array_merge($pgcache_dependencies, array(
|
1395 |
+
'dbcache.debug'
|
1396 |
+
));
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
if ($config->get_boolean('minify.enabled')) {
|
1400 |
+
$pgcache_dependencies = array_merge($pgcache_dependencies, array(
|
1401 |
+
'minify.debug',
|
1402 |
+
'minify.rewrite',
|
1403 |
+
'minify.options',
|
1404 |
+
'minify.html.enable',
|
1405 |
+
'minify.html.reject.admin',
|
1406 |
+
'minify.html.inline.css',
|
1407 |
+
'minify.html.inline.js',
|
1408 |
+
'minify.html.strip.crlf',
|
1409 |
+
'minify.css.enable',
|
1410 |
+
'minify.css.groups',
|
1411 |
+
'minify.js.enable',
|
1412 |
+
'minify.js.groups'
|
1413 |
+
));
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
if ($config->get_boolean('cdn.enabled')) {
|
1417 |
+
$pgcache_dependencies = array_merge($pgcache_dependencies, array(
|
1418 |
+
'cdn.debug',
|
1419 |
+
'cdn.engine',
|
1420 |
+
'cdn.includes.enable',
|
1421 |
+
'cdn.includes.files',
|
1422 |
+
'cdn.theme.enable',
|
1423 |
+
'cdn.theme.files',
|
1424 |
+
'cdn.minify.enable',
|
1425 |
+
'cdn.custom.enable',
|
1426 |
+
'cdn.custom.files',
|
1427 |
+
'cdn.ftp.domain',
|
1428 |
+
'cdn.s3.bucket',
|
1429 |
+
'cdn.cf.id',
|
1430 |
+
'cdn.cf.cname'
|
1431 |
+
));
|
1432 |
+
}
|
1433 |
+
|
1434 |
$minify_dependencies = array(
|
1435 |
'minify.debug',
|
1436 |
+
'minify.css.combine',
|
1437 |
'minify.css.strip.comments',
|
1438 |
'minify.css.strip.crlf',
|
1439 |
'minify.css.groups',
|
1541 |
}
|
1542 |
|
1543 |
/**
|
1544 |
+
* Write page cache rewrite rules
|
1545 |
*/
|
1546 |
+
if ($this->_tab == 'general' || $this->_tab == 'pgcache') {
|
1547 |
+
$is_wpmu = w3_is_wpmu();
|
1548 |
+
|
1549 |
+
if ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'file_pgcache') {
|
1550 |
+
if (!$is_wpmu) {
|
|
|
1551 |
$w3_plugin_pgcache->write_rules_core();
|
1552 |
+
}
|
1553 |
+
|
1554 |
+
$w3_plugin_pgcache->write_rules_cache();
|
1555 |
+
} else {
|
1556 |
+
if (!$is_wpmu) {
|
1557 |
$w3_plugin_pgcache->remove_rules_core();
|
|
|
1558 |
}
|
1559 |
+
|
1560 |
+
$w3_plugin_pgcache->remove_rules_cache();
|
1561 |
}
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
/**
|
1565 |
+
* Write minify rewrite rules
|
1566 |
+
*/
|
1567 |
+
if (W3TC_PHP5 && ($this->_tab == 'general' || $this->_tab == 'minify')) {
|
1568 |
+
if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_boolean('minify.rewrite')) {
|
1569 |
+
$w3_plugin_minify->write_rules();
|
1570 |
+
} else {
|
1571 |
+
require_once W3TC_DIR . '/lib/W3/Plugin/Minify.php';
|
1572 |
+
$w3_plugin_minify->remove_rules();
|
1573 |
}
|
1574 |
}
|
1575 |
|
1576 |
+
$this->redirect(array_merge($params, array(
|
1577 |
'note' => 'config_save'
|
1578 |
+
)));
|
1579 |
} else {
|
1580 |
+
$this->redirect(array_merge($params, array(
|
1581 |
'error' => 'config_save'
|
1582 |
+
)));
|
1583 |
}
|
1584 |
}
|
1585 |
|
1596 |
$request_type = W3_Request::get_string('request_type');
|
1597 |
$description = W3_Request::get_string('description');
|
1598 |
$templates = W3_Request::get_array('templates');
|
|
|
1599 |
$wp_login = W3_Request::get_string('wp_login');
|
1600 |
$wp_password = W3_Request::get_string('wp_password');
|
1601 |
$ftp_host = W3_Request::get_string('ftp_host');
|
1632 |
)));
|
1633 |
}
|
1634 |
|
1635 |
+
if (!preg_match('~^[a-z0-9_\-\.]+@[a-z0-9-\.]+\.[a-z]{2,5}$~', $email)) {
|
1636 |
$this->redirect(array_merge($params, array(
|
1637 |
'error' => 'support_request_email'
|
1638 |
)));
|
1687 |
/**
|
1688 |
* Add attachments
|
1689 |
*/
|
1690 |
+
$attachments = array(
|
1691 |
+
W3TC_CONFIG_PATH
|
1692 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1693 |
|
1694 |
/**
|
1695 |
* Attach server info
|
1696 |
*/
|
1697 |
$server_info = print_r($this->get_server_info(), true);
|
1698 |
$server_info = str_replace("\n", "\r\n", $server_info);
|
|
|
1699 |
|
1700 |
+
$server_info_path = W3TC_TMP_DIR . '/server_info.txt';
|
1701 |
+
|
1702 |
+
if (@file_put_contents($server_info_path, $server_info)) {
|
1703 |
+
$attachments[] = $server_info_path;
|
1704 |
+
}
|
1705 |
+
|
1706 |
+
/**
|
1707 |
+
* Attach phpinfo
|
1708 |
+
*/
|
1709 |
+
ob_start();
|
1710 |
+
phpinfo();
|
1711 |
+
$php_info = ob_get_contents();
|
1712 |
+
ob_end_clean();
|
1713 |
+
|
1714 |
+
$php_info_path = W3TC_TMP_DIR . '/php_info.html';
|
1715 |
+
|
1716 |
+
if (@file_put_contents($php_info_path, $php_info)) {
|
1717 |
+
$attachments[] = $php_info_path;
|
1718 |
}
|
1719 |
|
1720 |
/**
|
1724 |
$attachments[] = W3TC_MINIFY_LOG_FILE;
|
1725 |
}
|
1726 |
|
1727 |
+
/**
|
1728 |
+
* Attach templates
|
1729 |
+
*/
|
1730 |
+
foreach ($templates as $template) {
|
1731 |
+
if (!empty($template)) {
|
1732 |
+
$attachments[] = $template;
|
1733 |
+
}
|
1734 |
+
}
|
1735 |
+
|
1736 |
+
/**
|
1737 |
+
* Attach other files
|
1738 |
+
*/
|
1739 |
+
if (!empty($_FILES['files'])) {
|
1740 |
+
$files = (array) $_FILES['files'];
|
1741 |
+
for ($i = 0, $l = count($files); $i < $l; $i++) {
|
1742 |
+
if (isset($files['tmp_name'][$i]) && isset($files['name'][$i]) && isset($files['error'][$i]) && $files['error'][$i] == UPLOAD_ERR_OK) {
|
1743 |
+
$path = W3TC_TMP_DIR . '/' . $files['name'][$i];
|
1744 |
+
if (@move_uploaded_file($files['tmp_name'][$i], $path)) {
|
1745 |
+
$attachments[] = $path;
|
1746 |
+
}
|
1747 |
+
}
|
1748 |
+
}
|
1749 |
+
}
|
1750 |
+
|
1751 |
$data = array();
|
1752 |
|
1753 |
+
if (!empty($wp_login) && !empty($wp_password)) {
|
1754 |
$data['WP Admin login'] = $wp_login;
|
1755 |
$data['WP Admin password'] = $wp_password;
|
1756 |
}
|
1757 |
|
1758 |
+
if (!empty($ftp_host) && !empty($ftp_login) && !empty($ftp_password)) {
|
1759 |
$data['SSH / FTP host'] = $ftp_host;
|
1760 |
$data['SSH / FTP login'] = $ftp_login;
|
1761 |
$data['SSH / FTP password'] = $ftp_password;
|
1802 |
'phpmailer_init'
|
1803 |
));
|
1804 |
|
1805 |
+
set_time_limit(600);
|
1806 |
+
|
1807 |
$result = @wp_mail(W3TC_EMAIL, $subject, $body, implode("\n", $headers), $attachments);
|
1808 |
|
1809 |
/**
|
1868 |
*
|
1869 |
* @param string $text
|
1870 |
* @param string $note
|
1871 |
+
* @param string $redirect
|
1872 |
* @return string
|
1873 |
*/
|
1874 |
+
function button_hide_note($text, $note, $redirect = '')
|
1875 |
{
|
1876 |
$url = sprintf('options-general.php?page=%s&tab=%s&hide_note=%s', W3TC_FILE, $this->_tab, $note);
|
1877 |
|
1878 |
+
if ($redirect != '') {
|
1879 |
+
$url .= '&redirect=' . urlencode($redirect);
|
1880 |
+
}
|
1881 |
+
|
1882 |
return $this->button_link($text, $url);
|
1883 |
}
|
1884 |
|
1925 |
switch ($cdn_queue_action) {
|
1926 |
case 'delete':
|
1927 |
$cdn_queue_id = W3_Request::get_integer('cdn_queue_id');
|
1928 |
+
if (!empty($cdn_queue_id)) {
|
1929 |
$w3_plugin_cdn->queue_delete($cdn_queue_id);
|
1930 |
$notes[] = 'File successfully deleted from the queue.';
|
1931 |
}
|
1933 |
|
1934 |
case 'empty':
|
1935 |
$cdn_queue_type = W3_Request::get_integer('cdn_queue_type');
|
1936 |
+
if (!empty($cdn_queue_type)) {
|
1937 |
$w3_plugin_cdn->queue_empty($cdn_queue_type);
|
1938 |
$notes[] = 'Queue successfully emptied.';
|
1939 |
}
|
1941 |
}
|
1942 |
|
1943 |
$queue = $w3_plugin_cdn->queue_get();
|
1944 |
+
$title = 'Unsuccessful file transfer queue.';
|
1945 |
|
1946 |
include W3TC_DIR . '/inc/popup/cdn_queue.phtml';
|
1947 |
}
|
1956 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
1957 |
|
1958 |
$total = $w3_plugin_cdn->get_attachments_count();
|
1959 |
+
$title = 'Media Library export';
|
1960 |
|
1961 |
include W3TC_DIR . '/inc/popup/cdn_export_library.phtml';
|
1962 |
}
|
2009 |
$total = $w3_plugin_cdn->get_import_posts_count();
|
2010 |
$cdn_host = $cdn->get_domain();
|
2011 |
|
2012 |
+
$title = 'Media Library import';
|
2013 |
|
2014 |
include W3TC_DIR . '/inc/popup/cdn_import_library.phtml';
|
2015 |
}
|
2060 |
|
2061 |
$total = $w3_plugin_cdn->get_rename_posts_count();
|
2062 |
|
2063 |
+
$title = 'Modify attachment URLs';
|
2064 |
|
2065 |
include W3TC_DIR . '/inc/popup/cdn_rename_domain.phtml';
|
2066 |
}
|
2115 |
|
2116 |
switch ($cdn_export_type) {
|
2117 |
case 'includes':
|
2118 |
+
$title = 'Includes files export';
|
2119 |
$files = $w3_plugin_cdn->get_files_includes();
|
2120 |
break;
|
2121 |
|
2122 |
case 'theme':
|
2123 |
+
$title = 'Theme files export';
|
2124 |
$files = $w3_plugin_cdn->get_files_theme();
|
2125 |
break;
|
2126 |
|
2127 |
case 'minify':
|
2128 |
+
$title = 'Minify files export';
|
2129 |
$files = $w3_plugin_cdn->get_files_minify();
|
2130 |
break;
|
2131 |
|
2206 |
$user = W3_Request::get_string('user');
|
2207 |
$pass = W3_Request::get_string('pass');
|
2208 |
$path = W3_Request::get_string('path');
|
2209 |
+
$pasv = W3_Request::get_boolean('pasv');
|
2210 |
|
2211 |
$w3_cdn_ftp = & W3_Cdn::instance('ftp', array(
|
2212 |
'host' => $host,
|
2353 |
|
2354 |
$key = md5(serialize($servers));
|
2355 |
|
2356 |
+
if (!isset($results[$key])) {
|
2357 |
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
|
2358 |
|
2359 |
+
$memcached = & new W3_Cache_Memcached(array(
|
2360 |
'servers' => $servers,
|
2361 |
'persistant' => false
|
2362 |
));
|
2450 |
{
|
2451 |
if ($this->_config->get_string('pgcache.engine') == $type && $this->_config->get_boolean('pgcache.enabled')) {
|
2452 |
$this->_config->set('notes.need_empty_pgcache', false);
|
2453 |
+
$this->_config->set('notes.plugins_updated', false);
|
2454 |
|
2455 |
+
if (!$this->_config->save()) {
|
2456 |
$this->redirect(array(
|
2457 |
'error' => 'config_save'
|
2458 |
));
|
2468 |
if ($this->_config->get_string('minify.engine') == $type && $this->_config->get_boolean('minify.enabled')) {
|
2469 |
$this->_config->set('notes.need_empty_minify', false);
|
2470 |
|
2471 |
+
if (!$this->_config->save()) {
|
2472 |
$this->redirect(array(
|
2473 |
'error' => 'config_save'
|
2474 |
));
|
2492 |
* Flush APC cache
|
2493 |
* @return void
|
2494 |
*/
|
2495 |
+
function flush_opcode()
|
2496 |
{
|
2497 |
$this->flush('apc');
|
2498 |
+
$this->flush('eaccelerator');
|
2499 |
+
$this->flush('xcache');
|
2500 |
}
|
2501 |
|
2502 |
/**
|
2574 |
|
2575 |
if ($buffer != '' && w3_is_xml($buffer)) {
|
2576 |
$date = date('Y-m-d H:i:s');
|
2577 |
+
$host = (!empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
|
2578 |
|
2579 |
if ($this->is_supported()) {
|
2580 |
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", $host, $date);
|
2581 |
} else {
|
2582 |
+
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n\r\n";
|
2583 |
|
2584 |
if ($this->_config->get_boolean('minify.enabled')) {
|
2585 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
2666 |
/**
|
2667 |
* Check request URI
|
2668 |
*/
|
2669 |
+
if (!$this->check_request_uri()) {
|
2670 |
return false;
|
2671 |
}
|
2672 |
|
2730 |
'wp' => array(
|
2731 |
'version' => $wp_version,
|
2732 |
'db_version' => $wp_db_version,
|
2733 |
+
'w3tc_version' => W3TC_VERSION,
|
2734 |
'url' => w3_get_domain_url(),
|
2735 |
'path' => ABSPATH,
|
2736 |
'email' => get_option('admin_email'),
|
2739 |
'plugins' => $wordpress_plugins_active,
|
2740 |
'wp_cache' => (defined('WP_CACHE') ? 'true' : 'false')
|
2741 |
),
|
|
|
|
|
|
|
|
|
|
|
2742 |
'mysql' => array(
|
2743 |
'version' => $mysql_version,
|
2744 |
'variables' => $mysql_variables
|
2854 |
*/
|
2855 |
function redirect($params = array(), $check_referer = false)
|
2856 |
{
|
2857 |
+
require_once W3TC_LIB_W3_DIR . '/Request.php';
|
2858 |
+
|
2859 |
+
$url = W3_Request::get_string('redirect');
|
2860 |
+
|
2861 |
+
if ($url == '') {
|
2862 |
+
if ($check_referer && !empty($_SERVER['HTTP_REFERER'])) {
|
2863 |
+
$url = $_SERVER['HTTP_REFERER'];
|
2864 |
+
} else {
|
2865 |
+
$url = 'options-general.php';
|
2866 |
+
$params = array_merge(array(
|
2867 |
+
'page' => W3TC_FILE,
|
2868 |
+
'tab' => $this->_tab
|
2869 |
+
), $params);
|
2870 |
+
}
|
2871 |
}
|
2872 |
|
2873 |
w3_redirect($url, $params);
|
lib/memcached-client.php
DELETED
@@ -1,977 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
//
|
3 |
-
// +---------------------------------------------------------------------------+
|
4 |
-
// | memcached client, PHP |
|
5 |
-
// +---------------------------------------------------------------------------+
|
6 |
-
// | Copyright (c) 2003 Ryan T. Dean <rtdean@cytherianage.net> |
|
7 |
-
// | All rights reserved. |
|
8 |
-
// | |
|
9 |
-
// | Redistribution and use in source and binary forms, with or without |
|
10 |
-
// | modification, are permitted provided that the following conditions |
|
11 |
-
// | are met: |
|
12 |
-
// | |
|
13 |
-
// | 1. Redistributions of source code must retain the above copyright |
|
14 |
-
// | notice, this list of conditions and the following disclaimer. |
|
15 |
-
// | 2. Redistributions in binary form must reproduce the above copyright |
|
16 |
-
// | notice, this list of conditions and the following disclaimer in the |
|
17 |
-
// | documentation and/or other materials provided with the distribution. |
|
18 |
-
// | |
|
19 |
-
// | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
20 |
-
// | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
21 |
-
// | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
-
// | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
23 |
-
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
24 |
-
// | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
-
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
26 |
-
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
27 |
-
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
28 |
-
// | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
-
// +---------------------------------------------------------------------------+
|
30 |
-
// | Author: Ryan T. Dean <rtdean@cytherianage.net> |
|
31 |
-
// | Heavily influenced by the Perl memcached client by Brad Fitzpatrick. |
|
32 |
-
// | Permission granted by Brad Fitzpatrick for relicense of ported Perl |
|
33 |
-
// | client logic under 2-clause BSD license. |
|
34 |
-
// +---------------------------------------------------------------------------+
|
35 |
-
//
|
36 |
-
// $TCAnet$
|
37 |
-
//
|
38 |
-
|
39 |
-
/**
|
40 |
-
* This is the PHP client for memcached - a distributed memory cache daemon.
|
41 |
-
* More information is available at http://www.danga.com/memcached/
|
42 |
-
*
|
43 |
-
* Usage example:
|
44 |
-
*
|
45 |
-
* require_once 'memcached.php';
|
46 |
-
*
|
47 |
-
* $mc = new memcached(array(
|
48 |
-
* 'servers' => array('127.0.0.1:10000',
|
49 |
-
* array('192.0.0.1:10010', 2),
|
50 |
-
* '127.0.0.1:10020'),
|
51 |
-
* 'debug' => false,
|
52 |
-
* 'compress_threshold' => 10240,
|
53 |
-
* 'persistant' => true));
|
54 |
-
*
|
55 |
-
* $mc->add('key', array('some', 'array'));
|
56 |
-
* $mc->replace('key', 'some random string');
|
57 |
-
* $val = $mc->get('key');
|
58 |
-
*
|
59 |
-
* @author Ryan T. Dean <rtdean@cytherianage.net>
|
60 |
-
* @package memcached-client
|
61 |
-
* @version 0.1.2
|
62 |
-
*/
|
63 |
-
|
64 |
-
// {{{ requirements
|
65 |
-
// }}}
|
66 |
-
|
67 |
-
// {{{ constants
|
68 |
-
// {{{ flags
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Flag: indicates data is serialized
|
72 |
-
*/
|
73 |
-
if (! defined("MEMCACHE_SERIALIZED")) {
|
74 |
-
define("MEMCACHE_SERIALIZED", 1<<0);
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Flag: indicates data is compressed
|
79 |
-
*/
|
80 |
-
if (! defined("MEMCACHE_COMPRESSED")) {
|
81 |
-
define("MEMCACHE_COMPRESSED", 1<<1);
|
82 |
-
}
|
83 |
-
|
84 |
-
// }}}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Minimum savings to store data compressed
|
88 |
-
*/
|
89 |
-
if (! defined("COMPRESSION_SAVINGS")) {
|
90 |
-
define("COMPRESSION_SAVINGS", 0.20);
|
91 |
-
}
|
92 |
-
|
93 |
-
// }}}
|
94 |
-
|
95 |
-
// {{{ class memcached
|
96 |
-
/**
|
97 |
-
* memcached client class implemented using (p)fsockopen()
|
98 |
-
*
|
99 |
-
* @author Ryan T. Dean <rtdean@cytherianage.net>
|
100 |
-
* @package memcached-client
|
101 |
-
*/
|
102 |
-
class memcached_client
|
103 |
-
{
|
104 |
-
// {{{ properties
|
105 |
-
// {{{ public
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Command statistics
|
109 |
-
*
|
110 |
-
* @var array
|
111 |
-
* @access public
|
112 |
-
*/
|
113 |
-
var $stats;
|
114 |
-
|
115 |
-
// }}}
|
116 |
-
// {{{ private
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Cached Sockets that are connected
|
120 |
-
*
|
121 |
-
* @var array
|
122 |
-
* @access private
|
123 |
-
*/
|
124 |
-
var $_cache_sock;
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Current debug status; 0 - none to 9 - profiling
|
128 |
-
*
|
129 |
-
* @var boolean
|
130 |
-
* @access private
|
131 |
-
*/
|
132 |
-
var $_debug;
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Dead hosts, assoc array, 'host'=>'unixtime when ok to check again'
|
136 |
-
*
|
137 |
-
* @var array
|
138 |
-
* @access private
|
139 |
-
*/
|
140 |
-
var $_host_dead;
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Is compression available?
|
144 |
-
*
|
145 |
-
* @var boolean
|
146 |
-
* @access private
|
147 |
-
*/
|
148 |
-
var $_have_zlib;
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Do we want to use compression?
|
152 |
-
*
|
153 |
-
* @var boolean
|
154 |
-
* @access private
|
155 |
-
*/
|
156 |
-
var $_compress_enable;
|
157 |
-
|
158 |
-
/**
|
159 |
-
* At how many bytes should we compress?
|
160 |
-
*
|
161 |
-
* @var interger
|
162 |
-
* @access private
|
163 |
-
*/
|
164 |
-
var $_compress_threshold;
|
165 |
-
|
166 |
-
/**
|
167 |
-
* Are we using persistant links?
|
168 |
-
*
|
169 |
-
* @var boolean
|
170 |
-
* @access private
|
171 |
-
*/
|
172 |
-
var $_persistant;
|
173 |
-
|
174 |
-
/**
|
175 |
-
* If only using one server; contains ip:port to connect to
|
176 |
-
*
|
177 |
-
* @var string
|
178 |
-
* @access private
|
179 |
-
*/
|
180 |
-
var $_single_sock;
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Array containing ip:port or array(ip:port, weight)
|
184 |
-
*
|
185 |
-
* @var array
|
186 |
-
* @access private
|
187 |
-
*/
|
188 |
-
var $_servers;
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Our bit buckets
|
192 |
-
*
|
193 |
-
* @var array
|
194 |
-
* @access private
|
195 |
-
*/
|
196 |
-
var $_buckets;
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Total # of bit buckets we have
|
200 |
-
*
|
201 |
-
* @var interger
|
202 |
-
* @access private
|
203 |
-
*/
|
204 |
-
var $_bucketcount;
|
205 |
-
|
206 |
-
/**
|
207 |
-
* # of total servers we have
|
208 |
-
*
|
209 |
-
* @var interger
|
210 |
-
* @access private
|
211 |
-
*/
|
212 |
-
var $_active;
|
213 |
-
|
214 |
-
// }}}
|
215 |
-
// }}}
|
216 |
-
// {{{ methods
|
217 |
-
// {{{ public functions
|
218 |
-
// {{{ memcached()
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Memcache initializer
|
222 |
-
*
|
223 |
-
* @param array $args Associative array of settings
|
224 |
-
*
|
225 |
-
* @return mixed
|
226 |
-
* @access public
|
227 |
-
*/
|
228 |
-
function memcached_client ($args)
|
229 |
-
{
|
230 |
-
$this->set_servers($args['servers']);
|
231 |
-
$this->_debug = $args['debug'];
|
232 |
-
$this->stats = array();
|
233 |
-
$this->_compress_threshold = $args['compress_threshold'];
|
234 |
-
$this->_persistant = isset($args['persistant']) ? $args['persistant'] : false;
|
235 |
-
$this->_compress_enable = true;
|
236 |
-
$this->_have_zlib = function_exists("gzcompress");
|
237 |
-
|
238 |
-
$this->_cache_sock = array();
|
239 |
-
$this->_host_dead = array();
|
240 |
-
}
|
241 |
-
|
242 |
-
// }}}
|
243 |
-
// {{{ add()
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Adds a key/value to the memcache server if one isn't already set with
|
247 |
-
* that key
|
248 |
-
*
|
249 |
-
* @param string $key Key to set with data
|
250 |
-
* @param mixed $val Value to store
|
251 |
-
* @param interger $exp (optional) Time to expire data at
|
252 |
-
*
|
253 |
-
* @return boolean
|
254 |
-
* @access public
|
255 |
-
*/
|
256 |
-
function add ($key, $val, $exp = 0)
|
257 |
-
{
|
258 |
-
return $this->_set('add', $key, $val, $exp);
|
259 |
-
}
|
260 |
-
|
261 |
-
// }}}
|
262 |
-
// {{{ decr()
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Decriment a value stored on the memcache server
|
266 |
-
*
|
267 |
-
* @param string $key Key to decriment
|
268 |
-
* @param interger $amt (optional) Amount to decriment
|
269 |
-
*
|
270 |
-
* @return mixed FALSE on failure, value on success
|
271 |
-
* @access public
|
272 |
-
*/
|
273 |
-
function decr ($key, $amt=1)
|
274 |
-
{
|
275 |
-
return $this->_incrdecr('decr', $key, $amt);
|
276 |
-
}
|
277 |
-
|
278 |
-
// }}}
|
279 |
-
// {{{ delete()
|
280 |
-
|
281 |
-
/**
|
282 |
-
* Deletes a key from the server, optionally after $time
|
283 |
-
*
|
284 |
-
* @param string $key Key to delete
|
285 |
-
* @param interger $time (optional) How long to wait before deleting
|
286 |
-
*
|
287 |
-
* @return boolean TRUE on success, FALSE on failure
|
288 |
-
* @access public
|
289 |
-
*/
|
290 |
-
function delete ($key, $time = 0)
|
291 |
-
{
|
292 |
-
if (!$this->_active)
|
293 |
-
return false;
|
294 |
-
|
295 |
-
$sock = $this->get_sock($key);
|
296 |
-
if (!is_resource($sock))
|
297 |
-
return false;
|
298 |
-
|
299 |
-
$key = is_array($key) ? $key[1] : $key;
|
300 |
-
|
301 |
-
$this->stats['delete']++;
|
302 |
-
$cmd = "delete $key $time\r\n";
|
303 |
-
if(!fwrite($sock, $cmd, strlen($cmd)))
|
304 |
-
{
|
305 |
-
$this->_dead_sock($sock);
|
306 |
-
return false;
|
307 |
-
}
|
308 |
-
$res = trim(fgets($sock));
|
309 |
-
|
310 |
-
if ($this->_debug)
|
311 |
-
printf("MemCache: delete %s (%s)\n", $key, $res);
|
312 |
-
|
313 |
-
if ($res == "DELETED")
|
314 |
-
return true;
|
315 |
-
return false;
|
316 |
-
}
|
317 |
-
|
318 |
-
// }}}
|
319 |
-
// {{{ disconnect_all()
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Disconnects all connected sockets
|
323 |
-
*
|
324 |
-
* @access public
|
325 |
-
*/
|
326 |
-
function disconnect_all ()
|
327 |
-
{
|
328 |
-
foreach ($this->_cache_sock as $sock)
|
329 |
-
fclose($sock);
|
330 |
-
|
331 |
-
$this->_cache_sock = array();
|
332 |
-
}
|
333 |
-
|
334 |
-
// }}}
|
335 |
-
// {{{ enable_compress()
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Enable / Disable compression
|
339 |
-
*
|
340 |
-
* @param boolean $enable TRUE to enable, FALSE to disable
|
341 |
-
*
|
342 |
-
* @access public
|
343 |
-
*/
|
344 |
-
function enable_compress ($enable)
|
345 |
-
{
|
346 |
-
$this->_compress_enable = $enable;
|
347 |
-
}
|
348 |
-
|
349 |
-
// }}}
|
350 |
-
// {{{ forget_dead_hosts()
|
351 |
-
|
352 |
-
/**
|
353 |
-
* Forget about all of the dead hosts
|
354 |
-
*
|
355 |
-
* @access public
|
356 |
-
*/
|
357 |
-
function forget_dead_hosts ()
|
358 |
-
{
|
359 |
-
$this->_host_dead = array();
|
360 |
-
}
|
361 |
-
|
362 |
-
// }}}
|
363 |
-
// {{{ get()
|
364 |
-
|
365 |
-
/**
|
366 |
-
* Retrieves the value associated with the key from the memcache server
|
367 |
-
*
|
368 |
-
* @param string $key Key to retrieve
|
369 |
-
*
|
370 |
-
* @return mixed
|
371 |
-
* @access public
|
372 |
-
*/
|
373 |
-
function get ($key)
|
374 |
-
{
|
375 |
-
if (!$this->_active)
|
376 |
-
return false;
|
377 |
-
|
378 |
-
$sock = $this->get_sock($key);
|
379 |
-
|
380 |
-
if (!is_resource($sock))
|
381 |
-
return false;
|
382 |
-
|
383 |
-
$this->stats['get']++;
|
384 |
-
|
385 |
-
$cmd = "get $key\r\n";
|
386 |
-
if (!fwrite($sock, $cmd, strlen($cmd)))
|
387 |
-
{
|
388 |
-
$this->_dead_sock($sock);
|
389 |
-
return false;
|
390 |
-
}
|
391 |
-
|
392 |
-
$val = array();
|
393 |
-
$this->_load_items($sock, $val);
|
394 |
-
|
395 |
-
if ($this->_debug)
|
396 |
-
foreach ($val as $k => $v)
|
397 |
-
printf("MemCache: sock %s got %s => %s\r\n", $sock, $k, $v);
|
398 |
-
|
399 |
-
return $val[$key];
|
400 |
-
}
|
401 |
-
|
402 |
-
// }}}
|
403 |
-
// {{{ get_multi()
|
404 |
-
|
405 |
-
/**
|
406 |
-
* Get multiple keys from the server(s)
|
407 |
-
*
|
408 |
-
* @param array $keys Keys to retrieve
|
409 |
-
*
|
410 |
-
* @return array
|
411 |
-
* @access public
|
412 |
-
*/
|
413 |
-
function get_multi ($keys)
|
414 |
-
{
|
415 |
-
if (!$this->_active)
|
416 |
-
return false;
|
417 |
-
|
418 |
-
$this->stats['get_multi']++;
|
419 |
-
|
420 |
-
foreach ($keys as $key)
|
421 |
-
{
|
422 |
-
$sock = $this->get_sock($key);
|
423 |
-
if (!is_resource($sock)) continue;
|
424 |
-
$key = is_array($key) ? $key[1] : $key;
|
425 |
-
if (!isset($sock_keys[$sock]))
|
426 |
-
{
|
427 |
-
$sock_keys[$sock] = array();
|
428 |
-
$socks[] = $sock;
|
429 |
-
}
|
430 |
-
$sock_keys[$sock][] = $key;
|
431 |
-
}
|
432 |
-
|
433 |
-
// Send out the requests
|
434 |
-
foreach ($socks as $sock)
|
435 |
-
{
|
436 |
-
$cmd = "get";
|
437 |
-
foreach ($sock_keys[$sock] as $key)
|
438 |
-
{
|
439 |
-
$cmd .= " ". $key;
|
440 |
-
}
|
441 |
-
$cmd .= "\r\n";
|
442 |
-
|
443 |
-
if (fwrite($sock, $cmd, strlen($cmd)))
|
444 |
-
{
|
445 |
-
$gather[] = $sock;
|
446 |
-
} else
|
447 |
-
{
|
448 |
-
$this->_dead_sock($sock);
|
449 |
-
}
|
450 |
-
}
|
451 |
-
|
452 |
-
// Parse responses
|
453 |
-
$val = array();
|
454 |
-
foreach ($gather as $sock)
|
455 |
-
{
|
456 |
-
$this->_load_items($sock, $val);
|
457 |
-
}
|
458 |
-
|
459 |
-
if ($this->_debug)
|
460 |
-
foreach ($val as $k => $v)
|
461 |
-
printf("MemCache: got %s => %s\r\n", $k, $v);
|
462 |
-
|
463 |
-
return $val;
|
464 |
-
}
|
465 |
-
|
466 |
-
// }}}
|
467 |
-
// {{{ incr()
|
468 |
-
|
469 |
-
/**
|
470 |
-
* Increments $key (optionally) by $amt
|
471 |
-
*
|
472 |
-
* @param string $key Key to increment
|
473 |
-
* @param interger $amt (optional) amount to increment
|
474 |
-
*
|
475 |
-
* @return interger New key value?
|
476 |
-
* @access public
|
477 |
-
*/
|
478 |
-
function incr ($key, $amt=1)
|
479 |
-
{
|
480 |
-
return $this->_incrdecr('incr', $key, $amt);
|
481 |
-
}
|
482 |
-
|
483 |
-
// }}}
|
484 |
-
// {{{ replace()
|
485 |
-
|
486 |
-
/**
|
487 |
-
* Overwrites an existing value for key; only works if key is already set
|
488 |
-
*
|
489 |
-
* @param string $key Key to set value as
|
490 |
-
* @param mixed $value Value to store
|
491 |
-
* @param interger $exp (optional) Experiation time
|
492 |
-
*
|
493 |
-
* @return boolean
|
494 |
-
* @access public
|
495 |
-
*/
|
496 |
-
function replace ($key, $value, $exp=0)
|
497 |
-
{
|
498 |
-
return $this->_set('replace', $key, $value, $exp);
|
499 |
-
}
|
500 |
-
|
501 |
-
// }}}
|
502 |
-
// {{{ run_command()
|
503 |
-
|
504 |
-
/**
|
505 |
-
* Passes through $cmd to the memcache server connected by $sock; returns
|
506 |
-
* output as an array (null array if no output)
|
507 |
-
*
|
508 |
-
* NOTE: due to a possible bug in how PHP reads while using fgets(), each
|
509 |
-
* line may not be terminated by a \r\n. More specifically, my testing
|
510 |
-
* has shown that, on FreeBSD at least, each line is terminated only
|
511 |
-
* with a \n. This is with the PHP flag auto_detect_line_endings set
|
512 |
-
* to falase (the default).
|
513 |
-
*
|
514 |
-
* @param resource $sock Socket to send command on
|
515 |
-
* @param string $cmd Command to run
|
516 |
-
*
|
517 |
-
* @return array Output array
|
518 |
-
* @access public
|
519 |
-
*/
|
520 |
-
function run_command ($sock, $cmd)
|
521 |
-
{
|
522 |
-
if (!is_resource($sock))
|
523 |
-
return array();
|
524 |
-
|
525 |
-
if (!fwrite($sock, $cmd, strlen($cmd)))
|
526 |
-
return array();
|
527 |
-
|
528 |
-
while (true)
|
529 |
-
{
|
530 |
-
$res = fgets($sock);
|
531 |
-
$ret[] = $res;
|
532 |
-
if (preg_match('/^END/', $res))
|
533 |
-
break;
|
534 |
-
if (strlen($res) == 0)
|
535 |
-
break;
|
536 |
-
}
|
537 |
-
return $ret;
|
538 |
-
}
|
539 |
-
|
540 |
-
// }}}
|
541 |
-
// {{{ set()
|
542 |
-
|
543 |
-
/**
|
544 |
-
* Unconditionally sets a key to a given value in the memcache. Returns true
|
545 |
-
* if set successfully.
|
546 |
-
*
|
547 |
-
* @param string $key Key to set value as
|
548 |
-
* @param mixed $value Value to set
|
549 |
-
* @param interger $exp (optional) Experiation time
|
550 |
-
*
|
551 |
-
* @return boolean TRUE on success
|
552 |
-
* @access public
|
553 |
-
*/
|
554 |
-
function set ($key, $value, $exp=0)
|
555 |
-
{
|
556 |
-
return $this->_set('set', $key, $value, $exp);
|
557 |
-
}
|
558 |
-
|
559 |
-
// }}}
|
560 |
-
// {{{ set_compress_threshold()
|
561 |
-
|
562 |
-
/**
|
563 |
-
* Sets the compression threshold
|
564 |
-
*
|
565 |
-
* @param interger $thresh Threshold to compress if larger than
|
566 |
-
*
|
567 |
-
* @access public
|
568 |
-
*/
|
569 |
-
function set_compress_threshold ($thresh)
|
570 |
-
{
|
571 |
-
$this->_compress_threshold = $thresh;
|
572 |
-
}
|
573 |
-
|
574 |
-
// }}}
|
575 |
-
// {{{ set_debug()
|
576 |
-
|
577 |
-
/**
|
578 |
-
* Sets the debug flag
|
579 |
-
*
|
580 |
-
* @param boolean $dbg TRUE for debugging, FALSE otherwise
|
581 |
-
*
|
582 |
-
* @access public
|
583 |
-
*
|
584 |
-
* @see memcahced::memcached
|
585 |
-
*/
|
586 |
-
function set_debug ($dbg)
|
587 |
-
{
|
588 |
-
$this->_debug = $dbg;
|
589 |
-
}
|
590 |
-
|
591 |
-
// }}}
|
592 |
-
// {{{ set_servers()
|
593 |
-
|
594 |
-
/**
|
595 |
-
* Sets the server list to distribute key gets and puts between
|
596 |
-
*
|
597 |
-
* @param array $list Array of servers to connect to
|
598 |
-
*
|
599 |
-
* @access public
|
600 |
-
*
|
601 |
-
* @see memcached::memcached()
|
602 |
-
*/
|
603 |
-
function set_servers ($list)
|
604 |
-
{
|
605 |
-
$this->_servers = $list;
|
606 |
-
$this->_active = count($list);
|
607 |
-
$this->_buckets = null;
|
608 |
-
$this->_bucketcount = 0;
|
609 |
-
|
610 |
-
$this->_single_sock = null;
|
611 |
-
if ($this->_active == 1)
|
612 |
-
$this->_single_sock = $this->_servers[0];
|
613 |
-
}
|
614 |
-
|
615 |
-
// }}}
|
616 |
-
// }}}
|
617 |
-
// {{{ private methods
|
618 |
-
// {{{ _close_sock()
|
619 |
-
|
620 |
-
/**
|
621 |
-
* Close the specified socket
|
622 |
-
*
|
623 |
-
* @param string $sock Socket to close
|
624 |
-
*
|
625 |
-
* @access private
|
626 |
-
*/
|
627 |
-
function _close_sock ($sock)
|
628 |
-
{
|
629 |
-
$host = array_search($sock, $this->_cache_sock);
|
630 |
-
fclose($this->_cache_sock[$host]);
|
631 |
-
unset($this->_cache_sock[$host]);
|
632 |
-
}
|
633 |
-
|
634 |
-
// }}}
|
635 |
-
// {{{ _connect_sock()
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Connects $sock to $host, timing out after $timeout
|
639 |
-
*
|
640 |
-
* @param interger $sock Socket to connect
|
641 |
-
* @param string $host Host:IP to connect to
|
642 |
-
* @param float $timeout (optional) Timeout value, defaults to 0.25s
|
643 |
-
*
|
644 |
-
* @return boolean
|
645 |
-
* @access private
|
646 |
-
*/
|
647 |
-
function _connect_sock (&$sock, $host, $timeout = 0.25)
|
648 |
-
{
|
649 |
-
list ($ip, $port) = explode(":", $host);
|
650 |
-
if ($this->_persistant == 1)
|
651 |
-
{
|
652 |
-
$sock = @pfsockopen($ip, $port, $errno, $errstr, $timeout);
|
653 |
-
} else
|
654 |
-
{
|
655 |
-
$sock = @fsockopen($ip, $port, $errno, $errstr, $timeout);
|
656 |
-
}
|
657 |
-
|
658 |
-
if (!$sock)
|
659 |
-
return false;
|
660 |
-
return true;
|
661 |
-
}
|
662 |
-
|
663 |
-
// }}}
|
664 |
-
// {{{ _dead_sock()
|
665 |
-
|
666 |
-
/**
|
667 |
-
* Marks a host as dead until 30-40 seconds in the future
|
668 |
-
*
|
669 |
-
* @param string $sock Socket to mark as dead
|
670 |
-
*
|
671 |
-
* @access private
|
672 |
-
*/
|
673 |
-
function _dead_sock ($sock)
|
674 |
-
{
|
675 |
-
$host = array_search($sock, $this->_cache_sock);
|
676 |
-
list ($ip, $port) = explode(":", $host);
|
677 |
-
$this->_host_dead[$ip] = time() + 30 + intval(rand(0, 10));
|
678 |
-
$this->_host_dead[$host] = $this->_host_dead[$ip];
|
679 |
-
unset($this->_cache_sock[$host]);
|
680 |
-
}
|
681 |
-
|
682 |
-
// }}}
|
683 |
-
// {{{ get_sock()
|
684 |
-
|
685 |
-
/**
|
686 |
-
* get_sock
|
687 |
-
*
|
688 |
-
* @param string $key Key to retrieve value for;
|
689 |
-
*
|
690 |
-
* @return mixed resource on success, false on failure
|
691 |
-
* @access private
|
692 |
-
*/
|
693 |
-
function get_sock ($key)
|
694 |
-
{
|
695 |
-
if (!$this->_active)
|
696 |
-
return false;
|
697 |
-
|
698 |
-
if ($this->_single_sock !== null)
|
699 |
-
return $this->sock_to_host($this->_single_sock);
|
700 |
-
|
701 |
-
$hv = is_array($key) ? intval($key[0]) : $this->_hashfunc($key);
|
702 |
-
|
703 |
-
if ($this->_buckets === null)
|
704 |
-
{
|
705 |
-
foreach ($this->_servers as $v)
|
706 |
-
{
|
707 |
-
if (is_array($v))
|
708 |
-
{
|
709 |
-
for ($i=0; $i<$v[1]; $i++)
|
710 |
-
$bu[] = $v[0];
|
711 |
-
} else
|
712 |
-
{
|
713 |
-
$bu[] = $v;
|
714 |
-
}
|
715 |
-
}
|
716 |
-
$this->_buckets = $bu;
|
717 |
-
$this->_bucketcount = count($bu);
|
718 |
-
}
|
719 |
-
|
720 |
-
$realkey = is_array($key) ? $key[1] : $key;
|
721 |
-
for ($tries = 0; $tries<20; $tries++)
|
722 |
-
{
|
723 |
-
$host = $this->_buckets[$hv % $this->_bucketcount];
|
724 |
-
$sock = $this->sock_to_host($host);
|
725 |
-
if (is_resource($sock))
|
726 |
-
return $sock;
|
727 |
-
$hv += $this->_hashfunc($tries . $realkey);
|
728 |
-
}
|
729 |
-
|
730 |
-
return false;
|
731 |
-
}
|
732 |
-
|
733 |
-
// }}}
|
734 |
-
// {{{ _hashfunc()
|
735 |
-
|
736 |
-
/**
|
737 |
-
* Creates a hash interger based on the $key
|
738 |
-
*
|
739 |
-
* @param string $key Key to hash
|
740 |
-
*
|
741 |
-
* @return interger Hash value
|
742 |
-
* @access private
|
743 |
-
*/
|
744 |
-
function _hashfunc ($key)
|
745 |
-
{
|
746 |
-
$hash = 0;
|
747 |
-
for ($i=0; $i<strlen($key); $i++)
|
748 |
-
{
|
749 |
-
$hash = $hash*33 + ord($key[$i]);
|
750 |
-
}
|
751 |
-
|
752 |
-
return $hash;
|
753 |
-
}
|
754 |
-
|
755 |
-
// }}}
|
756 |
-
// {{{ _incrdecr()
|
757 |
-
|
758 |
-
/**
|
759 |
-
* Perform increment/decriment on $key
|
760 |
-
*
|
761 |
-
* @param string $cmd Command to perform
|
762 |
-
* @param string $key Key to perform it on
|
763 |
-
* @param interger $amt Amount to adjust
|
764 |
-
*
|
765 |
-
* @return interger New value of $key
|
766 |
-
* @access private
|
767 |
-
*/
|
768 |
-
function _incrdecr ($cmd, $key, $amt=1)
|
769 |
-
{
|
770 |
-
if (!$this->_active)
|
771 |
-
return null;
|
772 |
-
|
773 |
-
$sock = $this->get_sock($key);
|
774 |
-
if (!is_resource($sock))
|
775 |
-
return null;
|
776 |
-
|
777 |
-
$key = is_array($key) ? $key[1] : $key;
|
778 |
-
$this->stats[$cmd]++;
|
779 |
-
if (!fwrite($sock, "$cmd $key $amt\r\n"))
|
780 |
-
return $this->_dead_sock($sock);
|
781 |
-
|
782 |
-
stream_set_timeout($sock, 1, 0);
|
783 |
-
$line = fgets($sock);
|
784 |
-
if (!preg_match('/^(\d+)/', $line, $match))
|
785 |
-
return null;
|
786 |
-
return $match[1];
|
787 |
-
}
|
788 |
-
|
789 |
-
// }}}
|
790 |
-
// {{{ _load_items()
|
791 |
-
|
792 |
-
/**
|
793 |
-
* Load items into $ret from $sock
|
794 |
-
*
|
795 |
-
* @param resource $sock Socket to read from
|
796 |
-
* @param array $ret Returned values
|
797 |
-
*
|
798 |
-
* @access private
|
799 |
-
*/
|
800 |
-
function _load_items ($sock, &$ret)
|
801 |
-
{
|
802 |
-
while (1)
|
803 |
-
{
|
804 |
-
$decl = fgets($sock);
|
805 |
-
if ($decl == "END\r\n")
|
806 |
-
{
|
807 |
-
return true;
|
808 |
-
} elseif (preg_match('/^VALUE (\S+) (\d+) (\d+)\r\n$/', $decl, $match))
|
809 |
-
{
|
810 |
-
list($rkey, $flags, $len) = array($match[1], $match[2], $match[3]);
|
811 |
-
$bneed = $len+2;
|
812 |
-
$offset = 0;
|
813 |
-
|
814 |
-
while ($bneed > 0)
|
815 |
-
{
|
816 |
-
$data = fread($sock, $bneed);
|
817 |
-
$n = strlen($data);
|
818 |
-
if ($n == 0)
|
819 |
-
break;
|
820 |
-
$offset += $n;
|
821 |
-
$bneed -= $n;
|
822 |
-
$ret[$rkey] .= $data;
|
823 |
-
}
|
824 |
-
|
825 |
-
if ($offset != $len+2)
|
826 |
-
{
|
827 |
-
// Something is borked!
|
828 |
-
if ($this->_debug)
|
829 |
-
printf("Something is borked! key %s expecting %d got %d length\n", $rkey, $len+2, $offset);
|
830 |
-
|
831 |
-
unset($ret[$rkey]);
|
832 |
-
$this->_close_sock($sock);
|
833 |
-
return false;
|
834 |
-
}
|
835 |
-
|
836 |
-
//$ret[$rkey] = rtrim($ret[$rkey]); buggy
|
837 |
-
$ret[$rkey] = substr($ret[$rkey], 0, -2);
|
838 |
-
|
839 |
-
if ($this->_have_zlib && $flags & MEMCACHE_COMPRESSED) {
|
840 |
-
$ret[$rkey] = gzuncompress($ret[$rkey]);
|
841 |
-
}
|
842 |
-
|
843 |
-
if ($flags & MEMCACHE_SERIALIZED)
|
844 |
-
$ret[$rkey] = unserialize($ret[$rkey]);
|
845 |
-
|
846 |
-
} else
|
847 |
-
{
|
848 |
-
print("Error parsing memcached response\n");
|
849 |
-
return 0;
|
850 |
-
}
|
851 |
-
}
|
852 |
-
}
|
853 |
-
|
854 |
-
// }}}
|
855 |
-
// {{{ _set()
|
856 |
-
|
857 |
-
/**
|
858 |
-
* Performs the requested storage operation to the memcache server
|
859 |
-
*
|
860 |
-
* @param string $cmd Command to perform
|
861 |
-
* @param string $key Key to act on
|
862 |
-
* @param mixed $val What we need to store
|
863 |
-
* @param interger $exp When it should expire
|
864 |
-
*
|
865 |
-
* @return boolean
|
866 |
-
* @access private
|
867 |
-
*/
|
868 |
-
function _set ($cmd, $key, $val, $exp)
|
869 |
-
{
|
870 |
-
if (!$this->_active)
|
871 |
-
return false;
|
872 |
-
|
873 |
-
$sock = $this->get_sock($key);
|
874 |
-
if (!is_resource($sock))
|
875 |
-
return false;
|
876 |
-
|
877 |
-
$this->stats[$cmd]++;
|
878 |
-
|
879 |
-
$flags = 0;
|
880 |
-
|
881 |
-
if (!is_scalar($val))
|
882 |
-
{
|
883 |
-
$val = serialize($val);
|
884 |
-
$flags |= MEMCACHE_SERIALIZED;
|
885 |
-
if ($this->_debug)
|
886 |
-
printf("client: serializing data as it is not scalar\n");
|
887 |
-
}
|
888 |
-
|
889 |
-
$len = strlen($val);
|
890 |
-
|
891 |
-
if ($this->_have_zlib && $this->_compress_enable &&
|
892 |
-
$this->_compress_threshold && $len >= $this->_compress_threshold)
|
893 |
-
{
|
894 |
-
$c_val = gzcompress($val, 9);
|
895 |
-
$c_len = strlen($c_val);
|
896 |
-
|
897 |
-
if ($c_len < $len*(1 - COMPRESS_SAVINGS))
|
898 |
-
{
|
899 |
-
if ($this->_debug)
|
900 |
-
printf("client: compressing data; was %d bytes is now %d bytes\n", $len, $c_len);
|
901 |
-
$val = $c_val;
|
902 |
-
$len = $c_len;
|
903 |
-
$flags |= MEMCACHE_COMPRESSED;
|
904 |
-
}
|
905 |
-
}
|
906 |
-
if (!fwrite($sock, "$cmd $key $flags $exp $len\r\n$val\r\n"))
|
907 |
-
return $this->_dead_sock($sock);
|
908 |
-
|
909 |
-
$line = trim(fgets($sock));
|
910 |
-
|
911 |
-
if ($this->_debug)
|
912 |
-
{
|
913 |
-
if ($flags & MEMCACHE_COMPRESSED)
|
914 |
-
$val = 'compressed data';
|
915 |
-
printf("MemCache: %s %s => %s (%s)\n", $cmd, $key, $val, $line);
|
916 |
-
}
|
917 |
-
if ($line == "STORED")
|
918 |
-
return true;
|
919 |
-
return false;
|
920 |
-
}
|
921 |
-
|
922 |
-
// }}}
|
923 |
-
// {{{ sock_to_host()
|
924 |
-
|
925 |
-
/**
|
926 |
-
* Returns the socket for the host
|
927 |
-
*
|
928 |
-
* @param string $host Host:IP to get socket for
|
929 |
-
*
|
930 |
-
* @return mixed IO Stream or false
|
931 |
-
* @access private
|
932 |
-
*/
|
933 |
-
function sock_to_host ($host)
|
934 |
-
{
|
935 |
-
if (isset($this->_cache_sock[$host]))
|
936 |
-
return $this->_cache_sock[$host];
|
937 |
-
|
938 |
-
$now = time();
|
939 |
-
list ($ip, $port) = explode (":", $host);
|
940 |
-
if (isset($this->_host_dead[$host]) && $this->_host_dead[$host] > $now ||
|
941 |
-
isset($this->_host_dead[$ip]) && $this->_host_dead[$ip] > $now)
|
942 |
-
return null;
|
943 |
-
|
944 |
-
if (!$this->_connect_sock($sock, $host))
|
945 |
-
return $this->_dead_sock($host);
|
946 |
-
|
947 |
-
// Do not buffer writes
|
948 |
-
stream_set_write_buffer($sock, 0);
|
949 |
-
|
950 |
-
$this->_cache_sock[$host] = $sock;
|
951 |
-
|
952 |
-
return $this->_cache_sock[$host];
|
953 |
-
}
|
954 |
-
|
955 |
-
// }}}
|
956 |
-
// {{{ flush_all()
|
957 |
-
|
958 |
-
/**
|
959 |
-
* Flushes all memcached data
|
960 |
-
*
|
961 |
-
* @return boolean
|
962 |
-
* @access public
|
963 |
-
*/
|
964 |
-
function flush_all()
|
965 |
-
{
|
966 |
-
foreach ($this->_cache_sock as $sock) {
|
967 |
-
$this->run_command($sock, "flush_all\r\n");
|
968 |
-
}
|
969 |
-
}
|
970 |
-
|
971 |
-
// }}}
|
972 |
-
// }}}
|
973 |
-
// }}}
|
974 |
-
}
|
975 |
-
|
976 |
-
// }}}
|
977 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,36 +1,36 @@
|
|
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, performance, speed, multiple hosts, CSS, merge, combine, unobtrusive javascript, compress, optimize, optimizer, JavaScript, JS, cascading style sheet, plugin, yslow, YUI, google, google rank, google page speed, S3, CloudFront, AWS, Amazon Web Services, batcache, wp cache, wp super cache, w3 total cache
|
4 |
-
Requires at least: 2.
|
5 |
Tested up to: 2.9.1
|
6 |
-
Stable tag: 0.8.5.
|
7 |
|
8 |
-
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
The fastest and most complete WordPress performance optimization plugin. Trusted by many popular
|
13 |
|
14 |
Benefits:
|
15 |
|
16 |
-
* At least 10x improvement in overall site performance (when fully configured: Grade A in [YSlow](http://developer.yahoo.com/yslow/) or significant [Google Page Speed](http://code.google.com/speed/page-speed/)
|
17 |
-
* Improves "[site performance](http://googlewebmastercentral.blogspot.com/2009/12/your-sites-performance-in-webmaster.html)" which [
|
18 |
* "Instant" second page views (browser caching after first page view)
|
19 |
* Reduced page load time: increased visitor time on site (visitors view more pages)
|
20 |
* Optimized progressive render (pages appear to render immediately)
|
21 |
-
* Improved web server performance (
|
22 |
-
* Up to 80%
|
23 |
|
24 |
Features:
|
25 |
|
26 |
-
* Compatible with shared hosting, virtual private servers and dedicated servers / clusters
|
27 |
* Transparent content delivery network (CDN) integration with Media Library, theme files and WordPress itself
|
28 |
* Caching of (minified and compressed) pages and posts in memory or on disk
|
29 |
* Caching of (minified and compressed) CSS and JavaScript in memory, on disk or on CDN
|
30 |
-
* Caching of
|
31 |
* Caching of search results pages (i.e. URIs with query string variables) in memory or on disk
|
32 |
-
* Caching of database objects in memory
|
33 |
-
* Minification of posts and pages and
|
34 |
* Minification (combine and remove comments / white space) of inline, embedded or 3rd party JavaScript (with automated updates)
|
35 |
* Minification (combine and remove comments / white space) of inline, embedded or 3rd party CSS (with automated updates)
|
36 |
* Browser caching of CSS, JavaScript and HTML using future expire headers and entity tags (ETag)
|
@@ -38,29 +38,31 @@ Features:
|
|
38 |
* Non-blocking JavaScript embedding
|
39 |
* Import post attachments directly into the Media Library (and CDN)
|
40 |
|
41 |
-
|
42 |
|
43 |
== Frequently Asked Questions ==
|
44 |
|
45 |
= Why does speed matter? =
|
46 |
|
47 |
-
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
|
48 |
|
49 |
-
* Google.com:
|
50 |
-
* Yahoo.com:
|
51 |
-
* Amazon.com:
|
52 |
|
53 |
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.
|
54 |
|
55 |
-
In the near future search engines
|
56 |
|
57 |
= Why is W3 Total Cache better than other cache plugins? =
|
58 |
|
59 |
-
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.
|
60 |
|
61 |
= I've never heard of any of this stuff; my blog is fine, no one complains about the speed. Why should I install this? =
|
62 |
|
63 |
-
Rarely do readers take the time to complain. They typically just stop browsing earlier than you'd prefer and may not return altogether.
|
|
|
|
|
64 |
|
65 |
= And how many years of university do I need to use this thing? =
|
66 |
|
@@ -68,7 +70,11 @@ Rarely do readers take the time to complain. They typically just stop browsing e
|
|
68 |
|
69 |
= Which WordPress versions are supported? =
|
70 |
|
71 |
-
To use all features in the suite, a minimum of version WordPress 2.
|
|
|
|
|
|
|
|
|
72 |
|
73 |
= Will the plugin interfere with other plugins or widgets? =
|
74 |
|
@@ -80,86 +86,104 @@ Indeed it does.
|
|
80 |
|
81 |
= Does this plugin work with BuddyPress (bbPress)? =
|
82 |
|
83 |
-
|
84 |
|
85 |
-
=
|
86 |
|
87 |
-
|
88 |
|
89 |
-
=
|
90 |
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
* [Rackspace Cloud Files](http://www.rackspacecloud.com/cloud_hosting_products/files)
|
95 |
-
* [Cotendo](http://www.cotendo.com/)
|
96 |
-
* [VPS NET](https://vps.net/cdn-signup)
|
97 |
-
* [Amazon S3](http://aws.amazon.com/s3/) & [Amazon Cloudfront](http://aws.amazon.com/cloudfront/)
|
98 |
-
* [NetDNA](http://www.netdna.com/)
|
99 |
-
* [EdgeCast](http://www.edgecast.com/)
|
100 |
-
* [Akamai](http://www.akamai.com/)
|
101 |
-
* [Limelight Networks](http://www.limelightnetworks.com/)
|
102 |
-
* [SimpleCDN](http://www.simplecdn.com/)
|
103 |
-
* [Voxel](http://www.voxel.net/products-services/voxcast-cdn)
|
104 |
|
105 |
-
|
106 |
|
107 |
-
|
108 |
|
109 |
-
|
110 |
|
111 |
-
|
112 |
|
113 |
-
|
114 |
|
115 |
-
= How do I
|
116 |
-
Login to your CDN providers control panel or account management area. Following any set up steps they provide, create a new "pull zone" or "bucket" for your site's domain name. If there's a set up wizard or any troubleshooting tips your provider offers, be sure to review them. In the CDN Settings tab of the plugin, enter the hostname your CDN provider provided in the "replace default hostname with" field. You should always do a quick check by opening a test file from the CDN hostname, e.g. http://cdn.domain.com/favicon.ico. Troubleshoot with yoru CDN provider until this test is successful.
|
117 |
|
118 |
-
|
119 |
|
120 |
-
|
121 |
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
= I don't understand what a CDN has to do with caching, that's completely different, no? =
|
125 |
|
126 |
Technically no, a CDN is a high performance cache that stores static assets (your theme files, media library etc) in various locations throughout the world in order to provide low latency access to them by readers in those regions. So indeed a CDN is a high performance cache, many of which actually store your frequently requested assets in memory for fastest possible response.
|
127 |
|
128 |
-
=
|
129 |
|
130 |
-
You
|
131 |
|
132 |
-
=
|
133 |
|
134 |
-
|
135 |
|
136 |
-
|
137 |
|
138 |
-
|
139 |
|
140 |
-
|
141 |
|
142 |
-
|
|
|
143 |
|
144 |
-
|
145 |
|
146 |
-
|
|
|
147 |
|
148 |
-
|
|
|
|
|
|
|
149 |
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
= Is this plugin comptatible with GD Star Rating? =
|
153 |
|
154 |
Yes. Follow these steps:
|
155 |
|
156 |
1. Enable dynamic loading of ratings by checking GD Star Rating -> Settings -> Features "Cache support option"
|
157 |
-
1. If Database cache enabled in W3 Total Cache add
|
158 |
1. Empty all caches
|
159 |
|
160 |
= I see garbage characters instead of the normal web site, what's going on here? =
|
161 |
|
162 |
-
If a theme or it's files use the call php_flush() or function flush() that will interfere with the plugins normal operation; making the plugin send cached files before essential operations have finished. The flush() call is no longer necessary and should be removed.
|
163 |
|
164 |
= How do I cache only the home page? =
|
165 |
|
@@ -169,22 +193,6 @@ Add `/.+` to page cache "Never cache the following pages" option on the page cac
|
|
169 |
|
170 |
First, make sure the plugin is not active (disabled) site-wide. Then make sure it's deactivated site-wide. Now you should be able to successful upgrade without breaking your site.
|
171 |
|
172 |
-
= What is the purpose of the "Media Library Import" tool and how do I use it? =
|
173 |
-
|
174 |
-
The media library import tool is for old or "messy" WordPress installations that have attachments (images etc in posts or pages) scattered about the web server or "hot linked" to 3rd party sites instead of properly using the media library.
|
175 |
-
|
176 |
-
The tool will scan your posts and pages for the cases above and copy them to your media library, update your posts to use the link addresses and produce a .htaccess file containing the list of of permanent redirects, so search engines can find the files in their new location.
|
177 |
-
|
178 |
-
You should backup your database before performing this operation.
|
179 |
-
|
180 |
-
= How do I find the JS and CSS to optimize (minify) them with this plugin? =
|
181 |
-
|
182 |
-
View your page source in your browser and search for any `<style>`, `<link>` or `<script>` tags that contain external CSS or JS files and one by one add them to the minify settings page. Do not include any CSS in conditional statements (unless you know what you are doing) like:
|
183 |
-
|
184 |
-
`<!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="/wp-content/themes/default/lte.css" media="screen,projection" /><![endif]-->`
|
185 |
-
|
186 |
-
The plugin will concatenate, minify, HTTP compress and check for updates to these files automatically from now on. If you have any CSS or JS that are inline consider making them external files so that you can use them with minify.
|
187 |
-
|
188 |
= This is too good to be true, how can I test the results? =
|
189 |
You will be able to see it instantly on each page load, but for tangible metrics, consider the following tools:
|
190 |
|
@@ -199,23 +207,81 @@ You will be able to see it instantly on each page load, but for tangible metrics
|
|
199 |
* [Web Caching Tests](http://www.procata.com/cachetest/)
|
200 |
* [Port80 Compression Check (minify requires MSIE6 support to be enabled)](http://www.port80software.com/tools/compresscheck.asp)
|
201 |
* [A simple online web page compression / deflate / gzip test tool](http://www.gidnetwork.com/tools/gzip-test.php)
|
202 |
-
|
|
|
|
|
|
|
203 |
|
204 |
Install the plugin to read the full FAQ.
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
== Installation ==
|
207 |
|
208 |
-
1.
|
209 |
-
1. Login as an administrator to your WordPress Admin account. Using the "Add New" menu
|
210 |
-
1.
|
211 |
-
1. Locate and activate the plugin on the "Plugins" page. Page and database caching will now automatically be running with their default settings. Set the permissions of wp-content back to 755, e.g.: `# chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/`
|
212 |
1. Now click the "Settings" link to proceed to the "General Settings" tab and select your caching methods for page, database and minify. In most cases, "disk enhanced" mode for page cache, "disk" mode for minify and "disk" mode for database caching are "good" settings.
|
213 |
-
1. Optional
|
214 |
-
1. Optional
|
|
|
215 |
1. You're done! Get back to blogging!
|
216 |
|
217 |
== Changelog ==
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
= 0.8.5.1 =
|
220 |
* Added option to CDN Settings to skip specified directories
|
221 |
* Added option to allow for full control of HTTP compression options for page cache (some WordPress installations have issues with deflate)
|
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, performance, speed, multiple hosts, CSS, merge, combine, unobtrusive javascript, compress, optimize, optimizer, JavaScript, JS, cascading style sheet, plugin, yslow, YUI, google, google rank, google page speed, S3, CloudFront, AWS, Amazon Web Services, batcache, wp cache, wp super cache, w3 total cache, buddypress
|
4 |
+
Requires at least: 2.6
|
5 |
Tested up to: 2.9.1
|
6 |
+
Stable tag: 0.8.5.2
|
7 |
|
8 |
+
Improve the speed and user experience of your site. Add page caching, database caching, minify and content delivery network and more to WordPress.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
The fastest and most complete WordPress performance optimization plugin. Trusted by many popular sites like: mashable.com, smashingmagazine.com, makeuseof.com, kiss925.com, lockergnome.com, tutsplus.com, johnchow.com, ilovetypography.com, webdesignerdepot.com, pearsonified.com, css-tricks.com, yoast.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 overall site performance (when fully configured: Grade A in [YSlow](http://developer.yahoo.com/yslow/) or significant [Google Page Speed](http://code.google.com/speed/page-speed/) improvements)
|
17 |
+
* Improves "[site performance](http://googlewebmastercentral.blogspot.com/2009/12/your-sites-performance-in-webmaster.html)" which [affect your site's rank](http://searchengineland.com/site-speed-googles-next-ranking-factor-29793) on Google.com
|
18 |
* "Instant" second page views (browser caching after first page view)
|
19 |
* Reduced page load time: increased visitor time on site (visitors view more pages)
|
20 |
* Optimized progressive render (pages appear to render immediately)
|
21 |
+
* Improved web server performance (sustain high traffic spikes)
|
22 |
+
* Up to 80% bandwidth savings via minify and HTTP compression of HTML, CSS, JavaScript and feeds
|
23 |
|
24 |
Features:
|
25 |
|
26 |
+
* Compatible with shared hosting, virtual private / dedicated servers and dedicated servers / clusters
|
27 |
* Transparent content delivery network (CDN) integration with Media Library, theme files and WordPress itself
|
28 |
* Caching of (minified and compressed) pages and posts in memory or on disk
|
29 |
* Caching of (minified and compressed) CSS and JavaScript in memory, on disk or on CDN
|
30 |
+
* Caching of feeds (site, categories, tags, comments) in memory or on disk
|
31 |
* Caching of search results pages (i.e. URIs with query string variables) in memory or on disk
|
32 |
+
* Caching of database objects in memory or disk
|
33 |
+
* Minification of posts and pages and feeds
|
34 |
* Minification (combine and remove comments / white space) of inline, embedded or 3rd party JavaScript (with automated updates)
|
35 |
* Minification (combine and remove comments / white space) of inline, embedded or 3rd party CSS (with automated updates)
|
36 |
* Browser caching of CSS, JavaScript and HTML using future expire headers and entity tags (ETag)
|
38 |
* Non-blocking JavaScript embedding
|
39 |
* Import post attachments directly into the Media Library (and CDN)
|
40 |
|
41 |
+
Improve the user experience for your readers without having to change WordPress, your theme, your plugins or how you produce your content.
|
42 |
|
43 |
== Frequently Asked Questions ==
|
44 |
|
45 |
= Why does speed matter? =
|
46 |
|
47 |
+
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 research and uncovered the following:
|
48 |
|
49 |
+
* Google.com: **+500 ms** (speed decrease) -> **-20% traffic loss** [[1](http://home.blarg.net/~glinden/StanfordDataMining.2006-11-29.ppt)]
|
50 |
+
* 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)]
|
51 |
+
* Amazon.com: **+100 ms** (speed decrease) -> **-1% sales loss** [[1](http://home.blarg.net/~glinden/StanfordDataMining.2006-11-29.ppt)]
|
52 |
|
53 |
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.
|
54 |
|
55 |
+
In the near future, search engines will weigh the performance of web sites as factors in their ranking algorithms. Search engine's have the goal of providing users with the best user experience, so speed is definitely a concern.
|
56 |
|
57 |
= Why is W3 Total Cache better than other cache plugins? =
|
58 |
|
59 |
+
**It's complete.** 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. Most importantly, it's the only plugin designed to optimize all practical hosting environments. The options are many and setup is easy.
|
60 |
|
61 |
= I've never heard of any of this stuff; my blog is fine, no one complains about the speed. Why should I install this? =
|
62 |
|
63 |
+
Rarely do readers take the time to complain. They typically just stop browsing earlier than you'd prefer and may not return altogether. This is the only plugin specifically designed to make sure that all aspects of your site are as fast as possible. Google is placing more emphasis on the [speed of a site as a factor in rankings](http://searchengineland.com/site-speed-googles-next-ranking-factor-29793); this plugin helps with that too.
|
64 |
+
|
65 |
+
It's in every web site owner's best interest is to make sure that the performance of your blog is not hindering its success.
|
66 |
|
67 |
= And how many years of university do I need to use this thing? =
|
68 |
|
70 |
|
71 |
= Which WordPress versions are supported? =
|
72 |
|
73 |
+
To use all features in the suite, a minimum of version WordPress 2.6 with PHP 5 is required. Earlier versions will benefit from our Media Library Importer to get them back on the upgrade path and into a CDN of their choosing.
|
74 |
+
|
75 |
+
= What about comments? Does the plugin slow down the rate at which comments appear? =
|
76 |
+
|
77 |
+
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.
|
78 |
|
79 |
= Will the plugin interfere with other plugins or widgets? =
|
80 |
|
86 |
|
87 |
= Does this plugin work with BuddyPress (bbPress)? =
|
88 |
|
89 |
+
Yes.
|
90 |
|
91 |
+
= Will this plugin speed up WP Admin? =
|
92 |
|
93 |
+
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.
|
94 |
|
95 |
+
= Which web servers do you support? =
|
96 |
|
97 |
+
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](http://www.w3-edge.com/contact/).
|
98 |
|
99 |
+
= Is this plugin server cluster and load balancer friendly? =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
+
Yes, built from the ground up with scale and current hosting paradigms in mind.
|
102 |
|
103 |
+
= What is the purpose of the "Media Library Import" tool and how do I use it? =
|
104 |
|
105 |
+
The media library import tool is for old or "messy" WordPress installations that have attachments (images etc in posts or pages) scattered about the web server or "hot linked" to 3rd party sites instead of properly using the media library.
|
106 |
|
107 |
+
The tool will scan your posts and pages for the cases above and copy them to your media library, update your posts to use the link addresses and produce a .htaccess file containing the list of of permanent redirects, so search engines can find the files in their new location.
|
108 |
|
109 |
+
You should backup your database before performing this operation.
|
110 |
|
111 |
+
= How do I find the JS and CSS to optimize (minify) them with this plugin? =
|
|
|
112 |
|
113 |
+
View your page source in your browser and search for any `<style>`, `<link>` or `<script>` tags that contain external CSS or JS files and one by one add them to the minify settings page. Do not include any CSS in conditional statements (unless you know what you are doing) like:
|
114 |
|
115 |
+
`<!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="/wp-content/themes/default/lte.css" media="screen,projection" /><![endif]-->`
|
116 |
|
117 |
+
The plugin will combine, minify, HTTP compress and check for updates to these files automatically from now on. If you have any CSS or JS that are inline consider making them external files so that you can use them with minify.
|
118 |
+
|
119 |
+
= Who do you recommend as a CDN (Content Delivery Network) provider? =
|
120 |
+
|
121 |
+
That depends on how you use your blog and where most of your readers read your blog (regionally). Here's a short list:
|
122 |
+
|
123 |
+
* [MaxCDN](http://bit.ly/acaXXt)
|
124 |
+
* [Rackspace Cloud Files](http://bit.ly/9hpX8T)
|
125 |
+
* [Cotendo](http://bit.ly/bnVs0a)
|
126 |
+
* [VPS NET](http://bit.ly/d5hfFt)
|
127 |
+
* [Amazon Cloudfront](http://bit.ly/ao1sGt)
|
128 |
+
* [EdgeCast](http://bit.ly/bIjSWC)
|
129 |
+
* [Akamai](http://bit.ly/a5GBLV)
|
130 |
+
* [Limelight Networks](http://bit.ly/aCW04j)
|
131 |
+
* [SimpleCDN](http://bit.ly/93EAKK)
|
132 |
|
133 |
= I don't understand what a CDN has to do with caching, that's completely different, no? =
|
134 |
|
135 |
Technically no, a CDN is a high performance cache that stores static assets (your theme files, media library etc) in various locations throughout the world in order to provide low latency access to them by readers in those regions. So indeed a CDN is a high performance cache, many of which actually store your frequently requested assets in memory for fastest possible response.
|
136 |
|
137 |
+
= What if I don't want to work with a CDN right now, is there any other use for this feature? =
|
138 |
|
139 |
+
Yes! You can take advantage of the [pipelining](http://www.mozilla.org/projects/netlib/http/pipelining-faq.html) support in some browsers by creating a sub-domain for the static content for your site. So you could select the "Origin Push / Self-hosted" method of the General Settings tab. Create static.domain.com on your server (and update your DNS zone) and then specify the FTP details for it in the plugin configuration panel and you're done. If you disable the scripting options on your server you'll find that your server will actually respond slightly faster from that sub-domain because it's just sending files and not processing them.
|
140 |
|
141 |
+
= How do I configure Amazon Simple Storage Service (Amazon S3) or Amazon CloudFront as my CDN? =
|
142 |
|
143 |
+
First [create an S3 account](http://aws.amazon.com/). Next, you need to obtain your "Access key" and "Secret key" from the "Access Credentials" section of the "[Security Credentials](http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key)" page of "My Account." Make sure the status is "active." Next, make sure that "Amazon Simple Storage Service (Amazon S3)" is the selected type of CDN on the General Settings tab (if not change the setting and save the changes). Now on the CDN Settings tab enter your "Access key," "Secret key" and create a bucket. Click the "Test S3 Upload" button and make sure that the test is successful, if not check your settings and try again.
|
144 |
|
145 |
+
Save your settings. Make sure that you export your media library, upload your wp-includes (WordPress core files) theme files, and custom files if you wish to host each of those with AWS. Unless you wish to use CloudFront, you're almost done, skip to the next paragraph if you're using CloudFront. Just go to the General Settings tab and click the checkbox and save the settings to enable CDN functionality and empty the cache for the changes to take effect.
|
146 |
|
147 |
+
To use CloudFront, perform all of the steps above, except select the "Amazon CloudFront" CDN type in the CDN section of the General Settings tab. Proceed to the [AWS Management Console](https://console.aws.amazon.com/cloudfront/) and create a new distribution: select the S3 Bucket you created earlier as the "Origin," enter a [CNAME](http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?CNAMEs.html) if you wish to add one to your DNS Zone. Make sure that "Distribution Status" is enabled and "State" is deployed. Now on CDN Settings tab of the plugin, copy the subdomain found in the AWS Management Console and enter the CNAME used for the distribution in the "CNAME" field.
|
148 |
|
149 |
+
Now go to the General Settings tab and click the checkbox and save the settings to enable CDN functionality and empty the cache for the changes to take effect.
|
150 |
|
151 |
+
= How do I use an Origin Pull (Mirror) CDN? =
|
152 |
+
Login to your CDN providers control panel or account management area. Following any set up steps they provide, create a new "pull zone" or "bucket" for your site's domain name. If there's a set up wizard or any troubleshooting tips your provider offers, be sure to review them. In the CDN Settings tab of the plugin, enter the hostname your CDN provider provided in the "replace site's hostname with" field. You should always do a quick check by opening a test file from the CDN hostname, e.g. http://cdn.domain.com/favicon.ico. Troubleshoot with yoru CDN provider until this test is successful.
|
153 |
|
154 |
+
Now go to the General Settings tab and click the checkbox and save the settings to enable CDN functionality and empty the cache for the changes to take effect.
|
155 |
|
156 |
+
= My YSlow score is low because it doesn't recognize my CDN, what can I do? =
|
157 |
+
Rule 2 says to use a content delivery network (CDN). The score for this rule is computed by checking the hostname of each component against the list of known CDNs. Unfortunately, the list of "known CDNs" are the ones used by Yahoo!. Most likely these are not relevant to your web site, except for potentially yui.yahooapis.com. If you want an accurate score for your web site, you can add your CDN hostnames to YSlow using Firefox's preferences. Here are the steps to follow:
|
158 |
|
159 |
+
* Go to about:config in Firefox. You'll see the current list of preferences.
|
160 |
+
* Right-click in the window and choose New and String to create a new string preference.
|
161 |
+
* Enter extensions.yslow.cdnHostnames for the preference name.
|
162 |
+
* For the string value, enter the hostname of your CDN, for example, mycdn.com. Do not use quotes. If you have multiple CDN hostnames, separate them with commas.
|
163 |
|
164 |
+
If you specify CDN hostnames in your preferences, they'll be shown under the details for Rule 2 in the Performance view.
|
165 |
+
|
166 |
+
= What is the purpose of the "modify attachment URLs" button? =
|
167 |
+
|
168 |
+
If the domain name of your site has changed, this tool is useful in updating your posts and pages to use the current addresses. For example, if your site used to be www.domain.com, and you decided to change it to domain.com, the result would either be many "broken" images or many unncessary redirects (which slow down the visitor's browsing experience). You can use this tool to correct this and similar cases. Correcting the URLs of your images also allows the plugin to do a better job of determining which images are actually hosted with the CDN.
|
169 |
+
|
170 |
+
As always, it never hurts to back up your database first.
|
171 |
+
|
172 |
+
= Is this plugin comptatible with TDO Mini Forms? =
|
173 |
+
|
174 |
+
Captcha and recaptcha will work fine, however you will need to prevent any pages with forms from being cached. Add the page's URI to the "Never cache the following pages" box on the Page Cache Settings tab.
|
175 |
|
176 |
= Is this plugin comptatible with GD Star Rating? =
|
177 |
|
178 |
Yes. Follow these steps:
|
179 |
|
180 |
1. Enable dynamic loading of ratings by checking GD Star Rating -> Settings -> Features "Cache support option"
|
181 |
+
1. If Database cache enabled in W3 Total Cache add `wp_gdsr` to "Ignored query stems" field in the Database Cache settings tab, otherwise ratings will not updated after voting
|
182 |
1. Empty all caches
|
183 |
|
184 |
= I see garbage characters instead of the normal web site, what's going on here? =
|
185 |
|
186 |
+
If a theme or it's files use the call `php_flush()` or function `flush()` that will interfere with the plugins normal operation; making the plugin send cached files before essential operations have finished. The `flush()` call is no longer necessary and should be removed.
|
187 |
|
188 |
= How do I cache only the home page? =
|
189 |
|
193 |
|
194 |
First, make sure the plugin is not active (disabled) site-wide. Then make sure it's deactivated site-wide. Now you should be able to successful upgrade without breaking your site.
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
= This is too good to be true, how can I test the results? =
|
197 |
You will be able to see it instantly on each page load, but for tangible metrics, consider the following tools:
|
198 |
|
207 |
* [Web Caching Tests](http://www.procata.com/cachetest/)
|
208 |
* [Port80 Compression Check (minify requires MSIE6 support to be enabled)](http://www.port80software.com/tools/compresscheck.asp)
|
209 |
* [A simple online web page compression / deflate / gzip test tool](http://www.gidnetwork.com/tools/gzip-test.php)
|
210 |
+
|
211 |
+
= I don't have time to deal with this, but I know I need it. Will you help me? =
|
212 |
+
|
213 |
+
Yes! Please [reach out to us](http://www.w3-edge.com/contact/) and we'll get you acclimated so you can "set it and forget it."
|
214 |
|
215 |
Install the plugin to read the full FAQ.
|
216 |
|
217 |
+
== Other Notes ==
|
218 |
+
|
219 |
+
= Who do I thank for all of this? =
|
220 |
+
|
221 |
+
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:
|
222 |
+
|
223 |
+
* [Steve Souders](http://stevesouders.com/)
|
224 |
+
* [Steve Clay](http://mrclay.org/)
|
225 |
+
* [Ryan Grove](http://wonko.com/)
|
226 |
+
* [Nicholas Zakas](http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/)
|
227 |
+
* [Ryan Dean](http://rtdean.livejournal.com/)
|
228 |
+
* [Andrei Zmievski](http://gravitonic.com/)
|
229 |
+
* George Schlossnagle
|
230 |
+
* Daniel Cowgill
|
231 |
+
* [Rasmus Lerdorf](http://toys.lerdorf.com/)
|
232 |
+
* [Gopal Vijayaraghavan](http://t3.dotgnu.info/)
|
233 |
+
* [Bart Vanbraban](http://eaccelerator.net/)
|
234 |
+
* [mOo](http://xcache.lighttpd.net/)
|
235 |
+
|
236 |
+
Please reach out to all of these people and support their projects if you're so inclined.
|
237 |
+
|
238 |
== Installation ==
|
239 |
|
240 |
+
1. Deactivate and delete any other caching plugin you may be using. Make sure wp-content/ (temporarily) has 777 permissions before proceeding, e.g.: `# chmod 777 /var/www/vhosts/domain.com/httpdocs/wp-content/` using your web hosting control panel or your SSH account.
|
241 |
+
1. Login as an administrator to your WordPress Admin account. Using the "Add New" menu option under the "Plugins" section of the navigation, you can either search for: w3 total cache or if you've downloaded the plugin already, click the "Upload" link, find the .zip file you download and then click "Install Now". Or you can unzip and FTP upload the plugin to your plugins directory (wp-content/plugins/). In either case, when done wp-content/plugins/w3-total-cache/ should exist.
|
242 |
+
1. Locate and activate the plugin on the "Plugins" page. Page caching will **automatically be running** in basic mode. Set the permissions of wp-content back to 755, e.g.: `# chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/`.
|
|
|
243 |
1. Now click the "Settings" link to proceed to the "General Settings" tab and select your caching methods for page, database and minify. In most cases, "disk enhanced" mode for page cache, "disk" mode for minify and "disk" mode for database caching are "good" settings.
|
244 |
+
1. *Optional:* If you already have a content delivery network (CDN) provider, proceed to the "CDN Settings" tab and populate the fields and set your preferences. If you do not use the Media Library, you will need to import your images etc into the default locations. Use the Media Library Import Tool on the CDN Setting tab to perform this task. If you do not have a CDN provider, you can still improve your site's performance using the "Self-hosted" method. On your own server, create a subdomain and matching DNS Zone record; e.g. static.domain.com and configure FTP options on the CDN tab accordingly. Be sure to FTP upload the appropriate files, using the available upload buttons.
|
245 |
+
1. *Optional:* On the "Minify Settings" tab all of the recommended settings are preset. View your site's HTML source and search for .css and .js files and then specify any CSS and JS files in the respective section. In the case of JS files you can (optionally) specify the type and location of the embedding using the drop down menu. See the plugin's FAQ for more information on usage.
|
246 |
+
1. *Optional:* On the "Database Cache Settings" tab the recommended settings are preset. If you're using a shared hosting account use the "disk" method with caution; in either of these cases the response time of the disk may not be fast enough, so this option is disabled by default.
|
247 |
1. You're done! Get back to blogging!
|
248 |
|
249 |
== Changelog ==
|
250 |
|
251 |
+
= 0.8.5.2 =
|
252 |
+
* Added support for Bad Behavior plugin
|
253 |
+
* Added support for eAccelerator and XCache opcode caches
|
254 |
+
* Added support for rewriting href attribute of anchors for images that use the CDN
|
255 |
+
* Added deflate http compression support to minify
|
256 |
+
* Added setting of file modification time after FTP upload
|
257 |
+
* Added check of file modification time and file size before FTP upload
|
258 |
+
* Added check of file hash before uploading to Amazon S3
|
259 |
+
* Added option to force replacement of uploaded attachments on CDN
|
260 |
+
* Added option to toggle feed minification
|
261 |
+
* Added combine only option for CSS minification to overcome invalid CSS files
|
262 |
+
* Database caching now disabled by default to improve compatibility with some shared hosting environments
|
263 |
+
* Default page caching method now disk enhanced
|
264 |
+
* Improved HTTP Compression inter-operability
|
265 |
+
* Improved compatibility with Multi Site Manager
|
266 |
+
* Improved apache compatibility
|
267 |
+
* Improved .htaccess directives
|
268 |
+
* Improved header management for posts / pages
|
269 |
+
* Improved notifications
|
270 |
+
* Improved minify handling of external files
|
271 |
+
* Improved minify memory limit to avoid blank pages when document size is large
|
272 |
+
* Improved minify reliability by reducing comment removal options
|
273 |
+
* Improved Media Library Import versatility
|
274 |
+
* Improved reliability of plugin activation in WordPress MU
|
275 |
+
* Improved security handling for some operations
|
276 |
+
* Improved reliability of handling file names containing spaces in CDN functionality
|
277 |
+
* Improved non-blocking embedding reliability
|
278 |
+
* Improved memcached detection by supporting only PECL memcache
|
279 |
+
* Fixed bug with disk enhanced method of page cache in WordPress MU
|
280 |
+
* Fixed false match of page cache files in disk enhanced method of page cache
|
281 |
+
* Fixed a bug with cron anomalies caused by caching of wp_options table
|
282 |
+
* Fixed missing trailing slash issue when using disk enhanced page caching
|
283 |
+
* Fixed auto-embed bug CSS and JS when already manually embedded
|
284 |
+
|
285 |
= 0.8.5.1 =
|
286 |
* Added option to CDN Settings to skip specified directories
|
287 |
* Added option to allow for full control of HTTP compression options for page cache (some WordPress installations have issues with deflate)
|
w3-total-cache.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: The fastest and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your blog by adding: page caching, database caching, minify, content delivery network (CDN) functionality and more...
|
5 |
-
Version: 0.8.5.
|
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
|
@@ -30,19 +30,21 @@ Author URI: http://www.linkedin.com/in/w3edge
|
|
30 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31 |
*/
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$w3_plugin_totalcache
|
|
|
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: The fastest and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your blog by adding: page caching, database caching, minify, content delivery network (CDN) functionality and more...
|
5 |
+
Version: 0.8.5.2
|
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
|
30 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31 |
*/
|
32 |
|
33 |
+
if (! defined('W3TC_IN_MINIFY')) {
|
34 |
+
/**
|
35 |
+
* Require plugin configuration
|
36 |
+
*/
|
37 |
+
require_once dirname(__FILE__) . '/inc/define.php';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load plugins
|
41 |
+
*/
|
42 |
+
w3_load_plugins();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Run plugin
|
46 |
+
*/
|
47 |
+
require_once W3TC_DIR . '/lib/W3/Plugin/TotalCache.php';
|
48 |
+
$w3_plugin_totalcache = & W3_Plugin_TotalCache::instance();
|
49 |
+
$w3_plugin_totalcache->run();
|
50 |
+
}
|
wp-content/advanced-cache.php
CHANGED
@@ -3,16 +3,19 @@
|
|
3 |
/**
|
4 |
* W3 Total Cache advanced cache module
|
5 |
*/
|
6 |
-
if (! defined('
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
16 |
|
17 |
-
$w3_pgcache = & W3_PgCache::instance();
|
18 |
-
$w3_pgcache->process();
|
|
3 |
/**
|
4 |
* W3 Total Cache advanced cache module
|
5 |
*/
|
6 |
+
if (! defined('W3TC_IN_MINIFY')) {
|
7 |
+
if (! defined('W3TC_DIR')) {
|
8 |
+
define('W3TC_DIR', WP_CONTENT_DIR . '/plugins/w3-total-cache');
|
9 |
+
}
|
10 |
+
|
11 |
+
if (! is_dir(W3TC_DIR) || ! file_exists(W3TC_DIR . '/inc/define.php')) {
|
12 |
+
@header('X-Robots-Tag: noarchive, noodp, nosnippet');
|
13 |
+
die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', __FILE__));
|
14 |
+
}
|
15 |
+
|
16 |
+
require_once W3TC_DIR . '/inc/define.php';
|
17 |
+
require_once W3TC_DIR . '/lib/W3/PgCache.php';
|
18 |
|
19 |
+
$w3_pgcache = & W3_PgCache::instance();
|
20 |
+
$w3_pgcache->process();
|
21 |
+
}
|
wp-content/db.php
CHANGED
@@ -8,10 +8,11 @@ if (! defined('W3TC_DIR')) {
|
|
8 |
}
|
9 |
|
10 |
if (! is_dir(W3TC_DIR) || ! file_exists(W3TC_DIR . '/inc/define.php')) {
|
|
|
11 |
die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', __FILE__));
|
12 |
}
|
13 |
|
14 |
require_once W3TC_DIR . '/inc/define.php';
|
15 |
require_once W3TC_DIR . '/lib/W3/Db.php';
|
16 |
-
|
17 |
$GLOBALS['wpdb'] = & W3_Db::instance();
|
8 |
}
|
9 |
|
10 |
if (! is_dir(W3TC_DIR) || ! file_exists(W3TC_DIR . '/inc/define.php')) {
|
11 |
+
@header('X-Robots-Tag: noarchive, noodp, nosnippet');
|
12 |
die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', __FILE__));
|
13 |
}
|
14 |
|
15 |
require_once W3TC_DIR . '/inc/define.php';
|
16 |
require_once W3TC_DIR . '/lib/W3/Db.php';
|
17 |
+
|
18 |
$GLOBALS['wpdb'] = & W3_Db::instance();
|
wp-content/w3tc/min/index.php
CHANGED
@@ -3,6 +3,8 @@
|
|
3 |
/**
|
4 |
* W3 Total Cache Minify module
|
5 |
*/
|
|
|
|
|
6 |
if (! defined('ABSPATH')) {
|
7 |
require_once dirname(__FILE__) . '/../../../wp-load.php';
|
8 |
}
|
@@ -12,11 +14,12 @@ if (! defined('W3TC_DIR')) {
|
|
12 |
}
|
13 |
|
14 |
if (! is_dir(W3TC_DIR) || ! file_exists(W3TC_DIR . '/inc/define.php')) {
|
|
|
15 |
die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', dirname(__FILE__)));
|
16 |
}
|
17 |
|
18 |
require_once W3TC_DIR . '/inc/define.php';
|
19 |
require_once W3TC_DIR . '/lib/W3/Minify.php';
|
20 |
-
|
21 |
$w3_minify = & W3_Minify::instance();
|
22 |
$w3_minify->process();
|
3 |
/**
|
4 |
* W3 Total Cache Minify module
|
5 |
*/
|
6 |
+
define('W3TC_IN_MINIFY', true);
|
7 |
+
|
8 |
if (! defined('ABSPATH')) {
|
9 |
require_once dirname(__FILE__) . '/../../../wp-load.php';
|
10 |
}
|
14 |
}
|
15 |
|
16 |
if (! is_dir(W3TC_DIR) || ! file_exists(W3TC_DIR . '/inc/define.php')) {
|
17 |
+
@header('X-Robots-Tag: noarchive, noodp, nosnippet');
|
18 |
die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', dirname(__FILE__)));
|
19 |
}
|
20 |
|
21 |
require_once W3TC_DIR . '/inc/define.php';
|
22 |
require_once W3TC_DIR . '/lib/W3/Minify.php';
|
23 |
+
|
24 |
$w3_minify = & W3_Minify::instance();
|
25 |
$w3_minify->process();
|