W3 Total Cache - Version 0.9.7.1

Version Description

  • Fixed undefined variable notice
  • Fixed "No such file or directory" warning
  • Fixed writing to PHP error log rather than WordPress debug log
  • Fixed default referrer policy should be "no-referrer-when-downgrade"
  • Fixed php_flag error related to browser cache, using ini_set instead
  • Fixed CloudFlare IPv6 check undefined offset
  • Fixed Undefined constant WP_ROOT
  • Fixed frame-ancestors being overwritten by frame-src
  • Fixed missing semicolon in nginx configuration
  • Fixed HTTP/2 URLs handling for browser cache and CDN modules
  • Fixed display of CDN debug information
  • Fixed CSS Minification with Google Fonts when included via "Include external files/libraries" and non-latin character-sets are loaded
  • Fixed media query string not updating when all caches were purged
  • Fixed double slash with ABSPATH if file exists
  • Fixed setting max-age and expires header simultaneously
  • Fixed SASL detection for PECL Memcached
  • Fixed handling of manually entered objects to be purged on CDN
  • Fixed query string handling in Nginx
  • Improved error handling with Cloudfront
  • Improved page cache logging
  • Improved multi-tenant support for memory-based caching engines
  • Improved CSS minification
  • Improved purge behavior for changed media objects when using CDN
  • Improved compatibility with sitemap plugins
  • Added support for Memcached for Nginx
  • Added support for caching webm files
  • Added Brotli HTTP compression support
  • Added StackPath full site delivery support
  • Added wc_session to the list of ignored query stems for improved WooCommerce compatibility
Download this release

Release Info

Developer fredericktownes
Plugin Icon 128x128 W3 Total Cache
Version 0.9.7.1
Comparing to
See all releases

Code changes from version 0.9.7 to 0.9.7.1

Files changed (177) hide show
  1. BrowserCache_ConfigLabels.php +4 -1
  2. BrowserCache_Environment.php +84 -53
  3. BrowserCache_Page.php +18 -10
  4. BrowserCache_Page_View_QuickReference.php +78 -0
  5. BrowserCache_Plugin.php +83 -17
  6. BrowserCache_Plugin_Admin.php +3 -0
  7. Cache.php +21 -17
  8. CacheFlush.php +2 -2
  9. CacheFlush_Locally.php +14 -9
  10. Cache_Base.php +6 -2
  11. Cache_File_Generic.php +5 -0
  12. Cache_Memcache.php +3 -1
  13. Cache_Memcached.php +13 -11
  14. Cache_Nginx_Memcached.php +310 -0
  15. Cache_Redis.php +9 -3
  16. CdnEngine.php +4 -0
  17. CdnEngine_Ftp.php +271 -13
  18. CdnEngine_GoogleDrive.php +1 -1
  19. CdnEngine_Mirror_StackPath2.php +109 -0
  20. CdnEngine_S3_Cf.php +1 -1
  21. Cdn_AdminActions.php +9 -5
  22. Cdn_ConfigLabels.php +1 -1
  23. Cdn_Core.php +25 -1
  24. Cdn_GeneralPage_View.php +3 -3
  25. Cdn_GoogleDrive_Page.php +1 -1
  26. Cdn_Highwinds_Page_View.php +2 -2
  27. Cdn_Highwinds_Popup_View_ConfigureCnamesForm.php +1 -1
  28. Cdn_Highwinds_Widget.php +1 -1
  29. Cdn_MaxCdn_Page_View.php +9 -9
  30. Cdn_MaxCdn_Popup_View_Intro.php +2 -2
  31. Cdn_Plugin.php +103 -36
  32. Cdn_Plugin_Admin.php +38 -9
  33. Cdn_Plugin_WidgetMaxCdn.php +2 -2
  34. Cdn_Plugin_WidgetMaxCdn_View_Unauthorized.php +3 -3
  35. Cdn_RackSpaceCdn_AdminActions.php +1 -1
  36. Cdn_RackSpaceCdn_Page_View.php +2 -2
  37. Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php +1 -1
  38. Cdn_RackSpaceCdn_Popup_View_Service_Create.php +2 -2
  39. Cdn_RackSpaceCloudFiles_Page_View.php +1 -1
  40. Cdn_StackPath2_Api.php +257 -0
  41. Cdn_StackPath2_Page.php +28 -0
  42. Cdn_StackPath2_Page_View.js +71 -0
  43. Cdn_StackPath2_Page_View.php +96 -0
  44. Cdn_StackPath2_Popup.php +211 -0
  45. Cdn_StackPath2_Popup_View_Intro.php +47 -0
  46. Cdn_StackPath2_Popup_View_Sites.php +54 -0
  47. Cdn_StackPath2_Popup_View_Stacks.php +51 -0
  48. Cdn_StackPath2_Popup_View_Success.php +23 -0
  49. Cdn_StackPath2_Widget.php +131 -0
  50. Cdn_StackPath2_Widget_View.css +78 -0
  51. Cdn_StackPath2_Widget_View.js +46 -0
  52. Cdn_StackPath2_Widget_View_Authorized.php +40 -0
  53. Cdn_StackPath2_Widget_View_Unauthorized.php +17 -0
  54. Cdn_StackPath_Page_View.php +23 -23
  55. Cdn_StackPath_Popup.php +1 -1
  56. Cdn_StackPath_Widget.php +1 -1
  57. Cdn_StackPath_Widget_View.css +1 -1
  58. Cdn_StackPath_Widget_View_Unauthorized.php +8 -8
  59. Cdn_Util.php +4 -1
  60. Cdnfsd_CacheFlush.php +25 -3
  61. Cdnfsd_CloudFront_Api.php +5 -0
  62. Cdnfsd_CloudFront_Page_View.php +2 -2
  63. Cdnfsd_CloudFront_Popup_View_Distribution.php +1 -1
  64. Cdnfsd_CloudFront_Popup_View_Intro.php +1 -1
  65. Cdnfsd_CloudFront_Popup_View_Success.php +1 -1
  66. Cdnfsd_Core.php +25 -0
  67. Cdnfsd_GeneralPage_View.php +3 -3
  68. Cdnfsd_MaxCdn_Page_View.php +2 -2
  69. Cdnfsd_MaxCdn_Popup_View_Intro.php +2 -2
  70. Cdnfsd_Plugin.php +3 -3
  71. Cdnfsd_Plugin_Admin.php +21 -8
  72. Cdnfsd_StackPath2_Engine.php +69 -0
  73. Cdnfsd_StackPath2_Page.php +20 -0
  74. Cdnfsd_StackPath2_Page_View.js +71 -0
  75. Cdnfsd_StackPath2_Page_View.php +61 -0
  76. Cdnfsd_StackPath2_Popup.php +201 -0
  77. Cdnfsd_StackPath2_Popup_View_Intro.php +47 -0
  78. Cdnfsd_StackPath2_Popup_View_Sites.php +54 -0
  79. Cdnfsd_StackPath2_Popup_View_Stacks.php +50 -0
  80. Cdnfsd_StackPath2_Popup_View_Success.php +23 -0
  81. Cdnfsd_StackPath_Page_View.php +2 -2
  82. Cdnfsd_StackPath_Popup.php +1 -1
  83. Cdnfsd_StackPath_Popup_View_Intro.php +26 -26
  84. Cli.php +7 -1
  85. ConfigCompiler.php +0 -9
  86. ConfigDbStorage.php +5 -1
  87. ConfigKeys.php +221 -45
  88. ConfigState.php +6 -0
  89. DbCache_Environment.php +4 -2
  90. Extension_CloudFlare_Plugin.php +0 -3
  91. Extension_CloudFlare_Widget.php +3 -3
  92. Extension_NewRelic_GeneralPage_View.php +4 -4
  93. Extension_NewRelic_Plugin_Admin.php +13 -8
  94. Extension_NewRelic_Widget.php +2 -2
  95. Extension_NewRelic_Widget_View_Browser.php +1 -1
  96. Extension_Swarmify_Widget.php +3 -2
  97. Generic_AdminActions_Config.php +7 -4
  98. Generic_AdminActions_Default.php +71 -30
  99. Generic_AdminActions_Flush.php +7 -7
  100. Generic_Faq.php +11 -13
  101. Generic_Page_Dashboard_View.css +6 -0
  102. Generic_Page_General.php +1 -0
  103. Generic_Plugin_Admin.php +5 -5
  104. Generic_WidgetServices.php +7 -7
  105. Generic_WidgetSpreadTheWord.js +6 -6
  106. Generic_WidgetSpreadTheWord_Plugin.php +2 -2
  107. Licensing_AdminActions.php +60 -2
  108. Licensing_Core.php +25 -8
  109. Licensing_Plugin_Admin.php +121 -42
  110. Minify_AutoCss.php +305 -0
  111. Minify_AutoJs.php +316 -0
  112. Minify_Environment.php +70 -6
  113. Minify_MinifiedFileRequestHandler.php +16 -2
  114. Minify_Plugin.php +35 -440
  115. PageSpeed_Plugin_Widget.php +2 -2
  116. PgCache_ConfigLabels.php +2 -2
  117. PgCache_ContentGrabber.php +56 -7
  118. PgCache_Environment.php +173 -41
  119. PgCache_Page_CookieGroups_View.js +1 -1
  120. PgCache_Plugin.php +0 -1
  121. Root_Loader.php +2 -5
  122. Support_Page.php +4 -0
  123. UsageStatistics_Widget.php +1 -1
  124. Util_Admin.php +0 -10
  125. Util_Http.php +2 -2
  126. Util_Installed.php +8 -4
  127. Util_Ui.php +38 -25
  128. inc/lightbox/purchase.php +1 -1
  129. inc/lightbox/self_test.php +21 -1
  130. inc/lightbox/support_us.php +11 -7
  131. inc/lightbox/upgrade.php +6 -6
  132. inc/mime/all.php +1 -0
  133. inc/mime/other.php +1 -0
  134. inc/options/browsercache.php +72 -33
  135. inc/options/cdn.php +26 -11
  136. inc/options/cdn/azure.php +1 -1
  137. inc/options/cdn/cf.php +33 -33
  138. inc/options/cdn/cf2.php +12 -12
  139. inc/options/cdn/common/cnames.php +27 -27
  140. inc/options/cdn/ftp.php +22 -1
  141. inc/options/common/header.php +92 -74
  142. inc/options/dashboard.php +1 -1
  143. inc/options/dbcache.php +2 -1
  144. inc/options/general.php +11 -6
  145. inc/options/install.php +21 -224
  146. inc/options/minify.php +2 -2
  147. inc/options/minify/yuicss2.php +4 -4
  148. inc/options/parts/memcached.php +41 -41
  149. inc/options/parts/memcached_extension.php +13 -13
  150. inc/options/pgcache.php +7 -4
  151. languages/w3-total-cache-ar_AR.po +23 -3
  152. languages/w3-total-cache-nl_NL.po +23 -3
  153. languages/w3-total-cache-pl_PL.po +23 -3
  154. languages/w3-total-cache-sr_RS.mo +0 -0
  155. languages/w3-total-cache-sr_RS.po +25 -5
  156. languages/w3-total-cache.pot +23 -3
  157. lib/Minify/HTTP/Encoder.php +18 -1
  158. lib/Minify/Minify.php +12 -1
  159. lib/Minify/Minify/CSS/UriRewriter.php +1 -1
  160. lib/Minify/Minify/Cache/File.php +6 -2
  161. lib/Minify/Minify/Controller/Files.php +5 -1
  162. lib/Minify/Minify/HTML.php +72 -19
  163. lib/Minify/Minify/Inline.php +24 -3
  164. lib/Nusoap/nusoap.php +27 -2
  165. lib/SNS/sdk.class.php +16 -0
  166. pub/css/lightbox.css +2 -2
  167. pub/css/options.css +15 -5
  168. pub/img/cspref.png +0 -0
  169. pub/img/w3tc_stackpath-logo-retina.png +0 -0
  170. pub/img/w3tc_stackpath-logo.png +0 -0
  171. pub/img/w3tc_stackpath_logo.svg +40 -0
  172. pub/js/lightbox.js +2 -2
  173. pub/js/options.js +37 -31
  174. pub/js/widget.js +1 -1
  175. readme.txt +36 -18
  176. w3-total-cache-api.php +98 -57
  177. w3-total-cache.php +1 -1
BrowserCache_ConfigLabels.php CHANGED
@@ -16,6 +16,7 @@ class BrowserCache_ConfigLabels {
16
  'browsercache.cssjs.etag' => __( 'Set entity tag (eTag)', 'w3-total-cache' ),
17
  'browsercache.cssjs.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
18
  'browsercache.cssjs.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression', 'w3-total-cache' ),
 
19
  'browsercache.cssjs.replace' => __( 'Prevent caching of objects after settings change', 'w3-total-cache' ),
20
  'browsercache.cssjs.nocookies' => __( 'Disable cookies for static files', 'w3-total-cache' ),
21
  'browsercache.html.last_modified' => __( 'Set Last-Modified header', 'w3-total-cache' ),
@@ -26,6 +27,7 @@ class BrowserCache_ConfigLabels {
26
  'browsercache.html.etag' => __( 'Set entity tag (ETag)', 'w3-total-cache' ),
27
  'browsercache.html.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
28
  'browsercache.html.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression', 'w3-total-cache' ),
 
29
  'browsercache.other.last_modified' => __( 'Set Last-Modified header', 'w3-total-cache' ),
30
  'browsercache.other.expires' => __( 'Set expires header', 'w3-total-cache' ),
31
  'browsercache.other.lifetime' => __( 'Expires header lifetime:', 'w3-total-cache' ),
@@ -34,6 +36,7 @@ class BrowserCache_ConfigLabels {
34
  'browsercache.other.etag' => __( 'Set entity tag (ETag)', 'w3-total-cache' ),
35
  'browsercache.other.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
36
  'browsercache.other.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression</label>', 'w3-total-cache' ),
 
37
  'browsercache.other.replace' => __( 'Prevent caching of objects after settings change', 'w3-total-cache' ),
38
  'browsercache.other.nocookies' => __( 'Disable cookies for static files', 'w3-total-cache' ),
39
  'browsercache.security.session.cookie_httponly' => __( 'Access session cookies through the <acronym title="Hypertext Transfer Protocol">HTTP</acronym> only:', 'w3-total-cache' ),
@@ -43,7 +46,7 @@ class BrowserCache_ConfigLabels {
43
  'browsercache.security.hsts.directive' => __( 'Directive:', 'w3-total-cache' ),
44
  'browsercache.security.xfo' => __( 'X-Frame-Options', 'w3-total-cache' ),
45
  'browsercache.security.xfo.directive' => __( 'Directive:', 'w3-total-cache' ),
46
- 'browsercache.security.xss' => __( 'X-XSS-Protection', 'w3-total-cache' ),
47
  'browsercache.security.xss.directive' => __( 'Directive:', 'w3-total-cache' ),
48
  'browsercache.security.xcto' => __( 'X-Content-Type-Options', 'w3-total-cache' ),
49
  'browsercache.security.pkp' => __( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Public Key Pinning', 'w3-total-cache' ),
16
  'browsercache.cssjs.etag' => __( 'Set entity tag (eTag)', 'w3-total-cache' ),
17
  'browsercache.cssjs.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
18
  'browsercache.cssjs.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression', 'w3-total-cache' ),
19
+ 'browsercache.cssjs.brotli' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (brotli) compression', 'w3-total-cache' ),
20
  'browsercache.cssjs.replace' => __( 'Prevent caching of objects after settings change', 'w3-total-cache' ),
21
  'browsercache.cssjs.nocookies' => __( 'Disable cookies for static files', 'w3-total-cache' ),
22
  'browsercache.html.last_modified' => __( 'Set Last-Modified header', 'w3-total-cache' ),
27
  'browsercache.html.etag' => __( 'Set entity tag (ETag)', 'w3-total-cache' ),
28
  'browsercache.html.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
29
  'browsercache.html.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression', 'w3-total-cache' ),
30
+ 'browsercache.html.brotli' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (brotli) compression', 'w3-total-cache' ),
31
  'browsercache.other.last_modified' => __( 'Set Last-Modified header', 'w3-total-cache' ),
32
  'browsercache.other.expires' => __( 'Set expires header', 'w3-total-cache' ),
33
  'browsercache.other.lifetime' => __( 'Expires header lifetime:', 'w3-total-cache' ),
36
  'browsercache.other.etag' => __( 'Set entity tag (ETag)', 'w3-total-cache' ),
37
  'browsercache.other.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
38
  'browsercache.other.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression</label>', 'w3-total-cache' ),
39
+ 'browsercache.other.brotli' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (brotli) compression</label>', 'w3-total-cache' ),
40
  'browsercache.other.replace' => __( 'Prevent caching of objects after settings change', 'w3-total-cache' ),
41
  'browsercache.other.nocookies' => __( 'Disable cookies for static files', 'w3-total-cache' ),
42
  'browsercache.security.session.cookie_httponly' => __( 'Access session cookies through the <acronym title="Hypertext Transfer Protocol">HTTP</acronym> only:', 'w3-total-cache' ),
46
  'browsercache.security.hsts.directive' => __( 'Directive:', 'w3-total-cache' ),
47
  'browsercache.security.xfo' => __( 'X-Frame-Options', 'w3-total-cache' ),
48
  'browsercache.security.xfo.directive' => __( 'Directive:', 'w3-total-cache' ),
49
+ 'browsercache.security.xss' => __( 'X-<acronym title="Cross-Site Scripting">XSS</acronym>-Protection', 'w3-total-cache' ),
50
  'browsercache.security.xss.directive' => __( 'Directive:', 'w3-total-cache' ),
51
  'browsercache.security.xcto' => __( 'X-Content-Type-Options', 'w3-total-cache' ),
52
  'browsercache.security.pkp' => __( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Public Key Pinning', 'w3-total-cache' ),
BrowserCache_Environment.php CHANGED
@@ -112,6 +112,7 @@ class BrowserCache_Environment {
112
  unset( $other_compression['avi'] );
113
  unset( $other_compression['divx'] );
114
  unset( $other_compression['gif'] );
 
115
  unset( $other_compression['gz|gzip'] );
116
  unset( $other_compression['jpg|jpeg|jpe'] );
117
  unset( $other_compression['mid|midi'] );
@@ -286,6 +287,42 @@ class BrowserCache_Environment {
286
  $rules .= "</IfModule>\n";
287
  }
288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  $cssjs_compression = $config->get_boolean( 'browsercache.cssjs.compression' );
290
  $html_compression = $config->get_boolean( 'browsercache.html.compression' );
291
  $other_compression = $config->get_boolean( 'browsercache.other.compression' );
@@ -334,35 +371,6 @@ class BrowserCache_Environment {
334
  $rules .= $this->_rules_cache_generate_apache_for_type( $config,
335
  $extensions, $type );
336
 
337
- $sec = '';
338
- $v = $config->get_string( 'browsercache.security.session.cookie_httponly' );
339
- if ( !empty( $v ) ) {
340
- $sec .= ' php_flag session.cookie_httponly ' .
341
- ( $v == 'on' ? 'on' : 'off' ) . "\n";
342
- }
343
- $v = $config->get_string( 'browsercache.security.session.cookie_secure' );
344
- if ( !empty( $v ) ) {
345
- $sec .= ' php_flag session.cookie_secure ' .
346
- ( $v == 'on' ? 'on' : 'off' ) . "\n";
347
- }
348
- $v = $config->get_string( 'browsercache.security.session.use_only_cookies' );
349
- if ( !empty( $v ) ) {
350
- $sec .= ' php_flag session.use_only_cookies ' .
351
- ( $v == 'on' ? 'on' : 'off' ) . "\n";
352
- }
353
-
354
- if ( !empty( $sec ) ) {
355
- $rules .= "<IfModule mod_php5.c>\n";
356
- $rules .= $sec;
357
- $rules .= "</IfModule>\n";
358
- $rules .= "<IfModule mod_php7.c>\n";
359
- $rules .= $sec;
360
- $rules .= "</IfModule>\n";
361
- $rules .= "<IfModule mod_suphp.c>\n";
362
- $rules .= $sec;
363
- $rules .= "</IfModule>\n";
364
- }
365
-
366
  if ( $config->get_boolean( 'browsercache.hsts' ) ||
367
  $config->get_boolean( 'browsercache.security.xfo' ) ||
368
  $config->get_boolean( 'browsercache.security.xss' ) ||
@@ -623,6 +631,36 @@ class BrowserCache_Environment {
623
 
624
  }
625
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
  $cssjs_compression = $config->get_boolean( 'browsercache.cssjs.compression' );
627
  $html_compression = $config->get_boolean( 'browsercache.html.compression' );
628
  $other_compression = $config->get_boolean( 'browsercache.other.compression' );
@@ -668,28 +706,11 @@ class BrowserCache_Environment {
668
  }
669
  }
670
 
671
- foreach ( $mime_types as $type => $extensions )
672
- $this->_rules_cache_generate_nginx_for_type( $config, $rules,
673
- $extensions, $type );
674
-
675
- $sec = '';
676
- $v = $config->get_string( 'browsercache.security.session.cookie_httponly' );
677
- if ( !empty( $v ) ) {
678
- $sec .= 'session.cookie_httponly=' .
679
- ( $v == 'on' ? "on" : "off" ) . "\n";
680
- }
681
- $v = $config->get_string( 'browsercache.security.session.cookie_secure' );
682
- if ( !empty( $v ) ) {
683
- $sec .= 'session.cookie_secure=' .
684
- ( $v == 'on' ? "on" : "off" ) . "\n";
685
- }
686
- $v = $config->get_string( 'browsercache.security.session.use_only_cookies' );
687
- if ( !empty( $v ) ) {
688
- $sec .= 'session.use_only_cookies=' .
689
- ( $v == 'on' ? "on" : "off" ) . "\n";
690
- }
691
- if ( !empty( $sec ) ) {
692
- $rules .= "fastcgi_param PHP_FLAG \"$sec\";";
693
  }
694
 
695
  if ( $config->get_boolean( 'browsercache.hsts' ) ||
@@ -842,7 +863,12 @@ class BrowserCache_Environment {
842
 
843
  case 'cache_public_maxage':
844
  $add_header_rules .= " add_header Pragma \"public\";\n";
845
- $add_header_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
 
 
 
 
 
846
  break;
847
 
848
  case 'cache_validation':
@@ -857,7 +883,12 @@ class BrowserCache_Environment {
857
 
858
  case 'cache_maxage':
859
  $add_header_rules .= " add_header Pragma \"public\";\n";
860
- $add_header_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
 
 
 
 
 
861
  break;
862
 
863
  case 'no_cache':
112
  unset( $other_compression['avi'] );
113
  unset( $other_compression['divx'] );
114
  unset( $other_compression['gif'] );
115
+ unset( $other_compression['br'] );
116
  unset( $other_compression['gz|gzip'] );
117
  unset( $other_compression['jpg|jpeg|jpe'] );
118
  unset( $other_compression['mid|midi'] );
287
  $rules .= "</IfModule>\n";
288
  }
289
 
290
+ $cssjs_brotli = $config->get_boolean( 'browsercache.cssjs.brotli' );
291
+ $html_brotli = $config->get_boolean( 'browsercache.html.brotli' );
292
+ $other_brotli = $config->get_boolean( 'browsercache.other.brotli' );
293
+
294
+ if ( $cssjs_brotli || $html_brotli || $other_brotli ) {
295
+ $brotli_types = array();
296
+
297
+ if ( $cssjs_brotli ) {
298
+ $brotli_types = array_merge( $brotli_types, $cssjs_types );
299
+ }
300
+
301
+ if ( $html_brotli ) {
302
+ $brotli_types = array_merge( $brotli_types, $html_types );
303
+ }
304
+
305
+ if ( $other_brotli ) {
306
+ $brotli_types = array_merge( $brotli_types,
307
+ $other_compression_types );
308
+ }
309
+
310
+ $rules .= "<IfModule mod_brotli.c>\n";
311
+ if ( version_compare( Util_Environment::get_server_version(), '2.3.7', '>=' ) ) {
312
+ $rules .= " <IfModule mod_filter.c>\n";
313
+ }
314
+ $rules .= " AddOutputFilterByType BROTLI_COMPRESS " . implode( ' ', $brotli_types ) . "\n";
315
+ $rules .= " <IfModule mod_mime.c>\n";
316
+ $rules .= " # BROTLI_COMPRESS by extension\n";
317
+ $rules .= " AddOutputFilter BROTLI_COMPRESS js css htm html xml\n";
318
+ $rules .= " </IfModule>\n";
319
+
320
+ if ( version_compare( Util_Environment::get_server_version(), '2.3.7', '>=' ) ) {
321
+ $rules .= " </IfModule>\n";
322
+ }
323
+ $rules .= "</IfModule>\n";
324
+ }
325
+
326
  $cssjs_compression = $config->get_boolean( 'browsercache.cssjs.compression' );
327
  $html_compression = $config->get_boolean( 'browsercache.html.compression' );
328
  $other_compression = $config->get_boolean( 'browsercache.other.compression' );
371
  $rules .= $this->_rules_cache_generate_apache_for_type( $config,
372
  $extensions, $type );
373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  if ( $config->get_boolean( 'browsercache.hsts' ) ||
375
  $config->get_boolean( 'browsercache.security.xfo' ) ||
376
  $config->get_boolean( 'browsercache.security.xss' ) ||
631
 
632
  }
633
 
634
+ $cssjs_brotli = $config->get_boolean( 'browsercache.cssjs.brotli' );
635
+ $html_brotli = $config->get_boolean( 'browsercache.html.brotli' );
636
+ $other_brotli = $config->get_boolean( 'browsercache.other.brotli' );
637
+
638
+ if ( $cssjs_brotli || $html_brotli || $other_brotli ) {
639
+ $brotli_types = array();
640
+
641
+ if ( $cssjs_brotli ) {
642
+ $brotli_types = array_merge( $brotli_types, $cssjs_types );
643
+ }
644
+
645
+ if ( $html_brotli ) {
646
+ $brotli_types = array_merge( $brotli_types, $html_types );
647
+ }
648
+
649
+ if ( $other_brotli ) {
650
+ $brotli_types = array_merge( $brotli_types,
651
+ $other_compression_types );
652
+ }
653
+
654
+ unset( $brotli_types['html|htm'] );
655
+
656
+ // some nginx cant handle values longer than 47 chars
657
+ unset( $brotli_types['odp'] );
658
+
659
+ $rules .= "brotli on;\n";
660
+ $rules .= "brotli_types " .
661
+ implode( ' ', array_unique( $brotli_types ) ) . ";\n";
662
+ }
663
+
664
  $cssjs_compression = $config->get_boolean( 'browsercache.cssjs.compression' );
665
  $html_compression = $config->get_boolean( 'browsercache.html.compression' );
666
  $other_compression = $config->get_boolean( 'browsercache.other.compression' );
706
  }
707
  }
708
 
709
+ foreach ( $mime_types as $type => $extensions ) {
710
+ if ( $type != 'other_compression' ) {
711
+ $this->_rules_cache_generate_nginx_for_type( $config, $rules,
712
+ $extensions, $type );
713
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
714
  }
715
 
716
  if ( $config->get_boolean( 'browsercache.hsts' ) ||
863
 
864
  case 'cache_public_maxage':
865
  $add_header_rules .= " add_header Pragma \"public\";\n";
866
+
867
+ if ( $expires ) {
868
+ $add_header_rules .= " add_header Cache-Control \"public\";\n";
869
+ } else {
870
+ $add_header_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
871
+ }
872
  break;
873
 
874
  case 'cache_validation':
883
 
884
  case 'cache_maxage':
885
  $add_header_rules .= " add_header Pragma \"public\";\n";
886
+
887
+ if ( $expires ) {
888
+ $add_header_rules .= " add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\n";
889
+ } else {
890
+ $add_header_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
891
+ }
892
  break;
893
 
894
  case 'no_cache':
BrowserCache_Page.php CHANGED
@@ -4,19 +4,24 @@ namespace W3TC;
4
 
5
 
6
  class BrowserCache_Page extends Base_Page_Settings {
7
- /**
8
- * Current page
9
- *
10
- * @var string
11
- */
12
  protected $_page = 'w3tc_browsercache';
13
 
14
 
15
- /**
16
- * Browser cache tab
17
- *
18
- * @return void
19
- */
 
 
 
 
 
 
 
 
 
 
20
  function view() {
21
  $browsercache_enabled = $this->_config->get_boolean( 'browsercache.enabled' );
22
  $browsercache_last_modified = ( $this->_config->get_boolean( 'browsercache.cssjs.last_modified' ) && $this->_config->get_boolean( 'browsercache.html.last_modified' ) && $this->_config->get_boolean( 'browsercache.other.last_modified' ) );
@@ -25,6 +30,7 @@ class BrowserCache_Page extends Base_Page_Settings {
25
  $browsercache_etag = ( $this->_config->get_boolean( 'browsercache.cssjs.etag' ) && $this->_config->get_boolean( 'browsercache.html.etag' ) && $this->_config->get_boolean( 'browsercache.other.etag' ) );
26
  $browsercache_w3tc = ( $this->_config->get_boolean( 'browsercache.cssjs.w3tc' ) && $this->_config->get_boolean( 'browsercache.html.w3tc' ) && $this->_config->get_boolean( 'browsercache.other.w3tc' ) );
27
  $browsercache_compression = ( $this->_config->get_boolean( 'browsercache.cssjs.compression' ) && $this->_config->get_boolean( 'browsercache.html.compression' ) && $this->_config->get_boolean( 'browsercache.other.compression' ) );
 
28
  $browsercache_replace = ( $this->_config->get_boolean( 'browsercache.cssjs.replace' ) && $this->_config->get_boolean( 'browsercache.other.replace' ) );
29
  $browsercache_querystring = ( $this->_config->get_boolean( 'browsercache.cssjs.querystring' ) && $this->_config->get_boolean( 'browsercache.other.querystring' ) );
30
  $browsercache_update_media_qs = ( $this->_config->get_boolean( 'browsercache.cssjs.replace' ) || $this->_config->get_boolean( 'browsercache.other.replace' ) );
@@ -32,6 +38,8 @@ class BrowserCache_Page extends Base_Page_Settings {
32
  ( $this->_config->get_boolean( 'browsercache.cssjs.nocookies' ) &&
33
  $this->_config->get_boolean( 'browsercache.other.nocookies' ) );
34
 
 
 
35
  include W3TC_INC_DIR . '/options/browsercache.php';
36
  }
37
  }
4
 
5
 
6
  class BrowserCache_Page extends Base_Page_Settings {
 
 
 
 
 
7
  protected $_page = 'w3tc_browsercache';
8
 
9
 
10
+ static public function w3tc_ajax() {
11
+ add_action( 'w3tc_ajax_browsercache_quick_reference', array(
12
+ '\W3TC\BrowserCache_Page',
13
+ 'w3tc_ajax_browsercache_quick_reference' ) );
14
+ }
15
+
16
+
17
+
18
+ public function w3tc_ajax_browsercache_quick_reference() {
19
+ include W3TC_DIR . '/BrowserCache_Page_View_QuickReference.php';
20
+ exit();
21
+ }
22
+
23
+
24
+
25
  function view() {
26
  $browsercache_enabled = $this->_config->get_boolean( 'browsercache.enabled' );
27
  $browsercache_last_modified = ( $this->_config->get_boolean( 'browsercache.cssjs.last_modified' ) && $this->_config->get_boolean( 'browsercache.html.last_modified' ) && $this->_config->get_boolean( 'browsercache.other.last_modified' ) );
30
  $browsercache_etag = ( $this->_config->get_boolean( 'browsercache.cssjs.etag' ) && $this->_config->get_boolean( 'browsercache.html.etag' ) && $this->_config->get_boolean( 'browsercache.other.etag' ) );
31
  $browsercache_w3tc = ( $this->_config->get_boolean( 'browsercache.cssjs.w3tc' ) && $this->_config->get_boolean( 'browsercache.html.w3tc' ) && $this->_config->get_boolean( 'browsercache.other.w3tc' ) );
32
  $browsercache_compression = ( $this->_config->get_boolean( 'browsercache.cssjs.compression' ) && $this->_config->get_boolean( 'browsercache.html.compression' ) && $this->_config->get_boolean( 'browsercache.other.compression' ) );
33
+ $browsercache_brotli = ( $this->_config->get_boolean( 'browsercache.cssjs.brotli' ) && $this->_config->get_boolean( 'browsercache.html.brotli' ) && $this->_config->get_boolean( 'browsercache.other.brotli' ) );
34
  $browsercache_replace = ( $this->_config->get_boolean( 'browsercache.cssjs.replace' ) && $this->_config->get_boolean( 'browsercache.other.replace' ) );
35
  $browsercache_querystring = ( $this->_config->get_boolean( 'browsercache.cssjs.querystring' ) && $this->_config->get_boolean( 'browsercache.other.querystring' ) );
36
  $browsercache_update_media_qs = ( $this->_config->get_boolean( 'browsercache.cssjs.replace' ) || $this->_config->get_boolean( 'browsercache.other.replace' ) );
38
  ( $this->_config->get_boolean( 'browsercache.cssjs.nocookies' ) &&
39
  $this->_config->get_boolean( 'browsercache.other.nocookies' ) );
40
 
41
+ $is_nginx = Util_Environment::is_nginx();
42
+
43
  include W3TC_INC_DIR . '/options/browsercache.php';
44
  }
45
  }
BrowserCache_Page_View_QuickReference.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+
7
+ ?>
8
+ <div class="lightbox-content-padded">
9
+ <h3><?php _e( 'Security Headers: Quick Reference', 'w3-total-cache' ); ?></h3>
10
+
11
+ <fieldset>
12
+ <legend><?php _e( 'Legend', 'w3-total-cache' ); ?></legend>
13
+
14
+ <p>
15
+ All of the directives that end with -src support similar values known as
16
+ a source list. Multiple source list values can be space separated with the exception of
17
+ 'none' which should be the only value.
18
+ </p>
19
+ </fieldset>
20
+
21
+ <table class="w3tcbc_qrf">
22
+ <tr>
23
+ <th>Source Value</th>
24
+ <th>Example</th>
25
+ <th>Description</th>
26
+ </tr>
27
+ <tr>
28
+ <td><code>*</code></td>
29
+ <td><code>img-src *</code></td>
30
+ <td>Wildcard, allows any URL except data: blob: filesystem: schemes</td>
31
+ </tr>
32
+ <tr>
33
+ <td><code>'none'</code></td>
34
+ <td><code>object-src 'none'</code></td>
35
+ <td>Prevents loading resources from any source</td>
36
+ </tr>
37
+ <tr>
38
+ <td><code>'self'</code></td>
39
+ <td><code>script-src 'self'</code></td>
40
+ <td>Allows loading resources from the same origin (same scheme, host and port)</td>
41
+ </tr>
42
+ <tr>
43
+ <td><code>data:</code></td>
44
+ <td><code>img-src 'self' data:</code></td>
45
+ <td>Allows loading resources via the data scheme (e.g. Base64 encoded images)</td>
46
+ </tr>
47
+ <tr>
48
+ <td><code>domain.example.com</code></td>
49
+ <td><code>img-src domain.example.com</code></td>
50
+ <td>Allows loading resources from the specified domain name</td>
51
+ </tr>
52
+ <tr>
53
+ <td><code>*.example.com</code></td>
54
+ <td><code>img-src *.example.com</code></td>
55
+ <td>Allows loading resources from any subdomain under example.com</td>
56
+ </tr>
57
+ <tr>
58
+ <td><code>https://cdn.com</code></td>
59
+ <td><code>img-src https://cdn.com</code></td>
60
+ <td>Allows loading resources only over <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> matching the given domain</td>
61
+ </tr>
62
+ <tr>
63
+ <td><code>https:</code></td>
64
+ <td><code>img-src https:</code></td>
65
+ <td>Allows loading resources only over <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> on any domain</td>
66
+ </tr>
67
+ <tr>
68
+ <td><code>'unsafe-inline'</code></td>
69
+ <td><code>script-src 'unsafe-inline'</code></td>
70
+ <td>Allows use of inline source elements such as style attribute, onclick, or script tag bodies (depends on the context of the source it is applied to)</td>
71
+ </tr>
72
+ <tr>
73
+ <td><code>'unsafe-eval'</code></td>
74
+ <td><code>script-src 'unsafe-eval'</code></td>
75
+ <td>Allows unsafe dynamic code evaluation such as Javascript eval()</td>
76
+ </tr>
77
+ </table>
78
+ </div>
BrowserCache_Plugin.php CHANGED
@@ -30,16 +30,64 @@ class BrowserCache_Plugin {
30
  0, 2 );
31
  }
32
 
33
- if ( $this->can_ob() ) {
 
 
34
  $this->browsercache_rewrite =
35
  $this->_config->get_boolean( 'browsercache.rewrite' );
36
- Util_Bus::add_ob_callback( 'browsercache', array( $this, 'ob_callback' ) );
37
 
38
- // modify CDN urls too
39
  add_filter( 'w3tc_cdn_url',
40
- array( $this, 'w3tc_cdn_url' ),
41
- 0, 3 );
 
 
 
 
 
 
 
 
 
 
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  /**
@@ -48,18 +96,6 @@ class BrowserCache_Plugin {
48
  * @return boolean
49
  */
50
  function can_ob() {
51
- /**
52
- * Replace feature should be enabled
53
- */
54
- if ( !$this->_config->get_boolean( 'browsercache.cssjs.replace' ) &&
55
- !$this->_config->get_boolean( 'browsercache.html.replace' ) &&
56
- !$this->_config->get_boolean( 'browsercache.other.replace' ) &&
57
- !$this->_config->get_boolean( 'browsercache.cssjs.querystring' ) &&
58
- !$this->_config->get_boolean( 'browsercache.html.querystring' ) &&
59
- !$this->_config->get_boolean( 'browsercache.other.querystring' )) {
60
- return false;
61
- }
62
-
63
  /**
64
  * Skip if admin
65
  */
@@ -155,6 +191,36 @@ class BrowserCache_Plugin {
155
  return sprintf( '%s\'%s\'', $attr, $url );
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  /**
159
  * Link replace for CDN url
160
  *
30
  0, 2 );
31
  }
32
 
33
+ $url_uniqualize_enabled = $this->url_uniqualize_enabled();
34
+
35
+ if ( $this->url_clean_enabled() || $url_uniqualize_enabled ) {
36
  $this->browsercache_rewrite =
37
  $this->_config->get_boolean( 'browsercache.rewrite' );
 
38
 
39
+ // modify CDN urls
40
  add_filter( 'w3tc_cdn_url',
41
+ array( $this, 'w3tc_cdn_url' ), 0, 3 );
42
+
43
+ if ( $url_uniqualize_enabled ) {
44
+ add_action( 'w3tc_flush_all',
45
+ array( $this, 'w3tc_flush_all' ), 1050, 1 );
46
+ }
47
+
48
+
49
+ if ( $this->can_ob() ) {
50
+ Util_Bus::add_ob_callback( 'browsercache',
51
+ array( $this, 'ob_callback' ) );
52
+ }
53
  }
54
+
55
+ $v = $this->_config->get_string( 'browsercache.security.session.cookie_httponly' );
56
+ if ( !empty( $v ) ) {
57
+ @ini_set( 'session.cookie_httponly', $v == 'on' ? '1': '0' );
58
+ }
59
+ $v = $this->_config->get_string( 'browsercache.security.session.cookie_secure' );
60
+ if ( !empty( $v ) ) {
61
+ @ini_set( 'session.cookie_secure', $v == 'on' ? '1': '0' );
62
+ }
63
+ $v = $this->_config->get_string( 'browsercache.security.session.use_only_cookies' );
64
+ if ( !empty( $v ) ) {
65
+ @ini_set( 'session.use_only_cookies', $v == 'on' ? '1': '0' );
66
+ }
67
+
68
+ add_filter( 'w3tc_minify_http2_preload_url',
69
+ array( $this, 'w3tc_minify_http2_preload_url' ), 4000 );
70
+ }
71
+
72
+ private function url_clean_enabled() {
73
+ return
74
+ $this->_config->get_boolean( 'browsercache.cssjs.querystring' ) ||
75
+ $this->_config->get_boolean( 'browsercache.html.querystring' ) ||
76
+ $this->_config->get_boolean( 'browsercache.other.querystring' );
77
+ }
78
+
79
+ private function url_uniqualize_enabled() {
80
+ return $this->_config->get_boolean( 'browsercache.cssjs.replace' ) ||
81
+ $this->_config->get_boolean( 'browsercache.html.replace' ) ||
82
+ $this->_config->get_boolean( 'browsercache.other.replace' );
83
+ }
84
+
85
+ public function w3tc_flush_all( $extras = array() ) {
86
+ if ( isset( $extras['only'] ) && $extras['only'] != 'browsercache' )
87
+ return;
88
+
89
+ update_option( 'w3tc_browsercache_flush_timestamp',
90
+ rand( 10000, 99999 ) . '' );
91
  }
92
 
93
  /**
96
  * @return boolean
97
  */
98
  function can_ob() {
 
 
 
 
 
 
 
 
 
 
 
 
99
  /**
100
  * Skip if admin
101
  */
191
  return sprintf( '%s\'%s\'', $attr, $url );
192
  }
193
 
194
+ /**
195
+ * Mutate http/2 header links
196
+ */
197
+ public function w3tc_minify_http2_preload_url( $data ) {
198
+ if ( isset( $data['browsercache_processed'] ) ) {
199
+ return $data;
200
+ }
201
+
202
+ $data['browsercache_processed'] = '*';
203
+ $url = $data['result_link'];
204
+
205
+ // decouple extension
206
+ $matches = array();
207
+ if ( !preg_match( '/\.([a-zA-Z0-9]+)($|[\?])/', $url, $matches ) ) {
208
+ return $data;
209
+ }
210
+ $extension = $matches[1];
211
+
212
+ $ops = $this->_get_url_mutation_operations( $url, $extension );
213
+ if ( is_null( $ops ) ) {
214
+ return $data;
215
+ }
216
+
217
+ $mutate_by_querystring = !$this->browsercache_rewrite;
218
+
219
+ $url = $this->mutate_url( $url, $ops, $mutate_by_querystring );
220
+ $data['result_link'] = $url;
221
+ return $data;
222
+ }
223
+
224
  /**
225
  * Link replace for CDN url
226
  *
BrowserCache_Plugin_Admin.php CHANGED
@@ -6,5 +6,8 @@ class BrowserCache_Plugin_Admin {
6
  $config_labels = new BrowserCache_ConfigLabels();
7
  add_filter( 'w3tc_config_labels', array(
8
  $config_labels, 'config_labels' ) );
 
 
 
9
  }
10
  }
6
  $config_labels = new BrowserCache_ConfigLabels();
7
  add_filter( 'w3tc_config_labels', array(
8
  $config_labels, 'config_labels' ) );
9
+
10
+ add_action( 'w3tc_ajax',
11
+ array( '\W3TC\BrowserCache_Page', 'w3tc_ajax' ) );
12
  }
13
  }
Cache.php CHANGED
@@ -54,6 +54,10 @@ class Cache {
54
  }
55
  break;
56
 
 
 
 
 
57
  case 'redis':
58
  $instances[$instance_key] = new Cache_Redis( $config );
59
  break;
@@ -99,6 +103,10 @@ class Cache {
99
 
100
  break;
101
 
 
 
 
 
102
  case 'apc':
103
  $engine_name = 'apc';
104
  break;
@@ -138,6 +146,10 @@ class Cache {
138
  $engine_name = 'amazon simple storage service (s3)';
139
  break;
140
 
 
 
 
 
141
  case 'cf':
142
  $engine_name = 'amazon cloudfront';
143
  break;
@@ -162,22 +174,6 @@ class Cache {
162
  $engine_name = 'microsoft azure storage';
163
  break;
164
 
165
- case 'mirror':
166
- $engine_name = 'mirror';
167
- break;
168
-
169
- case 'maxcdn':
170
- $engine_name = 'maxcdn';
171
- break;
172
-
173
- case 'cotendo':
174
- $engine_name = 'cotendo';
175
- break;
176
-
177
- case 'akamai':
178
- $engine_name = 'akamai';
179
- break;
180
-
181
  case 'edgecast':
182
  $engine_name = 'media template procdn / edgecast';
183
  break;
@@ -186,8 +182,16 @@ class Cache {
186
  $engine_name = 'at&amp;t';
187
  break;
188
 
 
 
 
 
 
 
 
 
189
  default:
190
- $engine_name = 'n/a';
191
  break;
192
  }
193
 
54
  }
55
  break;
56
 
57
+ case 'nginx_memcached':
58
+ $instances[$instance_key] = new Cache_Nginx_Memcached( $config );
59
+ break;
60
+
61
  case 'redis':
62
  $instances[$instance_key] = new Cache_Redis( $config );
63
  break;
103
 
104
  break;
105
 
106
+ case 'nginx_memcached':
107
+ $engine_name = 'nginx + memcached';
108
+ break;
109
+
110
  case 'apc':
111
  $engine_name = 'apc';
112
  break;
146
  $engine_name = 'amazon simple storage service (s3)';
147
  break;
148
 
149
+ case 's3_compatible':
150
+ $engine_name = 's3 compatible';
151
+ break;
152
+
153
  case 'cf':
154
  $engine_name = 'amazon cloudfront';
155
  break;
174
  $engine_name = 'microsoft azure storage';
175
  break;
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  case 'edgecast':
178
  $engine_name = 'media template procdn / edgecast';
179
  break;
182
  $engine_name = 'at&amp;t';
183
  break;
184
 
185
+ case 'rackspace_cdn':
186
+ $engine_name = 'rackspace';
187
+ break;
188
+
189
+ case 'stackpath2':
190
+ $engine_name = 'stackpath';
191
+ break;
192
+
193
  default:
194
+ $engine_name = $engine;
195
  break;
196
  }
197
 
CacheFlush.php CHANGED
@@ -92,9 +92,9 @@ class CacheFlush {
92
  /**
93
  * Purge CDN mirror cache
94
  */
95
- function cdn_purge_all() {
96
  if ( $this->_config->get_boolean( 'cdn.enabled' ) )
97
- return $this->_executor->cdn_purge_all();
98
 
99
  return false;
100
  }
92
  /**
93
  * Purge CDN mirror cache
94
  */
95
+ function cdn_purge_all( $extras = array() ) {
96
  if ( $this->_config->get_boolean( 'cdn.enabled' ) )
97
+ return $this->_executor->cdn_purge_all( $extras );
98
 
99
  return false;
100
  }
CacheFlush_Locally.php CHANGED
@@ -103,13 +103,18 @@ class CacheFlush_Locally {
103
  /**
104
  * Purge CDN mirror cache
105
  */
106
- function cdn_purge_all() {
107
- do_action( 'w3tc_cdn_purge_all' );
108
- $cdn_core = Dispatcher::component( 'Cdn_Core' );
109
- $cdn = $cdn_core->get_cdn();
110
- $results = array();
111
- $v = $cdn->purge_all( $results );
112
- do_action( 'w3tc_cdn_purge_all_after' );
 
 
 
 
 
113
 
114
  return $v;
115
  }
@@ -159,7 +164,7 @@ class CacheFlush_Locally {
159
  function flush_post( $post_id, $extras = null ) {
160
  $do_flush = apply_filters( 'w3tc_preflush_post', true, $extras );
161
  if ( $do_flush )
162
- do_action( 'w3tc_flush_post', $post_id );
163
  }
164
 
165
  /**
@@ -219,7 +224,7 @@ class CacheFlush_Locally {
219
  function flush_url( $url, $extras = null ) {
220
  $do_flush = apply_filters( 'w3tc_preflush_url', true, $extras );
221
  if ( $do_flush )
222
- do_action( 'w3tc_flush_url', $url );
223
  }
224
 
225
  /**
103
  /**
104
  * Purge CDN mirror cache
105
  */
106
+ function cdn_purge_all( $extras = array() ) {
107
+ $do_flush = apply_filters( 'w3tc_preflush_cdn_all', true, $extras );
108
+
109
+ $v = false;
110
+ if ( $do_flush ) {
111
+ do_action( 'w3tc_cdn_purge_all' );
112
+ $cdn_core = Dispatcher::component( 'Cdn_Core' );
113
+ $cdn = $cdn_core->get_cdn();
114
+ $results = array();
115
+ $v = $cdn->purge_all( $results );
116
+ do_action( 'w3tc_cdn_purge_all_after' );
117
+ }
118
 
119
  return $v;
120
  }
164
  function flush_post( $post_id, $extras = null ) {
165
  $do_flush = apply_filters( 'w3tc_preflush_post', true, $extras );
166
  if ( $do_flush )
167
+ do_action( 'w3tc_flush_post', $post_id, $extras );
168
  }
169
 
170
  /**
224
  function flush_url( $url, $extras = null ) {
225
  $do_flush = apply_filters( 'w3tc_preflush_url', true, $extras );
226
  if ( $do_flush )
227
+ do_action( 'w3tc_flush_url', $url, $extras );
228
  }
229
 
230
  /**
Cache_Base.php CHANGED
@@ -184,7 +184,9 @@ class Cache_Base {
184
  * @return string
185
  */
186
  protected function _get_key_version_key( $group = '' ) {
187
- return sprintf( 'w3tc_%d_%s_%s_%d_key_version', $this->_blog_id, $this->_module, $group, $this->_instance_id );
 
 
188
  }
189
 
190
  /**
@@ -194,7 +196,9 @@ class Cache_Base {
194
  * @return string
195
  */
196
  public function get_item_key( $name ) {
197
- $key = sprintf( 'w3tc_%s_%d_%s_%s', $this->_host, $this->_blog_id, $this->_module, $name );
 
 
198
  return $key;
199
  }
200
 
184
  * @return string
185
  */
186
  protected function _get_key_version_key( $group = '' ) {
187
+ return sprintf( 'w3tc_%d_%d_%s_%s_key_version',
188
+ $this->_instance_id, $this->_blog_id,
189
+ $this->_module, $group );
190
  }
191
 
192
  /**
196
  * @return string
197
  */
198
  public function get_item_key( $name ) {
199
+ $key = sprintf( 'w3tc_%d_%s_%d_%s_%s',
200
+ $this->_instance_id, $this->_host, $this->_blog_id,
201
+ $this->_module, $name );
202
  return $key;
203
  }
204
 
Cache_File_Generic.php CHANGED
@@ -209,6 +209,11 @@ class Cache_File_Generic extends Cache_File {
209
  if ( !file_exists( $path ) )
210
  return true;
211
 
 
 
 
 
 
212
  $old_entry_path = $path . '_old';
213
  if ( ! @rename( $path, $old_entry_path ) ) {
214
  // if we can delete old entry - do second attempt to store in old-entry file
209
  if ( !file_exists( $path ) )
210
  return true;
211
 
212
+ $dir = dirname( $path );
213
+ if ( file_exists( $dir . DIRECTORY_SEPARATOR . '.htaccess' ) ) {
214
+ @unlink( $dir . DIRECTORY_SEPARATOR . '.htaccess' );
215
+ }
216
+
217
  $old_entry_path = $path . '_old';
218
  if ( ! @rename( $path, $old_entry_path ) ) {
219
  // if we can delete old entry - do second attempt to store in old-entry file
Cache_Memcache.php CHANGED
@@ -325,7 +325,9 @@ class Cache_Memcache extends Cache_Base {
325
 
326
  public function get_item_key( $name ) {
327
  // memcached doesn't survive spaces in a key
328
- $key = sprintf( 'w3tc_%s_%d_%s_%s', $this->_host, $this->_blog_id, $this->_module, md5( $name ) );
 
 
329
  return $key;
330
  }
331
  }
325
 
326
  public function get_item_key( $name ) {
327
  // memcached doesn't survive spaces in a key
328
+ $key = sprintf( 'w3tc_%d_%s_%d_%s_%s',
329
+ $this->_instance_id, $this->_host, $this->_blog_id,
330
+ $this->_module, md5( $name ) );
331
  return $key;
332
  }
333
  }
Cache_Memcached.php CHANGED
@@ -13,17 +13,17 @@ class Cache_Memcached extends Cache_Base {
13
  private $_memcache = null;
14
 
15
  /*
16
- * Used for faster flushing
17
- *
18
- * @var integer $_key_version
19
- */
20
  private $_key_version = array();
21
 
22
  /*
23
- * Configuration used to reinitialize persistent object
24
- *
25
- * @var integer $_key_version
26
- */
27
  private $_config = null;
28
 
29
  /**
@@ -77,10 +77,10 @@ class Cache_Memcached extends Cache_Base {
77
  }
78
 
79
  if ( isset( $config['username'] ) && !empty( $config['username'] ) &&
80
- method_exists( $this->_memcache, 'setSaslAuthData' ) &&
81
- ini_get( 'memcached.use_sasl' ) )
82
  $this->_memcache->setSaslAuthData( $config['username'],
83
  $config['password'] );
 
84
 
85
  // when disabled - no extra requests are made to obtain key version,
86
  // but flush operations not supported as a result
@@ -397,7 +397,9 @@ class Cache_Memcached extends Cache_Base {
397
 
398
  public function get_item_key( $name ) {
399
  // memcached doesn't survive spaces in a key
400
- $key = sprintf( 'w3tc_%s_%d_%s_%s', $this->_host, $this->_blog_id, $this->_module, md5( $name ) );
 
 
401
  return $key;
402
  }
403
  }
13
  private $_memcache = null;
14
 
15
  /*
16
+ * Used for faster flushing
17
+ *
18
+ * @var integer $_key_version
19
+ */
20
  private $_key_version = array();
21
 
22
  /*
23
+ * Configuration used to reinitialize persistent object
24
+ *
25
+ * @var integer $_key_version
26
+ */
27
  private $_config = null;
28
 
29
  /**
77
  }
78
 
79
  if ( isset( $config['username'] ) && !empty( $config['username'] ) &&
80
+ method_exists( $this->_memcache, 'setSaslAuthData' ) ) {
 
81
  $this->_memcache->setSaslAuthData( $config['username'],
82
  $config['password'] );
83
+ }
84
 
85
  // when disabled - no extra requests are made to obtain key version,
86
  // but flush operations not supported as a result
397
 
398
  public function get_item_key( $name ) {
399
  // memcached doesn't survive spaces in a key
400
+ $key = sprintf( 'w3tc_%d_%s_%d_%s_%s',
401
+ $this->_instance_id, $this->_host, $this->_blog_id,
402
+ $this->_module, md5( $name ) );
403
  return $key;
404
  }
405
  }
Cache_Nginx_Memcached.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ /**
5
+ * PECL Memcached class
6
+ */
7
+ class Cache_Nginx_Memcached extends Cache_Base {
8
+ /**
9
+ * Memcache object
10
+ */
11
+ private $_memcache = null;
12
+
13
+ /*
14
+ * Configuration used to reinitialize persistent object
15
+ */
16
+ private $_config = null;
17
+
18
+ /**
19
+ * constructor
20
+ */
21
+ function __construct( $config ) {
22
+ parent::__construct( $config );
23
+
24
+ if ( isset( $config['persistent'] ) && $config['persistent'] ) {
25
+ $this->_config = $config;
26
+ $this->_memcache = new \Memcached( $this->_get_key_version_key( '' ) );
27
+ $server_list = $this->_memcache->getServerList();
28
+
29
+ if ( empty( $server_list ) )
30
+ return $this->initialize( $config );
31
+ else
32
+ return true;
33
+ } else {
34
+ $this->_memcache = new \Memcached();
35
+ return $this->initialize( $config );
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Initializes
41
+ */
42
+ private function initialize( $config ) {
43
+ if ( empty( $config['servers'] ) )
44
+ return false;
45
+
46
+ if ( defined( '\Memcached::OPT_REMOVE_FAILED_SERVERS' ) ) {
47
+ $this->_memcache->setOption( \Memcached::OPT_REMOVE_FAILED_SERVERS, true );
48
+ }
49
+
50
+ $this->_memcache->setOption( \Memcached::OPT_COMPRESSION, false );
51
+
52
+ if ( isset( $config['aws_autodiscovery'] ) &&
53
+ $config['aws_autodiscovery'] &&
54
+ defined( '\Memcached::OPT_CLIENT_MODE' ) &&
55
+ defined( '\Memcached::DYNAMIC_CLIENT_MODE' ) )
56
+ $this->_memcache->setOption( \Memcached::OPT_CLIENT_MODE,
57
+ \Memcached::DYNAMIC_CLIENT_MODE );
58
+
59
+ foreach ( (array)$config['servers'] as $server ) {
60
+ if ( substr( $server, 0, 5 ) == 'unix:' )
61
+ $this->_memcache->addServer( trim( $server ), 0 );
62
+ else {
63
+ list( $ip, $port ) = explode( ':', $server );
64
+ $this->_memcache->addServer( trim( $ip ), (integer) trim( $port ) );
65
+ }
66
+ }
67
+
68
+ if ( isset( $config['username'] ) && !empty( $config['username'] ) &&
69
+ method_exists( $this->_memcache, 'setSaslAuthData' ) ) {
70
+ $this->_memcache->setSaslAuthData( $config['username'],
71
+ $config['password'] );
72
+ }
73
+
74
+ return true;
75
+ }
76
+
77
+ /**
78
+ * Adds data
79
+ *
80
+ * @param string $key
81
+ * @param mixed $var
82
+ * @param integer $expire
83
+ * @param string $group Used to differentiate between groups of cache values
84
+ * @return boolean
85
+ */
86
+ function add( $key, &$var, $expire = 0, $group = '' ) {
87
+ return $this->set( $key, $var, $expire, $group );
88
+ }
89
+
90
+ /**
91
+ * Sets data
92
+ *
93
+ * @param string $key
94
+ * @param mixed $var
95
+ * @param integer $expire
96
+ * @param string $group Used to differentiate between groups of cache values
97
+ * @return boolean
98
+ */
99
+ function set( $key, $var, $expire = 0, $group = '' ) {
100
+ $this->_memcache->setOption( \Memcached::OPT_USER_FLAGS,
101
+ ( isset( $var['c'] ) ? 1 : 0 ) );
102
+
103
+ return @$this->_memcache->set( $key, $var['content'], $expire );
104
+ }
105
+
106
+ /**
107
+ * Returns data
108
+ *
109
+ * @param string $key
110
+ * @param string $group Used to differentiate between groups of cache values
111
+ * @return mixed
112
+ */
113
+ function get_with_old( $key, $group = '' ) {
114
+ $has_old_data = false;
115
+
116
+ $v = @$this->_memcache->get( $key );
117
+ if ( $v === FALSE ) {
118
+ return null;
119
+ }
120
+
121
+ $data = array( 'content' => $v );
122
+ $data['compression'] = ( substr( $key, -5 ) == '_gzip' ? 'gzip' : '' );
123
+ return array( $data, false );
124
+ }
125
+
126
+ /**
127
+ * Replaces data
128
+ *
129
+ * @param string $key
130
+ * @param mixed $var
131
+ * @param integer $expire
132
+ * @param string $group Used to differentiate between groups of cache values
133
+ * @return boolean
134
+ */
135
+ function replace( $key, &$var, $expire = 0, $group = '' ) {
136
+ return $this->set( $key, $var, $expire, $group );
137
+ }
138
+
139
+ /**
140
+ * Deletes data
141
+ *
142
+ * @param string $key
143
+ * @param string $group
144
+ * @return boolean
145
+ */
146
+ function delete( $key, $group = '' ) {
147
+ return @$this->_memcache->delete( $key );
148
+ }
149
+
150
+ /**
151
+ * Key to delete, deletes _old and primary if exists.
152
+ *
153
+ * @param unknown $key
154
+ * @return bool
155
+ */
156
+ function hard_delete( $key, $group = '' ) {
157
+ return @$this->_memcache->delete( $key );
158
+ }
159
+
160
+ /**
161
+ * Flushes all data
162
+ *
163
+ * @param string $group Used to differentiate between groups of cache values
164
+ * @return boolean
165
+ */
166
+ function flush( $group = '' ) {
167
+ // can only flush everything from memcached, no way to flush only
168
+ // pgcache cache
169
+ return @$this->_memcache->flush();
170
+ }
171
+
172
+ /**
173
+ * Checks if engine can function properly in this environment
174
+ *
175
+ * @return bool
176
+ */
177
+ public function available() {
178
+ return class_exists( 'Memcached' );
179
+ }
180
+
181
+ public function get_statistics() {
182
+ $a = $this->_memcache->getStats();
183
+ if ( count( $a ) > 0 ) {
184
+ $keys = array_keys( $a );
185
+ $key = $keys[0];
186
+ return $a[$key];
187
+ }
188
+
189
+ return $a;
190
+ }
191
+
192
+ /**
193
+ * Returns size used by cache
194
+ */
195
+ public function get_stats_size( $timeout_time ) {
196
+ $size = array(
197
+ 'bytes' => 0,
198
+ 'items' => 0,
199
+ 'timeout_occurred' => false,
200
+ );
201
+
202
+ $key_prefix = $this->get_item_key( '' );
203
+ $error_occurred = false;
204
+
205
+ $server_list = $this->_memcache->getServerList();
206
+ $n = 0;
207
+
208
+ foreach ( $server_list as $server ) {
209
+ $loader = new Cache_Memcached_Stats( $server['host'], $server['port'] );
210
+ $slabs = $loader->slabs();
211
+ if ( !is_array( $slabs ) ) {
212
+ $error_occurred = true;
213
+ continue;
214
+ }
215
+
216
+ foreach ( $slabs as $slab_id ) {
217
+ $cdump = $loader->cachedump( $slab_id );
218
+ if ( !is_array( $cdump ) )
219
+ continue;
220
+
221
+ foreach ( $cdump as $line ) {
222
+ $key_data = explode( ' ', $line );
223
+ if ( !is_array( $key_data ) || count( $key_data ) < 3 )
224
+ continue;
225
+ $n++;
226
+ if ( $n % 10 == 0 ) {
227
+ $size['timeout_occurred'] = ( time() > $timeout_time );
228
+ if ( $size['timeout_occurred'] )
229
+ return $size;
230
+ }
231
+
232
+ $key = $key_data[1];
233
+ $bytes = substr( $key_data[2], 1 );
234
+
235
+ if ( substr( $key, 0, strlen( $key_prefix ) ) == $key_prefix ) {
236
+ $size['bytes'] += $bytes;
237
+ $size['items']++;
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ if ( $error_occurred && $size['items'] <= 0 ) {
244
+ $size['bytes'] = null;
245
+ $size['items'] = null;
246
+ }
247
+
248
+ return $size;
249
+ }
250
+
251
+ /**
252
+ * Used to replace as atomically as possible known value to new one
253
+ */
254
+ public function set_if_maybe_equals( $key, $old_value, $new_value ) {
255
+ $storage_key = $this->get_item_key( $key );
256
+
257
+ $cas = null;
258
+ $value = @$this->_memcache->get( $storage_key, null, $cas );
259
+
260
+ if ( !is_array( $value ) )
261
+ return false;
262
+
263
+ if ( isset( $old_value['content'] ) &&
264
+ $value['content'] != $old_value['content'] )
265
+ return false;
266
+
267
+ return @$this->_memcache->cas( $cas, $storage_key, $new_value );
268
+ }
269
+
270
+ /**
271
+ * Use key as a counter and add integet value to it
272
+ */
273
+ public function counter_add( $key, $value ) {
274
+ if ( $value == 0 )
275
+ return true;
276
+
277
+ $storage_key = $this->get_item_key( $key );
278
+ $r = @$this->_memcache->increment( $storage_key, $value );
279
+ if ( !$r ) // it doesnt initialize counter by itself
280
+ $this->counter_set( $key, 0 );
281
+
282
+ return $r;
283
+ }
284
+
285
+ /**
286
+ * Use key as a counter and add integet value to it
287
+ */
288
+ public function counter_set( $key, $value ) {
289
+ $storage_key = $this->get_item_key( $key );
290
+ return @$this->_memcache->set( $storage_key, $value );
291
+ }
292
+
293
+ /**
294
+ * Get counter's value
295
+ */
296
+ public function counter_get( $key ) {
297
+ $storage_key = $this->get_item_key( $key );
298
+ $v = (int)@$this->_memcache->get( $storage_key );
299
+
300
+ return $v;
301
+ }
302
+
303
+ public function get_item_key( $name ) {
304
+ // memcached doesn't survive spaces in a key
305
+ $key = sprintf( 'w3tc_%d_%s_%d_%s_%s',
306
+ $this->_instance_id, $this->_host, $this->_blog_id,
307
+ $this->_module, md5( $name ) );
308
+ return $key;
309
+ }
310
+ }
Cache_Redis.php CHANGED
@@ -216,9 +216,15 @@ class Cache_Redis extends Cache_Base {
216
  if ( is_null( $accessor ) )
217
  return 0;
218
 
219
- $v = $accessor->get( $storage_key );
220
- $v = intval( $v );
221
- $this->_key_version[$group] = ( $v > 0 ? $v : 1 );
 
 
 
 
 
 
222
  }
223
 
224
  return $this->_key_version[$group];
216
  if ( is_null( $accessor ) )
217
  return 0;
218
 
219
+ $v_original = $accessor->get( $storage_key );
220
+ $v = intval( $v_original );
221
+ $v = ( $v > 0 ? $v : 1 );
222
+
223
+ if ( (string)$v_original !== (string)$v ) {
224
+ $accessor->set( $storage_key, $v );
225
+ }
226
+
227
+ $this->_key_version[$group] = $v;
228
  }
229
 
230
  return $this->_key_version[$group];
CdnEngine.php CHANGED
@@ -92,6 +92,10 @@ class CdnEngine {
92
  $instances[$instance_key] = new CdnEngine_Mirror_StackPath( $config );
93
  break;
94
 
 
 
 
 
95
  default :
96
  trigger_error( 'Incorrect CDN engine', E_USER_WARNING );
97
  $instances[$instance_key] = new CdnEngine_Base();
92
  $instances[$instance_key] = new CdnEngine_Mirror_StackPath( $config );
93
  break;
94
 
95
+ case 'stackpath2':
96
+ $instances[$instance_key] = new CdnEngine_Mirror_StackPath2( $config );
97
+ break;
98
+
99
  default :
100
  trigger_error( 'Incorrect CDN engine', E_USER_WARNING );
101
  $instances[$instance_key] = new CdnEngine_Base();
CdnEngine_Ftp.php CHANGED
@@ -25,15 +25,18 @@ class CdnEngine_Ftp extends CdnEngine_Base {
25
  */
26
  function __construct( $config = array() ) {
27
  $config = array_merge( array(
28
- 'host' => '',
29
- 'type' => '',
30
- 'user' => '',
31
- 'pass' => '',
32
- 'path' => '',
33
- 'pasv' => false,
34
- 'domain' => array(),
35
- 'docroot' => ''
36
- ), $config );
 
 
 
37
 
38
  $host_port = explode( ':', $config['host'] );
39
  if ( sizeof( $host_port ) == 2 ) {
@@ -41,6 +44,11 @@ class CdnEngine_Ftp extends CdnEngine_Base {
41
  $config['port'] = $host_port[1];
42
  }
43
 
 
 
 
 
 
44
  parent::__construct( $config );
45
  }
46
 
@@ -63,6 +71,21 @@ class CdnEngine_Ftp extends CdnEngine_Base {
63
 
64
  $this->_set_error_handler();
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  if ( $this->_config['type'] == 'ftps' )
67
  $this->_ftp = @ftp_ssl_connect( $this->_config['host'],
68
  (int) $this->_config['port'], W3TC_CDN_FTP_CONNECT_TIMEOUT );
@@ -112,11 +135,59 @@ class CdnEngine_Ftp extends CdnEngine_Base {
112
  return true;
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /**
116
  * Disconnects from FTP server
117
  */
118
  function _disconnect() {
119
- @ftp_close( $this->_ftp );
 
 
 
 
 
 
 
120
  }
121
 
122
  /**
@@ -141,7 +212,7 @@ class CdnEngine_Ftp extends CdnEngine_Base {
141
  * @return boolean
142
  */
143
  function upload( $files, &$results, $force_rewrite = false,
144
- $timeout_time = NULL ) {
145
  $error = null;
146
 
147
  if ( !$this->_connect( $error ) ) {
@@ -152,6 +223,10 @@ class CdnEngine_Ftp extends CdnEngine_Base {
152
 
153
  $this->_set_error_handler();
154
 
 
 
 
 
155
  $home = @ftp_pwd( $this->_ftp );
156
 
157
  if ( $home === false ) {
@@ -250,6 +325,83 @@ class CdnEngine_Ftp extends CdnEngine_Base {
250
  return !$this->_is_error( $results );
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  /**
254
  * Deletes files from FTP
255
  *
@@ -272,7 +424,12 @@ class CdnEngine_Ftp extends CdnEngine_Base {
272
  $local_path = $file['local_path'];
273
  $remote_path = $file['remote_path'];
274
 
275
- $result = @ftp_delete( $this->_ftp, $remote_path );
 
 
 
 
 
276
 
277
  if ( $result ) {
278
  $results[] = $this->_get_result( $local_path, $remote_path,
@@ -288,7 +445,13 @@ class CdnEngine_Ftp extends CdnEngine_Base {
288
  while ( true ) {
289
  $remote_path = dirname( $remote_path );
290
 
291
- if ( $remote_path == '.' || !@ftp_rmdir( $this->_ftp, $remote_path ) ) {
 
 
 
 
 
 
292
  break;
293
  }
294
  }
@@ -311,6 +474,10 @@ class CdnEngine_Ftp extends CdnEngine_Base {
311
  return false;
312
  }
313
 
 
 
 
 
314
  $rand = md5( time() );
315
  $tmp_dir = 'test_dir_' . $rand;
316
  $tmp_file = 'test_file_' . $rand;
@@ -407,6 +574,97 @@ class CdnEngine_Ftp extends CdnEngine_Base {
407
  return true;
408
  }
409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  /**
411
  * Returns array of CDN domains
412
  *
25
  */
26
  function __construct( $config = array() ) {
27
  $config = array_merge( array(
28
+ 'host' => '',
29
+ 'type' => '',
30
+ 'user' => '',
31
+ 'pass' => '',
32
+ 'default_keys' => false,
33
+ 'pubkey' => '',
34
+ 'privkey' => '',
35
+ 'path' => '',
36
+ 'pasv' => false,
37
+ 'domain' => array(),
38
+ 'docroot' => ''
39
+ ), $config );
40
 
41
  $host_port = explode( ':', $config['host'] );
42
  if ( sizeof( $host_port ) == 2 ) {
44
  $config['port'] = $host_port[1];
45
  }
46
 
47
+ if ( $config['type'] == 'sftp' && $config['default_keys'] ) {
48
+ $config['pubkey'] = $_SERVER['HOME'] . '/.ssh/id_rsa.pub';
49
+ $config['privkey'] = $_SERVER['HOME'] . '/.ssh/id_rsa';
50
+ }
51
+
52
  parent::__construct( $config );
53
  }
54
 
71
 
72
  $this->_set_error_handler();
73
 
74
+ if ( $this->_config['type'] == 'sftp' ) {
75
+ if ( !function_exists( 'ssh2_connect' ) ) {
76
+ $error = sprintf('Missing required php-ssh2 extension.');
77
+
78
+ $this->_restore_error_handler();
79
+ $this->_disconnect();
80
+
81
+ return false;
82
+ }
83
+
84
+ $this->_ftp = @ssh2_connect( $this->_config['host'], (int) $this->_config['port'] );
85
+
86
+ return $this->_connect_sftp( $error );
87
+ }
88
+
89
  if ( $this->_config['type'] == 'ftps' )
90
  $this->_ftp = @ftp_ssl_connect( $this->_config['host'],
91
  (int) $this->_config['port'], W3TC_CDN_FTP_CONNECT_TIMEOUT );
135
  return true;
136
  }
137
 
138
+ /**
139
+ * Connects to SFTP server
140
+ *
141
+ * @param string $error
142
+ * @return boolean
143
+ */
144
+ function _connect_sftp( &$error ) {
145
+ if ( is_file( $this->_config['pass'] ) ) {
146
+ if ( !@ssh2_auth_pubkey_file( $this->_ftp, $this->_config['user'], $this->_config['pubkey'], $this->_config['privkey'], $this->_config['pass'] ) ) {
147
+ $error = sprintf('Public key authentication failed (%s).', $this->_get_last_error());
148
+
149
+ $this->_restore_error_handler();
150
+ $this->_disconnect();
151
+
152
+ return false;
153
+ }
154
+ } else {
155
+ if ( !@ssh2_auth_password( $this->_ftp, $this->_config['user'], $this->_config['pass'] ) ) {
156
+ $error = sprintf('Incorrect login or password (%s).', $this->_get_last_error());
157
+
158
+ $this->_restore_error_handler();
159
+ $this->_disconnect();
160
+
161
+ return false;
162
+ }
163
+ }
164
+
165
+ if ( !empty( $this->_config['path'] ) && !@ssh2_exec( $this->_ftp, 'cd ' . $this->_config['path'] ) ) {
166
+ $error = sprintf( 'Unable to change directory to: %s (%s).', $this->_config['path'], $this->_get_last_error() );
167
+
168
+ $this->_restore_error_handler();
169
+ $this->_disconnect();
170
+
171
+ return false;
172
+ }
173
+
174
+ $this->_restore_error_handler();
175
+
176
+ return true;
177
+ }
178
+
179
  /**
180
  * Disconnects from FTP server
181
  */
182
  function _disconnect() {
183
+ if ( $this->_config['type'] == 'sftp' ) {
184
+ if ( function_exists( 'ssh2_connect' ) ) {
185
+ @ssh2_exec( $this->_ftp, 'echo "EXITING" && exit;' );
186
+ $this->_ftp = null;
187
+ }
188
+ } else {
189
+ @ftp_close( $this->_ftp );
190
+ }
191
  }
192
 
193
  /**
212
  * @return boolean
213
  */
214
  function upload( $files, &$results, $force_rewrite = false,
215
+ $timeout_time = NULL ) {
216
  $error = null;
217
 
218
  if ( !$this->_connect( $error ) ) {
223
 
224
  $this->_set_error_handler();
225
 
226
+ if ( $this->_config['type'] == 'sftp' ) {
227
+ return $this->_upload_sftp( $files, $results, $force_rewrite, $timeout_time );
228
+ }
229
+
230
  $home = @ftp_pwd( $this->_ftp );
231
 
232
  if ( $home === false ) {
325
  return !$this->_is_error( $results );
326
  }
327
 
328
+ /**
329
+ * Uploads files to SFTP
330
+ *
331
+ * @param array $files
332
+ * @param array $results
333
+ * @param boolean $force_rewrite
334
+ * @return boolean
335
+ */
336
+ function _upload_sftp( $files, $results, $force_rewrite, $timeout_time ) {
337
+ $sftp = ssh2_sftp( $this->_ftp );
338
+
339
+ foreach ( $files as $file ) {
340
+ $local_path = $file['local_path'];
341
+ $remote_path = $file['remote_path'];
342
+
343
+ // process at least one item before timeout so that progress goes on
344
+ if ( !empty( $results ) ) {
345
+ if ( !is_null( $timeout_time ) && time() > $timeout_time ) {
346
+ return 'timeout';
347
+ }
348
+ }
349
+
350
+ if ( !file_exists( $local_path ) ) {
351
+ $results[] = $this->_get_result( $local_path, $remote_path,
352
+ W3TC_CDN_RESULT_ERROR, 'Source file not found.', $file );
353
+
354
+ continue;
355
+ }
356
+
357
+ $remote_dir = dirname( $remote_path );
358
+
359
+ if ( !@file_exists( 'ssh2.sftp://' . intval($sftp) . $remote_dir ) ) {
360
+ if ( !@ssh2_sftp_mkdir( $sftp, $remote_dir, null, true ) ) {
361
+ $results[] = $this->_get_result( $local_path,
362
+ $remote_path, W3TC_CDN_RESULT_ERROR,
363
+ sprintf( 'Unable to create directory (%s).',
364
+ $this->_get_last_error() ),
365
+ $file );
366
+
367
+ continue;
368
+ }
369
+ }
370
+
371
+ $mtime = @filemtime( $local_path );
372
+
373
+ if ( !$force_rewrite ) {
374
+ $size = @filesize( $local_path );
375
+ $statinfo = @ssh2_sftp_stat( $sftp, $remote_path );
376
+
377
+ if ( $size === $statinfo['size'] && $mtime === $statinfo['mtime'] ) {
378
+ $results[] = $this->_get_result( $local_path, $remote_path,
379
+ W3TC_CDN_RESULT_OK, 'File up-to-date.', $file );
380
+
381
+ continue;
382
+ }
383
+ }
384
+
385
+ $result = @ssh2_scp_send( $this->_ftp, $local_path, $remote_path );
386
+
387
+ if ( $result ) {
388
+ $results[] = $this->_get_result( $local_path, $remote_path,
389
+ W3TC_CDN_RESULT_OK, 'OK', $file );
390
+ } else {
391
+ $results[] = $this->_get_result( $local_path, $remote_path,
392
+ W3TC_CDN_RESULT_ERROR,
393
+ sprintf( 'Unable to upload file (%s).',
394
+ $this->_get_last_error() ),
395
+ $file );
396
+ }
397
+ }
398
+
399
+ $this->_restore_error_handler();
400
+ $this->_disconnect();
401
+
402
+ return !$this->_is_error( $results );
403
+ }
404
+
405
  /**
406
  * Deletes files from FTP
407
  *
424
  $local_path = $file['local_path'];
425
  $remote_path = $file['remote_path'];
426
 
427
+ if ( $this->_config['type'] == 'sftp' ) {
428
+ $sftp = @ssh2_sftp( $this->_ftp );
429
+ $result = @ssh2_sftp_unlink( $sftp, $remote_path );
430
+ } else {
431
+ $result = @ftp_delete( $this->_ftp, $remote_path );
432
+ }
433
 
434
  if ( $result ) {
435
  $results[] = $this->_get_result( $local_path, $remote_path,
445
  while ( true ) {
446
  $remote_path = dirname( $remote_path );
447
 
448
+ if ( $remote_path == '.' ) {
449
+ break;
450
+ }
451
+
452
+ if ( $this->_config['type'] == 'sftp' && !@ssh2_sftp_rmdir( $sftp, $remote_path ) ) {
453
+ break;
454
+ } else if ( !@ftp_rmdir( $this->_ftp, $remote_path ) ) {
455
  break;
456
  }
457
  }
474
  return false;
475
  }
476
 
477
+ if ( $this->_config['type'] == 'sftp' ) {
478
+ return $this->_test_sftp( $error );
479
+ }
480
+
481
  $rand = md5( time() );
482
  $tmp_dir = 'test_dir_' . $rand;
483
  $tmp_file = 'test_file_' . $rand;
574
  return true;
575
  }
576
 
577
+ /**
578
+ * Tests FTP server
579
+ *
580
+ * @param string $error
581
+ * @return boolean
582
+ */
583
+ function _test_sftp( &$error ) {
584
+
585
+ $rand = md5( time() );
586
+ $tmp_dir = 'test_dir_' . $rand;
587
+ $tmp_file = 'test_file_' . $rand;
588
+ $local_path = W3TC_CACHE_TMP_DIR . '/' . $tmp_file;
589
+ $remote_path = $tmp_dir . '/' . $tmp_file;
590
+
591
+ if ( !@file_put_contents( $local_path, $rand ) ) {
592
+ $error = sprintf( 'Unable to create file: %s.', $local_path );
593
+
594
+ return false;
595
+ }
596
+
597
+ if ( !$this->_connect( $error ) ) {
598
+ return false;
599
+ }
600
+
601
+ $sftp = @ssh2_sftp( $this->_ftp );
602
+
603
+ $this->_set_error_handler();
604
+
605
+ if ( !@ssh2_sftp_mkdir( $sftp, $tmp_dir ) ) {
606
+ $error = sprintf( 'Unable to make directory: %s (%s).', $tmp_dir, $this->_get_last_error() );
607
+
608
+ @unlink( $local_path );
609
+
610
+ $this->_restore_error_handler();
611
+ $this->_disconnect();
612
+
613
+ return false;
614
+ }
615
+
616
+ if ( file_exists( $this->_config['docroot'] . '/' . $tmp_dir ) ) {
617
+ $error = sprintf( 'Test directory was made in your site root, not on separate FTP host or path. Change path or FTP information: %s.', $tmp_dir );
618
+
619
+ @unlink( $local_path );
620
+ @ssh2_sftp_rmdir( $sftp, $tmp_dir );
621
+
622
+ $this->_restore_error_handler();
623
+ $this->_disconnect();
624
+
625
+ return false;
626
+ }
627
+
628
+ if ( !@ssh2_scp_send( $this->_ftp, $local_path, $remote_path ) ) {
629
+ $error = sprintf( 'Unable to upload file: %s (%s).', $local_path, $this->_get_last_error() );
630
+
631
+ @unlink( $local_path );
632
+ @ssh2_sftp_rmdir( $sftp, $tmp_dir );
633
+
634
+ $this->_restore_error_handler();
635
+ $this->_disconnect();
636
+
637
+ return false;
638
+ }
639
+
640
+ @unlink( $local_path );
641
+
642
+ if ( !@ssh2_sftp_unlink( $sftp, $remote_path ) ) {
643
+ $error = sprintf( 'Unable to delete file: %s (%s).', $local_path, $this->_get_last_error() );
644
+
645
+ @ssh2_sftp_rmdir( $sftp, $tmp_dir );
646
+
647
+ $this->_restore_error_handler();
648
+ $this->_disconnect();
649
+
650
+ return false;
651
+ }
652
+
653
+ if ( !@ssh2_sftp_rmdir( $sftp, $tmp_dir ) ) {
654
+ $error = sprintf( 'Unable to remove directory: %s (%s).', $tmp_dir, $this->_get_last_error() );
655
+
656
+ $this->_restore_error_handler();
657
+ $this->_disconnect();
658
+
659
+ return false;
660
+ }
661
+
662
+ $this->_restore_error_handler();
663
+ $this->_disconnect();
664
+
665
+ return true;
666
+ }
667
+
668
  /**
669
  * Returns array of CDN domains
670
  *
CdnEngine_GoogleDrive.php CHANGED
@@ -54,7 +54,7 @@ class CdnEngine_GoogleDrive extends CdnEngine_Base {
54
 
55
 
56
  private function _refresh_token() {
57
- $result = wp_remote_post( GOOGLE_DRIVE_AUTHORIZE_URL, array(
58
  'body' => array(
59
  'client_id' => $this->_client_id,
60
  'refresh_token' => $this->_refresh_token
54
 
55
 
56
  private function _refresh_token() {
57
+ $result = wp_remote_post( W3TC_GOOGLE_DRIVE_AUTHORIZE_URL, array(
58
  'body' => array(
59
  'client_id' => $this->_client_id,
60
  'refresh_token' => $this->_refresh_token
CdnEngine_Mirror_StackPath2.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ class CdnEngine_Mirror_StackPath2 extends CdnEngine_Mirror {
5
+ /**
6
+ * PHP5 Constructor
7
+ *
8
+ * @param array $config
9
+ */
10
+ function __construct( $config = array() ) {
11
+ $config = array_merge( array(
12
+ 'client_id' => '',
13
+ 'client_secret' => '',
14
+ 'stack_id' => '',
15
+ 'site_root_domain' => '',
16
+ 'access_token' => '',
17
+ 'on_new_access_token' => null
18
+ ), $config );
19
+
20
+ parent::__construct( $config );
21
+ }
22
+
23
+ /**
24
+ * Purges remote files
25
+ *
26
+ * @param array $files
27
+ * @param array $results
28
+ * @return boolean
29
+ */
30
+ function purge( $files, &$results ) {
31
+ if ( empty( $this->_config['client_id'] ) ) {
32
+ $results = $this->_get_results( $files, W3TC_CDN_RESULT_HALT, __( 'Empty Authorization Key.', 'w3-total-cache' ) );
33
+
34
+ return false;
35
+ }
36
+
37
+ $url_prefixes = $this->url_prefixes();
38
+ $api = new Cdn_StackPath2_Api( $this->_config );
39
+ $results = array();
40
+
41
+ try {
42
+ $items = array();
43
+ foreach ( $files as $file ) {
44
+ foreach ( $url_prefixes as $prefix ) {
45
+ $items[] = array( 'url' => $prefix . '/' . $file['remote_path'],
46
+ 'recursive' => true,
47
+ );
48
+ }
49
+ }
50
+ $api->purge( array( 'items' => $items ) );
51
+
52
+ $results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_OK, 'OK' );
53
+ } catch ( \Exception $e ) {
54
+ $results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_HALT, __( 'Failure to pull zone: ', 'w3-total-cache' ) . $e->getMessage() );
55
+ }
56
+
57
+ return !$this->_is_error( $results );
58
+ }
59
+
60
+ /**
61
+ * Purge CDN completely
62
+ *
63
+ * @param unknown $results
64
+ * @return bool
65
+ */
66
+ function purge_all( &$results ) {
67
+ if ( empty( $this->_config['client_id'] ) ) {
68
+ $results = $this->_get_results( $files, W3TC_CDN_RESULT_HALT, __( 'Empty Authorization Key.', 'w3-total-cache' ) );
69
+
70
+ return false;
71
+ }
72
+
73
+ $url_prefixes = $this->url_prefixes();
74
+ $api = new Cdn_StackPath2_Api( $this->_config );
75
+ $results = array();
76
+
77
+ try {
78
+ $items = array();
79
+ foreach ( $url_prefixes as $prefix ) {
80
+ $items[] = array( 'url' => $prefix . '/',
81
+ 'recursive' => true,
82
+ );
83
+ }
84
+
85
+ $r = $api->purge( array( 'items' => $items ) );
86
+ } catch ( \Exception $e ) {
87
+ $results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_HALT, __( 'Failure to pull zone: ', 'w3-total-cache' ) . $e->getMessage() );
88
+ }
89
+
90
+ return !$this->_is_error( $results );
91
+ }
92
+
93
+
94
+
95
+ private function url_prefixes() {
96
+ $url_prefixes = array();
97
+
98
+ if ( $this->_config['ssl'] == 'auto' ||
99
+ $this->_config['ssl'] == 'enabled' ) {
100
+ $url_prefixes[] = 'https://' . $this->_config['site_root_domain'];
101
+ }
102
+ if ( $this->_config['ssl'] == 'auto' ||
103
+ $this->_config['ssl'] != 'enabled' ) {
104
+ $url_prefixes[] = 'http://' . $this->_config['site_root_domain'];
105
+ }
106
+
107
+ return $url_prefixes;
108
+ }
109
+ }
CdnEngine_S3_Cf.php CHANGED
@@ -306,7 +306,7 @@ class CdnEngine_S3_Cf extends CdnEngine_S3 {
306
 
307
  foreach ( $_domains as $_domain ) {
308
  if ( !in_array( $_domain, $cnames ) ) {
309
- $error = sprintf( 'Domain name %s is not in distribution CNAME list.', $_domain );
310
 
311
  return false;
312
  }
306
 
307
  foreach ( $_domains as $_domain ) {
308
  if ( !in_array( $_domain, $cnames ) ) {
309
+ $error = sprintf( 'Domain name %s is not in distribution <acronym title="Canonical Name">CNAME</acronym> list.', $_domain );
310
 
311
  return false;
312
  }
Cdn_AdminActions.php CHANGED
@@ -405,11 +405,15 @@ class Cdn_AdminActions {
405
  $config['docroot'] = Util_Environment::document_root();
406
 
407
  if ( $result ) {
408
- if ( $engine == 'google_drive' || $engine == 'highwinds' ||
 
409
  $engine == 'limelight' ||
410
- $engine == 'maxcdn' || $engine == 'stackpath' ||
 
 
411
  $engine == 'rackspace_cdn' ||
412
- $engine == 'rscf' || $engine == 's3_compatible' ) {
 
413
  // those use already stored w3tc config
414
  $w3_cdn = Dispatcher::component( 'Cdn_Core' )->get_cdn();
415
  } else {
@@ -536,7 +540,7 @@ class Cdn_AdminActions {
536
  $state->save();
537
  }
538
  } catch ( \Exception $ex ) {}
539
- Util_Environment::redirect( MAXCDN_AUTHORIZE_URL );
540
  }
541
 
542
  function w3tc_cdn_maxcdn_signup() {
@@ -545,6 +549,6 @@ class Cdn_AdminActions {
545
  $state->set( 'track.maxcdn_signup', time() );
546
  $state->save();
547
  } catch ( \Exception $ex ) {}
548
- Util_Environment::redirect( MAXCDN_SIGNUP_URL );
549
  }
550
  }
405
  $config['docroot'] = Util_Environment::document_root();
406
 
407
  if ( $result ) {
408
+ if ( $engine == 'google_drive' ||
409
+ $engine == 'highwinds' ||
410
  $engine == 'limelight' ||
411
+ $engine == 'maxcdn' ||
412
+ $engine == 'stackpath' ||
413
+ $engine == 'stackpath2' ||
414
  $engine == 'rackspace_cdn' ||
415
+ $engine == 'rscf' ||
416
+ $engine == 's3_compatible' ) {
417
  // those use already stored w3tc config
418
  $w3_cdn = Dispatcher::component( 'Cdn_Core' )->get_cdn();
419
  } else {
540
  $state->save();
541
  }
542
  } catch ( \Exception $ex ) {}
543
+ Util_Environment::redirect( W3TC_MAXCDN_AUTHORIZE_URL );
544
  }
545
 
546
  function w3tc_cdn_maxcdn_signup() {
549
  $state->set( 'track.maxcdn_signup', time() );
550
  $state->save();
551
  } catch ( \Exception $ex ) {}
552
+ Util_Environment::redirect( W3TC_MAXCDN_SIGNUP_URL );
553
  }
554
  }
Cdn_ConfigLabels.php CHANGED
@@ -17,7 +17,7 @@ class Cdn_ConfigLabels {
17
  'cdn.import.external' => __( 'Import external media library attachments', 'w3-total-cache' ),
18
  'cdn.canonical_header' => __( 'Add canonical header', 'w3-total-cache' ),
19
  'cdn.reject.ssl' => __( 'Disable <acronym title="Content Delivery Network">CDN</acronym> on <acronym title="Secure Sockets Layer">SSL</acronym> pages', 'w3-total-cache' ),
20
- 'cdn.admin.media_library' => __( 'Use CDN links for the Media Library on admin pages', 'w3-total-cache' ),
21
  'cdn.reject.logged_roles' => __( 'Disable <acronym title="Content Delivery Network">CDN</acronym> for the following roles', 'w3-total-cache' ),
22
  'cdn.reject.uri' => __( 'Disable <acronym title="Content Delivery Network">CDN</acronym> on the following pages:', 'w3-total-cache' ),
23
  'cdn.autoupload.enabled' => __( 'Export changed files automatically', 'w3-total-cache' ),
17
  'cdn.import.external' => __( 'Import external media library attachments', 'w3-total-cache' ),
18
  'cdn.canonical_header' => __( 'Add canonical header', 'w3-total-cache' ),
19
  'cdn.reject.ssl' => __( 'Disable <acronym title="Content Delivery Network">CDN</acronym> on <acronym title="Secure Sockets Layer">SSL</acronym> pages', 'w3-total-cache' ),
20
+ 'cdn.admin.media_library' => __( 'Use <acronym title="Content Delivery Network">CDN</acronym> links for the Media Library on admin pages', 'w3-total-cache' ),
21
  'cdn.reject.logged_roles' => __( 'Disable <acronym title="Content Delivery Network">CDN</acronym> for the following roles', 'w3-total-cache' ),
22
  'cdn.reject.uri' => __( 'Disable <acronym title="Content Delivery Network">CDN</acronym> on the following pages:', 'w3-total-cache' ),
23
  'cdn.autoupload.enabled' => __( 'Export changed files automatically', 'w3-total-cache' ),
Cdn_Core.php CHANGED
@@ -266,7 +266,7 @@ class Cdn_Core {
266
 
267
  $return = $cdn->purge( $files, $results );
268
 
269
- if ( !$return && $queue_failed ) {
270
  foreach ( $results as $result ) {
271
  if ( $result['result'] != W3TC_CDN_RESULT_OK ) {
272
  $this->queue_add( $result['local_path'], $result['remote_path'], W3TC_CDN_COMMAND_PURGE, $result['error'] );
@@ -584,6 +584,24 @@ class Cdn_Core {
584
  );
585
  break;
586
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
587
  }
588
 
589
  $engine_config = array_merge( $engine_config, array(
@@ -631,6 +649,12 @@ class Cdn_Core {
631
  $state->save();
632
  }
633
 
 
 
 
 
 
 
634
  /**
635
  * Convert relative file which is relative to ABSPATH (wp folder on disc) to path uri
636
  *
266
 
267
  $return = $cdn->purge( $files, $results );
268
 
269
+ if ( !$return ) {
270
  foreach ( $results as $result ) {
271
  if ( $result['result'] != W3TC_CDN_RESULT_OK ) {
272
  $this->queue_add( $result['local_path'], $result['remote_path'], W3TC_CDN_COMMAND_PURGE, $result['error'] );
584
  );
585
  break;
586
 
587
+ case 'stackpath2':
588
+ $state = Dispatcher::config_state();
589
+
590
+ $engine_config = array(
591
+ 'client_id' => $c->get_string( 'cdn.stackpath2.client_id' ),
592
+ 'client_secret' => $c->get_string( 'cdn.stackpath2.client_secret' ),
593
+ 'stack_id' => $c->get_string( 'cdn.stackpath2.stack_id' ),
594
+ 'site_root_domain' => $c->get_string( 'cdn.stackpath2.site_root_domain' ),
595
+ 'domain' => $c->get_array( 'cdn.stackpath2.domain' ),
596
+ 'ssl' => $c->get_string( 'cdn.stackpath2.ssl' ),
597
+ 'access_token' => $state->get_string( 'cdn.stackpath2.access_token' ),
598
+ 'on_new_access_token' => array(
599
+ $this,
600
+ 'on_stackpath2_new_access_token'
601
+ )
602
+ );
603
+ break;
604
+
605
  }
606
 
607
  $engine_config = array_merge( $engine_config, array(
649
  $state->save();
650
  }
651
 
652
+ public function on_stackpath2_new_access_token( $access_token ) {
653
+ $state = Dispatcher::config_state();
654
+ $state->set( 'cdn.stackpath2.access_token', $access_token );
655
+ $state->save();
656
+ }
657
+
658
  /**
659
  * Convert relative file which is relative to ABSPATH (wp folder on disc) to path uri
660
  *
Cdn_GeneralPage_View.php CHANGED
@@ -9,9 +9,9 @@ Util_Ui::config_overloading_button( array(
9
  'key' => 'cdn.configuration_overloaded'
10
  ) );
11
  ?>
12
- <p><?php _e( 'Host static files with your content delivery network provider to reduce page load time.', 'w3-total-cache' ); ?>
13
  <?php if ( !$cdn_enabled ): ?>
14
- <?php printf( __( ' If you do not have a <acronym title="Content Delivery Network">CDN</acronym> provider try MaxCDN. <a href="%s" target="_blank">Sign up and save 25&#37;</a>.', 'w3-total-cache' ), wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ); ?>
15
  <?php endif ?>
16
  </p>
17
  <table class="form-table">
@@ -20,7 +20,7 @@ Util_Ui::config_item( array(
20
  'key' => 'cdn.enabled',
21
  'control' => 'checkbox',
22
  'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
23
- '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 site visitors.',
24
  'w3-total-cache' )
25
  ) );
26
 
9
  'key' => 'cdn.configuration_overloaded'
10
  ) );
11
  ?>
12
+ <p><?php w3tc_e( 'cdn.general.header', 'Host static files with your <acronym title="Content Delivery Network">CDN</acronym> to reduce page load time.' ); ?>
13
  <?php if ( !$cdn_enabled ): ?>
14
+ <?php printf( __( ' If you do not have a <acronym title="Content Delivery Network">CDN</acronym> provider try StackPath. <a href="%s" target="_blank">Sign up now to enjoy a special offer!</a>.', 'w3-total-cache' ), wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ); ?>
15
  <?php endif ?>
16
  </p>
17
  <table class="form-table">
20
  'key' => 'cdn.enabled',
21
  'control' => 'checkbox',
22
  'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
23
+ 'description' => __( 'Theme files, media library attachments, <acronym title="Cascading Style Sheet">CSS</acronym>, <acronym title="JavaScript">JS</acronym> files etc will quickly for site visitors.',
24
  'w3-total-cache' )
25
  ) );
26
 
Cdn_GoogleDrive_Page.php CHANGED
@@ -13,7 +13,7 @@ class Cdn_GoogleDrive_Page {
13
 
14
  wp_localize_script( 'w3tc_cdn_google_drive',
15
  'w3tc_cdn_google_drive_url',
16
- GOOGLE_DRIVE_AUTHORIZE_URL . '?return_url=' . urlencode( $return_url ) );
17
 
18
  // it's return from google oauth
19
  if ( isset( $_GET['oa_client_id'] ) ) {
13
 
14
  wp_localize_script( 'w3tc_cdn_google_drive',
15
  'w3tc_cdn_google_drive_url',
16
+ W3TC_GOOGLE_DRIVE_AUTHORIZE_URL . '?return_url=' . urlencode( $return_url ) );
17
 
18
  // it's return from google oauth
19
  if ( isset( $_GET['oa_client_id'] ) ) {
Cdn_Highwinds_Page_View.php CHANGED
@@ -21,7 +21,7 @@ $hash_code = $config->get_string( 'cdn.highwinds.host.hash_code' );
21
 
22
  <?php if ( !empty( $hash_code ) ): ?>
23
  <tr>
24
- <th><label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> host (CNAME target):', 'w3-total-cache' ); ?></label></th>
25
  <td class="w3tc_config_value_text">
26
  cds.<?php echo $config->get_string( 'cdn.highwinds.host.hash_code' ) ?>.hwcdn.net
27
  </td>
@@ -42,7 +42,7 @@ $hash_code = $config->get_string( 'cdn.highwinds.host.hash_code' );
42
  <td>
43
  <?php $cnames = $config->get_array( 'cdn.highwinds.host.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
44
  <input class="w3tc_cdn_highwinds_configure_cnames_form button" type="button"
45
- value="<?php _e( 'Configure CNAMEs', 'w3-total-cache' ); ?>" />
46
  <br />
47
  <span class="description"><?php _e( 'Hostname provided by your <acronym title="Content Delivery Network">CDN</acronym> provider, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
48
  </td>
21
 
22
  <?php if ( !empty( $hash_code ) ): ?>
23
  <tr>
24
+ <th><label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> host (<acronym title="Canonical Name">CNAME</acronym> target):', 'w3-total-cache' ); ?></label></th>
25
  <td class="w3tc_config_value_text">
26
  cds.<?php echo $config->get_string( 'cdn.highwinds.host.hash_code' ) ?>.hwcdn.net
27
  </td>
42
  <td>
43
  <?php $cnames = $config->get_array( 'cdn.highwinds.host.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
44
  <input class="w3tc_cdn_highwinds_configure_cnames_form button" type="button"
45
+ value="<?php _e( 'Configure <acronym title="Canonical Name">CNAME</acronym>s', 'w3-total-cache' ); ?>" />
46
  <br />
47
  <span class="description"><?php _e( 'Hostname provided by your <acronym title="Content Delivery Network">CDN</acronym> provider, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
48
  </td>
Cdn_Highwinds_Popup_View_ConfigureCnamesForm.php CHANGED
@@ -10,7 +10,7 @@ if ( !empty( $details['error_message'] ) )
10
  echo '<div class="error">' . $details['error_message'] . '</div>';
11
  ?>
12
  <div class="metabox-holder">
13
- <?php Util_Ui::postbox_header( __( 'CNAMEs to use', 'w3-total-cache' ) ); ?>
14
  <?php $cname_class = 'w3tc-ignore-change'; include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
15
  <br />
16
  <span class="description"><?php _e( 'Enter hostname mapped to <acronym title="Content Delivery Network">CDN</acronym> host, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
10
  echo '<div class="error">' . $details['error_message'] . '</div>';
11
  ?>
12
  <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( __( '<acronym title="Canonical Name">CNAME</acronym>s to use', 'w3-total-cache' ) ); ?>
14
  <?php $cname_class = 'w3tc-ignore-change'; include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
15
  <br />
16
  <span class="description"><?php _e( 'Enter hostname mapped to <acronym title="Content Delivery Network">CDN</acronym> host, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
Cdn_Highwinds_Widget.php CHANGED
@@ -9,7 +9,7 @@ class Cdn_Highwinds_Widget {
9
  add_action( 'admin_print_scripts',
10
  array( $o, 'admin_print_scripts' ) );
11
  add_action( 'w3tc_widget_setup',
12
- array( $o, 'w3tc_widget_setup' ) );
13
  }
14
 
15
 
9
  add_action( 'admin_print_scripts',
10
  array( $o, 'admin_print_scripts' ) );
11
  add_action( 'w3tc_widget_setup',
12
+ array( $o, 'w3tc_widget_setup' ), 2000 );
13
  }
14
 
15
 
Cdn_MaxCdn_Page_View.php CHANGED
@@ -9,9 +9,9 @@ if ( !defined( 'W3TC' ) )
9
  <tr>
10
  <th style="width: 300px;"><label><?php _e( 'Create account:', 'w3-total-cache' )?></label></th>
11
  <td>
12
- <a href="<?php esc_attr_e( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) )?>" target="_blank" id="netdna-maxcdn-create-account" class="button-primary"><?php _e( 'Sign Up Now and Save 25%', 'w3-total-cache' ) ?></a>
13
  <br />
14
- <span class="description"><?php _e( 'MaxCDN is a service that lets you speed up your site even more with W3 Total Cache. 100% Money Back Guarantee (30 Days)!', 'w3-total-cache' )?></span>
15
  </td>
16
  </tr>
17
  <?php endif ?>
@@ -43,13 +43,13 @@ if ( !defined( 'W3TC' ) )
43
  <?php if ( !is_null( $http_domain ) ): ?>
44
  <tr>
45
  <th>
46
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> HTTP CNAME:', 'w3-total-cache' ); ?></label>
47
  </th>
48
  <td class="w3tc_config_value_text">
49
  <?php echo htmlspecialchars( $http_domain ) ?><br />
50
  <span class="description">
51
  This website domain has to be CNAME pointing to this
52
- <acronym title="Content Delivery Network">CDN</acronym> domain for HTTP requests
53
  </span>
54
  </td>
55
  </tr>
@@ -57,13 +57,13 @@ if ( !defined( 'W3TC' ) )
57
  <?php if ( !is_null( $https_domain ) ): ?>
58
  <tr>
59
  <th>
60
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> HTTPS CNAME:', 'w3-total-cache' ); ?></label>
61
  </th>
62
  <td class="w3tc_config_value_text">
63
  <?php echo htmlspecialchars( $https_domain ) ?><br />
64
  <span class="description">
65
- This website domain has to be CNAME pointing to this
66
- <acronym title="Content Delivery Network">CDN</acronym> domain for HTTPS requests
67
  </span>
68
  </td>
69
  </tr>
@@ -74,8 +74,8 @@ if ( !defined( 'W3TC' ) )
74
  <td>
75
  <select id="cdn_maxcdn_ssl" name="cdn__maxcdn__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
76
  <option value="auto"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
77
- <option value="enabled"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' )?></option>
78
- <option value="disabled"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' )?></option>
79
  </select>
80
  <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' )?></span>
81
  </td>
9
  <tr>
10
  <th style="width: 300px;"><label><?php _e( 'Create account:', 'w3-total-cache' )?></label></th>
11
  <td>
12
+ <a href="<?php esc_attr_e( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) )?>" target="_blank" id="netdna-maxcdn-create-account" class="button-primary"><?php w3tc_e( 'cdn.maxcdn.signUpAndSave', 'Sign Up Now and save!' ) ?></a>
13
  <br />
14
+ <span class="description"><?php w3tc_e( 'cdn.maxcdn.signUpAndSave.description', 'MaxCDN is a service that lets you speed up your site even more with W3 Total Cache. Sign up now to recieve a special offer!' ) ?></span>
15
  </td>
16
  </tr>
17
  <?php endif ?>
43
  <?php if ( !is_null( $http_domain ) ): ?>
44
  <tr>
45
  <th>
46
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="Hypertext Transfer Protocol">HTTP</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
47
  </th>
48
  <td class="w3tc_config_value_text">
49
  <?php echo htmlspecialchars( $http_domain ) ?><br />
50
  <span class="description">
51
  This website domain has to be CNAME pointing to this
52
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="Hypertext Transfer Protocol">HTTP</acronym> requests
53
  </span>
54
  </td>
55
  </tr>
57
  <?php if ( !is_null( $https_domain ) ): ?>
58
  <tr>
59
  <th>
60
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="Hypertext Transfer Protocol">HTTP</acronym>S <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
61
  </th>
62
  <td class="w3tc_config_value_text">
63
  <?php echo htmlspecialchars( $https_domain ) ?><br />
64
  <span class="description">
65
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
66
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
67
  </span>
68
  </td>
69
  </tr>
74
  <td>
75
  <select id="cdn_maxcdn_ssl" name="cdn__maxcdn__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
76
  <option value="auto"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
77
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use <acronym title="Secure Sockets Layer">SSL</acronym>)', 'w3-total-cache' )?></option>
78
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use <acronym title="Hypertext Transfer Protocol">HTTP</acronym>)', 'w3-total-cache' )?></option>
79
  </select>
80
  <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' )?></span>
81
  </td>
Cdn_MaxCdn_Popup_View_Intro.php CHANGED
@@ -18,11 +18,11 @@ if ( isset( $details['error_message'] ) )
18
  <td>
19
  <input name="api_key" type="text" class="w3tc-ignore-change"
20
  style="width: 550px"
21
- value="<?php echo $details['api_key'] ?>" />
22
  <br />
23
  <span class="description">
24
  To obtain API key you can
25
- <a target="_blank" href="<?php echo $url_obtain_key ?>">click here</a>,
26
  log in, and paste the key in above field.
27
  </span>
28
  </td>
18
  <td>
19
  <input name="api_key" type="text" class="w3tc-ignore-change"
20
  style="width: 550px"
21
+ value="<?php echo esc_attr( $details['api_key'] ) ?>" />
22
  <br />
23
  <span class="description">
24
  To obtain API key you can
25
+ <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
26
  log in, and paste the key in above field.
27
  </span>
28
  </td>
Cdn_Plugin.php CHANGED
@@ -17,11 +17,13 @@ class Cdn_Plugin {
17
  * Config
18
  */
19
  private $_config = null;
 
20
 
21
- private $_replaced_urls = array();
22
 
23
  function __construct() {
24
  $this->_config = Dispatcher::config();
 
25
  }
26
 
27
  /**
@@ -63,14 +65,24 @@ class Cdn_Plugin {
63
 
64
  }
65
 
66
- add_action( 'delete_attachment',
67
- array( $this, 'delete_attachment' ) );
 
 
 
 
 
 
 
 
 
68
 
69
- add_filter( 'update_attached_file',
70
- array( $this, 'update_attached_file' ) );
 
71
 
72
- add_filter( 'wp_update_attachment_metadata',
73
- array( $this, 'update_attachment_metadata' ) );
74
 
75
  add_filter( 'w3tc_admin_bar_menu',
76
  array( $this, 'w3tc_admin_bar_menu' ) );
@@ -99,6 +111,9 @@ class Cdn_Plugin {
99
  'media_row_actions'
100
  ), 0, 2 );
101
  }
 
 
 
102
  }
103
 
104
  /**
@@ -138,6 +153,22 @@ class Cdn_Plugin {
138
  $common->upload( $upload, true, $results );
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  /**
142
  * Update attachment file
143
  *
@@ -155,7 +186,9 @@ class Cdn_Plugin {
155
 
156
  $cdn_engine = $this->_config->get_string( 'cdn.engine' );
157
  if ( Cdn_Util::is_engine_mirror( $cdn_engine ) ) {
158
- $common->purge( $files, $results );
 
 
159
  } else {
160
  $common->upload( $files, true, $results );
161
  }
@@ -278,7 +311,12 @@ class Cdn_Plugin {
278
  if ( $this->can_cdn2( $buffer ) ) {
279
  $srcset_helper = new _Cdn_Plugin_ContentFilter();
280
  $buffer = $srcset_helper->replace_all_links( $buffer );
281
- $this->_replaced_urls = $srcset_helper->get_replaced_urls();
 
 
 
 
 
282
  }
283
  }
284
 
@@ -714,6 +752,34 @@ class Cdn_Plugin {
714
  return $url;
715
  }
716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  public function w3tc_admin_bar_menu( $menu_items ) {
718
  $cdn_engine = $this->_config->get_string( 'cdn.engine' );
719
 
@@ -752,23 +818,34 @@ class Cdn_Plugin {
752
  ( empty( $this->cdn_reject_reason ) ? '' :
753
  sprintf( ' (%s)', $this->cdn_reject_reason ) ) );
754
 
755
- if ( $this->_config->get_boolean( 'cdn.debug' ) ) {
756
- $strings[] = '';
757
- $strings[] = 'CDN debug info:';
758
 
759
- if ( count( $this->_replaced_urls ) ) {
760
- $strings[] = "Replaced URLs:";
761
 
762
- foreach ( $this->_footer_comment_postfix as $old_url => $new_url ) {
763
- $strings[] = sprintf( "%s => %s",
764
- Util_Content::escape_comment( $old_url ),
765
- Util_Content::escape_comment( $new_url ) );
766
- }
 
 
 
 
 
 
 
 
767
  }
 
768
  $strings[] = '';
769
  }
770
 
771
- return $strings;
 
 
772
  }
773
  }
774
 
@@ -777,7 +854,8 @@ class _Cdn_Plugin_ContentFilter {
777
  private $_regexps = array();
778
  private $_placeholders = array();
779
  private $_config;
780
- private $_replaced_urls;
 
781
  /**
782
  * If background uploading already scheduled
783
  *
@@ -1097,8 +1175,8 @@ class _Cdn_Plugin_ContentFilter {
1097
  /**
1098
  * Check if URL was already replaced
1099
  */
1100
- if ( isset( $this->replaced_urls[$url] ) ) {
1101
- return $quote . $this->replaced_urls[$url];
1102
  }
1103
 
1104
  /**
@@ -1156,7 +1234,7 @@ class _Cdn_Plugin_ContentFilter {
1156
  $common = Dispatcher::component( 'Cdn_Core' );
1157
  $new_url = $common->url_to_cdn_url( $url, $path );
1158
  if ( !is_null( $new_url ) ) {
1159
- $this->replaced_urls[$url] = $new_url;
1160
  return $quote . $new_url;
1161
  }
1162
 
@@ -1199,17 +1277,6 @@ class _Cdn_Plugin_ContentFilter {
1199
  }
1200
 
1201
  function get_replaced_urls() {
1202
- $strings = array();
1203
- if ( count( $this->_replaced_urls ) ) {
1204
- $strings[] = "Replaced URLs:";
1205
-
1206
- foreach ( $this->_replaced_urls as $old_url => $new_url ) {
1207
- $strings[] = sprintf( "%s => %s",
1208
- Util_Content::escape_comment( $old_url ),
1209
- Util_Content::escape_comment( $new_url ) );
1210
- }
1211
- }
1212
- return $strings;
1213
  }
1214
-
1215
  }
17
  * Config
18
  */
19
  private $_config = null;
20
+ private $_debug = false;
21
 
22
+ private $_attachments_action = array();
23
 
24
  function __construct() {
25
  $this->_config = Dispatcher::config();
26
+ $this->_debug = $this->_config->get_boolean( 'cdn.debug' );
27
  }
28
 
29
  /**
65
 
66
  }
67
 
68
+ $flush_on_actions = !$this->_config->get_boolean( 'cdn.flush_manually' );
69
+
70
+ if ( $flush_on_actions ) {
71
+ add_action( 'delete_attachment',
72
+ array( $this, 'delete_attachment' ) );
73
+
74
+ add_filter( 'wp_insert_attachment_data',
75
+ array( $this, 'check_inserting_new_attachment' ) );
76
+
77
+ add_filter( 'update_attached_file',
78
+ array( $this, 'update_attached_file' ) );
79
 
80
+ add_filter( 'wp_update_attachment_metadata',
81
+ array( $this, 'update_attachment_metadata' ) );
82
+ }
83
 
84
+ add_filter( 'w3tc_preflush_cdn_all',
85
+ array( $this, 'w3tc_preflush_cdn_all' ), 10, 2 );
86
 
87
  add_filter( 'w3tc_admin_bar_menu',
88
  array( $this, 'w3tc_admin_bar_menu' ) );
111
  'media_row_actions'
112
  ), 0, 2 );
113
  }
114
+
115
+ add_filter( 'w3tc_minify_http2_preload_url',
116
+ array( $this, 'w3tc_minify_http2_preload_url' ), 3000 );
117
  }
118
 
119
  /**
153
  $common->upload( $upload, true, $results );
154
  }
155
 
156
+ function check_inserting_new_attachment( $data, $postarr ) {
157
+ $this->_attachments_action[ $postarr['file'] ] = empty( $postarr['ID'] ) ? 'insert' : 'update';
158
+
159
+ return $data;
160
+ }
161
+
162
+ public function w3tc_preflush_cdn_all( $do_flush, $extras = array() ) {
163
+ if ( $this->_config->get_boolean( 'cdn.flush_manually' ) ) {
164
+ if ( !isset( $extras['ui_action'] ) ) {
165
+ $do_flush = false;
166
+ }
167
+ }
168
+
169
+ return $do_flush;
170
+ }
171
+
172
  /**
173
  * Update attachment file
174
  *
186
 
187
  $cdn_engine = $this->_config->get_string( 'cdn.engine' );
188
  if ( Cdn_Util::is_engine_mirror( $cdn_engine ) ) {
189
+ if ( ! array_key_exists( $attached_file, $this->_attachments_action ) || $this->_attachments_action[ $attached_file ] === 'update' ) {
190
+ $common->purge( $files, $results );
191
+ }
192
  } else {
193
  $common->upload( $files, true, $results );
194
  }
311
  if ( $this->can_cdn2( $buffer ) ) {
312
  $srcset_helper = new _Cdn_Plugin_ContentFilter();
313
  $buffer = $srcset_helper->replace_all_links( $buffer );
314
+
315
+ if ( $this->_debug ) {
316
+ $replaced_urls = $srcset_helper->get_replaced_urls();
317
+ $buffer = $this->w3tc_footer_comment_after(
318
+ $buffer, $replaced_urls );
319
+ }
320
  }
321
  }
322
 
752
  return $url;
753
  }
754
 
755
+ /**
756
+ * Mutate http/2 header links
757
+ */
758
+ public function w3tc_minify_http2_preload_url( $data ) {
759
+ $url = $data['result_link'];
760
+
761
+ $url = trim( $url );
762
+ if ( empty( $url ) ) {
763
+ return $data;
764
+ }
765
+
766
+ $parsed = parse_url( $url );
767
+ $uri = ( isset( $parsed['path'] ) ? $parsed['path'] : '/' ) .
768
+ ( isset( $parsed['query'] ) ? '?' . $parsed['query'] : '' );
769
+
770
+ $common = Dispatcher::component( 'Cdn_Core' );
771
+ $new_url = $common->url_to_cdn_url( $url, $uri );
772
+ if ( is_null( $new_url ) ) {
773
+ return $data;
774
+ }
775
+
776
+ $data['result_link'] = $new_url;
777
+ // url_to_cdn_url processed by browsercache internally
778
+ $data['browsercache_processed'] = '*';
779
+
780
+ return $data;
781
+ }
782
+
783
  public function w3tc_admin_bar_menu( $menu_items ) {
784
  $cdn_engine = $this->_config->get_string( 'cdn.engine' );
785
 
818
  ( empty( $this->cdn_reject_reason ) ? '' :
819
  sprintf( ' (%s)', $this->cdn_reject_reason ) ) );
820
 
821
+ if ( $this->_debug ) {
822
+ $strings[] = '{w3tc_cdn_debug_info}';
823
+ }
824
 
825
+ return $strings;
826
+ }
827
 
828
+
829
+
830
+ public function w3tc_footer_comment_after( $buffer, $replaced_urls ) {
831
+ $strings = array();
832
+
833
+ if ( is_array( $replaced_urls ) &&
834
+ count( $replaced_urls ) ) {
835
+ $strings[] = "Replaced URLs for CDN:";
836
+
837
+ foreach ( $replaced_urls as $old_url => $new_url ) {
838
+ $strings[] = sprintf( "%s => %s",
839
+ Util_Content::escape_comment( $old_url ),
840
+ Util_Content::escape_comment( $new_url ) );
841
  }
842
+
843
  $strings[] = '';
844
  }
845
 
846
+ $buffer = str_replace( '{w3tc_cdn_debug_info}',
847
+ implode( "\n", $strings ), $buffer );
848
+ return $buffer;
849
  }
850
  }
851
 
854
  private $_regexps = array();
855
  private $_placeholders = array();
856
  private $_config;
857
+ private $_replaced_urls = array();
858
+
859
  /**
860
  * If background uploading already scheduled
861
  *
1175
  /**
1176
  * Check if URL was already replaced
1177
  */
1178
+ if ( isset( $this->_replaced_urls[$url] ) ) {
1179
+ return $quote . $this->_replaced_urls[$url];
1180
  }
1181
 
1182
  /**
1234
  $common = Dispatcher::component( 'Cdn_Core' );
1235
  $new_url = $common->url_to_cdn_url( $url, $path );
1236
  if ( !is_null( $new_url ) ) {
1237
+ $this->_replaced_urls[$url] = $new_url;
1238
  return $quote . $new_url;
1239
  }
1240
 
1277
  }
1278
 
1279
  function get_replaced_urls() {
1280
+ return $this->_replaced_urls;
 
 
 
 
 
 
 
 
 
 
1281
  }
 
1282
  }
Cdn_Plugin_Admin.php CHANGED
@@ -15,13 +15,13 @@ class Cdn_Plugin_Admin {
15
  add_filter( 'w3tc_errors', array( $admin_notes, 'w3tc_errors' ) );
16
 
17
  if ( $c->get_boolean( 'cdn.admin.media_library' ) &&
18
- $c->get_boolean( 'cdn.uploads.enable' ) ) {
19
 
20
- add_filter( 'wp_get_attachment_url',
21
- array( $this, 'wp_get_attachment_url' ), 0 );
22
 
23
- add_filter( 'attachment_link',
24
- array( $this, 'wp_get_attachment_url' ), 0 );
25
  }
26
  }
27
 
@@ -113,6 +113,31 @@ class Cdn_Plugin_Admin {
113
  add_action( 'w3tc_ajax_cdn_stackpath_widgetdata', array(
114
  '\W3TC\Cdn_StackPath_Widget',
115
  'w3tc_ajax_cdn_stackpath_widgetdata' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
  add_action( 'w3tc_settings_general_boxarea_cdn', array(
@@ -173,8 +198,12 @@ class Cdn_Plugin_Admin {
173
  'label' => __( 'RackSpace CDN', 'w3-total-cache' ),
174
  'optgroup' => $optgroup_pull
175
  );
 
 
 
 
176
  $engine_values['stackpath'] = array(
177
- 'label' => __( 'StackPath', 'w3-total-cache' ),
178
  'optgroup' => $optgroup_pull
179
  );
180
  $engine_values['edgecast'] = array(
@@ -230,7 +259,7 @@ class Cdn_Plugin_Admin {
230
  * @param string $url the local url to modify
231
  * @return string
232
  */
233
- function wp_get_attachment_url( $url ) {
234
  if ( defined( 'WP_ADMIN' ) ) {
235
  $url = trim( $url );
236
 
@@ -252,6 +281,6 @@ class Cdn_Plugin_Admin {
252
  }
253
  }
254
 
255
- return $url;
256
- }
257
  }
15
  add_filter( 'w3tc_errors', array( $admin_notes, 'w3tc_errors' ) );
16
 
17
  if ( $c->get_boolean( 'cdn.admin.media_library' ) &&
18
+ $c->get_boolean( 'cdn.uploads.enable' ) ) {
19
 
20
+ add_filter( 'wp_get_attachment_url',
21
+ array( $this, 'wp_get_attachment_url' ), 0 );
22
 
23
+ add_filter( 'attachment_link',
24
+ array( $this, 'wp_get_attachment_url' ), 0 );
25
  }
26
  }
27
 
113
  add_action( 'w3tc_ajax_cdn_stackpath_widgetdata', array(
114
  '\W3TC\Cdn_StackPath_Widget',
115
  'w3tc_ajax_cdn_stackpath_widgetdata' ) );
116
+ } elseif ( $cdn_engine == 'stackpath2' ) {
117
+ add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
118
+ '\W3TC\Cdn_StackPath2_Page',
119
+ 'admin_print_scripts_w3tc_cdn' ) );
120
+ add_action( 'w3tc_ajax', array(
121
+ '\W3TC\Cdn_StackPath2_Popup',
122
+ 'w3tc_ajax' ) );
123
+ add_action( 'w3tc_settings_cdn_boxarea_configuration', array(
124
+ '\W3TC\Cdn_StackPath2_Page',
125
+ 'w3tc_settings_cdn_boxarea_configuration'
126
+ ) );
127
+ add_action( 'admin_init_w3tc_dashboard', array(
128
+ '\W3TC\Cdn_StackPath2_Widget',
129
+ 'admin_init_w3tc_dashboard' ) );
130
+ add_action( 'w3tc_ajax_cdn_stackpath2_widgetdata', array(
131
+ '\W3TC\Cdn_StackPath2_Widget',
132
+ 'w3tc_ajax_cdn_stackpath2_widgetdata' ) );
133
+ } else {
134
+ // default cdn widget
135
+ add_action( 'admin_init_w3tc_dashboard', array(
136
+ '\W3TC\Cdn_StackPath2_Widget',
137
+ 'admin_init_w3tc_dashboard' ) );
138
+ add_action( 'w3tc_ajax_cdn_stackpath2_widgetdata', array(
139
+ '\W3TC\Cdn_StackPath2_Widget',
140
+ 'w3tc_ajax_cdn_stackpath2_widgetdata' ) );
141
  }
142
 
143
  add_action( 'w3tc_settings_general_boxarea_cdn', array(
198
  'label' => __( 'RackSpace CDN', 'w3-total-cache' ),
199
  'optgroup' => $optgroup_pull
200
  );
201
+ $engine_values['stackpath2'] = array(
202
+ 'label' => __( 'StackPath (recommended)', 'w3-total-cache' ),
203
+ 'optgroup' => $optgroup_pull
204
+ );
205
  $engine_values['stackpath'] = array(
206
+ 'label' => __( 'StackPath SecureCDN (Legacy)', 'w3-total-cache' ),
207
  'optgroup' => $optgroup_pull
208
  );
209
  $engine_values['edgecast'] = array(
259
  * @param string $url the local url to modify
260
  * @return string
261
  */
262
+ function wp_get_attachment_url( $url ) {
263
  if ( defined( 'WP_ADMIN' ) ) {
264
  $url = trim( $url );
265
 
281
  }
282
  }
283
 
284
+ return $url;
285
+ }
286
  }
Cdn_Plugin_WidgetMaxCdn.php CHANGED
@@ -23,11 +23,11 @@ class Cdn_Plugin_WidgetMaxCdn {
23
  add_action( 'w3tc_widget_setup', array(
24
  $this,
25
  'wp_dashboard_setup'
26
- ), 100 );
27
  add_action( 'w3tc_network_dashboard_setup', array(
28
  $this,
29
  'wp_dashboard_setup'
30
- ), 100 );
31
 
32
  // Configure authorize and have_zone
33
  $this->authorized = $this->_config->get_string( 'cdn.maxcdn.authorization_key' ) != '' &&
23
  add_action( 'w3tc_widget_setup', array(
24
  $this,
25
  'wp_dashboard_setup'
26
+ ), 2000 );
27
  add_action( 'w3tc_network_dashboard_setup', array(
28
  $this,
29
  'wp_dashboard_setup'
30
+ ), 2000 );
31
 
32
  // Configure authorize and have_zone
33
  $this->authorized = $this->_config->get_string( 'cdn.maxcdn.authorization_key' ) != '' &&
Cdn_Plugin_WidgetMaxCdn_View_Unauthorized.php CHANGED
@@ -6,11 +6,11 @@ if ( !defined( 'W3TC' ) )
6
 
7
  ?>
8
  <div id="maxcdn-widget" class="w3tcmaxcdn_signup">
9
- <p><?php _e( 'Dramatically increase website speeds in just a few clicks! Add the MaxCDN content delivery network service to your site.', 'w3-total-cache' )?></p>
10
  <h4 class="w3tcmaxcdn_signup_h4"><?php _e( 'New customers', 'w3-total-cache' )?></h4>
11
  <p><?php _e( 'MaxCDN works magically with W3 Total Cache.', 'w3-total-cache' )?></p>
12
- <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' )?>" target="_blank"><?php _e( 'Sign Up Now and Save 25%', 'w3-total-cache' )?></a>
13
- <p><span class="desc"><?php _e( '100% Money Back Guarantee (30 Days)', 'w3-total-cache' )?></span></p>
14
  <h4 class="w3tcmaxcdn_signup_h4"><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
15
  <p><?php _e( "Existing MaxCDN customers, enable <acronym title='Content Delivery Network'>CDN</acronym> and:", 'w3-total-cache' )?></p>
16
  <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' )?>" target="_blank"><?php _e( 'Authorize', 'w3-total-cache' )?></a>
6
 
7
  ?>
8
  <div id="maxcdn-widget" class="w3tcmaxcdn_signup">
9
+ <p><?php _e( 'Dramatically increase website speeds in just a few clicks! Add the MaxCDN content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) service to your site.', 'w3-total-cache' )?></p>
10
  <h4 class="w3tcmaxcdn_signup_h4"><?php _e( 'New customers', 'w3-total-cache' )?></h4>
11
  <p><?php _e( 'MaxCDN works magically with W3 Total Cache.', 'w3-total-cache' )?></p>
12
+ <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' )?>" target="_blank"><?php _e( 'Create an Account', 'w3-total-cache' )?></a>
13
+ <p><span class="desc"><?php _e( 'Exclusive offers availabel for W3TC users!', 'w3-total-cache' )?></span></p>
14
  <h4 class="w3tcmaxcdn_signup_h4"><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
15
  <p><?php _e( "Existing MaxCDN customers, enable <acronym title='Content Delivery Network'>CDN</acronym> and:", 'w3-total-cache' )?></p>
16
  <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' )?>" target="_blank"><?php _e( 'Authorize', 'w3-total-cache' )?></a>
Cdn_RackSpaceCdn_AdminActions.php CHANGED
@@ -14,7 +14,7 @@ class Cdn_RackSpaceCdn_AdminActions {
14
  $domains = $cdn->service_domains_get();
15
  } catch ( \Exception $ex ) {
16
  Util_Admin::redirect_with_custom_messages2( array(
17
- 'errors' => array( 'Failed to obtain CNAMEs: ' . $ex->getMessage() )
18
  ), true );
19
  return;
20
  }
14
  $domains = $cdn->service_domains_get();
15
  } catch ( \Exception $ex ) {
16
  Util_Admin::redirect_with_custom_messages2( array(
17
+ 'errors' => array( 'Failed to obtain <acronym title="Canonical Name">CNAME</acronym>s: ' . $ex->getMessage() )
18
  ), true );
19
  return;
20
  }
Cdn_RackSpaceCdn_Page_View.php CHANGED
@@ -38,7 +38,7 @@ if ( !defined( 'W3TC' ) )
38
  </td>
39
  </tr>
40
  <tr>
41
- <th><label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> host (CNAME target):', 'w3-total-cache' ); ?></label></th>
42
  <td class="w3tc_config_value_text">
43
  <?php echo $access_url_full ?>
44
  </td>
@@ -63,7 +63,7 @@ if ( !defined( 'W3TC' ) )
63
  <?php $cnames = $config->get_array( 'cdn.rackspace_cdn.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
64
  <input name="w3tc_cdn_rackspace_cdn_domains_reload"
65
  class="w3tc-button-save button" type="submit"
66
- value="<?php _e( 'Reload CNAMEs from RackSpace', 'w3-total-cache' ); ?>" />
67
  <br />
68
  <span class="description">
69
  <?php _e( 'Hostname(s) mapped to <acronym title="Content Delivery Network">CDN</acronym> host, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>. You can manage them from RackSpace management console and load here afterwards.', 'w3-total-cache' ); ?>
38
  </td>
39
  </tr>
40
  <tr>
41
+ <th><label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> host (<acronym title="Canonical Name">CNAME</acronym> target):', 'w3-total-cache' ); ?></label></th>
42
  <td class="w3tc_config_value_text">
43
  <?php echo $access_url_full ?>
44
  </td>
63
  <?php $cnames = $config->get_array( 'cdn.rackspace_cdn.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
64
  <input name="w3tc_cdn_rackspace_cdn_domains_reload"
65
  class="w3tc-button-save button" type="submit"
66
+ value="<?php _e( 'Reload C<acronym title="Canonical Name">CNAME</acronym>s from RackSpace', 'w3-total-cache' ); ?>" />
67
  <br />
68
  <span class="description">
69
  <?php _e( 'Hostname(s) mapped to <acronym title="Content Delivery Network">CDN</acronym> host, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>. You can manage them from RackSpace management console and load here afterwards.', 'w3-total-cache' ); ?>
Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php CHANGED
@@ -10,7 +10,7 @@ if ( !empty( $details['error_message'] ) )
10
  echo '<div class="error">' . $details['error_message'] . '</div>';
11
  ?>
12
  <div class="metabox-holder">
13
- <?php Util_Ui::postbox_header( __( 'CNAMEs to use', 'w3-total-cache' ) ); ?>
14
  <?php $cname_class = 'w3tc-ignore-change'; include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
15
  <br />
16
  <span class="description"><?php _e( 'Enter hostname mapped to <acronym title="Content Delivery Network">CDN</acronym> host, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
10
  echo '<div class="error">' . $details['error_message'] . '</div>';
11
  ?>
12
  <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( __( '<acronym title="Canonical Name">CNAME</acronym>s to use', 'w3-total-cache' ) ); ?>
14
  <?php $cname_class = 'w3tc-ignore-change'; include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
15
  <br />
16
  <span class="description"><?php _e( 'Enter hostname mapped to <acronym title="Content Delivery Network">CDN</acronym> host, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
Cdn_RackSpaceCdn_Popup_View_Service_Create.php CHANGED
@@ -58,7 +58,7 @@ if ( isset( $details['error_message'] ) )
58
  </tr>
59
  <tr class="w3tc_cdn_rackspace_cname_http"
60
  style="<?php echo $details['cname_http_style'] ?>">
61
- <th style="white-space: nowrap">Primary CNAME:</td>
62
  <td>
63
  <input name="cname_http" type="text" class="w3tc-ignore-change"
64
  style="width: 200px"
@@ -71,7 +71,7 @@ if ( isset( $details['error_message'] ) )
71
  </tr>
72
  <tr class="w3tc_cdn_rackspace_cname_https"
73
  style="<?php echo $details['cname_https_style'] ?>">
74
- <th style="white-space: nowrap">Primary CNAME:</td>
75
  <td>
76
  <input name="cname_https_prefix" type="text" class="w3tc-ignore-change"
77
  style="width: 100px"
58
  </tr>
59
  <tr class="w3tc_cdn_rackspace_cname_http"
60
  style="<?php echo $details['cname_http_style'] ?>">
61
+ <th style="white-space: nowrap">Primary <acronym title="Canonical Name">CNAME</acronym>:</td>
62
  <td>
63
  <input name="cname_http" type="text" class="w3tc-ignore-change"
64
  style="width: 200px"
71
  </tr>
72
  <tr class="w3tc_cdn_rackspace_cname_https"
73
  style="<?php echo $details['cname_https_style'] ?>">
74
+ <th style="white-space: nowrap">Primary <acronym title="Canonical Name">CNAME</acronym>:</td>
75
  <td>
76
  <input name="cname_https_prefix" type="text" class="w3tc-ignore-change"
77
  style="width: 100px"
Cdn_RackSpaceCloudFiles_Page_View.php CHANGED
@@ -38,7 +38,7 @@ if ( !defined( 'W3TC' ) )
38
  </td>
39
  </tr>
40
  <tr>
41
- <th><label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> host (CNAME target):', 'w3-total-cache' ); ?></label></th>
42
  <td class="w3tc_config_value_text">
43
  http: <?php echo $cdn_host_http ?><br />
44
  https: <?php echo $cdn_host_https ?>
38
  </td>
39
  </tr>
40
  <tr>
41
+ <th><label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> host (<acronym title="Canonical Name">CNAME</acronym> target):', 'w3-total-cache' ); ?></label></th>
42
  <td class="w3tc_config_value_text">
43
  http: <?php echo $cdn_host_http ?><br />
44
  https: <?php echo $cdn_host_https ?>
Cdn_StackPath2_Api.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ /**
5
+ * StackPath REST Client Library
6
+ */
7
+ class Cdn_StackPath2_Api {
8
+ private $client_id;
9
+ private $client_secret;
10
+ private $stack_id;
11
+ private $access_token;
12
+ private $on_new_access_token;
13
+
14
+
15
+
16
+ public function __construct( $config ) {
17
+ $this->client_id = $config['client_id'];
18
+ $this->client_secret = $config['client_secret'];
19
+ $this->stack_id = isset( $config['stack_id'] ) ? $config['stack_id'] : '';
20
+ $this->access_token =
21
+ isset( $config['access_token'] ) ? $config['access_token'] : '';
22
+ $this->on_new_access_token =
23
+ isset( $config['on_new_access_token'] ) ? $config['on_new_access_token'] : null;
24
+ }
25
+
26
+
27
+
28
+ public function authenticate() {
29
+ $request_json = array(
30
+ 'client_id' => $this->client_id,
31
+ 'client_secret' => $this->client_secret,
32
+ 'grant_type' => 'client_credentials'
33
+ );
34
+
35
+ $result = wp_remote_post(
36
+ 'https://gateway.stackpath.com/identity/v1/oauth2/token',
37
+ array(
38
+ 'headers' => array(
39
+ 'Accept' => 'application/json',
40
+ 'Content-Type' => 'application/json'
41
+ ),
42
+ 'body' => json_encode( $request_json )
43
+ )
44
+ );
45
+
46
+ $r = $this->_decode_response( $result );
47
+ if ( $r['auth_required'] ) {
48
+ throw new \Exception( 'Authentication failed' );
49
+ }
50
+ if ( !isset( $r['response_json']['access_token'] ) ) {
51
+ throw new \Exception(
52
+ 'Unexpected authentication response: access token not found' );
53
+ }
54
+
55
+ $this->access_token = $r['response_json']['access_token'];
56
+ return $this->access_token;
57
+ }
58
+
59
+
60
+ public function site_list() {
61
+ return $this->_wp_remote_get(
62
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/sites" );
63
+ }
64
+
65
+
66
+
67
+ public function site_get( $site_id ) {
68
+ return $this->_wp_remote_get(
69
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/sites/$site_id" );
70
+ }
71
+
72
+
73
+
74
+ public function site_create( $data ) {
75
+ return $this->_wp_remote_post(
76
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/sites", $data );
77
+ }
78
+
79
+
80
+
81
+ public function site_metrics( $site_id, $days ) {
82
+ $d = new \DateTime();
83
+
84
+ $end_date = $d->format( 'Y-m-d' ) . 'T00:00:00Z';
85
+ $start_date = $d->sub( new \DateInterval( 'P' . $days . 'D' ) )->format( 'Y-m-d' ) . 'T00:00:00Z';
86
+
87
+ return $this->_wp_remote_get(
88
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/metrics",
89
+ array(
90
+ 'site_id' => $site_id,
91
+ 'start_date' => $start_date,
92
+ 'end_date' => $end_date,
93
+ 'platforms' => 'CDS',
94
+ 'granularity' => 'P1D'
95
+ )
96
+ );
97
+ }
98
+
99
+
100
+
101
+ public function purge( $data ) {
102
+ return $this->_wp_remote_post(
103
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/purge", $data );
104
+ }
105
+
106
+
107
+
108
+ public function site_dns_targets_get( $site_id ) {
109
+ return $this->_wp_remote_get(
110
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/sites/$site_id/dns/targets" );
111
+ }
112
+
113
+
114
+
115
+ private function site_scope_get_by_platform( $site_id, $platform ) {
116
+ $scopes = $this->_wp_remote_get(
117
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/sites/$site_id/scopes" );
118
+ foreach ( $scopes['results'] as $scope ) {
119
+ if ( $scope['platform'] == $platform )
120
+ return $scope;
121
+ }
122
+
123
+ return null;
124
+ }
125
+
126
+
127
+
128
+ public function site_cds_get( $site_id ) {
129
+ $scope = $this->site_scope_get_by_platform( $site_id, 'CDS' );
130
+ $scope_id = $scope['id'];
131
+
132
+ return $this->_wp_remote_get(
133
+ "https://gateway.stackpath.com/cdn/v1/stacks/$this->stack_id/sites/$site_id/scopes/$scope_id/configuration" );
134
+ }
135
+
136
+
137
+ public function stacks_list() {
138
+ return $this->_wp_remote_get( 'https://gateway.stackpath.com/stack/v1/stacks' );
139
+ }
140
+
141
+
142
+
143
+ public function stack_get( $stack_id ) {
144
+ return $this->_wp_remote_get( "https://gateway.stackpath.com/stack/v1/stacks/$stack_id" );
145
+ }
146
+
147
+
148
+
149
+ private function _decode_response( $result ) {
150
+ if ( is_wp_error( $result ) )
151
+ throw new \Exception( 'Failed to reach API endpoint' );
152
+
153
+ $response_json = @json_decode( $result['body'], true );
154
+ if ( is_null( $response_json ) )
155
+ throw new \Exception(
156
+ 'Failed to reach API endpoint, got unexpected response ' .
157
+ $result['body'] );
158
+
159
+ if ( $result['response']['code'] == '401' ) {
160
+ return array(
161
+ 'auth_required' => true,
162
+ 'response_json' => array()
163
+ );
164
+ }
165
+
166
+ if ( $result['response']['code'] != '200' && $result['response']['code'] != '201' ) {
167
+ if ( isset( $response_json['message'] ) ) {
168
+ throw new \Exception( $response_json['message'] );
169
+ } else {
170
+ throw new \Exception( 'response code ' .
171
+ $result['response']['code'] . ' with ' . $result['body'] );
172
+ }
173
+ }
174
+
175
+ return array(
176
+ 'auth_required' => false,
177
+ 'response_json' => $response_json
178
+ );
179
+ }
180
+
181
+
182
+
183
+ private function _wp_remote_get( $url, $data = array() ) {
184
+ //var_dump( $url );
185
+ //var_dump( array( 'headers' => 'authorization: Bearer ' . $this->access_token ) );
186
+
187
+ if ( !empty( $this->access_token ) ) {
188
+ $result = wp_remote_get(
189
+ $url . ( empty( $data ) ? '' : '?' . http_build_query( $data ) ),
190
+ array(
191
+ 'headers' => 'authorization: Bearer ' . $this->access_token
192
+ )
193
+ );
194
+
195
+ $r = self::_decode_response( $result );
196
+ if ( !$r['auth_required'] ) {
197
+ return $r['response_json'];
198
+ }
199
+ }
200
+
201
+ $this->authenticate();
202
+ if ( !is_null( $this->on_new_access_token ) ) {
203
+ call_user_func( $this->on_new_access_token, $this->access_token );
204
+ }
205
+
206
+ return $this->_wp_remote_get( $url, $data );
207
+ }
208
+
209
+
210
+
211
+ private function _wp_remote_post( $url, $data ) {
212
+ if ( !empty( $this->access_token ) ) {
213
+ add_filter( 'http_request_timeout', array( $this, 'filter_timeout_time' ) );
214
+ add_filter( 'https_ssl_verify', array( $this, 'https_ssl_verify' ) );
215
+
216
+ $result = wp_remote_post( $url, array(
217
+ 'headers' => array(
218
+ 'authorization' => 'Bearer ' . $this->access_token,
219
+ 'Accept' => 'application/json',
220
+ 'Content-Type' => 'application/json'
221
+ ),
222
+ 'body' => json_encode( $data )
223
+ ) );
224
+
225
+ remove_filter( 'https_ssl_verify', array( $this, 'https_ssl_verify' ) );
226
+ remove_filter( 'http_request_timeout', array( $this, 'filter_timeout_time' ) );
227
+
228
+ $r = self::_decode_response( $result );
229
+ if ( !$r['auth_required'] ) {
230
+ return $r['response_json'];
231
+ }
232
+ }
233
+
234
+ $this->authenticate();
235
+ if ( !is_null( $this->on_new_access_token ) ) {
236
+ call_user_func( $this->on_new_access_token, $this->access_token );
237
+ }
238
+
239
+ return $this->_wp_remote_post( $url, $data );
240
+ }
241
+
242
+
243
+
244
+ /**
245
+ * Increase http request timeout to 60 seconds
246
+ */
247
+ public function filter_timeout_time($time) {
248
+ return 600;
249
+ }
250
+
251
+ /**
252
+ * Don't check certificate, some users have limited CA list
253
+ */
254
+ public function https_ssl_verify($v) {
255
+ return false;
256
+ }
257
+ }
Cdn_StackPath2_Page.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+
5
+
6
+ class Cdn_StackPath2_Page {
7
+ // called from plugin-admin
8
+ static public function admin_print_scripts_w3tc_cdn() {
9
+ wp_enqueue_script( 'w3tc_cdn_stackpath',
10
+ plugins_url( 'Cdn_StackPath2_Page_View.js', W3TC_FILE ),
11
+ array( 'jquery' ), '1.0' );
12
+ }
13
+
14
+
15
+
16
+ static public function w3tc_settings_cdn_boxarea_configuration() {
17
+ $config = Dispatcher::config();
18
+ $client_id = $config->get_string( 'cdn.stackpath2.client_id' );
19
+ $site_id = $config->get_string( 'cdn.stackpath2.site_id' );
20
+ $domains = $config->get_array( 'cdn.stackpath2.domain' );
21
+
22
+ $authorized = !empty( $client_id ) && !empty( $site_id );
23
+ $http_domain = isset( $domains['http_default'] ) ? $domains['http_default'] : null;
24
+ $https_domain = isset( $domains['https_default'] ) ? $domains['https_default'] : null;
25
+
26
+ include W3TC_DIR . '/Cdn_StackPath2_Page_View.php';
27
+ }
28
+ }
Cdn_StackPath2_Page_View.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+ function w3tc_stackpath_resize(o) {
3
+ o.options.height = jQuery('.w3tc_cdn_stackpath2_form').height();
4
+ o.resize();
5
+ }
6
+
7
+ $('body')
8
+ .on('click', '.w3tc_cdn_stackpath2_authorize', function() {
9
+ W3tc_Lightbox.open({
10
+ id:'w3tc-overlay',
11
+ close: '',
12
+ width: 800,
13
+ height: 300,
14
+ url: ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
15
+ '&w3tc_action=cdn_stackpath2_intro',
16
+ callback: w3tc_stackpath_resize
17
+ });
18
+ })
19
+
20
+
21
+
22
+ .on('click', '.w3tc_cdn_stackpath2_list_stacks', function() {
23
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
24
+ '&w3tc_action=cdn_stackpath2_list_stacks';
25
+
26
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_form', w3tc_stackpath_resize);
27
+ })
28
+
29
+
30
+
31
+ .on('click', '.w3tc_cdn_stackpath2_list_sites', function() {
32
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
33
+ '&w3tc_action=cdn_stackpath2_list_sites';
34
+
35
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_form', w3tc_stackpath_resize);
36
+ })
37
+
38
+
39
+
40
+ .on('click', '.w3tc_cdn_stackpath2_view_site', function() {
41
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
42
+ '&w3tc_action=cdn_stackpath2_view_site';
43
+
44
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_form', w3tc_stackpath_resize);
45
+ })
46
+
47
+
48
+
49
+ .on('click', '.w3tc_cdn_stackpath2_configure_site', function() {
50
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
51
+ '&w3tc_action=cdn_stackpath2_configure_site';
52
+
53
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_form', w3tc_stackpath_resize);
54
+ })
55
+
56
+
57
+
58
+ .on('click', '.w3tc_cdn_stackpath2_configure_site_skip', function() {
59
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
60
+ '&w3tc_action=cdn_stackpath2_configure_site_skip';
61
+
62
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_form', w3tc_stackpath_resize);
63
+ })
64
+
65
+
66
+
67
+ .on('click', '.w3tc_cdn_stackpath2_done', function() {
68
+ // refresh page
69
+ window.location = window.location + '&';
70
+ })
71
+ });
Cdn_StackPath2_Page_View.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+
7
+ ?>
8
+ <?php if ( !$authorized ): ?>
9
+ <tr>
10
+ <th style="width: 300px;"><label><?php _e( 'Create account:', 'w3-total-cache' )?></label></th>
11
+ <td>
12
+ <a href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL )?>" target="_blank" id="netdna-stackpath-create-account" class="button-primary"><?php w3tc_e( 'cdn.stackpath2.signUpAndSave', 'Sign Up Now and save!' ) ?></a>
13
+ <br />
14
+ <span class="description"><?php w3tc_e( 'cdn.stackpath2.signUpAndSave.description', 'StackPath is a service that lets you speed up your site even more with W3 Total Cache. Sign up now to recieve a special offer!' ) ?></span>
15
+ </td>
16
+ </tr>
17
+ <?php endif ?>
18
+
19
+
20
+
21
+ <tr>
22
+ <th style="width: 300px;">
23
+ <label>
24
+ <?php _e( 'Specify account credentials:', 'w3-total-cache' ); ?>
25
+ </label>
26
+ </th>
27
+ <td>
28
+ <?php if ( $authorized ): ?>
29
+ <input class="w3tc_cdn_stackpath2_authorize button-primary"
30
+ type="button"
31
+ value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
32
+ />
33
+ <?php else: ?>
34
+ <input class="w3tc_cdn_stackpath2_authorize button-primary"
35
+ type="button"
36
+ value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
37
+ />
38
+ <?php endif ?>
39
+ </td>
40
+ </tr>
41
+
42
+ <?php if ( $authorized ): ?>
43
+ <?php if ( !is_null( $http_domain ) ): ?>
44
+ <tr>
45
+ <th>
46
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="HyperText Transfer Protocol">HTTP</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
47
+ </th>
48
+ <td class="w3tc_config_value_text">
49
+ <?php echo htmlspecialchars( $http_domain ) ?><br />
50
+ <span class="description">
51
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
52
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol">HTTP</acronym> requests
53
+ </span>
54
+ </td>
55
+ </tr>
56
+ <?php endif ?>
57
+ <?php if ( !is_null( $https_domain ) ): ?>
58
+ <tr>
59
+ <th>
60
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
61
+ </th>
62
+ <td class="w3tc_config_value_text">
63
+ <?php echo htmlspecialchars( $https_domain ) ?><br />
64
+ <span class="description">
65
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
66
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
67
+ </span>
68
+ </td>
69
+ </tr>
70
+ <?php endif ?>
71
+
72
+ <tr>
73
+ <th><label for="cdn_stackpath_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support', 'w3-total-cache' )?>:</label></th>
74
+ <td>
75
+ <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
76
+ <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
77
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use <acronym title="Secure Sockets Layer">SSL</acronym>)', 'w3-total-cache' )?></option>
78
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use <acronym title="HyperText Transfer Protocol">HTTP</acronym>)', 'w3-total-cache' )?></option>
79
+ </select>
80
+ <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' )?></span>
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' )?></th>
85
+ <td>
86
+ <?php $cnames = $config->get_array( 'cdn.stackpath2.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
87
+ <br /><span class="description"><?php _e( 'Enter the hostname provided by your <acronym title="Content Delivery Network">CDN</acronym> provider, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' )?></span>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <th colspan="2">
92
+ <input id="cdn_test" class="button {type: 'stackpath', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test StackPath', 'w3-total-cache' )?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
93
+ </th>
94
+ </tr>
95
+
96
+ <?php endif ?>
Cdn_StackPath2_Popup.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+
5
+
6
+ class Cdn_StackPath2_Popup {
7
+ static public function w3tc_ajax() {
8
+ $o = new Cdn_StackPath2_Popup();
9
+
10
+ add_action( 'w3tc_ajax_cdn_stackpath2_intro',
11
+ array( $o, 'w3tc_ajax_cdn_stackpath2_intro' ) );
12
+ add_action( 'w3tc_ajax_cdn_stackpath2_list_stacks',
13
+ array( $o, 'w3tc_ajax_cdn_stackpath2_list_stacks' ) );
14
+ add_action( 'w3tc_ajax_cdn_stackpath2_list_sites',
15
+ array( $o, 'w3tc_ajax_cdn_stackpath2_list_sites' ) );
16
+ add_action( 'w3tc_ajax_cdn_stackpath2_configure_site',
17
+ array( $o, 'w3tc_ajax_cdn_stackpath2_configure_site' ) );
18
+ }
19
+
20
+
21
+
22
+ public function w3tc_ajax_cdn_stackpath2_intro() {
23
+ $config = Dispatcher::config();
24
+
25
+ $this->render_intro( array(
26
+ 'client_id' => $config->get_string( 'cdn.stackpath2.client_id' ),
27
+ 'client_secret' => $config->get_string( 'cdn.stackpath2.client_secret' )
28
+ ) );
29
+ }
30
+
31
+
32
+
33
+ private function render_intro( $details ) {
34
+ $config = Dispatcher::config();
35
+ $url_obtain_key = W3TC_STACKPATH2_AUTHORIZE_URL;
36
+
37
+ include W3TC_DIR . '/Cdn_StackPath2_Popup_View_Intro.php';
38
+ exit();
39
+ }
40
+
41
+
42
+
43
+ public function w3tc_ajax_cdn_stackpath2_list_stacks() {
44
+ $api_config = array(
45
+ 'client_id' => $_REQUEST['client_id'],
46
+ 'client_secret' => $_REQUEST['client_secret']
47
+ );
48
+
49
+ $api = new Cdn_StackPath2_Api( $api_config );
50
+
51
+ try {
52
+ $r = $r = $api->stacks_list();
53
+ $stacks = $r['results'];
54
+ } catch ( \Exception $ex ) {
55
+ $error_message = 'Can\'t authenticate: ' . $ex->getMessage();
56
+
57
+ $this->render_intro( array(
58
+ 'client_id' => $api_config['client_id'],
59
+ 'client_secret' => $api_config['client_secret'],
60
+ 'error_message' => $error_message
61
+ ) );
62
+ exit();
63
+ }
64
+
65
+ $count = 0;
66
+ $stack_id = '';
67
+ foreach ( $stacks as $i ) {
68
+ if ( $i['status'] == 'ACTIVE' ) {
69
+ $count++;
70
+ $stack_id = $i['id'];
71
+ }
72
+ }
73
+
74
+ if ( $count == 1 ) {
75
+ $api_config['stack_id'] = $stack_id;
76
+ $this->_w3tc_ajax_cdn_stackpath2_list_sites( $api_config );
77
+ exit();
78
+ }
79
+
80
+ $details = array(
81
+ 'api_config' => $this->api_config_encode( $api_config ),
82
+ 'stacks' => $stacks
83
+ );
84
+
85
+ include W3TC_DIR . '/Cdn_StackPath2_Popup_View_Stacks.php';
86
+ exit();
87
+ }
88
+
89
+
90
+
91
+ public function w3tc_ajax_cdn_stackpath2_list_sites() {
92
+ $api_config = $this->api_config_decode( $_REQUEST['api_config'] );
93
+ $api_config['stack_id'] = $_REQUEST['stack_id'];
94
+ $this->_w3tc_ajax_cdn_stackpath2_list_sites( $api_config );
95
+ }
96
+
97
+
98
+
99
+ private function _w3tc_ajax_cdn_stackpath2_list_sites( $api_config ) {
100
+ $api = new Cdn_StackPath2_Api( $api_config );
101
+
102
+ try {
103
+ $r = $api->site_list();
104
+ $sites = $r['results'];
105
+ } catch ( \Exception $ex ) {
106
+ $error_message = 'Can\'t authenticate: ' . $ex->getMessage();
107
+
108
+ $this->render_intro( array(
109
+ 'client_id' => $api_config['client_id'],
110
+ 'client_secret' => $api_config['client_secret'],
111
+ 'stack_id' => $api_config['stack_id'],
112
+ 'error_message' => $error_message
113
+ ) );
114
+ exit();
115
+ }
116
+
117
+ $details = array(
118
+ 'api_config' => $this->api_config_encode( $api_config ),
119
+ 'sites' => $sites,
120
+ 'new_hostname' => parse_url( home_url(), PHP_URL_HOST )
121
+ );
122
+
123
+ include W3TC_DIR . '/Cdn_StackPath2_Popup_View_Sites.php';
124
+ exit();
125
+ }
126
+
127
+
128
+
129
+ public function w3tc_ajax_cdn_stackpath2_configure_site() {
130
+ $api_config = $this->api_config_decode( $_REQUEST['api_config'] );
131
+ $site_id = Util_Request::get( 'site_id', '' );
132
+
133
+ $api = new Cdn_StackPath2_Api( $api_config );
134
+ $cors_present = false;
135
+
136
+ try {
137
+ if ( empty( $site_id ) ) {
138
+ // create new zone mode
139
+ $hostname = parse_url( home_url(), PHP_URL_HOST );
140
+
141
+ $r = $api->site_create( array(
142
+ 'domain' => $hostname,
143
+ 'origin' => array(
144
+ 'path' => '/',
145
+ 'hostname' => $hostname,
146
+ 'port' => 80,
147
+ 'securePort' => 443
148
+ ),
149
+ 'features' => array( 'CDN' )
150
+ ) );
151
+
152
+ $site_id = $r['site']['id'];
153
+ }
154
+
155
+ $r = $api->site_dns_targets_get( $site_id );
156
+ $domains = $r['addresses'];
157
+
158
+ $cds = $api->site_cds_get( $site_id );
159
+
160
+ if ( isset( $cds['configuration'] ) &&
161
+ isset( $cds['configuration']['staticHeader'] ) ) {
162
+ $headers = $cds['configuration']['staticHeader'];
163
+
164
+ $cors_present = isset( $headers[0] ) &&
165
+ isset( $headers[0]['http'] ) &&
166
+ preg_match( '/access\-control\-allow\-origin/i', $headers[0]['http'] );
167
+ }
168
+ } catch ( \Exception $ex ) {
169
+ $this->render_intro( array(
170
+ 'client_id' => $api_config['client_id'],
171
+ 'client_secret' => $api_config['client_secret'],
172
+ 'stack_id' => $api_config['stack_id'],
173
+ 'error_message' => 'Can\'t obtain site: ' . $ex->getMessage()
174
+ ) );
175
+ exit();
176
+ }
177
+
178
+ $c = Dispatcher::config();
179
+ $c->set( 'cdn.stackpath2.client_id', $api_config['client_id'] );
180
+ $c->set( 'cdn.stackpath2.client_secret', $api_config['client_secret'] );
181
+ $c->set( 'cdn.stackpath2.stack_id', $api_config['stack_id'] );
182
+ $c->set( 'cdn.stackpath2.site_id', $site_id );
183
+ $c->set( 'cdn.stackpath2.site_root_domain', $domains[0] );
184
+ $c->set( 'cdn.stackpath2.domain', $domains );
185
+ $c->set( 'cdn.cors_header', !$cors_present );
186
+ $c->save();
187
+
188
+ include W3TC_DIR . '/Cdn_StackPath2_Popup_View_Success.php';
189
+ exit();
190
+ }
191
+
192
+
193
+
194
+ private function api_config_encode( $c ) {
195
+ return implode( ';', array(
196
+ $c['client_id'], $c['client_secret'],
197
+ isset( $c['stack_id'] ) ? $c['stack_id'] : ''
198
+ ) );
199
+ }
200
+
201
+
202
+
203
+ private function api_config_decode( $s ) {
204
+ $a = explode( ';', $s );
205
+ return array(
206
+ 'client_id' => $a[0],
207
+ 'client_secret' => $a[1],
208
+ 'stack_id' => $a[2]
209
+ );
210
+ }
211
+ }
Cdn_StackPath2_Popup_View_Intro.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_form">
8
+ <?php
9
+ if ( isset( $details['error_message'] ) )
10
+ echo '<div class="error">' . $details['error_message'] . '</div>';
11
+ ?>
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header(
14
+ __( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
15
+ <table class="form-table">
16
+ <tr>
17
+ <td>API Client ID:</td>
18
+ <td>
19
+ <input name="client_id" type="text" class="w3tc-ignore-change"
20
+ style="width: 550px"
21
+ value="<?php echo esc_attr( $details['client_id'] ) ?>" />
22
+ </td>
23
+ </tr>
24
+ <tr>
25
+ <td>API Client Secret:</td>
26
+ <td>
27
+ <input name="client_secret" type="text" class="w3tc-ignore-change"
28
+ style="width: 550px"
29
+ value="<?php echo esc_attr( $details['client_secret'] ) ?>" />
30
+ <br />
31
+ <span class="description">
32
+ To obtain API key you can
33
+ <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
34
+ log in, and paste the key in above field.
35
+ </span>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+
40
+ <p class="submit">
41
+ <input type="button"
42
+ class="w3tc_cdn_stackpath2_list_stacks w3tc-button-save button-primary"
43
+ value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
44
+ </p>
45
+ <?php Util_Ui::postbox_footer(); ?>
46
+ </div>
47
+ </form>
Cdn_StackPath2_Popup_View_Sites.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_form" method="post">
8
+ <?php
9
+ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
10
+ ?>
11
+ <div class="metabox-holder">
12
+ <?php Util_Ui::postbox_header( __( 'Select site to use', 'w3-total-cache' ) ); ?>
13
+ <table class="form-table">
14
+ <tr>
15
+ <td>Site:</td>
16
+ <td>
17
+ <?php
18
+ if ( count( $details['sites'] ) > 15 ) {
19
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
+ }
21
+ ?>
22
+
23
+ <?php foreach ( $details['sites'] as $i ): ?>
24
+
25
+ <label>
26
+ <input name="site_id" type="radio" class="w3tc-ignore-change"
27
+ value="<?php echo esc_attr( $i['id'] ) ?>" />
28
+ <?php echo esc_html( $i['label'] ) ?>
29
+ </label><br />
30
+ <?php endforeach ?>
31
+
32
+ <label>
33
+ <input name="site_id" type="radio" class="w3tc-ignore-change" value=""
34
+ />
35
+ Add new site: <?php echo esc_html( $details['new_hostname'] ) ?>
36
+ </label>
37
+
38
+ <?php
39
+ if ( count( $details['sites'] ) > 15 ) {
40
+ echo '</div>';
41
+ }
42
+ ?>
43
+ </td>
44
+ </tr>
45
+ </table>
46
+
47
+ <p class="submit">
48
+ <input type="button"
49
+ class="w3tc_cdn_stackpath2_configure_site w3tc-button-save button-primary"
50
+ value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
51
+ </p>
52
+ <?php Util_Ui::postbox_footer(); ?>
53
+ </div>
54
+ </form>
Cdn_StackPath2_Popup_View_Stacks.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_form" method="post">
8
+ <?php
9
+ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
10
+ ?>
11
+ <div class="metabox-holder">
12
+ <?php Util_Ui::postbox_header( __( 'Select stack to use', 'w3-total-cache' ) ); ?>
13
+ <table class="form-table">
14
+ <tr>
15
+ <td>Site:</td>
16
+ <td>
17
+ <?php
18
+ if ( count( $details['stacks'] ) > 15 ) {
19
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
+ }
21
+ ?>
22
+
23
+ <?php foreach ( $details['stacks'] as $i ): ?>
24
+
25
+ <label>
26
+ <input name="stack_id" type="radio" class="w3tc-ignore-change"
27
+ value="<?php echo esc_attr( $i['id'] ) ?>" />
28
+ <?php echo esc_html( $i['name'] ) ?>
29
+ <?php if ( $i['status'] != 'ACTIVE' ): ?>
30
+ (<?php echo esc_html( $i['status'] ) ?>)
31
+ <?php endif ?>
32
+ </label><br />
33
+ <?php endforeach ?>
34
+
35
+ <?php
36
+ if ( count( $details['stacks'] ) > 15 ) {
37
+ echo '</div>';
38
+ }
39
+ ?>
40
+ </td>
41
+ </tr>
42
+ </table>
43
+
44
+ <p class="submit">
45
+ <input type="button"
46
+ class="w3tc_cdn_stackpath2_list_sites w3tc-button-save button-primary"
47
+ value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
48
+ </p>
49
+ <?php Util_Ui::postbox_footer(); ?>
50
+ </div>
51
+ </form>
Cdn_StackPath2_Popup_View_Success.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_form">
8
+ <div class="metabox-holder">
9
+ <?php Util_Ui::postbox_header(
10
+ __( 'Succeeded', 'w3-total-cache' ) ); ?>
11
+
12
+ <div style="text-align: center">
13
+ Site was successfully configured.<br />
14
+ </div>
15
+
16
+ <p class="submit">
17
+ <input type="button"
18
+ class="w3tc_cdn_stackpath2_done w3tc-button-save button-primary"
19
+ value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
20
+ </p>
21
+ <?php Util_Ui::postbox_footer(); ?>
22
+ </div>
23
+ </form>
Cdn_StackPath2_Widget.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ class Cdn_StackPath2_Widget {
5
+ static public function admin_init_w3tc_dashboard() {
6
+ $o = new Cdn_StackPath2_Widget();
7
+ add_action( 'admin_print_styles',
8
+ array( $o, 'admin_print_styles' ) );
9
+ add_action( 'admin_print_scripts',
10
+ array( $o, 'admin_print_scripts' ) );
11
+ add_action( 'w3tc_widget_setup',
12
+ array( $o, 'w3tc_widget_setup' ), 2000 );
13
+ }
14
+
15
+
16
+
17
+ public function w3tc_widget_setup() {
18
+ Util_Widget::add( 'w3tc_stackpath',
19
+ '<div class="w3tc-widget-stackpath2-logo"></div>',
20
+ array( $this, 'widget_form' ),
21
+ Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ),
22
+ 'normal' );
23
+ }
24
+
25
+ /**
26
+ * Runs plugin
27
+ */
28
+ function widget_form() {
29
+ $c = Dispatcher::config();
30
+
31
+ // Configure authorize and have_zone
32
+ $authorized = $c->get_string( 'cdn.stackpath2.client_id' ) != '' &&
33
+ $c->get_string( 'cdn.engine' ) == 'stackpath2';
34
+
35
+ if ( $authorized ) {
36
+ include dirname( __FILE__ ) . DIRECTORY_SEPARATOR .
37
+ 'Cdn_StackPath2_Widget_View_Authorized.php';
38
+ } else {
39
+ include dirname( __FILE__ ) . DIRECTORY_SEPARATOR .
40
+ 'Cdn_StackPath2_Widget_View_Unauthorized.php';
41
+ }
42
+ }
43
+
44
+
45
+
46
+ static function w3tc_ajax_cdn_stackpath2_widgetdata() {
47
+ $c = Dispatcher::config();
48
+ $cs = Dispatcher::config_state();
49
+
50
+ $api = new Cdn_StackPath2_Api( array(
51
+ 'client_id' => $c->get_string( 'cdn.stackpath2.client_id' ),
52
+ 'client_secret' => $c->get_string( 'cdn.stackpath2.client_secret' ),
53
+ 'stack_id' => $c->get_string( 'cdn.stackpath2.stack_id' ),
54
+ 'access_token' => $cs->get_string( 'cdn.stackpath2.access_token' )
55
+ ) );
56
+
57
+ $stack_id = $c->get_string( 'cdn.stackpath2.stack_id' );
58
+ $site_id = $c->get_string( 'cdn.stackpath2.site_id' );
59
+ $response = array();
60
+
61
+ try {
62
+ $r = $api->site_metrics( $site_id, 7 );
63
+ $series = $r['series'][0];
64
+
65
+ $keys = $series['metrics'];
66
+ $stats = array();
67
+ foreach ($series['samples'] as $sample) {
68
+ $row = array();
69
+ for ( $n = 0; $n < count( $keys ); $n++ ) {
70
+ $row[$keys[$n]] = $sample['values'][$n];
71
+ }
72
+
73
+ $stats[] = $row;
74
+ }
75
+
76
+ $total_mb = 0;
77
+ $total_requests = 0;
78
+ $chart_mb = array( array('Date', 'MB', 'Requests' ) );
79
+
80
+ $dd = new \DateTime();
81
+
82
+ foreach ($stats as $r) {
83
+ $total_mb += $r['xferUsedTotalMB'];
84
+ $total_requests += $r['requestsCountTotal'];
85
+ $d = $dd->setTimestamp( (int)$r['usageTime'] );
86
+ $chart_mb[] = array(
87
+ $d->format( 'M/d' ),
88
+ $r['xferUsedTotalMB'],
89
+ $r['requestsCountTotal']
90
+ );
91
+ }
92
+
93
+ $response['summary_mb'] = sprintf( '%.2f MB', $total_mb );
94
+ $response['summary_requests'] = $total_requests;
95
+ $response['chart_mb'] = $chart_mb;
96
+
97
+ $response['url_manage'] =
98
+ "https://control.stackpath.com/stacks/$stack_id/cdn/sites/$site_id/cache";
99
+ $response['url_reports'] =
100
+ "https://control.stackpath.com/stacks/$stack_id/cdn/sites/$site_id/overview";
101
+ } catch ( \Exception $ex ) {
102
+ $response['error'] = $ex->getMessage();
103
+ }
104
+
105
+ echo json_encode( $response );
106
+ }
107
+
108
+
109
+
110
+
111
+
112
+ public function admin_print_styles() {
113
+ wp_enqueue_style( 'w3tc-widget' );
114
+ wp_enqueue_style( 'w3tc-stackpath-widget',
115
+ plugins_url( 'Cdn_StackPath2_Widget_View.css', W3TC_FILE ),
116
+ array(), W3TC_VERSION );
117
+ }
118
+
119
+
120
+
121
+ public function admin_print_scripts() {
122
+ wp_enqueue_style( 'w3tc-widget' );
123
+ wp_enqueue_script( 'google-jsapi', 'https://www.google.com/jsapi');
124
+ wp_enqueue_script( 'w3tc-stackpath-widget',
125
+ plugins_url( 'Cdn_StackPath2_Widget_View.js', W3TC_FILE ),
126
+ array( 'google-jsapi' ), W3TC_VERSION );
127
+ wp_enqueue_script( 'w3tc-metadata' );
128
+ wp_enqueue_script( 'w3tc-widget' );
129
+ }
130
+
131
+ }
Cdn_StackPath2_Widget_View.css ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .w3tc-widget-stackpath2-logo {
2
+ width: 150px;
3
+ height: 35px;
4
+ background: url("pub/img/w3tc_stackpath_logo.svg") 0 8px no-repeat;
5
+ float: left;
6
+ }
7
+
8
+ .w3tcstackpath2_h4 {
9
+ text-align: center;
10
+ }
11
+ .w3tcstackpath2_summary_h4 {
12
+ text-align: center;
13
+ color: #8F8F8F;
14
+ text-align: left;
15
+ margin: 0;
16
+ }
17
+ .w3tcstackpath2_summary {
18
+ border-bottom: 1px solid #d2d2d2;
19
+ padding-left: 10px;
20
+ padding-right: 10px;
21
+ }
22
+ .w3tcstackpath2_wrapper {
23
+ margin-left: -10px;
24
+ margin-right: -10px;
25
+ }
26
+ .w3tcstackpath2_ul li {
27
+ margin-bottom: 3px;
28
+ padding: 0;
29
+ }
30
+ .w3tcstackpath2_summary_col1 {
31
+ display: block;
32
+ font-weight: bold;
33
+ width: 90px;
34
+ float:left;
35
+ }
36
+ .w3tcstackpath2_summary_col2 {
37
+ display: block;
38
+ font-weight: bold;
39
+ width: 80px;
40
+ float:left;
41
+ }
42
+ .w3tcstackpath2_tools {
43
+ margin-top:15px;
44
+ padding-left: 10px;
45
+ padding-right: 10px;
46
+ }
47
+ .w3tcstackpath2_tools li {
48
+ display:inline-block;
49
+ margin-right:10px;
50
+ }
51
+ .w3tcstackpath2_chart {
52
+ clear: both;
53
+ padding-left: 10px;
54
+ padding-right: 10px;
55
+ }
56
+ .w3tcstackpath2_chart p {
57
+ color:#8F8F8F;
58
+ margin:0;
59
+ }
60
+
61
+ .w3tcstackpath2_wrapper .button-secondary{
62
+ margin-bottom: 3px;
63
+ }
64
+
65
+ .w3tcstackpath2_signup_h4 {
66
+ text-align: left;
67
+ margin-bottom: 0;
68
+ padding-bottom: 0;
69
+ }
70
+
71
+ .w3tcstackpath2_signup p{
72
+ margin-top: 4px;
73
+ padding-top: 0;
74
+
75
+ }
76
+ .w3tcstackpath2_signup p span.desc {
77
+ color:#8F8F8F;
78
+ }
Cdn_StackPath2_Widget_View.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var w3tcstackpath2_graph_data;
2
+
3
+ function w3tcstackpath2_load() {
4
+ jQuery('.w3tcstackpath2_loading').removeClass('w3tc_hidden');
5
+ jQuery('.w3tcstackpath2_content').addClass('w3tc_hidden');
6
+ jQuery('.w3tcstackpath2_error').addClass('w3tc_none');
7
+
8
+ jQuery.getJSON(ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
9
+ '&w3tc_action=cdn_stackpath2_widgetdata',
10
+ function(data) {
11
+ if (data && data.error) {
12
+ jQuery('.w3tcstackpath2_error').removeClass('w3tc_none');
13
+ jQuery('.w3tcstackpath2_error_details').html(data.error);
14
+ jQuery('.w3tcstackpath2_loading').addClass('w3tc_hidden');
15
+ return;
16
+ }
17
+
18
+ for (p in data) {
19
+ var v = data[p];
20
+ if (p.substr(0, 4) == 'url_')
21
+ jQuery('.w3tcstackpath2_href_' + p.substr(4)).attr('href', v);
22
+ else
23
+ jQuery('.w3tcstackpath2_' + p).html(v);
24
+ }
25
+
26
+ var chart_data = google.visualization.arrayToDataTable(data.chart_mb);
27
+
28
+ var chart = new google.visualization.ColumnChart(
29
+ document.getElementById('chart_div'));
30
+ var options = {};//colors: 'blue,red'};
31
+ chart.draw(chart_data, options);
32
+
33
+ jQuery('.w3tcstackpath2_content').removeClass('w3tc_hidden');
34
+ jQuery('.w3tcstackpath2_loading').addClass('w3tc_hidden');
35
+ }
36
+ ).fail(function() {
37
+ jQuery('.w3tcstackpath2_error').removeClass('w3tc_none');
38
+ jQuery('.w3tcstackpath2_content').addClass('w3tc_hidden');
39
+ jQuery('.w3tcstackpath2_loading').addClass('w3tc_hidden');
40
+ });
41
+ }
42
+
43
+
44
+
45
+ google.load("visualization", "1", {packages:["corechart"]});
46
+ google.setOnLoadCallback(w3tcstackpath2_load);
Cdn_StackPath2_Widget_View_Authorized.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <div class="w3tcstackpath2_loading w3tc_loading w3tc_hidden">Loading...</div>
8
+ <div class="w3tcstackpath2_error w3tc_none">
9
+ An error occurred
10
+ <div class="w3tcstackpath2_error_details"></div>
11
+ </div>
12
+
13
+ <div id="stackpath-widget" class="stackpath-netdna-widget-base w3tcstackpath2_content w3tc_hidden">
14
+ <div class="w3tcstackpath2_wrapper">
15
+ <div class="w3tcstackpath2_tools">
16
+ <ul class="w3tcstackpath2_ul">
17
+ <li><a class="button w3tcstackpath2_href_manage" href=""><?php _e( 'Manage', 'w3-total-cache' )?></a></li>
18
+ <li><a class="button w3tcstackpath2_href_reports" href=""><?php _e( 'Reports', 'w3-total-cache' )?></a></li>
19
+ <li><a class="button" href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=w3tc_cdn&amp;w3tc_cdn_purge' ) )?>" onclick="w3tc_popupadmin_bar(this.href); return false"><?php _e( 'Purge', 'w3-total-cache' )?></a></li>
20
+ </ul>
21
+ </div>
22
+ <div class="w3tcstackpath2_summary">
23
+ <h4 class="w3tcstackpath2_summary_h4"><?php _e( 'Report - 7 days', 'w3-total-cache' ) ?></h4>
24
+ </div>
25
+ <ul class="w3tcstackpath2_ul">
26
+ <li>
27
+ <span class="w3tcstackpath2_summary_col1"><?php _e('Transferred', 'w3-total-cache') ?>:</span>
28
+ <span class="w3tcstackpath2_summary_col2 w3tcstackpath2_summary_mb"></span>
29
+ </li>
30
+ <li>
31
+ <span class="w3tcstackpath2_summary_col1"><?php _e('Requests', 'w3-total-cache') ?>:</span>
32
+ <span class="w3tcstackpath2_summary_col2 w3tcstackpath2_summary_requests"></span>
33
+ </li>
34
+ </ul>
35
+ <div class="w3tcstackpath2_chart charts w3tcstackpath2_area">
36
+ <h4 class="w3tcstackpath2_h4"><?php _e( 'Requests', 'w3-total-cache' ) ?></h4>
37
+ <div id="chart_div" style="width: 320px; height: 220px;margin-left: auto ; margin-right: auto ;"></div>
38
+ </div>
39
+ </div>
40
+ </div>
Cdn_StackPath2_Widget_View_Unauthorized.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+
7
+ ?>
8
+ <div id="stackpath-widget" class="w3tcstackpath_signup">
9
+ <p><?php w3tc_e( 'cdn.stackpath2.widget.header', 'Dramatically increase website speeds in just a few clicks! Add the StackPath content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) service to your site.' )?></p>
10
+ <h4 class="w3tcstackpath_signup_h4"><?php _e( 'New customers', 'w3-total-cache' )?></h4>
11
+ <p><?php w3tc_e( 'cdn.stackpath2.widget.works_magically', 'StackPath works magically with W3 Total Cache.' )?></p>
12
+ <a class="button-primary" href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL )?>" target="_blank"><?php _e( 'Sign Up Now ', 'w3-total-cache' )?></a>
13
+ <p><!--span class="desc"><?php _e( 'Exclusive offers availabel for W3TC users!', 'w3-total-cache' )?></span></p>-->
14
+ <h4 class="w3tcstackpath_signup_h4"><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
15
+ <p><?php w3tc_e( 'cdn.stackpath2.widget.existing', "If you're an existing StackPath customer, enable <acronym title='Content Delivery Network'>CDN</acronym> and:" )?></p>
16
+ <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' )?>" target="_blank"><?php _e( 'Authorize', 'w3-total-cache' )?></a>
17
+ </div>
Cdn_StackPath_Page_View.php CHANGED
@@ -6,14 +6,14 @@ if ( !defined( 'W3TC' ) )
6
 
7
  ?>
8
  <?php if ( !$authorized ): ?>
9
- <tr>
10
- <th style="width: 300px;"><label><?php _e( 'Create account:', 'w3-total-cache' )?></label></th>
11
- <td>
12
- <a href="<?php esc_attr_e( STACKPATH_SIGNUP_URL )?>" target="_blank" id="netdna-stackpath-create-account" class="button-primary"><?php _e( 'Sign Up Now and Save', 'w3-total-cache' ) ?></a>
13
- <br />
14
- <span class="description"><?php _e( 'StackPath is a service that lets you speed up your site even more with W3 Total Cache. 100% Money Back Guarantee (30 Days)!', 'w3-total-cache' )?></span>
15
- </td>
16
- </tr>
17
  <?php endif ?>
18
 
19
 
@@ -43,13 +43,13 @@ if ( !defined( 'W3TC' ) )
43
  <?php if ( !is_null( $http_domain ) ): ?>
44
  <tr>
45
  <th>
46
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> HTTP CNAME:', 'w3-total-cache' ); ?></label>
47
  </th>
48
  <td class="w3tc_config_value_text">
49
  <?php echo htmlspecialchars( $http_domain ) ?><br />
50
  <span class="description">
51
- This website domain has to be CNAME pointing to this
52
- <acronym title="Content Delivery Network">CDN</acronym> domain for HTTP requests
53
  </span>
54
  </td>
55
  </tr>
@@ -57,13 +57,13 @@ if ( !defined( 'W3TC' ) )
57
  <?php if ( !is_null( $https_domain ) ): ?>
58
  <tr>
59
  <th>
60
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> HTTPS CNAME:', 'w3-total-cache' ); ?></label>
61
  </th>
62
  <td class="w3tc_config_value_text">
63
  <?php echo htmlspecialchars( $https_domain ) ?><br />
64
  <span class="description">
65
- This website domain has to be CNAME pointing to this
66
- <acronym title="Content Delivery Network">CDN</acronym> domain for HTTPS requests
67
  </span>
68
  </td>
69
  </tr>
@@ -74,23 +74,23 @@ if ( !defined( 'W3TC' ) )
74
  <td>
75
  <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
76
  <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
77
- <option value="enabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' )?></option>
78
- <option value="disabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' )?></option>
79
  </select>
80
- <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' )?></span>
81
  </td>
82
  </tr>
83
  <tr>
84
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' )?></th>
85
- <td>
86
  <?php $cnames = $config->get_array( 'cdn.stackpath.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
87
- <br /><span class="description"><?php _e( 'Enter the hostname provided by your <acronym title="Content Delivery Network">CDN</acronym> provider, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' )?></span>
88
- </td>
89
  </tr>
90
  <tr>
91
  <th colspan="2">
92
- <input id="cdn_test" class="button {type: 'stackpath', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test StackPath', 'w3-total-cache' )?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
93
- </th>
94
  </tr>
95
 
96
  <?php endif ?>
6
 
7
  ?>
8
  <?php if ( !$authorized ): ?>
9
+ <tr>
10
+ <th style="width: 300px;"><label><?php _e( 'Create account:', 'w3-total-cache' )?></label></th>
11
+ <td>
12
+ <a href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL ) ?>" target="_blank" id="netdna-stackpath-create-account" class="button-primary"><?php w3tc_e( 'cdn.stackpath.signUpAndSave', 'Sign Up Now and save!' ) ?></a>
13
+ <br />
14
+ <span class="description"><?php w3tc_e( 'cdn.stackpath.signUpAndSave.description', 'StackPath is a service that lets you speed up your site even more with W3 Total Cache. Sign up now and save!' )?></span>
15
+ </td>
16
+ </tr>
17
  <?php endif ?>
18
 
19
 
43
  <?php if ( !is_null( $http_domain ) ): ?>
44
  <tr>
45
  <th>
46
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="HyperText Transfer Protocol">HTTP</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
47
  </th>
48
  <td class="w3tc_config_value_text">
49
  <?php echo htmlspecialchars( $http_domain ) ?><br />
50
  <span class="description">
51
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
52
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol">HTTP</acronym> requests
53
  </span>
54
  </td>
55
  </tr>
57
  <?php if ( !is_null( $https_domain ) ): ?>
58
  <tr>
59
  <th>
60
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
61
  </th>
62
  <td class="w3tc_config_value_text">
63
  <?php echo htmlspecialchars( $https_domain ) ?><br />
64
  <span class="description">
65
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
66
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
67
  </span>
68
  </td>
69
  </tr>
74
  <td>
75
  <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
76
  <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
77
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use <acronym title="Secure Sockets Layer">SSL</acronym>)', 'w3-total-cache' )?></option>
78
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use <acronym title="HyperText Transfer Protocol">HTTP</acronym>)', 'w3-total-cache' )?></option>
79
  </select>
80
+ <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' )?></span>
81
  </td>
82
  </tr>
83
  <tr>
84
+ <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' )?></th>
85
+ <td>
86
  <?php $cnames = $config->get_array( 'cdn.stackpath.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
87
+ <br /><span class="description"><?php _e( 'Enter the hostname provided by your <acronym title="Content Delivery Network">CDN</acronym> provider, this value will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' )?></span>
88
+ </td>
89
  </tr>
90
  <tr>
91
  <th colspan="2">
92
+ <input id="cdn_test" class="button {type: 'stackpath', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test StackPath', 'w3-total-cache' )?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
93
+ </th>
94
  </tr>
95
 
96
  <?php endif ?>
Cdn_StackPath_Popup.php CHANGED
@@ -30,7 +30,7 @@ class Cdn_StackPath_Popup {
30
 
31
  private function render_intro( $details ) {
32
  $config = Dispatcher::config();
33
- $url_obtain_key = STACKPATH_AUTHORIZE_URL;
34
 
35
  include W3TC_DIR . '/Cdn_StackPath_Popup_View_Intro.php';
36
  exit();
30
 
31
  private function render_intro( $details ) {
32
  $config = Dispatcher::config();
33
+ $url_obtain_key = W3TC_STACKPATH_AUTHORIZE_URL;
34
 
35
  include W3TC_DIR . '/Cdn_StackPath_Popup_View_Intro.php';
36
  exit();
Cdn_StackPath_Widget.php CHANGED
@@ -9,7 +9,7 @@ class Cdn_StackPath_Widget {
9
  add_action( 'admin_print_scripts',
10
  array( $o, 'admin_print_scripts' ) );
11
  add_action( 'w3tc_widget_setup',
12
- array( $o, 'w3tc_widget_setup' ) );
13
  }
14
 
15
 
9
  add_action( 'admin_print_scripts',
10
  array( $o, 'admin_print_scripts' ) );
11
  add_action( 'w3tc_widget_setup',
12
+ array( $o, 'w3tc_widget_setup' ), 2000 );
13
  }
14
 
15
 
Cdn_StackPath_Widget_View.css CHANGED
@@ -1,7 +1,7 @@
1
  .w3tc-widget-stackpath-logo {
2
  width: 150px;
3
  height: 35px;
4
- background: url("pub/img/w3tc_stackpath-logo.png") 0 5px no-repeat;
5
  float: left;
6
  }
7
 
1
  .w3tc-widget-stackpath-logo {
2
  width: 150px;
3
  height: 35px;
4
+ background: url("pub/img/w3tc_stackpath_logo.svg") 0 8px no-repeat;
5
  float: left;
6
  }
7
 
Cdn_StackPath_Widget_View_Unauthorized.php CHANGED
@@ -6,12 +6,12 @@ if ( !defined( 'W3TC' ) )
6
 
7
  ?>
8
  <div id="stackpath-widget" class="w3tcstackpath_signup">
9
- <p><?php _e( 'Dramatically increase website speeds in just a few clicks! Add the StackPath content delivery network service to your site.', 'w3-total-cache' )?></p>
10
- <h4 class="w3tcstackpath_signup_h4"><?php _e( 'New customers', 'w3-total-cache' )?></h4>
11
- <p><?php _e( 'StackPath works magically with W3 Total Cache.', 'w3-total-cache' )?></p>
12
- <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_stackpath_signup' ), 'w3tc' )?>" target="_blank"><?php _e( 'Sign Up Now ', 'w3-total-cache' )?></a>
13
- <p><!--span class="desc"><?php _e( '100% Money Back Guarantee (30 Days)', 'w3-total-cache' )?></span></p>-->
14
- <h4 class="w3tcstackpath_signup_h4"><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
15
- <p><?php _e( "If you're an existing StackPath customer, enable <acronym title='Content Delivery Network'>CDN</acronym> and:", 'w3-total-cache' )?></p>
16
- <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' )?>" target="_blank"><?php _e( 'Authorize', 'w3-total-cache' )?></a>
17
  </div>
6
 
7
  ?>
8
  <div id="stackpath-widget" class="w3tcstackpath_signup">
9
+ <p><?php w3tc_e( 'cdn.stackpath.widget.header', 'Dramatically increase website speeds in just a few clicks! Add the StackPath content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) service to your site.' ) ?></p>
10
+ <h4 class="w3tcstackpath_signup_h4"><?php _e( 'New customers', 'w3-total-cache' )?></h4>
11
+ <p><?php w3tc_e( 'cdn.stackpath.widget.works_magically', 'StackPath works magically with W3 Total Cache.' ) ?></p>
12
+ <a class="button-primary" href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL )?>" target="_blank"><?php _e( 'Sign Up Now ', 'w3-total-cache' )?></a>
13
+ <p><!--span class="desc"><?php _e( 'Exclusive offers availabel for W3TC users!', 'w3-total-cache' )?></span></p>-->
14
+ <h4 class="w3tcstackpath_signup_h4"><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
15
+ <p><?php w3tc_e( 'cdn.stackpath.widget.existing', "If you're an existing StackPath customer, enable <acronym title='Content Delivery Network'>CDN</acronym> and:" )?></p>
16
+ <a class="button-primary" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' )?>" target="_blank"><?php _e( 'Authorize', 'w3-total-cache' )?></a>
17
  </div>
Cdn_Util.php CHANGED
@@ -28,6 +28,7 @@ class Cdn_Util {
28
  's3',
29
  's3_compatible',
30
  'stackpath',
 
31
  ) );
32
  }
33
 
@@ -41,7 +42,7 @@ class Cdn_Util {
41
  return in_array( $engine, array(
42
  'mirror', 'maxcdn', 'cotendo', 'cf2', 'akamai',
43
  'edgecast', 'att', 'highwinds', 'limelight', 'rackspace_cdn',
44
- 'stackpath' ) );
45
  }
46
 
47
  static public function is_engine_push( $engine ) {
@@ -63,6 +64,7 @@ class Cdn_Util {
63
  'limelight',
64
  'maxcdn',
65
  'stackpath',
 
66
  ) );
67
  }
68
 
@@ -89,6 +91,7 @@ class Cdn_Util {
89
  's3',
90
  's3_compatible',
91
  'stackpath',
 
92
  ) );
93
  }
94
 
28
  's3',
29
  's3_compatible',
30
  'stackpath',
31
+ 'stackpath2',
32
  ) );
33
  }
34
 
42
  return in_array( $engine, array(
43
  'mirror', 'maxcdn', 'cotendo', 'cf2', 'akamai',
44
  'edgecast', 'att', 'highwinds', 'limelight', 'rackspace_cdn',
45
+ 'stackpath', 'stackpath2' ) );
46
  }
47
 
48
  static public function is_engine_push( $engine ) {
64
  'limelight',
65
  'maxcdn',
66
  'stackpath',
67
+ 'stackpath2',
68
  ) );
69
  }
70
 
91
  's3',
92
  's3_compatible',
93
  'stackpath',
94
+ 'stackpath2',
95
  ) );
96
  }
97
 
Cdnfsd_CacheFlush.php CHANGED
@@ -18,10 +18,18 @@ class Cdnfsd_CacheFlush {
18
  /**
19
  * Purges everything from CDNs that supports it
20
  */
21
- static public function w3tc_flush_all( $extras = array() ) {
22
  if ( isset( $extras['only'] ) && $extras['only'] != 'cdn' )
23
  return;
24
 
 
 
 
 
 
 
 
 
25
  $o = Dispatcher::component( 'Cdnfsd_CacheFlush' );
26
 
27
  $o->flush_all_requested = true;
@@ -36,7 +44,7 @@ class Cdnfsd_CacheFlush {
36
  * @param integer $post_id
37
  * @return boolean
38
  */
39
- static public function w3tc_flush_post( $post_id ) {
40
  if ( !$post_id ) {
41
  $post_id = Util_Environment::detect_post_id();
42
  }
@@ -45,6 +53,13 @@ class Cdnfsd_CacheFlush {
45
  return false;
46
 
47
  $config = Dispatcher::config();
 
 
 
 
 
 
 
48
  $full_urls = array();
49
  $post = null;
50
  $terms = array();
@@ -181,7 +196,14 @@ class Cdnfsd_CacheFlush {
181
  *
182
  * @param unknown $url
183
  */
184
- static public function w3tc_flush_url( $url ) {
 
 
 
 
 
 
 
185
  $o = Dispatcher::component( 'Cdnfsd_CacheFlush' );
186
  $o->queued_urls[$url] = '*';
187
 
18
  /**
19
  * Purges everything from CDNs that supports it
20
  */
21
+ static public function w3tc_flush_all( $extras = null ) {
22
  if ( isset( $extras['only'] ) && $extras['only'] != 'cdn' )
23
  return;
24
 
25
+ $config = Dispatcher::config();
26
+ if ( $config->get_boolean( 'cdn.flush_manually' ) ) {
27
+ // in this mode flush only on purge button clicks
28
+ if ( !isset( $extras['ui_action'] ) ) {
29
+ return true;
30
+ }
31
+ }
32
+
33
  $o = Dispatcher::component( 'Cdnfsd_CacheFlush' );
34
 
35
  $o->flush_all_requested = true;
44
  * @param integer $post_id
45
  * @return boolean
46
  */
47
+ static public function w3tc_flush_post( $post_id, $extras = null ) {
48
  if ( !$post_id ) {
49
  $post_id = Util_Environment::detect_post_id();
50
  }
53
  return false;
54
 
55
  $config = Dispatcher::config();
56
+ if ( $config->get_boolean( 'cdn.flush_manually' ) ) {
57
+ // in this mode flush only on purge button clicks
58
+ if ( !isset( $extras['ui_action'] ) ) {
59
+ return true;
60
+ }
61
+ }
62
+
63
  $full_urls = array();
64
  $post = null;
65
  $terms = array();
196
  *
197
  * @param unknown $url
198
  */
199
+ static public function w3tc_flush_url( $url, $extras = null ) {
200
+ if ( $config->get_boolean( 'cdn.flush_manually' ) ) {
201
+ // in this mode flush only on purge button clicks
202
+ if ( !isset( $extras['ui_action'] ) ) {
203
+ return true;
204
+ }
205
+ }
206
+
207
  $o = Dispatcher::component( 'Cdnfsd_CacheFlush' );
208
  $o->queued_urls[$url] = '*';
209
 
Cdnfsd_CloudFront_Api.php CHANGED
@@ -183,6 +183,11 @@ class Cdnfsd_CloudFront_Api {
183
  $response = wp_remote_request( $url, $request );
184
 
185
  // handle response
 
 
 
 
 
186
  if ( substr( $response['body'], 0, 5 ) != '<?xml' )
187
  throw new \Exception( 'Unexpected non-xml response from service received' );
188
 
183
  $response = wp_remote_request( $url, $request );
184
 
185
  // handle response
186
+ if ( is_wp_error( $response ) ) {
187
+ throw new \Exception( 'Failed to reach CloudFront: ' .
188
+ implode( '; ', $response->get_error_messages() ) );
189
+ }
190
+
191
  if ( substr( $response['body'], 0, 5 ) != '<?xml' )
192
  throw new \Exception( 'Unexpected non-xml response from service received' );
193
 
Cdnfsd_CloudFront_Page_View.php CHANGED
@@ -40,14 +40,14 @@ _e( 'Specify account credentials:',
40
  <?php if ( $authorized ): ?>
41
  <tr>
42
  <th>
43
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> CNAME:', 'w3-total-cache' ); ?></label>
44
  </th>
45
  <td class="w3tc_config_value_text">
46
  <?php
47
  echo $config->get_string( 'cdnfsd.cloudfront.distribution_domain' )
48
  ?><br />
49
  <span class="description">
50
- This website domain has to be CNAME pointing to this
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </span>
53
  </td>
40
  <?php if ( $authorized ): ?>
41
  <tr>
42
  <th>
43
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
44
  </th>
45
  <td class="w3tc_config_value_text">
46
  <?php
47
  echo $config->get_string( 'cdnfsd.cloudfront.distribution_domain' )
48
  ?><br />
49
  <span class="description">
50
+ The website domain has to be a CNAME pointing to this
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </span>
53
  </td>
Cdnfsd_CloudFront_Popup_View_Distribution.php CHANGED
@@ -26,7 +26,7 @@ Util_Ui::hidden( '', 'distribution_comment', $details['distribution_comment'] );
26
  Create an apex <acronym title="Domain Name System">DNS</acronym> record pointing to your WordPress host <acronym title="Internet Protocol">IP</acronym>.
27
  CloudFront will use this host to mirror your site.
28
 
29
- Tip: If you real domain name is domain.com, then the host
30
  for the apex record should be origin.domain.com with the host
31
  <acronym title="Internet Protocol">IP</acronym> of domain.com, e.g.:
32
  </span>
26
  Create an apex <acronym title="Domain Name System">DNS</acronym> record pointing to your WordPress host <acronym title="Internet Protocol">IP</acronym>.
27
  CloudFront will use this host to mirror your site.
28
 
29
+ Tip: If your real domain name is domain.com, then the host
30
  for the apex record should be origin.domain.com with the host
31
  <acronym title="Internet Protocol">IP</acronym> of domain.com, e.g.:
32
  </span>
Cdnfsd_CloudFront_Popup_View_Intro.php CHANGED
@@ -11,7 +11,7 @@ if ( isset( $details['error_message'] ) )
11
  ?>
12
  <div class="metabox-holder">
13
  <?php Util_Ui::postbox_header(
14
- __( 'Your CloudFront Account credentials', 'w3-total-cache' ) ); ?>
15
  <table class="form-table">
16
  <tr>
17
  <td>Access Key:</td>
11
  ?>
12
  <div class="metabox-holder">
13
  <?php Util_Ui::postbox_header(
14
+ __( 'Your <acronym title="Amazon Web Services">AWS</acronym> CloudFront Account Credentials', 'w3-total-cache' ) ); ?>
15
  <table class="form-table">
16
  <tr>
17
  <td>Access Key:</td>
Cdnfsd_CloudFront_Popup_View_Success.php CHANGED
@@ -11,7 +11,7 @@ if ( !defined( 'W3TC' ) )
11
 
12
  <div style="text-align: center">
13
  Pull Zone <?php echo $details['name'] ?> was successfully configured.<br />
14
- Next, update the domain DNS records
15
  <strong><?php echo $details['home_domain'] ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to
16
  <strong><?php echo $details['dns_cname_target'] ?></strong> to enable caching.
17
 
11
 
12
  <div style="text-align: center">
13
  Pull Zone <?php echo $details['name'] ?> was successfully configured.<br />
14
+ Next, update the domain <acronym title="Domain Name System">DNS</acronym> records
15
  <strong><?php echo $details['home_domain'] ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to
16
  <strong><?php echo $details['dns_cname_target'] ?></strong> to enable caching.
17
 
Cdnfsd_Core.php CHANGED
@@ -51,6 +51,24 @@ class Cdnfsd_Core {
51
  ) );
52
  break;
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  default:
55
  throw new \Exception( 'unknown engine ' . $engine );
56
  }
@@ -58,4 +76,11 @@ class Cdnfsd_Core {
58
 
59
  return $engine_object;
60
  }
 
 
 
 
 
 
 
61
  }
51
  ) );
52
  break;
53
 
54
+ case 'stackpath2':
55
+ $state = Dispatcher::config_state();
56
+
57
+ $engine_object = new Cdnfsd_StackPath2_Engine( array(
58
+ 'client_id' => $c->get_string( 'cdnfsd.stackpath2.client_id' ),
59
+ 'client_secret' => $c->get_string( 'cdnfsd.stackpath2.client_secret' ),
60
+ 'stack_id' => $c->get_string( 'cdnfsd.stackpath2.stack_id' ),
61
+ 'site_root_domain' => $c->get_string( 'cdnfsd.stackpath2.site_root_domain' ),
62
+ 'domain' => $c->get_array( 'cdnfsd.stackpath2.domain' ),
63
+ 'ssl' => $c->get_string( 'cdnfsd.stackpath2.ssl' ),
64
+ 'access_token' => $state->get_string( 'cdnfsd.stackpath2.access_token' ),
65
+ 'on_new_access_token' => array(
66
+ $this,
67
+ 'on_stackpath2_new_access_token'
68
+ )
69
+ ) );
70
+ break;
71
+
72
  default:
73
  throw new \Exception( 'unknown engine ' . $engine );
74
  }
76
 
77
  return $engine_object;
78
  }
79
+
80
+
81
+ public function on_stackpath2_new_access_token( $access_token ) {
82
+ $state = Dispatcher::config_state();
83
+ $state->set( 'cdnfsd.stackpath2.access_token', $access_token );
84
+ $state->save();
85
+ }
86
  }
Cdnfsd_GeneralPage_View.php CHANGED
@@ -5,9 +5,9 @@ if ( !defined( 'W3TC' ) )
5
  die();
6
 
7
  ?>
8
- <p><?php _e( 'Host whole website with your full site content delivery network provider to reduce page load time.', 'w3-total-cache' ); ?>
9
  <?php if ( !$cdnfsd_enabled ): ?>
10
- <?php printf( __( ' If you do not have a <acronym title="Content Delivery Network">CDN</acronym> provider try MaxCDN. <a href="%s" target="_blank">Sign up and save 25&#37;</a>.', 'w3-total-cache' ), wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ); ?>
11
  <?php endif ?>
12
  </p>
13
  <table class="form-table">
@@ -18,7 +18,7 @@ Util_Ui::config_item( array(
18
  'control' => 'checkbox',
19
  'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
20
  'disabled' => ( $is_pro ? null : true ),
21
- 'description' => __( 'Whole website will appear to load instantly for site visitors.',
22
  'w3-total-cache' ) .
23
  ( $is_pro ? '' : __( ' <strong>Available after upgrade.</strong>', 'w3-total-cache' ) )
24
  ) );
5
  die();
6
 
7
  ?>
8
+ <p><?php w3tc_e( 'cdnfsd.general.header', 'Host the entire website with your compatible <acronym title="Content Delivery Network">CDN</acronym> provider to reduce page load time.' ) ?>
9
  <?php if ( !$cdnfsd_enabled ): ?>
10
+ <?php printf( __( ' If you do not have a <acronym title="Content Delivery Network">CDN</acronym> provider try StackPath. <a href="%s" target="_blank">Sign up now to enjoy a special offer!</a>.', 'w3-total-cache' ), wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ); ?>
11
  <?php endif ?>
12
  </p>
13
  <table class="form-table">
18
  'control' => 'checkbox',
19
  'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
20
  'disabled' => ( $is_pro ? null : true ),
21
+ 'description' => __( 'The entire website will load quickly for site visitors.',
22
  'w3-total-cache' ) .
23
  ( $is_pro ? '' : __( ' <strong>Available after upgrade.</strong>', 'w3-total-cache' ) )
24
  ) );
Cdnfsd_MaxCdn_Page_View.php CHANGED
@@ -40,14 +40,14 @@ _e( 'Specify account credentials:',
40
  <?php if ( $authorized ): ?>
41
  <tr>
42
  <th>
43
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> CNAME:', 'w3-total-cache' ); ?></label>
44
  </th>
45
  <td class="w3tc_config_value_text">
46
  <?php
47
  echo $config->get_string( 'cdnfsd.maxcdn.zone_domain' )
48
  ?><br />
49
  <span class="description">
50
- This website domain has to be CNAME pointing to this
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </span>
53
  </td>
40
  <?php if ( $authorized ): ?>
41
  <tr>
42
  <th>
43
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
44
  </th>
45
  <td class="w3tc_config_value_text">
46
  <?php
47
  echo $config->get_string( 'cdnfsd.maxcdn.zone_domain' )
48
  ?><br />
49
  <span class="description">
50
+ The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </span>
53
  </td>
Cdnfsd_MaxCdn_Popup_View_Intro.php CHANGED
@@ -18,11 +18,11 @@ if ( isset( $details['error_message'] ) )
18
  <td>
19
  <input name="api_key" type="text" class="w3tc-ignore-change"
20
  style="width: 550px"
21
- value="<?php echo $details['api_key'] ?>" />
22
  <br />
23
  <span class="description">
24
  To obtain API key you can
25
- <a target="_blank" href="<?php echo $url_obtain_key ?>">click here</a>,
26
  log in, and paste the key in above field.
27
  </span>
28
  </td>
18
  <td>
19
  <input name="api_key" type="text" class="w3tc-ignore-change"
20
  style="width: 550px"
21
+ value="<?php echo esc_attr( $details['api_key'] ) ?>" />
22
  <br />
23
  <span class="description">
24
  To obtain API key you can
25
+ <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
26
  log in, and paste the key in above field.
27
  </span>
28
  </td>
Cdnfsd_Plugin.php CHANGED
@@ -36,16 +36,16 @@ class Cdnfsd_Plugin {
36
  add_action( 'w3tc_flush_post', array(
37
  '\W3TC\Cdnfsd_CacheFlush',
38
  'w3tc_flush_post'
39
- ), 3000, 1 );
40
  add_action( 'w3tc_flushable_posts', '__return_true', 3000 );
41
  add_action( 'w3tc_flush_posts', array(
42
  '\W3TC\Cdnfsd_CacheFlush',
43
  'w3tc_flush_all'
44
- ), 3000 );
45
  add_action( 'w3tc_flush_url', array(
46
  '\W3TC\Cdnfsd_CacheFlush',
47
  'w3tc_flush_url'
48
- ), 3000, 1 );
49
  add_filter( 'w3tc_flush_execute_delayed_operations', array(
50
  '\W3TC\Cdnfsd_CacheFlush',
51
  'w3tc_flush_execute_delayed_operations'
36
  add_action( 'w3tc_flush_post', array(
37
  '\W3TC\Cdnfsd_CacheFlush',
38
  'w3tc_flush_post'
39
+ ), 3000, 2 );
40
  add_action( 'w3tc_flushable_posts', '__return_true', 3000 );
41
  add_action( 'w3tc_flush_posts', array(
42
  '\W3TC\Cdnfsd_CacheFlush',
43
  'w3tc_flush_all'
44
+ ), 3000, 1 );
45
  add_action( 'w3tc_flush_url', array(
46
  '\W3TC\Cdnfsd_CacheFlush',
47
  'w3tc_flush_url'
48
+ ), 3000, 2 );
49
  add_filter( 'w3tc_flush_execute_delayed_operations', array(
50
  '\W3TC\Cdnfsd_CacheFlush',
51
  'w3tc_flush_execute_delayed_operations'
Cdnfsd_Plugin_Admin.php CHANGED
@@ -47,6 +47,16 @@ class Cdnfsd_Plugin_Admin {
47
  add_action( 'w3tc_settings_box_cdnfsd', array(
48
  '\W3TC\Cdnfsd_StackPath_Page',
49
  'w3tc_settings_box_cdnfsd' ) );
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
  add_action( 'w3tc_settings_general_boxarea_cdn_footer',
@@ -65,7 +75,7 @@ class Cdnfsd_Plugin_Admin {
65
 
66
  $cdnfsd_engine_values = array();
67
  $cdnfsd_engine_values[''] = array(
68
- 'label' => '',
69
  );
70
  $cdnfsd_engine_values['cloudfront'] = array(
71
  'label' => __( 'Amazon CloudFront', 'w3-total-cache' ),
@@ -78,26 +88,29 @@ class Cdnfsd_Plugin_Admin {
78
  'label' => __( 'Limelight', 'w3-total-cache' ),
79
  );
80
  $cdnfsd_engine_values['maxcdn'] = array(
81
- 'label' => __( 'MaxCDN (recommended)', 'w3-total-cache' ),
82
  );
83
  $cdnfsd_engine_values['stackpath'] = array(
84
- 'label' => __( 'StackPath', 'w3-total-cache' ),
 
 
 
85
  );
86
 
87
  $tag = '';
88
  if ( $cdnfsd_engine == 'cloudfront' ) {
89
- $tag = '#cdn-fsd-cloudfront';
90
  } elseif ( $cdnfsd_engine == 'maxcdn' ) {
91
- $tag = '#cdn-fsd-maxcdn';
92
- } elseif ( $cdnfsd_engine == 'stackpath' ) {
93
- $tag = '#cdn-fsd-stackpath';
94
  }
95
 
96
  if ( empty( $tag ) ) {
97
  $cdnfsd_engine_extra_description = '';
98
  } else {
99
  $cdnfsd_engine_extra_description =
100
- ' See <a href="admin.php?page=w3tc_faq' . $tag .
101
  '">setup instructions</a>';
102
  }
103
 
47
  add_action( 'w3tc_settings_box_cdnfsd', array(
48
  '\W3TC\Cdnfsd_StackPath_Page',
49
  'w3tc_settings_box_cdnfsd' ) );
50
+ } elseif ( $cdnfsd_engine == 'stackpath2' ) {
51
+ add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
52
+ '\W3TC\Cdnfsd_StackPath2_Page',
53
+ 'admin_print_scripts_performance_page_w3tc_cdn' ) );
54
+ add_action( 'w3tc_ajax', array(
55
+ '\W3TC\Cdnfsd_StackPath2_Popup',
56
+ 'w3tc_ajax' ) );
57
+ add_action( 'w3tc_settings_box_cdnfsd', array(
58
+ '\W3TC\Cdnfsd_StackPath2_Page',
59
+ 'w3tc_settings_box_cdnfsd' ) );
60
  }
61
 
62
  add_action( 'w3tc_settings_general_boxarea_cdn_footer',
75
 
76
  $cdnfsd_engine_values = array();
77
  $cdnfsd_engine_values[''] = array(
78
+ 'label' => 'Select a provider',
79
  );
80
  $cdnfsd_engine_values['cloudfront'] = array(
81
  'label' => __( 'Amazon CloudFront', 'w3-total-cache' ),
88
  'label' => __( 'Limelight', 'w3-total-cache' ),
89
  );
90
  $cdnfsd_engine_values['maxcdn'] = array(
91
+ 'label' => __( 'MaxCDN', 'w3-total-cache' ),
92
  );
93
  $cdnfsd_engine_values['stackpath'] = array(
94
+ 'label' => __( 'StackPath SecureCDN (Legacy)', 'w3-total-cache' ),
95
+ );
96
+ $cdnfsd_engine_values['stackpath2'] = array(
97
+ 'label' => __( 'StackPath (recommended)', 'w3-total-cache' ),
98
  );
99
 
100
  $tag = '';
101
  if ( $cdnfsd_engine == 'cloudfront' ) {
102
+ $tag = 'https://api.w3-edge.com/v1/redirects/faq/cdn-fsd/cloudfront';
103
  } elseif ( $cdnfsd_engine == 'maxcdn' ) {
104
+ $tag = 'https://api.w3-edge.com/v1/redirects/faq/cdn-fsd/maxcdn';
105
+ } elseif ( $cdnfsd_engine == 'stackpath' || $cdnfsd_engine == 'stackpath2' ) {
106
+ $tag = 'https://api.w3-edge.com/v1/redirects/faq/cdn-fsd/stackpath';
107
  }
108
 
109
  if ( empty( $tag ) ) {
110
  $cdnfsd_engine_extra_description = '';
111
  } else {
112
  $cdnfsd_engine_extra_description =
113
+ ' See <a href="' . $tag .
114
  '">setup instructions</a>';
115
  }
116
 
Cdnfsd_StackPath2_Engine.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+
5
+
6
+ class Cdnfsd_StackPath2_Engine {
7
+ private $config;
8
+
9
+
10
+
11
+ function __construct( $config = array() ) {
12
+ $this->config = $config;
13
+ }
14
+
15
+
16
+
17
+ function flush_urls( $urls ) {
18
+ if ( empty( $this->config['client_id'] ) ) {
19
+ throw new \Exception( __( 'API key not specified.', 'w3-total-cache' ) );
20
+ }
21
+
22
+ $api = new Cdn_StackPath2_Api( $this->config );
23
+
24
+ $items = array();
25
+ foreach ( $urls as $url ) {
26
+ $items[] = array( 'url' => $url,
27
+ 'recursive' => true,
28
+ );
29
+ }
30
+
31
+ try {
32
+ $api->purge( array( 'items' => $items ) );
33
+ } catch ( \Exception $ex ) {
34
+ if ( $ex->getMessage() == 'Validation Failure: Purge url must contain one of your hostnames' ) {
35
+ throw new \Exception('CDN site is not configured correctly: Delivery Domain must match your site domain');
36
+ } else {
37
+ throw $ex;
38
+ }
39
+ }
40
+ }
41
+
42
+
43
+
44
+ /**
45
+ * Flushes CDN completely
46
+ */
47
+ function flush_all() {
48
+ if ( empty( $this->config['client_id'] ) ) {
49
+ throw new \Exception( __( 'API key not specified.', 'w3-total-cache' ) );
50
+ }
51
+
52
+ $api = new Cdn_StackPath2_Api( $this->config );
53
+
54
+ $items = array();
55
+ $items[] = array( 'url' => home_url( '/' ),
56
+ 'recursive' => true,
57
+ );
58
+
59
+ try {
60
+ $r = $api->purge( array( 'items' => $items ) );
61
+ } catch ( \Exception $ex ) {
62
+ if ( $ex->getMessage() == 'Validation Failure: Purge url must contain one of your hostnames' ) {
63
+ throw new \Exception('CDN site is not configured correctly: Delivery Domain must match your site domain');
64
+ } else {
65
+ throw $ex;
66
+ }
67
+ }
68
+ }
69
+ }
Cdnfsd_StackPath2_Page.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+
5
+
6
+ class Cdnfsd_StackPath2_Page {
7
+ // called from plugin-admin
8
+ static public function admin_print_scripts_performance_page_w3tc_cdn() {
9
+ wp_enqueue_script( 'w3tc_cdn_stackpath2_fsd',
10
+ plugins_url( 'Cdnfsd_StackPath2_Page_View.js', W3TC_FILE ),
11
+ array( 'jquery' ), '1.0' );
12
+ }
13
+
14
+
15
+
16
+ static public function w3tc_settings_box_cdnfsd() {
17
+ $config = Dispatcher::config();
18
+ include W3TC_DIR . '/Cdnfsd_StackPath2_Page_View.php';
19
+ }
20
+ }
Cdnfsd_StackPath2_Page_View.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+ function w3tc_stackpath_resize(o) {
3
+ o.options.height = jQuery('.w3tc_cdn_stackpath2_fsd_form').height();
4
+ o.resize();
5
+ }
6
+
7
+ $('body')
8
+ .on('click', '.w3tc_cdn_stackpath2_fsd_authorize', function() {
9
+ W3tc_Lightbox.open({
10
+ id:'w3tc-overlay',
11
+ close: '',
12
+ width: 800,
13
+ height: 300,
14
+ url: ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
15
+ '&w3tc_action=cdn_stackpath2_fsd_intro',
16
+ callback: w3tc_stackpath_resize
17
+ });
18
+ })
19
+
20
+
21
+
22
+ .on('click', '.w3tc_cdn_stackpath2_fsd_list_stacks', function() {
23
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
24
+ '&w3tc_action=cdn_stackpath2_fsd_list_stacks';
25
+
26
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_fsd_form', w3tc_stackpath_resize);
27
+ })
28
+
29
+
30
+
31
+ .on('click', '.w3tc_cdn_stackpath2_fsd_list_sites', function() {
32
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
33
+ '&w3tc_action=cdn_stackpath2_fsd_list_sites';
34
+
35
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_fsd_form', w3tc_stackpath_resize);
36
+ })
37
+
38
+
39
+
40
+ .on('click', '.w3tc_cdn_stackpath2_fsd_view_site', function() {
41
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
42
+ '&w3tc_action=cdn_stackpath2_fsd_view_site';
43
+
44
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_fsd_form', w3tc_stackpath_resize);
45
+ })
46
+
47
+
48
+
49
+ .on('click', '.w3tc_cdn_stackpath2_fsd_configure_site', function() {
50
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
51
+ '&w3tc_action=cdn_stackpath2_fsd_configure_site';
52
+
53
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_fsd_form', w3tc_stackpath_resize);
54
+ })
55
+
56
+
57
+
58
+ .on('click', '.w3tc_cdn_stackpath2_fsd_configure_site_skip', function() {
59
+ var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
60
+ '&w3tc_action=cdn_stackpath2_fsd_configure_site_skip';
61
+
62
+ W3tc_Lightbox.load_form(url, '.w3tc_cdn_stackpath2_fsd_form', w3tc_stackpath_resize);
63
+ })
64
+
65
+
66
+
67
+ .on('click', '.w3tc_cdn_stackpath2_fsd_done', function() {
68
+ // refresh page
69
+ window.location = window.location + '&';
70
+ })
71
+ });
Cdnfsd_StackPath2_Page_View.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+
7
+ $key = $config->get_string( 'cdnfsd.stackpath2.client_id' );
8
+ $authorized = !empty( $key );
9
+
10
+ ?>
11
+ <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( __( 'Configuration: Full-Site Delivery', 'w3-total-cache' ),
14
+ '', 'configuration' ); ?>
15
+ <table class="form-table">
16
+ <tr>
17
+ <th style="width: 300px;">
18
+ <label>
19
+ <?php
20
+ _e( 'Specify account credentials:',
21
+ 'w3-total-cache' );
22
+ ?>
23
+ </label>
24
+ </th>
25
+ <td>
26
+ <?php if ( $authorized ): ?>
27
+ <input class="w3tc_cdn_stackpath2_fsd_authorize button-primary"
28
+ type="button"
29
+ value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
30
+ />
31
+ <?php else: ?>
32
+ <input class="w3tc_cdn_stackpath2_fsd_authorize button-primary"
33
+ type="button"
34
+ value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
35
+ />
36
+ <?php endif ?>
37
+ </td>
38
+ </tr>
39
+
40
+ <?php if ( $authorized ): ?>
41
+ <tr>
42
+ <th>
43
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
44
+ </th>
45
+ <td class="w3tc_config_value_text">
46
+ <?php
47
+ echo implode( ', ', $config->get_array( 'cdnfsd.stackpath2.domain' ) )
48
+ ?><br />
49
+ <span class="description">
50
+ The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
51
+ <acronym title="Content Delivery Network">CDN</acronym> domain
52
+ </span>
53
+ </td>
54
+ </tr>
55
+ <?php endif ?>
56
+ </table>
57
+
58
+ <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
59
+ <?php Util_Ui::postbox_footer(); ?>
60
+ </div>
61
+ </form>
Cdnfsd_StackPath2_Popup.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+
5
+
6
+ class Cdnfsd_StackPath2_Popup {
7
+ static public function w3tc_ajax() {
8
+ $o = new Cdnfsd_StackPath2_Popup();
9
+
10
+ add_action( 'w3tc_ajax_cdn_stackpath2_fsd_intro',
11
+ array( $o, 'w3tc_ajax_cdn_stackpath2_fsd_intro' ) );
12
+ add_action( 'w3tc_ajax_cdn_stackpath2_fsd_list_stacks',
13
+ array( $o, 'w3tc_ajax_cdn_stackpath2_fsd_list_stacks' ) );
14
+ add_action( 'w3tc_ajax_cdn_stackpath2_fsd_list_sites',
15
+ array( $o, 'w3tc_ajax_cdn_stackpath2_fsd_list_sites' ) );
16
+ add_action( 'w3tc_ajax_cdn_stackpath2_fsd_configure_site',
17
+ array( $o, 'w3tc_ajax_cdn_stackpath2_fsd_configure_site' ) );
18
+ }
19
+
20
+
21
+
22
+ public function w3tc_ajax_cdn_stackpath2_fsd_intro() {
23
+ $config = Dispatcher::config();
24
+
25
+ $this->render_intro( array(
26
+ 'client_id' => $config->get_string( 'cdnfsd.stackpath2.client_id' ),
27
+ 'client_secret' => $config->get_string( 'cdnfsd.stackpath2.client_secret' ),
28
+ 'stack_id' => $config->get_string( 'cdnfsd.stackpath2.stack_id' )
29
+ ) );
30
+ }
31
+
32
+
33
+
34
+ private function render_intro( $details ) {
35
+ $config = Dispatcher::config();
36
+ $url_obtain_key = W3TC_STACKPATH2_AUTHORIZE_URL;
37
+
38
+ include W3TC_DIR . '/Cdnfsd_StackPath2_Popup_View_Intro.php';
39
+ exit();
40
+ }
41
+
42
+
43
+
44
+ public function w3tc_ajax_cdn_stackpath2_fsd_list_stacks() {
45
+ $api_config = array(
46
+ 'client_id' => $_REQUEST['client_id'],
47
+ 'client_secret' => $_REQUEST['client_secret']
48
+ );
49
+
50
+ $api = new Cdn_StackPath2_Api( $api_config );
51
+
52
+ try {
53
+ $r = $r = $api->stacks_list();
54
+ $stacks = $r['results'];
55
+ } catch ( \Exception $ex ) {
56
+ $error_message = 'Can\'t authenticate: ' . $ex->getMessage();
57
+
58
+ $this->render_intro( array(
59
+ 'client_id' => $api_config['client_id'],
60
+ 'client_secret' => $api_config['client_secret'],
61
+ 'error_message' => $error_message
62
+ ) );
63
+ exit();
64
+ }
65
+
66
+ $count = 0;
67
+ $stack_id = '';
68
+ foreach ( $stacks as $i ) {
69
+ if ( $i['status'] == 'ACTIVE' ) {
70
+ $count++;
71
+ $stack_id = $i['id'];
72
+ }
73
+ }
74
+
75
+ if ( $count == 1 ) {
76
+ $api_config['stack_id'] = $stack_id;
77
+ $this->_w3tc_ajax_cdn_stackpath2_fsd_list_sites( $api_config );
78
+ exit();
79
+ }
80
+
81
+ $details = array(
82
+ 'api_config' => $this->api_config_encode( $api_config ),
83
+ 'stacks' => $stacks
84
+ );
85
+
86
+ include W3TC_DIR . '/Cdnfsd_StackPath2_Popup_View_Stacks.php';
87
+ exit();
88
+ }
89
+
90
+
91
+
92
+ public function w3tc_ajax_cdn_stackpath2_fsd_list_sites() {
93
+ $api_config = $this->api_config_decode( $_REQUEST['api_config'] );
94
+ $api_config['stack_id'] = $_REQUEST['stack_id'];
95
+
96
+ $this->_w3tc_ajax_cdn_stackpath2_fsd_list_sites( $api_config );
97
+ }
98
+
99
+
100
+
101
+ public function _w3tc_ajax_cdn_stackpath2_fsd_list_sites( $api_config ) {
102
+ $api = new Cdn_StackPath2_Api( $api_config );
103
+
104
+ try {
105
+ $r = $api->site_list();
106
+ $sites = $r['results'];
107
+ } catch ( \Exception $ex ) {
108
+ $error_message = 'Can\'t authenticate: ' . $ex->getMessage();
109
+
110
+ $this->render_intro( array(
111
+ 'client_id' => $api_config['client_id'],
112
+ 'client_secret' => $api_config['client_secret'],
113
+ 'stack_id' => $api_config['stack_id'],
114
+ 'error_message' => $error_message
115
+ ) );
116
+ exit();
117
+ }
118
+
119
+ $details = array(
120
+ 'api_config' => $this->api_config_encode( $api_config ),
121
+ 'sites' => $sites,
122
+ 'new_hostname' => parse_url( home_url(), PHP_URL_HOST )
123
+ );
124
+
125
+ include W3TC_DIR . '/Cdnfsd_StackPath2_Popup_View_Sites.php';
126
+ exit();
127
+ }
128
+
129
+
130
+
131
+ public function w3tc_ajax_cdn_stackpath2_fsd_configure_site() {
132
+ $api_config = $this->api_config_decode( $_REQUEST['api_config'] );
133
+ $site_id = Util_Request::get( 'site_id', '' );
134
+
135
+ $api = new Cdn_StackPath2_Api( $api_config );
136
+
137
+ try {
138
+ if ( empty( $site_id ) ) {
139
+ // create new zone mode
140
+ $hostname = parse_url( home_url(), PHP_URL_HOST );
141
+ $hostname = 'an6.w3-edge.com';
142
+
143
+ $r = $api->site_create( array(
144
+ 'domain' => $hostname,
145
+ 'origin' => array(
146
+ 'path' => '/',
147
+ 'hostname' => $hostname,
148
+ 'port' => 80,
149
+ 'securePort' => 443
150
+ ),
151
+ 'features' => array( 'CDN' )
152
+ ) );
153
+
154
+ $site_id = $r['site']['id'];
155
+ }
156
+
157
+ $r = $api->site_dns_targets_get( $site_id );
158
+ $domains = $r['addresses'];
159
+ } catch ( \Exception $ex ) {
160
+ $this->render_intro( array(
161
+ 'client_id' => $api_config['client_id'],
162
+ 'client_secret' => $api_config['client_secret'],
163
+ 'stack_id' => $api_config['stack_id'],
164
+ 'error_message' => 'Can\'t obtain site: ' . $ex->getMessage()
165
+ ) );
166
+ exit();
167
+ }
168
+
169
+ $c = Dispatcher::config();
170
+ $c->set( 'cdnfsd.stackpath2.client_id', $api_config['client_id'] );
171
+ $c->set( 'cdnfsd.stackpath2.client_secret', $api_config['client_secret'] );
172
+ $c->set( 'cdnfsd.stackpath2.stack_id', $api_config['stack_id'] );
173
+ $c->set( 'cdnfsd.stackpath2.site_id', $site_id );
174
+ $c->set( 'cdnfsd.stackpath2.site_root_domain', $domains[0] );
175
+ $c->set( 'cdnfsd.stackpath2.domain', $domains );
176
+ $c->save();
177
+
178
+ include W3TC_DIR . '/Cdnfsd_StackPath2_Popup_View_Success.php';
179
+ exit();
180
+ }
181
+
182
+
183
+
184
+ private function api_config_encode( $c ) {
185
+ return implode( ';', array(
186
+ $c['client_id'], $c['client_secret'],
187
+ isset( $c['stack_id'] ) ? $c['stack_id'] : ''
188
+ ) );
189
+ }
190
+
191
+
192
+
193
+ private function api_config_decode( $s ) {
194
+ $a = explode( ';', $s );
195
+ return array(
196
+ 'client_id' => $a[0],
197
+ 'client_secret' => $a[1],
198
+ 'stack_id' => $a[2]
199
+ );
200
+ }
201
+ }
Cdnfsd_StackPath2_Popup_View_Intro.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_fsd_form">
8
+ <?php
9
+ if ( isset( $details['error_message'] ) )
10
+ echo '<div class="error">' . $details['error_message'] . '</div>';
11
+ ?>
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header(
14
+ __( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
15
+ <table class="form-table">
16
+ <tr>
17
+ <td>API Client ID:</td>
18
+ <td>
19
+ <input name="client_id" type="text" class="w3tc-ignore-change"
20
+ style="width: 550px"
21
+ value="<?php echo esc_attr( $details['client_id'] ) ?>" />
22
+ </td>
23
+ </tr>
24
+ <tr>
25
+ <td>API Client Secret:</td>
26
+ <td>
27
+ <input name="client_secret" type="text" class="w3tc-ignore-change"
28
+ style="width: 550px"
29
+ value="<?php echo esc_attr( $details['client_secret'] ) ?>" />
30
+ <br />
31
+ <span class="description">
32
+ To obtain API key you can
33
+ <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
34
+ log in, and paste the key in above field.
35
+ </span>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+
40
+ <p class="submit">
41
+ <input type="button"
42
+ class="w3tc_cdn_stackpath2_fsd_list_stacks w3tc-button-save button-primary"
43
+ value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
44
+ </p>
45
+ <?php Util_Ui::postbox_footer(); ?>
46
+ </div>
47
+ </form>
Cdnfsd_StackPath2_Popup_View_Sites.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_fsd_form" method="post">
8
+ <?php
9
+ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
10
+ ?>
11
+ <div class="metabox-holder">
12
+ <?php Util_Ui::postbox_header( __( 'Select site to use', 'w3-total-cache' ) ); ?>
13
+ <table class="form-table">
14
+ <tr>
15
+ <td>Site:</td>
16
+ <td>
17
+ <?php
18
+ if ( count( $details['sites'] ) > 15 ) {
19
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
+ }
21
+ ?>
22
+
23
+ <?php foreach ( $details['sites'] as $i ): ?>
24
+
25
+ <label>
26
+ <input name="site_id" type="radio" class="w3tc-ignore-change"
27
+ value="<?php echo esc_attr( $i['id'] ) ?>" />
28
+ <?php echo esc_html( $i['label'] ) ?>
29
+ </label><br />
30
+ <?php endforeach ?>
31
+
32
+ <label>
33
+ <input name="site_id" type="radio" class="w3tc-ignore-change" value=""
34
+ />
35
+ Add new site: <?php echo esc_html( $details['new_hostname'] ) ?>
36
+ </label>
37
+
38
+ <?php
39
+ if ( count( $details['sites'] ) > 15 ) {
40
+ echo '</div>';
41
+ }
42
+ ?>
43
+ </td>
44
+ </tr>
45
+ </table>
46
+
47
+ <p class="submit">
48
+ <input type="button"
49
+ class="w3tc_cdn_stackpath2_fsd_configure_site w3tc-button-save button-primary"
50
+ value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
51
+ </p>
52
+ <?php Util_Ui::postbox_footer(); ?>
53
+ </div>
54
+ </form>
Cdnfsd_StackPath2_Popup_View_Stacks.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_fsd_form" method="post">
8
+ <?php
9
+ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
10
+ ?>
11
+ <div class="metabox-holder">
12
+ <?php Util_Ui::postbox_header( __( 'Select stack to use', 'w3-total-cache' ) ); ?>
13
+ <table class="form-table">
14
+ <tr>
15
+ <td>Site:</td>
16
+ <td>
17
+ <?php
18
+ if ( count( $details['stacks'] ) > 15 ) {
19
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
+ }
21
+ ?>
22
+
23
+ <?php foreach ( $details['stacks'] as $i ): ?>
24
+ <label>
25
+ <input name="stack_id" type="radio" class="w3tc-ignore-change"
26
+ value="<?php echo esc_attr( $i['id'] ) ?>" />
27
+ <?php echo esc_html( $i['name'] ) ?>
28
+ <?php if ( $i['status'] != 'ACTIVE' ): ?>
29
+ (<?php echo esc_html( $i['status'] ) ?>)
30
+ <?php endif ?>
31
+ </label><br />
32
+ <?php endforeach ?>
33
+
34
+ <?php
35
+ if ( count( $details['stacks'] ) > 15 ) {
36
+ echo '</div>';
37
+ }
38
+ ?>
39
+ </td>
40
+ </tr>
41
+ </table>
42
+
43
+ <p class="submit">
44
+ <input type="button"
45
+ class="w3tc_cdn_stackpath2_fsd_list_sites w3tc-button-save button-primary"
46
+ value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
47
+ </p>
48
+ <?php Util_Ui::postbox_footer(); ?>
49
+ </div>
50
+ </form>
Cdnfsd_StackPath2_Popup_View_Success.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ if ( !defined( 'W3TC' ) )
5
+ die();
6
+ ?>
7
+ <form class="w3tc_cdn_stackpath2_fsd_form">
8
+ <div class="metabox-holder">
9
+ <?php Util_Ui::postbox_header(
10
+ __( 'Succeeded', 'w3-total-cache' ) ); ?>
11
+
12
+ <div style="text-align: center">
13
+ Site was successfully configured.<br />
14
+ </div>
15
+
16
+ <p class="submit">
17
+ <input type="button"
18
+ class="w3tc_cdn_stackpath2_fsd_done w3tc-button-save button-primary"
19
+ value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
20
+ </p>
21
+ <?php Util_Ui::postbox_footer(); ?>
22
+ </div>
23
+ </form>
Cdnfsd_StackPath_Page_View.php CHANGED
@@ -40,14 +40,14 @@ _e( 'Specify account credentials:',
40
  <?php if ( $authorized ): ?>
41
  <tr>
42
  <th>
43
- <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> CNAME:', 'w3-total-cache' ); ?></label>
44
  </th>
45
  <td class="w3tc_config_value_text">
46
  <?php
47
  echo $config->get_string( 'cdnfsd.stackpath.zone_domain' )
48
  ?><br />
49
  <span class="description">
50
- This website domain has to be CNAME pointing to this
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </span>
53
  </td>
40
  <?php if ( $authorized ): ?>
41
  <tr>
42
  <th>
43
+ <label><?php _e( '<acronym title="Content Delivery Network">CDN</acronym> <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?></label>
44
  </th>
45
  <td class="w3tc_config_value_text">
46
  <?php
47
  echo $config->get_string( 'cdnfsd.stackpath.zone_domain' )
48
  ?><br />
49
  <span class="description">
50
+ The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </span>
53
  </td>
Cdnfsd_StackPath_Popup.php CHANGED
@@ -32,7 +32,7 @@ class Cdnfsd_StackPath_Popup {
32
 
33
  private function render_intro( $details ) {
34
  $config = Dispatcher::config();
35
- $url_obtain_key = STACKPATH_AUTHORIZE_URL;
36
 
37
  include W3TC_DIR . '/Cdnfsd_StackPath_Popup_View_Intro.php';
38
  exit();
32
 
33
  private function render_intro( $details ) {
34
  $config = Dispatcher::config();
35
+ $url_obtain_key = W3TC_STACKPATH_AUTHORIZE_URL;
36
 
37
  include W3TC_DIR . '/Cdnfsd_StackPath_Popup_View_Intro.php';
38
  exit();
Cdnfsd_StackPath_Popup_View_Intro.php CHANGED
@@ -5,35 +5,35 @@ if ( !defined( 'W3TC' ) )
5
  die();
6
  ?>
7
  <form class="w3tc_popup_form">
8
- <?php
9
  if ( isset( $details['error_message'] ) )
10
  echo '<div class="error">' . $details['error_message'] . '</div>';
11
  ?>
12
- <div class="metabox-holder">
13
- <?php Util_Ui::postbox_header(
14
  __( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
15
- <table class="form-table">
16
- <tr>
17
- <td>API Key:</td>
18
- <td>
19
- <input name="api_key" type="text" class="w3tc-ignore-change"
20
- style="width: 550px"
21
- value="<?php echo $details['api_key'] ?>" />
22
- <br />
23
- <span class="description">
24
- To obtain API key you can
25
- <a target="_blank" href="<?php echo $url_obtain_key ?>">click here</a>,
26
- log in, and paste the key in above field.
27
- </span>
28
- </td>
29
- </tr>
30
- </table>
31
 
32
- <p class="submit">
33
- <input type="button"
34
- class="w3tc_cdn_stackpath_fsd_list_zones w3tc-button-save button-primary"
35
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
36
- </p>
37
- <?php Util_Ui::postbox_footer(); ?>
38
- </div>
39
  </form>
5
  die();
6
  ?>
7
  <form class="w3tc_popup_form">
8
+ <?php
9
  if ( isset( $details['error_message'] ) )
10
  echo '<div class="error">' . $details['error_message'] . '</div>';
11
  ?>
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header(
14
  __( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
15
+ <table class="form-table">
16
+ <tr>
17
+ <td>API Key:</td>
18
+ <td>
19
+ <input name="api_key" type="text" class="w3tc-ignore-change"
20
+ style="width: 550px"
21
+ value="<?php echo esc_attr( $details['api_key'] ) ?>" />
22
+ <br />
23
+ <span class="description">
24
+ To obtain API key you can
25
+ <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
26
+ log in, and paste the key in above field.
27
+ </span>
28
+ </td>
29
+ </tr>
30
+ </table>
31
 
32
+ <p class="submit">
33
+ <input type="button"
34
+ class="w3tc_cdn_stackpath_fsd_list_zones w3tc-button-save button-primary"
35
+ value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
36
+ </p>
37
+ <?php Util_Ui::postbox_footer(); ?>
38
+ </div>
39
  </form>
Cli.php CHANGED
@@ -342,12 +342,18 @@ class W3TotalCache_Command extends \WP_CLI_Command {
342
 
343
  /**
344
  * Purges URL's from cdn and varnish if enabled
 
 
345
  */
346
  function cdn_purge( $args = array() ) {
347
  $purgeitems = array();
348
  foreach ( $args as $file ) {
349
  $cdncommon = Dispatcher::component( 'Cdn_Core' );
350
- $local_path = WP_ROOT . $file;
 
 
 
 
351
  $remote_path = $file;
352
  $purgeitems[] = $cdncommon->build_file_descriptor( $local_path, $remote_path );
353
  }
342
 
343
  /**
344
  * Purges URL's from cdn and varnish if enabled
345
+ *
346
+ * @param array $args List if files to be purged, absolute path or relative to wordpress installation path
347
  */
348
  function cdn_purge( $args = array() ) {
349
  $purgeitems = array();
350
  foreach ( $args as $file ) {
351
  $cdncommon = Dispatcher::component( 'Cdn_Core' );
352
+ if (file_exists($file)) {
353
+ $local_path = $file;
354
+ } else {
355
+ $local_path = ABSPATH . $file;
356
+ }
357
  $remote_path = $file;
358
  $purgeitems[] = $cdncommon->build_file_descriptor( $local_path, $remote_path );
359
  }
ConfigCompiler.php CHANGED
@@ -395,15 +395,6 @@ class ConfigCompiler {
395
  $file_data['browsercache.other.querystring'] = $file_data['browsercache.other.replace'];
396
  }
397
 
398
- //
399
- // changes in 0.9.5.3
400
- //
401
- if ( version_compare( $file_data['version'], '0.9.5.3', '<' ) ) {
402
- if ( !isset( $file_data['extensions.active']['swarmify'] ) ) {
403
- $file_data['extensions.active']['swarmify'] = 'w3-total-cache/Extension_Swarmify_Plugin.php';
404
- }
405
- }
406
-
407
  //
408
  // changes in 0.9.5.4
409
  //
395
  $file_data['browsercache.other.querystring'] = $file_data['browsercache.other.replace'];
396
  }
397
 
 
 
 
 
 
 
 
 
 
398
  //
399
  // changes in 0.9.5.4
400
  //
ConfigDbStorage.php CHANGED
@@ -90,8 +90,12 @@ class ConfigDbStorage {
90
  if ( defined('W3TC_CONFIG_DATABASE_TABLE' ) ) {
91
  $template = W3TC_CONFIG_DATABASE_TABLE;
92
  } else {
 
 
 
 
93
  global $table_prefix;
94
- $template = $table_prefix . '{blog_id_prefix}options';
95
  }
96
 
97
  if ( $blog_id <= 0 )
90
  if ( defined('W3TC_CONFIG_DATABASE_TABLE' ) ) {
91
  $template = W3TC_CONFIG_DATABASE_TABLE;
92
  } else {
93
+ if ( is_multisite() ) {
94
+ error_log( 'Please use W3TC_CONFIG_DATABASE_TABLE constant, funcationality without it is not stable in multisite mode' );
95
+ }
96
+
97
  global $table_prefix;
98
+ $template = $table_prefix . 'options';
99
  }
100
 
101
  if ( $blog_id <= 0 )
ConfigKeys.php CHANGED
@@ -128,7 +128,8 @@ $keys = array(
128
  'default' => array(
129
  'gdsr_',
130
  'wp_rg_',
131
- '_wp_session_'
 
132
  )
133
  ),
134
  'dbcache.reject.uri' => array(
@@ -979,9 +980,13 @@ $keys = array(
979
  'type' => 'boolean',
980
  'default' => false
981
  ),
 
 
 
 
982
  'cdn.engine' => array(
983
  'type' => 'string',
984
- 'default' => 'maxcdn'
985
  ),
986
  'cdn.uploads.enable' => array(
987
  'type' => 'boolean',
@@ -1095,6 +1100,18 @@ $keys = array(
1095
  'type' => 'string',
1096
  'default' => 'auto'
1097
  ),
 
 
 
 
 
 
 
 
 
 
 
 
1098
 
1099
  'cdn.google_drive.client_id' => array(
1100
  'type' => 'string',
@@ -1433,6 +1450,34 @@ $keys = array(
1433
  'type' => 'integer',
1434
  'default' => 0
1435
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1436
  'cdn.reject.admins' => array(
1437
  'type' => 'boolean',
1438
  'default' => false
@@ -1517,6 +1562,34 @@ $keys = array(
1517
  'type' => 'integer',
1518
  'default' => 0
1519
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1520
 
1521
  'varnish.configuration_overloaded' => array(
1522
  'type' => 'boolean',
@@ -1555,7 +1628,7 @@ $keys = array(
1555
  'type' => 'array',
1556
  'default' => array(
1557
  'robots\.txt',
1558
- '[a-z0-9_\-]*sitemap[a-z0-9_\-]*\.(xml|xsl|html)(\.gz)?'
1559
  )
1560
  ),
1561
  'browsercache.cssjs.last_modified' => array(
@@ -1566,6 +1639,10 @@ $keys = array(
1566
  'type' => 'boolean',
1567
  'default' => true
1568
  ),
 
 
 
 
1569
  'browsercache.cssjs.expires' => array(
1570
  'type' => 'boolean',
1571
  'default' => true
@@ -1606,6 +1683,10 @@ $keys = array(
1606
  'type' => 'boolean',
1607
  'default' => true
1608
  ),
 
 
 
 
1609
  'browsercache.html.last_modified' => array(
1610
  'type' => 'boolean',
1611
  'default' => true
@@ -1646,6 +1727,10 @@ $keys = array(
1646
  'type' => 'boolean',
1647
  'default' => true
1648
  ),
 
 
 
 
1649
  'browsercache.other.expires' => array(
1650
  'type' => 'boolean',
1651
  'default' => true
@@ -1754,14 +1839,14 @@ $keys = array(
1754
  'type' => 'string',
1755
  'default' => '0'
1756
  ),
1757
- 'browsercache.security.referrer.policy' => array(
1758
- 'type' => 'boolean',
1759
- 'default' => 'false'
1760
- ),
1761
- 'browsercache.security.referrer.policy.directive' => array(
1762
- 'type' => 'string',
1763
- 'default' => '0'
1764
- ),
1765
  'browsercache.security.csp' => array(
1766
  'type' => 'boolean',
1767
  'default' => false
@@ -1836,63 +1921,136 @@ $keys = array(
1836
  'mobile.rgroups' => array(
1837
  'type' => 'array',
1838
  'default' => array(
1839
- 'high' => array(
1840
  'theme' => '',
1841
  'enabled' => false,
1842
  'redirect' => '',
1843
  'agents' => array(
1844
- 'android',
1845
- 'mobi',
1846
- 'bada',
1847
- 'incognito',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1848
  'kindle',
1849
- 'maemo',
1850
- 'opera\ mini',
1851
- 's8000',
1852
- 'series60',
1853
- 'ucbrowser',
1854
- 'ucweb',
1855
- 'webmate',
1856
- 'webos'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1857
  )
1858
  ),
1859
- 'low' => array(
1860
  'theme' => '',
1861
  'enabled' => false,
1862
  'redirect' => '',
1863
  'agents' => array(
1864
- '2\.0\ mmp',
1865
  '240x320',
 
 
 
1866
  'alcatel',
1867
  'amoi',
 
1868
  'asus',
1869
- 'au\-mic',
1870
  'audiovox',
1871
  'avantgo',
 
1872
  'benq',
1873
  'bird',
1874
  'blackberry',
1875
  'blazer',
1876
  'cdm',
1877
  'cellphone',
 
1878
  'danger',
1879
  'ddipocket',
1880
  'docomo',
 
1881
  'dopod',
1882
- 'elaine/3\.0',
 
1883
  'ericsson',
1884
  'eudoraweb',
1885
  'fly',
 
 
1886
  'haier',
1887
  'hiptop',
1888
- 'hp\.ipaq',
1889
  'htc',
 
 
 
 
1890
  'huawei',
1891
- 'i\-mobile',
1892
  'iemobile',
1893
  'iemobile/7',
 
1894
  'iemobile/9',
1895
- 'j\-phone',
 
 
 
1896
  'kddi',
1897
  'konka',
1898
  'kwc',
@@ -1900,27 +2058,34 @@ $keys = array(
1900
  'lenovo',
1901
  'lg',
1902
  'lg/u990',
 
1903
  'lge\ vx',
 
 
1904
  'midp',
1905
- 'midp\-2\.0',
1906
  'mmef20',
1907
  'mmp',
1908
  'mobilephone',
1909
- 'mot\-v',
 
 
1910
  'motorola',
1911
- 'msie\ 10\.0',
1912
  'netfront',
1913
  'newgen',
1914
  'newt',
 
 
1915
  'nintendo\ ds',
1916
  'nintendo\ wii',
1917
  'nitro',
1918
  'nokia',
1919
  'novarra',
1920
- 'o2',
1921
  'openweb',
 
1922
  'opera\ mobi',
1923
- 'opera\.mobi',
1924
  'p160u',
1925
  'palm',
1926
  'panasonic',
@@ -1932,40 +2097,52 @@ $keys = array(
1932
  'playbook',
1933
  'playstation\ portable',
1934
  'portalmmm',
1935
- '\bppc\b',
1936
  'proxinet',
1937
  'psp',
1938
  'qtek',
 
1939
  'sagem',
1940
  'samsung',
 
1941
  'sanyo',
1942
  'sch',
1943
- 'sch\-i800',
1944
  'sec',
1945
  'sendo',
 
 
1946
  'sgh',
1947
  'sharp',
1948
- 'sharp\-tq\-gx10',
1949
  'small',
1950
  'smartphone',
1951
  'softbank',
1952
  'sonyericsson',
 
 
 
1953
  'sph',
1954
  'symbian',
1955
  'symbian\ os',
1956
  'symbianos',
 
 
 
1957
  'toshiba',
 
1958
  'treo',
1959
- 'ts21i\-10',
1960
- 'up\.browser',
1961
- 'up\.link',
1962
  'uts',
1963
  'vertu',
1964
  'vodafone',
1965
  'wap',
 
 
1966
  'willcome',
1967
  'windows\ ce',
1968
- 'windows\.ce',
1969
  'winwap',
1970
  'xda',
1971
  'xoom',
@@ -2109,8 +2286,7 @@ $keys = array(
2109
  'type' => 'array',
2110
  'default' => array(
2111
  'newrelic' => 'w3-total-cache/Extension_NewRelic_Plugin.php',
2112
- 'fragmentcache' => 'w3-total-cache/Extension_FragmentCache_Plugin.php',
2113
- 'swarmify' => 'w3-total-cache/Extension_Swarmify_Plugin.php'
2114
  )
2115
  ),
2116
  'extensions.active_frontend' => array(
128
  'default' => array(
129
  'gdsr_',
130
  'wp_rg_',
131
+ '_wp_session_',
132
+ '_wc_session_'
133
  )
134
  ),
135
  'dbcache.reject.uri' => array(
980
  'type' => 'boolean',
981
  'default' => false
982
  ),
983
+ 'cdn.flush_manually' => array(
984
+ 'type' => 'boolean',
985
+ 'default' => false
986
+ ),
987
  'cdn.engine' => array(
988
  'type' => 'string',
989
+ 'default' => 'stackpath2'
990
  ),
991
  'cdn.uploads.enable' => array(
992
  'type' => 'boolean',
1100
  'type' => 'string',
1101
  'default' => 'auto'
1102
  ),
1103
+ 'cdn.ftp.default_keys' => array(
1104
+ 'type' => 'boolean',
1105
+ 'default' => true
1106
+ ),
1107
+ 'cdn.ftp.pubkey' => array(
1108
+ 'type' => 'string',
1109
+ 'default' => ''
1110
+ ),
1111
+ 'cdn.ftp.privkey' => array(
1112
+ 'type' => 'string',
1113
+ 'default' => ''
1114
+ ),
1115
 
1116
  'cdn.google_drive.client_id' => array(
1117
  'type' => 'string',
1450
  'type' => 'integer',
1451
  'default' => 0
1452
  ),
1453
+ 'cdn.stackpath2.client_id' => array(
1454
+ 'type' => 'string',
1455
+ 'default' => ''
1456
+ ),
1457
+ 'cdn.stackpath2.client_secret' => array(
1458
+ 'type' => 'string',
1459
+ 'default' => ''
1460
+ ),
1461
+ 'cdn.stackpath2.stack_id' => array(
1462
+ 'type' => 'string',
1463
+ 'default' => ''
1464
+ ),
1465
+ 'cdn.stackpath2.site_id' => array(
1466
+ 'type' => 'string',
1467
+ 'default' => 0
1468
+ ),
1469
+ 'cdn.stackpath2.site_root_domain' => array(
1470
+ 'type' => 'string',
1471
+ 'default' => 0
1472
+ ),
1473
+ 'cdn.stackpath2.domain' => array(
1474
+ 'type' => 'array',
1475
+ 'default' => array()
1476
+ ),
1477
+ 'cdn.stackpath2.ssl' => array(
1478
+ 'type' => 'string',
1479
+ 'default' => 'auto'
1480
+ ),
1481
  'cdn.reject.admins' => array(
1482
  'type' => 'boolean',
1483
  'default' => false
1562
  'type' => 'integer',
1563
  'default' => 0
1564
  ),
1565
+ 'cdnfsd.stackpath2.client_id' => array(
1566
+ 'type' => 'string',
1567
+ 'default' => ''
1568
+ ),
1569
+ 'cdnfsd.stackpath2.client_secret' => array(
1570
+ 'type' => 'string',
1571
+ 'default' => ''
1572
+ ),
1573
+ 'cdnfsd.stackpath2.stack_id' => array(
1574
+ 'type' => 'string',
1575
+ 'default' => ''
1576
+ ),
1577
+ 'cdnfsd.stackpath2.site_id' => array(
1578
+ 'type' => 'string',
1579
+ 'default' => 0
1580
+ ),
1581
+ 'cdnfsd.stackpath2.site_root_domain' => array(
1582
+ 'type' => 'string',
1583
+ 'default' => 0
1584
+ ),
1585
+ 'cdnfsd.stackpath2.domain' => array(
1586
+ 'type' => 'array',
1587
+ 'default' => array()
1588
+ ),
1589
+ 'cdnfsd.stackpath2.ssl' => array(
1590
+ 'type' => 'string',
1591
+ 'default' => 'auto'
1592
+ ),
1593
 
1594
  'varnish.configuration_overloaded' => array(
1595
  'type' => 'boolean',
1628
  'type' => 'array',
1629
  'default' => array(
1630
  'robots\.txt',
1631
+ '[a-z0-9_\-]*sitemap[a-z0-9_\.\-]*\.(xml|xsl|html)(\.gz)?'
1632
  )
1633
  ),
1634
  'browsercache.cssjs.last_modified' => array(
1639
  'type' => 'boolean',
1640
  'default' => true
1641
  ),
1642
+ 'browsercache.cssjs.brotli' => array(
1643
+ 'type' => 'boolean',
1644
+ 'default' => false
1645
+ ),
1646
  'browsercache.cssjs.expires' => array(
1647
  'type' => 'boolean',
1648
  'default' => true
1683
  'type' => 'boolean',
1684
  'default' => true
1685
  ),
1686
+ 'browsercache.html.brotli' => array(
1687
+ 'type' => 'boolean',
1688
+ 'default' => false
1689
+ ),
1690
  'browsercache.html.last_modified' => array(
1691
  'type' => 'boolean',
1692
  'default' => true
1727
  'type' => 'boolean',
1728
  'default' => true
1729
  ),
1730
+ 'browsercache.other.brotli' => array(
1731
+ 'type' => 'boolean',
1732
+ 'default' => false
1733
+ ),
1734
  'browsercache.other.expires' => array(
1735
  'type' => 'boolean',
1736
  'default' => true
1839
  'type' => 'string',
1840
  'default' => '0'
1841
  ),
1842
+ 'browsercache.security.referrer.policy' => array(
1843
+ 'type' => 'boolean',
1844
+ 'default' => 'false'
1845
+ ),
1846
+ 'browsercache.security.referrer.policy.directive' => array(
1847
+ 'type' => 'string',
1848
+ 'default' => 'no-referrer-when-downgrade'
1849
+ ),
1850
  'browsercache.security.csp' => array(
1851
  'type' => 'boolean',
1852
  'default' => false
1921
  'mobile.rgroups' => array(
1922
  'type' => 'array',
1923
  'default' => array(
1924
+ 'tablets' => array(
1925
  'theme' => '',
1926
  'enabled' => false,
1927
  'redirect' => '',
1928
  'agents' => array(
1929
+ 'a1-32ab0',
1930
+ 'a210',
1931
+ 'a211',
1932
+ 'b6000-h',
1933
+ 'b8000-h',
1934
+ 'bnrv200',
1935
+ 'bntv400',
1936
+ 'darwin',
1937
+ 'gt-n8005',
1938
+ 'gt-p3105',
1939
+ 'gt-p6810',
1940
+ 'gt-p7510',
1941
+ 'hmj37',
1942
+ 'hp-tablet',
1943
+ 'hp\sslate',
1944
+ 'hp\sslatebook',
1945
+ 'ht7s3',
1946
+ 'ideatab_a1107',
1947
+ 'ideataba2109a',
1948
+ 'ideos\ss7',
1949
+ 'imm76d',
1950
+ 'ipad',
1951
+ 'k00f',
1952
+ 'kfjwi',
1953
+ 'kfot',
1954
+ 'kftt',
1955
  'kindle',
1956
+ 'l-06c',
1957
+ 'lg-f200k',
1958
+ 'lg-f200l',
1959
+ 'lg-f200s',
1960
+ 'm470bsa',
1961
+ 'm470bse',
1962
+ 'maxwell',
1963
+ 'me173x',
1964
+ 'mediapad',
1965
+ 'midc497',
1966
+ 'msi\senjoy\s10\splus',
1967
+ 'mz601',
1968
+ 'mz616',
1969
+ 'nexus',
1970
+ 'nookcolor',
1971
+ 'pg09410',
1972
+ 'pg41200',
1973
+ 'pmp5570c',
1974
+ 'pmp5588c',
1975
+ 'pocketbook',
1976
+ 'qmv7a',
1977
+ 'sgp311',
1978
+ 'sgpt12',
1979
+ 'shv-e230k',
1980
+ 'shw-m305w',
1981
+ 'shw-m380w',
1982
+ 'sm-p605',
1983
+ 'smarttab',
1984
+ 'sonysgp321',
1985
+ 'sph-p500',
1986
+ 'surfpad',
1987
+ 'tab07-200',
1988
+ 'tab10-201',
1989
+ 'tab465euk',
1990
+ 'tab474',
1991
+ 'tablet',
1992
+ 'tegranote',
1993
+ 'tf700t',
1994
+ 'thinkpad',
1995
+ 'viewpad',
1996
+ 'voltaire'
1997
  )
1998
  ),
1999
+ 'phones' => array(
2000
  'theme' => '',
2001
  'enabled' => false,
2002
  'redirect' => '',
2003
  'agents' => array(
2004
+ '(android|bb\d+|meego).+mobile',
2005
  '240x320',
2006
+ '2.0\ mmp',
2007
+ '\bppc\b',
2008
+ 'acer\ s100',
2009
  'alcatel',
2010
  'amoi',
2011
+ 'archos5',
2012
  'asus',
2013
+ 'au-mic',
2014
  'audiovox',
2015
  'avantgo',
2016
+ 'bada',
2017
  'benq',
2018
  'bird',
2019
  'blackberry',
2020
  'blazer',
2021
  'cdm',
2022
  'cellphone',
2023
+ 'cupcake',
2024
  'danger',
2025
  'ddipocket',
2026
  'docomo',
2027
+ 'docomo\ ht-03a',
2028
  'dopod',
2029
+ 'dream',
2030
+ 'elaine/3.0',
2031
  'ericsson',
2032
  'eudoraweb',
2033
  'fly',
2034
+ 'froyo',
2035
+ 'googlebot-mobile',
2036
  'haier',
2037
  'hiptop',
2038
+ 'hp.ipaq',
2039
  'htc',
2040
+ 'htc\ hero',
2041
+ 'htc\ magic',
2042
+ 'htc_dream',
2043
+ 'htc_magic',
2044
  'huawei',
2045
+ 'i-mobile',
2046
  'iemobile',
2047
  'iemobile/7',
2048
+ 'iemobile/7.0',
2049
  'iemobile/9',
2050
+ 'incognito',
2051
+ 'iphone',
2052
+ 'ipod',
2053
+ 'j-phone',
2054
  'kddi',
2055
  'konka',
2056
  'kwc',
2058
  'lenovo',
2059
  'lg',
2060
  'lg/u990',
2061
+ 'lg-gw620',
2062
  'lge\ vx',
2063
+ 'liquid\ build',
2064
+ 'maemo',
2065
  'midp',
2066
+ 'midp-2.0',
2067
  'mmef20',
2068
  'mmp',
2069
  'mobilephone',
2070
+ 'mot-mb200',
2071
+ 'mot-mb300',
2072
+ 'mot-v',
2073
  'motorola',
2074
+ 'msie\ 10.0',
2075
  'netfront',
2076
  'newgen',
2077
  'newt',
2078
+ 'nexus\ 7',
2079
+ 'nexus\ one',
2080
  'nintendo\ ds',
2081
  'nintendo\ wii',
2082
  'nitro',
2083
  'nokia',
2084
  'novarra',
 
2085
  'openweb',
2086
+ 'opera\ mini',
2087
  'opera\ mobi',
2088
+ 'opera.mobi',
2089
  'p160u',
2090
  'palm',
2091
  'panasonic',
2097
  'playbook',
2098
  'playstation\ portable',
2099
  'portalmmm',
 
2100
  'proxinet',
2101
  'psp',
2102
  'qtek',
2103
+ 's8000',
2104
  'sagem',
2105
  'samsung',
2106
+ 'samsung-s8000',
2107
  'sanyo',
2108
  'sch',
2109
+ 'sch-i800',
2110
  'sec',
2111
  'sendo',
2112
+ 'series60.*webkit',
2113
+ 'series60/5.0',
2114
  'sgh',
2115
  'sharp',
2116
+ 'sharp-tq-gx10',
2117
  'small',
2118
  'smartphone',
2119
  'softbank',
2120
  'sonyericsson',
2121
+ 'sonyericssone10',
2122
+ 'sonyericssonu20',
2123
+ 'sonyericssonx10',
2124
  'sph',
2125
  'symbian',
2126
  'symbian\ os',
2127
  'symbianos',
2128
+ 't-mobile\ mytouch\ 3g',
2129
+ 't-mobile\ opal',
2130
+ 'tattoo',
2131
  'toshiba',
2132
+ 'touch',
2133
  'treo',
2134
+ 'ts21i-10',
2135
+ 'up.browser',
2136
+ 'up.link',
2137
  'uts',
2138
  'vertu',
2139
  'vodafone',
2140
  'wap',
2141
+ 'webmate',
2142
+ 'webos',
2143
  'willcome',
2144
  'windows\ ce',
2145
+ 'windows.ce',
2146
  'winwap',
2147
  'xda',
2148
  'xoom',
2286
  'type' => 'array',
2287
  'default' => array(
2288
  'newrelic' => 'w3-total-cache/Extension_NewRelic_Plugin.php',
2289
+ 'fragmentcache' => 'w3-total-cache/Extension_FragmentCache_Plugin.php'
 
2290
  )
2291
  ),
2292
  'extensions.active_frontend' => array(
ConfigState.php CHANGED
@@ -13,6 +13,11 @@ namespace W3TC;
13
  * common.hide_note_no_zlib
14
  * common.hide_note_zlib_output_compression
15
  * common.show_note.nginx_restart_required
 
 
 
 
 
16
  * minify.error.file
17
  * minify.error.last
18
  * minify.error.notification.last
@@ -31,6 +36,7 @@ namespace W3TC;
31
  * cdn.google_drive.access_token
32
  * cdn.rackspace_cf.access_state
33
  * cdn.rackspace_cdn.access_state
 
34
  * cdn.show_note_theme_changed
35
  * cdn.show_note_wp_upgraded
36
  * cdn.show_note_cdn_upload
13
  * common.hide_note_no_zlib
14
  * common.hide_note_zlib_output_compression
15
  * common.show_note.nginx_restart_required
16
+ * common.hide_note_php_version_56
17
+ * license.status
18
+ * license.next_check - time of next check
19
+ * license.terms - accepted/declined/''
20
+ * license.community_terms - accepted/declined/'' (master)
21
  * minify.error.file
22
  * minify.error.last
23
  * minify.error.notification.last
36
  * cdn.google_drive.access_token
37
  * cdn.rackspace_cf.access_state
38
  * cdn.rackspace_cdn.access_state
39
+ * cdn.stackpath2.access_token
40
  * cdn.show_note_theme_changed
41
  * cdn.show_note_wp_upgraded
42
  * cdn.show_note_cdn_upload
DbCache_Environment.php CHANGED
@@ -20,10 +20,12 @@ class DbCache_Environment {
20
  public function fix_on_wpadmin_request( $config, $force_all_checks ) {
21
  $exs = new Util_Environment_Exceptions();
22
  try {
23
- if ( $config->get_boolean( 'dbcache.enabled' ) )
 
24
  $this->create_addin();
25
- else
26
  $this->delete_addin();
 
27
  } catch ( Util_WpFile_FilesystemOperationException $ex ) {
28
  $exs->push( $ex );
29
  }
20
  public function fix_on_wpadmin_request( $config, $force_all_checks ) {
21
  $exs = new Util_Environment_Exceptions();
22
  try {
23
+ if ( $config->get_boolean( 'dbcache.enabled' ) ||
24
+ Util_Environment::is_dbcluster() ) {
25
  $this->create_addin();
26
+ } else {
27
  $this->delete_addin();
28
+ }
29
  } catch ( Util_WpFile_FilesystemOperationException $ex ) {
30
  $exs->push( $ex );
31
  }
Extension_CloudFlare_Plugin.php CHANGED
@@ -321,7 +321,6 @@ class Extension_CloudFlare_Plugin {
321
  return 0;
322
 
323
  $left_piece = $pieces[0];
324
- $right_piece = $pieces[1];
325
 
326
  // Extract out the main IP pieces
327
  $ip_pieces = explode( "::", $left_piece, 2 );
@@ -338,7 +337,6 @@ class Extension_CloudFlare_Plugin {
338
  }
339
 
340
  // Check to see if the last IP block (part after ::) is set
341
- $last_piece = "";
342
  $size = count( $main_ip_pieces );
343
  if ( trim( $last_ip_piece ) != "" ) {
344
  $last_piece = str_pad( $last_ip_piece, 4, "0", STR_PAD_LEFT );
@@ -373,7 +371,6 @@ class Extension_CloudFlare_Plugin {
373
  private function ipv6_in_range( $ip, $range_ip ) {
374
  $pieces = explode( "/", $range_ip, 2 );
375
  $left_piece = $pieces[0];
376
- $right_piece = $pieces[1];
377
 
378
  // Extract out the main IP pieces
379
  $ip_pieces = explode( "::", $left_piece, 2 );
321
  return 0;
322
 
323
  $left_piece = $pieces[0];
 
324
 
325
  // Extract out the main IP pieces
326
  $ip_pieces = explode( "::", $left_piece, 2 );
337
  }
338
 
339
  // Check to see if the last IP block (part after ::) is set
 
340
  $size = count( $main_ip_pieces );
341
  if ( trim( $last_ip_piece ) != "" ) {
342
  $last_piece = str_pad( $last_ip_piece, 4, "0", STR_PAD_LEFT );
371
  private function ipv6_in_range( $ip, $range_ip ) {
372
  $pieces = explode( "/", $range_ip, 2 );
373
  $left_piece = $pieces[0];
 
374
 
375
  // Extract out the main IP pieces
376
  $ip_pieces = explode( "::", $left_piece, 2 );
Extension_CloudFlare_Widget.php CHANGED
@@ -14,13 +14,13 @@ class Extension_CloudFlare_Widget {
14
  add_action( 'w3tc_widget_setup', array(
15
  $this,
16
  'w3tc_widget_setup'
17
- ) );
18
  }
19
 
20
 
21
 
22
  function w3tc_widget_setup() {
23
- Util_Widget::add( 'w3tc_cloudflare',
24
  '<div class="w3tc_cloudflare_widget_logo"></div>',
25
  array( $this, 'widget_form' ),
26
  Util_Ui::admin_url( 'admin.php?page=w3tc_general#cloudflare' ),
@@ -51,7 +51,7 @@ class Extension_CloudFlare_Widget {
51
  } catch ( \Exception $e ) {
52
  $stats = null;
53
  }
54
-
55
  include W3TC_DIR . '/Extension_CloudFlare_Widget_View.php';
56
  }
57
 
14
  add_action( 'w3tc_widget_setup', array(
15
  $this,
16
  'w3tc_widget_setup'
17
+ ), 10000 );
18
  }
19
 
20
 
21
 
22
  function w3tc_widget_setup() {
23
+ Util_Widget::add( 'w3tc_cloudflare',
24
  '<div class="w3tc_cloudflare_widget_logo"></div>',
25
  array( $this, 'widget_form' ),
26
  Util_Ui::admin_url( 'admin.php?page=w3tc_general#cloudflare' ),
51
  } catch ( \Exception $e ) {
52
  $stats = null;
53
  }
54
+
55
  include W3TC_DIR . '/Extension_CloudFlare_Widget_View.php';
56
  }
57
 
Extension_NewRelic_GeneralPage_View.php CHANGED
@@ -13,10 +13,10 @@ Util_Ui::config_overloading_button( array(
13
  ?>
14
 
15
  <?php if ( !$new_relic_installed ): ?>
16
- <p><?php echo sprintf( __( '
17
- New Relic may not be installed or not active on this server. %s. Visit %s for installation instructions.', 'w3-total-cache' )
18
- , '<a href="' . esc_attr( NEWRELIC_SIGNUP_URL ) . '" target="_blank">' . __( 'Sign up for a (free) account', 'w3-total-cache' ) . '</a>'
19
- , '<a href="https://newrelic.com/docs/php/new-relic-for-php" target="_blank">New Relic</a>' )
20
  ?>
21
  </p>
22
  <?php endif; ?>
13
  ?>
14
 
15
  <?php if ( !$new_relic_installed ): ?>
16
+ <p><?php echo sprintf(
17
+ w3tc_er( 'newrelic.general.header', 'New Relic may not be installed or not active on this server. <a href="%s" target="_blank">Sign up for a (free) account</a>. Visit <a href="%s" target="_blank">New Relic</a> for installation instructions.' ),
18
+ esc_url( W3TC_NEWRELIC_SIGNUP_URL ),
19
+ esc_url( 'https://newrelic.com/docs/php/new-relic-for-php' ) )
20
  ?>
21
  </p>
22
  <?php endif; ?>
Extension_NewRelic_Plugin_Admin.php CHANGED
@@ -72,14 +72,19 @@ class Extension_NewRelic_Plugin_Admin {
72
  ) );
73
  }
74
 
75
- add_action( 'admin_init_w3tc_dashboard', array(
76
- '\W3TC\Extension_NewRelic_Widget',
77
- 'admin_init_w3tc_dashboard' ) );
78
- add_action( 'w3tc_ajax', array(
79
- '\W3TC\Extension_NewRelic_Widget',
80
- 'w3tc_ajax' ) );
81
-
82
- add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
 
 
 
 
 
83
  }
84
 
85
 
72
  ) );
73
  }
74
 
75
+ $v = $this->_config->get_string( array( 'newrelic', 'api_key' ) );
76
+ $new_relic_configured = !empty( $v );
77
+
78
+ if ( $new_relic_configured ) {
79
+ add_action( 'admin_init_w3tc_dashboard', array(
80
+ '\W3TC\Extension_NewRelic_Widget',
81
+ 'admin_init_w3tc_dashboard' ) );
82
+ add_action( 'w3tc_ajax', array(
83
+ '\W3TC\Extension_NewRelic_Widget',
84
+ 'w3tc_ajax' ) );
85
+
86
+ add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
87
+ }
88
  }
89
 
90
 
Extension_NewRelic_Widget.php CHANGED
@@ -27,9 +27,9 @@ class Extension_NewRelic_Widget {
27
  $o = new Extension_NewRelic_Widget();
28
  $o->_config = Dispatcher::config();
29
 
30
- add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 350 );
31
  add_action( 'w3tc_network_dashboard_setup',
32
- array( $o, 'wp_dashboard_setup' ), 350 );
33
 
34
  $nerser = Dispatcher::component( 'Extension_NewRelic_Service' );
35
  $view_application = $nerser->get_effective_application_id();
27
  $o = new Extension_NewRelic_Widget();
28
  $o->_config = Dispatcher::config();
29
 
30
+ add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 9000 );
31
  add_action( 'w3tc_network_dashboard_setup',
32
+ array( $o, 'wp_dashboard_setup' ), 9000 );
33
 
34
  $nerser = Dispatcher::component( 'Extension_NewRelic_Service' );
35
  $view_application = $nerser->get_effective_application_id();
Extension_NewRelic_Widget_View_Browser.php CHANGED
@@ -7,7 +7,7 @@ if ( !defined( 'W3TC' ) )
7
  ?>
8
  <?php _e( 'Metrics are not available for browser applications', 'w3-total-cache' )?>
9
  <p>
10
- <a href="<?php echo esc_attr( NEWRELIC_SIGNUP_URL ); ?>" target="_blank">
11
  <?php _e( 'Upgrade your New Relic account to enable more metrics.', 'w3-total-cache' )?>
12
  </a>
13
  </p>
7
  ?>
8
  <?php _e( 'Metrics are not available for browser applications', 'w3-total-cache' )?>
9
  <p>
10
+ <a href="<?php echo esc_attr( W3TC_NEWRELIC_SIGNUP_URL ); ?>" target="_blank">
11
  <?php _e( 'Upgrade your New Relic account to enable more metrics.', 'w3-total-cache' )?>
12
  </a>
13
  </p>
Extension_Swarmify_Widget.php CHANGED
@@ -10,9 +10,10 @@ class Extension_Swarmify_Widget {
10
  $o = new Extension_Swarmify_Widget();
11
  $o->_config = Dispatcher::config();
12
 
13
- add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 150 );
 
14
  add_action( 'w3tc_network_dashboard_setup',
15
- array( $o, 'wp_dashboard_setup' ), 150 );
16
 
17
  wp_enqueue_style( 'w3tc-widget-swarmify',
18
  plugins_url( 'Extension_Swarmify_Widget_View.css', W3TC_FILE ),
10
  $o = new Extension_Swarmify_Widget();
11
  $o->_config = Dispatcher::config();
12
 
13
+ add_action( 'w3tc_widget_setup',
14
+ array( $o, 'wp_dashboard_setup' ), 9000 );
15
  add_action( 'w3tc_network_dashboard_setup',
16
+ array( $o, 'wp_dashboard_setup' ), 9500 );
17
 
18
  wp_enqueue_style( 'w3tc-widget-swarmify',
19
  plugins_url( 'Extension_Swarmify_Widget_View.css', W3TC_FILE ),
Generic_AdminActions_Config.php CHANGED
@@ -160,13 +160,16 @@ class Generic_AdminActions_Config {
160
  $support = Util_Request::get_string( 'support' );
161
  $tweeted = Util_Request::get_boolean( 'tweeted' );
162
  $signmeup = Util_Request::get_boolean( 'signmeup' );
163
- $track_usage = Util_Request::get_boolean( 'track_usage' );
164
  $this->_config->set( 'common.support', $support );
165
  $this->_config->set( 'common.tweeted', $tweeted );
166
- if ( $track_usage )
 
 
167
  $this->_config->set( 'common.track_usage', true );
168
- else
169
- $this->_config->set( 'common.track_usage', false );
 
170
 
171
  if ( $signmeup ) {
172
  if ( Util_Environment::is_w3tc_pro( $this->_config ) )
160
  $support = Util_Request::get_string( 'support' );
161
  $tweeted = Util_Request::get_boolean( 'tweeted' );
162
  $signmeup = Util_Request::get_boolean( 'signmeup' );
163
+ $accept_terms = Util_Request::get_boolean( 'accept_terms' );
164
  $this->_config->set( 'common.support', $support );
165
  $this->_config->set( 'common.tweeted', $tweeted );
166
+
167
+ $state_master = Dispatcher::config_state_master();
168
+ if ( $accept_terms ) {
169
  $this->_config->set( 'common.track_usage', true );
170
+ $state_master->set( 'license.community_terms', 'accept' );
171
+ }
172
+ $state_master->save();
173
 
174
  if ( $signmeup ) {
175
  if ( Util_Environment::is_w3tc_pro( $this->_config ) )
Generic_AdminActions_Default.php CHANGED
@@ -3,6 +3,11 @@ namespace W3TC;
3
 
4
 
5
 
 
 
 
 
 
6
  define( 'W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN', '~define\s*\(\s*[\'"]COOKIE_DOMAIN[\'"]\s*,.*?\)~is' );
7
 
8
  class Generic_AdminActions_Default {
@@ -256,55 +261,62 @@ class Generic_AdminActions_Default {
256
  $config->set( 'pgcache.enabled', false );
257
  $data['response_errors'][] = 'fancy_permalinks_disabled_pgcache';
258
  }
259
-
260
- if ( !Util_Environment::is_w3tc_pro( $this->_config ) )
261
- delete_transient( 'w3tc_license_status' );
262
  }
263
 
264
  /**
265
  * Minify tab
266
  */
267
- if ( $this->_page == 'w3tc_minify' && !$this->_config->get_boolean( 'minify.auto' ) ) {
268
- $js_groups = array();
269
- $css_groups = array();
270
-
271
- $js_files = Util_Request::get_array( 'js_files' );
272
- $css_files = Util_Request::get_array( 'css_files' );
 
 
273
 
274
- foreach ( $js_files as $theme => $templates ) {
275
- foreach ( $templates as $template => $locations ) {
276
- foreach ( (array) $locations as $location => $types ) {
277
- foreach ( (array) $types as $files ) {
278
- foreach ( (array) $files as $file ) {
279
- if ( !empty( $file ) ) {
280
- $js_groups[$theme][$template][$location]['files'][] = Util_Environment::normalize_file_minify( $file );
 
 
 
 
 
 
 
 
281
  }
282
  }
283
  }
284
  }
285
  }
286
- }
287
 
288
- foreach ( $css_files as $theme => $templates ) {
289
- foreach ( $templates as $template => $locations ) {
290
- foreach ( (array) $locations as $location => $files ) {
291
- foreach ( (array) $files as $file ) {
292
- if ( !empty( $file ) ) {
293
- $css_groups[$theme][$template][$location]['files'][] = Util_Environment::normalize_file_minify( $file );
 
294
  }
295
  }
296
  }
297
  }
298
- }
299
 
300
- $config->set( 'minify.js.groups', $js_groups );
301
- $config->set( 'minify.css.groups', $css_groups );
302
 
303
- $js_theme = Util_Request::get_string( 'js_theme' );
304
- $css_theme = Util_Request::get_string( 'css_theme' );
305
 
306
- $data['response_query_string']['js_theme'] = $js_theme;
307
- $data['response_query_string']['css_theme'] = $css_theme;
 
308
  }
309
 
310
  /**
@@ -592,6 +604,9 @@ class Generic_AdminActions_Default {
592
 
593
  $config->set( 'cdn.stackpath.domain', $cdn_domains );
594
  break;
 
 
 
595
  }
596
  }
597
 
@@ -666,6 +681,32 @@ class Generic_AdminActions_Default {
666
  );
667
  }
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  /**
670
  * Enables COOKIE_DOMAIN
671
  *
3
 
4
 
5
 
6
+ use RecursiveDirectoryIterator;
7
+ use RecursiveIteratorIterator;
8
+ use RecursiveRegexIterator;
9
+ use RegexIterator;
10
+
11
  define( 'W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN', '~define\s*\(\s*[\'"]COOKIE_DOMAIN[\'"]\s*,.*?\)~is' );
12
 
13
  class Generic_AdminActions_Default {
261
  $config->set( 'pgcache.enabled', false );
262
  $data['response_errors'][] = 'fancy_permalinks_disabled_pgcache';
263
  }
 
 
 
264
  }
265
 
266
  /**
267
  * Minify tab
268
  */
269
+ if ( $this->_page == 'w3tc_minify' ) {
270
+ if ( ( $this->_config->get_boolean( 'minify.js.http2push' ) && ! $config->get_boolean( 'minify.js.http2push' ) ) ||
271
+ ( $this->_config->get_boolean( 'minify.css.http2push' ) && ! $config->get_boolean( 'minify.css.http2push' ) ) ) {
272
+ if ( $config->get_string( 'pgcache.engine' ) == 'file_generic' ) {
273
+ $cache_dir = Util_Environment::cache_blog_dir( 'page_enhanced' );
274
+ $this->_deleteAllHtaccessFiles( $cache_dir );
275
+ }
276
+ }
277
 
278
+ if ( !$this->_config->get_boolean( 'minify.auto' ) ) {
279
+ $js_groups = array();
280
+ $css_groups = array();
281
+
282
+ $js_files = Util_Request::get_array( 'js_files' );
283
+ $css_files = Util_Request::get_array( 'css_files' );
284
+
285
+ foreach ( $js_files as $theme => $templates ) {
286
+ foreach ( $templates as $template => $locations ) {
287
+ foreach ( (array) $locations as $location => $types ) {
288
+ foreach ( (array) $types as $files ) {
289
+ foreach ( (array) $files as $file ) {
290
+ if ( !empty( $file ) ) {
291
+ $js_groups[$theme][$template][$location]['files'][] = Util_Environment::normalize_file_minify( $file );
292
+ }
293
  }
294
  }
295
  }
296
  }
297
  }
 
298
 
299
+ foreach ( $css_files as $theme => $templates ) {
300
+ foreach ( $templates as $template => $locations ) {
301
+ foreach ( (array) $locations as $location => $files ) {
302
+ foreach ( (array) $files as $file ) {
303
+ if ( !empty( $file ) ) {
304
+ $css_groups[$theme][$template][$location]['files'][] = Util_Environment::normalize_file_minify( $file );
305
+ }
306
  }
307
  }
308
  }
309
  }
 
310
 
311
+ $config->set( 'minify.js.groups', $js_groups );
312
+ $config->set( 'minify.css.groups', $css_groups );
313
 
314
+ $js_theme = Util_Request::get_string( 'js_theme' );
315
+ $css_theme = Util_Request::get_string( 'css_theme' );
316
 
317
+ $data['response_query_string']['js_theme'] = $js_theme;
318
+ $data['response_query_string']['css_theme'] = $css_theme;
319
+ }
320
  }
321
 
322
  /**
604
 
605
  $config->set( 'cdn.stackpath.domain', $cdn_domains );
606
  break;
607
+ case 'stackpath2':
608
+ $config->set( 'cdn.stackpath2.domain', $cdn_domains );
609
+ break;
610
  }
611
  }
612
 
681
  );
682
  }
683
 
684
+ private function _deleteAllHtaccessFiles($dir) {
685
+ if ( ! is_dir( $dir ) ) {
686
+ return;
687
+ }
688
+
689
+ $handle = opendir( $dir );
690
+ if ( $handle === false ) {
691
+ return;
692
+ }
693
+
694
+ while ( false !== ( $file = readdir( $handle ) ) ) {
695
+ if ( $file == '.' || $file == '..' ) {
696
+ continue;
697
+ }
698
+
699
+ if ( is_dir( $file ) ) {
700
+ $this->_deleteAllHtaccessFiles( $file );
701
+ continue;
702
+ } else if ( $file === '.htaccess' ) {
703
+ @unlink( $file );
704
+ }
705
+ }
706
+
707
+ closedir( $handle );
708
+ }
709
+
710
  /**
711
  * Enables COOKIE_DOMAIN
712
  *
Generic_AdminActions_Flush.php CHANGED
@@ -120,7 +120,7 @@ class Generic_AdminActions_Flush {
120
  * @return void
121
  */
122
  function w3tc_flush_pgcache() {
123
- w3tc_flush_posts();
124
 
125
  $state_note = Dispatcher::config_state_note();
126
  $state_note->set( 'common.show_note.flush_posts_needed', false );
@@ -214,7 +214,7 @@ class Generic_AdminActions_Flush {
214
 
215
  /*
216
  * Flush varnish cache
217
- */
218
  function w3tc_flush_varnish() {
219
  $this->flush_varnish();
220
 
@@ -225,9 +225,9 @@ class Generic_AdminActions_Flush {
225
 
226
  /*
227
  * Flush CDN mirror
228
- */
229
  function w3tc_flush_cdn() {
230
- $this->flush_cdn();
231
 
232
  Util_Admin::redirect( array(
233
  'w3tc_note' => 'flush_cdn'
@@ -242,7 +242,7 @@ class Generic_AdminActions_Flush {
242
  */
243
  function w3tc_flush_post() {
244
  $post_id = Util_Request::get_integer( 'post_id' );
245
- w3tc_flush_post( $post_id );
246
 
247
  Util_Admin::redirect( array(
248
  'w3tc_note' => 'pgcache_purge_post'
@@ -368,9 +368,9 @@ class Generic_AdminActions_Flush {
368
  /**
369
  * Flush CDN mirror
370
  */
371
- function flush_cdn() {
372
  $cacheflush = Dispatcher::component( 'CacheFlush' );
373
- $cacheflush->cdn_purge_all();
374
  }
375
 
376
 
120
  * @return void
121
  */
122
  function w3tc_flush_pgcache() {
123
+ w3tc_flush_posts( array( 'ui_action' => 'flush_button' ) );
124
 
125
  $state_note = Dispatcher::config_state_note();
126
  $state_note->set( 'common.show_note.flush_posts_needed', false );
214
 
215
  /*
216
  * Flush varnish cache
217
+ */
218
  function w3tc_flush_varnish() {
219
  $this->flush_varnish();
220
 
225
 
226
  /*
227
  * Flush CDN mirror
228
+ */
229
  function w3tc_flush_cdn() {
230
+ $this->flush_cdn( array( 'ui_action' => 'flush_button' ) );
231
 
232
  Util_Admin::redirect( array(
233
  'w3tc_note' => 'flush_cdn'
242
  */
243
  function w3tc_flush_post() {
244
  $post_id = Util_Request::get_integer( 'post_id' );
245
+ w3tc_flush_post( $post_id, array( 'ui_action' => 'flush_button' ) );
246
 
247
  Util_Admin::redirect( array(
248
  'w3tc_note' => 'pgcache_purge_post'
368
  /**
369
  * Flush CDN mirror
370
  */
371
+ function flush_cdn( $extras = array() ) {
372
  $cacheflush = Dispatcher::component( 'CacheFlush' );
373
+ $cacheflush->cdn_purge_all( $extras );
374
  }
375
 
376
 
Generic_Faq.php CHANGED
@@ -5,22 +5,20 @@ class Generic_Faq {
5
  static public function sections() {
6
  // name => column where to show
7
  return array(
8
- 'General' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-General',
9
- 'Usage' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Usage',
10
- 'Compatibility' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Compatibility',
11
- 'Minification' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Minification',
12
- 'CDN' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-CDN',
13
- 'Browser Cache' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Browser-Cache',
14
- 'Errors / Debugging' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Debugging',
15
- 'Requirements' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Requirements',
16
- 'Developers' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Developers',
17
- 'Extensions' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Extensions',
18
- 'Installation' => 'https://github.com/Auctollo/w3-total-cache/wiki/FAQ%3A-Installation'
19
  );
20
  }
21
 
22
-
23
-
24
  /**
25
  * Returns list of questions for section
26
  */
5
  static public function sections() {
6
  // name => column where to show
7
  return array(
8
+ 'General' => 'https://api.w3-edge.com/v1/faq/general',
9
+ 'Usage' => 'https://api.w3-edge.com/v1/faq/usage',
10
+ 'Compatibility' => 'https://api.w3-edge.com/v1/faq/compatibility',
11
+ 'Minification' => 'https://api.w3-edge.com/v1/faq/minification',
12
+ 'CDN' => 'https://api.w3-edge.com/v1/faq/cdn',
13
+ 'Browser Cache' => 'https://api.w3-edge.com/v1/faq/browser-cache',
14
+ 'Errors / Debugging' => 'https://api.w3-edge.com/v1/faq/errors-debugging',
15
+ 'Requirements' => 'https://api.w3-edge.com/v1/faq/requirements',
16
+ 'Developers' => 'https://api.w3-edge.com/v1/faq/developers',
17
+ 'Extensions' => 'https://api.w3-edge.com/v1/faq/extensions',
18
+ 'Installation' => 'https://api.w3-edge.com/v1/faq/installation'
19
  );
20
  }
21
 
 
 
22
  /**
23
  * Returns list of questions for section
24
  */
Generic_Page_Dashboard_View.css CHANGED
@@ -1,6 +1,7 @@
1
  #w3tc-dashboard-widgets.metabox-holder {
2
  background-color: #FFF;
3
  margin:0;padding:0;
 
4
  }
5
  #w3tc-dashboard-widgets .hndle {
6
  height: 36px;
@@ -21,7 +22,12 @@
21
  margin-right: 200px;
22
  border: none;
23
  background-color: #fff;
 
24
  }
 
 
 
 
25
  #w3tc-dashboard-widgets .handlediv {
26
  display: none;
27
  }
1
  #w3tc-dashboard-widgets.metabox-holder {
2
  background-color: #FFF;
3
  margin:0;padding:0;
4
+ display: flex;
5
  }
6
  #w3tc-dashboard-widgets .hndle {
7
  height: 36px;
22
  margin-right: 200px;
23
  border: none;
24
  background-color: #fff;
25
+ flex-grow: 1;
26
  }
27
+ #w3tc-dashboard-widgets #postbox-container-right {
28
+ float: none;
29
+ }
30
+
31
  #w3tc-dashboard-widgets .handlediv {
32
  display: none;
33
  }
Generic_Page_General.php CHANGED
@@ -52,6 +52,7 @@ class Generic_Page_General extends Base_Page_Settings {
52
  $licensing_visible = ( ( !Util_Environment::is_wpmu() || is_network_admin() ) &&
53
  !ini_get( 'w3tc.license_key' ) &&
54
  get_transient( 'w3tc_license_status' ) != 'host_valid' );
 
55
 
56
  $custom_areas = apply_filters( "w3tc_settings_general_anchors", array() );
57
  include W3TC_INC_DIR . '/options/general.php';
52
  $licensing_visible = ( ( !Util_Environment::is_wpmu() || is_network_admin() ) &&
53
  !ini_get( 'w3tc.license_key' ) &&
54
  get_transient( 'w3tc_license_status' ) != 'host_valid' );
55
+ $is_pro = Util_Environment::is_w3tc_pro( $this->_config );
56
 
57
  $custom_areas = apply_filters( "w3tc_settings_general_anchors", array() );
58
  include W3TC_INC_DIR . '/options/general.php';
Generic_Plugin_Admin.php CHANGED
@@ -268,13 +268,13 @@ class Generic_Plugin_Admin {
268
 
269
  ?>
270
  <script type="text/javascript">
271
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
272
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
273
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
274
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
275
 
276
- ga('create', '<?php echo $profile ?>', 'auto');
277
- ga('set', {
278
  'dimension1': 'w3-total-cache',
279
  'dimension2': '<?php echo W3TC_VERSION ?>',
280
  'dimension3': '<?php global $wp_version; echo $wp_version; ?>',
@@ -286,7 +286,7 @@ class Generic_Plugin_Admin {
286
  'page': '<?php echo $page ?>'
287
  });
288
 
289
- ga('send', 'pageview');
290
 
291
  </script>
292
  <?php
268
 
269
  ?>
270
  <script type="text/javascript">
271
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
272
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
273
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
274
+ })(window,document,'script','https://api.w3-edge.com/v1/analytics','w3tc_ga');
275
 
276
+ w3tc_ga('create', '<?php echo $profile ?>', 'auto');
277
+ w3tc_ga('set', {
278
  'dimension1': 'w3-total-cache',
279
  'dimension2': '<?php echo W3TC_VERSION ?>',
280
  'dimension3': '<?php global $wp_version; echo $wp_version; ?>',
286
  'page': '<?php echo $page ?>'
287
  });
288
 
289
+ w3tc_ga('send', 'pageview');
290
 
291
  </script>
292
  <?php
Generic_WidgetServices.php CHANGED
@@ -21,9 +21,9 @@ class Generic_WidgetServices {
21
  static public function admin_init_w3tc_dashboard() {
22
  $o = new Generic_WidgetServices();
23
 
24
- add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 3 );
25
  add_action( 'w3tc_network_dashboard_setup',
26
- array( $o, 'wp_dashboard_setup' ), 3 );
27
  }
28
 
29
  function wp_dashboard_setup() {
@@ -42,14 +42,14 @@ class Generic_WidgetServices {
42
  $v = get_site_option( 'w3tc_generic_widgetservices' );
43
  try {
44
  $v = json_decode( $v, true );
45
- if ( isset( $v['items'] ) && isset( $v['expires'] ) &&
46
  $v['expires'] > time() )
47
  return $v['items'];
48
  } catch ( \Exception $e ) {
49
  }
50
 
51
 
52
- $result = wp_remote_request( W3TC_SUPPORT_SERVICES_URL,
53
  array( 'method' => 'GET' ) );
54
 
55
  if ( is_wp_error( $result ) )
@@ -60,10 +60,10 @@ class Generic_WidgetServices {
60
  if ( is_null( $response_json ) || !isset( $response_json['items'] ) )
61
  return null;
62
 
63
- update_site_option( 'w3tc_generic_widgetservices',
64
  json_encode( array(
65
- 'items' => $response_json['items'],
66
- 'expires' => time() + 3600 * 24 * 7
67
  ) ) );
68
 
69
  return $response_json['items'];
21
  static public function admin_init_w3tc_dashboard() {
22
  $o = new Generic_WidgetServices();
23
 
24
+ add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 5000 );
25
  add_action( 'w3tc_network_dashboard_setup',
26
+ array( $o, 'wp_dashboard_setup' ), 5000 );
27
  }
28
 
29
  function wp_dashboard_setup() {
42
  $v = get_site_option( 'w3tc_generic_widgetservices' );
43
  try {
44
  $v = json_decode( $v, true );
45
+ if ( isset( $v['items'] ) && isset( $v['expires'] ) &&
46
  $v['expires'] > time() )
47
  return $v['items'];
48
  } catch ( \Exception $e ) {
49
  }
50
 
51
 
52
+ $result = wp_remote_request( W3TC_SUPPORT_SERVICES_URL,
53
  array( 'method' => 'GET' ) );
54
 
55
  if ( is_wp_error( $result ) )
60
  if ( is_null( $response_json ) || !isset( $response_json['items'] ) )
61
  return null;
62
 
63
+ update_site_option( 'w3tc_generic_widgetservices',
64
  json_encode( array(
65
+ 'content' => $response_json,
66
+ 'expires' => time() + 3600 * 24 * 7
67
  ) ) );
68
 
69
  return $response_json['items'];
Generic_WidgetSpreadTheWord.js CHANGED
@@ -1,19 +1,19 @@
1
  jQuery(function() {
2
- jQuery('.button-vote').live('click', function() {
3
  window.open('https://wordpress.org/support/plugin/w3-total-cache/reviews/#new-post');
4
  });
5
 
6
- jQuery('.button-share').live('click', function() {
7
  window.open('https://plus.google.com/share?url=' +
8
  encodeURIComponent(w3tc_spread_the_word_product_url), '_blank');
9
  });
10
 
11
- jQuery('.button-tweet').live('click', function() {
12
  window.open('https://twitter.com/?status=' +
13
  encodeURIComponent(w3tc_spread_the_word_tweet), '_blank');
14
  });
15
 
16
- jQuery('.button-like').live('click', function() {
17
  window.open('https://www.facebook.com/sharer.php?u=' +
18
  encodeURIComponent(w3tc_spread_the_word_product_url), '_blank');
19
  });
@@ -34,7 +34,7 @@ jQuery(function() {
34
  });
35
  });
36
 
37
- jQuery('.button-rating').live('click', function() {
38
  window.open(w3tc_spread_the_word_rate_url, '_blank');
39
  });
40
- });
1
  jQuery(function() {
2
+ jQuery('.button-vote').on('click', function () {
3
  window.open('https://wordpress.org/support/plugin/w3-total-cache/reviews/#new-post');
4
  });
5
 
6
+ jQuery('.button-share').on('click', function () {
7
  window.open('https://plus.google.com/share?url=' +
8
  encodeURIComponent(w3tc_spread_the_word_product_url), '_blank');
9
  });
10
 
11
+ jQuery('.button-tweet').on('click', function () {
12
  window.open('https://twitter.com/?status=' +
13
  encodeURIComponent(w3tc_spread_the_word_tweet), '_blank');
14
  });
15
 
16
+ jQuery('.button-like').on('click', function () {
17
  window.open('https://www.facebook.com/sharer.php?u=' +
18
  encodeURIComponent(w3tc_spread_the_word_product_url), '_blank');
19
  });
34
  });
35
  });
36
 
37
+ jQuery('.button-rating').on('click', function () {
38
  window.open(w3tc_spread_the_word_rate_url, '_blank');
39
  });
40
+ });
Generic_WidgetSpreadTheWord_Plugin.php CHANGED
@@ -25,11 +25,11 @@ class Generic_WidgetSpreadTheWord_Plugin {
25
  add_action( 'w3tc_widget_setup', array(
26
  $this,
27
  'wp_dashboard_setup'
28
- ) );
29
  add_action( 'w3tc_network_dashboard_setup', array(
30
  $this,
31
  'wp_dashboard_setup'
32
- ) );
33
 
34
  if ( is_admin() ) {
35
  add_action( 'wp_ajax_w3tc_link_support', array( $this, 'action_widget_link_support' ) );
25
  add_action( 'w3tc_widget_setup', array(
26
  $this,
27
  'wp_dashboard_setup'
28
+ ), 4000 );
29
  add_action( 'w3tc_network_dashboard_setup', array(
30
  $this,
31
  'wp_dashboard_setup'
32
+ ), 4000 );
33
 
34
  if ( is_admin() ) {
35
  add_action( 'wp_ajax_w3tc_link_support', array( $this, 'action_widget_link_support' ) );
Licensing_AdminActions.php CHANGED
@@ -11,13 +11,21 @@ class Licensing_AdminActions {
11
  $this->_config = Dispatcher::config();
12
  }
13
 
 
 
14
  /**
15
  * test action
16
  */
17
  function w3tc_licensing_buy_plugin() {
 
 
 
 
18
  include W3TC_INC_DIR . '/lightbox/purchase.php';
19
  }
20
 
 
 
21
  /**
22
  * Self test action
23
  */
@@ -25,16 +33,26 @@ class Licensing_AdminActions {
25
  include W3TC_INC_DIR . '/lightbox/upgrade.php';
26
  }
27
 
 
 
28
  function w3tc_licensing_check_key() {
29
- delete_transient( 'w3tc_license_status' );
 
 
 
30
  Licensing_Core::activate_license( $this->_config->get_string( 'plugin.license_key' ), W3TC_VERSION );
31
  Util_Admin::redirect( array(), true );
32
  }
33
 
 
 
34
  function w3tc_licensing_reset_rooturi() {
35
  $license_key = $this->_config->get_string( 'plugin.license_key' );
36
 
37
- delete_transient( 'w3tc_license_status' );
 
 
 
38
  Licensing_Core::activate_license( $license_key, W3TC_VERSION );
39
 
40
  $license = Licensing_Core::check_license( $license_key, W3TC_VERSION );
@@ -60,4 +78,44 @@ class Licensing_AdminActions {
60
  ), true );
61
  }
62
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
11
  $this->_config = Dispatcher::config();
12
  }
13
 
14
+
15
+
16
  /**
17
  * test action
18
  */
19
  function w3tc_licensing_buy_plugin() {
20
+ $state = Dispatcher::config_state_master();
21
+ $iframe_url = W3TC_PURCHASE_URL .
22
+ '?install_date=' . esc_attr( $state->get_integer( 'common.install' ) );
23
+
24
  include W3TC_INC_DIR . '/lightbox/purchase.php';
25
  }
26
 
27
+
28
+
29
  /**
30
  * Self test action
31
  */
33
  include W3TC_INC_DIR . '/lightbox/upgrade.php';
34
  }
35
 
36
+
37
+
38
  function w3tc_licensing_check_key() {
39
+ $state = Dispatcher::config_state();
40
+ $state->set( 'license.next_check', 0 );
41
+ $state->save();
42
+
43
  Licensing_Core::activate_license( $this->_config->get_string( 'plugin.license_key' ), W3TC_VERSION );
44
  Util_Admin::redirect( array(), true );
45
  }
46
 
47
+
48
+
49
  function w3tc_licensing_reset_rooturi() {
50
  $license_key = $this->_config->get_string( 'plugin.license_key' );
51
 
52
+ $state = Dispatcher::config_state();
53
+ $state->set( 'license.next_check', 0 );
54
+ $state->save();
55
+
56
  Licensing_Core::activate_license( $license_key, W3TC_VERSION );
57
 
58
  $license = Licensing_Core::check_license( $license_key, W3TC_VERSION );
78
  ), true );
79
  }
80
  }
81
+
82
+
83
+
84
+ static public function w3tc_licensing_terms_accept() {
85
+ Licensing_Core::terms_accept();
86
+
87
+ Util_Admin::redirect_with_custom_messages2( array(
88
+ 'notes' => array( 'Terms have been accepted' )
89
+ ), true );
90
+ }
91
+
92
+
93
+
94
+ static public function w3tc_licensing_terms_decline() {
95
+ $c = Dispatcher::config();
96
+ if ( !Util_Environment::is_w3tc_pro( $c ) ) {
97
+ $state_master = Dispatcher::config_state_master();
98
+ $state_master->set( 'license.community_terms', 'decline' );
99
+ $state_master->save();
100
+ } else {
101
+ // not called in this mode
102
+ }
103
+
104
+ Util_Admin::redirect_with_custom_messages2( array(
105
+ 'notes' => array( 'Terms have been declined' )
106
+ ), true );
107
+ }
108
+
109
+
110
+
111
+ static public function w3tc_licensing_terms_refresh() {
112
+ $state = Dispatcher::config_state();
113
+ $state->set( 'license.next_check', 0 );
114
+ $state->set( 'license.terms', 'postpone' );
115
+ $state->save();
116
+
117
+ Util_Admin::redirect_with_custom_messages2( array(
118
+ 'notes' => array( 'Thank you for your reaction' )
119
+ ), true );
120
+ }
121
  }
Licensing_Core.php CHANGED
@@ -8,19 +8,22 @@ class Licensing_Core {
8
  * Activates a license
9
  */
10
  static public function activate_license( $license, $version ) {
 
 
11
  // data to send in our API request
12
  $api_params = array(
13
  'edd_action'=> 'activate_license',
14
  'license' => $license, // legacy
15
  'license_key' => $license,
16
  'home_url' => network_home_url(),
17
- 'item_name' => urlencode( EDD_W3EDGE_W3TC_NAME ), // the name of our product in EDD
 
18
  'r' => rand(),
19
  'version' => $version
20
  );
21
 
22
  // Call the custom API.
23
- $response = wp_remote_get( add_query_arg( $api_params, EDD_W3EDGE_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
24
  if ( is_wp_error( $response ) )
25
  return false;
26
 
@@ -39,12 +42,12 @@ class Licensing_Core {
39
  'license' => $license, // legacy
40
  'license_key' => $license,
41
  'home_url' => network_home_url(),
42
- 'item_name' => urlencode( EDD_W3EDGE_W3TC_NAME ), // the name of our product in EDD,
43
  'r' => rand()
44
  );
45
 
46
  // Call the custom API.
47
- $response = wp_remote_get( add_query_arg( $api_params, EDD_W3EDGE_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
48
 
49
  // make sure the response came back okay
50
  if ( is_wp_error( $response ) )
@@ -68,13 +71,13 @@ class Licensing_Core {
68
  'license' => $license, // legacy
69
  'license_key' => $license,
70
  'home_url' => network_home_url(),
71
- 'item_name' => urlencode( EDD_W3EDGE_W3TC_NAME ),
72
  'r' => rand(),
73
  'version' => $version
74
  );
75
 
76
  // Call the custom API.
77
- $response = wp_remote_get( add_query_arg( $api_params, EDD_W3EDGE_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
78
 
79
  if ( is_wp_error( $response ) )
80
  return false;
@@ -88,13 +91,13 @@ class Licensing_Core {
88
  'edd_action'=> 'reset_rooturi',
89
  'license_key' => $license,
90
  'home_url' => network_home_url(),
91
- 'item_name' => urlencode( EDD_W3EDGE_W3TC_NAME ), // the name of our product in EDD
92
  'r' => rand(),
93
  'version' => $version
94
  );
95
 
96
  // Call the custom API.
97
- $response = wp_remote_get( add_query_arg( $api_params, EDD_W3EDGE_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
98
  if ( is_wp_error( $response ) )
99
  return false;
100
 
@@ -102,4 +105,18 @@ class Licensing_Core {
102
  $status = json_decode( wp_remote_retrieve_body( $response ) );
103
  return $status;
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
8
  * Activates a license
9
  */
10
  static public function activate_license( $license, $version ) {
11
+ $state = Dispatcher::config_state_master();
12
+
13
  // data to send in our API request
14
  $api_params = array(
15
  'edd_action'=> 'activate_license',
16
  'license' => $license, // legacy
17
  'license_key' => $license,
18
  'home_url' => network_home_url(),
19
+ 'item_name' => urlencode( W3TC_PURCHASE_PRODUCT_NAME ), // the name of our product in EDD
20
+ 'plugin_install_date' => gmdate( 'Y-m-d\\TH:i:s\\Z', $state->get_integer( 'common.install' ) ),
21
  'r' => rand(),
22
  'version' => $version
23
  );
24
 
25
  // Call the custom API.
26
+ $response = wp_remote_get( add_query_arg( $api_params, W3TC_LICENSE_API_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
27
  if ( is_wp_error( $response ) )
28
  return false;
29
 
42
  'license' => $license, // legacy
43
  'license_key' => $license,
44
  'home_url' => network_home_url(),
45
+ 'item_name' => urlencode( W3TC_PURCHASE_PRODUCT_NAME ), // the name of our product in EDD,
46
  'r' => rand()
47
  );
48
 
49
  // Call the custom API.
50
+ $response = wp_remote_get( add_query_arg( $api_params, W3TC_LICENSE_API_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
51
 
52
  // make sure the response came back okay
53
  if ( is_wp_error( $response ) )
71
  'license' => $license, // legacy
72
  'license_key' => $license,
73
  'home_url' => network_home_url(),
74
+ 'item_name' => urlencode( W3TC_PURCHASE_PRODUCT_NAME ),
75
  'r' => rand(),
76
  'version' => $version
77
  );
78
 
79
  // Call the custom API.
80
+ $response = wp_remote_get( add_query_arg( $api_params, W3TC_LICENSE_API_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
81
 
82
  if ( is_wp_error( $response ) )
83
  return false;
91
  'edd_action'=> 'reset_rooturi',
92
  'license_key' => $license,
93
  'home_url' => network_home_url(),
94
+ 'item_name' => urlencode( W3TC_PURCHASE_PRODUCT_NAME ), // the name of our product in EDD
95
  'r' => rand(),
96
  'version' => $version
97
  );
98
 
99
  // Call the custom API.
100
+ $response = wp_remote_get( add_query_arg( $api_params, W3TC_LICENSE_API_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
101
  if ( is_wp_error( $response ) )
102
  return false;
103
 
105
  $status = json_decode( wp_remote_retrieve_body( $response ) );
106
  return $status;
107
  }
108
+
109
+ static public function terms_accept() {
110
+ $c = Dispatcher::config();
111
+ if ( !Util_Environment::is_w3tc_pro( $c ) ) {
112
+ $state_master = Dispatcher::config_state_master();
113
+ $state_master->set( 'license.community_terms', 'accept' );
114
+ $state_master->save();
115
+
116
+ $c->set( 'common.track_usage', true );
117
+ $c->save();
118
+ } else {
119
+ // not called in this mode
120
+ }
121
+ }
122
  }
Licensing_Plugin_Admin.php CHANGED
@@ -24,24 +24,25 @@ class Licensing_Plugin_Admin {
24
  add_action( 'w3tc_message_action_licensing_upgrade',
25
  array( $this, 'w3tc_message_action_licensing_upgrade' ) );
26
 
27
- if ( !Util_Environment::is_w3tc_pro( $this->_config ) )
28
- add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) );
29
  }
30
 
31
 
32
 
33
  public function w3tc_admin_bar_menu( $menu_items ) {
34
- $menu_items['00020.licensing'] = array(
35
- 'id' => 'w3tc_overlay_upgrade',
36
- 'parent' => 'w3tc',
37
- 'title' => __(
38
- '<span style="color: red; background: none;">Upgrade Performance</span>',
39
- 'w3-total-cache'
40
- ),
41
- 'href' => wp_nonce_url( network_admin_url(
42
- 'admin.php?page=w3tc_dashboard&amp;' .
43
- 'w3tc_message_action=licensing_upgrade' ), 'w3tc' )
44
- );
 
 
45
 
46
  if ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) {
47
  $menu_items['90040.licensing'] = array(
@@ -63,13 +64,13 @@ class Licensing_Plugin_Admin {
63
 
64
  public function admin_head_licensing_upgrade() {
65
  ?>
66
- <script type="text/javascript">
67
- jQuery(function() {
68
- w3tc_lightbox_upgrade(w3tc_nonce);
69
- jQuery('#w3tc-license-instruction').show();
70
- });
71
- </script>
72
- <?php
73
  }
74
 
75
  /**
@@ -79,25 +80,33 @@ class Licensing_Plugin_Admin {
79
  * @param Config $old_config
80
  */
81
  function possible_state_change( $config, $old_config ) {
 
 
82
  if ( $old_config->get_string( 'plugin.license_key' ) !='' && $config->get_string( 'plugin.license_key' ) == '' ) {
83
  $result = Licensing_Core::deactivate_license( $old_config->get_string( 'plugin.license_key' ) );
84
  if ( $result ) {
85
  $this->site_inactivated = true;
86
  }
87
- delete_transient( 'w3tc_license_status' );
88
  } elseif ( $old_config->get_string( 'plugin.license_key' ) =='' && $config->get_string( 'plugin.license_key' ) != '' ) {
89
  $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION );
90
  if ( $result ) {
91
  $this->site_activated = true;
92
  $config->set( 'common.track_usage', true );
93
  }
94
- delete_transient( 'w3tc_license_status' );
95
  } elseif ( $old_config->get_string( 'plugin.license_key' ) != $config->get_string( 'plugin.license_key' ) ) {
96
  $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION );
97
  if ( $result ) {
98
  $this->site_activated = true;
99
  }
100
- delete_transient( 'w3tc_license_status' );
 
 
 
 
 
 
101
  }
102
  }
103
 
@@ -108,8 +117,12 @@ class Licensing_Plugin_Admin {
108
  $capability = apply_filters( 'w3tc_capability_admin_notices',
109
  'manage_options' );
110
 
 
 
111
  if ( current_user_can( $capability ) ) {
112
  if ( is_admin() && Util_Admin::is_w3tc_admin_page() ) {
 
 
113
  /**
114
  * Only admin can see W3TC notices and errors
115
  */
@@ -140,16 +153,12 @@ class Licensing_Plugin_Admin {
140
  */
141
  function admin_notices() {
142
  $message = '';
143
- $status = get_transient( 'w3tc_license_status' );
144
- $set_transient = false;
145
- if ( !$status ) {
146
- $status = $this->update_license_status();
147
- $set_transient = true;
148
- $transient_timeout = 3600 * 24 * 5;
149
- }
150
 
 
 
151
 
152
- if ( $status == 'no_key' ) {
 
153
  } elseif ( $this->_status_is( $status, 'inactive.expired' ) ) {
154
  $message = sprintf( __( 'The W3 Total Cache license key has expired. Please renew it: %s', 'w3-total-cache' ),
155
  '<input type="button" class="button-primary button-buy-plugin {nonce: \''. wp_create_nonce( 'w3tc' ).'\'}" value="'.__( 'Renew', 'w3-total-cache' ) . '" />' );
@@ -170,11 +179,6 @@ class Licensing_Plugin_Admin {
170
  } elseif ( $this->_status_is( $status, 'active' ) ) {
171
  } else {
172
  $message = __( 'The W3 Total Cache license key can\'t be verified.', 'w3-total-cache' );
173
- $transient_timeout = 60;
174
- }
175
-
176
- if ( $set_transient ) {
177
- set_transient( 'w3tc_license_status', $status, $transient_timeout );
178
  }
179
 
180
  if ( $message )
@@ -192,13 +196,75 @@ class Licensing_Plugin_Admin {
192
  }
193
  }
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  /**
196
  *
197
  *
198
  * @return string
199
  */
200
- function update_license_status() {
 
 
 
 
 
 
201
  $status = '';
 
202
  $license_key = $this->get_license_key();
203
 
204
  $old_plugin_type = $this->_config->get_string( 'plugin.type' );
@@ -209,6 +275,7 @@ class Licensing_Plugin_Admin {
209
 
210
  if ( $license ) {
211
  $status = $license->license_status;
 
212
  if ( $this->_status_is( $status, 'active' ) ) {
213
  $plugin_type = 'pro';
214
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) &&
@@ -223,6 +290,19 @@ class Licensing_Plugin_Admin {
223
  $status = 'no_key';
224
  }
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  if ( $old_plugin_type != $plugin_type ) {
227
  try {
228
  $this->_config->set( 'plugin.type', $plugin_type );
@@ -233,11 +313,8 @@ class Licensing_Plugin_Admin {
233
  return $status;
234
  }
235
 
236
- /**
237
- *
238
- *
239
- * @return string
240
- */
241
  function get_license_key() {
242
  $license_key = $this->_config->get_string( 'plugin.license_key', '' );
243
  if ( $license_key == '' )
@@ -245,6 +322,8 @@ class Licensing_Plugin_Admin {
245
  return $license_key;
246
  }
247
 
 
 
248
  function action_verify_plugin_license_key() {
249
  $license = Util_Request::get_string( 'license_key', '' );
250
 
24
  add_action( 'w3tc_message_action_licensing_upgrade',
25
  array( $this, 'w3tc_message_action_licensing_upgrade' ) );
26
 
27
+ add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) );
 
28
  }
29
 
30
 
31
 
32
  public function w3tc_admin_bar_menu( $menu_items ) {
33
+ if ( !Util_Environment::is_w3tc_pro( $this->_config ) ) {
34
+ $menu_items['00020.licensing'] = array(
35
+ 'id' => 'w3tc_overlay_upgrade',
36
+ 'parent' => 'w3tc',
37
+ 'title' => __(
38
+ '<span style="color: red; background: none;">Upgrade Performance</span>',
39
+ 'w3-total-cache'
40
+ ),
41
+ 'href' => wp_nonce_url( network_admin_url(
42
+ 'admin.php?page=w3tc_dashboard&amp;' .
43
+ 'w3tc_message_action=licensing_upgrade' ), 'w3tc' )
44
+ );
45
+ }
46
 
47
  if ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) {
48
  $menu_items['90040.licensing'] = array(
64
 
65
  public function admin_head_licensing_upgrade() {
66
  ?>
67
+ <script type="text/javascript">
68
+ jQuery(function() {
69
+ w3tc_lightbox_upgrade(w3tc_nonce);
70
+ jQuery('#w3tc-license-instruction').show();
71
+ });
72
+ </script>
73
+ <?php
74
  }
75
 
76
  /**
80
  * @param Config $old_config
81
  */
82
  function possible_state_change( $config, $old_config ) {
83
+ $changed = false;
84
+
85
  if ( $old_config->get_string( 'plugin.license_key' ) !='' && $config->get_string( 'plugin.license_key' ) == '' ) {
86
  $result = Licensing_Core::deactivate_license( $old_config->get_string( 'plugin.license_key' ) );
87
  if ( $result ) {
88
  $this->site_inactivated = true;
89
  }
90
+ $changed = true;
91
  } elseif ( $old_config->get_string( 'plugin.license_key' ) =='' && $config->get_string( 'plugin.license_key' ) != '' ) {
92
  $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION );
93
  if ( $result ) {
94
  $this->site_activated = true;
95
  $config->set( 'common.track_usage', true );
96
  }
97
+ $changed = true;
98
  } elseif ( $old_config->get_string( 'plugin.license_key' ) != $config->get_string( 'plugin.license_key' ) ) {
99
  $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION );
100
  if ( $result ) {
101
  $this->site_activated = true;
102
  }
103
+ $changed = true;
104
+ }
105
+
106
+ if ( $changed ) {
107
+ $state = Dispatcher::config_state();
108
+ $state->set( 'license.next_check', 0 );
109
+ $state->save();
110
  }
111
  }
112
 
117
  $capability = apply_filters( 'w3tc_capability_admin_notices',
118
  'manage_options' );
119
 
120
+ $this->maybe_update_license_status();
121
+
122
  if ( current_user_can( $capability ) ) {
123
  if ( is_admin() && Util_Admin::is_w3tc_admin_page() ) {
124
+ add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
125
+
126
  /**
127
  * Only admin can see W3TC notices and errors
128
  */
153
  */
154
  function admin_notices() {
155
  $message = '';
 
 
 
 
 
 
 
156
 
157
+ $state = Dispatcher::config_state();
158
+ $status = $state->get_string( 'license.status' );
159
 
160
+ if ( defined( 'W3TC_PRO' ) ) {
161
+ } elseif ( $status == 'no_key' ) {
162
  } elseif ( $this->_status_is( $status, 'inactive.expired' ) ) {
163
  $message = sprintf( __( 'The W3 Total Cache license key has expired. Please renew it: %s', 'w3-total-cache' ),
164
  '<input type="button" class="button-primary button-buy-plugin {nonce: \''. wp_create_nonce( 'w3tc' ).'\'}" value="'.__( 'Renew', 'w3-total-cache' ) . '" />' );
179
  } elseif ( $this->_status_is( $status, 'active' ) ) {
180
  } else {
181
  $message = __( 'The W3 Total Cache license key can\'t be verified.', 'w3-total-cache' );
 
 
 
 
 
182
  }
183
 
184
  if ( $message )
196
  }
197
  }
198
 
199
+
200
+
201
+ function w3tc_notes( $notes ) {
202
+ $terms = '';
203
+ $state_master = Dispatcher::config_state_master();
204
+
205
+ if ( defined( 'W3TC_PRO' ) ) {
206
+ $terms = 'accept';
207
+ } elseif ( !Util_Environment::is_w3tc_pro( $this->_config ) ) {
208
+ $terms = $state_master->get_string( 'license.community_terms' );
209
+
210
+ $buttons = sprintf( '<br /><br />%s&nbsp;%s',
211
+ Util_Ui::button_link( __( 'Accept', 'w3-total-cache' ),
212
+ Util_Ui::url( array(
213
+ 'w3tc_licensing_terms_accept' => 'y' ) ) ),
214
+ Util_Ui::button_link( __( 'Decline', 'w3-total-cache' ),
215
+ Util_Ui::url( array(
216
+ 'w3tc_licensing_terms_decline' => 'y' ) ) ) );
217
+ } else {
218
+ $state = Dispatcher::config_state();
219
+ $terms = $state->get_string( 'license.terms' );
220
+
221
+ $return_url = self_admin_url( Util_Ui::url( array(
222
+ 'w3tc_licensing_terms_refresh' => 'y' ) ) );
223
+
224
+ $buttons =
225
+ sprintf( '<form method="post" action="%s">', W3TC_TERMS_ACCEPT_URL ) .
226
+ Util_Ui::r_hidden( 'return_url', 'return_url', $return_url ) .
227
+ Util_Ui::r_hidden( 'license_key', 'license_key', $this->get_license_key() ) .
228
+ Util_Ui::r_hidden( 'home_url', 'home_url', home_url() ) .
229
+ '<input type="submit" class="button" name="answer" value="Accept" />&nbsp;' .
230
+ '<input type="submit" class="button" name="answer" value="Decline" />' .
231
+ '</form>';
232
+ }
233
+
234
+ if ( $terms != 'accept' && $terms != 'decline' && $terms != 'postpone' ) {
235
+ if ( $state_master->get_integer( 'common.install' ) < 1542029724 ) {
236
+ /* installed before 2018-11-12 */
237
+ $notes['licensing_terms'] = sprintf(
238
+ __( 'Our terms of use and privacy policies have been updated. Please <a href="%s" target="blank">review</a> and accept them.', 'w3-total-cache' ),
239
+ W3TC_TERMS_URL ) .
240
+ $buttons;
241
+ } else {
242
+ $notes['licensing_terms'] = sprintf(
243
+ __( 'Thanks for using W3 Total Cache! Please review the latest <a href="%s" target="blank">terms of use and privacy policy</a>, and accept them.', 'w3-total-cache' ),
244
+ W3TC_TERMS_URL ) .
245
+ $buttons;
246
+ }
247
+ }
248
+
249
+ return $notes;
250
+ }
251
+
252
+
253
+
254
  /**
255
  *
256
  *
257
  * @return string
258
  */
259
+ private function maybe_update_license_status() {
260
+ $state = Dispatcher::config_state();
261
+ if ( time() < $state->get_integer( 'license.next_check' ) ) {
262
+ return;
263
+ }
264
+
265
+ $check_timeout = 3600 * 24 * 5;
266
  $status = '';
267
+ $terms = '';
268
  $license_key = $this->get_license_key();
269
 
270
  $old_plugin_type = $this->_config->get_string( 'plugin.type' );
275
 
276
  if ( $license ) {
277
  $status = $license->license_status;
278
+ $terms = $license->license_terms;
279
  if ( $this->_status_is( $status, 'active' ) ) {
280
  $plugin_type = 'pro';
281
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) &&
290
  $status = 'no_key';
291
  }
292
 
293
+ if ( $status == 'no_key' ) {
294
+ } elseif ( $this->_status_is( $status, 'invalid' ) ) {
295
+ } elseif ( $this->_status_is( $status, 'inactive' ) ) {
296
+ } elseif ( $this->_status_is( $status, 'active' ) ) {
297
+ } else {
298
+ $check_timeout = 60;
299
+ }
300
+
301
+ $state->set( 'license.status', $status );
302
+ $state->set( 'license.next_check', time() + $check_timeout );
303
+ $state->set( 'license.terms', $terms );
304
+ $state->save();
305
+
306
  if ( $old_plugin_type != $plugin_type ) {
307
  try {
308
  $this->_config->set( 'plugin.type', $plugin_type );
313
  return $status;
314
  }
315
 
316
+
317
+
 
 
 
318
  function get_license_key() {
319
  $license_key = $this->_config->get_string( 'plugin.license_key', '' );
320
  if ( $license_key == '' )
322
  return $license_key;
323
  }
324
 
325
+
326
+
327
  function action_verify_plugin_license_key() {
328
  $license = Util_Request::get_string( 'license_key', '' );
329
 
Minify_AutoCss.php ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ class Minify_AutoCss {
5
+ private $config;
6
+ private $buffer;
7
+
8
+ /**
9
+ * CSS files to ignore
10
+ *
11
+ * @var array
12
+ */
13
+ private $ignore_css_files;
14
+
15
+ /**
16
+ * Helper object to use
17
+ *
18
+ * @var _W3_MinifyHelpers
19
+ */
20
+ private $minify_helpers;
21
+
22
+ /**
23
+ * Array of processed styles
24
+ *
25
+ * @var array
26
+ */
27
+ private $debug_minified_urls = array();
28
+
29
+ /**
30
+ * Current position to embed minified style
31
+ *
32
+ * @var integer
33
+ */
34
+ private $embed_pos;
35
+
36
+ /**
37
+ * Current list of files to minify
38
+ *
39
+ * @var array
40
+ */
41
+ private $files_to_minify;
42
+
43
+ /**
44
+ * Current number of minification group
45
+ *
46
+ * @var integer
47
+ */
48
+ private $debug = false;
49
+ private $embed_to_html;
50
+
51
+ /**
52
+ * Constructor
53
+ *
54
+ * @param unknown $config
55
+ * @param unknown $buffer
56
+ * @param unknown $minify_helpers
57
+ */
58
+ function __construct( $config, $buffer, $minify_helpers ) {
59
+ $this->config = $config;
60
+ $this->debug = $config->get_boolean( 'minify.debug' );
61
+ $this->buffer = $buffer;
62
+ $this->minify_helpers = $minify_helpers;
63
+
64
+ // ignored files
65
+ $this->ignore_css_files = $this->config->get_array(
66
+ 'minify.reject.files.css' );
67
+ $this->ignore_css_files = array_map( array( '\W3TC\Util_Environment',
68
+ 'normalize_file' ), $this->ignore_css_files );
69
+
70
+ $this->embed_to_html = $this->config->get_boolean( 'minify.css.embed' );
71
+ }
72
+
73
+ /**
74
+ * Does auto-minification
75
+ *
76
+ * @return string buffer of minified content
77
+ */
78
+ public function execute() {
79
+ // find all style tags
80
+ $buffer_nocomments = preg_replace( '~<!--.*?-->\s*~s', '', $this->buffer );
81
+ $matches = null;
82
+
83
+ // end of <head> means another group of styles, cannt be combined
84
+ if ( !preg_match_all( '~((<style\s*[^>]*>.*?</style>)|(<link\s+([^>]+)/?>(.*</link>)?))~is',
85
+ $buffer_nocomments, $matches ) ) {
86
+ $matches = null;
87
+ }
88
+
89
+ if ( is_null( $matches ) ) {
90
+ return $this->buffer;
91
+ }
92
+
93
+ $style_tags = $matches[1];
94
+ $style_tags = apply_filters( 'w3tc_minify_css_style_tags',
95
+ $style_tags );
96
+
97
+ // pass styles
98
+ $this->embed_pos = null;
99
+ $this->files_to_minify = array();
100
+
101
+ for ( $n = 0; $n < count( $style_tags ); $n++ ) {
102
+ $this->process_style_tag( $style_tags[$n], $n );
103
+ }
104
+
105
+ $this->flush_collected( '' );
106
+
107
+ return $this->buffer;
108
+ }
109
+
110
+ /**
111
+ * Returns list of minified styles
112
+ *
113
+ * @return array
114
+ */
115
+ public function get_debug_minified_urls() {
116
+ return $this->debug_minified_urls;
117
+ }
118
+
119
+ /**
120
+ * Processes style tag
121
+ *
122
+ * @param unknown $style_tag
123
+ * @return void
124
+ */
125
+ private function process_style_tag( $style_tag, $style_tag_number ) {
126
+ if ( $this->debug ) {
127
+ Minify_Core::log( 'processing tag ' . substr( $style_tag, 0, 150 ) );
128
+ }
129
+
130
+ $tag_pos = strpos( $this->buffer, $style_tag );
131
+ if ( $tag_pos === false ) {
132
+ // style is external but not found, skip processing it
133
+ if ( $this->debug ) {
134
+ Minify_Core::log( 'style not found:' . $style_tag );
135
+ }
136
+ return;
137
+ }
138
+
139
+ $style_href = null;
140
+ $causes_flush = true;
141
+ if ( preg_match( '~<link\s+([^>]+)/?>(.*</link>)?~Uis', $style_tag, $match ) ) {
142
+ // all link tags dont cause automatic flush since
143
+ // its minified or its not style <link> tag
144
+ $causes_flush = false;
145
+
146
+ $attrs = array();
147
+ $attr_matches = null;
148
+ if ( preg_match_all( '~(\w+)=["\']([^"\']*)["\']~', $match[1],
149
+ $attr_matches, PREG_SET_ORDER ) ) {
150
+ foreach ( $attr_matches as $attr_match ) {
151
+ $name = strtolower( $attr_match[1] );
152
+ $attrs[$name] = trim( $attr_match[2] );
153
+ }
154
+ }
155
+
156
+ if ( isset( $attrs['href'] ) && isset( $attrs['rel'] ) &&
157
+ stristr( $attrs['rel'], 'stylesheet' ) !== false &&
158
+ ( !isset( $attrs['media'] ) || stristr( $attrs['media'], 'print' ) === false ) ) {
159
+ $style_href = $attrs['href'];
160
+ }
161
+ }
162
+
163
+ if ( $causes_flush ) {
164
+ $data = array(
165
+ 'style_tag_original' => $style_tag,
166
+ 'style_tag_new' => $style_tag,
167
+ 'style_tag_number' => $style_tag_number,
168
+ 'style_tag_pos' => $tag_pos,
169
+ 'should_replace' => false,
170
+ 'buffer' => $this->buffer
171
+ );
172
+
173
+ $data = apply_filters( 'w3tc_minify_css_do_local_style_minification',
174
+ $data );
175
+ $this->buffer = $data['buffer'];
176
+
177
+ if ( $data['should_replace'] ) {
178
+ $this->buffer = substr_replace( $this->buffer,
179
+ $data['style_tag_new'], $tag_pos,
180
+ strlen( $style_tag ) );
181
+ }
182
+
183
+ // it's not external style, have to flush what we have before it
184
+ if ( $this->debug ) {
185
+ Minify_Core::log( 'its not link tag, flushing' );
186
+ }
187
+
188
+ $this->flush_collected( $style_tag );
189
+
190
+ return;
191
+ }
192
+ if ( empty( $style_href ) ) {
193
+ if ( $this->debug ) {
194
+ Minify_Core::log( 'its not style link tag' );
195
+ }
196
+ return;
197
+ }
198
+
199
+ $style_href = Util_Environment::url_relative_to_full( $style_href );
200
+ $file = Util_Environment::url_to_docroot_filename( $style_href );
201
+
202
+ $step1_result = $this->minify_helpers->is_file_for_minification(
203
+ $style_href, $file );
204
+ if ( $step1_result == 'url' )
205
+ $file = $style_href;
206
+
207
+ $step1 = !empty( $step1_result );
208
+ $step2 = !in_array( $file, $this->ignore_css_files );
209
+
210
+ $do_tag_minification = $step1 && $step2;
211
+ $do_tag_minification = apply_filters(
212
+ 'w3tc_minify_css_do_tag_minification',
213
+ $do_tag_minification, $style_tag, $file );
214
+
215
+ if ( !$do_tag_minification ) {
216
+ if ( $this->debug ) {
217
+ Minify_Core::log( 'file ' . $file .
218
+ ' didnt pass minification check:' .
219
+ ' file_for_min: ' . ( $step1 ? 'true' : 'false' ) .
220
+ ' ignore_css_files: ' . ( $step2 ? 'true' : 'false' ) );
221
+ }
222
+
223
+ $data = array(
224
+ 'style_tag_original' => $style_tag,
225
+ 'style_tag_new' => $style_tag,
226
+ 'style_tag_number' => $style_tag_number,
227
+ 'style_tag_pos' => $tag_pos,
228
+ 'style_href' => $style_href,
229
+ 'should_replace' => false,
230
+ 'buffer' => $this->buffer
231
+ );
232
+
233
+ $data = apply_filters( 'w3tc_minify_css_do_excluded_tag_style_minification',
234
+ $data );
235
+ $this->buffer = $data['buffer'];
236
+
237
+ if ( $data['should_replace'] ) {
238
+ $this->buffer = substr_replace( $this->buffer,
239
+ $data['style_tag_new'], $tag_pos,
240
+ strlen( $style_tag ) );
241
+ }
242
+
243
+ $this->flush_collected( $style_tag );
244
+ return;
245
+ }
246
+
247
+ $this->debug_minified_urls[] = $file;
248
+ $this->buffer = substr_replace( $this->buffer, '',
249
+ $tag_pos, strlen( $style_tag ) );
250
+
251
+ // put minified file at the place of first tag
252
+ if ( count( $this->files_to_minify ) <= 0 )
253
+ $this->embed_pos = $tag_pos;
254
+ $this->files_to_minify[] = $file;
255
+ }
256
+
257
+ /**
258
+ * Minifies collected styles
259
+ */
260
+ private function flush_collected( $last_style_tag ) {
261
+ if ( count( $this->files_to_minify ) <= 0 )
262
+ return;
263
+ $do_flush_collected = apply_filters( 'w3tc_minify_css_do_flush_collected',
264
+ true, $last_style_tag, $this );
265
+ if ( !$do_flush_collected )
266
+ return;
267
+
268
+ // find embed position
269
+ $embed_pos = $this->embed_pos;
270
+
271
+ // build minified style tag
272
+ $data = array(
273
+ 'files_to_minify' => $this->files_to_minify,
274
+ 'embed_pos' => $embed_pos,
275
+ 'buffer' => $this->buffer,
276
+ 'embed_to_html' => $this->embed_to_html
277
+ );
278
+
279
+ $data = apply_filters( 'w3tc_minify_css_step', $data );
280
+ $this->buffer = $data['buffer'];
281
+
282
+ if ( !empty( $data['files_to_minify'] ) ) {
283
+ $style_data = $this->minify_helpers->generate_css_style_tag(
284
+ $data['files_to_minify'],
285
+ $data['embed_to_html'] );
286
+
287
+ $data['style_to_embed_url'] = $style_data['url'];
288
+ $data['style_to_embed_body'] = $style_data['body'];
289
+ $data = apply_filters( 'w3tc_minify_css_step_style_to_embed',
290
+ $data );
291
+ $this->buffer = $data['buffer'];
292
+
293
+ if ( $this->config->get_boolean( 'minify.css.http2push' ) ) {
294
+ $this->minify_helpers->http2_header_add(
295
+ $data['style_to_embed_url'], 'style' );
296
+ }
297
+
298
+ // replace
299
+ $this->buffer = substr_replace( $this->buffer,
300
+ $data['style_to_embed_body'], $data['embed_pos'], 0 );
301
+ }
302
+
303
+ $this->files_to_minify = array();
304
+ }
305
+ }
Minify_AutoJs.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace W3TC;
3
+
4
+ class Minify_AutoJs {
5
+ /**
6
+ * Config
7
+ */
8
+ private $config;
9
+
10
+ /**
11
+ * Processed buffer
12
+ *
13
+ * @var string
14
+ */
15
+ private $buffer;
16
+
17
+ /**
18
+ * JS files to ignore
19
+ *
20
+ * @var array
21
+ */
22
+ private $ignore_js_files;
23
+
24
+ /**
25
+ * Embed type
26
+ *
27
+ * @var string
28
+ */
29
+ private $embed_type;
30
+
31
+ /**
32
+ * Helper object to use
33
+ *
34
+ * @var _W3_MinifyHelpers
35
+ */
36
+ private $minify_helpers;
37
+
38
+ /**
39
+ * Array of processed scripts
40
+ *
41
+ * @var array
42
+ */
43
+ private $debug_minified_urls = array();
44
+
45
+ /**
46
+ * Current position to embed minified script
47
+ *
48
+ * @var integer
49
+ */
50
+ private $embed_pos;
51
+
52
+ /**
53
+ * Current list of files to minify
54
+ *
55
+ * @var array
56
+ */
57
+ private $files_to_minify;
58
+
59
+ /**
60
+ * Current group type
61
+ *
62
+ * @var string
63
+ */
64
+ private $group_type = 'head';
65
+
66
+ /**
67
+ * Current number of minification group
68
+ *
69
+ * @var integer
70
+ */
71
+ private $minify_group_number = 0;
72
+ private $debug = false;
73
+
74
+ /**
75
+ * Constructor
76
+ *
77
+ * @param unknown $config
78
+ * @param unknown $buffer
79
+ * @param unknown $minify_helpers
80
+ */
81
+ function __construct( $config, $buffer, $minify_helpers ) {
82
+ $this->config = $config;
83
+ $this->debug = $config->get_boolean( 'minify.debug' );
84
+ $this->buffer = $buffer;
85
+ $this->minify_helpers = $minify_helpers;
86
+
87
+ // ignored files
88
+ $this->ignore_js_files = $this->config->get_array( 'minify.reject.files.js' );
89
+ $this->ignore_js_files = array_map( array( '\W3TC\Util_Environment', 'normalize_file' ), $this->ignore_js_files );
90
+
91
+ // define embed type
92
+ $this->embed_type = array(
93
+ 'head' => $this->config->get_string( 'minify.js.header.embed_type' ),
94
+ 'body' => $this->config->get_string( 'minify.js.body.embed_type' )
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Does auto-minification
100
+ *
101
+ * @return string buffer of minified content
102
+ */
103
+ public function execute() {
104
+ // find all script tags
105
+ $buffer_nocomments = preg_replace( '~<!--.*?-->\s*~s', '', $this->buffer );
106
+ $matches = null;
107
+
108
+ // end of <head> means another group of scripts, cannt be combined
109
+ if ( !preg_match_all( '~(<script\s*[^>]*>.*?</script>|</head>)~is',
110
+ $buffer_nocomments, $matches ) ) {
111
+ $matches = null;
112
+ }
113
+
114
+ if ( is_null( $matches ) ) {
115
+ return $this->buffer;
116
+ }
117
+
118
+ $script_tags = $matches[1];
119
+ $script_tags = apply_filters( 'w3tc_minify_js_script_tags',
120
+ $script_tags );
121
+
122
+ // pass scripts
123
+ $this->embed_pos = null;
124
+ $this->files_to_minify = array();
125
+
126
+ for ( $n = 0; $n < count( $script_tags ); $n++ ) {
127
+ $this->process_script_tag( $script_tags[$n], $n );
128
+ }
129
+
130
+ $this->flush_collected( '' );
131
+
132
+ return $this->buffer;
133
+ }
134
+
135
+ /**
136
+ * Returns list of minified scripts
137
+ *
138
+ * @return array
139
+ */
140
+ public function get_debug_minified_urls() {
141
+ return $this->debug_minified_urls;
142
+ }
143
+
144
+ /**
145
+ * Processes script tag
146
+ *
147
+ * @param unknown $script_tag
148
+ * @return void
149
+ */
150
+ private function process_script_tag( $script_tag, $script_tag_number ) {
151
+ if ( $this->debug ) {
152
+ Minify_Core::log( 'processing tag ' . substr( $script_tag, 0, 150 ) );
153
+ }
154
+
155
+ $tag_pos = strpos( $this->buffer, $script_tag );
156
+ if ( $tag_pos === false ) {
157
+ // script is external but not found, skip processing it
158
+ if ( $this->debug ) {
159
+ Minify_Core::log( 'script not found:' . $script_tag );
160
+ }
161
+ return;
162
+ }
163
+
164
+ $match = null;
165
+ if ( !preg_match( '~<script\s+[^<>]*src=["\']?([^"\'> ]+)["\'> ]~is',
166
+ $script_tag, $match ) ) {
167
+ $match = null;
168
+ }
169
+ if ( is_null( $match ) ) {
170
+ $data = array(
171
+ 'script_tag_original' => $script_tag,
172
+ 'script_tag_new' => $script_tag,
173
+ 'script_tag_number' => $script_tag_number,
174
+ 'script_tag_pos' => $tag_pos,
175
+ 'should_replace' => false,
176
+ 'buffer' => $this->buffer
177
+ );
178
+
179
+ $data = apply_filters( 'w3tc_minify_js_do_local_script_minification',
180
+ $data );
181
+ $this->buffer = $data['buffer'];
182
+
183
+ if ( $data['should_replace'] ) {
184
+ $this->buffer = substr_replace( $this->buffer,
185
+ $data['script_tag_new'], $tag_pos,
186
+ strlen( $script_tag ) );
187
+ }
188
+
189
+ // it's not external script, have to flush what we have before it
190
+ if ( $this->debug ) {
191
+ Minify_Core::log( 'its not src=, flushing' );
192
+ }
193
+
194
+ $this->flush_collected( $script_tag );
195
+
196
+ if ( preg_match( '~</head>~is', $script_tag, $match ) )
197
+ $this->group_type = 'body';
198
+
199
+ return;
200
+ }
201
+
202
+ $script_src = $match[1];
203
+ $script_src = Util_Environment::url_relative_to_full( $script_src );
204
+ $file = Util_Environment::url_to_docroot_filename( $script_src );
205
+
206
+ $step1_result = $this->minify_helpers->is_file_for_minification(
207
+ $script_src, $file );
208
+ if ( $step1_result == 'url' )
209
+ $file = $script_src;
210
+
211
+ $step1 = !empty( $step1_result );
212
+ $step2 = !in_array( $file, $this->ignore_js_files );
213
+
214
+ $do_tag_minification = $step1 && $step2;
215
+ $do_tag_minification = apply_filters( 'w3tc_minify_js_do_tag_minification',
216
+ $do_tag_minification, $script_tag, $file );
217
+
218
+ if ( !$do_tag_minification ) {
219
+ if ( $this->debug ) {
220
+ Minify_Core::log( 'file ' . $file .
221
+ ' didnt pass minification check:' .
222
+ ' file_for_min: ' . ( $step1 ? 'true' : 'false' ) .
223
+ ' ignore_js_files: ' . ( $step2 ? 'true' : 'false' ) );
224
+ }
225
+
226
+ $data = array(
227
+ 'script_tag_original' => $script_tag,
228
+ 'script_tag_new' => $script_tag,
229
+ 'script_tag_number' => $script_tag_number,
230
+ 'script_tag_pos' => $tag_pos,
231
+ 'script_src' => $script_src,
232
+ 'should_replace' => false,
233
+ 'buffer' => $this->buffer
234
+ );
235
+
236
+ $data = apply_filters( 'w3tc_minify_js_do_excluded_tag_script_minification',
237
+ $data );
238
+ $this->buffer = $data['buffer'];
239
+
240
+ if ( $data['should_replace'] ) {
241
+ $this->buffer = substr_replace( $this->buffer,
242
+ $data['script_tag_new'], $tag_pos,
243
+ strlen( $script_tag ) );
244
+ }
245
+
246
+ $this->flush_collected( $script_tag );
247
+ return;
248
+ }
249
+
250
+ $this->debug_minified_urls[] = $file;
251
+ $this->buffer = substr_replace( $this->buffer, '',
252
+ $tag_pos, strlen( $script_tag ) );
253
+
254
+ // for head group - put minified file at the place of first script
255
+ // for body - put at the place of last script, to make as more DOM
256
+ // objects available as possible
257
+ if ( count( $this->files_to_minify ) <= 0 || $this->group_type == 'body' )
258
+ $this->embed_pos = $tag_pos;
259
+ $this->files_to_minify[] = $file;
260
+ }
261
+
262
+ /**
263
+ * Minifies collected scripts
264
+ */
265
+ private function flush_collected( $last_script_tag ) {
266
+ if ( count( $this->files_to_minify ) <= 0 )
267
+ return;
268
+ $do_flush_collected = apply_filters( 'w3tc_minify_js_do_flush_collected',
269
+ true, $last_script_tag, $this );
270
+ if ( !$do_flush_collected )
271
+ return;
272
+
273
+ // find embed position
274
+ $embed_pos = $this->embed_pos;
275
+
276
+ // build minified script tag
277
+ $data = array(
278
+ 'files_to_minify' => $this->files_to_minify,
279
+ 'embed_pos' => $embed_pos,
280
+ 'embed_type' => $this->embed_type[$this->group_type],
281
+ 'buffer' => $this->buffer
282
+ );
283
+
284
+ $data = apply_filters( 'w3tc_minify_js_step', $data );
285
+ $this->buffer = $data['buffer'];
286
+
287
+ if ( !empty( $data['files_to_minify'] ) ) {
288
+ $url = $this->minify_helpers->get_minify_url_for_files(
289
+ $data['files_to_minify'], 'js' );
290
+
291
+ $script = '';
292
+ if ( !is_null( $url ) ) {
293
+ $script .= $this->minify_helpers->generate_script_tag( $url,
294
+ $data['embed_type'] );
295
+ }
296
+
297
+ $data['script_to_embed_url'] = $url;
298
+ $data['script_to_embed_body'] = $script;
299
+ $data = apply_filters( 'w3tc_minify_js_step_script_to_embed',
300
+ $data );
301
+ $this->buffer = $data['buffer'];
302
+
303
+ if ( $this->config->get_boolean( 'minify.js.http2push' ) ) {
304
+ $this->minify_helpers->http2_header_add(
305
+ $data['script_to_embed_url'], 'script' );
306
+ }
307
+
308
+ // replace
309
+ $this->buffer = substr_replace( $this->buffer,
310
+ $data['script_to_embed_body'], $data['embed_pos'], 0 );
311
+ }
312
+
313
+ $this->files_to_minify = array();
314
+ $this->minify_group_number++;
315
+ }
316
+ }
Minify_Environment.php CHANGED
@@ -377,6 +377,9 @@ class Minify_Environment {
377
 
378
  $engine = $config->get_string( 'minify.engine' );
379
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
 
 
 
380
  $compression = ( $browsercache &&
381
  $config->get_boolean( 'browsercache.cssjs.compression' ) &&
382
  !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) );
@@ -388,12 +391,19 @@ class Minify_Environment {
388
  $rules .= " RewriteBase " . $cache_uri . "\n";
389
 
390
  if ( $engine == 'file' ) {
 
 
 
 
 
 
391
  if ( $compression ) {
392
  $rules .= " RewriteCond %{HTTP:Accept-Encoding} gzip\n";
393
  $rules .= " RewriteRule .* - [E=APPEND_EXT:_gzip]\n";
394
  $rules .= " RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -" . ( $config->get_boolean( 'minify.file.nfs' ) ? 'F' : 'f' ) . "\n";
395
  $rules .= " RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]\n";
396
- } else {
 
397
  $rules .= " RewriteCond %{REQUEST_FILENAME} !-f\n";
398
  }
399
  }
@@ -433,6 +443,9 @@ class Minify_Environment {
433
 
434
  $engine = $config->get_string( 'minify.engine' );
435
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
 
 
 
436
  $compression = ( $browsercache &&
437
  $config->get_boolean( 'browsercache.cssjs.compression' ) &&
438
  !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) );
@@ -443,6 +456,12 @@ class Minify_Environment {
443
  if ( $engine == 'file' ) {
444
  $rules .= "set \$w3tc_enc \"\";\n";
445
 
 
 
 
 
 
 
446
  if ( $compression ) {
447
  $rules .= "if (\$http_accept_encoding ~ gzip) {\n";
448
  $rules .= " set \$w3tc_enc _gzip;\n";
@@ -535,6 +554,7 @@ class Minify_Environment {
535
  */
536
  private function rules_cache_generate_apache( $config ) {
537
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
 
538
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.compression' ) );
539
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.expires' ) );
540
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.cssjs.lifetime' ) : 0 );
@@ -554,6 +574,21 @@ class Minify_Environment {
554
  $rules .= "FileETag MTime Size\n";
555
  }
556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
  if ( $compression ) {
558
  $rules .= "<IfModule mod_mime.c>\n";
559
  $rules .= " AddType text/css .css_gzip\n";
@@ -577,7 +612,7 @@ class Minify_Environment {
577
  $rules .= "</IfModule>\n";
578
  }
579
 
580
- if ( $w3tc || $compression || $cache_control ) {
581
  $rules .= "<IfModule mod_headers.c>\n";
582
 
583
  if ( $w3tc ) {
@@ -585,7 +620,7 @@ class Minify_Environment {
585
  Util_Environment::w3tc_header() . "\"\n";
586
  }
587
 
588
- if ( $compression ) {
589
  $rules .= " Header set Vary \"Accept-Encoding\"\n";
590
  }
591
 
@@ -654,6 +689,7 @@ class Minify_Environment {
654
  Util_Environment::filename_to_url( W3TC_CACHE_MINIFY_DIR ) ) . '/';
655
 
656
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
 
657
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.compression' ) );
658
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.expires' ) );
659
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.cssjs.lifetime' ) : 0 );
@@ -674,7 +710,7 @@ class Minify_Environment {
674
  Util_Environment::w3tc_header() . "\";\n";
675
  }
676
 
677
- if ( $compression ) {
678
  $common_rules .= " add_header Vary \"Accept-Encoding\";\n";
679
  }
680
 
@@ -689,7 +725,12 @@ class Minify_Environment {
689
 
690
  case 'cache_public_maxage':
691
  $common_rules .= " add_header Pragma \"public\";\n";
692
- $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
 
 
 
 
 
693
  break;
694
 
695
  case 'cache_validation':
@@ -704,7 +745,12 @@ class Minify_Environment {
704
 
705
  case 'cache_maxage':
706
  $common_rules .= " add_header Pragma \"public\";\n";
707
- $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
 
 
 
 
 
708
  break;
709
 
710
  case 'no_cache':
@@ -726,6 +772,24 @@ class Minify_Environment {
726
  $rules .= $common_rules;
727
  $rules .= "}\n";
728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
729
  if ( $compression ) {
730
  $rules .= "location ~ " . $cache_uri . ".*js_gzip$ {\n";
731
  $rules .= " gzip off;\n";
377
 
378
  $engine = $config->get_string( 'minify.engine' );
379
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
380
+ $brotli = ( $browsercache &&
381
+ $config->get_boolean( 'browsercache.cssjs.brotli' ) &&
382
+ !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) );
383
  $compression = ( $browsercache &&
384
  $config->get_boolean( 'browsercache.cssjs.compression' ) &&
385
  !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) );
391
  $rules .= " RewriteBase " . $cache_uri . "\n";
392
 
393
  if ( $engine == 'file' ) {
394
+ if ( $brotli ) {
395
+ $rules .= " RewriteCond %{HTTP:Accept-Encoding} br\n";
396
+ $rules .= " RewriteRule .* - [E=APPEND_EXT:_br]\n";
397
+ $rules .= " RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -" . ( $config->get_boolean( 'minify.file.nfs' ) ? 'F' : 'f' ) . "\n";
398
+ $rules .= " RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]\n";
399
+ }
400
  if ( $compression ) {
401
  $rules .= " RewriteCond %{HTTP:Accept-Encoding} gzip\n";
402
  $rules .= " RewriteRule .* - [E=APPEND_EXT:_gzip]\n";
403
  $rules .= " RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -" . ( $config->get_boolean( 'minify.file.nfs' ) ? 'F' : 'f' ) . "\n";
404
  $rules .= " RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]\n";
405
+ }
406
+ if ( !$brotli && !$compression ) {
407
  $rules .= " RewriteCond %{REQUEST_FILENAME} !-f\n";
408
  }
409
  }
443
 
444
  $engine = $config->get_string( 'minify.engine' );
445
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
446
+ $brotli = ( $browsercache &&
447
+ $config->get_boolean( 'browsercache.cssjs.brotli' ) &&
448
+ !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) );
449
  $compression = ( $browsercache &&
450
  $config->get_boolean( 'browsercache.cssjs.compression' ) &&
451
  !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) );
456
  if ( $engine == 'file' ) {
457
  $rules .= "set \$w3tc_enc \"\";\n";
458
 
459
+ if ( $brotli ) {
460
+ $rules .= "if (\$http_accept_encoding ~ br) {\n";
461
+ $rules .= " set \$w3tc_enc _br;\n";
462
+ $rules .= "}\n";
463
+ }
464
+
465
  if ( $compression ) {
466
  $rules .= "if (\$http_accept_encoding ~ gzip) {\n";
467
  $rules .= " set \$w3tc_enc _gzip;\n";
554
  */
555
  private function rules_cache_generate_apache( $config ) {
556
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
557
+ $brotli = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.brotli' ) );
558
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.compression' ) );
559
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.expires' ) );
560
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.cssjs.lifetime' ) : 0 );
574
  $rules .= "FileETag MTime Size\n";
575
  }
576
 
577
+ if ( $brotli ) {
578
+ $rules .= "<IfModule mod_mime.c>\n";
579
+ $rules .= " AddType text/css .css_br\n";
580
+ $rules .= " AddEncoding br .css_br\n";
581
+ $rules .= " AddType application/x-javascript .js_br\n";
582
+ $rules .= " AddEncoding br .js_br\n";
583
+ $rules .= "</IfModule>\n";
584
+ $rules .= "<IfModule mod_deflate.c>\n";
585
+ $rules .= " <IfModule mod_setenvif.c>\n";
586
+ $rules .= " SetEnvIfNoCase Request_URI \\.css_br$ no-brotli\n";
587
+ $rules .= " SetEnvIfNoCase Request_URI \\.js_br$ no-brotli\n";
588
+ $rules .= " </IfModule>\n";
589
+ $rules .= "</IfModule>\n";
590
+ }
591
+
592
  if ( $compression ) {
593
  $rules .= "<IfModule mod_mime.c>\n";
594
  $rules .= " AddType text/css .css_gzip\n";
612
  $rules .= "</IfModule>\n";
613
  }
614
 
615
+ if ( $w3tc || $brotli || $compression || $cache_control ) {
616
  $rules .= "<IfModule mod_headers.c>\n";
617
 
618
  if ( $w3tc ) {
620
  Util_Environment::w3tc_header() . "\"\n";
621
  }
622
 
623
+ if ( $brotli || $compression ) {
624
  $rules .= " Header set Vary \"Accept-Encoding\"\n";
625
  }
626
 
689
  Util_Environment::filename_to_url( W3TC_CACHE_MINIFY_DIR ) ) . '/';
690
 
691
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
692
+ $brotli = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.brotli' ) );
693
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.compression' ) );
694
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.cssjs.expires' ) );
695
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.cssjs.lifetime' ) : 0 );
710
  Util_Environment::w3tc_header() . "\";\n";
711
  }
712
 
713
+ if ( $brotli || $compression ) {
714
  $common_rules .= " add_header Vary \"Accept-Encoding\";\n";
715
  }
716
 
725
 
726
  case 'cache_public_maxage':
727
  $common_rules .= " add_header Pragma \"public\";\n";
728
+
729
+ if ( $expires ) {
730
+ $common_rules .= " add_header Cache-Control \"public\";\n";
731
+ } else {
732
+ $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
733
+ }
734
  break;
735
 
736
  case 'cache_validation':
745
 
746
  case 'cache_maxage':
747
  $common_rules .= " add_header Pragma \"public\";\n";
748
+
749
+ if ( $expires ) {
750
+ $common_rules .= " add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\n";
751
+ } else {
752
+ $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
753
+ }
754
  break;
755
 
756
  case 'no_cache':
772
  $rules .= $common_rules;
773
  $rules .= "}\n";
774
 
775
+ if ( $brotli ) {
776
+ $rules .= "location ~ " . $cache_uri . ".*js_br$ {\n";
777
+ $rules .= " brotli off;\n";
778
+ $rules .= " types {}\n";
779
+ $rules .= " default_type application/x-javascript;\n";
780
+ $rules .= $common_rules;
781
+ $rules .= " add_header Content-Encoding br;\n";
782
+ $rules .= "}\n";
783
+
784
+ $rules .= "location ~ " . $cache_uri . ".*css_br$ {\n";
785
+ $rules .= " brotli off;\n";
786
+ $rules .= " types {}\n";
787
+ $rules .= " default_type text/css;\n";
788
+ $rules .= $common_rules;
789
+ $rules .= " add_header Content-Encoding br;\n";
790
+ $rules .= "}\n";
791
+ }
792
+
793
  if ( $compression ) {
794
  $rules .= "location ~ " . $cache_uri . ".*js_gzip$ {\n";
795
  $rules .= " gzip off;\n";
Minify_MinifiedFileRequestHandler.php CHANGED
@@ -54,6 +54,15 @@ class Minify_MinifiedFileRequestHandler {
54
  if ( ! $cache->store( basename( $file ), array( 'content' => 'content ok' ) ) ) {
55
  echo 'error storing';
56
  } else {
 
 
 
 
 
 
 
 
 
57
  if ( ( function_exists( 'gzencode' ) &&
58
  $this->_config->get_boolean( 'browsercache.enabled' ) &&
59
  $this->_config->get_boolean( 'browsercache.cssjs.compression' ) ) )
@@ -134,7 +143,8 @@ class Minify_MinifiedFileRequestHandler {
134
  'encodeOutput' => ( $browsercache &&
135
  !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) &&
136
  !$quiet &&
137
- $this->_config->get_boolean( 'browsercache.cssjs.compression' ) ),
 
138
  'bubbleCssImports' => ( $this->_config->get_string( 'minify.css.imports' ) == 'bubble' ),
139
  'processCssImports' => ( $this->_config->get_string( 'minify.css.imports' ) == 'process' ),
140
  'cacheHeaders' => array(
@@ -593,7 +603,11 @@ class Minify_MinifiedFileRequestHandler {
593
  Util_File::mkdir_from_safe( dirname( $cache_path ), W3TC_CACHE_DIR );
594
  }
595
 
596
- Util_Http::download( $url, $cache_path );
 
 
 
 
597
  }
598
 
599
  return file_exists( $cache_path ) ? $this->_get_minify_source( $cache_path, $url ) : false;
54
  if ( ! $cache->store( basename( $file ), array( 'content' => 'content ok' ) ) ) {
55
  echo 'error storing';
56
  } else {
57
+ if ( ( function_exists( 'brotli_compress' ) &&
58
+ $this->_config->get_boolean( 'browsercache.enabled' ) &&
59
+ $this->_config->get_boolean( 'browsercache.cssjs.brotli' ) ) )
60
+ if ( !$cache->store( basename( $file ) . '_br',
61
+ array( 'content' => brotli_compress( 'content ok' ) ) ) ) {
62
+ echo 'error storing';
63
+ exit();
64
+ }
65
+
66
  if ( ( function_exists( 'gzencode' ) &&
67
  $this->_config->get_boolean( 'browsercache.enabled' ) &&
68
  $this->_config->get_boolean( 'browsercache.cssjs.compression' ) ) )
143
  'encodeOutput' => ( $browsercache &&
144
  !defined( 'W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF' ) &&
145
  !$quiet &&
146
+ ( $this->_config->get_boolean( 'browsercache.cssjs.compression' ) ||
147
+ $this->_config->get_boolean( 'browsercache.cssjs.brotli' ) ) ),
148
  'bubbleCssImports' => ( $this->_config->get_string( 'minify.css.imports' ) == 'bubble' ),
149
  'processCssImports' => ( $this->_config->get_string( 'minify.css.imports' ) == 'process' ),
150
  'cacheHeaders' => array(
603
  Util_File::mkdir_from_safe( dirname( $cache_path ), W3TC_CACHE_DIR );
604
  }
605
 
606
+ // google-fonts (most used for external inclusion)
607
+ // doesnt return full content (unicode-range) for simple useragents
608
+ Util_Http::download( $url, $cache_path,
609
+ array( 'user-agent' =>
610
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92' ) );
611
  }
612
 
613
  return file_exists( $cache_path ) ? $this->_get_minify_source( $cache_path, $url ) : false;
Minify_Plugin.php CHANGED
@@ -174,7 +174,7 @@ class Minify_Plugin {
174
 
175
  if ( $this->_config->get_boolean( 'minify.auto' ) ) {
176
  if ( $js_enable ) {
177
- $minifier = new _W3_MinifyJsAuto( $this->_config,
178
  $buffer, $this->minify_helpers );
179
  $buffer = $minifier->execute();
180
  $this->replaced_scripts =
@@ -182,114 +182,9 @@ class Minify_Plugin {
182
  }
183
 
184
  if ( $css_enable ) {
185
- $embed_to_html = $this->_config->get_boolean( 'minify.css.embed' );
186
- $ignore_css_files = $this->_config->get_array( 'minify.reject.files.css' );
187
- $files_to_minify = array();
188
-
189
- $embed_pos = strpos( $buffer, '<!-- W3TC-include-css -->' );
190
-
191
-
192
- $buffer = str_replace( '<!-- W3TC-include-css -->', '', $buffer );
193
- if ( $embed_pos === false ) {
194
- if ( preg_match( '~<head(\s+[^>]*)*>~Ui', $buffer, $match, PREG_OFFSET_CAPTURE ) )
195
- $embed_pos = strlen( $match[0][0] ) + $match[0][1];
196
- else
197
- $embed_pos = 0;
198
- }
199
-
200
- $ignore_css_files = array_map( array( '\W3TC\Util_Environment', 'normalize_file' ), $ignore_css_files );
201
- $handled_styles = array();
202
- $style_tags = Minify_Extract::extract_css( $buffer );
203
- $previous_file_was_ignored = false;
204
- foreach ( $style_tags as $style_tag_tuple ) {
205
- $style_tag = $style_tag_tuple[0];
206
- $style_len = strlen( $style_tag );
207
- $tag_pos = strpos( $buffer, $style_tag );
208
- $match = array();
209
- $url = $style_tag_tuple[1];
210
- if ( $this->_config->get_boolean( 'minify.debug' ) ) {
211
- Minify_Core::log( 'adding ' . $url );
212
- }
213
-
214
- $url = Util_Environment::url_relative_to_full( $url );
215
- $file = Util_Environment::url_to_docroot_filename( $url );
216
-
217
- $include_type = $this->minify_helpers->is_file_for_minification( $url, $file );
218
- if ( $include_type == 'url' )
219
- $file = $url;
220
-
221
- $do_tag_minification = !empty( $include_type ) &&
222
- !in_array( $file, $handled_styles );
223
-
224
- $do_tag_minification = apply_filters( 'w3tc_minify_css_do_tag_minification',
225
- $do_tag_minification, $style_tag, $file );
226
-
227
- if ( !$do_tag_minification )
228
- continue;
229
-
230
- $handled_styles[] = $file;
231
- $this->replaced_styles[] = $file;
232
- if ( in_array( $file, $ignore_css_files ) ) {
233
- if ( $tag_pos > $embed_pos ) {
234
- if ( $files_to_minify ) {
235
- $data = array(
236
- 'files_to_minify' => $files_to_minify,
237
- 'embed_pos' => $embed_pos,
238
- 'embed_to_html' => $embed_to_html
239
- );
240
-
241
- $data = apply_filters(
242
- 'w3tc_minify_css_step',
243
- $data );
244
-
245
- $style = $this->get_style_custom(
246
- $data['files_to_minify'],
247
- $data['embed_to_html'] );
248
-
249
- if ( $this->_config->get_boolean( 'minify.css.http2push' ) ) {
250
- $this->minify_helpers->http2_header_add( $style['url'],
251
- 'style' );
252
- }
253
-
254
- $buffer = substr_replace( $buffer, $style['body'], $embed_pos, 0 );
255
-
256
- $files_to_minify = array();
257
- $style_len = $style_len + strlen( $style['body'] );
258
- }
259
- $embed_pos = $embed_pos + $style_len;
260
- $previous_file_was_ignored = true;
261
- }
262
- } else {
263
- $buffer = substr_replace( $buffer, '', $tag_pos, $style_len );
264
- if ( $embed_pos > $tag_pos )
265
- $embed_pos -= $style_len;
266
- elseif ( $previous_file_was_ignored )
267
- $embed_pos = $tag_pos;
268
-
269
- $files_to_minify[] = $file;
270
- }
271
- }
272
-
273
- $data = array(
274
- 'files_to_minify' => $files_to_minify,
275
- 'embed_pos' => $embed_pos,
276
- 'embed_to_html' => $embed_to_html
277
- );
278
-
279
- $data = apply_filters( 'w3tc_minify_css_step',
280
- $data );
281
-
282
- $style = $this->get_style_custom(
283
- $data['files_to_minify'],
284
- $data['embed_to_html'] );
285
-
286
- if ( $this->_config->get_boolean( 'minify.css.http2push' ) ) {
287
- $this->minify_helpers->http2_header_add( $style['url'],
288
- 'style' );
289
- }
290
-
291
- $buffer = substr_replace( $buffer, $style['body'],
292
- $data['embed_pos'], 0 );
293
  }
294
 
295
  $buffer = apply_filters( 'w3tc_minify_processed', $buffer );
@@ -837,31 +732,8 @@ class Minify_Plugin {
837
  * @return string
838
  */
839
  function get_style_custom( $files, $embed_to_html = false ) {
840
- $return = array(
841
- 'url' => null,
842
- 'body' => ''
843
- );
844
-
845
- if ( count( $files ) ) {
846
- if ( $embed_to_html ) {
847
- $body = $this->minify_helpers->get_minified_content_for_files(
848
- $files, 'css' );
849
- if ( !is_null( $body ) ) {
850
- $return['body'] = $body;
851
- }
852
- }
853
-
854
- if ( empty( $return['body'] ) ) {
855
- $return['url'] = $this->minify_helpers->get_minify_url_for_files(
856
- $files, 'css' );
857
- if ( !is_null( $return['url'] ) ) {
858
- $return['body'] = $this->get_style( $return['url'], false,
859
- false );
860
- }
861
- }
862
- }
863
-
864
- return $return;
865
  }
866
 
867
  /**
@@ -1325,324 +1197,47 @@ class _W3_MinifyHelpers {
1325
 
1326
  // Cloudflare needs URI without host
1327
  $uri = Util_Environment::url_to_uri( $url );
1328
- header( 'Link: <' . $uri . '>; rel=preload; as=' . $as, false );
1329
- }
1330
- }
1331
-
1332
- /**
1333
- * Class _W3_MinifyJsAuto
1334
- */
1335
- class _W3_MinifyJsAuto {
1336
- /**
1337
- * Config
1338
- */
1339
- private $config;
1340
-
1341
- /**
1342
- * Processed buffer
1343
- *
1344
- * @var string
1345
- */
1346
- private $buffer;
1347
-
1348
- /**
1349
- * JS files to ignore
1350
- *
1351
- * @var array
1352
- */
1353
- private $ignore_js_files;
1354
-
1355
- /**
1356
- * Embed type
1357
- *
1358
- * @var string
1359
- */
1360
- private $embed_type;
1361
-
1362
- /**
1363
- * Helper object to use
1364
- *
1365
- * @var _W3_MinifyHelpers
1366
- */
1367
- private $minify_helpers;
1368
-
1369
- /**
1370
- * Array of processed scripts
1371
- *
1372
- * @var array
1373
- */
1374
- private $debug_minified_urls = array();
1375
-
1376
- /**
1377
- * Current position to embed minified script
1378
- *
1379
- * @var integer
1380
- */
1381
- private $embed_pos;
1382
-
1383
- /**
1384
- * Current list of files to minify
1385
- *
1386
- * @var array
1387
- */
1388
- private $files_to_minify;
1389
-
1390
- /**
1391
- * Current group type
1392
- *
1393
- * @var string
1394
- */
1395
- private $group_type = 'head';
1396
-
1397
- /**
1398
- * Current number of minification group
1399
- *
1400
- * @var integer
1401
- */
1402
- private $minify_group_number = 0;
1403
- private $debug = false;
1404
-
1405
- /**
1406
- * Constructor
1407
- *
1408
- * @param unknown $config
1409
- * @param unknown $buffer
1410
- * @param unknown $minify_helpers
1411
- */
1412
- function __construct( $config, $buffer, $minify_helpers ) {
1413
- $this->config = $config;
1414
- $this->debug = $config->get_boolean( 'minify.debug' );
1415
- $this->buffer = $buffer;
1416
- $this->minify_helpers = $minify_helpers;
1417
-
1418
- // ignored files
1419
- $this->ignore_js_files = $this->config->get_array( 'minify.reject.files.js' );
1420
- $this->ignore_js_files = array_map( array( '\W3TC\Util_Environment', 'normalize_file' ), $this->ignore_js_files );
1421
-
1422
- // define embed type
1423
- $this->embed_type = array(
1424
- 'head' => $this->config->get_string( 'minify.js.header.embed_type' ),
1425
- 'body' => $this->config->get_string( 'minify.js.body.embed_type' )
1426
- );
1427
- }
1428
-
1429
- /**
1430
- * Does auto-minification
1431
- *
1432
- * @return string buffer of minified content
1433
- */
1434
- public function execute() {
1435
- // find all script tags
1436
- $buffer_nocomments = preg_replace( '~<!--.*?-->\s*~s', '', $this->buffer );
1437
- $matches = null;
1438
-
1439
- // end of <head> means another group of scripts, cannt be combined
1440
- if ( !preg_match_all( '~(<script\s*[^>]*>.*?</script>|</head>)~is',
1441
- $buffer_nocomments, $matches ) ) {
1442
- $matches = null;
1443
- }
1444
-
1445
- if ( is_null( $matches ) ) {
1446
- return $this->buffer;
1447
- }
1448
-
1449
- $script_tags = $matches[1];
1450
- $script_tags = apply_filters( 'w3tc_minify_js_script_tags',
1451
- $script_tags );
1452
-
1453
- // pass scripts
1454
- $this->embed_pos = null;
1455
- $this->files_to_minify = array();
1456
-
1457
- for ( $n = 0; $n < count( $script_tags ); $n++ ) {
1458
- $this->process_script_tag( $script_tags[$n], $n );
1459
- }
1460
-
1461
- $this->flush_collected( '' );
1462
-
1463
- return $this->buffer;
1464
- }
1465
-
1466
- /**
1467
- * Returns list of minified scripts
1468
- *
1469
- * @return array
1470
- */
1471
- public function get_debug_minified_urls() {
1472
- return $this->debug_minified_urls;
1473
- }
1474
-
1475
- /**
1476
- * Processes script tag
1477
- *
1478
- * @param unknown $script_tag
1479
- * @return void
1480
- */
1481
- private function process_script_tag( $script_tag, $script_tag_number ) {
1482
- if ( $this->debug ) {
1483
- Minify_Core::log( 'processing tag ' . substr( $script_tag, 0, 150 ) );
1484
- }
1485
-
1486
- $tag_pos = strpos( $this->buffer, $script_tag );
1487
- if ( $tag_pos === false ) {
1488
- // script is external but not found, skip processing it
1489
- error_log( 'script not found:' . $script_tag );
1490
- if ( $this->debug ) {
1491
- Minify_Core::log( 'script not found:' . $script_tag );
1492
- }
1493
- return;
1494
- }
1495
 
1496
- $match = null;
1497
- if ( !preg_match( '~<script\s+[^<>]*src=["\']?([^"\'> ]+)["\'> ]~is',
1498
- $script_tag, $match ) ) {
1499
- $match = null;
1500
- }
1501
- if ( is_null( $match ) ) {
1502
- $data = array(
1503
- 'script_tag_original' => $script_tag,
1504
- 'script_tag_new' => $script_tag,
1505
- 'script_tag_number' => $script_tag_number,
1506
- 'script_tag_pos' => $tag_pos,
1507
- 'should_replace' => false,
1508
- 'buffer' => $this->buffer
1509
- );
1510
-
1511
- $data = apply_filters( 'w3tc_minify_js_do_local_script_minification',
1512
- $data );
1513
- $this->buffer = $data['buffer'];
1514
-
1515
- if ( $data['should_replace'] ) {
1516
- $this->buffer = substr_replace( $this->buffer,
1517
- $data['script_tag_new'], $tag_pos,
1518
- strlen( $script_tag ) );
1519
- }
1520
-
1521
- // it's not external script, have to flush what we have before it
1522
- if ( $this->debug ) {
1523
- Minify_Core::log( 'its not src=, flushing' );
1524
- }
1525
-
1526
- $this->flush_collected( $script_tag );
1527
-
1528
- if ( preg_match( '~</head>~is', $script_tag, $match ) )
1529
- $this->group_type = 'body';
1530
-
1531
- return;
1532
- }
1533
-
1534
- $script_src = $match[1];
1535
- $script_src = Util_Environment::url_relative_to_full( $script_src );
1536
- $file = Util_Environment::url_to_docroot_filename( $script_src );
1537
-
1538
- $step1_result = $this->minify_helpers->is_file_for_minification(
1539
- $script_src, $file );
1540
- if ( $step1_result == 'url' )
1541
- $file = $script_src;
1542
-
1543
- $step1 = !empty( $step1_result );
1544
- $step2 = !in_array( $file, $this->ignore_js_files );
1545
-
1546
- $do_tag_minification = $step1 && $step2;
1547
- $do_tag_minification = apply_filters( 'w3tc_minify_js_do_tag_minification',
1548
- $do_tag_minification, $script_tag, $file );
1549
-
1550
- if ( !$do_tag_minification ) {
1551
- if ( $this->debug ) {
1552
- Minify_Core::log( 'file ' . $file .
1553
- ' didnt pass minification check:' .
1554
- ' file_for_min: ' . ( $step1 ? 'true' : 'false' ) .
1555
- ' ignore_js_files: ' . ( $step2 ? 'true' : 'false' ) );
1556
- }
1557
-
1558
- $data = array(
1559
- 'script_tag_original' => $script_tag,
1560
- 'script_tag_new' => $script_tag,
1561
- 'script_tag_number' => $script_tag_number,
1562
- 'script_tag_pos' => $tag_pos,
1563
- 'script_src' => $script_src,
1564
- 'should_replace' => false,
1565
- 'buffer' => $this->buffer
1566
- );
1567
-
1568
- $data = apply_filters( 'w3tc_minify_js_do_excluded_tag_script_minification',
1569
- $data );
1570
- $this->buffer = $data['buffer'];
1571
-
1572
- if ( $data['should_replace'] ) {
1573
- $this->buffer = substr_replace( $this->buffer,
1574
- $data['script_tag_new'], $tag_pos,
1575
- strlen( $script_tag ) );
1576
- }
1577
-
1578
- $this->flush_collected( $script_tag );
1579
- return;
1580
- }
1581
-
1582
- $this->debug_minified_urls[] = $file;
1583
- $this->buffer = substr_replace( $this->buffer, '',
1584
- $tag_pos, strlen( $script_tag ) );
1585
 
1586
- // for head group - put minified file at the place of first script
1587
- // for body - put at the place of last script, to make as more DOM
1588
- // objects available as possible
1589
- if ( count( $this->files_to_minify ) <= 0 || $this->group_type == 'body' )
1590
- $this->embed_pos = $tag_pos;
1591
- $this->files_to_minify[] = $file;
1592
  }
1593
 
1594
- /**
1595
- * Minifies collected scripts
1596
- */
1597
- private function flush_collected( $last_script_tag ) {
1598
- if ( count( $this->files_to_minify ) <= 0 )
1599
- return;
1600
- $do_flush_collected = apply_filters( 'w3tc_minify_js_do_flush_collected',
1601
- true, $last_script_tag, $this );
1602
- if ( !$do_flush_collected )
1603
- return;
1604
 
1605
- // find embed position
1606
- $embed_pos = $this->embed_pos;
1607
 
1608
- // build minified script tag
1609
- $data = array(
1610
- 'files_to_minify' => $this->files_to_minify,
1611
- 'embed_pos' => $embed_pos,
1612
- 'embed_type' => $this->embed_type[$this->group_type],
1613
- 'buffer' => $this->buffer
1614
  );
1615
 
1616
- $data = apply_filters( 'w3tc_minify_js_step', $data );
1617
- $this->buffer = $data['buffer'];
1618
-
1619
- if ( !empty( $data['files_to_minify'] ) ) {
1620
- $url = $this->minify_helpers->get_minify_url_for_files(
1621
- $data['files_to_minify'], 'js' );
1622
-
1623
- $script = '';
1624
- if ( !is_null( $url ) ) {
1625
- $script .= $this->minify_helpers->generate_script_tag( $url,
1626
- $data['embed_type'] );
1627
  }
1628
 
1629
- $data['script_to_embed_url'] = $url;
1630
- $data['script_to_embed_body'] = $script;
1631
- $data = apply_filters( 'w3tc_minify_js_step_script_to_embed',
1632
- $data );
1633
- $this->buffer = $data['buffer'];
1634
-
1635
- if ( $this->config->get_boolean( 'minify.js.http2push' ) ) {
1636
- $this->minify_helpers->http2_header_add(
1637
- $data['script_to_embed_url'], 'script' );
1638
  }
1639
-
1640
- // replace
1641
- $this->buffer = substr_replace( $this->buffer,
1642
- $data['script_to_embed_body'], $data['embed_pos'], 0 );
1643
  }
1644
 
1645
- $this->files_to_minify = array();
1646
- $this->minify_group_number++;
1647
  }
1648
  }
174
 
175
  if ( $this->_config->get_boolean( 'minify.auto' ) ) {
176
  if ( $js_enable ) {
177
+ $minifier = new Minify_AutoJs( $this->_config,
178
  $buffer, $this->minify_helpers );
179
  $buffer = $minifier->execute();
180
  $this->replaced_scripts =
182
  }
183
 
184
  if ( $css_enable ) {
185
+ $minifier = new Minify_AutoCss( $this->_config, $buffer,
186
+ $this->minify_helpers );
187
+ $buffer = $minifier->execute();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  }
189
 
190
  $buffer = apply_filters( 'w3tc_minify_processed', $buffer );
732
  * @return string
733
  */
734
  function get_style_custom( $files, $embed_to_html = false ) {
735
+ return $this->minify_helpers->generate_css_style_tag(
736
+ $files, $embed_to_html );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
  }
738
 
739
  /**
1197
 
1198
  // Cloudflare needs URI without host
1199
  $uri = Util_Environment::url_to_uri( $url );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1200
 
1201
+ // priorities attached:
1202
+ // 3000 - cdn
1203
+ // 4000 - browsercache
1204
+ $data = apply_filters( 'w3tc_minify_http2_preload_url', array(
1205
+ 'result_link' => $uri,
1206
+ 'original_url' => $url
1207
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1208
 
1209
+ header( 'Link: <' . $data['result_link'] . '>; rel=preload; as=' . $as, false );
 
 
 
 
 
1210
  }
1211
 
 
 
 
 
 
 
 
 
 
 
1212
 
 
 
1213
 
1214
+ function generate_css_style_tag( $files, $embed_to_html ) {
1215
+ $return = array(
1216
+ 'url' => null,
1217
+ 'body' => ''
 
 
1218
  );
1219
 
1220
+ if ( count( $files ) ) {
1221
+ if ( $embed_to_html ) {
1222
+ $body = $this->get_minified_content_for_files(
1223
+ $files, 'css' );
1224
+ if ( !is_null( $body ) ) {
1225
+ $return['body'] = $body;
1226
+ }
 
 
 
 
1227
  }
1228
 
1229
+ if ( empty( $return['body'] ) ) {
1230
+ $return['url'] = $this->get_minify_url_for_files(
1231
+ $files, 'css' );
1232
+ if ( !is_null( $return['url'] ) ) {
1233
+ $return['body'] =
1234
+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
1235
+ str_replace( '&', '&amp;', $return['url'] ) .
1236
+ "\" media=\"all\" />\r\n";
1237
+ }
1238
  }
 
 
 
 
1239
  }
1240
 
1241
+ return $return;
 
1242
  }
1243
  }
PageSpeed_Plugin_Widget.php CHANGED
@@ -29,9 +29,9 @@ class PageSpeed_Plugin_Widget {
29
 
30
  public function admin_init_w3tc_dashboard() {
31
  add_action( 'w3tc_widget_setup',
32
- array( $this, 'wp_dashboard_setup' ), 500 );
33
  add_action( 'w3tc_network_dashboard_setup',
34
- array( $this, 'wp_dashboard_setup' ), 500 );
35
 
36
  wp_enqueue_script( 'w3tc-widget-pagespeed',
37
  plugins_url( 'PageSpeed_Widget_View.js', W3TC_FILE ),
29
 
30
  public function admin_init_w3tc_dashboard() {
31
  add_action( 'w3tc_widget_setup',
32
+ array( $this, 'wp_dashboard_setup' ), 3000 );
33
  add_action( 'w3tc_network_dashboard_setup',
34
+ array( $this, 'wp_dashboard_setup' ), 3000 );
35
 
36
  wp_enqueue_script( 'w3tc-widget-pagespeed',
37
  plugins_url( 'PageSpeed_Widget_View.js', W3TC_FILE ),
PgCache_ConfigLabels.php CHANGED
@@ -10,7 +10,7 @@ class PgCache_ConfigLabels {
10
  'pgcache.cache.home' => get_option( 'show_on_front' ) == 'posts' ? __( 'Cache front page', 'w3-total-cache' ): __( 'Cache posts page', 'w3-total-cache' ),
11
  'pgcache.reject.front_page' => __( 'Don\'t cache front page', 'w3-total-cache' ),
12
  'pgcache.cache.feed' => __( 'Cache feeds: site, categories, tags, comments', 'w3-total-cache' ),
13
- 'pgcache.cache.ssl' => __( 'Cache <acronym title="Secure Socket Layer">SSL</acronym> (<acronym title="HyperText Transfer Protocol over SSL">https</acronym>) requests', 'w3-total-cache' ),
14
  'pgcache.cache.query' => __( 'Cache <acronym title="Uniform Resource Identifier">URI</acronym>s with query string variables', 'w3-total-cache' ),
15
  'pgcache.cache.404' => __( 'Cache 404 (not found) pages', 'w3-total-cache' ),
16
  'pgcache.reject.logged' => __( 'Don\'t cache pages for logged in users', 'w3-total-cache' ),
@@ -38,7 +38,7 @@ class PgCache_ConfigLabels {
38
  'pgcache.purge.pages' => __( 'Additional pages:', 'w3-total-cache' ),
39
  'pgcache.purge.sitemap_regex' => __( 'Purge sitemaps:', 'w3-total-cache' ),
40
  'pgcache.compatibility' => __( 'Enable', 'w3-total-cache' ),
41
- 'pgcache.remove_charset' => __( 'Disable UTF-8 blog charset support' , 'w3-total-cache' ),
42
  'pgcache.reject.request_head' => __( ' Disable caching of HEAD <acronym title="Hypertext Transfer Protocol">HTTP</acronym> requests', 'w3-total-cache' ),
43
  'pgcache.lifetime' => __( 'Maximum lifetime of cache objects:', 'w3-total-cache' ),
44
  'pgcache.file.gc' => __( 'Garbage collection interval:', 'w3-total-cache' ),
10
  'pgcache.cache.home' => get_option( 'show_on_front' ) == 'posts' ? __( 'Cache front page', 'w3-total-cache' ): __( 'Cache posts page', 'w3-total-cache' ),
11
  'pgcache.reject.front_page' => __( 'Don\'t cache front page', 'w3-total-cache' ),
12
  'pgcache.cache.feed' => __( 'Cache feeds: site, categories, tags, comments', 'w3-total-cache' ),
13
+ 'pgcache.cache.ssl' => __( 'Cache <acronym title="Secure Socket Layer">SSL</acronym> (<acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym>) requests', 'w3-total-cache' ),
14
  'pgcache.cache.query' => __( 'Cache <acronym title="Uniform Resource Identifier">URI</acronym>s with query string variables', 'w3-total-cache' ),
15
  'pgcache.cache.404' => __( 'Cache 404 (not found) pages', 'w3-total-cache' ),
16
  'pgcache.reject.logged' => __( 'Don\'t cache pages for logged in users', 'w3-total-cache' ),
38
  'pgcache.purge.pages' => __( 'Additional pages:', 'w3-total-cache' ),
39
  'pgcache.purge.sitemap_regex' => __( 'Purge sitemaps:', 'w3-total-cache' ),
40
  'pgcache.compatibility' => __( 'Enable', 'w3-total-cache' ),
41
+ 'pgcache.remove_charset' => __( 'Disable <acronym title="Unicode Transformation Format">UTF</acronym>-8 blog charset support' , 'w3-total-cache' ),
42
  'pgcache.reject.request_head' => __( ' Disable caching of HEAD <acronym title="Hypertext Transfer Protocol">HTTP</acronym> requests', 'w3-total-cache' ),
43
  'pgcache.lifetime' => __( 'Maximum lifetime of cache objects:', 'w3-total-cache' ),
44
  'pgcache.file.gc' => __( 'Garbage collection interval:', 'w3-total-cache' ),
PgCache_ContentGrabber.php CHANGED
@@ -128,7 +128,10 @@ class PgCache_ContentGrabber {
128
  $this->_lifetime = $this->_config->get_integer( 'pgcache.lifetime' );
129
  $this->_late_init = $this->_config->get_boolean( 'pgcache.late_init' );
130
  $this->_late_caching = $this->_config->get_boolean( 'pgcache.late_caching' );
131
- $this->_enhanced_mode = ( $this->_config->get_string( 'pgcache.engine' ) == 'file_generic' );
 
 
 
132
 
133
  if ( $this->_config->get_boolean( 'mobile.enabled' ) ) {
134
  $this->_mobile = Dispatcher::component( 'Mobile_UserAgent' );
@@ -251,7 +254,9 @@ class PgCache_ContentGrabber {
251
 
252
  if ( !$data ) {
253
  if ( $this->_debug ) {
254
- self::log( 'no cache entry for ' . $this->_page_key );
 
 
255
  }
256
 
257
  return null;
@@ -315,8 +320,8 @@ class PgCache_ContentGrabber {
315
  */
316
  $this->_bad_behavior();
317
 
318
- $is_404 = $data['404'];
319
- $headers = $data['headers'];
320
  $content = $data['content'];
321
  $has_dynamic = isset( $data['has_dynamic'] ) && $data['has_dynamic'];
322
  $etag = md5( $content );
@@ -334,7 +339,7 @@ class PgCache_ContentGrabber {
334
  $time = time();
335
  $compression = $this->_page_key_extension['compression'];
336
  } else {
337
- $time = $data['time'];
338
  $compression = $data['compression'];
339
  }
340
 
@@ -701,6 +706,7 @@ class PgCache_ContentGrabber {
701
 
702
  switch ( $engine ) {
703
  case 'memcached':
 
704
  $engineConfig = array(
705
  'servers' => $this->_config->get_array( 'pgcache.memcached.servers' ),
706
  'persistent' => $this->_config->get_boolean( 'pgcache.memcached.persistent' ),
@@ -744,6 +750,7 @@ class PgCache_ContentGrabber {
744
 
745
  switch ( $engine ) {
746
  case 'memcached':
 
747
  $engineConfig = array(
748
  'servers' => $this->_config->get_array( 'pgcache.memcached.servers' ),
749
  'persistent' => $this->_config->get_boolean( 'pgcache.memcached.persistent' ),
@@ -1052,6 +1059,10 @@ class PgCache_ContentGrabber {
1052
  case 'deflate':
1053
  $data = gzdeflate( $data );
1054
  break;
 
 
 
 
1055
  }
1056
 
1057
  return $data;
@@ -1177,12 +1188,22 @@ class PgCache_ContentGrabber {
1177
  false
1178
  );
1179
 
 
 
 
 
1180
  if ( $this->_config->get_boolean( 'browsercache.enabled' ) &&
1181
  $this->_config->get_boolean( 'browsercache.html.compression' ) &&
1182
  function_exists( 'gzencode' ) ) {
1183
  $compressions[] = 'gzip';
1184
  }
1185
 
 
 
 
 
 
 
1186
  return $compressions;
1187
  }
1188
 
@@ -1301,6 +1322,7 @@ class PgCache_ContentGrabber {
1301
  ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
1302
  } else {
1303
  $key = $this->_request_host . $this->_request_uri;
 
1304
  }
1305
 
1306
  // replace fragment
@@ -1335,6 +1357,30 @@ class PgCache_ContentGrabber {
1335
  }
1336
 
1337
  $key .= '_index';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1338
  } else {
1339
  if ( isset( $page_key_extension['querystring.processing'] ) &&
1340
  $page_key_extension['querystring.processing'] == 'include' ) {
@@ -1368,8 +1414,8 @@ class PgCache_ContentGrabber {
1368
  $page_key_extension['content_type'] : '';
1369
 
1370
  if ( @preg_match( "~(text/xml|text/xsl|application/rdf\+xml|application/rss\+xml|application/atom\+xml)~i", $content_type ) ||
1371
- strpos( $this->_request_uri, "/feed/" ) !== false ||
1372
- strpos( $this->_request_uri, ".xsl" ) !== false ) {
1373
  $key_postfix = '.xml';
1374
  }
1375
  }
@@ -1942,6 +1988,9 @@ class PgCache_ContentGrabber {
1942
  'time' => $time,
1943
  'content' => $buffers[$_compression]
1944
  );
 
 
 
1945
  if ( $has_dynamic )
1946
  $_data['has_dynamic'] = true;
1947
 
128
  $this->_lifetime = $this->_config->get_integer( 'pgcache.lifetime' );
129
  $this->_late_init = $this->_config->get_boolean( 'pgcache.late_init' );
130
  $this->_late_caching = $this->_config->get_boolean( 'pgcache.late_caching' );
131
+
132
+ $engine = $this->_config->get_string( 'pgcache.engine' );
133
+ $this->_enhanced_mode = ( $engine == 'file_generic' );
134
+ $this->_nginx_memcached = ( $engine == 'nginx_memcached' );
135
 
136
  if ( $this->_config->get_boolean( 'mobile.enabled' ) ) {
137
  $this->_mobile = Dispatcher::component( 'Mobile_UserAgent' );
254
 
255
  if ( !$data ) {
256
  if ( $this->_debug ) {
257
+ self::log( 'no cache entry for ' .
258
+ $this->_request_host . $this->_request_uri . ' ' .
259
+ $this->_page_key );
260
  }
261
 
262
  return null;
320
  */
321
  $this->_bad_behavior();
322
 
323
+ $is_404 = isset( $data['404'] ) ? $data['404'] : false;
324
+ $headers = isset( $data['headers'] ) ? $data['headers'] : array();
325
  $content = $data['content'];
326
  $has_dynamic = isset( $data['has_dynamic'] ) && $data['has_dynamic'];
327
  $etag = md5( $content );
339
  $time = time();
340
  $compression = $this->_page_key_extension['compression'];
341
  } else {
342
+ $time = isset( $data['time'] ) ? $data['time'] : time();
343
  $compression = $data['compression'];
344
  }
345
 
706
 
707
  switch ( $engine ) {
708
  case 'memcached':
709
+ case 'nginx_memcached':
710
  $engineConfig = array(
711
  'servers' => $this->_config->get_array( 'pgcache.memcached.servers' ),
712
  'persistent' => $this->_config->get_boolean( 'pgcache.memcached.persistent' ),
750
 
751
  switch ( $engine ) {
752
  case 'memcached':
753
+ case 'nginx_memcached':
754
  $engineConfig = array(
755
  'servers' => $this->_config->get_array( 'pgcache.memcached.servers' ),
756
  'persistent' => $this->_config->get_boolean( 'pgcache.memcached.persistent' ),
1059
  case 'deflate':
1060
  $data = gzdeflate( $data );
1061
  break;
1062
+
1063
+ case 'br':
1064
+ $data = brotli_compress( $data );
1065
+ break;
1066
  }
1067
 
1068
  return $data;
1188
  false
1189
  );
1190
 
1191
+ if ( defined( 'W3TC_PAGECACHE_STORE_COMPRESSION_OFF' ) ) {
1192
+ return $compressions;
1193
+ }
1194
+
1195
  if ( $this->_config->get_boolean( 'browsercache.enabled' ) &&
1196
  $this->_config->get_boolean( 'browsercache.html.compression' ) &&
1197
  function_exists( 'gzencode' ) ) {
1198
  $compressions[] = 'gzip';
1199
  }
1200
 
1201
+ if ( $this->_config->get_boolean( 'browsercache.enabled' ) &&
1202
+ $this->_config->get_boolean( 'browsercache.html.brotli' ) &&
1203
+ function_exists( 'brotli_compress' ) ) {
1204
+ $compressions[] = 'br';
1205
+ }
1206
+
1207
  return $compressions;
1208
  }
1209
 
1322
  ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
1323
  } else {
1324
  $key = $this->_request_host . $this->_request_uri;
1325
+ $request_url = $this->_request_uri;
1326
  }
1327
 
1328
  // replace fragment
1357
  }
1358
 
1359
  $key .= '_index';
1360
+ } else if ( $this->_nginx_memcached ) {
1361
+ // URL decode
1362
+ $key = urldecode( $key );
1363
+
1364
+ // replace double slashes
1365
+ $key = preg_replace( '~[/\\\]+~', '/', $key );
1366
+
1367
+ // replace index.php
1368
+ $key = str_replace( '/index.php', '/', $key );
1369
+
1370
+ $key_query = '';
1371
+ if ( isset( $page_key_extension['querystring.processing'] ) &&
1372
+ $page_key_extension['querystring.processing'] == 'include' ) {
1373
+
1374
+ if ( preg_match( '~\?.*$~', $key, $m ) ) {
1375
+ $key_query = '_' . md5( $m[0] );
1376
+ }
1377
+ }
1378
+
1379
+ $key = preg_replace( '~\?.*$~', '', $key );
1380
+
1381
+ // make sure one slash is at the end
1382
+ $key = ltrim( $key, '/' );
1383
+ $key = rtrim( $key, '/' ) . '/';
1384
  } else {
1385
  if ( isset( $page_key_extension['querystring.processing'] ) &&
1386
  $page_key_extension['querystring.processing'] == 'include' ) {
1414
  $page_key_extension['content_type'] : '';
1415
 
1416
  if ( @preg_match( "~(text/xml|text/xsl|application/rdf\+xml|application/rss\+xml|application/atom\+xml)~i", $content_type ) ||
1417
+ strpos( $request_url, "/feed/" ) !== false ||
1418
+ strpos( $request_url, ".xsl" ) !== false ) {
1419
  $key_postfix = '.xml';
1420
  }
1421
  }
1988
  'time' => $time,
1989
  'content' => $buffers[$_compression]
1990
  );
1991
+ if ( !empty( $_compression ) ) {
1992
+ $_data['c'] = $_compression;
1993
+ }
1994
  if ( $has_dynamic )
1995
  $_data['has_dynamic'] = true;
1996
 
PgCache_Environment.php CHANGED
@@ -27,8 +27,7 @@ class PgCache_Environment {
27
  $this->fix_folders( $config, $exs );
28
 
29
  if ( $config->get_boolean( 'config.check' ) || $force_all_checks ) {
30
- if ( $config->get_boolean( 'pgcache.enabled' ) &&
31
- $config->get_string( 'pgcache.engine' ) == 'file_generic' ) {
32
  $this->rules_core_add( $config, $exs );
33
  $this->rules_cache_add( $config, $exs );
34
  } else {
@@ -125,6 +124,12 @@ class PgCache_Environment {
125
  throw $exs;
126
  }
127
 
 
 
 
 
 
 
128
  /**
129
  * Returns required rules for module
130
  *
@@ -132,9 +137,9 @@ class PgCache_Environment {
132
  * @return array
133
  */
134
  public function get_required_rules( $config ) {
135
- if ( !$config->get_boolean( 'pgcache.enabled' ) ||
136
- $config->get_string( 'pgcache.engine' ) != 'file_generic' )
137
  return null;
 
138
 
139
  $rewrite_rules = array();
140
  $pgcache_rules_core_path = Util_Rule::get_pgcache_rules_core_path();
@@ -543,9 +548,7 @@ class PgCache_Environment {
543
  'wp-postpass'
544
  );
545
 
546
- if ( $config->get_string( 'pgcache.engine' ) == 'file_generic' ) {
547
- $reject_cookies[] = 'w3tc_logged_out';
548
- }
549
 
550
  /**
551
  * Reject cache for logged in users
@@ -743,7 +746,11 @@ class PgCache_Environment {
743
  /**
744
  * Set Accept-Encoding
745
  */
746
- if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.html.compression' ) ) {
 
 
 
 
747
  $rules .= " RewriteCond %{HTTP:Accept-Encoding} gzip\n";
748
  $rules .= " RewriteRule .* - [E=W3TC_ENC:_gzip]\n";
749
  $env_W3TC_ENC = '%{ENV:W3TC_ENC}';
@@ -828,6 +835,7 @@ class PgCache_Environment {
828
 
829
  $cache_dir = Util_Environment::normalize_path( W3TC_CACHE_PAGE_ENHANCED_DIR );
830
  $permalink_structure = get_option( 'permalink_structure' );
 
831
 
832
  /**
833
  * Auto reject cookies
@@ -837,7 +845,7 @@ class PgCache_Environment {
837
  'wp-postpass'
838
  );
839
 
840
- if ( $config->get_string( 'pgcache.engine' ) == 'file_generic' ) {
841
  $reject_cookies[] = 'w3tc_logged_out';
842
  }
843
 
@@ -881,6 +889,7 @@ class PgCache_Environment {
881
  $env_w3tc_ssl = '';
882
  $env_w3tc_ext = '';
883
  $env_w3tc_enc = '';
 
884
 
885
  $rules = '';
886
  $rules .= W3TC_MARKER_BEGIN_PGCACHE_CORE . "\n";
@@ -901,15 +910,21 @@ class PgCache_Environment {
901
  $rules .= "set \$w3tc_query_string \$query_string;\n";
902
 
903
  foreach ( $w3tc_query_strings as $query ) {
904
- $query .= ( strpos( $query, '=' ) === false ? '.*?' : '' );
905
- $rules .= "if (\$w3tc_query_string ~* \"^(.*?&|)".$query."(&.*|)$\") {\n";
906
  $rules .= " set \$w3tc_query_string $1$2;\n";
907
  $rules .= "}\n";
908
  }
909
 
910
- $rules .= "if (\$w3tc_query_string ~ ^&+$) {\n";
911
  $rules .= " set \$w3tc_query_string \"\";\n";
912
  $rules .= "}\n";
 
 
 
 
 
 
913
  }
914
 
915
  /**
@@ -979,11 +994,14 @@ class PgCache_Environment {
979
 
980
  /**
981
  * Check permalink structure trailing slash
 
982
  */
983
- if ( substr( $permalink_structure, -1 ) == '/' ) {
984
- $rules .= "if (\$request_uri !~ \\/$) {\n";
985
- $rules .= " set \$w3tc_rewrite 0;\n";
986
- $rules .= "}\n";
 
 
987
  }
988
 
989
  /**
@@ -1122,7 +1140,18 @@ class PgCache_Environment {
1122
  $rules .= " set \$w3tc_ssl _ssl;\n";
1123
  $rules .= "}\n";
1124
 
1125
- $env_w3tc_ssl = "\$w3tc_ssl";
 
 
 
 
 
 
 
 
 
 
 
1126
  }
1127
 
1128
  if ( $config->get_boolean( 'browsercache.enabled' ) &&
@@ -1133,44 +1162,101 @@ class PgCache_Environment {
1133
  $rules .= " set \$w3tc_enc _gzip;\n";
1134
  $rules .= "}\n";
1135
 
1136
- $env_w3tc_enc = "\$w3tc_enc";
1137
  }
1138
 
1139
- $cache_path = str_replace( Util_Environment::document_root(), '', $cache_dir );
1140
- $uri_prefix = $cache_path . "/\$http_host/" .
1141
- "\$request_uri/_index" . $env_w3tc_ua . $env_w3tc_ref .
1142
- $env_w3tc_cookie . $env_w3tc_ssl . $env_w3tc_preview;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
 
1144
  if ( !$config->get_boolean( 'pgcache.cache.nginx_handle_xml' ) ) {
1145
  $env_w3tc_ext = '.html';
1146
 
1147
- $rules .= "if (!-f \"\$document_root" . $uri_prefix . ".html" .
1148
- $env_w3tc_enc . "\") {\n";
1149
- $rules .= " set \$w3tc_rewrite 0;\n";
1150
  $rules .= "}\n";
1151
  } else {
1152
- $env_w3tc_ext = "\$w3tc_ext";
1153
 
1154
- $rules .= "set \$w3tc_ext \"\";\n";
1155
- $rules .= "if (-f \"\$document_root" . $uri_prefix . ".html" .
1156
- $env_w3tc_enc . "\") {\n";
1157
- $rules .= " set \$w3tc_ext .html;\n";
1158
  $rules .= "}\n";
1159
 
1160
- $rules .= "if (-f \"\$document_root" . $uri_prefix . ".xml" .
1161
- $env_w3tc_enc . "\") {\n";
1162
- $rules .= " set \$w3tc_ext .xml;\n";
1163
  $rules .= "}\n";
1164
 
1165
- $rules .= "if (\$w3tc_ext = \"\") {\n";
1166
- $rules .= " set \$w3tc_rewrite 0;\n";
1167
  $rules .= "}\n";
1168
  }
1169
 
1170
- $rules .= "if (\$w3tc_rewrite = 1) {\n";
1171
- $rules .= " rewrite .* \"" . $uri_prefix . $env_w3tc_ext . $env_w3tc_enc . "\" last;\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1172
  $rules .= "}\n";
1173
- $rules .= W3TC_MARKER_END_PGCACHE_CORE . "\n";
1174
 
1175
  return $rules;
1176
  }
@@ -1253,6 +1339,7 @@ class PgCache_Environment {
1253
  $pingback_url = get_bloginfo( 'pingback_url' );
1254
 
1255
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
 
1256
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.html.compression' ) );
1257
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.html.expires' ) );
1258
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.html.lifetime' ) : 0 );
@@ -1267,7 +1354,7 @@ class PgCache_Environment {
1267
  $rules .= "Options -MultiViews\n";
1268
 
1269
  // allow to read files by apache if they are blocked at some level above
1270
- $rules .= "<Files ~ \"\.(html|html_gzip|xml|xml_gzip)$\">\n";
1271
 
1272
  if ( version_compare( Util_Environment::get_server_version(), '2.4', '>=' ) ) {
1273
  $rules .= " Require all granted\n";
@@ -1294,6 +1381,19 @@ class PgCache_Environment {
1294
  $rules .= "FileETag MTime Size\n";
1295
  }
1296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1297
  if ( $compression ) {
1298
  $rules .= "<IfModule mod_mime.c>\n";
1299
  $rules .= " AddType text/html .html_gzip\n";
@@ -1399,6 +1499,10 @@ class PgCache_Environment {
1399
  * @return string
1400
  */
1401
  private function rules_cache_generate_nginx( $config ) {
 
 
 
 
1402
  $cache_root = Util_Environment::normalize_path( W3TC_CACHE_PAGE_ENHANCED_DIR );
1403
  $cache_dir = rtrim( str_replace( Util_Environment::document_root(), '', $cache_root ), '/' );
1404
 
@@ -1407,6 +1511,7 @@ class PgCache_Environment {
1407
  }
1408
 
1409
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
 
1410
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.html.compression' ) );
1411
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.html.expires' ) );
1412
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.html.lifetime' ) : 0 );
@@ -1443,7 +1548,12 @@ class PgCache_Environment {
1443
 
1444
  case 'cache_public_maxage':
1445
  $common_rules .= " add_header Pragma \"public\";\n";
1446
- $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
 
 
 
 
 
1447
  break;
1448
 
1449
  case 'cache_validation':
@@ -1458,7 +1568,12 @@ class PgCache_Environment {
1458
 
1459
  case 'cache_maxage':
1460
  $common_rules .= " add_header Pragma \"public\";\n";
1461
- $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
 
 
 
 
 
1462
  break;
1463
 
1464
  case 'no_cache':
@@ -1477,6 +1592,23 @@ class PgCache_Environment {
1477
  $rules .= "}\n";
1478
  }
1479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1480
  if ( $compression ) {
1481
  $maybe_xml = '';
1482
  if ($config->get_boolean('pgcache.cache.nginx_handle_xml')) {
27
  $this->fix_folders( $config, $exs );
28
 
29
  if ( $config->get_boolean( 'config.check' ) || $force_all_checks ) {
30
+ if ( $this->are_rules_present( $config ) ) {
 
31
  $this->rules_core_add( $config, $exs );
32
  $this->rules_cache_add( $config, $exs );
33
  } else {
124
  throw $exs;
125
  }
126
 
127
+ private function are_rules_present( $c ) {
128
+ $e = $c->get_boolean( 'pgcache.enabled' );
129
+
130
+ return ( $e == 'file_generic' || $e == 'nginx_memcached' );
131
+ }
132
+
133
  /**
134
  * Returns required rules for module
135
  *
137
  * @return array
138
  */
139
  public function get_required_rules( $config ) {
140
+ if ( !$this->are_rules_present( $config ) ) {
 
141
  return null;
142
+ }
143
 
144
  $rewrite_rules = array();
145
  $pgcache_rules_core_path = Util_Rule::get_pgcache_rules_core_path();
548
  'wp-postpass'
549
  );
550
 
551
+ $reject_cookies[] = 'w3tc_logged_out';
 
 
552
 
553
  /**
554
  * Reject cache for logged in users
746
  /**
747
  * Set Accept-Encoding
748
  */
749
+ if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.html.brotli' ) ) {
750
+ $rules .= " RewriteCond %{HTTP:Accept-Encoding} br\n";
751
+ $rules .= " RewriteRule .* - [E=W3TC_ENC:_br]\n";
752
+ $env_W3TC_ENC = '%{ENV:W3TC_ENC}';
753
+ } else if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.html.compression' ) ) {
754
  $rules .= " RewriteCond %{HTTP:Accept-Encoding} gzip\n";
755
  $rules .= " RewriteRule .* - [E=W3TC_ENC:_gzip]\n";
756
  $env_W3TC_ENC = '%{ENV:W3TC_ENC}';
835
 
836
  $cache_dir = Util_Environment::normalize_path( W3TC_CACHE_PAGE_ENHANCED_DIR );
837
  $permalink_structure = get_option( 'permalink_structure' );
838
+ $pgcache_engine = $config->get_string( 'pgcache.engine' );
839
 
840
  /**
841
  * Auto reject cookies
845
  'wp-postpass'
846
  );
847
 
848
+ if ( $pgcache_engine == 'file_generic' ) {
849
  $reject_cookies[] = 'w3tc_logged_out';
850
  }
851
 
889
  $env_w3tc_ssl = '';
890
  $env_w3tc_ext = '';
891
  $env_w3tc_enc = '';
892
+ $env_request_uri = '$request_uri';
893
 
894
  $rules = '';
895
  $rules .= W3TC_MARKER_BEGIN_PGCACHE_CORE . "\n";
910
  $rules .= "set \$w3tc_query_string \$query_string;\n";
911
 
912
  foreach ( $w3tc_query_strings as $query ) {
913
+ $query .= ( strpos( $query, '=' ) === false ? '=.*?' : '' );
914
+ $rules .= "if (\$w3tc_query_string ~* \"^(.*?&|)" . $query . "(&.*|)$\") {\n";
915
  $rules .= " set \$w3tc_query_string $1$2;\n";
916
  $rules .= "}\n";
917
  }
918
 
919
+ $rules .= "if (\$w3tc_query_string ~ ^[?&]+$) {\n";
920
  $rules .= " set \$w3tc_query_string \"\";\n";
921
  $rules .= "}\n";
922
+
923
+ $rules .= "set \$w3tc_request_uri \$request_uri;\n";
924
+ $rules .= "if (\$w3tc_request_uri ~* \"^([^?]+)\?\") {\n";
925
+ $rules .= " set \$w3tc_request_uri \$1;\n";
926
+ $rules .= "}\n";
927
+ $env_request_uri = '$w3tc_request_uri';
928
  }
929
 
930
  /**
994
 
995
  /**
996
  * Check permalink structure trailing slash
997
+ * and allow WordPress to redirect for non-slash URIs
998
  */
999
+ if ( $pgcache_engine == 'file_generic' ) {
1000
+ if ( substr( $permalink_structure, -1 ) == '/' ) {
1001
+ $rules .= "if ($env_request_uri !~ \\/$) {\n";
1002
+ $rules .= " set \$w3tc_rewrite 0;\n";
1003
+ $rules .= "}\n";
1004
+ }
1005
  }
1006
 
1007
  /**
1140
  $rules .= " set \$w3tc_ssl _ssl;\n";
1141
  $rules .= "}\n";
1142
 
1143
+ $env_w3tc_ssl = '$w3tc_ssl';
1144
+ }
1145
+
1146
+ if ( $config->get_boolean( 'browsercache.enabled' ) &&
1147
+ $config->get_boolean( 'browsercache.html.brotli' ) ) {
1148
+ $rules .= "set \$w3tc_enc \"\";\n";
1149
+
1150
+ $rules .= "if (\$http_accept_encoding ~ br) {\n";
1151
+ $rules .= " set \$w3tc_enc _br;\n";
1152
+ $rules .= "}\n";
1153
+
1154
+ $env_w3tc_enc = '$w3tc_enc';
1155
  }
1156
 
1157
  if ( $config->get_boolean( 'browsercache.enabled' ) &&
1162
  $rules .= " set \$w3tc_enc _gzip;\n";
1163
  $rules .= "}\n";
1164
 
1165
+ $env_w3tc_enc = '$w3tc_enc';
1166
  }
1167
 
1168
+ $key_postfix = $env_w3tc_ua . $env_w3tc_ref . $env_w3tc_cookie .
1169
+ $env_w3tc_ssl . $env_w3tc_preview;
1170
+
1171
+ if ( $pgcache_engine == 'file_generic' ) {
1172
+ $rules .= $this->for_file_generic( $config, $cache_dir,
1173
+ $env_request_uri, $key_postfix, $env_w3tc_enc );
1174
+ } elseif ( $pgcache_engine == 'nginx_memcached' ) {
1175
+ $rules .= $this->for_nginx_memcached( $config, $cache_dir,
1176
+ $env_request_uri, $key_postfix, $env_w3tc_enc );
1177
+ }
1178
+
1179
+ $rules .= W3TC_MARKER_END_PGCACHE_CORE . "\n";
1180
+
1181
+ return $rules;
1182
+ }
1183
+
1184
+
1185
+
1186
+ private function for_file_generic( $config, $cache_dir, $env_request_uri,
1187
+ $key_postfix, $env_w3tc_enc ) {
1188
+ $rules = '';
1189
+
1190
+ $cache_path = str_replace( Util_Environment::document_root(), '',
1191
+ $cache_dir );
1192
+ $uri_prefix = $cache_path . "/\$http_host/$env_request_uri/_index" .
1193
+ $key_postfix;
1194
 
1195
  if ( !$config->get_boolean( 'pgcache.cache.nginx_handle_xml' ) ) {
1196
  $env_w3tc_ext = '.html';
1197
 
1198
+ $rules .= 'if (!-f "$document_root' . $uri_prefix . '.html' .
1199
+ $env_w3tc_enc . '") {' . "\n";
1200
+ $rules .= ' set $w3tc_rewrite 0;' . "\n";
1201
  $rules .= "}\n";
1202
  } else {
1203
+ $env_w3tc_ext = '$w3tc_ext';
1204
 
1205
+ $rules .= 'set $w3tc_ext "";' . "\n";
1206
+ $rules .= 'if (-f "$document_root' . $uri_prefix . '.html' .
1207
+ $env_w3tc_enc . '") {' . "\n";
1208
+ $rules .= ' set $w3tc_ext .html;' . "\n";
1209
  $rules .= "}\n";
1210
 
1211
+ $rules .= 'if (-f "$document_root' . $uri_prefix . '.xml' .
1212
+ $env_w3tc_enc . '") {' . "\n";
1213
+ $rules .= ' set $w3tc_ext .xml;' . "\n";
1214
  $rules .= "}\n";
1215
 
1216
+ $rules .= 'if ($w3tc_ext = "") {' . "\n";
1217
+ $rules .= ' set $w3tc_rewrite 0;' . "\n";
1218
  $rules .= "}\n";
1219
  }
1220
 
1221
+ $rules .= 'if ($w3tc_rewrite = 1) {' . "\n";
1222
+ $rules .= ' rewrite .* "' . $uri_prefix . $env_w3tc_ext . $env_w3tc_enc .
1223
+ '" last;' . "\n";
1224
+ $rules .= "}\n";
1225
+
1226
+ return $rules;
1227
+ }
1228
+
1229
+
1230
+
1231
+ private function for_nginx_memcached( $config, $cache_dir, $env_request_uri,
1232
+ $key_postfix, $env_w3tc_enc ) {
1233
+ $rules = "set \$request_uri_noslash $env_request_uri;\n";
1234
+ $rules .= "if ($env_request_uri ~ \"(.*?)(/+)$\") {\n";
1235
+ $rules .= ' set $request_uri_noslash $1;' . "\n";
1236
+ $rules .= "}\n";
1237
+
1238
+ $cache_path = str_replace( Util_Environment::document_root(), '',
1239
+ $cache_dir );
1240
+
1241
+ $rules .= 'location ~ ".*(?<!php)$" {' . "\n";
1242
+ $rules .= ' set $memcached_key "$http_host$request_uri_noslash/' .
1243
+ $key_postfix . $env_w3tc_enc . '";' . "\n";
1244
+
1245
+ if ( $config->get_boolean( 'browsercache.enabled' ) &&
1246
+ $config->get_boolean( 'browsercache.html.compression' ) ) {
1247
+ $rules .= ' memcached_gzip_flag 65536;' . "\n";
1248
+ }
1249
+
1250
+ $rules .= ' default_type text/html;' . "\n";
1251
+ $rules .= ' if ($w3tc_rewrite = 1) {' . "\n";
1252
+ $rules .= ' memcached_pass localhost:11211;' . "\n";
1253
+ $rules .= " }\n";
1254
+ $rules .= ' error_page 404 502 504 = @fallback;' . "\n";
1255
+ $rules .= "}\n";
1256
+
1257
+ $rules .= 'location @fallback {' . "\n";
1258
+ $rules .= ' try_files $uri $uri/ $uri.html /index.php?$args;' . "\n";
1259
  $rules .= "}\n";
 
1260
 
1261
  return $rules;
1262
  }
1339
  $pingback_url = get_bloginfo( 'pingback_url' );
1340
 
1341
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
1342
+ $brotli = ( $browsercache && $config->get_boolean( 'browsercache.html.brotli' ) );
1343
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.html.compression' ) );
1344
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.html.expires' ) );
1345
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.html.lifetime' ) : 0 );
1354
  $rules .= "Options -MultiViews\n";
1355
 
1356
  // allow to read files by apache if they are blocked at some level above
1357
+ $rules .= "<Files ~ \"\.(html|html_gzip|html_br|xml|xml_gzip|xml_br)$\">\n";
1358
 
1359
  if ( version_compare( Util_Environment::get_server_version(), '2.4', '>=' ) ) {
1360
  $rules .= " Require all granted\n";
1381
  $rules .= "FileETag MTime Size\n";
1382
  }
1383
 
1384
+ if ( $brotli ) {
1385
+ $rules .= "<IfModule mod_mime.c>\n";
1386
+ $rules .= " AddType text/html .html_br\n";
1387
+ $rules .= " AddEncoding br .html_br\n";
1388
+ $rules .= " AddType text/xml .xml_br\n";
1389
+ $rules .= " AddEncoding br .xml_br\n";
1390
+ $rules .= "</IfModule>\n";
1391
+ $rules .= "<IfModule mod_setenvif.c>\n";
1392
+ $rules .= " SetEnvIfNoCase Request_URI \\.html_br$ no-brotli\n";
1393
+ $rules .= " SetEnvIfNoCase Request_URI \\.xml_br$ no-brotli\n";
1394
+ $rules .= "</IfModule>\n";
1395
+ }
1396
+
1397
  if ( $compression ) {
1398
  $rules .= "<IfModule mod_mime.c>\n";
1399
  $rules .= " AddType text/html .html_gzip\n";
1499
  * @return string
1500
  */
1501
  private function rules_cache_generate_nginx( $config ) {
1502
+ if ( $config->get_string( 'pgcache.engine') != 'file_generic' ) {
1503
+ return '';
1504
+ }
1505
+
1506
  $cache_root = Util_Environment::normalize_path( W3TC_CACHE_PAGE_ENHANCED_DIR );
1507
  $cache_dir = rtrim( str_replace( Util_Environment::document_root(), '', $cache_root ), '/' );
1508
 
1511
  }
1512
 
1513
  $browsercache = $config->get_boolean( 'browsercache.enabled' );
1514
+ $brotli = ( $browsercache && $config->get_boolean( 'browsercache.html.brotli' ) );
1515
  $compression = ( $browsercache && $config->get_boolean( 'browsercache.html.compression' ) );
1516
  $expires = ( $browsercache && $config->get_boolean( 'browsercache.html.expires' ) );
1517
  $lifetime = ( $browsercache ? $config->get_integer( 'browsercache.html.lifetime' ) : 0 );
1548
 
1549
  case 'cache_public_maxage':
1550
  $common_rules .= " add_header Pragma \"public\";\n";
1551
+
1552
+ if ( $expires ) {
1553
+ $common_rules .= " add_header Cache-Control \"public\";\n";
1554
+ } else {
1555
+ $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
1556
+ }
1557
  break;
1558
 
1559
  case 'cache_validation':
1568
 
1569
  case 'cache_maxage':
1570
  $common_rules .= " add_header Pragma \"public\";\n";
1571
+
1572
+ if ( $expires ) {
1573
+ $common_rules .= " add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\n";
1574
+ } else {
1575
+ $common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
1576
+ }
1577
  break;
1578
 
1579
  case 'no_cache':
1592
  $rules .= "}\n";
1593
  }
1594
 
1595
+ if ( $brotli ) {
1596
+ $maybe_xml = '';
1597
+ if ($config->get_boolean('pgcache.cache.nginx_handle_xml')) {
1598
+ $maybe_xml = "\n" .
1599
+ " text/xml xml_br;\n" .
1600
+ " ";
1601
+ }
1602
+
1603
+ $rules .= "location ~ " . $cache_dir . ".*br$ {\n";
1604
+ $rules .= " brotli off;\n";
1605
+ $rules .= " types {" . $maybe_xml . "}\n";
1606
+ $rules .= " default_type text/html;\n";
1607
+ $rules .= $common_rules;
1608
+ $rules .= " add_header Content-Encoding br;\n";
1609
+ $rules .= "}\n";
1610
+ }
1611
+
1612
  if ( $compression ) {
1613
  $maybe_xml = '';
1614
  if ($config->get_boolean('pgcache.cache.nginx_handle_xml')) {
PgCache_Page_CookieGroups_View.js CHANGED
@@ -70,7 +70,7 @@ jQuery('#w3tc_cookiegroup_add').click(function() {
70
  }
71
  });
72
 
73
- jQuery('.w3tc_cookiegroup_delete').live('click', function() {
74
  if (confirm('Are you sure want to delete this group?')) {
75
  jQuery(this).parents('#cookiegroups li').remove();
76
  w3tc_cookiegroups_clear();
70
  }
71
  });
72
 
73
+ jQuery('.w3tc_cookiegroup_delete').on('click', function () {
74
  if (confirm('Are you sure want to delete this group?')) {
75
  jQuery(this).parents('#cookiegroups li').remove();
76
  w3tc_cookiegroups_clear();
PgCache_Plugin.php CHANGED
@@ -133,7 +133,6 @@ class PgCache_Plugin {
133
  /**
134
  * Prime cache
135
  *
136
- * @param integer $start
137
  * @return void
138
  */
139
  function prime() {
133
  /**
134
  * Prime cache
135
  *
 
136
  * @return void
137
  */
138
  function prime() {
Root_Loader.php CHANGED
@@ -55,8 +55,7 @@ class Root_Loader {
55
  $plugins[] = new Cdn_Plugin_Admin();
56
  $plugins[] = new Cdnfsd_Plugin_Admin();
57
  $cdn_engine = $c->get_string( 'cdn.engine' );
58
- if ( $cdn_engine == 'highwinds' || $cdn_engine == 'stackpath' ) {
59
- } else {
60
  $plugins[] = new Cdn_Plugin_WidgetMaxCdn();
61
  }
62
 
@@ -64,9 +63,7 @@ class Root_Loader {
64
  $plugins[] = new PageSpeed_Plugin_Widget();
65
 
66
  $plugins[] = new Generic_Plugin_AdminCompatibility();
67
-
68
- if ( !( defined( 'W3TC_PRO' ) || defined( 'W3TC_ENTERPRISE' ) ) )
69
- $plugins[] = new Licensing_Plugin_Admin();
70
 
71
  if ( $c->get_boolean( 'pgcache.enabled' ) ||
72
  $c->get_boolean( 'varnish.enabled' ) )
55
  $plugins[] = new Cdn_Plugin_Admin();
56
  $plugins[] = new Cdnfsd_Plugin_Admin();
57
  $cdn_engine = $c->get_string( 'cdn.engine' );
58
+ if ( $cdn_engine == 'maxcdn' ) {
 
59
  $plugins[] = new Cdn_Plugin_WidgetMaxCdn();
60
  }
61
 
63
  $plugins[] = new PageSpeed_Plugin_Widget();
64
 
65
  $plugins[] = new Generic_Plugin_AdminCompatibility();
66
+ $plugins[] = new Licensing_Plugin_Admin();
 
 
67
 
68
  if ( $c->get_boolean( 'pgcache.enabled' ) ||
69
  $c->get_boolean( 'varnish.enabled' ) )
Support_Page.php CHANGED
@@ -70,6 +70,10 @@ class Support_Page {
70
  if ( $p != 'page' && $p != '_wpnonce' && $p != 'done' )
71
  $postprocess_url .= '&' . urlencode( $p ) . '=' . urlencode( $v );
72
  }
 
 
 
 
73
  include W3TC_DIR . '/Support_Page_View_DoneContent.php';
74
  } else
75
  include W3TC_DIR . '/Support_Page_View_PageContent.php';
70
  if ( $p != 'page' && $p != '_wpnonce' && $p != 'done' )
71
  $postprocess_url .= '&' . urlencode( $p ) . '=' . urlencode( $v );
72
  }
73
+
74
+ // terms accepted as a part of form
75
+ Licensing_Core::terms_accept();
76
+
77
  include W3TC_DIR . '/Support_Page_View_DoneContent.php';
78
  } else
79
  include W3TC_DIR . '/Support_Page_View_PageContent.php';
UsageStatistics_Widget.php CHANGED
@@ -22,7 +22,7 @@ class UsageStatistics_Widget {
22
  add_action( 'w3tc_widget_setup', array(
23
  $this,
24
  'w3tc_widget_setup'
25
- ), 300 );
26
  add_action( 'w3tc_ajax_ustats_get', array( $this, 'w3tc_ajax_ustats_get' ) );
27
  }
28
 
22
  add_action( 'w3tc_widget_setup', array(
23
  $this,
24
  'w3tc_widget_setup'
25
+ ), 1000 );
26
  add_action( 'w3tc_ajax_ustats_get', array( $this, 'w3tc_ajax_ustats_get' ) );
27
  }
28
 
Util_Admin.php CHANGED
@@ -761,16 +761,6 @@ class Util_Admin {
761
  }
762
 
763
 
764
- static public function make_track_call( $params ) {
765
- wp_remote_post( W3TC_TRACK_URL, array(
766
- 'timeout' => 45,
767
- 'redirection' => 5,
768
- 'blocking' => false,
769
- 'headers' => array(),
770
- 'body' => array_merge( $params, array( 'id' => md5( home_url() ) ) )
771
- ) );
772
- }
773
-
774
  /**
775
  * Returns current WordPress page
776
  *
761
  }
762
 
763
 
 
 
 
 
 
 
 
 
 
 
764
  /**
765
  * Returns current WordPress page
766
  *
Util_Http.php CHANGED
@@ -61,12 +61,12 @@ class Util_Http {
61
  * @param string $file
62
  * @return boolean
63
  */
64
- static public function download( $url, $file ) {
65
  if ( strpos( $url, '//' ) === 0 ) {
66
  $url = ( Util_Environment::is_https() ? 'https:' : 'http:' ) . $url;
67
  }
68
 
69
- $response = self::get( $url );
70
 
71
  if ( !is_wp_error( $response ) && $response['response']['code'] == 200 ) {
72
  return @file_put_contents( $file, $response['body'] );
61
  * @param string $file
62
  * @return boolean
63
  */
64
+ static public function download( $url, $file, $args = array() ) {
65
  if ( strpos( $url, '//' ) === 0 ) {
66
  $url = ( Util_Environment::is_https() ? 'https:' : 'http:' ) . $url;
67
  }
68
 
69
+ $response = self::get( $url, $args );
70
 
71
  if ( !is_wp_error( $response ) && $response['response']['code'] == 200 ) {
72
  return @file_put_contents( $file, $response['body'] );
Util_Installed.php CHANGED
@@ -50,8 +50,7 @@ class Util_Installed {
50
  $r = false;
51
  else {
52
  $o = new \Memcached();
53
- $r = ( method_exists( $o, 'setSaslAuthData' ) &&
54
- ini_get( 'memcached.use_sasl' ) );
55
  }
56
  }
57
 
@@ -66,6 +65,12 @@ class Util_Installed {
66
 
67
 
68
 
 
 
 
 
 
 
69
  static public function memcached_aws() {
70
  return class_exists( '\Memcached' ) &&
71
  defined( '\Memcached::OPT_CLIENT_MODE' ) &&
@@ -81,8 +86,7 @@ class Util_Installed {
81
  $r = false;
82
  else {
83
  $o = new \Memcached();
84
- $r = ( method_exists( $o, 'setSaslAuthData' ) &&
85
- ini_get( 'memcached.use_sasl' ) );
86
  }
87
  }
88
 
50
  $r = false;
51
  else {
52
  $o = new \Memcached();
53
+ $r = method_exists( $o, 'setSaslAuthData' );
 
54
  }
55
  }
56
 
65
 
66
 
67
 
68
+ static public function memcached_memcached() {
69
+ return class_exists( 'Memcached' );
70
+ }
71
+
72
+
73
+
74
  static public function memcached_aws() {
75
  return class_exists( '\Memcached' ) &&
76
  defined( '\Memcached::OPT_CLIENT_MODE' ) &&
86
  $r = false;
87
  else {
88
  $o = new \Memcached();
89
+ $r = method_exists( $o, 'setSaslAuthData' );
 
90
  }
91
  }
92
 
Util_Ui.php CHANGED
@@ -184,21 +184,21 @@ class Util_Ui {
184
  $b2_id = 'w3tc_default_save_and_flush_' . $id;
185
 
186
  ?>
187
- <p class="submit">
188
- <?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
189
- <input type="submit" id="<?php echo $b1_id ?>"
190
- name="w3tc_save_options"
191
- class="w3tc-button-save button-primary"
192
- value="<?php _e( 'Save all settings', 'w3-total-cache' ); ?>" />
193
- <?php echo $extra ?>
194
- <?php if ( !is_network_admin() ): ?>
195
- <input type="submit" id="<?php echo $b2_id ?>"
196
- name="w3tc_default_save_and_flush" style="float: right"
197
- class="w3tc-button-save button-primary"
198
- value="<?php _e( 'Save Settings & Purge Caches', 'w3-total-cache' ); ?>" />
199
- <?php endif ?>
200
- </p>
201
- <?php
202
  }
203
 
204
  static public function sealing_disabled( $key ) {
@@ -304,7 +304,7 @@ class Util_Ui {
304
  }
305
 
306
  /**
307
- * Echos an input text element
308
  *
309
  * @param string $id
310
  * @param string $name
@@ -312,12 +312,25 @@ class Util_Ui {
312
  * @param bool $disabled
313
  * @param int $size
314
  */
315
- static public function hidden( $id, $name, $value ) {
316
- echo '<input type="hidden" id="' . esc_attr( $id ) .
317
  '" name="' . esc_attr( $name ) .
318
  '" value="' . esc_attr( $value ) . '" />';
319
  }
320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  /**
322
  * Echos an label element
323
  *
@@ -472,10 +485,10 @@ class Util_Ui {
472
  * @param bool $disabled
473
  */
474
  static public function textarea( $id, $name, $value, $disabled = false ) {?>
475
- <textarea class="enabled" id="<?php echo esc_attr( $id )?>"
476
- name="<?php echo esc_attr( $name )?>" rows="5" cols=25 style="width: 100%"
477
- <?php disabled( $disabled ) ?>><?php echo esc_textarea( $value )?></textarea>
478
- <?php
479
  }
480
 
481
  /**
@@ -855,9 +868,9 @@ class Util_Ui {
855
 
856
 
857
  /*
858
- * Converts configuration key returned in http _GET/_POST
859
- * to configuration key
860
- */
861
  static public function config_key_from_http_name( $http_key ) {
862
  $a = explode( '___', $http_key );
863
  if ( count( $a ) == 2 ) {
184
  $b2_id = 'w3tc_default_save_and_flush_' . $id;
185
 
186
  ?>
187
+ <p class="submit">
188
+ <?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
189
+ <input type="submit" id="<?php echo $b1_id ?>"
190
+ name="w3tc_save_options"
191
+ class="w3tc-button-save button-primary"
192
+ value="<?php _e( 'Save all settings', 'w3-total-cache' ); ?>" />
193
+ <?php echo $extra ?>
194
+ <?php if ( !is_network_admin() ): ?>
195
+ <input type="submit" id="<?php echo $b2_id ?>"
196
+ name="w3tc_default_save_and_flush" style="float: right"
197
+ class="w3tc-button-save button-primary"
198
+ value="<?php _e( 'Save Settings & Purge Caches', 'w3-total-cache' ); ?>" />
199
+ <?php endif ?>
200
+ </p>
201
+ <?php
202
  }
203
 
204
  static public function sealing_disabled( $key ) {
304
  }
305
 
306
  /**
307
+ * Returns an input text element
308
  *
309
  * @param string $id
310
  * @param string $name
312
  * @param bool $disabled
313
  * @param int $size
314
  */
315
+ static public function r_hidden( $id, $name, $value ) {
316
+ return '<input type="hidden" id="' . esc_attr( $id ) .
317
  '" name="' . esc_attr( $name ) .
318
  '" value="' . esc_attr( $value ) . '" />';
319
  }
320
 
321
+ /**
322
+ * Echos an input text element
323
+ *
324
+ * @param string $id
325
+ * @param string $name
326
+ * @param string $value
327
+ * @param bool $disabled
328
+ * @param int $size
329
+ */
330
+ static public function hidden( $id, $name, $value ) {
331
+ echo self::r_hidden( $id, $name, $value );
332
+ }
333
+
334
  /**
335
  * Echos an label element
336
  *
485
  * @param bool $disabled
486
  */
487
  static public function textarea( $id, $name, $value, $disabled = false ) {?>
488
+ <textarea class="enabled" id="<?php echo esc_attr( $id )?>"
489
+ name="<?php echo esc_attr( $name )?>" rows="5" cols=25 style="width: 100%"
490
+ <?php disabled( $disabled ) ?>><?php echo esc_textarea( $value )?></textarea>
491
+ <?php
492
  }
493
 
494
  /**
868
 
869
 
870
  /*
871
+ * Converts configuration key returned in http _GET/_POST
872
+ * to configuration key
873
+ */
874
  static public function config_key_from_http_name( $http_key ) {
875
  $a = explode( '___', $http_key );
876
  if ( count( $a ) == 2 ) {
inc/lightbox/purchase.php CHANGED
@@ -1,4 +1,4 @@
1
  <div style="min-height:400px;height:100%;margin-top:15px;">
2
- <iframe id="buy_frame" name="buy_frame" src="<?php echo EDD_W3EDGE_STORE_URL_PLUGIN ?>" style="height:90%;width:100%" scrolling="auto">
3
  </iframe>
4
  </div>
1
  <div style="min-height:400px;height:100%;margin-top:15px;">
2
+ <iframe id="buy_frame" name="buy_frame" src="<?php echo $iframe_url ?>" style="height:90%;width:100%" scrolling="auto">
3
  </iframe>
4
  </div>
inc/lightbox/self_test.php CHANGED
@@ -84,7 +84,17 @@ if ( !defined( 'W3TC' ) )
84
  <?php else: ?>
85
  <span style="background-color: #FFFF00"><?php _e( 'Not installed', 'w3-total-cache' ); ?></span>
86
  <?php endif; ?>
87
- <span class="w3tc-self-test-hint"><?php _e( '(required for compression support)', 'w3-total-cache' ); ?></span>
 
 
 
 
 
 
 
 
 
 
88
  </li>
89
 
90
  <li>
@@ -192,6 +202,16 @@ if ( !defined( 'W3TC' ) )
192
  <?php endif; ?>
193
  </li>
194
 
 
 
 
 
 
 
 
 
 
 
195
  <?php
196
  if ( Util_Environment::is_apache() ):
197
  $apache_modules = ( function_exists( 'apache_get_modules' ) ? apache_get_modules() : false );
84
  <?php else: ?>
85
  <span style="background-color: #FFFF00"><?php _e( 'Not installed', 'w3-total-cache' ); ?></span>
86
  <?php endif; ?>
87
+ <span class="w3tc-self-test-hint"><?php _e( '(required for gzip compression support)', 'w3-total-cache' ); ?></span>
88
+ </li>
89
+
90
+ <li>
91
+ brotli extension:
92
+ <?php if ( function_exists( 'brotli_compress' ) ): ?>
93
+ <span style="background-color: #33cc33"><?php _e( 'Installed', 'w3-total-cache' ); ?></span>
94
+ <?php else: ?>
95
+ <span style="background-color: #FFFF00"><?php _e( 'Not installed', 'w3-total-cache' ); ?></span>
96
+ <?php endif; ?>
97
+ <span class="w3tc-self-test-hint"><?php _e( '(required for brotli compression support)', 'w3-total-cache' ); ?></span>
98
  </li>
99
 
100
  <li>
202
  <?php endif; ?>
203
  </li>
204
 
205
+ <li>
206
+ SSH2 extension:
207
+ <?php if ( function_exists( 'ssh2_connect' ) ): ?>
208
+ <span style="background-color: #33cc33"><?php _e( 'Installed', 'w3-total-cache' ); ?></span>
209
+ <?php else: ?>
210
+ <span style="background-color: #FFFF00"><?php _e( 'Not installed', 'w3-total-cache' ); ?></span>
211
+ <?php endif; ?>
212
+ <span class="w3tc-self-test-hint"><?php _e( '(required for Self-hosted (<acronym title="File Transfer Protocol">FTP</acronym>) <acronym title="Content Delivery Network">CDN</acronym> <acronym title="Secure File Transfer Protocol">SFTP</acronym> support)', 'w3-total-cache' ); ?></span>
213
+ </li>
214
+
215
  <?php
216
  if ( Util_Environment::is_apache() ):
217
  $apache_modules = ( function_exists( 'apache_get_modules' ) ? apache_get_modules() : false );
inc/lightbox/support_us.php CHANGED
@@ -4,6 +4,8 @@ namespace W3TC;
4
  if ( !defined( 'W3TC' ) )
5
  die();
6
 
 
 
7
  ?>
8
  <div id="w3tc-support-us">
9
  <div class="w3tc-overlay-logo"></div>
@@ -85,13 +87,15 @@ echo Util_Ui::hidden(
85
  <input id="email" name="email" type="text" class="form-control w3tc-size" value="<?php esc_attr_e( $email ) ?>"></label><br />
86
  <input type="checkbox" name="signmeup" id="signmeup" class="css-checkbox" value="1" checked="checked" /><label for="signmeup" class="css-label"> <?php _e( 'Yes, sign me up.', 'w3-total-cache' ) ?> </label>
87
  </p>
88
- <p>
89
- <input type="checkbox" name="track_usage" id="track_usage" class="css-checkbox" value="1"
90
- checked="checked" />
91
- <label for="track_usage" class="css-label">
92
- <?php _e( 'Anonymously track usage to improve product quality.', 'w3-total-cache' ) ?>
93
- </label>
94
- </p>
 
 
95
  </div>
96
  <div class="w3tc_overlay_footer">
97
  <p>
4
  if ( !defined( 'W3TC' ) )
5
  die();
6
 
7
+ $state_master = Dispatcher::config_state_master();
8
+
9
  ?>
10
  <div id="w3tc-support-us">
11
  <div class="w3tc-overlay-logo"></div>
87
  <input id="email" name="email" type="text" class="form-control w3tc-size" value="<?php esc_attr_e( $email ) ?>"></label><br />
88
  <input type="checkbox" name="signmeup" id="signmeup" class="css-checkbox" value="1" checked="checked" /><label for="signmeup" class="css-label"> <?php _e( 'Yes, sign me up.', 'w3-total-cache' ) ?> </label>
89
  </p>
90
+ <?php if ( $state_master->get( 'license.community_terms' ) != 'accept' ): ?>
91
+ <p>
92
+ <input type="checkbox" name="accept_terms" id="accept_terms" class="css-checkbox" value="1"
93
+ />
94
+ <label for="accept_terms" class="css-label">
95
+ <?php sprintf( _e( 'Please review the latest <a href="%s" target="blank">terms of use and privacy policy</a>, and accept them.', 'w3-total-cache' ), W3TC_TERMS_URL ) ?>
96
+ </label>
97
+ </p>
98
+ <?php endif ?>
99
  </div>
100
  <div class="w3tc_overlay_footer">
101
  <p>
inc/lightbox/upgrade.php CHANGED
@@ -23,17 +23,17 @@ if ( !defined( 'W3TC' ) )
23
  </div>
24
  <div class="w3tc_overlay_upgrade_content_r">
25
  <ul>
26
- <li>
27
- <strong>Extension</strong><br>
28
- Improve the performance of your Genesis, WPML-powered site, and much more by unlocking W3TC Pro.</li>
29
  <li>
30
  <strong>Full Site Delivery (FSD)</strong><br>
31
  Provide the best user experience possible by enhancing by hosting HTML pages and RSS feeds with (supported) <acronym title="Content Delivery Network">CDN</acronym>'s high speed global networks.</li>
32
  <li>
33
- <strong>REST API Caching</strong><br>
34
- Save resources or add scale and performance to the WordPress API with W3TC Pro.</li>
 
 
 
35
  <li><strong>Fragment Caching</strong><br>
36
- Unlocking the fragment caching module delivers enhanced performance for plugins and themes that use the WordPress Transient API. StudioPress' Genesis Framework is up to 60% faster with W3TC Pro.</li>
37
  </ul>
38
  </div>
39
  </div>
23
  </div>
24
  <div class="w3tc_overlay_upgrade_content_r">
25
  <ul>
 
 
 
26
  <li>
27
  <strong>Full Site Delivery (FSD)</strong><br>
28
  Provide the best user experience possible by enhancing by hosting HTML pages and RSS feeds with (supported) <acronym title="Content Delivery Network">CDN</acronym>'s high speed global networks.</li>
29
  <li>
30
+ <strong>Extensions Support</strong><br>
31
+ Add accelerated mobile pages (<acronym title="Accelerated Mobile Pages">AMP</acronym>) support. Improve the performance of your Genesis, WPML-powered site, and much more.</li>
32
+ <li>
33
+ <strong><acronym title="Representational State Transfer">REST</acronym> <acronym title="Application Programming Interface">API</acronym> Caching</strong><br>
34
+ Save resources or add scale and performance to the WordPress <acronym title="Application Programming Interface">API</acronym> with W3TC Pro.</li>
35
  <li><strong>Fragment Caching</strong><br>
36
+ Unlocking the fragment caching module delivers enhanced performance for plugins and themes that use the WordPress Transient <acronym title="Application Programming Interface">API</acronym>. StudioPress' Genesis Framework is up to 60% faster with W3TC Pro.</li>
37
  </ul>
38
  </div>
39
  </div>
inc/mime/all.php CHANGED
@@ -562,6 +562,7 @@ return array(
562
  'wbmp' => 'image/vnd.wap.wbmp',
563
  'wbs' => 'application/vnd.criticaltools.wbs+xml',
564
  'wbxml' => 'application/vnd.wap.wbxml',
 
565
  'webp' => 'image/webp',
566
  'wm' => 'video/x-ms-wm',
567
  'wma' => 'audio/x-ms-wma',
562
  'wbmp' => 'image/vnd.wap.wbmp',
563
  'wbs' => 'application/vnd.criticaltools.wbs+xml',
564
  'wbxml' => 'application/vnd.wap.wbxml',
565
+ 'webm' => 'video/webm',
566
  'webp' => 'image/webp',
567
  'wm' => 'video/x-ms-wm',
568
  'wma' => 'audio/x-ms-wma',
inc/mime/other.php CHANGED
@@ -24,6 +24,7 @@ return array(
24
  'mp3|m4a' => 'audio/mpeg',
25
  'mp4|m4v' => 'video/mp4',
26
  'mpeg|mpg|mpe' => 'video/mpeg',
 
27
  'mpp' => 'application/vnd.ms-project',
28
  'otf' => 'application/x-font-otf',
29
  '_otf' => 'application/vnd.ms-opentype',
24
  'mp3|m4a' => 'audio/mpeg',
25
  'mp4|m4v' => 'video/mp4',
26
  'mpeg|mpg|mpe' => 'video/mpeg',
27
+ 'webm' => 'video/webm',
28
  'mpp' => 'application/vnd.ms-project',
29
  'otf' => 'application/x-font-otf',
30
  '_otf' => 'application/vnd.ms-opentype',
inc/options/browsercache.php CHANGED
@@ -5,7 +5,7 @@ if ( !defined( 'W3TC' ) )
5
  die();
6
 
7
  $security_session_values = array(
8
- '' => 'Leave as is',
9
  'on' => 'Enable',
10
  'off' => 'Disable'
11
  );
@@ -32,7 +32,6 @@ $security_session_values = array(
32
  <?php Util_Ui::postbox_header( __( 'General', 'w3-total-cache' ), '', 'general' ); ?>
33
  <p><?php _e( 'Specify global browser cache policy.', 'w3-total-cache' ) ?></p>
34
  <table class="form-table">
35
- <?php if ( !Util_Environment::is_nginx() ): ?>
36
  <tr>
37
  <th colspan="2">
38
  <label>
@@ -42,7 +41,6 @@ $security_session_values = array(
42
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
43
  </th>
44
  </tr>
45
- <?php endif; ?>
46
  <tr>
47
  <th colspan="2">
48
  <label>
@@ -82,6 +80,15 @@ $security_session_values = array(
82
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
83
  </th>
84
  </tr>
 
 
 
 
 
 
 
 
 
85
  <tr>
86
  <th colspan="2">
87
  <label><input id="browsercache_replace" type="checkbox"
@@ -95,7 +102,7 @@ $security_session_values = array(
95
  <label><input id="browsercache_querystring" type="checkbox"
96
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
97
  name="querystring" value="1"<?php checked( $browsercache_querystring, true ); ?> /> <?php _e( 'Remove query strings from static resources', 'w3-total-cache' ); ?></label>
98
- <br /><span class="description"><?php _e( 'Resources with a "?" in the URL are not cached by some proxy caching servers.', 'w3-total-cache' ); ?></span>
99
  </th>
100
  </tr>
101
  <tr>
@@ -150,14 +157,12 @@ Util_Ui::config_item( array(
150
  <p><?php _e( 'Specify browser cache policy for Cascading Style Sheets and JavaScript files.', 'w3-total-cache' ); ?></p>
151
 
152
  <table class="form-table">
153
- <?php if ( !Util_Environment::is_nginx() ): ?>
154
  <tr>
155
  <th colspan="2">
156
  <?php $this->checkbox( 'browsercache.cssjs.last_modified' ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.last_modified' ) ?></label>
157
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
158
  </th>
159
  </tr>
160
- <?php endif; ?>
161
  <tr>
162
  <th colspan="2">
163
  <?php $this->checkbox( 'browsercache.cssjs.expires' ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.expires' ) ?></label>
@@ -188,14 +193,20 @@ Util_Ui::config_item( array(
188
  <select id="browsercache_cssjs_cache_policy"
189
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
190
  name="browsercache__cssjs__cache__policy">
191
- <?php $value = $this->_config->get_string( 'browsercache.cssjs.cache.policy' ); ?>
 
 
 
192
  <option value="cache"<?php selected( $value, 'cache' ); ?>>cache ("public")</option>
193
- <option value="cache_public_maxage"<?php selected( $value, 'cache_public_maxage' ); ?>><?php _e( 'cache with max-age ("public, max-age=EXPIRES_SECONDS")', 'w3-total-cache' ); ?></option>
194
- <option value="cache_validation"<?php selected( $value, 'cache_validation' ); ?>><?php _e( 'cache with validation ("public, must-revalidate, proxy-revalidate"', 'w3-total-cache' ); ?></option>
195
- <option value="cache_maxage"<?php selected( $value, 'cache_maxage' ); ?>><?php _e( 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
196
  <option value="cache_noproxy"<?php selected( $value, 'cache_noproxy' ); ?>><?php _e( 'cache without proxy ("private, must-revalidate")', 'w3-total-cache' ); ?></option>
197
- <option value="no_cache"<?php selected( $value, 'no_cache' ); ?>><?php _e( 'no-cache ("max-age=0, private, no-store, no-cache, must-revalidate"', 'w3-total-cache' ); ?></option>
198
  </select>
 
 
 
199
  </td>
200
  </tr>
201
  <tr>
@@ -216,6 +227,12 @@ Util_Ui::config_item( array(
216
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
217
  </th>
218
  </tr>
 
 
 
 
 
 
219
  <tr>
220
  <th colspan="2">
221
  <?php $this->checkbox( 'browsercache.cssjs.replace' ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.replace' ) ?></label>
@@ -225,7 +242,7 @@ Util_Ui::config_item( array(
225
  <tr>
226
  <th colspan="2">
227
  <?php $this->checkbox( 'browsercache.cssjs.querystring' ) ?> <?php _e( 'Remove query strings from static resources', 'w3-total-cache' ); ?></label>
228
- <br /><span class="description"><?php _e( 'Resources with a "?" in the URL are not cached by some proxy caching servers.', 'w3-total-cache' ); ?></span>
229
  </th>
230
  </tr>
231
  <tr>
@@ -243,14 +260,12 @@ Util_Ui::config_item( array(
243
  <p><?php _e( 'Specify browser cache policy for posts, pages, feeds and text-based files.', 'w3-total-cache' ); ?></p>
244
 
245
  <table class="form-table">
246
- <?php if ( !Util_Environment::is_nginx() ): ?>
247
  <tr>
248
  <th colspan="2">
249
  <?php $this->checkbox( 'browsercache.html.last_modified' ) ?> <?php Util_Ui::e_config_label( 'browsercache.html.last_modified' ) ?></label>
250
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
251
  </th>
252
  </tr>
253
- <?php endif; ?>
254
  <tr>
255
  <th colspan="2">
256
  <?php $this->checkbox( 'browsercache.html.expires' ) ?> <?php Util_Ui::e_config_label( 'browsercache.html.expires' ) ?></label>
@@ -281,14 +296,20 @@ Util_Ui::config_item( array(
281
  <td>
282
  <select id="browsercache_html_cache_policy" name="browsercache__html__cache__policy"
283
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>>
284
- <?php $value = $this->_config->get_string( 'browsercache.html.cache.policy' ); ?>
 
 
 
285
  <option value="cache"<?php selected( $value, 'cache' ); ?>>cache ("public")</option>
286
- <option value="cache_public_maxage"<?php selected( $value, 'cache_public_maxage' ); ?>><?php _e( 'cache with max-age ("public, max-age=EXPIRES_SECONDS")', 'w3-total-cache' ); ?></option>
287
  <option value="cache_validation"<?php selected( $value, 'cache_validation' ); ?>><?php _e( 'cache with validation ("public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
288
- <option value="cache_maxage"<?php selected( $value, 'cache_maxage' ); ?>><?php _e( 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
289
  <option value="cache_noproxy"<?php selected( $value, 'cache_noproxy' ); ?>><?php _e( 'cache without proxy ("private, must-revalidate")', 'w3-total-cache' ); ?></option>
290
  <option value="no_cache"<?php selected( $value, 'no_cache' ); ?>><?php _e( 'no-cache ("max-age=0, private, no-store, no-cache, must-revalidate")', 'w3-total-cache' ); ?></option>
291
  </select>
 
 
 
292
  </td>
293
  </tr>
294
  <tr>
@@ -309,6 +330,12 @@ Util_Ui::config_item( array(
309
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
310
  </th>
311
  </tr>
 
 
 
 
 
 
312
  </table>
313
 
314
  <?php Util_Ui::button_config_save( 'browsercache_html_xml' ); ?>
@@ -316,14 +343,12 @@ Util_Ui::config_item( array(
316
 
317
  <?php Util_Ui::postbox_header( __( 'Media &amp; Other Files', 'w3-total-cache' ), '', 'media' ); ?>
318
  <table class="form-table">
319
- <?php if ( !Util_Environment::is_nginx() ): ?>
320
  <tr>
321
  <th colspan="2">
322
  <?php $this->checkbox( 'browsercache.other.last_modified' ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.last_modified' ) ?></label>
323
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
324
  </th>
325
  </tr>
326
- <?php endif; ?>
327
  <tr>
328
  <th colspan="2">
329
  <?php $this->checkbox( 'browsercache.other.expires' ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.expires' ) ?></label>
@@ -354,14 +379,20 @@ Util_Ui::config_item( array(
354
  <select id="browsercache_other_cache_policy"
355
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
356
  name="browsercache__other__cache__policy">
357
- <?php $value = $this->_config->get_string( 'browsercache.other.cache.policy' ); ?>
 
 
 
358
  <option value="cache"<?php selected( $value, 'cache' ); ?>><?php _e( 'cache ("public")' ); ?></option>
359
- <option value="cache_public_maxage"<?php selected( $value, 'cache_public_maxage' ); ?>><?php _e( 'cache with max-age ("public, max-age=EXPIRES_SECONDS")', 'w3-total-cache' ); ?></option>
360
  <option value="cache_validation"<?php selected( $value, 'cache_validation' ); ?>><?php _e( 'cache with validation ("public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
361
- <option value="cache_maxage"<?php selected( $value, 'cache_maxage' ); ?>><?php _e( 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
362
  <option value="cache_noproxy"<?php selected( $value, 'cache_noproxy' ); ?>><?php _e( 'cache without proxy ("private, must-revalidate")', 'w3-total-cache' ); ?></option>
363
  <option value="no_cache"<?php selected( $value, 'no_cache' ); ?>><?php _e( 'no-cache ("max-age=0, private, no-store, no-cache, must-revalidate")', 'w3-total-cache' ); ?></option>
364
  </select>
 
 
 
365
  </td>
366
  </tr>
367
  <tr>
@@ -382,6 +413,12 @@ Util_Ui::config_item( array(
382
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
383
  </th>
384
  </tr>
 
 
 
 
 
 
385
  <tr>
386
  <th colspan="2">
387
  <?php $this->checkbox( 'browsercache.other.replace' ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.replace' ) ?></label>
@@ -391,7 +428,7 @@ Util_Ui::config_item( array(
391
  <tr>
392
  <th colspan="2">
393
  <?php $this->checkbox( 'browsercache.other.querystring' ) ?> <?php _e( 'Remove query strings from static resources', 'w3-total-cache' ); ?></label>
394
- <br /><span class="description"><?php _e( 'Resources with a "?" in the URL are not cached by some proxy caching servers.', 'w3-total-cache' ); ?></span>
395
  </th>
396
  </tr>
397
  <tr>
@@ -407,13 +444,15 @@ Util_Ui::config_item( array(
407
 
408
  <?php Util_Ui::postbox_header( __( 'Security Headers', 'w3-total-cache' ), '', 'security' ); ?>
409
  <p><?php _e( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> security headers provide another layer of protection for your website by helping to mitigate attacks and security vulnerabilities.', 'w3-total-cache' ); ?></p>
 
 
410
  <table class="form-table">
411
  <?php
412
  Util_Ui::config_item( array(
413
  'key' => 'browsercache.security.session.use_only_cookies',
414
  'control' => 'selectbox',
415
  'selectbox_values' => $security_session_values,
416
- 'description' => __( 'This setting prevents attacks that are caused by passing session IDs in URLs.',
417
  'w3-total-cache' )
418
  ) );
419
  ?>
@@ -438,7 +477,7 @@ Util_Ui::config_item( array(
438
  <tr>
439
  <th colspan="2">
440
  <?php $this->checkbox( 'browsercache.hsts' ) ?> <?php Util_Ui::e_config_label( 'browsercache.hsts' ) ?></label>
441
- <br /><span class="description"><?php _e( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Strict-Transport-Security (HSTS) enforces secure (<acronym title="Hypertext Transfer Protocol">HTTP</acronym> over <acronym title="Secure Sockets Layer">SSL</acronym>/<acronym title="Transport Layer Security">TLS</acronym>) connections to the server. This can help mitigate adverse effects caused by bugs and session leaks through cookies and links. It also helps defend against man-in-the-middle attacks. If there are <acronym title="Secure Sockets Layer">SSL</acronym> negotiation warnings then users will not be permitted to ignore them.', 'w3-total-cache' ); ?></span>
442
  </th>
443
  </tr>
444
  <tr>
@@ -485,7 +524,7 @@ Util_Ui::config_item( array(
485
  <tr>
486
  <th colspan="2">
487
  <?php $this->checkbox( 'browsercache.security.xss' ) ?> <?php Util_Ui::e_config_label( 'browsercache.security.xss' ) ?></label>
488
- <br /><span class="description"><?php _e( 'This header enables the Cross-Site Scripting (XSS) filter. It helps to stop malicious scripts from being injected into your website. Although this is already built into and enabled by default in most browsers today it is made available here to enforce its reactivation if it was disabled within the user\'s browser.', 'w3-total-cache' ); ?></span>
489
  </th>
490
  </tr>
491
  <tr>
@@ -558,7 +597,7 @@ Util_Ui::config_item( array(
558
  <td>
559
  <input id="browsercache_security_pkp_report_url" type="text" name="browsercache__security__pkp__report__url"
560
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.pkp.report.url' ) ); ?>" size="50" placeholder="Enter URL" />
561
- <div><i><?php _e( 'This optional field can be used to specify a URL that clients will send reports to if pin validation failures occur. The report is sent as a POST request with a JSON body.' ); ?></i></div>
562
  </td>
563
  </tr>
564
  <tr>
@@ -591,13 +630,14 @@ Util_Ui::config_item( array(
591
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
592
  name="browsercache__security__referrer__policy__directive">
593
  <?php $value = $this->_config->get_string( 'browsercache.security.referrer.policy.directive' ); ?>
594
- <option value="0"<?php selected( $value, '0' ); ?>><?php _e( '""', 'w3-total-cache' ); ?></option>
595
  <option value="no-referrer"<?php selected( $value, 'no-referrer' ); ?>><?php _e( 'no-referrer', 'w3-total-cache' ); ?></option>
596
  <option value="no-referrer-when-downgrade"<?php selected( $value, 'no-referrer-when-downgrade' ); ?>><?php _e( 'no-referrer-when-downgrade', 'w3-total-cache' ); ?></option>
597
  <option value="same-origin"<?php selected( $value, 'same-origin' ); ?>><?php _e( 'same-origin', 'w3-total-cache' ); ?></option>
598
  <option value="origin"<?php selected( $value, 'origin' ); ?>><?php _e( 'origin', 'w3-total-cache' ); ?></option>
599
  <option value="strict-origin"<?php selected( $value, 'strict-origin' ); ?>><?php _e( 'strict-origin', 'w3-total-cache' ); ?></option>
600
  <option value="origin-when-cross-origin"<?php selected( $value, 'origin-when-cross-origin' ); ?>><?php _e( 'origin-when-cross-origin', 'w3-total-cache' ); ?></option>
 
601
  <option value="unsafe-url"<?php selected( $value, 'unsafe-url' ); ?>><?php _e( 'unsafe-url', 'w3-total-cache' ); ?></option>
602
  </select>
603
  <div id="browsercache_security_referrer_policy_directive_description"></div>
@@ -607,7 +647,6 @@ Util_Ui::config_item( array(
607
  <th colspan="2">
608
  <?php $this->checkbox( 'browsercache.security.csp' ) ?> <?php Util_Ui::e_config_label( 'browsercache.security.csp' ) ?></label>
609
  <br /><span class="description"><?php _e( 'The Content Security Policy (<acronym title="Content Security Policy">CSP</acronym>) header reduces the risk of <acronym title="Cross-Site Scripting">XSS</acronym> attacks by allowing you to define where resources can be retrieved from, preventing browsers from loading data from any other locations. This makes it harder for an attacker to inject malicious code into your site.' ); ?></span>
610
- <p><a onclick="w3tc_csp_reference()" href="javascript:void(0);">Quick Reference Chart</a></p>
611
  </th>
612
  </tr>
613
  <tr>
@@ -617,7 +656,7 @@ Util_Ui::config_item( array(
617
  <td>
618
  <input id="browsercache_security_csp_base" type="text" name="browsercache__security__csp__base"
619
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.base' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
620
- <div><i><?php _e( 'Restricts the URLs which can be used in a document\'s &lt;base&gt; element.' ); ?></i></div>
621
  </td>
622
  </tr>
623
  <tr>
@@ -697,7 +736,7 @@ Util_Ui::config_item( array(
697
  <td>
698
  <input id="browsercache_security_csp_style" type="text" name="browsercache__security__csp__style"
699
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.style' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
700
- <div><i><?php _e( 'Specifies valid sources for CSS stylesheets.' ); ?></i></div>
701
  </td>
702
  </tr>
703
  <tr>
@@ -707,7 +746,7 @@ Util_Ui::config_item( array(
707
  <td>
708
  <input id="browsercache_security_csp_form" type="text" name="browsercache__security__csp__form"
709
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.form' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
710
- <div><i><?php _e( 'Restricts the URLs which can be used as the target of form submissions from a given context.' ); ?></i></div>
711
  </td>
712
  </tr>
713
  <tr>
@@ -716,7 +755,7 @@ Util_Ui::config_item( array(
716
  </th>
717
  <td>
718
  <input id="browsercache_security_csp_frame_ancestors" type="text" name="browsercache__security__csp__frame__ancestors"
719
- <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.frame' ) ); ?>" size="50" placeholder="Example: 'none'" />
720
  <div><i><?php _e( 'Specifies valid parents that may embed a page using &lt;frame&gt;, &lt;iframe&gt;, &lt;object&gt;, &lt;embed&gt;, or &lt;applet&gt;.' ); ?></i></div>
721
  </td>
722
  </tr>
5
  die();
6
 
7
  $security_session_values = array(
8
+ '' => 'Default',
9
  'on' => 'Enable',
10
  'off' => 'Disable'
11
  );
32
  <?php Util_Ui::postbox_header( __( 'General', 'w3-total-cache' ), '', 'general' ); ?>
33
  <p><?php _e( 'Specify global browser cache policy.', 'w3-total-cache' ) ?></p>
34
  <table class="form-table">
 
35
  <tr>
36
  <th colspan="2">
37
  <label>
41
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
42
  </th>
43
  </tr>
 
44
  <tr>
45
  <th colspan="2">
46
  <label>
80
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
81
  </th>
82
  </tr>
83
+ <tr>
84
+ <th colspan="2">
85
+ <label><input id="browsercache_brotli" type="checkbox"
86
+ <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
87
+ <?php if ( !function_exists( 'brotli_compress' ) ) echo 'disabled="disabled"' ?>
88
+ name="compression"<?php checked( $browsercache_brotli, true ); ?> value="1" /> <?php _e( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (brotli) compression', 'w3-total-cache' ); ?></label>
89
+ <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
90
+ </th>
91
+ </tr>
92
  <tr>
93
  <th colspan="2">
94
  <label><input id="browsercache_replace" type="checkbox"
102
  <label><input id="browsercache_querystring" type="checkbox"
103
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
104
  name="querystring" value="1"<?php checked( $browsercache_querystring, true ); ?> /> <?php _e( 'Remove query strings from static resources', 'w3-total-cache' ); ?></label>
105
+ <br /><span class="description"><?php _e( 'Resources with a "?" in the <acronym title="Uniform Resource Locator">URL</acronym> are not cached by some proxy caching servers.', 'w3-total-cache' ); ?></span>
106
  </th>
107
  </tr>
108
  <tr>
157
  <p><?php _e( 'Specify browser cache policy for Cascading Style Sheets and JavaScript files.', 'w3-total-cache' ); ?></p>
158
 
159
  <table class="form-table">
 
160
  <tr>
161
  <th colspan="2">
162
  <?php $this->checkbox( 'browsercache.cssjs.last_modified' ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.last_modified' ) ?></label>
163
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
164
  </th>
165
  </tr>
 
166
  <tr>
167
  <th colspan="2">
168
  <?php $this->checkbox( 'browsercache.cssjs.expires' ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.expires' ) ?></label>
193
  <select id="browsercache_cssjs_cache_policy"
194
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
195
  name="browsercache__cssjs__cache__policy">
196
+ <?php
197
+ $value = $this->_config->get_string( 'browsercache.cssjs.cache.policy' );
198
+ $cssjs_expires = $this->_config->get_boolean( 'browsercache.cssjs.expires' );
199
+ ?>
200
  <option value="cache"<?php selected( $value, 'cache' ); ?>>cache ("public")</option>
201
+ <option value="cache_public_maxage"<?php selected( $value, 'cache_public_maxage' ); disabled( $is_nginx && $cssjs_expires ); ?>><?php _e( 'cache with max-age ("public, max-age=EXPIRES_SECONDS")', 'w3-total-cache' ); ?></option>
202
+ <option value="cache_validation"<?php selected( $value, 'cache_validation' ); ?>><?php _e( 'cache with validation ("public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
203
+ <option value="cache_maxage"<?php selected( $value, 'cache_maxage' ); disabled( $is_nginx && $cssjs_expires ); ?>><?php _e( 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
204
  <option value="cache_noproxy"<?php selected( $value, 'cache_noproxy' ); ?>><?php _e( 'cache without proxy ("private, must-revalidate")', 'w3-total-cache' ); ?></option>
205
+ <option value="no_cache"<?php selected( $value, 'no_cache' ); ?>><?php _e( 'no-cache ("max-age=0, private, no-store, no-cache, must-revalidate")', 'w3-total-cache' ); ?></option>
206
  </select>
207
+ <?php if ( $is_nginx && $cssjs_expires ) : ?>
208
+ <br /><span class="description"><?php _e( 'The Expires header already sets the max-age.', 'w3-total-cache' ); ?></span>
209
+ <?php endif; ?>
210
  </td>
211
  </tr>
212
  <tr>
227
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
228
  </th>
229
  </tr>
230
+ <tr>
231
+ <th colspan="2">
232
+ <?php $this->checkbox( 'browsercache.cssjs.brotli', !function_exists( 'brotli_compress' ) ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.brotli' ) ?> </label>
233
+ <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
234
+ </th>
235
+ </tr>
236
  <tr>
237
  <th colspan="2">
238
  <?php $this->checkbox( 'browsercache.cssjs.replace' ) ?> <?php Util_Ui::e_config_label( 'browsercache.cssjs.replace' ) ?></label>
242
  <tr>
243
  <th colspan="2">
244
  <?php $this->checkbox( 'browsercache.cssjs.querystring' ) ?> <?php _e( 'Remove query strings from static resources', 'w3-total-cache' ); ?></label>
245
+ <br /><span class="description"><?php _e( 'Resources with a "?" in the <acronym title="Uniform Resource Locator">URL</acronym> are not cached by some proxy caching servers.', 'w3-total-cache' ); ?></span>
246
  </th>
247
  </tr>
248
  <tr>
260
  <p><?php _e( 'Specify browser cache policy for posts, pages, feeds and text-based files.', 'w3-total-cache' ); ?></p>
261
 
262
  <table class="form-table">
 
263
  <tr>
264
  <th colspan="2">
265
  <?php $this->checkbox( 'browsercache.html.last_modified' ) ?> <?php Util_Ui::e_config_label( 'browsercache.html.last_modified' ) ?></label>
266
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
267
  </th>
268
  </tr>
 
269
  <tr>
270
  <th colspan="2">
271
  <?php $this->checkbox( 'browsercache.html.expires' ) ?> <?php Util_Ui::e_config_label( 'browsercache.html.expires' ) ?></label>
296
  <td>
297
  <select id="browsercache_html_cache_policy" name="browsercache__html__cache__policy"
298
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>>
299
+ <?php
300
+ $value = $this->_config->get_string( 'browsercache.html.cache.policy' );
301
+ $html_expires = $this->_config->get_boolean( 'browsercache.html.expires' );
302
+ ?>
303
  <option value="cache"<?php selected( $value, 'cache' ); ?>>cache ("public")</option>
304
+ <option value="cache_public_maxage"<?php selected( $value, 'cache_public_maxage' ); disabled( $is_nginx && $html_expires ); ?>><?php _e( 'cache with max-age ("public, max-age=EXPIRES_SECONDS")', 'w3-total-cache' ); ?></option>
305
  <option value="cache_validation"<?php selected( $value, 'cache_validation' ); ?>><?php _e( 'cache with validation ("public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
306
+ <option value="cache_maxage"<?php selected( $value, 'cache_maxage' ); disabled( $is_nginx && $html_expires ); ?>><?php _e( 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
307
  <option value="cache_noproxy"<?php selected( $value, 'cache_noproxy' ); ?>><?php _e( 'cache without proxy ("private, must-revalidate")', 'w3-total-cache' ); ?></option>
308
  <option value="no_cache"<?php selected( $value, 'no_cache' ); ?>><?php _e( 'no-cache ("max-age=0, private, no-store, no-cache, must-revalidate")', 'w3-total-cache' ); ?></option>
309
  </select>
310
+ <?php if ( $is_nginx && $html_expires ) : ?>
311
+ <br /><span class="description"><?php _e( 'The Expires header already sets the max-age.', 'w3-total-cache' ); ?></span>
312
+ <?php endif; ?>
313
  </td>
314
  </tr>
315
  <tr>
330
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
331
  </th>
332
  </tr>
333
+ <tr>
334
+ <th colspan="2">
335
+ <?php $this->checkbox( 'browsercache.html.brotli', !function_exists( 'brotli_compress' ) ) ?> <?php Util_Ui::e_config_label( 'browsercache.html.brotli' ) ?></label>
336
+ <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
337
+ </th>
338
+ </tr>
339
  </table>
340
 
341
  <?php Util_Ui::button_config_save( 'browsercache_html_xml' ); ?>
343
 
344
  <?php Util_Ui::postbox_header( __( 'Media &amp; Other Files', 'w3-total-cache' ), '', 'media' ); ?>
345
  <table class="form-table">
 
346
  <tr>
347
  <th colspan="2">
348
  <?php $this->checkbox( 'browsercache.other.last_modified' ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.last_modified' ) ?></label>
349
  <br /><span class="description"><?php _e( 'Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache' ); ?></span>
350
  </th>
351
  </tr>
 
352
  <tr>
353
  <th colspan="2">
354
  <?php $this->checkbox( 'browsercache.other.expires' ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.expires' ) ?></label>
379
  <select id="browsercache_other_cache_policy"
380
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
381
  name="browsercache__other__cache__policy">
382
+ <?php
383
+ $value = $this->_config->get_string( 'browsercache.other.cache.policy' );
384
+ $other_expires = $this->_config->get_string( 'browsercache.other.expires' );
385
+ ?>
386
  <option value="cache"<?php selected( $value, 'cache' ); ?>><?php _e( 'cache ("public")' ); ?></option>
387
+ <option value="cache_public_maxage"<?php selected( $value, 'cache_public_maxage' ); disabled( $is_nginx && $other_expires ); ?>><?php _e( 'cache with max-age ("public, max-age=EXPIRES_SECONDS")', 'w3-total-cache' ); ?></option>
388
  <option value="cache_validation"<?php selected( $value, 'cache_validation' ); ?>><?php _e( 'cache with validation ("public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
389
+ <option value="cache_maxage"<?php selected( $value, 'cache_maxage' ); disabled( $is_nginx && $other_expires ); ?>><?php _e( 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate")', 'w3-total-cache' ); ?></option>
390
  <option value="cache_noproxy"<?php selected( $value, 'cache_noproxy' ); ?>><?php _e( 'cache without proxy ("private, must-revalidate")', 'w3-total-cache' ); ?></option>
391
  <option value="no_cache"<?php selected( $value, 'no_cache' ); ?>><?php _e( 'no-cache ("max-age=0, private, no-store, no-cache, must-revalidate")', 'w3-total-cache' ); ?></option>
392
  </select>
393
+ <?php if ( $is_nginx && $other_expires ) : ?>
394
+ <br /><span class="description"><?php _e( 'The Expires header already sets the max-age.', 'w3-total-cache' ); ?></span>
395
+ <?php endif; ?>
396
  </td>
397
  </tr>
398
  <tr>
413
  <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
414
  </th>
415
  </tr>
416
+ <tr>
417
+ <th colspan="2">
418
+ <?php $this->checkbox( 'browsercache.other.brotli', !function_exists( 'brotli_compress' ) ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.brotli' ) ?>
419
+ <br /><span class="description"><?php _e( 'Reduce the download time for text-based files.', 'w3-total-cache' ); ?></span>
420
+ </th>
421
+ </tr>
422
  <tr>
423
  <th colspan="2">
424
  <?php $this->checkbox( 'browsercache.other.replace' ) ?> <?php Util_Ui::e_config_label( 'browsercache.other.replace' ) ?></label>
428
  <tr>
429
  <th colspan="2">
430
  <?php $this->checkbox( 'browsercache.other.querystring' ) ?> <?php _e( 'Remove query strings from static resources', 'w3-total-cache' ); ?></label>
431
+ <br /><span class="description"><?php _e( 'Resources with a "?" in the <acronym title="Uniform Resource Locator">URL</acronym> are not cached by some proxy caching servers.', 'w3-total-cache' ); ?></span>
432
  </th>
433
  </tr>
434
  <tr>
444
 
445
  <?php Util_Ui::postbox_header( __( 'Security Headers', 'w3-total-cache' ), '', 'security' ); ?>
446
  <p><?php _e( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> security headers provide another layer of protection for your website by helping to mitigate attacks and security vulnerabilities.', 'w3-total-cache' ); ?></p>
447
+ <p><a onclick="w3tc_csp_reference()" href="javascript:void(0);">Quick Reference Chart</a></p>
448
+
449
  <table class="form-table">
450
  <?php
451
  Util_Ui::config_item( array(
452
  'key' => 'browsercache.security.session.use_only_cookies',
453
  'control' => 'selectbox',
454
  'selectbox_values' => $security_session_values,
455
+ 'description' => __( 'This setting prevents attacks that are caused by passing session IDs in <acronym title="Uniform Resource Locator">URL</acronym>s.',
456
  'w3-total-cache' )
457
  ) );
458
  ?>
477
  <tr>
478
  <th colspan="2">
479
  <?php $this->checkbox( 'browsercache.hsts' ) ?> <?php Util_Ui::e_config_label( 'browsercache.hsts' ) ?></label>
480
+ <br /><span class="description"><?php _e( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Strict-Transport-Security (<acronym title="HTTP Strict Transport Security">HSTS</acronym>) enforces secure (<acronym title="Hypertext Transfer Protocol">HTTP</acronym> over <acronym title="Secure Sockets Layer">SSL</acronym>/<acronym title="Transport Layer Security">TLS</acronym>) connections to the server. This can help mitigate adverse effects caused by bugs and session leaks through cookies and links. It also helps defend against man-in-the-middle attacks. If there are <acronym title="Secure Sockets Layer">SSL</acronym> negotiation warnings then users will not be permitted to ignore them.', 'w3-total-cache' ); ?></span>
481
  </th>
482
  </tr>
483
  <tr>
524
  <tr>
525
  <th colspan="2">
526
  <?php $this->checkbox( 'browsercache.security.xss' ) ?> <?php Util_Ui::e_config_label( 'browsercache.security.xss' ) ?></label>
527
+ <br /><span class="description"><?php _e( 'This header enables the <acronym title="Cross-Site Scripting">XSS</acronym> filter. It helps to stop malicious scripts from being injected into your website. Although this is already built into and enabled by default in most browsers today it is made available here to enforce its reactivation if it was disabled within the user\'s browser.', 'w3-total-cache' ); ?></span>
528
  </th>
529
  </tr>
530
  <tr>
597
  <td>
598
  <input id="browsercache_security_pkp_report_url" type="text" name="browsercache__security__pkp__report__url"
599
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.pkp.report.url' ) ); ?>" size="50" placeholder="Enter URL" />
600
+ <div><i><?php _e( 'This optional field can be used to specify a <acronym title="Uniform Resource Locator">URL</acronym> that clients will send reports to if pin validation failures occur. The report is sent as a POST request with a JSON body.' ); ?></i></div>
601
  </td>
602
  </tr>
603
  <tr>
630
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?>
631
  name="browsercache__security__referrer__policy__directive">
632
  <?php $value = $this->_config->get_string( 'browsercache.security.referrer.policy.directive' ); ?>
633
+ <option value="0"<?php selected( $value, '0' ); ?>><?php _e( 'Not Set', 'w3-total-cache' ); ?></option>
634
  <option value="no-referrer"<?php selected( $value, 'no-referrer' ); ?>><?php _e( 'no-referrer', 'w3-total-cache' ); ?></option>
635
  <option value="no-referrer-when-downgrade"<?php selected( $value, 'no-referrer-when-downgrade' ); ?>><?php _e( 'no-referrer-when-downgrade', 'w3-total-cache' ); ?></option>
636
  <option value="same-origin"<?php selected( $value, 'same-origin' ); ?>><?php _e( 'same-origin', 'w3-total-cache' ); ?></option>
637
  <option value="origin"<?php selected( $value, 'origin' ); ?>><?php _e( 'origin', 'w3-total-cache' ); ?></option>
638
  <option value="strict-origin"<?php selected( $value, 'strict-origin' ); ?>><?php _e( 'strict-origin', 'w3-total-cache' ); ?></option>
639
  <option value="origin-when-cross-origin"<?php selected( $value, 'origin-when-cross-origin' ); ?>><?php _e( 'origin-when-cross-origin', 'w3-total-cache' ); ?></option>
640
+ <option value="strict-origin-when-cross-origin"<?php selected( $value, 'strict-origin-when-cross-origin' ); ?>><?php _e( 'strict-origin-when-cross-origin', 'w3-total-cache' ); ?></option>
641
  <option value="unsafe-url"<?php selected( $value, 'unsafe-url' ); ?>><?php _e( 'unsafe-url', 'w3-total-cache' ); ?></option>
642
  </select>
643
  <div id="browsercache_security_referrer_policy_directive_description"></div>
647
  <th colspan="2">
648
  <?php $this->checkbox( 'browsercache.security.csp' ) ?> <?php Util_Ui::e_config_label( 'browsercache.security.csp' ) ?></label>
649
  <br /><span class="description"><?php _e( 'The Content Security Policy (<acronym title="Content Security Policy">CSP</acronym>) header reduces the risk of <acronym title="Cross-Site Scripting">XSS</acronym> attacks by allowing you to define where resources can be retrieved from, preventing browsers from loading data from any other locations. This makes it harder for an attacker to inject malicious code into your site.' ); ?></span>
 
650
  </th>
651
  </tr>
652
  <tr>
656
  <td>
657
  <input id="browsercache_security_csp_base" type="text" name="browsercache__security__csp__base"
658
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.base' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
659
+ <div><i><?php _e( 'Restricts the <acronym title="Uniform Resource Locator">URL</acronym>s which can be used in a document\'s &lt;base&gt; element.' ); ?></i></div>
660
  </td>
661
  </tr>
662
  <tr>
736
  <td>
737
  <input id="browsercache_security_csp_style" type="text" name="browsercache__security__csp__style"
738
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.style' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
739
+ <div><i><?php _e( 'Specifies valid sources for <acronym title="Cascading Style Sheet">CSS</acronym> stylesheets.' ); ?></i></div>
740
  </td>
741
  </tr>
742
  <tr>
746
  <td>
747
  <input id="browsercache_security_csp_form" type="text" name="browsercache__security__csp__form"
748
  <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.form' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
749
+ <div><i><?php _e( 'Restricts the <acronym title="Uniform Resource Locator">URL</acronym>s which can be used as the target of form submissions from a given context.' ); ?></i></div>
750
  </td>
751
  </tr>
752
  <tr>
755
  </th>
756
  <td>
757
  <input id="browsercache_security_csp_frame_ancestors" type="text" name="browsercache__security__csp__frame__ancestors"
758
+ <?php Util_Ui::sealing_disabled( 'browsercache.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.frame.ancestors' ) ); ?>" size="50" placeholder="Example: 'none'" />
759
  <div><i><?php _e( 'Specifies valid parents that may embed a page using &lt;frame&gt;, &lt;iframe&gt;, &lt;object&gt;, &lt;embed&gt;, or &lt;applet&gt;.' ); ?></i></div>
760
  </td>
761
  </tr>
inc/options/cdn.php CHANGED
@@ -124,7 +124,8 @@ if ( !$upload_blogfiles_enabled )
124
  <th<?php if ( $cdn_mirror ): ?> colspan="2"<?php endif; ?>>
125
  <?php $this->checkbox( 'cdn.custom.enable' ) ?> <?php Util_Ui::e_config_label( 'cdn.custom.enable' ) ?></label><br />
126
  <span class="description">
127
- <?php echo sprintf( __( '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>. Supports masks (See <a href="%s">FAQ</a>)', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_faq#q82' ) ); ?>
 
128
  </span>
129
  </th>
130
  <?php if ( ! $cdn_mirror ): ?>
@@ -143,6 +144,7 @@ if ( !$upload_blogfiles_enabled )
143
  </th>
144
  </tr>
145
  <?php endif; ?>
 
146
  <?php if ( $cdn_supports_header ): ?>
147
  <tr>
148
  <th colspan="2">
@@ -159,10 +161,14 @@ if ( !$upload_blogfiles_enabled )
159
  <?php Util_Ui::postbox_header( __( 'Configuration: Objects', 'w3-total-cache' ), '', 'configuration' ); ?>
160
  <table class="form-table">
161
  <?php
162
- if ( $cdn_engine == 'google_drive' || $cdn_engine == 'highwinds' ||
 
163
  $cdn_engine == 'limelight' ||
164
- $cdn_engine == 'maxcdn' || $cdn_engine == 'rackspace_cdn' ||
165
- $cdn_engine == 'rscf' || $cdn_engine == 'stackpath' ) {
 
 
 
166
  do_action( 'w3tc_settings_cdn_boxarea_configuration' );
167
  } else if ( Cdn_Util::is_engine( $cdn_engine ) ) {
168
  include W3TC_INC_DIR . '/options/cdn/' . $cdn_engine . '.php';
@@ -177,6 +183,15 @@ if ( $cdn_engine == 'google_drive' || $cdn_engine == 'highwinds' ||
177
 
178
  <?php Util_Ui::postbox_header( __( 'Advanced', 'w3-total-cache' ), '', 'advanced' ); ?>
179
  <table class="form-table">
 
 
 
 
 
 
 
 
 
180
  <tr>
181
  <th colspan="2">
182
  <?php $this->checkbox( 'cdn.reject.ssl' ) ?> <?php Util_Ui::e_config_label( 'cdn.reject.ssl' ) ?></label><br />
@@ -184,17 +199,17 @@ if ( $cdn_engine == 'google_drive' || $cdn_engine == 'highwinds' ||
184
  </th>
185
  </tr>
186
  <tr>
187
- <th colspan="2">
188
- <?php $this->checkbox( 'cdn.admin.media_library' ) ?> <?php Util_Ui::e_config_label( 'cdn.admin.media_library' ) ?></label><br />
189
  <span class="description">All Media Library content will use <acronym title="Content Delivery Network">CDN</acronym> links on administration pages.</span>
190
  </th>
191
- </tr>
192
  <tr>
193
- <th colspan="2">
194
- <?php $this->checkbox( 'cdn.cors_header' ) ?> Add <acronym title="Access-Control-Allow-Origin">CORS</acronym> header</label><br />
195
  <span class="description">Add <acronym title="Access-Control-Allow-Origin">CORS</acronym> headers to allow cross-domain assets usage.</span>
196
  </th>
197
- </tr>
198
 
199
  <tr>
200
  <th colspan="2">
@@ -218,7 +233,7 @@ if ( $cdn_engine == 'google_drive' || $cdn_engine == 'highwinds' ||
218
  <textarea id="cdn_reject_uri" name="cdn__reject__uri"
219
  <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>
220
  cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $this->_config->get_array( 'cdn.reject.uri' ) ) ); ?></textarea><br />
221
- <span class="description"><?php echo sprintf( __( 'Always ignore the specified pages / directories. Supports regular expression (See <a href="%s">FAQ</a>' ), network_admin_url( 'admin.php?page=w3tc_faq#q82' ) ) ?></span>
222
  </td>
223
  </tr>
224
  <tr>
124
  <th<?php if ( $cdn_mirror ): ?> colspan="2"<?php endif; ?>>
125
  <?php $this->checkbox( 'cdn.custom.enable' ) ?> <?php Util_Ui::e_config_label( 'cdn.custom.enable' ) ?></label><br />
126
  <span class="description">
127
+ <?php echo sprintf( __( '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>.', 'w3-total-cache' ),
128
+ 'https://api.w3-edge.com/v1/redirects/faq/usage/regexp-support' ); ?>
129
  </span>
130
  </th>
131
  <?php if ( ! $cdn_mirror ): ?>
144
  </th>
145
  </tr>
146
  <?php endif; ?>
147
+
148
  <?php if ( $cdn_supports_header ): ?>
149
  <tr>
150
  <th colspan="2">
161
  <?php Util_Ui::postbox_header( __( 'Configuration: Objects', 'w3-total-cache' ), '', 'configuration' ); ?>
162
  <table class="form-table">
163
  <?php
164
+ if ( $cdn_engine == 'google_drive' ||
165
+ $cdn_engine == 'highwinds' ||
166
  $cdn_engine == 'limelight' ||
167
+ $cdn_engine == 'maxcdn' ||
168
+ $cdn_engine == 'rackspace_cdn' ||
169
+ $cdn_engine == 'rscf' ||
170
+ $cdn_engine == 'stackpath' ||
171
+ $cdn_engine == 'stackpath2' ) {
172
  do_action( 'w3tc_settings_cdn_boxarea_configuration' );
173
  } else if ( Cdn_Util::is_engine( $cdn_engine ) ) {
174
  include W3TC_INC_DIR . '/options/cdn/' . $cdn_engine . '.php';
183
 
184
  <?php Util_Ui::postbox_header( __( 'Advanced', 'w3-total-cache' ), '', 'advanced' ); ?>
185
  <table class="form-table">
186
+
187
+ <tr>
188
+ <th colspan="2">
189
+ <?php $this->checkbox( 'cdn.flush_manually' ) ?>
190
+ <?php _e( 'Only purge <acronym title="Content Delivery Network">CDN</acronym> manually', 'w3-total-cache' ) ?></label><br />
191
+ <span class="description"><?php _e( 'Purge <acronym title="Content Delivery Network">CDN</acronym> only if explicit purge button is clicked.', 'w3-total-cache' ) ?></span>
192
+ </th>
193
+ </tr>
194
+
195
  <tr>
196
  <th colspan="2">
197
  <?php $this->checkbox( 'cdn.reject.ssl' ) ?> <?php Util_Ui::e_config_label( 'cdn.reject.ssl' ) ?></label><br />
199
  </th>
200
  </tr>
201
  <tr>
202
+ <th colspan="2">
203
+ <?php $this->checkbox( 'cdn.admin.media_library' ) ?> <?php Util_Ui::e_config_label( 'cdn.admin.media_library' ) ?></label><br />
204
  <span class="description">All Media Library content will use <acronym title="Content Delivery Network">CDN</acronym> links on administration pages.</span>
205
  </th>
206
+ </tr>
207
  <tr>
208
+ <th colspan="2">
209
+ <?php $this->checkbox( 'cdn.cors_header' ) ?> Add <acronym title="Access-Control-Allow-Origin">CORS</acronym> header</label><br />
210
  <span class="description">Add <acronym title="Access-Control-Allow-Origin">CORS</acronym> headers to allow cross-domain assets usage.</span>
211
  </th>
212
+ </tr>
213
 
214
  <tr>
215
  <th colspan="2">
233
  <textarea id="cdn_reject_uri" name="cdn__reject__uri"
234
  <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>
235
  cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $this->_config->get_array( 'cdn.reject.uri' ) ) ); ?></textarea><br />
236
+ <span class="description"><?php echo sprintf( __( 'Always ignore the specified pages / directories. Supports regular expression (See <a href="%s"><acronym title="Frequently Asked Questions">FAQ</acronym></a>)' ), network_admin_url( 'admin.php?page=w3tc_faq' ) ) ?></span>
237
  </td>
238
  </tr>
239
  <tr>
inc/options/cdn/azure.php CHANGED
@@ -46,7 +46,7 @@ if ( !defined( 'W3TC' ) )
46
  <?php echo esc_attr( $cdn_azure_user ); ?>.blob.core.windows.net
47
  <?php else: ?>
48
  &lt;account name&gt;.blob.core.windows.net
49
- <?php endif; ?> <?php _e( 'or CNAME:', 'w3-total-cache' ); ?>
50
  <?php $cnames = $this->_config->get_array( 'cdn.azure.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
51
  </td>
52
  </tr>
46
  <?php echo esc_attr( $cdn_azure_user ); ?>.blob.core.windows.net
47
  <?php else: ?>
48
  &lt;account name&gt;.blob.core.windows.net
49
+ <?php endif; ?> <?php _e( 'or <acronym title="Canonical Name">CNAME</acronym>:', 'w3-total-cache' ); ?>
50
  <?php $cnames = $this->_config->get_array( 'cdn.azure.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
51
  </td>
52
  </tr>
inc/options/cdn/cf.php CHANGED
@@ -6,49 +6,49 @@ if ( !defined( 'W3TC' ) )
6
 
7
  ?>
8
  <tr>
9
- <th colspan="2">
10
- <span class="description"><?php _e( 'We recommend that you use <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/AccessPolicyLanguage_KeyConcepts.html" target="_blank"><acronym title="AWS Identity and Access Management">IAM</acronym></a> to create a new policy for <acronym title="Amazon Web Services">AWS</acronym> services that have limited permissions. A helpful tool: <a href="http://awspolicygen.s3.amazonaws.com/policygen.html" target="_blank"><acronym title="Amazon Web Services">AWS</acronym> Policy Generator</a>', 'w3-total-cache' ); ?></span>
11
- </th>
12
  </tr>
13
  <tr>
14
  <th style="width: 300px;"><label for="cdn_cf_key"><?php _e( 'Access key ID:', 'w3-total-cache' ); ?></label></th>
15
  <td>
16
  <input id="cdn_cf_key" class="w3tc-ignore-change" type="text"
17
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__cf__key" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf.key' ) ); ?>" size="30" />
18
  </td>
19
  </tr>
20
  <tr>
21
  <th><label for="cdn_cf_secret"><?php _e( 'Secret key:', 'w3-total-cache' ); ?></label></th>
22
  <td>
23
  <input id="cdn_cf_secret" class="w3tc-ignore-change" type="password"
24
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__cf__secret" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf.secret' ) ); ?>" size="60" />
25
  </td>
26
  </tr>
27
  <tr>
28
  <th><label for="cdn_cf_bucket"><?php _e( 'Bucket:', 'w3-total-cache' ); ?></label></th>
29
- <td>
30
- <input id="cdn_cf_bucket" type="text" name="cdn__cf__bucket"
31
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> value="<?php echo esc_attr( strtolower( $this->_config->get_string( 'cdn.cf.bucket' ) ) ); ?>" size="30" />
32
- <select id="cdn_cf_bucket_location" name="cdn__cf__bucket__location" style="margin-top:-4px">
33
- <option value="" style="display:none;">Select Bucket Location</option>
34
- <option value="us-east-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-east-1' ); ?>>US East (N. Virginia)</option>
35
- <option value="us-east-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-east-2' ); ?>>US East (Ohio)</option>
36
- <option value="us-west-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-west-1' ); ?>>US-West (N. California)</option>
37
- <option value="us-west-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-west-2' ); ?>>US-West (Oregon)</option>
38
- <option value="ca-central-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ca-central-1' ); ?>>Canada (Montreal)</option>
39
- <option value="ap-south-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-south-1' ); ?>>Asia Pacific (Mumbai)</option>
40
- <option value="ap-northeast-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-northeast-2' ); ?>>Asia Pacific (Seoul)</option>
41
- <option value="ap-southeast-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-southeast-1' ); ?>>Asia Pacific (Singapore)</option>
42
- <option value="ap-southeast-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-southeast-2' ); ?>>Asia Pacific (Sydney)</option>
43
- <option value="ap-northeast-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-northeast-1' ); ?>>Asia Pacific (Tokyo)</option>
44
- <option value="eu-central-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'eu-central-1' ); ?>>EU (Frankfurt)</option>
45
- <option value="eu-west-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'eu-west-1' ); ?>>EU (Ireland)</option>
46
- <option value="eu-west-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'eu-west-2' ); ?>>EU (London)</option>
47
- <option value="sa-east-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'sa-east-1' ); ?>>South America (S&atilde;o Paulo)</option>
48
- </select>
49
- <b>or</b>
50
- <input id="cdn_create_container" class="button {type: 'cf', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Create as new bucket with distribution', 'w3-total-cache' ); ?>" /> <span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
51
- </td>
52
  </tr>
53
  <tr>
54
  <th><label for="cdn_cf_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support:', 'w3-total-cache' ); ?></label></th>
@@ -58,20 +58,20 @@ if ( !defined( 'W3TC' ) )
58
  <option value="enabled"<?php selected( $this->_config->get_string( 'cdn.cf.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
59
  <option value="disabled"<?php selected( $this->_config->get_string( 'cdn.cf.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
60
  </select>
61
- <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' ); ?></span>
62
  </td>
63
  </tr>
64
  <tr>
65
  <th><label for="cdn_cf_id"><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></label></th>
66
  <td>
67
  <input id="cdn_cf_id" type="text" name="cdn__cf__id"
68
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf.id' ) ); ?>" size="18" style="text-align: right;" />.cloudfront.net or CNAME:
69
  <?php $cnames = $this->_config->get_array( 'cdn.cf.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
70
- <br /><span class="description"><?php _e( '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.', 'w3-total-cache' ); ?></span>
71
  </td>
72
  </tr>
73
  <tr>
74
  <th colspan="2">
75
- <input id="cdn_test" class="button {type: 'cf', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test S3 upload &amp; CloudFront distribution', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
76
- </th>
77
  </tr>
6
 
7
  ?>
8
  <tr>
9
+ <th colspan="2">
10
+ <span class="description"><?php _e( 'We recommend that you use <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/AccessPolicyLanguage_KeyConcepts.html" target="_blank"><acronym title="AWS Identity and Access Management">IAM</acronym></a> to create a new policy for <acronym title="Amazon Web Services">AWS</acronym> services that have limited permissions. A helpful tool: <a href="http://awspolicygen.s3.amazonaws.com/policygen.html" target="_blank"><acronym title="Amazon Web Services">AWS</acronym> Policy Generator</a>', 'w3-total-cache' ); ?></span>
11
+ </th>
12
  </tr>
13
  <tr>
14
  <th style="width: 300px;"><label for="cdn_cf_key"><?php _e( 'Access key ID:', 'w3-total-cache' ); ?></label></th>
15
  <td>
16
  <input id="cdn_cf_key" class="w3tc-ignore-change" type="text"
17
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__cf__key" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf.key' ) ); ?>" size="30" />
18
  </td>
19
  </tr>
20
  <tr>
21
  <th><label for="cdn_cf_secret"><?php _e( 'Secret key:', 'w3-total-cache' ); ?></label></th>
22
  <td>
23
  <input id="cdn_cf_secret" class="w3tc-ignore-change" type="password"
24
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__cf__secret" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf.secret' ) ); ?>" size="60" />
25
  </td>
26
  </tr>
27
  <tr>
28
  <th><label for="cdn_cf_bucket"><?php _e( 'Bucket:', 'w3-total-cache' ); ?></label></th>
29
+ <td>
30
+ <input id="cdn_cf_bucket" type="text" name="cdn__cf__bucket"
31
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> value="<?php echo esc_attr( strtolower( $this->_config->get_string( 'cdn.cf.bucket' ) ) ); ?>" size="30" />
32
+ <select id="cdn_cf_bucket_location" name="cdn__cf__bucket__location" style="margin-top:-4px">
33
+ <option value="" style="display:none;">Select Bucket Location</option>
34
+ <option value="us-east-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-east-1' ); ?>>US East (N. Virginia)</option>
35
+ <option value="us-east-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-east-2' ); ?>>US East (Ohio)</option>
36
+ <option value="us-west-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-west-1' ); ?>>US-West (N. California)</option>
37
+ <option value="us-west-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'us-west-2' ); ?>>US-West (Oregon)</option>
38
+ <option value="ca-central-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ca-central-1' ); ?>>Canada (Montreal)</option>
39
+ <option value="ap-south-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-south-1' ); ?>>Asia Pacific (Mumbai)</option>
40
+ <option value="ap-northeast-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-northeast-2' ); ?>>Asia Pacific (Seoul)</option>
41
+ <option value="ap-southeast-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-southeast-1' ); ?>>Asia Pacific (Singapore)</option>
42
+ <option value="ap-southeast-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-southeast-2' ); ?>>Asia Pacific (Sydney)</option>
43
+ <option value="ap-northeast-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'ap-northeast-1' ); ?>>Asia Pacific (Tokyo)</option>
44
+ <option value="eu-central-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'eu-central-1' ); ?>>EU (Frankfurt)</option>
45
+ <option value="eu-west-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'eu-west-1' ); ?>>EU (Ireland)</option>
46
+ <option value="eu-west-2"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'eu-west-2' ); ?>>EU (London)</option>
47
+ <option value="sa-east-1"<?php selected( $this->_config->get_string( 'cdn.cf.bucket.location' ), 'sa-east-1' ); ?>>South America (S&atilde;o Paulo)</option>
48
+ </select>
49
+ <b>or</b>
50
+ <input id="cdn_create_container" class="button {type: 'cf', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Create as new bucket with distribution', 'w3-total-cache' ); ?>" /> <span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
51
+ </td>
52
  </tr>
53
  <tr>
54
  <th><label for="cdn_cf_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support:', 'w3-total-cache' ); ?></label></th>
58
  <option value="enabled"<?php selected( $this->_config->get_string( 'cdn.cf.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
59
  <option value="disabled"<?php selected( $this->_config->get_string( 'cdn.cf.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
60
  </select>
61
+ <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' ); ?></span>
62
  </td>
63
  </tr>
64
  <tr>
65
  <th><label for="cdn_cf_id"><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></label></th>
66
  <td>
67
  <input id="cdn_cf_id" type="text" name="cdn__cf__id"
68
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf.id' ) ); ?>" size="18" style="text-align: right;" />.cloudfront.net or <acronym title="Canonical Name">CNAME</acronym>:
69
  <?php $cnames = $this->_config->get_array( 'cdn.cf.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
70
+ <br /><span class="description"><?php _e( 'If you have already added a <a href="http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?CNAMEs.html" target="_blank"><acronym title="Canonical Name">CNAME</acronym></a> to your <acronym title="Domain Name System">DNS</acronym> Zone, enter it here.', 'w3-total-cache' ); ?></span>
71
  </td>
72
  </tr>
73
  <tr>
74
  <th colspan="2">
75
+ <input id="cdn_test" class="button {type: 'cf', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test S3 upload &amp; CloudFront distribution', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
76
+ </th>
77
  </tr>
inc/options/cdn/cf2.php CHANGED
@@ -6,22 +6,22 @@ if ( !defined( 'W3TC' ) )
6
 
7
  ?>
8
  <tr>
9
- <th colspan="2">
10
- <span class="description"><?php _e( 'We recommend that you use <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/AccessPolicyLanguage_KeyConcepts.html" target="_blank"><acronym title="AWS Identity and Access Management">IAM</acronym></a> to create a new policy for <acronym title="Amazon Web Services">AWS</acronym> services that have limited permissions. A helpful tool: <a href="http://awspolicygen.s3.amazonaws.com/policygen.html" target="_blank"><acronym title="Amazon Web Services">AWS</acronym> Policy Generator</a>', 'w3-total-cache' ); ?></span>
11
- </th>
12
  </tr>
13
  <tr>
14
  <th style="width: 300px;"><label for="cdn_cf2_key"><?php _e( 'Access key ID:', 'w3-total-cache' ); ?></label></th>
15
  <td>
16
  <input id="cdn_cf2_key" class="w3tc-ignore-change" type="text"
17
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__cf2__key" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf2.key' ) ); ?>" size="30" />
18
  </td>
19
  </tr>
20
  <tr>
21
  <th><label for="cdn_cf2_secret"><?php _e( 'Secret key:', 'w3-total-cache' ); ?></label></th>
22
  <td>
23
  <input id="cdn_cf2_secret" class="w3tc-ignore-change"
24
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> type="password" name="cdn__cf2__secret" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf2.secret' ) ); ?>" size="60" />
25
  </td>
26
  </tr>
27
  <tr>
@@ -29,8 +29,8 @@ if ( !defined( 'W3TC' ) )
29
  <td>
30
  <?php echo Util_Environment::host_port(); ?>
31
  <input id="cdn_create_container"
32
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> class="button {type: 'cf2', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Create distribution', 'w3-total-cache' ); ?>" />
33
- <span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
34
  </td>
35
  </tr>
36
  <tr>
@@ -41,20 +41,20 @@ if ( !defined( 'W3TC' ) )
41
  <option value="enabled"<?php selected( $this->_config->get_string( 'cdn.cf2.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
42
  <option value="disabled"<?php selected( $this->_config->get_string( 'cdn.cf2.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
43
  </select>
44
- <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' ); ?></span>
45
  </td>
46
  </tr>
47
  <tr>
48
  <th><label for="cdn_cf2_id"><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></label></th>
49
  <td>
50
  <input id="cdn_cf2_id" type="text" name="cdn__cf2__id"
51
- <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf2.id' ) ); ?>" size="18" style="text-align: right;" />.cloudfront.net or CNAME:
52
  <?php $cnames = $this->_config->get_array( 'cdn.cf2.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
53
- <br /><span class="description"><?php _e( '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.', 'w3-total-cache' ); ?></span>
54
  </td>
55
  </tr>
56
  <tr>
57
  <th colspan="2">
58
- <input id="cdn_test" class="button {type: 'cf2', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test CloudFront distribution', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
59
- </th>
60
  </tr>
6
 
7
  ?>
8
  <tr>
9
+ <th colspan="2">
10
+ <span class="description"><?php _e( 'We recommend that you use <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/AccessPolicyLanguage_KeyConcepts.html" target="_blank"><acronym title="AWS Identity and Access Management">IAM</acronym></a> to create a new policy for <acronym title="Amazon Web Services">AWS</acronym> services that have limited permissions. A helpful tool: <a href="http://awspolicygen.s3.amazonaws.com/policygen.html" target="_blank"><acronym title="Amazon Web Services">AWS</acronym> Policy Generator</a>', 'w3-total-cache' ); ?></span>
11
+ </th>
12
  </tr>
13
  <tr>
14
  <th style="width: 300px;"><label for="cdn_cf2_key"><?php _e( 'Access key ID:', 'w3-total-cache' ); ?></label></th>
15
  <td>
16
  <input id="cdn_cf2_key" class="w3tc-ignore-change" type="text"
17
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__cf2__key" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf2.key' ) ); ?>" size="30" />
18
  </td>
19
  </tr>
20
  <tr>
21
  <th><label for="cdn_cf2_secret"><?php _e( 'Secret key:', 'w3-total-cache' ); ?></label></th>
22
  <td>
23
  <input id="cdn_cf2_secret" class="w3tc-ignore-change"
24
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> type="password" name="cdn__cf2__secret" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf2.secret' ) ); ?>" size="60" />
25
  </td>
26
  </tr>
27
  <tr>
29
  <td>
30
  <?php echo Util_Environment::host_port(); ?>
31
  <input id="cdn_create_container"
32
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> class="button {type: 'cf2', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Create distribution', 'w3-total-cache' ); ?>" />
33
+ <span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
34
  </td>
35
  </tr>
36
  <tr>
41
  <option value="enabled"<?php selected( $this->_config->get_string( 'cdn.cf2.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
42
  <option value="disabled"<?php selected( $this->_config->get_string( 'cdn.cf2.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
43
  </select>
44
+ <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' ); ?></span>
45
  </td>
46
  </tr>
47
  <tr>
48
  <th><label for="cdn_cf2_id"><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></label></th>
49
  <td>
50
  <input id="cdn_cf2_id" type="text" name="cdn__cf2__id"
51
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> value="<?php echo esc_attr( $this->_config->get_string( 'cdn.cf2.id' ) ); ?>" size="18" style="text-align: right;" />.cloudfront.net or <acronym title="Canonical Name">CNAME</acronym>:
52
  <?php $cnames = $this->_config->get_array( 'cdn.cf2.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
53
+ <br /><span class="description"><?php _e( 'If you have already added a <a href="http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?CNAMEs.html" target="_blank"><acronym title="Canonical Name">CNAME</acronym></a> to your <acronym title="Domain Name System">DNS</acronym> Zone, enter it here.', 'w3-total-cache' ); ?></span>
54
  </td>
55
  </tr>
56
  <tr>
57
  <th colspan="2">
58
+ <input id="cdn_test" class="button {type: 'cf2', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test CloudFront distribution', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
59
+ </th>
60
  </tr>
inc/options/cdn/common/cnames.php CHANGED
@@ -2,13 +2,13 @@
2
  namespace W3TC;
3
 
4
  if (!defined('W3TC'))
5
- die();
6
 
7
  ?>
8
- <ol id="cdn_cnames">
9
  <?php
10
  if (! count($cnames)) {
11
- $cnames = array('');
12
  }
13
 
14
  $count = count( $cnames );
@@ -23,40 +23,40 @@ foreach ( $cnames as $index => $cname ):
23
  continue;
24
  }
25
 
26
- $label = '';
27
 
28
- if ($count > 1):
29
- switch ($real_index):
30
- case 0:
31
- $label = __('(reserved for CSS)', 'w3-total-cache');
32
- break;
33
 
34
- case 1:
35
- $label = __('(reserved for JS in <head>)', 'w3-total-cache');
36
- break;
37
 
38
- case 2:
39
- $label = __('(reserved for JS after <body>)', 'w3-total-cache');
40
- break;
41
 
42
- case 3:
43
- $label = __('(reserved for JS before </body>)', 'w3-total-cache');
44
- break;
45
 
46
- default:
47
- $label = '';
48
- break;
49
- endswitch;
50
- endif;
51
  ?>
52
  <li>
53
- <input type="text" name="cdn_cnames[]"
54
- <?php Util_Ui::sealing_disabled('cdn.') ?> value="<?php echo esc_attr($cname); ?>" size="60" />
55
  <input class="button cdn_cname_delete" type="button"
56
- <?php Util_Ui::sealing_disabled('cdn.') ?> value="<?php _e('Delete', 'w3-total-cache'); ?>"<?php if (!$index): ?> style="display: none;"<?php endif; ?> />
57
  <span><?php echo htmlspecialchars($label); ?></span>
58
  </li>
59
  <?php $real_index++; endforeach; ?>
60
  </ol>
61
  <input id="cdn_cname_add" class="button" type="button" value="<?php _e('Add CNAME', 'w3-total-cache'); ?>"
62
- <?php Util_Ui::sealing_disabled('cdn.') ?> />
2
  namespace W3TC;
3
 
4
  if (!defined('W3TC'))
5
+ die();
6
 
7
  ?>
8
+ <ol id="cdn_cnames" style="margin: 0">
9
  <?php
10
  if (! count($cnames)) {
11
+ $cnames = array('');
12
  }
13
 
14
  $count = count( $cnames );
23
  continue;
24
  }
25
 
26
+ $label = '';
27
 
28
+ if ($count > 1):
29
+ switch ($real_index):
30
+ case 0:
31
+ $label = __('(reserved for CSS)', 'w3-total-cache');
32
+ break;
33
 
34
+ case 1:
35
+ $label = __('(reserved for JS in <head>)', 'w3-total-cache');
36
+ break;
37
 
38
+ case 2:
39
+ $label = __('(reserved for JS after <body>)', 'w3-total-cache');
40
+ break;
41
 
42
+ case 3:
43
+ $label = __('(reserved for JS before </body>)', 'w3-total-cache');
44
+ break;
45
 
46
+ default:
47
+ $label = '';
48
+ break;
49
+ endswitch;
50
+ endif;
51
  ?>
52
  <li>
53
+ <input type="text" name="cdn_cnames[]" id="cdn_cnames_<?php echo $real_index ?>"
54
+ <?php Util_Ui::sealing_disabled('cdn.') ?> value="<?php echo esc_attr($cname); ?>" size="60" />
55
  <input class="button cdn_cname_delete" type="button"
56
+ <?php Util_Ui::sealing_disabled('cdn.') ?> value="<?php _e('Delete', 'w3-total-cache'); ?>"<?php if (!$index): ?> style="display: none;"<?php endif; ?> />
57
  <span><?php echo htmlspecialchars($label); ?></span>
58
  </li>
59
  <?php $real_index++; endforeach; ?>
60
  </ol>
61
  <input id="cdn_cname_add" class="button" type="button" value="<?php _e('Add CNAME', 'w3-total-cache'); ?>"
62
+ <?php Util_Ui::sealing_disabled('cdn.') ?> />
inc/options/cdn/ftp.php CHANGED
@@ -25,6 +25,7 @@ if ( !defined( 'W3TC' ) )
25
  <select id="cdn_ftp_type" name="cdn__ftp__type" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
26
  <option value=""<?php selected( $this->_config->get_string( 'cdn.ftp.type' ), '' ); ?>><?php _e( 'Plain FTP', 'w3-total-cache' ); ?></option>
27
  <option value="ftps"<?php selected( $this->_config->get_string( 'cdn.ftp.type' ), 'ftps' ); ?>><?php _e( 'SSL-FTP connection (FTPS)', 'w3-total-cache' ); ?></option>
 
28
  </select>
29
  </td>
30
  </tr>
@@ -61,11 +62,31 @@ if ( !defined( 'W3TC' ) )
61
  <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' ); ?></span>
62
  </td>
63
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  <tr>
65
  <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
66
  <td>
67
  <?php $cnames = $this->_config->get_array( 'cdn.ftp.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
68
- <br /><span class="description"><?php _e( 'Enter the hostname or CNAME(s) of your <acronym title="File Transfer Protocol">FTP</acronym> server configured above, these values will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
69
  </td>
70
  </tr>
71
  <tr>
25
  <select id="cdn_ftp_type" name="cdn__ftp__type" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
26
  <option value=""<?php selected( $this->_config->get_string( 'cdn.ftp.type' ), '' ); ?>><?php _e( 'Plain FTP', 'w3-total-cache' ); ?></option>
27
  <option value="ftps"<?php selected( $this->_config->get_string( 'cdn.ftp.type' ), 'ftps' ); ?>><?php _e( 'SSL-FTP connection (FTPS)', 'w3-total-cache' ); ?></option>
28
+ <option value="sftp"<?php selected( $this->_config->get_string( 'cdn.ftp.type' ), 'sftp' ); echo function_exists( 'ssh2_connect' ) ? '' : ' disabled'; ?>><?php _e( 'FTP over SSH (SFTP)', 'w3-total-cache' ); ?></option>
29
  </select>
30
  </td>
31
  </tr>
62
  <br /><span class="description"><?php _e( 'Some <acronym title="Content Delivery Network">CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.', 'w3-total-cache' ); ?></span>
63
  </td>
64
  </tr>
65
+ <tr>
66
+ <th colspan="2">
67
+ <?php $this->checkbox( 'cdn.ftp.default_keys', !function_exists( 'ssh2_connect' ) ) ?> <?php _e( 'Use default <acronym title="Secure Shell">SSH</acronym> public/private key files', 'w3-total-cache' ); ?></label><br />
68
+ <span class="description"><?php _e( 'Enable this option if you don\'t have special public/private key files.', 'w3-total-cache' ); ?></span>
69
+ </th>
70
+ </tr>
71
+ <tr>
72
+ <th><label for="cdn_ftp_pubkey"><?php _e( '<acronym title="Secure File Transfer Protocol">SFTP</acronym> public key:', 'w3-total-cache' ); ?></label></th>
73
+ <td>
74
+ <input id="cdn_ftp_pubkey" class="w3tc-ignore-change" type="text"
75
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__ftp__pubkey" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.ftp.pubkey' ) ); ?>" size="30" <?php echo function_exists( 'ssh2_connect' ) ? '' : 'disabled'; ?> />
76
+ </td>
77
+ </tr>
78
+ <tr>
79
+ <th><label for="cdn_ftp_privkey"><?php _e( '<acronym title="Secure File Transfer Protocol">SFTP</acronym> private key:', 'w3-total-cache' ); ?></label></th>
80
+ <td>
81
+ <input id="cdn_ftp_privkey" class="w3tc-ignore-change" type="text"
82
+ <?php Util_Ui::sealing_disabled( 'cdn.' ) ?> name="cdn__ftp__privkey" value="<?php echo esc_attr( $this->_config->get_string( 'cdn.ftp.privkey' ) ); ?>" size="30" <?php echo function_exists( 'ssh2_connect' ) ? '' : 'disabled'; ?> />
83
+ </td>
84
+ </tr>
85
  <tr>
86
  <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
87
  <td>
88
  <?php $cnames = $this->_config->get_array( 'cdn.ftp.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
89
+ <br /><span class="description"><?php _e( 'Enter the hostname or <acronym title="Canonical Name">CNAME</acronym>(s) of your <acronym title="File Transfer Protocol">FTP</acronym> server configured above, these values will replace your site\'s hostname in the <acronym title="Hypertext Markup Language">HTML</acronym>.', 'w3-total-cache' ); ?></span>
90
  </td>
91
  </tr>
92
  <tr>
inc/options/common/header.php CHANGED
@@ -5,19 +5,20 @@ if ( !defined( 'W3TC' ) )
5
  die();
6
 
7
  $config = Dispatcher::config();
 
8
  $page = Util_Admin::get_current_page();
9
  $licensing_visible = ( ( !Util_Environment::is_wpmu() || is_network_admin() ) &&
10
  !ini_get( 'w3tc.license_key' ) &&
11
- get_transient( 'w3tc_license_status' ) != 'host_valid' );
12
  ?>
13
 
14
  <?php do_action( 'w3tc-dashboard-head' ) ?>
15
  <div class="wrap" id="w3tc">
16
- <h2 class="logo"><?php _e( 'W3 Total Cache <span>by W3 EDGE <sup>&reg;</sup></span>', 'w3-total-cache' ); ?></h2>
17
  <?php if ( !Util_Environment::is_w3tc_pro( $config ) ): ?>
18
- <?php include W3TC_INC_OPTIONS_DIR . '/edd/buy.php' ?>
19
  <?php endif ?>
20
- <?php
21
  switch ( $page ) {
22
  case 'w3tc_general':
23
  $anchors = array(
@@ -35,7 +36,7 @@ $licensing_visible = ( ( !Util_Environment::is_wpmu() || is_network_admin() ) &&
35
  array( 'id' => 'cdn', 'text' => __( '<abbr title="Content Delivery Network">CDN</abbr>', 'w3-total-cache' ) ),
36
  array( 'id' => 'reverse_proxy', 'text' => __( 'Reverse Proxy', 'w3-total-cache' ) ) ) );
37
  if ( Util_Environment::is_w3tc_pro() )
38
- $anchors[] = array( 'id' => 'amazon_sns', 'text' => __( 'Amazon <abbr title="Simple Notification Service">SNS</abbr>', 'w3-total-cache' ) );
39
  $anchors[] = array( 'id' => 'monitoring', 'text' => __( 'Monitoring', 'w3-total-cache' ) );
40
  if ( $licensing_visible )
41
  array( 'id' => 'licensing', 'text' => __( 'Licensing', 'w3-total-cache' ) );
@@ -53,104 +54,121 @@ $licensing_visible = ( ( !Util_Environment::is_wpmu() || is_network_admin() ) &&
53
  $links[] = '<a href="#" class="button-self-test">Compatibility Test</a>';
54
 
55
  ?>
56
- <p id="w3tc-options-menu">
57
- <?php echo implode( ' | ', $links ); ?>
58
- </p>
59
- <?php
60
  break;
61
  ?>
62
- <?php
63
  case 'w3tc_pgcache':
64
  ?>
65
- <p id="w3tc-options-menu">
66
- Jump to:
67
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
68
- <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
69
- <a href="#mirrors"><?php _e( 'Mirrors', 'w3-total-cache' ); ?></a> |
70
- <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a> |
71
- <a href="#cache_preload"><?php _e( 'Cache Preload', 'w3-total-cache' ); ?></a> |
72
- <a href="#purge_policy"><?php _e( 'Purge Policy', 'w3-total-cache' ); ?></a> |
73
- <a href="#notes"><?php _e( 'Note(s)', 'w3-total-cache' ); ?></a>
74
- </p>
75
- <?php
76
  break;
77
  ?>
78
- <?php
79
  case 'w3tc_minify':
80
  ?>
81
- <p id="w3tc-options-menu">
82
- <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
83
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
84
- <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
85
- <a href="#html_xml"><?php _e( '<acronym title="Hypertext Markup Language">HTML</acronym> &amp; <acronym title="eXtensible Markup Language">XML</acronym>', 'w3-total-cache' ); ?></a> |
86
- <a href="#js"><?php _e( '<acronym title="JavaScript">JS</acronym>', 'w3-total-cache' ); ?></a> |
87
- <a href="#css"><?php _e( '<acronym title="Cascading Style Sheet">CSS</acronym>', 'w3-total-cache' ); ?></a> |
88
- <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a> |
89
- <a href="#notes"><?php _e( 'Note(s)', 'w3-total-cache' ); ?></a>
90
- </p>
91
- <?php
92
  break;
93
  ?>
94
- <?php
95
  case 'w3tc_dbcache':
96
  ?>
97
- <p id="w3tc-options-menu">
98
- <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
99
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
100
- <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
101
- <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a>
102
- </p>
103
- <?php
104
  break;
105
  ?>
106
- <?php
107
  case 'w3tc_objectcache':
108
  ?>
109
- <p id="w3tc-options-menu">
110
- <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
111
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
112
- <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a>
113
- </p>
114
- <?php
115
  break;
116
  ?>
117
- <?php
118
  case 'w3tc_browsercache':
119
  ?>
120
- <p id="w3tc-options-menu">
121
- <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
122
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
123
- <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
124
- <a href="#css_js"><?php _e( '<acronym title="Cascading Style Sheet">CSS</acronym> &amp; <acronym title="JavaScript">JS</acronym>', 'w3-total-cache' ); ?></a> |
125
- <a href="#html_xml"><?php _e( '<acronym title="Hypertext Markup Language">HTML</acronym> &amp; <acronym title="eXtensible Markup Language">XML</acronym>', 'w3-total-cache' ); ?></a> |
126
- <a href="#media"><?php _e( 'Media', 'w3-total-cache' ); ?></a> |
127
- <a href="#security"><?php _e( 'Security Headers', 'w3-total-cache' ); ?></a>
128
- </p>
129
- <?php
130
  break;
131
  ?>
132
- <?php
133
  case 'w3tc_mobile':
134
  ?>
135
- <p id="w3tc-options-menu">
136
- <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
137
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
138
- <a href="#manage"><?php _e( 'Manage User Agent Groups', 'w3-total-cache' ); ?></a>
139
- </p>
140
- <?php
141
  break;
142
  ?>
143
- <?php
144
  case 'w3tc_referrer':
145
  ?>
146
- <p id="w3tc-options-menu">
147
- <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
148
- <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
149
- <a href="#manage"><?php _e( 'Manage Referrer Groups', 'w3-total-cache' ); ?></a>
150
- </p>
151
- <?php
152
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  ?>
154
- <?php
155
  }
156
  ?>
5
  die();
6
 
7
  $config = Dispatcher::config();
8
+ $state = Dispatcher::config_state();
9
  $page = Util_Admin::get_current_page();
10
  $licensing_visible = ( ( !Util_Environment::is_wpmu() || is_network_admin() ) &&
11
  !ini_get( 'w3tc.license_key' ) &&
12
+ $state->get_string( 'license.status' ) != 'host_valid' );
13
  ?>
14
 
15
  <?php do_action( 'w3tc-dashboard-head' ) ?>
16
  <div class="wrap" id="w3tc">
17
+ <h2 class="logo"><?php _e( 'W3 Total Cache <span>by W3 EDGE <sup>&reg;</sup></span>', 'w3-total-cache' ); ?></h2>
18
  <?php if ( !Util_Environment::is_w3tc_pro( $config ) ): ?>
19
+ <?php include W3TC_INC_OPTIONS_DIR . '/edd/buy.php' ?>
20
  <?php endif ?>
21
+ <?php
22
  switch ( $page ) {
23
  case 'w3tc_general':
24
  $anchors = array(
36
  array( 'id' => 'cdn', 'text' => __( '<abbr title="Content Delivery Network">CDN</abbr>', 'w3-total-cache' ) ),
37
  array( 'id' => 'reverse_proxy', 'text' => __( 'Reverse Proxy', 'w3-total-cache' ) ) ) );
38
  if ( Util_Environment::is_w3tc_pro() )
39
+ $anchors[] = array( 'id' => 'amazon_sns', 'text' => __( 'Message Bus', 'w3-total-cache' ) );
40
  $anchors[] = array( 'id' => 'monitoring', 'text' => __( 'Monitoring', 'w3-total-cache' ) );
41
  if ( $licensing_visible )
42
  array( 'id' => 'licensing', 'text' => __( 'Licensing', 'w3-total-cache' ) );
54
  $links[] = '<a href="#" class="button-self-test">Compatibility Test</a>';
55
 
56
  ?>
57
+ <p id="w3tc-options-menu">
58
+ <?php echo implode( ' | ', $links ); ?>
59
+ </p>
60
+ <?php
61
  break;
62
  ?>
63
+ <?php
64
  case 'w3tc_pgcache':
65
  ?>
66
+ <p id="w3tc-options-menu">
67
+ Jump to:
68
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
69
+ <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
70
+ <a href="#mirrors"><?php _e( 'Mirrors', 'w3-total-cache' ); ?></a> |
71
+ <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a> |
72
+ <a href="#cache_preload"><?php _e( 'Cache Preload', 'w3-total-cache' ); ?></a> |
73
+ <a href="#purge_policy"><?php _e( 'Purge Policy', 'w3-total-cache' ); ?></a> |
74
+ <a href="#notes"><?php _e( 'Note(s)', 'w3-total-cache' ); ?></a>
75
+ </p>
76
+ <?php
77
  break;
78
  ?>
79
+ <?php
80
  case 'w3tc_minify':
81
  ?>
82
+ <p id="w3tc-options-menu">
83
+ <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
84
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
85
+ <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
86
+ <a href="#html_xml"><?php _e( '<acronym title="Hypertext Markup Language">HTML</acronym> &amp; <acronym title="eXtensible Markup Language">XML</acronym>', 'w3-total-cache' ); ?></a> |
87
+ <a href="#js"><?php _e( '<acronym title="JavaScript">JS</acronym>', 'w3-total-cache' ); ?></a> |
88
+ <a href="#css"><?php _e( '<acronym title="Cascading Style Sheet">CSS</acronym>', 'w3-total-cache' ); ?></a> |
89
+ <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a> |
90
+ <a href="#notes"><?php _e( 'Note(s)', 'w3-total-cache' ); ?></a>
91
+ </p>
92
+ <?php
93
  break;
94
  ?>
95
+ <?php
96
  case 'w3tc_dbcache':
97
  ?>
98
+ <p id="w3tc-options-menu">
99
+ <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
100
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
101
+ <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
102
+ <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a>
103
+ </p>
104
+ <?php
105
  break;
106
  ?>
107
+ <?php
108
  case 'w3tc_objectcache':
109
  ?>
110
+ <p id="w3tc-options-menu">
111
+ <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
112
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
113
+ <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a>
114
+ </p>
115
+ <?php
116
  break;
117
  ?>
118
+ <?php
119
  case 'w3tc_browsercache':
120
  ?>
121
+ <p id="w3tc-options-menu">
122
+ <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
123
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
124
+ <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
125
+ <a href="#css_js"><?php _e( '<acronym title="Cascading Style Sheet">CSS</acronym> &amp; <acronym title="JavaScript">JS</acronym>', 'w3-total-cache' ); ?></a> |
126
+ <a href="#html_xml"><?php _e( '<acronym title="Hypertext Markup Language">HTML</acronym> &amp; <acronym title="eXtensible Markup Language">XML</acronym>', 'w3-total-cache' ); ?></a> |
127
+ <a href="#media"><?php _e( 'Media', 'w3-total-cache' ); ?></a> |
128
+ <a href="#security"><?php _e( 'Security Headers', 'w3-total-cache' ); ?></a>
129
+ </p>
130
+ <?php
131
  break;
132
  ?>
133
+ <?php
134
  case 'w3tc_mobile':
135
  ?>
136
+ <p id="w3tc-options-menu">
137
+ <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
138
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
139
+ <a href="#manage"><?php _e( 'Manage User Agent Groups', 'w3-total-cache' ); ?></a>
140
+ </p>
141
+ <?php
142
  break;
143
  ?>
144
+ <?php
145
  case 'w3tc_referrer':
146
  ?>
147
+ <p id="w3tc-options-menu">
148
+ <?php _e( 'Jump to: ', 'w3-total-cache' ); ?>
149
+ <a href="#toplevel_page_w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
150
+ <a href="#manage"><?php _e( 'Manage Referrer Groups', 'w3-total-cache' ); ?></a>
151
+ </p>
152
+ <?php
153
  break;
154
+
155
+ case 'w3tc_install':
156
+ ?>
157
+ <p id="w3tc-options-menu">
158
+ Jump to:
159
+ <a href="#initial"><?php _e( 'Initial Installation', 'w3-total-cache' ); ?></a> |
160
+ <?php if ( count( $rewrite_rules_descriptors ) ): ?>
161
+ <a href="#rules"><?php _e( 'Rewrite Rules', 'w3-total-cache' ); ?></a> |
162
+ <?php endif ?>
163
+ <?php if ( count( $other_areas ) ): ?>
164
+ <a href="#other"><?php _e( 'Other', 'w3-total-cache' ); ?></a> |
165
+ <?php endif ?>
166
+ <a href="#additional"><?php _e( 'Services', 'w3-total-cache' ); ?></a> |
167
+ <a href="#modules"><?php _e( '<acronym title="Hypertext Preprocessor">PHP</acronym> Modules', 'w3-total-cache' ); ?></a>
168
+ </p>
169
+ <?php
170
+ break;
171
  ?>
172
+ <?php
173
  }
174
  ?>
inc/options/dashboard.php CHANGED
@@ -36,7 +36,7 @@ echo implode( " $string ", apply_filters( 'w3tc_dashboard_actions', array() ) )
36
  <div id="w3tc-dashboard-widgets" class="clearfix widefat metabox-holder">
37
  <?php $screen = get_current_screen();
38
  ?>
39
- <div id="postbox-container-left" style="float: left;">
40
  <div class="content">
41
  <div id="dashboard-text" style="display:inline-block;">
42
  <h1><?php _e( 'Dashboard', 'w3-total-cache' )?></h1>
36
  <div id="w3tc-dashboard-widgets" class="clearfix widefat metabox-holder">
37
  <?php $screen = get_current_screen();
38
  ?>
39
+ <div id="postbox-container-left">
40
  <div class="content">
41
  <div id="dashboard-text" style="display:inline-block;">
42
  <h1><?php _e( 'Dashboard', 'w3-total-cache' )?></h1>
inc/options/dbcache.php CHANGED
@@ -68,7 +68,8 @@ if ( $this->_config->get_string( 'dbcache.engine' ) == 'memcached' ) {
68
  <textarea id="dbcache_reject_uri" name="dbcache__reject__uri"
69
  <?php Util_Ui::sealing_disabled( 'dbcache.' ) ?> cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $this->_config->get_array( 'dbcache.reject.uri' ) ) ); ?></textarea><br />
70
  <span class="description">
71
- <?php echo sprintf( __( 'Always ignore the specified pages / directories. Supports regular expressions (See <a href="%s">FAQ</a>).', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_faq#q82' ) ); ?>
 
72
  </span>
73
  </td>
74
  </tr>
68
  <textarea id="dbcache_reject_uri" name="dbcache__reject__uri"
69
  <?php Util_Ui::sealing_disabled( 'dbcache.' ) ?> cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $this->_config->get_array( 'dbcache.reject.uri' ) ) ); ?></textarea><br />
70
  <span class="description">
71
+ <?php echo sprintf( __( 'Always ignore the specified pages / directories. Supports regular expressions (See <a href="%s"><acronym title="Frequently Asked Questions">FAQ</acronym></a>).', 'w3-total-cache' ),
72
+ 'https://api.w3-edge.com/v1/redirects/faq/usage/regexp-support' ); ?>
73
  </span>
74
  </td>
75
  </tr>
inc/options/general.php CHANGED
@@ -90,6 +90,12 @@ Util_Ui::config_item( array(
90
  'label' => __( 'Memcached', 'w3-total-cache' ),
91
  'optgroup' => 2
92
  ),
 
 
 
 
 
 
93
  'redis' => array(
94
  'disabled' => !Util_Installed::redis(),
95
  'label' => __( 'Redis', 'w3-total-cache' ),
@@ -120,7 +126,7 @@ Util_Ui::config_overloading_button( array(
120
  'key' => 'minify.configuration_overloaded'
121
  ) );
122
  ?>
123
- <p><?php _e( '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>.', 'w3-total-cache' ); ?></p>
124
 
125
  <table class="form-table">
126
  <?php
@@ -290,8 +296,7 @@ Util_Ui::config_overloading_button( array(
290
  <p>
291
  <?php
292
  echo sprintf(
293
- __( 'A reverse proxy adds scale to an server by handling requests before WordPress does. Purge settings are set on the <a href="%s">Page Cache settings</a> page and <a href="%s">Browser Cache settings</a> are set on the browser cache settings page.',
294
- 'w3-total-cache' ),
295
  self_admin_url( 'admin.php?page=w3tc_pgcache' ),
296
  self_admin_url( 'admin.php?page=w3tc_browsercache' ) );
297
  ?>
@@ -321,7 +326,7 @@ Util_Ui::button_config_save( 'general_varnish',
321
  ?>
322
  <?php Util_Ui::postbox_footer(); ?>
323
 
324
- <?php if ( Util_Environment::is_w3tc_pro() ): ?>
325
  <?php Util_Ui::postbox_header( 'Message Bus', '', 'amazon_sns' ); ?>
326
  <p>
327
  Allows policy management to be shared between a dynamic pool of servers. For example, each server in a pool to use opcode caching (which is not a shared resource) and purging is then syncronized between any number of servers in real-time; each server therefore behaves identically even though resources are not shared.
@@ -395,7 +400,7 @@ foreach ( $custom_areas as $area )
395
  <input id="plugin_license_key_verify" type="button" class="button" value="<?php _e( 'Verify license key', 'w3-total-cache' ) ?>"/>
396
  <span class="w3tc_license_verification"></span>
397
  <br />
398
- <span class="description"><?php printf( __( 'Please enter the license key provided you received after %s.', 'w3-total-cache' ), '<a class="button-buy-plugin" href="' . EDD_W3EDGE_STORE_URL_PLUGIN .'">' . __( 'upgrading', 'w3-total-cache' ) . '</a>' )?></span>
399
  </td>
400
  </tr>
401
 
@@ -511,7 +516,7 @@ Util_Ui::config_item( array(
511
  <?php if ( Util_Environment::is_w3tc_pro() ): ?>
512
  <?php $this->checkbox_debug( 'cluster.messagebus.debug' ) ?> <?php Util_Ui::e_config_label( 'cluster.messagebus.debug' ) ?></label><br />
513
  <?php endif; ?>
514
- <span class="description"><?php _e( '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.', 'w3-total-cache' ); ?></span>
515
  </td>
516
  </tr>
517
  </table>
90
  'label' => __( 'Memcached', 'w3-total-cache' ),
91
  'optgroup' => 2
92
  ),
93
+ 'nginx_memcached' => array(
94
+ 'disabled' => !Util_Installed::memcached_memcached() || !$is_pro,
95
+ 'label' => __( 'Nginx + Memcached', 'w3-total-cache' ) .
96
+ ( $is_pro ? '' : ' (available after upgrade)' ),
97
+ 'optgroup' => 2
98
+ ),
99
  'redis' => array(
100
  'disabled' => !Util_Installed::redis(),
101
  'label' => __( 'Redis', 'w3-total-cache' ),
126
  'key' => 'minify.configuration_overloaded'
127
  ) );
128
  ?>
129
+ <p><?php w3tc_e( 'minify.general.header', '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>
130
 
131
  <table class="form-table">
132
  <?php
296
  <p>
297
  <?php
298
  echo sprintf(
299
+ w3tc_er( 'reverseproxy.general.header', 'A reverse proxy adds scale to an server by handling requests before WordPress does. Purge settings are set on the <a href="%s">Page Cache settings</a> page and <a href="%s">Browser Cache settings</a> are set on the browser cache settings page.' ),
 
300
  self_admin_url( 'admin.php?page=w3tc_pgcache' ),
301
  self_admin_url( 'admin.php?page=w3tc_browsercache' ) );
302
  ?>
326
  ?>
327
  <?php Util_Ui::postbox_footer(); ?>
328
 
329
+ <?php if ( $is_pro ): ?>
330
  <?php Util_Ui::postbox_header( 'Message Bus', '', 'amazon_sns' ); ?>
331
  <p>
332
  Allows policy management to be shared between a dynamic pool of servers. For example, each server in a pool to use opcode caching (which is not a shared resource) and purging is then syncronized between any number of servers in real-time; each server therefore behaves identically even though resources are not shared.
400
  <input id="plugin_license_key_verify" type="button" class="button" value="<?php _e( 'Verify license key', 'w3-total-cache' ) ?>"/>
401
  <span class="w3tc_license_verification"></span>
402
  <br />
403
+ <span class="description"><?php printf( __( 'Please enter the license key provided after %s.', 'w3-total-cache' ), '<a class="button-buy-plugin" href="#">' . __( 'upgrading', 'w3-total-cache' ) . '</a>' )?></span>
404
  </td>
405
  </tr>
406
 
516
  <?php if ( Util_Environment::is_w3tc_pro() ): ?>
517
  <?php $this->checkbox_debug( 'cluster.messagebus.debug' ) ?> <?php Util_Ui::e_config_label( 'cluster.messagebus.debug' ) ?></label><br />
518
  <?php endif; ?>
519
+ <span class="description"><?php _e( 'If selected, detailed caching information will 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.', 'w3-total-cache' ); ?></span>
520
  </td>
521
  </tr>
522
  </table>
inc/options/install.php CHANGED
@@ -8,6 +8,7 @@ if ( !defined( 'W3TC' ) )
8
  <?php include W3TC_INC_DIR . '/options/common/header.php'; ?>
9
 
10
  <div id="install">
 
11
  <ol>
12
  <li>
13
  <?php _e( 'Set the permissions of wp-content/ back to 755, e.g.:', 'w3-total-cache' ); ?>
@@ -15,7 +16,7 @@ if ( !defined( 'W3TC' ) )
15
  </li>
16
  <li><?php _e( 'On the "<a href="admin.php?page=w3tc_general">General</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.', 'w3-total-cache' ); ?></li>
17
  <li><?php _e( '1. The "Compatibility Mode" option found in the advanced section of the "<a href="admin.php?page=w3tc_pgcache">Page Cache Settings</a>" tab will enable functionality that optimizes the interoperablity of caching with WordPress, is disabled by default, but highly recommended. Years of testing in hundreds of thousands of installations have helped us learn how to make caching behave well with WordPress. The tradeoff is that disk enhanced page cache performance under load tests will be decreased by ~20% at scale.', 'w3-total-cache' ); ?></li>
18
- <li><?php _e( '<em>Recommended:</em> On the "<a href="admin.php?page=w3tc_minify">Minify</a>" tab all of the recommended settings are preset. Use the help button to simplify discovery of your <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files and groups. Pay close attention to the method and location of your <acronym title="JavaScript">JS</acronym> group embeddings. See the plugin\'s <a href="admin.php?page=w3tc_faq">FAQ</a> for more information on usage.', 'w3-total-cache' ); ?></li>
19
  <li><?php _e( '<em>Recommended:</em> On the "<a href="admin.php?page=w3tc_browsercache">Browser Cache</a>" tab, <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression is enabled by default. Make sure to enable other options to suit your goals.', 'w3-total-cache' ); ?></li>
20
  <li><?php _e( '<em>Recommended:</em> If you already have a content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) provider, proceed to the "<a href="admin.php?page=w3tc_cdn">Content Delivery Network</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 "Content Delivery Network" 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 "Content Delivery Network" tab accordingly. Be sure to <acronym title="File Transfer Protocol">FTP</acronym> upload the appropriate files, using the available upload buttons.', 'w3-total-cache' ); ?></li>
21
  <li><?php _e( '<em>Optional:</em> On the "<a href="admin.php?page=w3tc_dbcache">Database Cache</a>" tab the recommended settings are preset. If 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.', 'w3-total-cache' ); ?></li>
@@ -29,7 +30,7 @@ if ( !defined( 'W3TC' ) )
29
 
30
  <hr />
31
  <?php if ( count( $rewrite_rules_descriptors ) ): ?>
32
- <h3><?php _e( 'Rewrite rules', 'w3-total-cache' ); ?></h3>
33
  <?php foreach ( $rewrite_rules_descriptors as $descriptor ): ?>
34
  <p><strong><?php echo htmlspecialchars( $descriptor['filename'] ); ?>:</strong></p>
35
  <pre class="code"><?php echo htmlspecialchars( $descriptor['content'] ); ?></pre>
@@ -37,7 +38,7 @@ if ( !defined( 'W3TC' ) )
37
  <hr />
38
  <?php endif; ?>
39
  <?php if ( count( $other_areas ) ): ?>
40
- <h3><?php _e( 'Other', 'w3-total-cache' ); ?></h3>
41
  <?php foreach ( $other_areas as $area => $descriptors ): ?>
42
  <?php foreach ( $descriptors as $descriptor ): ?>
43
  <p><strong><?php echo htmlspecialchars( $descriptor['title'] ); ?>:</strong></p>
@@ -46,238 +47,35 @@ if ( !defined( 'W3TC' ) )
46
  <?php endforeach; ?>
47
  <hr />
48
  <?php endif; ?>
49
- <h3><?php _e( 'Software Installation for Dedicated / Virtual Dedicated / Multiple Servers (Optional)', 'w3-total-cache' ); ?></h3>
50
-
51
- <p><?php _e( '<strong>Server Preparation:</strong><br /><em>Time required: ~1 minute</em>', 'w3-total-cache' ); ?></p>
52
-
53
- <ol>
54
- <li>
55
- <?php _e( '<a href="http://www.google.com/search?q=installing%20yum&amp;output=search&amp;tbs=qdr:y&amp;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:', 'w3-total-cache' ); ?>
56
- <pre class="console"># yum update</pre>
57
- </li>
58
- <li>
59
- <?php _e( 'Install <acronym title="PHP Extension Community Library">PECL</acronym>:', 'w3-total-cache' ); ?>
60
- <pre class="console"># yum install php-pear</pre>
61
- </li>
62
- <li>
63
- <?php _e( 'Install the <acronym title="Hypertext Preprocessor">PHP</acronym> Development package:', 'w3-total-cache' ); ?>
64
- <pre class="console"># yum install php-devel</pre>
65
- </li>
66
- <li>
67
- <?php _e( 'Install apxs with the following command:', 'w3-total-cache' ); ?>
68
- <pre class="console"># yum install httpd-devel</pre>
69
- </li>
70
- <li>
71
- <?php _e( 'Make sure GCC is up-to-date:', 'w3-total-cache' ); ?>
72
- <pre class="console"># yum install gcc make</pre>
73
- </li>
74
- <li>
75
- <?php _e( 'Make sure ZLIB is fully installed:', 'w3-total-cache' ); ?>
76
- <pre class="console"># yum install zlib-devel</pre>
77
- </li>
78
- <li>
79
- <?php _e( 'Make sure PCRE is fully installed:', 'w3-total-cache' ); ?>
80
- <pre class="console"># yum install pcre-devel</pre>
81
- </li>
82
- </ol>
83
-
84
- <hr />
85
-
86
- <p id="memcached"><strong><?php _e( 'Memcached (Daemon) Installation:</strong><br /><em>Time required: 2 minutes</em>', 'w3-total-cache' ); ?></p>
87
-
88
- <ol>
89
- <li>
90
- <?php _e( 'Try to install with yum:', 'w3-total-cache' ); ?>
91
- <pre class="console"># yum install libevent libevent-devel</pre>
92
-
93
- <?php _e( '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>:', 'w3-total-cache' ); ?>
94
- <pre class="console"># cd /usr/local/src &amp;&amp; wget <a href="http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz" target="_blank">http://monkey.org/~provos/libevent-2.0.14-stable.tar.gz</a> &amp;&amp; tar -xzf libevent-2.0.12-stable.tar.gz &amp;&amp; cd libevent-2.0.12-stable</pre>
95
- </li>
96
- <li>
97
- <?php _e( 'Let\'s compile:', 'w3-total-cache' ); ?>
98
- <pre class="console"># ./configure &amp;&amp; make &amp;&amp; make install</pre>
99
- </li>
100
- <li>
101
- <?php _e( 'In the output you should see:', 'w3-total-cache' ); ?>
102
- <pre class="console"><?php echo sprintf( __( 'Libraries have been installed in: %s', 'w3-total-cache' ), '/usr/local/lib' ); ?></pre>
103
- <?php _e( 'If so you can:', 'w3-total-cache' ); ?>
104
- <pre class="console"># echo "/usr/local/lib/" &gt; /etc/ld.so.conf.d/libevent.conf</pre>
105
- </li>
106
- <li>
107
- <?php _e( 'Configure your server for the new install:', 'w3-total-cache' ); ?>
108
- <pre class="console"># ldconfig -v</pre>
109
- </li>
110
- <li>
111
- <?php _e( 'Now find the <a href="http://memcached.org/" target="_blank">latest stable memcached</a>, download and extract:', 'w3-total-cache' ); ?>
112
- <pre class="console"># cd /usr/local/src &amp;&amp; wget <a href="http://memcached.googlecode.com/files/memcached-1.4.6.tar.gz" target="_blank">http://memcached.googlecode.com/files/memcached-1.4.6.tar.gz</a> &amp;&amp; tar -xzf memcached-1.4.6.tar.gz &amp;&amp; cd memcached-1.4.6</pre>
113
- </li>
114
- <li>
115
- <?php _e( 'Let\'s compile:', 'w3-total-cache' ); ?>
116
- <pre class="console"># ./configure &amp;&amp; make &amp;&amp; make install</pre>
117
- </li>
118
- <li>
119
- <?php _e( 'Make sure memcached is starts automatically on server boot:', 'w3-total-cache' ); ?>
120
- <pre class="console"># touch /etc/init.d/memcached
121
- # echo '#!/bin/sh -e' &gt;&gt; /etc/init.d/memcached
122
- # echo '/usr/local/bin/memcached -d -m 128 -p 11211 -u nobody -l localhost' &gt;&gt; /etc/init.d/memcached
123
- # chmod u+x /etc/init.d/memcached
124
- # echo '/etc/init.d/memcached' &gt;&gt; /etc/rc.local</pre>
125
- </li>
126
- <li>
127
- <?php _e( 'And finally, let\'s start memcached:', 'w3-total-cache' ); ?>
128
- <pre class="console"># /etc/init.d/memcached</pre>
129
- </li>
130
- </ol>
131
-
132
- <hr />
133
-
134
- <p id="memcache"><?php _e( '<strong><acronym title="PHP Extension Community Library">PECL</acronym> Memcached Module Installation:</strong><br /><em>Time required: 1 minute</em>', 'w3-total-cache' ); ?></p>
135
-
136
- <ol>
137
- <li>
138
- <?php _e( 'Either use <acronym title="PHP Extension Community Library">PECL</acronym> (and skip to #4 if successful):', 'w3-total-cache' ); ?>
139
- <pre class="console"># pecl install memcached</pre>
140
- </li>
141
- <li>
142
- <?php _e( 'Or via compilation. Download the <a href="http://pecl.php.net/package/memcache" target="_blank">latest stable version</a> and extract:', 'w3-total-cache' ); ?>
143
- <pre class="console"># cd /usr/local/src/ &amp;&amp; wget <a href="http://pecl.php.net/get/memcache-2.2.6.tgz" target="_blank">http://pecl.php.net/get/memcache-2.2.6.tgz</a> &amp;&amp; tar -xzf memcache-2.2.6.tgz &amp;&amp; cd memcache-2.2.6</pre>
144
- </li>
145
- <li>
146
- <?php _e( 'Now we start to compile:', 'w3-total-cache' ); ?>
147
- <pre class="console"># phpize &amp;&amp; ./configure &amp;&amp; make &amp;&amp; make install</pre>
148
- </li>
149
- <li>
150
- <?php _e( 'You can also use the memcache.ini file we prepared for you:', 'w3-total-cache' ); ?>
151
- <pre class="console"># cp /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/memcache.ini /etc/php.d/</pre>
152
- </li>
153
- <li>
154
- <?php _e( 'Finally restart apache:', 'w3-total-cache' ); ?>
155
- <pre class="console"># /etc/init.d/httpd restart</pre>
156
- </li>
157
- <li>
158
- <?php _e( 'You\'re done! Memcache should now be available. If the following command retuns anything, you\'re all set:', 'w3-total-cache' ); ?>
159
- <pre class="console"># php -r 'phpinfo();' | grep 'memcache'</pre>
160
- </li>
161
- </ol>
162
-
163
- <hr />
164
-
165
- <p id="APC"><?php _e( '<strong><acronym title="PHP Extension Community Library">PECL</acronym> Alternative PHP Cache (<acronym title="Alternative PHP Cache">APC</acronym>) Installation (Recommended):</strong><br /><em>Time required: 1 minute</em>', 'w3-total-cache' ); ?></p>
166
-
167
- <ol>
168
- <li>
169
- <?php _e( '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):', 'w3-total-cache' ); ?>
170
- <pre class="console"># pecl install apc</pre>
171
- </li>
172
- <li>
173
- <?php _e( 'Or via compilation. Download the <a href="http://pecl.php.net/package/APC" target="_blank">latest stable version</a> and extract:', 'w3-total-cache' ); ?>
174
- <pre class="console"># cd /usr/local/src &amp;&amp; wget <a href="http://pecl.php.net/get/APC-3.1.9.tgz" target="_blank">http://pecl.php.net/get/APC-3.1.9.tgz</a> &amp;&amp; tar -xzf APC-3.1.9.tgz &amp;&amp; cd APC-3.1.9</pre>
175
- </li>
176
- <li>
177
- <?php _e( 'Note the paths returned for the following commands:', 'w3-total-cache' ); ?>
178
- <pre class="console"># whereis php-config
179
- # whereis apxs</pre>
180
- </li>
181
- <li>
182
- <?php _e( 'Use the output from #2 to modify the --with-apxs and --with-php-config flags in the following compile command:', 'w3-total-cache' ); ?>
183
- <pre class="console"># phpize &amp;&amp; ./configure --enable-apc --enable-apc-mmap --with-apxs=/usr/sbin/apxs --with-php-config=/usr/bin/php-config &amp;&amp; make &amp;&amp; make install</pre>
184
- The result should be similar to:
185
- <pre class="console"><?php echo sprintf( __( 'Installing shared extensions: %s', 'w3-total-cache' ), '/usr/lib/php/modules/' ); ?></pre>
186
- </li>
187
- <li>
188
- <?php _e( 'You can also use the apc.ini file we prepared for you:', 'w3-total-cache' ); ?>
189
- <pre class="console"># cp /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/apc.ini /etc/php.d/</pre>
190
- </li>
191
- <li>
192
- <?php _e( 'Restart apache when ready:', 'w3-total-cache' ); ?>
193
- <pre class="console"># /etc/init.d/httpd restart</pre>
194
- </li>
195
- <li>
196
- <?php _e( 'You\'re done! <acronym title="Alternative PHP Cache">APC</acronym> should now be available. If the following command retuns anything, you\'re all set:', 'w3-total-cache' ); ?>
197
- <pre class="console"># php -r 'phpinfo();' | grep 'apc'</pre>
198
- </li>
199
- </ol>
200
-
201
- <hr />
202
-
203
- <p id="XCache"><?php _e( '<strong>XCache Installation:</strong><br /><em>Time required: 1 minute</em>', 'w3-total-cache' ); ?></p>
204
-
205
- <ol>
206
- <li>
207
- <?php _e( 'Download the <a href="http://xcache.lighttpd.net/wiki/ReleaseArchive" target="_blank">latest compatible version</a> and extract:', 'w3-total-cache' ); ?>
208
- <pre class="console"># cd /usr/local/src &amp;&amp; wget <a href="http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz" target="_blank">http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz</a> &amp;&amp; tar -xzf xcache-1.3.2.tar.gz &amp;&amp; cd xcache-1.3.2</pre>
209
- </li>
210
  <li>
211
- <?php _e( 'Note the path returned for the following command:', 'w3-total-cache' ); ?>
212
- <pre class="console"># whereis php-config</pre>
213
  </li>
214
  <li>
215
- <?php _e( 'Use the output from #2 to modify the --with-php-config flag in the following compile command:', 'w3-total-cache' ); ?>
216
- <pre class="console"># phpize &amp;&amp; ./configure --with-php-config=/usr/bin/php-config --enable-xcache --enable-xcache-optimizer --enable-xcache-coverager &amp;&amp; make &amp;&amp; make install</pre>
217
- <?php _e( 'The result should be similar to:', 'w3-total-cache' ); ?>
218
- <pre class="console">Installing shared extensions: /usr/lib/php/modules/</pre>
219
- </li>
220
- <li>
221
- <?php _e( 'You can also use the eaccelerator.ini file we prepared for you:', 'w3-total-cache' ); ?>
222
- <pre class="console"># cp /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/xcache.ini /etc/php.d/</pre>
223
- </li>
224
- <li>
225
- <?php _e( 'Restart apache when ready:', 'w3-total-cache' ); ?>
226
- <pre class="console"># /etc/init.d/httpd restart</pre>
227
  </li>
 
 
 
 
228
  <li>
229
- <?php _e( 'You\'re done! XCache should now be available. If the following command retuns anything, you\'re all set:', 'w3-total-cache' ); ?>
230
- <pre class="console"># php -r 'phpinfo();' | grep 'xcache'</pre>
231
- </li>
232
- </ol>
233
-
234
- <hr />
235
-
236
- <p id="eAccelerator"><?php _e( '<strong>eAccelerator Installation:</strong><br /><em>Time required: 1 minute</em>', 'w3-total-cache' ); ?></p>
237
-
238
- <ol>
239
- <li>
240
- <?php _e( 'If using <acronym title="Hypertext Preprocessor">PHP</acronym> v5+, download the <a href="http://eaccelerator.net/" target="_blank">lastest compatible version</a> and extract. Remember v0.9.5.3 is the last version that supports user objects, later versions only support opcode caching.', 'w3-total-cache' ); ?>
241
- <pre class="console"># cd /usr/local/src &amp;&amp; wget <a href="http://autosetup1.googlecode.com/files/eaccelerator-0.9.5.3.tar.bz2" target="_blank">http://autosetup1.googlecode.com/files/eaccelerator-0.9.5.3.tar.bz2</a> &amp;&amp; tar -xjf eaccelerator-0.9.5.3.tar.bz2 &amp;&amp; cd eaccelerator-0.9.5.3</pre>
242
  </li>
243
  <li>
244
- <?php _e( 'Note the path returned for the following command:', 'w3-total-cache' ); ?>
245
- <pre class="console"># whereis php-config</pre>
246
  </li>
247
  <li>
248
- <?php _e( 'Use the output from #2 to modify the --with-php-config flag in the following compile command:', 'w3-total-cache' ); ?>
249
- <pre class="console"># phpize &amp;&amp; ./configure --with-eaccelerator-shared-memory --with-php-config=/usr/bin/php-config &amp;&amp; make &amp;&amp; make install</pre>
250
- <?php _e( 'The result should be similar to:', 'w3-total-cache' ); ?>
251
- <pre class="console">Installing shared extensions: /usr/lib/php/modules/</pre>
252
- </li>
253
- <li>
254
- <?php _e( 'You can also use the eaccelerator.ini file we prepared for you:', 'w3-total-cache' ); ?>
255
- <pre class="console"># cp /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/eaccelerator.ini /etc/php.d/</pre>
256
  </li>
257
  <li>
258
- <?php _e( 'Restart apache when ready:', 'w3-total-cache' ); ?>
259
- <pre class="console"># /etc/init.d/httpd restart</pre>
260
  </li>
261
  <li>
262
- <?php _e( 'You\'re done! eAccelerator should now be available. If the following command retuns anything, you\'re all set:', 'w3-total-cache' ); ?>
263
- <pre class="console"># php -r 'phpinfo();' | grep 'eaccelerator'</pre>
264
  </li>
265
- </ol>
266
- <hr />
267
 
268
- <p id="newrelic"><strong>New Relic Installation:</strong><br /><em>Time required: Mileage varies.</em></p>
269
- <p>
270
- Find requirements and installation instructions on New Relic website: <a href="https://newrelic.com/docs/php/new-relic-for-php" target="_blank">Installing New Relic for PHP</a>.
271
- To see if this server supports New Relic click "compatibility check" on the <a href="<?php echo admin_url( 'admin.php?page=w3tc_dashboard' )?>">Dashboard tab</a>. Other key resources can be found below:
272
- </p>
273
- <ul>
274
- <li><a href="https://newrelic.com/docs/php/quick-installation-instructions-advanced-users" target="_blank">Quick Installation Instructions (Advanced Users)</a></li>
275
- <li><a href="https://newrelic.com/docs/php/the-newrelic-install-script" target="_blank">The newrelic-install Script</a></li>
276
- <li><a href="https://newrelic.com/docs/php/php-agent-installation-redhat-and-centos" target="_blank">Installing with yum or rpm (RedHat, CentOS)</a></li>
277
- <li><a href="https://newrelic.com/docs/php/php-agent-installation-ubuntu-and-debian" target="_blank">Installing with dpkg or apt (Ubuntu, Debian)</a></li>
278
- <li><a href="https://newrelic.com/docs/php/php-agent-installation-tar-files" target="_blank">Installing from tar Files (other Linux variants, OpenSolaris, FreeBSD)</a></li>
279
- <li><a href="https://newrelic.com/docs/php/newrelic-daemon-startup-modes" target="_blank">New Relic Daemon Startup Modes</a></li>
280
- </ul>
281
  <hr />
282
 
283
  <div class="metabox-holder">
@@ -286,12 +84,11 @@ if ( !defined( 'W3TC' ) )
286
  <tr>
287
  <th colspan="2">
288
  <ul>
289
- <li><?php _e( '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>.', 'w3-total-cache' ); ?></li>
290
- <li><?php _e( 'Best compatibility with <a href="http://www.iis.net/" target="_blank">IIS</a> is realized via <a href="http://www.microsoft.com/web/webmatrix/" target="_blank">WebMatrix</a>, which also includes the supported <a href="http://www.iis.net/download/wincacheforphp" target="_blank">WinCache</a> opcode cache.', 'w3-total-cache' ); ?></li>
291
  <li><?php _e( '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 manually created for your web server software.', 'w3-total-cache' ); ?></li>
292
  <li><?php _e( '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.', 'w3-total-cache' ); ?></li>
293
- <li><?php _e( '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.', 'w3-total-cache' ); ?></li>
294
- <li><?php _e( 'Some yum or mirrors may not have the necessary packages, in such cases you may have to do a manual installation.', 'w3-total-cache' ); ?></li>
295
  </ul>
296
  </th>
297
  </tr>
8
  <?php include W3TC_INC_DIR . '/options/common/header.php'; ?>
9
 
10
  <div id="install">
11
+ <h3 id="initial"><?php _e( 'Initial Installation', 'w3-total-cache' ); ?></h3>
12
  <ol>
13
  <li>
14
  <?php _e( 'Set the permissions of wp-content/ back to 755, e.g.:', 'w3-total-cache' ); ?>
16
  </li>
17
  <li><?php _e( 'On the "<a href="admin.php?page=w3tc_general">General</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.', 'w3-total-cache' ); ?></li>
18
  <li><?php _e( '1. The "Compatibility Mode" option found in the advanced section of the "<a href="admin.php?page=w3tc_pgcache">Page Cache Settings</a>" tab will enable functionality that optimizes the interoperablity of caching with WordPress, is disabled by default, but highly recommended. Years of testing in hundreds of thousands of installations have helped us learn how to make caching behave well with WordPress. The tradeoff is that disk enhanced page cache performance under load tests will be decreased by ~20% at scale.', 'w3-total-cache' ); ?></li>
19
+ <li><?php _e( '<em>Recommended:</em> On the "<a href="admin.php?page=w3tc_minify">Minify</a>" tab all of the recommended settings are preset. Use the help button to simplify discovery of your <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> files and groups. Pay close attention to the method and location of your <acronym title="JavaScript">JS</acronym> group embeddings. See the plugin\'s <a href="https://api.w3-edge.com/v1/redirects/faq/usage"><acronym title="Frequently Asked Questions">FAQ</acronym></a> for more information on usage.', 'w3-total-cache' ); ?></li>
20
  <li><?php _e( '<em>Recommended:</em> On the "<a href="admin.php?page=w3tc_browsercache">Browser Cache</a>" tab, <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression is enabled by default. Make sure to enable other options to suit your goals.', 'w3-total-cache' ); ?></li>
21
  <li><?php _e( '<em>Recommended:</em> If you already have a content delivery network (<acronym title="Content Delivery Network">CDN</acronym>) provider, proceed to the "<a href="admin.php?page=w3tc_cdn">Content Delivery Network</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 "Content Delivery Network" 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 "Content Delivery Network" tab accordingly. Be sure to <acronym title="File Transfer Protocol">FTP</acronym> upload the appropriate files, using the available upload buttons.', 'w3-total-cache' ); ?></li>
22
  <li><?php _e( '<em>Optional:</em> On the "<a href="admin.php?page=w3tc_dbcache">Database Cache</a>" tab the recommended settings are preset. If 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.', 'w3-total-cache' ); ?></li>
30
 
31
  <hr />
32
  <?php if ( count( $rewrite_rules_descriptors ) ): ?>
33
+ <h3 id="rules"><?php _e( 'Rewrite Rules (based on active settings)', 'w3-total-cache' ); ?></h3>
34
  <?php foreach ( $rewrite_rules_descriptors as $descriptor ): ?>
35
  <p><strong><?php echo htmlspecialchars( $descriptor['filename'] ); ?>:</strong></p>
36
  <pre class="code"><?php echo htmlspecialchars( $descriptor['content'] ); ?></pre>
38
  <hr />
39
  <?php endif; ?>
40
  <?php if ( count( $other_areas ) ): ?>
41
+ <h3 id="other"><?php _e( 'Other', 'w3-total-cache' ); ?></h3>
42
  <?php foreach ( $other_areas as $area => $descriptors ): ?>
43
  <?php foreach ( $descriptors as $descriptor ): ?>
44
  <p><strong><?php echo htmlspecialchars( $descriptor['title'] ); ?>:</strong></p>
47
  <?php endforeach; ?>
48
  <hr />
49
  <?php endif; ?>
50
+ <h3 id="additional"><?php _e( 'Services', 'w3-total-cache' ); ?></h3>
51
+ <ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  <li>
53
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation"><?php _e( 'Server Preparation', 'w3-total-cache' ); ?></a>
 
54
  </li>
55
  <li>
56
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation/memcached"><?php _e( 'Install Memcached Deamon', 'w3-total-cache' ); ?></a>
 
 
 
 
 
 
 
 
 
 
 
57
  </li>
58
+ </ul>
59
+ <hr />
60
+ <h3 id="modules"><?php _e( '<acronym title="Hypertext Preprocessor">PHP</acronym> Modules', 'w3-total-cache' ); ?></h3>
61
+ <ul>
62
  <li>
63
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation/php/memcached"><?php _e( 'Install Memcached Module', 'w3-total-cache' ); ?></a>
 
 
 
 
 
 
 
 
 
 
 
 
64
  </li>
65
  <li>
66
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation/php/apc"><?php _e( 'Install <acronym title="Alternative PHP Cache">APC</acronym> module', 'w3-total-cache' ); ?></a>
 
67
  </li>
68
  <li>
69
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation/php/xcache"><?php _e( 'Install XCache Module', 'w3-total-cache' ); ?></a>
 
 
 
 
 
 
 
70
  </li>
71
  <li>
72
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation/php/eaccelerator"><?php _e( 'Install eAccelerator Module', 'w3-total-cache' ); ?></a>
 
73
  </li>
74
  <li>
75
+ <a href="https://api.w3-edge.com/v1/redirects/faq/installation/newrelic"><?php _e( 'New Relic Module', 'w3-total-cache' ); ?></a>
 
76
  </li>
77
+ </ul>
 
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  <hr />
80
 
81
  <div class="metabox-holder">
84
  <tr>
85
  <th colspan="2">
86
  <ul>
87
+ <li><?php _e( 'Additional installation guides can be found in the <a href="https://api.w3-edge.com/v1/redirects/faq/installation" target="_blank">wiki</a>.', 'w3-total-cache' ); ?></li>
88
+ <li><?php _e( 'Best compatibility with <a href="http://www.iis.net/" target="_blank">IIS</a> is realized via <a href="http://www.iis.net/download/wincacheforphp" target="_blank">WinCache</a> opcode cache.', 'w3-total-cache' ); ?></li>
89
  <li><?php _e( '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 manually created for your web server software.', 'w3-total-cache' ); ?></li>
90
  <li><?php _e( '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.', 'w3-total-cache' ); ?></li>
91
+ <li><?php _e( 'Consider using memcached for objects that must persist across web server restarts or that you wish to share amongst your server pool, e.g.: database objects or page cache.', 'w3-total-cache' ); ?></li>
 
92
  </ul>
93
  </th>
94
  </tr>
inc/options/minify.php CHANGED
@@ -320,7 +320,7 @@ Util_Ui::config_item( array(
320
  'description' => __( 'For better performance, send files to browser before they are requested when using the <acronym title="Hypertext Markup Language">HTTP</acronym>/2 protocol.',
321
  'w3-total-cache' ) .
322
  ( $this->_config->get_string( 'pgcache.engine' ) != 'file_generic' ? '' :
323
- __( ' <br /><b>Not supported by "Disk: Enhanced" page cache engine for Nginx</b>', 'w3-total-cache' ) )
324
  ) ); ?>
325
  </table>
326
 
@@ -445,7 +445,7 @@ Util_Ui::config_item( array(
445
  'description' => __( 'For better performance, send files to browser before they are requested when using the <acronym title="Hypertext Markup Language">HTTP</acronym>/2 protocol.',
446
  'w3-total-cache' ) .
447
  ( $this->_config->get_string( 'pgcache.engine' ) != 'file_generic' ? '' :
448
- __( ' <br /><b>Not supported by "Disk: Enhanced" page cache engine for Nginx</b>', 'w3-total-cache' ) )
449
  ) ); ?>
450
  </table>
451
 
320
  'description' => __( 'For better performance, send files to browser before they are requested when using the <acronym title="Hypertext Markup Language">HTTP</acronym>/2 protocol.',
321
  'w3-total-cache' ) .
322
  ( $this->_config->get_string( 'pgcache.engine' ) != 'file_generic' ? '' :
323
+ __( ' <br /><b>Not supported by "Disk: Enhanced" page cache method for Nginx</b>', 'w3-total-cache' ) )
324
  ) ); ?>
325
  </table>
326
 
445
  'description' => __( 'For better performance, send files to browser before they are requested when using the <acronym title="Hypertext Markup Language">HTTP</acronym>/2 protocol.',
446
  'w3-total-cache' ) .
447
  ( $this->_config->get_string( 'pgcache.engine' ) != 'file_generic' ? '' :
448
+ __( ' <br /><b>Not supported by "Disk: Enhanced" page cache method for Nginx</b>', 'w3-total-cache' ) )
449
  ) ); ?>
450
  </table>
451
 
inc/options/minify/yuicss2.php CHANGED
@@ -6,15 +6,15 @@ if ( !defined( 'W3TC' ) )
6
 
7
  ?>
8
  <tr>
9
- <th><label for="minify_yuicss_path_java"><?php Util_Ui::e_config_label( 'minify.yuicss.path.java' ) ?></label></th>
10
  <td>
11
- <input class="css_enabled" id="minify_yuicss_path_java" type="text"
12
  <?php Util_Ui::sealing_disabled( 'minify.' ) ?> name="minify__yuicss__path__java" value="<?php echo esc_attr( $this->_config->get_string( 'minify.yuicss.path.java' ) ); ?>" size="100" /></td>
13
  </tr>
14
  <tr>
15
- <th><label for="minify_yuicss_path_jar"><?php Util_Ui::e_config_label( 'minify.yuicss.path.jar' ) ?></label></th>
16
  <td>
17
- <input class="css_enabled" id="minify_yuicss_path_jar" type="text"
18
  <?php Util_Ui::sealing_disabled( 'minify.' ) ?> name="minify__yuicss__path__jar" value="<?php echo esc_attr( $this->_config->get_string( 'minify.yuicss.path.jar' ) ); ?>" size="100" /></td>
19
  </tr>
20
  <tr>
6
 
7
  ?>
8
  <tr>
9
+ <th><label for="minify__yuicss__path__java"><?php Util_Ui::e_config_label( 'minify.yuicss.path.java' ) ?></label></th>
10
  <td>
11
+ <input class="css_enabled" id="minify__yuicss__path__java" type="text"
12
  <?php Util_Ui::sealing_disabled( 'minify.' ) ?> name="minify__yuicss__path__java" value="<?php echo esc_attr( $this->_config->get_string( 'minify.yuicss.path.java' ) ); ?>" size="100" /></td>
13
  </tr>
14
  <tr>
15
+ <th><label for="minify__yuicss__path__jar"><?php Util_Ui::e_config_label( 'minify.yuicss.path.jar' ) ?></label></th>
16
  <td>
17
+ <input class="css_enabled" id="minify__yuicss__path__jar" type="text"
18
  <?php Util_Ui::sealing_disabled( 'minify.' ) ?> name="minify__yuicss__path__jar" value="<?php echo esc_attr( $this->_config->get_string( 'minify.yuicss.path.jar' ) ); ?>" size="100" /></td>
19
  </tr>
20
  <tr>
inc/options/parts/memcached.php CHANGED
@@ -9,68 +9,68 @@ if ( !defined( 'W3TC' ) )
9
  */
10
  ?>
11
  <tr>
12
- <th><label for="memcached_servers"><?php echo Util_ConfigLabel::get( 'memcached.servers' ) ?></label></th>
13
- <td>
14
- <input id="memcached_servers" type="text"
15
- name="<?php echo $module ?>__memcached__servers"
16
- <?php Util_Ui::sealing_disabled( $module ) ?>
17
- value="<?php echo esc_attr( implode( ',', $this->_config->get_array( $module . '.memcached.servers' ) ) ); ?>" size="80" />
18
- <input id="memcached_test" class="button {nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
19
- <?php Util_Ui::sealing_disabled( $module ) ?>
20
- type="button" value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
21
- <span id="memcached_test_status" class="w3tc-status w3tc-process"></span>
22
- <br /><span class="description"><?php _e( 'Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122', 'w3-total-cache' ); ?></span>
23
- </td>
24
  </tr>
25
  <tr>
26
- <th><label><?php _e( 'Use persistent connection:', 'w3-total-cache' ); ?></label></th>
27
- <td>
28
- <?php $this->checkbox( $module . '.memcached.persistent' ) ?> <?php echo Util_ConfigLabel::get( 'memcached.persistent' ) ?></label><br />
29
- <span class="description"><?php _e( 'Using persistent connection doesn\'t reinitialize memcached driver on each request', 'w3-total-cache' ); ?></span>
30
- </td>
31
  </tr>
32
  <tr>
33
- <th><label><?php _e( 'Node Auto Discovery:', 'w3-total-cache' ); ?></label></th>
34
- <td>
35
- <label><?php $this->checkbox( $module . '.memcached.aws_autodiscovery',
36
  !Util_Installed::memcached_aws() ) ?>
37
- Amazon Node Auto Discovery</label><br />
38
- <span class="description">
39
- <?php
40
  if ( !Util_Installed::memcached_aws() )
41
  _e( 'ElastiCache <acronym title="Hypertext Preprocessor">PHP</acronym> module not found', 'w3-total-cache' );
42
  else
43
  _e( 'When Amazon ElastiCache used, specify configuration endpoint as Memcached host', 'w3-total-cache' );
44
  ?>
45
- </span>
46
- </td>
47
  </tr>
48
 
49
  <tr>
50
- <th><label for="memcached_username"><?php echo Util_ConfigLabel::get( 'memcached.username' ) ?></label></th>
51
- <td>
52
- <input id="memcached_username" name="<?php echo $module ?>__memcached__username" type="text"
53
- <?php Util_Ui::sealing_disabled( $module ) ?>
54
- <?php
55
  $this->value_with_disabled( $module . '.memcached.username',
56
  !Util_Installed::memcached_auth(), '' )
57
  ?> /><br />
58
- <span class="description">
59
- <?php _e( 'Specify memcached username, when <acronym title="Simple Authentication and Security Layer">SASL</acronym> authentication used', 'w3-total-cache' );
60
  if ( !Util_Installed::memcached_auth() )
61
- _e( '<br>Available when memcached extension installed, built with <acronym title="Simple Authentication and Security Layer">SASL</acronym>, and memcached.use_sasl = 1 option is set in php.ini', 'w3-total-cache' )
62
  ?></span>
63
- </td>
64
  </tr>
65
  <tr>
66
- <th><label for="memcached_password"><?php echo Util_ConfigLabel::get( 'memcached.password' ) ?></label></th>
67
- <td>
68
- <input id="memcached_password" name="<?php echo $module ?>__memcached__password" type="text"
69
- <?php Util_Ui::sealing_disabled( $module ) ?>
70
- <?php
71
  $this->value_with_disabled( $module . '.memcached.password',
72
  !Util_Installed::memcached_auth(), '' )
73
  ?> /><br />
74
- <span class="description"><?php _e( 'Specify memcached password, when <acronym title="Simple Authentication and Security Layer">SASL</acronym> authentication used', 'w3-total-cache' )?></span>
75
- </td>
76
  </tr>
9
  */
10
  ?>
11
  <tr>
12
+ <th><label for="memcached_servers"><?php echo Util_ConfigLabel::get( 'memcached.servers' ) ?></label></th>
13
+ <td>
14
+ <input id="memcached_servers" type="text"
15
+ name="<?php echo $module ?>__memcached__servers"
16
+ <?php Util_Ui::sealing_disabled( $module ) ?>
17
+ value="<?php echo esc_attr( implode( ',', $this->_config->get_array( $module . '.memcached.servers' ) ) ); ?>" size="80" />
18
+ <input id="memcached_test" class="button {nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
19
+ <?php Util_Ui::sealing_disabled( $module ) ?>
20
+ type="button" value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
21
+ <span id="memcached_test_status" class="w3tc-status w3tc-process"></span>
22
+ <br /><span class="description"><?php _e( 'Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122', 'w3-total-cache' ); ?></span>
23
+ </td>
24
  </tr>
25
  <tr>
26
+ <th><label><?php _e( 'Use persistent connection:', 'w3-total-cache' ); ?></label></th>
27
+ <td>
28
+ <?php $this->checkbox( $module . '.memcached.persistent' ) ?> <?php echo Util_ConfigLabel::get( 'memcached.persistent' ) ?></label><br />
29
+ <span class="description"><?php _e( 'Using persistent connection doesn\'t reinitialize memcached driver on each request', 'w3-total-cache' ); ?></span>
30
+ </td>
31
  </tr>
32
  <tr>
33
+ <th><label><?php _e( 'Node Auto Discovery:', 'w3-total-cache' ); ?></label></th>
34
+ <td>
35
+ <label><?php $this->checkbox( $module . '.memcached.aws_autodiscovery',
36
  !Util_Installed::memcached_aws() ) ?>
37
+ Amazon Node Auto Discovery</label><br />
38
+ <span class="description">
39
+ <?php
40
  if ( !Util_Installed::memcached_aws() )
41
  _e( 'ElastiCache <acronym title="Hypertext Preprocessor">PHP</acronym> module not found', 'w3-total-cache' );
42
  else
43
  _e( 'When Amazon ElastiCache used, specify configuration endpoint as Memcached host', 'w3-total-cache' );
44
  ?>
45
+ </span>
46
+ </td>
47
  </tr>
48
 
49
  <tr>
50
+ <th><label for="memcached_username"><?php echo Util_ConfigLabel::get( 'memcached.username' ) ?></label></th>
51
+ <td>
52
+ <input id="memcached_username" name="<?php echo $module ?>__memcached__username" type="text"
53
+ <?php Util_Ui::sealing_disabled( $module ) ?>
54
+ <?php
55
  $this->value_with_disabled( $module . '.memcached.username',
56
  !Util_Installed::memcached_auth(), '' )
57
  ?> /><br />
58
+ <span class="description">
59
+ <?php _e( 'Specify memcached username, when <acronym title="Simple Authentication and Security Layer">SASL</acronym> authentication used', 'w3-total-cache' );
60
  if ( !Util_Installed::memcached_auth() )
61
+ _e( '<br>Available when memcached extension installed, built with <acronym title="Simple Authentication and Security Layer">SASL</acronym>', 'w3-total-cache' )
62
  ?></span>
63
+ </td>
64
  </tr>
65
  <tr>
66
+ <th><label for="memcached_password"><?php echo Util_ConfigLabel::get( 'memcached.password' ) ?></label></th>
67
+ <td>
68
+ <input id="memcached_password" name="<?php echo $module ?>__memcached__password" type="text"
69
+ <?php Util_Ui::sealing_disabled( $module ) ?>
70
+ <?php
71
  $this->value_with_disabled( $module . '.memcached.password',
72
  !Util_Installed::memcached_auth(), '' )
73
  ?> /><br />
74
+ <span class="description"><?php _e( 'Specify memcached password, when <acronym title="Simple Authentication and Security Layer">SASL</acronym> authentication used', 'w3-total-cache' )?></span>
75
+ </td>
76
  </tr>
inc/options/parts/memcached_extension.php CHANGED
@@ -10,18 +10,18 @@ $config = Dispatcher::config();
10
  */
11
  ?>
12
  <tr>
13
- <th><label for="memcached_servers"><?php echo Util_ConfigLabel::get( 'memcached.servers' ) ?></label></th>
14
- <td>
15
- <input id="memcached_servers" type="text"
16
- name="<?php echo $module ?>___memcached__servers"
17
- <?php Util_Ui::sealing_disabled( $module ) ?>
18
- value="<?php echo esc_attr( implode( ',', $config->get_array( array( $module, 'memcached.servers' ) ) ) ); ?>" size="80" />
19
- <input id="memcached_test" class="button {nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
20
- <?php Util_Ui::sealing_disabled( $module ) ?>
21
- type="button" value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
22
- <span id="memcached_test_status" class="w3tc-status w3tc-process"></span>
23
- <br /><span class="description"><?php _e( 'Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122', 'w3-total-cache' ); ?></span>
24
- </td>
25
  </tr>
26
  <?php
27
 
@@ -55,7 +55,7 @@ Util_Ui::config_item( array(
55
  'description' =>
56
  __( 'Specify memcached username, when <acronym title="Simple Authentication and Security Layer">SASL</acronym> authentication used', 'w3-total-cache' ) .
57
  ( Util_Installed::memcache_auth() ? '' :
58
- __( '<br>Available when memcached extension installed, built with <acronym title="Simple Authentication and Security Layer">SASL</acronym>, and memcached.use_sasl = 1 option is set in php.ini', 'w3-total-cache' )
59
  )
60
  ) );
61
 
10
  */
11
  ?>
12
  <tr>
13
+ <th><label for="memcached_servers"><?php echo Util_ConfigLabel::get( 'memcached.servers' ) ?></label></th>
14
+ <td>
15
+ <input id="memcached_servers" type="text"
16
+ name="<?php echo $module ?>___memcached__servers"
17
+ <?php Util_Ui::sealing_disabled( $module ) ?>
18
+ value="<?php echo esc_attr( implode( ',', $config->get_array( array( $module, 'memcached.servers' ) ) ) ); ?>" size="80" />
19
+ <input id="memcached_test" class="button {nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
20
+ <?php Util_Ui::sealing_disabled( $module ) ?>
21
+ type="button" value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
22
+ <span id="memcached_test_status" class="w3tc-status w3tc-process"></span>
23
+ <br /><span class="description"><?php _e( 'Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122', 'w3-total-cache' ); ?></span>
24
+ </td>
25
  </tr>
26
  <?php
27
 
55
  'description' =>
56
  __( 'Specify memcached username, when <acronym title="Simple Authentication and Security Layer">SASL</acronym> authentication used', 'w3-total-cache' ) .
57
  ( Util_Installed::memcache_auth() ? '' :
58
+ __( '<br>Available when memcached extension installed, built with <acronym title="Simple Authentication and Security Layer">SASL</acronym>', 'w3-total-cache' )
59
  )
60
  ) );
61
 
inc/options/pgcache.php CHANGED
@@ -293,7 +293,8 @@ Util_Ui::postbox_header( __( 'Purge Policy: ', 'w3-total-cache' ) . implode( ',
293
  </td>
294
  </tr>
295
  <?php
296
- if ( $this->_config->get_string( 'pgcache.engine' ) == 'memcached' ) {
 
297
  $module = 'pgcache';
298
  include W3TC_INC_DIR . '/options/parts/memcached.php';
299
  } elseif ( $this->_config->get_string( 'pgcache.engine' ) == 'redis' ) {
@@ -393,7 +394,9 @@ if ( $this->_config->get_string( 'pgcache.engine' ) == 'memcached' ) {
393
  <span class="description">
394
  <?php
395
  echo sprintf(
396
- __( 'Always ignore the specified pages / directories. Supports regular expressions (See <a href="%s">FAQ</a>)', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_faq#q82' )
 
 
397
  ); ?>
398
  </span>
399
  </td>
@@ -440,7 +443,7 @@ echo sprintf(
440
  <textarea id="pgcache_accept_files" name="pgcache__accept__files"
441
  <?php Util_Ui::sealing_disabled( 'pgcache.' ) ?>
442
  cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $this->_config->get_array( 'pgcache.accept.files' ) ) ); ?></textarea><br />
443
- <span class="description"><?php echo sprintf( __( 'Cache the specified pages / directories even if listed in the "never cache the following pages" field. Supports regular expression (See <a href="%s">FAQ</a>)', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_faq#q82' ) ); ?></span>
444
  </td>
445
  </tr>
446
  <?php if ( substr( $permalink_structure, -1 ) == '/' ): ?>
@@ -468,7 +471,7 @@ echo sprintf(
468
  <th><label><?php Util_Ui::e_config_label( 'pgcache.cache.nginx_handle_xml' ) ?></label></th>
469
  <td>
470
  <?php $this->checkbox( 'pgcache.cache.nginx_handle_xml' ) ?> <?php Util_Ui::e_config_label( 'pgcache.cache.nginx_handle_xml' ) ?></label><br />
471
- <span class="description"><?php _e( 'Return correct Content-Type header for XML files (e.g., feeds and sitemaps). Slows down cache engine.', 'w3-total-cache' ); ?></span>
472
  </td>
473
  </tr>
474
  <?php endif; ?>
293
  </td>
294
  </tr>
295
  <?php
296
+ if ( $this->_config->get_string( 'pgcache.engine' ) == 'memcached' ||
297
+ $this->_config->get_string( 'pgcache.engine' ) == 'nginx_memcached' ) {
298
  $module = 'pgcache';
299
  include W3TC_INC_DIR . '/options/parts/memcached.php';
300
  } elseif ( $this->_config->get_string( 'pgcache.engine' ) == 'redis' ) {
394
  <span class="description">
395
  <?php
396
  echo sprintf(
397
+ __( 'Always ignore the specified pages / directories. Supports regular expressions (See <a href="%s"><acronym title="Frequently Asked Questions">FAQ</acronym></a>)',
398
+ 'w3-total-cache' ),
399
+ 'https://github.com/W3EDGE/w3-total-cache/wiki/FAQ:-Usage#which-textareas-for-file-entries-support-regular-expressions'
400
  ); ?>
401
  </span>
402
  </td>
443
  <textarea id="pgcache_accept_files" name="pgcache__accept__files"
444
  <?php Util_Ui::sealing_disabled( 'pgcache.' ) ?>
445
  cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $this->_config->get_array( 'pgcache.accept.files' ) ) ); ?></textarea><br />
446
+ <span class="description"><?php echo sprintf( __( 'Cache the specified pages / directories even if listed in the "never cache the following pages" field. Supports regular expression (See <a href="%s"><acronym title="Frequently Asked Questions">FAQ</acronym></a>)', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_faq' ) ); ?></span>
447
  </td>
448
  </tr>
449
  <?php if ( substr( $permalink_structure, -1 ) == '/' ): ?>
471
  <th><label><?php Util_Ui::e_config_label( 'pgcache.cache.nginx_handle_xml' ) ?></label></th>
472
  <td>
473
  <?php $this->checkbox( 'pgcache.cache.nginx_handle_xml' ) ?> <?php Util_Ui::e_config_label( 'pgcache.cache.nginx_handle_xml' ) ?></label><br />
474
+ <span class="description"><?php _e( 'Return correct Content-Type header for <acronym title="Extensible Markup Language">XML</acronym> files (e.g., feeds and sitemaps). Slows down cache engine.', 'w3-total-cache' ); ?></span>
475
  </td>
476
  </tr>
477
  <?php endif; ?>
languages/w3-total-cache-ar_AR.po CHANGED
@@ -505,6 +505,10 @@ msgstr "غير متاح"
505
  msgid "Not detected"
506
  msgstr "لم يتم الاكتشاف"
507
 
 
 
 
 
508
  #: inc/lightbox/self_test.php:213
509
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
510
  msgstr ""
@@ -968,7 +972,7 @@ msgid "cache with max-age (\"public, max-age=EXPIRES_SECONDS\")"
968
  msgstr ""
969
 
970
  #: inc/options/browsercache.php:166
971
- msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\""
972
  msgstr ""
973
 
974
  #: inc/options/browsercache.php:167 inc/options/browsercache.php:257
@@ -984,7 +988,7 @@ msgid "cache without proxy (\"private, must-revalidate\")"
984
  msgstr ""
985
 
986
  #: inc/options/browsercache.php:169
987
- msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\""
988
  msgstr ""
989
 
990
  #: inc/options/browsercache.php:211
@@ -2211,7 +2215,7 @@ msgstr ""
2211
 
2212
  #: inc/options/general.php:758
2213
  msgid ""
2214
- "If selected, detailed caching information will be appear at the end of each "
2215
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2216
  "comment. View a page's source code to review."
2217
  msgstr ""
@@ -3692,6 +3696,22 @@ msgid ""
3692
  "information."
3693
  msgstr ""
3694
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3695
  #: inc/options/cdn/akamai.php:55 inc/options/cdn/att.php:28
3696
  #: inc/options/cdn/azure.php:37 inc/options/cdn/cf.php:42
3697
  #: inc/options/cdn/cf2.php:42 inc/options/cdn/cotendo.php:35
505
  msgid "Not detected"
506
  msgstr "لم يتم الاكتشاف"
507
 
508
+ #: ../inc/lightbox/self_test.php:202
509
+ msgid "(required for Self-hosted (<acronym title=\"File Transfer Protocol\">FTP</acronym>) <acronym title=\"Content Delivery Network\">CDN</acronym> <acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> support)"
510
+ msgstr ""
511
+
512
  #: inc/lightbox/self_test.php:213
513
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
514
  msgstr ""
972
  msgstr ""
973
 
974
  #: inc/options/browsercache.php:166
975
+ msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\")"
976
  msgstr ""
977
 
978
  #: inc/options/browsercache.php:167 inc/options/browsercache.php:257
988
  msgstr ""
989
 
990
  #: inc/options/browsercache.php:169
991
+ msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\")"
992
  msgstr ""
993
 
994
  #: inc/options/browsercache.php:211
2215
 
2216
  #: inc/options/general.php:758
2217
  msgid ""
2218
+ "If selected, detailed caching information will appear at the end of each "
2219
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2220
  "comment. View a page's source code to review."
2221
  msgstr ""
3696
  "information."
3697
  msgstr ""
3698
 
3699
+ #: inc/options/cdn/ftp.php:67
3700
+ msgid "Use default <acronym title=\"Secure Shell\">SSH</acronym> public/private key files"
3701
+ msgstr ""
3702
+
3703
+ #: inc/options/cdn/ftp.php:68
3704
+ msgid "Enable this option if you don't have special public/private key files."
3705
+ msgstr ""
3706
+
3707
+ #: inc/options/cdn/ftp.php:72
3708
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> public key:"
3709
+ msgstr ""
3710
+
3711
+ #: inc/options/cdn/ftp.php:79
3712
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> private key:"
3713
+ msgstr ""
3714
+
3715
  #: inc/options/cdn/akamai.php:55 inc/options/cdn/att.php:28
3716
  #: inc/options/cdn/azure.php:37 inc/options/cdn/cf.php:42
3717
  #: inc/options/cdn/cf2.php:42 inc/options/cdn/cotendo.php:35
languages/w3-total-cache-nl_NL.po CHANGED
@@ -502,6 +502,10 @@ msgstr ""
502
  msgid "Not detected"
503
  msgstr ""
504
 
 
 
 
 
505
  #: ../inc/lightbox/self_test.php:213
506
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
507
  msgstr ""
@@ -964,7 +968,7 @@ msgid "cache with max-age (\"public, max-age=EXPIRES_SECONDS\")"
964
  msgstr ""
965
 
966
  #: ../inc/options/browsercache.php:166
967
- msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\""
968
  msgstr ""
969
 
970
  #: ../inc/options/browsercache.php:167 ../inc/options/browsercache.php:257
@@ -980,7 +984,7 @@ msgid "cache without proxy (\"private, must-revalidate\")"
980
  msgstr ""
981
 
982
  #: ../inc/options/browsercache.php:169
983
- msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\""
984
  msgstr ""
985
 
986
  #: ../inc/options/browsercache.php:211
@@ -2209,7 +2213,7 @@ msgstr ""
2209
 
2210
  #: ../inc/options/general.php:758
2211
  msgid ""
2212
- "If selected, detailed caching information will be appear at the end of each "
2213
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2214
  "comment. View a page's source code to review."
2215
  msgstr ""
@@ -3691,6 +3695,22 @@ msgid ""
3691
  "information."
3692
  msgstr ""
3693
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3694
  #: ../inc/options/cdn/akamai.php:55 ../inc/options/cdn/att.php:28
3695
  #: ../inc/options/cdn/azure.php:37 ../inc/options/cdn/cf.php:42
3696
  #: ../inc/options/cdn/cf2.php:42 ../inc/options/cdn/cotendo.php:35
502
  msgid "Not detected"
503
  msgstr ""
504
 
505
+ #: ../inc/lightbox/self_test.php:202
506
+ msgid "(required for Self-hosted (<acronym title=\"File Transfer Protocol\">FTP</acronym>) <acronym title=\"Content Delivery Network\">CDN</acronym> <acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> support)"
507
+ msgstr ""
508
+
509
  #: ../inc/lightbox/self_test.php:213
510
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
511
  msgstr ""
968
  msgstr ""
969
 
970
  #: ../inc/options/browsercache.php:166
971
+ msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\")"
972
  msgstr ""
973
 
974
  #: ../inc/options/browsercache.php:167 ../inc/options/browsercache.php:257
984
  msgstr ""
985
 
986
  #: ../inc/options/browsercache.php:169
987
+ msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\")"
988
  msgstr ""
989
 
990
  #: ../inc/options/browsercache.php:211
2213
 
2214
  #: ../inc/options/general.php:758
2215
  msgid ""
2216
+ "If selected, detailed caching information will appear at the end of each "
2217
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2218
  "comment. View a page's source code to review."
2219
  msgstr ""
3695
  "information."
3696
  msgstr ""
3697
 
3698
+ #: inc/options/cdn/ftp.php:67
3699
+ msgid "Use default <acronym title=\"Secure Shell\">SSH</acronym> public/private key files"
3700
+ msgstr ""
3701
+
3702
+ #: inc/options/cdn/ftp.php:68
3703
+ msgid "Enable this option if you don't have special public/private key files."
3704
+ msgstr ""
3705
+
3706
+ #: inc/options/cdn/ftp.php:72
3707
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> public key:"
3708
+ msgstr ""
3709
+
3710
+ #: inc/options/cdn/ftp.php:79
3711
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> private key:"
3712
+ msgstr ""
3713
+
3714
  #: ../inc/options/cdn/akamai.php:55 ../inc/options/cdn/att.php:28
3715
  #: ../inc/options/cdn/azure.php:37 ../inc/options/cdn/cf.php:42
3716
  #: ../inc/options/cdn/cf2.php:42 ../inc/options/cdn/cotendo.php:35
languages/w3-total-cache-pl_PL.po CHANGED
@@ -501,6 +501,10 @@ msgstr ""
501
  msgid "Not detected"
502
  msgstr ""
503
 
 
 
 
 
504
  #: inc/lightbox/self_test.php:213
505
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
506
  msgstr ""
@@ -962,7 +966,7 @@ msgid "cache with max-age (\"public, max-age=EXPIRES_SECONDS\")"
962
  msgstr ""
963
 
964
  #: inc/options/browsercache.php:166
965
- msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\""
966
  msgstr ""
967
 
968
  #: inc/options/browsercache.php:167 inc/options/browsercache.php:257
@@ -978,7 +982,7 @@ msgid "cache without proxy (\"private, must-revalidate\")"
978
  msgstr ""
979
 
980
  #: inc/options/browsercache.php:169
981
- msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\""
982
  msgstr ""
983
 
984
  #: inc/options/browsercache.php:211
@@ -2205,7 +2209,7 @@ msgstr ""
2205
 
2206
  #: inc/options/general.php:758
2207
  msgid ""
2208
- "If selected, detailed caching information will be appear at the end of each "
2209
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2210
  "comment. View a page's source code to review."
2211
  msgstr ""
@@ -3686,6 +3690,22 @@ msgid ""
3686
  "information."
3687
  msgstr ""
3688
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3689
  #: inc/options/cdn/akamai.php:55 inc/options/cdn/att.php:28
3690
  #: inc/options/cdn/azure.php:37 inc/options/cdn/cf.php:42
3691
  #: inc/options/cdn/cf2.php:42 inc/options/cdn/cotendo.php:35
501
  msgid "Not detected"
502
  msgstr ""
503
 
504
+ #: ../inc/lightbox/self_test.php:202
505
+ msgid "(required for Self-hosted (<acronym title=\"File Transfer Protocol\">FTP</acronym>) <acronym title=\"Content Delivery Network\">CDN</acronym> <acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> support)"
506
+ msgstr ""
507
+
508
  #: inc/lightbox/self_test.php:213
509
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
510
  msgstr ""
966
  msgstr ""
967
 
968
  #: inc/options/browsercache.php:166
969
+ msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\")"
970
  msgstr ""
971
 
972
  #: inc/options/browsercache.php:167 inc/options/browsercache.php:257
982
  msgstr ""
983
 
984
  #: inc/options/browsercache.php:169
985
+ msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\")"
986
  msgstr ""
987
 
988
  #: inc/options/browsercache.php:211
2209
 
2210
  #: inc/options/general.php:758
2211
  msgid ""
2212
+ "If selected, detailed caching information will appear at the end of each "
2213
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2214
  "comment. View a page's source code to review."
2215
  msgstr ""
3690
  "information."
3691
  msgstr ""
3692
 
3693
+ #: inc/options/cdn/ftp.php:67
3694
+ msgid "Use default <acronym title=\"Secure Shell\">SSH</acronym> public/private key files"
3695
+ msgstr ""
3696
+
3697
+ #: inc/options/cdn/ftp.php:68
3698
+ msgid "Enable this option if you don't have special public/private key files."
3699
+ msgstr ""
3700
+
3701
+ #: inc/options/cdn/ftp.php:72
3702
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> public key:"
3703
+ msgstr ""
3704
+
3705
+ #: inc/options/cdn/ftp.php:79
3706
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> private key:"
3707
+ msgstr ""
3708
+
3709
  #: inc/options/cdn/akamai.php:55 inc/options/cdn/att.php:28
3710
  #: inc/options/cdn/azure.php:37 inc/options/cdn/cf.php:42
3711
  #: inc/options/cdn/cf2.php:42 inc/options/cdn/cotendo.php:35
languages/w3-total-cache-sr_RS.mo CHANGED
Binary file
languages/w3-total-cache-sr_RS.po CHANGED
@@ -570,6 +570,10 @@ msgstr "Nije dostupno"
570
  msgid "Not detected"
571
  msgstr "Nije detektovano"
572
 
 
 
 
 
573
  #: ../inc/lightbox/self_test.php:213
574
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
575
  msgstr "(potrebno za disk-poboljšani keš strane i keš pregledača)"
@@ -1103,8 +1107,8 @@ msgid "cache with max-age (\"public, max-age=EXPIRES_SECONDS\")"
1103
  msgstr "keširati sa max-age (\"public, max-age=EXPIRES_SECONDS\")"
1104
 
1105
  #: ../inc/options/browsercache.php:166
1106
- msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\""
1107
- msgstr "keširati sa validacijom (\"public, must-revalidate, proxy-revalidate\""
1108
 
1109
  #: ../inc/options/browsercache.php:167 ../inc/options/browsercache.php:257
1110
  #: ../inc/options/browsercache.php:333
@@ -1121,8 +1125,8 @@ msgid "cache without proxy (\"private, must-revalidate\")"
1121
  msgstr "keš bez proksija (\"private, must-revalidate\")"
1122
 
1123
  #: ../inc/options/browsercache.php:169
1124
- msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\""
1125
- msgstr "bez keša (\"max-age=0, private, no-store, no-cache, must-revalidate\""
1126
 
1127
  #: ../inc/options/browsercache.php:211
1128
  msgid ""
@@ -2549,7 +2553,7 @@ msgstr "Amazon <acronym title=\"Simple Notification Service\">SNS</acronym>"
2549
 
2550
  #: ../inc/options/general.php:758
2551
  msgid ""
2552
- "If selected, detailed caching information will be appear at the end of each "
2553
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2554
  "comment. View a page's source code to review."
2555
  msgstr ""
@@ -4365,6 +4369,22 @@ msgstr ""
4365
  "podržavaju <acronym title=\"Secure Sockets Layer\">SSL</acronym>, "
4366
  "kontaktirajte vašeg dobavljača za više informacija."
4367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4368
  #: ../inc/options/cdn/akamai.php:55 ../inc/options/cdn/att.php:28
4369
  #: ../inc/options/cdn/azure.php:37 ../inc/options/cdn/cf.php:42
4370
  #: ../inc/options/cdn/cf2.php:42 ../inc/options/cdn/cotendo.php:35
570
  msgid "Not detected"
571
  msgstr "Nije detektovano"
572
 
573
+ #: ../inc/lightbox/self_test.php:202
574
+ msgid "(required for Self-hosted (<acronym title=\"File Transfer Protocol\">FTP</acronym>) <acronym title=\"Content Delivery Network\">CDN</acronym> <acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> support)"
575
+ msgstr ""
576
+
577
  #: ../inc/lightbox/self_test.php:213
578
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
579
  msgstr "(potrebno za disk-poboljšani keš strane i keš pregledača)"
1107
  msgstr "keširati sa max-age (\"public, max-age=EXPIRES_SECONDS\")"
1108
 
1109
  #: ../inc/options/browsercache.php:166
1110
+ msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\")"
1111
+ msgstr "keširati sa validacijom (\"public, must-revalidate, proxy-revalidate\")"
1112
 
1113
  #: ../inc/options/browsercache.php:167 ../inc/options/browsercache.php:257
1114
  #: ../inc/options/browsercache.php:333
1125
  msgstr "keš bez proksija (\"private, must-revalidate\")"
1126
 
1127
  #: ../inc/options/browsercache.php:169
1128
+ msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\")"
1129
+ msgstr "bez keša (\"max-age=0, private, no-store, no-cache, must-revalidate\")"
1130
 
1131
  #: ../inc/options/browsercache.php:211
1132
  msgid ""
2553
 
2554
  #: ../inc/options/general.php:758
2555
  msgid ""
2556
+ "If selected, detailed caching information will appear at the end of each "
2557
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2558
  "comment. View a page's source code to review."
2559
  msgstr ""
4369
  "podržavaju <acronym title=\"Secure Sockets Layer\">SSL</acronym>, "
4370
  "kontaktirajte vašeg dobavljača za više informacija."
4371
 
4372
+ #: inc/options/cdn/ftp.php:67
4373
+ msgid "Use default <acronym title=\"Secure Shell\">SSH</acronym> public/private key files"
4374
+ msgstr ""
4375
+
4376
+ #: inc/options/cdn/ftp.php:68
4377
+ msgid "Enable this option if you don't have special public/private key files."
4378
+ msgstr ""
4379
+
4380
+ #: inc/options/cdn/ftp.php:72
4381
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> public key:"
4382
+ msgstr ""
4383
+
4384
+ #: inc/options/cdn/ftp.php:79
4385
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> private key:"
4386
+ msgstr ""
4387
+
4388
  #: ../inc/options/cdn/akamai.php:55 ../inc/options/cdn/att.php:28
4389
  #: ../inc/options/cdn/azure.php:37 ../inc/options/cdn/cf.php:42
4390
  #: ../inc/options/cdn/cf2.php:42 ../inc/options/cdn/cotendo.php:35
languages/w3-total-cache.pot CHANGED
@@ -924,6 +924,10 @@ msgstr ""
924
  msgid "Not detected"
925
  msgstr ""
926
 
 
 
 
 
927
  #: inc/lightbox/self_test.php:213
928
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
929
  msgstr ""
@@ -1313,7 +1317,7 @@ msgid "cache with max-age (\"public, max-age=EXPIRES_SECONDS\")"
1313
  msgstr ""
1314
 
1315
  #: inc/options/browsercache.php:166
1316
- msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\""
1317
  msgstr ""
1318
 
1319
  #: inc/options/browsercache.php:167 inc/options/browsercache.php:257
@@ -1329,7 +1333,7 @@ msgid "cache without proxy (\"private, must-revalidate\")"
1329
  msgstr ""
1330
 
1331
  #: inc/options/browsercache.php:169
1332
- msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\""
1333
  msgstr ""
1334
 
1335
  #: inc/options/browsercache.php:211
@@ -1689,6 +1693,22 @@ msgid ""
1689
  "information."
1690
  msgstr ""
1691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1692
  #: inc/options/cdn/akamai.php:55 inc/options/cdn/att.php:28
1693
  #: inc/options/cdn/azure.php:37 inc/options/cdn/cf.php:42
1694
  #: inc/options/cdn/cf2.php:42 inc/options/cdn/cotendo.php:35
@@ -2901,7 +2921,7 @@ msgstr ""
2901
 
2902
  #: inc/options/general.php:684
2903
  msgid ""
2904
- "If selected, detailed caching information will be appear at the end of each "
2905
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2906
  "comment. View a page's source code to review."
2907
  msgstr ""
924
  msgid "Not detected"
925
  msgstr ""
926
 
927
+ #: ../inc/lightbox/self_test.php:202
928
+ msgid "(required for Self-hosted (<acronym title=\"File Transfer Protocol\">FTP</acronym>) <acronym title=\"Content Delivery Network\">CDN</acronym> <acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> support)"
929
+ msgstr ""
930
+
931
  #: inc/lightbox/self_test.php:213
932
  msgid "(required for disk enhanced Page Cache and Browser Cache)"
933
  msgstr ""
1317
  msgstr ""
1318
 
1319
  #: inc/options/browsercache.php:166
1320
+ msgid "cache with validation (\"public, must-revalidate, proxy-revalidate\")"
1321
  msgstr ""
1322
 
1323
  #: inc/options/browsercache.php:167 inc/options/browsercache.php:257
1333
  msgstr ""
1334
 
1335
  #: inc/options/browsercache.php:169
1336
+ msgid "no-cache (\"max-age=0, private, no-store, no-cache, must-revalidate\")"
1337
  msgstr ""
1338
 
1339
  #: inc/options/browsercache.php:211
1693
  "information."
1694
  msgstr ""
1695
 
1696
+ #: inc/options/cdn/ftp.php:67
1697
+ msgid "Use default <acronym title=\"Secure Shell\">SSH</acronym> public/private key files"
1698
+ msgstr ""
1699
+
1700
+ #: inc/options/cdn/ftp.php:68
1701
+ msgid "Enable this option if you don't have special public/private key files."
1702
+ msgstr ""
1703
+
1704
+ #: inc/options/cdn/ftp.php:72
1705
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> public key:"
1706
+ msgstr ""
1707
+
1708
+ #: inc/options/cdn/ftp.php:79
1709
+ msgid "<acronym title=\"Secure File Transfer Protocol\">SFTP</acronym> private key:"
1710
+ msgstr ""
1711
+
1712
  #: inc/options/cdn/akamai.php:55 inc/options/cdn/att.php:28
1713
  #: inc/options/cdn/azure.php:37 inc/options/cdn/cf.php:42
1714
  #: inc/options/cdn/cf2.php:42 inc/options/cdn/cotendo.php:35
2921
 
2922
  #: inc/options/general.php:684
2923
  msgid ""
2924
+ "If selected, detailed caching information will appear at the end of each "
2925
  "page in a <acronym title=\"Hypertext Markup Language\">HTML</acronym> "
2926
  "comment. View a page's source code to review."
2927
  msgstr ""
lib/Minify/HTTP/Encoder.php CHANGED
@@ -201,6 +201,21 @@ class HTTP_Encoder {
201
  return array('', '');
202
  }
203
  $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  // gzip checks (quick)
205
  if (0 === strpos($ae, 'gzip,') // most browsers
206
  || 0 === strpos($ae, 'deflate, gzip,') // opera
@@ -250,7 +265,9 @@ class HTTP_Encoder {
250
  {
251
  return false;
252
  }
253
- if ($this->_encodeMethod[0] === 'deflate') {
 
 
254
  $encoded = gzdeflate($this->_content, $compressionLevel);
255
  } elseif ($this->_encodeMethod[0] === 'gzip') {
256
  $encoded = gzencode($this->_content, $compressionLevel);
201
  return array('', '');
202
  }
203
  $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
204
+ // brotli checks (quick)
205
+ if (0 === strpos($ae, 'br,')
206
+ || strpos($ae, ', br') === strlen($ae) - 4
207
+ ) {
208
+ if (function_exists('brotli_compress'))
209
+ return array('br', 'br');
210
+ }
211
+ // brotli checks (slow)
212
+ if (preg_match(
213
+ '@(?:^|,)\\s*((?:x-)?br)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
214
+ ,$ae
215
+ ,$m)) {
216
+ if (function_exists('brotli_compress'))
217
+ return array('br', $m[1]);
218
+ }
219
  // gzip checks (quick)
220
  if (0 === strpos($ae, 'gzip,') // most browsers
221
  || 0 === strpos($ae, 'deflate, gzip,') // opera
265
  {
266
  return false;
267
  }
268
+ if ($this->_encodeMethod[0] === 'br') {
269
+ $encoded = brotli_compress($this->_content);
270
+ } elseif ($this->_encodeMethod[0] === 'deflate') {
271
  $encoded = gzdeflate($this->_content, $compressionLevel);
272
  } elseif ($this->_encodeMethod[0] === 'gzip') {
273
  $encoded = gzencode($this->_content, $compressionLevel);
lib/Minify/Minify.php CHANGED
@@ -309,7 +309,14 @@ class Minify0_Minify {
309
  throw $e;
310
  }
311
  self::$_cache->store($cacheId, $content);
312
- if (function_exists('gzencode') && self::$_options['encodeMethod'] && self::$_options['encodeOutput']) {
 
 
 
 
 
 
 
313
  $compressed = $content;
314
  $compressed['content'] = gzencode($content['content'],
315
  self::$_options['encodeLevel']);
@@ -340,6 +347,10 @@ class Minify0_Minify {
340
  case 'deflate':
341
  $content['content'] = gzdeflate($content['content'], self::$_options['encodeLevel']);
342
  break;
 
 
 
 
343
  }
344
  // still need to encode
345
  }
309
  throw $e;
310
  }
311
  self::$_cache->store($cacheId, $content);
312
+ if (function_exists('brotli_compress') && self::$_options['encodeMethod'] === 'br' && self::$_options['encodeOutput']) {
313
+ $compressed = $content;
314
+ $compressed['content'] = brotli_compress($content['content']);
315
+
316
+ self::$_cache->store($cacheId . '_' . self::$_options['encodeMethod'],
317
+ $compressed);
318
+ }
319
+ if (function_exists('gzencode') && self::$_options['encodeMethod'] && self::$_options['encodeMethod'] !== 'br' && self::$_options['encodeOutput']) {
320
  $compressed = $content;
321
  $compressed['content'] = gzencode($content['content'],
322
  self::$_options['encodeLevel']);
347
  case 'deflate':
348
  $content['content'] = gzdeflate($content['content'], self::$_options['encodeLevel']);
349
  break;
350
+
351
+ case 'br':
352
+ $content['content'] = brotli_compress($content['content']);
353
+ break;
354
  }
355
  // still need to encode
356
  }
lib/Minify/Minify/CSS/UriRewriter.php CHANGED
@@ -413,7 +413,7 @@ class Minify_CSS_UriRewriter {
413
  $parse_url = @parse_url(self::$_prependPath);
414
 
415
  if ($parse_url && isset($parse_url['host'])) {
416
- $scheme = $parse_url['scheme'];
417
  $host = $parse_url['host'];
418
  $port = (isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '');
419
  $path = (!empty($parse_url['path']) ? $parse_url['path'] : '/');
413
  $parse_url = @parse_url(self::$_prependPath);
414
 
415
  if ($parse_url && isset($parse_url['host'])) {
416
+ $scheme = array_key_exists('scheme', $parse_url) ? $parse_url['scheme'] : '';
417
  $host = $parse_url['host'];
418
  $port = (isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '');
419
  $path = (!empty($parse_url['path']) ? $parse_url['path'] : '/');
lib/Minify/Minify/Cache/File.php CHANGED
@@ -52,8 +52,12 @@ class Minify_Cache_File {
52
  return false;
53
  }
54
 
55
- @unlink($path . '_old');
56
- @unlink($path . '_meta_old');
 
 
 
 
57
 
58
  $content = $data['content'];
59
  unset($data['content']);
52
  return false;
53
  }
54
 
55
+ if ( file_exists( $path . '_old' ) ) {
56
+ @unlink($path . '_old');
57
+ }
58
+ if ( file_exists( $path . '_meta_old' ) ) {
59
+ @unlink($path . '_meta_old');
60
+ }
61
 
62
  $content = $data['content'];
63
  unset($data['content']);
lib/Minify/Minify/Controller/Files.php CHANGED
@@ -55,7 +55,11 @@ class Minify_Controller_Files extends Minify_Controller_Base {
55
  continue;
56
  }
57
  if (0 === strpos($file, '//')) {
58
- $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
 
 
 
 
59
  }
60
  $realPath = realpath($file);
61
  if (is_file($realPath)) {
55
  continue;
56
  }
57
  if (0 === strpos($file, '//')) {
58
+ if ( is_file( ABSPATH . substr($file, 1) ) ) {
59
+ $file = ABSPATH . substr( $file, 1 );
60
+ } else {
61
+ $file = $_SERVER['DOCUMENT_ROOT'] . substr( $file, 1 );
62
+ }
63
  }
64
  $realPath = realpath($file);
65
  if (is_file($realPath)) {
lib/Minify/Minify/HTML.php CHANGED
@@ -100,7 +100,7 @@ class Minify_HTML {
100
 
101
  // replace dynamic tags
102
  $this->_html = preg_replace_callback(
103
- '~(<!--\s*m(func|clude)(.*)-->\s*<!--\s*/m(func|clude)\s*-->)~is'
104
  ,array($this, '_removeComment')
105
  ,$this->_html);
106
 
@@ -146,10 +146,16 @@ class Minify_HTML {
146
 
147
  // remove ws outside of all elements
148
  $this->_html = preg_replace(
149
- '/>(\\s(?:\\s*))?([^<]+)(\\s(?:\s*))?</'
150
- ,'>$1$2$3<'
151
  ,$this->_html);
152
 
 
 
 
 
 
 
153
  // use newlines before 1st attribute in open tags (to limit line lengths)
154
  $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
155
 
@@ -171,6 +177,28 @@ class Minify_HTML {
171
  ,array_values($this->_placeholders)
172
  ,$this->_html
173
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  return $this->_html;
175
  }
176
 
@@ -244,6 +272,13 @@ class Minify_HTML {
244
  $openScript = "<script{$m[2]}";
245
  $js = $m[3];
246
 
 
 
 
 
 
 
 
247
  // whitespace surrounding? preserve at least one space
248
  $ws1 = ($m[1] === '') ? '' : ' ';
249
  $ws2 = ($m[4] === '') ? '' : ' ';
@@ -253,22 +288,33 @@ class Minify_HTML {
253
  $js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
254
  }
255
 
256
- // remove CDATA section markers
257
- $js_old = $js;
258
- $js = $this->_removeCdata($js);
259
- $needsCdata = ( $js_old != $js );
260
-
261
- // minify
262
- $minifier = $this->_jsMinifier
263
- ? $this->_jsMinifier
264
- : 'trim';
265
- $js = call_user_func($minifier, $js);
266
-
267
- return $this->_reservePlace($needsCdata && $this->_needsCdata($js)
268
- ? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
269
- : "{$ws1}{$openScript}{$js}</script>{$ws2}"
270
- );
271
- }
 
 
 
 
 
 
 
 
 
 
 
272
 
273
  protected function _removeCdata($str)
274
  {
@@ -295,4 +341,11 @@ class Minify_HTML {
295
  {
296
  return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
297
  }
 
 
 
 
 
 
 
298
  }
100
 
101
  // replace dynamic tags
102
  $this->_html = preg_replace_callback(
103
+ '~(<!--\s*m(func|clude)(.*)-->\s*<!--\s*/m(func|clude)\s*-->)~is'
104
  ,array($this, '_removeComment')
105
  ,$this->_html);
106
 
146
 
147
  // remove ws outside of all elements
148
  $this->_html = preg_replace(
149
+ '/(^|>)\\s+\\b([^<]+)\\b\\s+?(<|$)/'
150
+ ,'$1 $2 $3'
151
  ,$this->_html);
152
 
153
+ // remove ws before end of all empty elements
154
+ $this->_html = preg_replace(
155
+ '/\\s*\\/>/'
156
+ ,'/>'
157
+ ,$this->_html);
158
+
159
  // use newlines before 1st attribute in open tags (to limit line lengths)
160
  $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
161
 
177
  ,array_values($this->_placeholders)
178
  ,$this->_html
179
  );
180
+
181
+ // remove trailing slash from void elements
182
+ $this->_html = preg_replace(
183
+ '/<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)([^>]+)\\s*\\/>/i'
184
+ ,'<$1$2>'
185
+ ,$this->_html);
186
+
187
+ // in HTML5, type attribute is unnecessary for JavaScript resources
188
+ // in HTML5, type attribute for style element is not needed and should be omitted
189
+ if (false !== stripos($this->_html, '<!doctype html>')) {
190
+ $this->_html = preg_replace(
191
+ '/<(script|style)([^>]*)\\stype=[\'"]?(text\\/javascript|text\\/css|application\\/javascript)[\'"]?([^>]*)>/i'
192
+ ,'<$1$2$4>'
193
+ ,$this->_html);
194
+ }
195
+
196
+ // unquote attribute values without spaces
197
+ $this->_html = preg_replace_callback(
198
+ '/(<[a-z\\-]+\\s)\\s*([^>]+>)/m'
199
+ ,array($this, '_removeAttributeQuotes')
200
+ ,$this->_html);
201
+
202
  return $this->_html;
203
  }
204
 
272
  $openScript = "<script{$m[2]}";
273
  $js = $m[3];
274
 
275
+ $script_tag = "<script{$m[2]}>{$js}</script>";
276
+
277
+ $type = '';
278
+ if (preg_match('#type="([^"]+)"#i', $m[2], $matches)) {
279
+ $type = strtolower($matches[1]);
280
+ }
281
+
282
  // whitespace surrounding? preserve at least one space
283
  $ws1 = ($m[1] === '') ? '' : ' ';
284
  $ws2 = ($m[4] === '') ? '' : ' ';
288
  $js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
289
  }
290
 
291
+ // minify
292
+ $minifier = $this->_jsMinifier
293
+ ? $this->_jsMinifier
294
+ : 'trim';
295
+
296
+ if (in_array($type, array('text/template', 'text/x-handlebars-template'))) {
297
+ $minifier = '';
298
+ }
299
+
300
+ $minifier = apply_filters('w3tc_minify_html_script_minifier', $minifier, $type, $script_tag);
301
+
302
+ if (empty($minifier)) {
303
+ $needsCdata = false;
304
+ } else {
305
+ // remove CDATA section markers
306
+ $js_old = $js;
307
+ $js = $this->_removeCdata($js);
308
+ $needsCdata = ( $js_old != $js );
309
+
310
+ $js = call_user_func($minifier, $js);
311
+ }
312
+
313
+ return $this->_reservePlace($needsCdata && $this->_needsCdata($js)
314
+ ? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
315
+ : "{$ws1}{$openScript}{$js}</script>{$ws2}"
316
+ );
317
+ }
318
 
319
  protected function _removeCdata($str)
320
  {
341
  {
342
  return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
343
  }
344
+
345
+ protected function _removeAttributeQuotes($m) {
346
+ $m[2] = preg_replace('/([a-z0-9]=)[\'"]([^\'"\\s=]+)[\'"](?!\\/)/i', '$1$2', $m[2]);
347
+ $m[2] = preg_replace('/([a-z0-9]=)[\'"]([^\'"\\s=]+)[\'"]\\//i', '$1$2 /', $m[2]);
348
+ $m[2] = preg_replace('/([a-z0-9])=[\'"][\'"]/i', '$1', $m[2]);
349
+ return $m[1] . $m[2];
350
+ }
351
  }
lib/Minify/Minify/Inline.php CHANGED
@@ -36,11 +36,32 @@ abstract class Minify_Inline {
36
  }
37
 
38
  protected function _process($openTag, $content, $closeTag) {
39
- $content = $this->_removeCdata($content);
 
 
 
 
 
 
 
 
 
 
40
 
41
- $content = call_user_func($this->_minifier, $content, $this->_minifierOptions);
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- if ($this->_needsCdata($content)) {
44
  $content = $this->_wrapCdata($content);
45
  }
46
 
36
  }
37
 
38
  protected function _process($openTag, $content, $closeTag) {
39
+ $type = '';
40
+ if (preg_match('#type="([^"]+)"#i', $openTag, $matches)) {
41
+ $type = strtolower($matches[1]);
42
+ }
43
+
44
+ // minify
45
+ $minifier = $this->_minifier;
46
+
47
+ if (in_array($type, array('text/template', 'text/x-handlebars-template'))) {
48
+ $minifier = '';
49
+ }
50
 
51
+ $minifier = apply_filters('w3tc_minify_html_script_minifier', $minifier, $type, $openTag . $content . $closeTag);
52
+
53
+ if (empty($minifier)) {
54
+ $needsCdata = false;
55
+ } else {
56
+ // remove CDATA section markers
57
+ $content_old = $content;
58
+ $content = $this->_removeCdata($content);
59
+ $needsCdata = ( $content_old != $content );
60
+
61
+ $content = call_user_func($minifier, $content, $this->_minifierOptions);
62
+ }
63
 
64
+ if ($needsCdata && $this->_needsCdata($content)) {
65
  $content = $this->_wrapCdata($content);
66
  }
67
 
lib/Nusoap/nusoap.php CHANGED
@@ -3854,7 +3854,20 @@ class nusoap_server extends nusoap_base {
3854
  // uncompress if necessary
3855
  if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
3856
  $this->debug('got content encoding: ' . $this->headers['content-encoding']);
3857
- if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
 
 
 
 
 
 
 
 
 
 
 
 
 
3858
  // if decoding works, use it. else assume data wasn't gzencoded
3859
  if (function_exists('gzuncompress')) {
3860
  if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
@@ -4182,7 +4195,19 @@ class nusoap_server extends nusoap_base {
4182
  // NOTE: there is no way to know whether the Web server will also compress
4183
  // this data.
4184
  if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
4185
- if (strstr($this->headers['accept-encoding'], 'gzip')) {
 
 
 
 
 
 
 
 
 
 
 
 
4186
  if (function_exists('gzencode')) {
4187
  if (isset($this->debug_flag) && $this->debug_flag) {
4188
  $payload .= "<!-- Content being gzipped -->";
3854
  // uncompress if necessary
3855
  if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
3856
  $this->debug('got content encoding: ' . $this->headers['content-encoding']);
3857
+ if ($this->headers['content-encoding'] == 'br') {
3858
+ // if decoding works, use it. else assume data wasn't brotli compressed
3859
+ if (function_exists('brotli_uncompress')) {
3860
+ if ($this->headers['content-encoding'] == 'deflate' && $debrdata = @brotli_uncompress($data)) {
3861
+ $data = $debrdata;
3862
+ } else {
3863
+ $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
3864
+ return;
3865
+ }
3866
+ } else {
3867
+ $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
3868
+ return;
3869
+ }
3870
+ } elseif ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
3871
  // if decoding works, use it. else assume data wasn't gzencoded
3872
  if (function_exists('gzuncompress')) {
3873
  if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
4195
  // NOTE: there is no way to know whether the Web server will also compress
4196
  // this data.
4197
  if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
4198
+ if (strstr($this->headers['accept-encoding'], 'br')) {
4199
+ if (function_exists('brotli_compress')) {
4200
+ if (isset($this->debug_flag) && $this->debug_flag) {
4201
+ $payload .= "<!-- Content being brotli compressed -->";
4202
+ }
4203
+ $this->outgoing_headers[] = "Content-Encoding: br";
4204
+ $payload = brotli_compress($payload);
4205
+ } else {
4206
+ if (isset($this->debug_flag) && $this->debug_flag) {
4207
+ $payload .= "<!-- Content will not be brotli compressed: no brotli_compress -->";
4208
+ }
4209
+ }
4210
+ } elseif (strstr($this->headers['accept-encoding'], 'gzip')) {
4211
  if (function_exists('gzencode')) {
4212
  if (isset($this->debug_flag) && $this->debug_flag) {
4213
  $payload .= "<!-- Content being gzipped -->";
lib/SNS/sdk.class.php CHANGED
@@ -1382,6 +1382,22 @@ class CFRuntime
1382
  }
1383
  }
1384
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1385
  }
1386
  }
1387
 
1382
  }
1383
  }
1384
  break;
1385
+
1386
+ case 'br':
1387
+ if (strpos($headers['_info']['url'], 'monitoring.') !== false)
1388
+ {
1389
+ // CloudWatchWatch incorrectly does nothing when they say br.
1390
+ continue;
1391
+ }
1392
+ else
1393
+ {
1394
+ // Everyone else uses br correctly.
1395
+ if (($uncompressed = brotli_uncompress($body)) !== false)
1396
+ {
1397
+ $body = $uncompressed;
1398
+ }
1399
+ }
1400
+ break;
1401
  }
1402
  }
1403
 
pub/css/lightbox.css CHANGED
@@ -114,7 +114,7 @@ th.minify-files-add, td.minify-files-add {
114
  .w3tc-overlay .content {
115
  padding: 10px 10px 10px 10px;
116
  }
117
- .w3tc-overlay p, .w3tc-overlay label, .w3tc-overlay input, .w3tc-overlay option {
118
  font-family:Arial, Verdana,sans-serif;
119
  color:#88898a;
120
  }
@@ -495,4 +495,4 @@ padding: 10px 20px 20px 20px;
495
  width: inherit;
496
  float: none;
497
  }
498
- }
114
  .w3tc-overlay .content {
115
  padding: 10px 10px 10px 10px;
116
  }
117
+ .w3tc-overlay p, .w3tc-overlay label, .w3tc-overlay option {
118
  font-family:Arial, Verdana,sans-serif;
119
  color:#88898a;
120
  }
495
  width: inherit;
496
  float: none;
497
  }
498
+ }
pub/css/options.css CHANGED
@@ -453,9 +453,19 @@ th.w3tc_extensions_manage_column_check {
453
  padding-top:0;
454
  padding-bottom:4px;
455
  }
456
- #w3tc_csp {
457
- width: 872px;
458
- height: 654px;
459
- background: url("../img/cspref.png") center center no-repeat;
460
- margin: auto;
 
 
 
 
 
 
 
 
 
 
461
  }
453
  padding-top:0;
454
  padding-bottom:4px;
455
  }
456
+
457
+ .lightbox-content-padded {
458
+ padding: 15px;
459
+ }
460
+
461
+ .w3tcbc_qrf {
462
+ width: 100%;
463
+ }
464
+
465
+ .w3tcbc_qrf th {
466
+ text-align: left;
467
+ }
468
+
469
+ .w3tcbc_qrf td code {
470
+ white-space: nowrap;
471
  }
pub/img/cspref.png DELETED
Binary file
pub/img/w3tc_stackpath-logo-retina.png DELETED
Binary file
pub/img/w3tc_stackpath-logo.png DELETED
Binary file
pub/img/w3tc_stackpath_logo.svg ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="Logo" x="0px" y="0px" viewBox="0 0 174 24" style="enable-background:new 0 0 174 24;" xml:space="preserve">
4
+ <style type="text/css">
5
+ .st0{fill:#000000;}
6
+ .st1{fill:url(#SVGID_1_);}
7
+ .st2{fill:url(#SVGID_2_);}
8
+ </style>
9
+ <g>
10
+ <g>
11
+ <g>
12
+ <path class="st0" d="M73.379,15.362l0.03,0.092c-0.102,2.639-0.876,4.651-2.322,6.043c-1.446,1.39-3.544,2.085-6.292,2.085 c-2.759,0-5.004-0.855-6.73-2.565c-1.728-1.709-2.59-3.93-2.59-6.658V9.663c0-2.721,0.829-4.936,2.489-6.653 c1.661-1.714,3.82-2.572,6.478-2.572c2.82,0,4.977,0.717,6.468,2.148c1.493,1.431,2.336,3.467,2.53,6.103l-0.031,0.093h-5.043 c-0.071-1.462-0.396-2.55-0.973-3.26c-0.579-0.711-1.562-1.066-2.951-1.066c-1.176,0-2.101,0.476-2.775,1.429 c-0.674,0.954-1.011,2.202-1.011,3.746v4.729c0,1.555,0.368,2.812,1.104,3.769c0.736,0.958,1.748,1.437,3.036,1.437 c1.246,0,2.13-0.334,2.651-1.005c0.522-0.669,0.819-1.734,0.891-3.198H73.379z"></path>
13
+ <path class="st0" d="M13.187,17.275c0-0.793-0.261-1.406-0.781-1.839c-0.521-0.432-1.457-0.89-2.806-1.375 c-2.82-0.896-4.91-1.855-6.269-2.882c-1.359-1.024-2.039-2.505-2.039-4.441c0-1.885,0.809-3.41,2.43-4.573 C5.342,1,7.397,0.418,9.892,0.418c2.473,0,4.499,0.641,6.078,1.923c1.578,1.282,2.342,2.934,2.291,4.952L18.23,7.386h-5.027 c0-0.895-0.302-1.626-0.906-2.186c-0.603-0.561-1.435-0.842-2.499-0.842c-1.042,0-1.86,0.232-2.453,0.696 C6.754,5.517,6.458,6.088,6.458,6.768c0,0.66,0.298,1.188,0.896,1.585c0.599,0.396,1.719,0.893,3.364,1.491 c2.535,0.762,4.444,1.699,5.726,2.811c1.282,1.112,1.923,2.643,1.923,4.589c0,1.977-0.763,3.525-2.291,4.643 c-1.527,1.117-3.554,1.676-6.078,1.676c-2.535,0-4.726-0.641-6.575-1.923c-1.85-1.283-2.75-3.13-2.698-5.539l0.031-0.093h5.043 c0,1.297,0.347,2.225,1.042,2.78c0.695,0.557,1.748,0.834,3.158,0.834c1.074,0,1.872-0.216,2.4-0.648 C12.924,18.541,13.187,17.974,13.187,17.275"></path>
14
+ <polygon class="st0" points="19.577,0.567 19.577,5.016 25.685,5.016 25.685,23.37 30.323,23.37 30.323,5.016 36.393,5.016 36.393,0.567 "></polygon>
15
+ <polygon class="st0" points="130.629,0.567 130.629,5.016 136.737,5.016 136.737,23.37 141.375,23.37 141.375,5.016 147.445,5.016 147.445,0.567 "></polygon>
16
+ <polygon class="st0" points="162.791,0.567 162.791,9.728 155.248,9.728 155.248,0.567 150.649,0.567 150.649,23.37 155.248,23.37 155.248,14.173 162.791,14.173 162.791,23.37 167.39,23.37 167.39,0.567 "></polygon>
17
+ <path class="st0" d="M101.775,15.549v7.815h-5.268V0.561h8.477c2.683,0,4.812,0.692,6.387,2.076 c1.574,1.384,2.362,3.192,2.362,5.427c0,2.244-0.789,4.054-2.362,5.426c-1.575,1.374-3.704,2.06-6.387,2.06H101.775z M101.775,11.478h3.209c1.14,0,2.007-0.315,2.603-0.947c0.596-0.631,0.894-1.443,0.894-2.434c0-1.014-0.298-1.843-0.894-2.492 c-0.595-0.646-1.462-0.97-2.603-0.97h-3.209V11.478z"></path>
18
+ <path class="st0" d="M93.306,22.301c-2.66-3.08-6.816-7.855-8.989-10.408l8.989-10.445V0.567h-1.418h-3.799 c-2.413,2.851-4.79,5.589-7.203,8.436V0.567h-4.6V23.37h4.6v-8.437l7.24,8.437h3.763h1.418V22.301z"></path>
19
+ <polygon class="st0" points="119.906,0.566 112.062,23.369 116.964,23.369 124.997,0.566 "></polygon>
20
+ <polygon class="st0" points="42.247,0.566 34.402,23.369 39.304,23.369 47.337,0.566 "></polygon>
21
+ <g>
22
+ <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="58.0636" y1="15.3441" x2="43.8426" y2="10.168">
23
+ <stop offset="0.0555" style="stop-color:#000000"></stop>
24
+ <stop offset="1" style="stop-color:#000000;stop-opacity:0.2"></stop>
25
+ </linearGradient>
26
+ <polygon class="st1" points="47.337,0.567 44.883,7.533 47.337,14.554 42.41,14.554 40.844,18.998 48.732,18.998 50.24,23.369 55.143,23.369 "></polygon>
27
+ </g>
28
+ <g>
29
+ <linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="135.723" y1="15.3441" x2="121.5019" y2="10.168">
30
+ <stop offset="0.0555" style="stop-color:#000000"></stop>
31
+ <stop offset="1" style="stop-color:#000000;stop-opacity:0.2"></stop>
32
+ </linearGradient>
33
+ <polygon class="st2" points="124.996,0.567 122.542,7.533 124.996,14.554 120.069,14.554 118.504,18.998 126.392,18.998 127.899,23.369 132.802,23.369 "></polygon>
34
+ </g>
35
+ </g>
36
+ </g>
37
+ </g>
38
+ <path class="st0" d="M170.618,0.945h-0.696v1.895h-0.469V0.945h-0.688V0.565h1.853V0.945z"></path>
39
+ <path class="st0" d="M171.497,0.565l0.584,1.649l0.581-1.649h0.615v2.274h-0.47V2.218l0.047-1.073l-0.614,1.695h-0.321l-0.612-1.693 l0.047,1.072v0.622h-0.469V0.565H171.497z"></path>
40
+ </svg>
pub/js/lightbox.js CHANGED
@@ -63,11 +63,11 @@ var W3tc_Lightbox = {
63
  if (typeof ga != 'undefined') {
64
  var w3tc_action = this.options.url.match(/w3tc_action=([^&]+)/);
65
  if (w3tc_action && w3tc_action[1])
66
- ga('send', 'pageview', 'overlays/' + w3tc_action[1]);
67
  else {
68
  var w3tc_action = this.options.url.match(/&(w3tc_[^&]+)&/);
69
  if (w3tc_action && w3tc_action[1])
70
- ga('send', 'pageview', 'overlays/' + w3tc_action[1]);
71
  }
72
  }
73
  }
63
  if (typeof ga != 'undefined') {
64
  var w3tc_action = this.options.url.match(/w3tc_action=([^&]+)/);
65
  if (w3tc_action && w3tc_action[1])
66
+ w3tc_ga('send', 'pageview', 'overlays/' + w3tc_action[1]);
67
  else {
68
  var w3tc_action = this.options.url.match(/&(w3tc_[^&]+)&/);
69
  if (w3tc_action && w3tc_action[1])
70
+ w3tc_ga('send', 'pageview', 'overlays/' + w3tc_action[1]);
71
  }
72
  }
73
  }
pub/js/options.js CHANGED
@@ -271,10 +271,10 @@ function w3tc_security_headers() {
271
  {
272
  browsercache_security_hsts_directive:
273
  {
274
- maxage: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using HTTPS. This only affects the site\'s main domain.',
275
- maxagepre: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using HTTPS with a request to be included in Chrome\'s HSTS preload list - a list of sites that are hardcoded into Chrome as being HTTPS only. This only affects the site\'s main domain.',
276
- maxageinc: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using HTTPS. This affects the site\'s subdomains as well.',
277
- maxageincpre: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using HTTPS with a request to be included in Chrome\'s HSTS preload list - a list of sites that are hardcoded into Chrome as being HTTPS only. This affects the site\'s subdomains as well.'
278
  },
279
  browsercache_security_xfo_directive:
280
  {
@@ -286,7 +286,7 @@ function w3tc_security_headers() {
286
  {
287
  0: "Disables XSS filtering.",
288
  1: "Enables XSS filtering (usually default in browsers). If a cross-site scripting attack is detected, the browser will sanitize the page (remove the unsafe parts).",
289
- block: "Enables XSS filtering. Rather than sanitizing the page, the browser will prevent rendering of the page if an attack is detected."
290
  },
291
  browsercache_security_pkp_extra:
292
  {
@@ -295,8 +295,8 @@ function w3tc_security_headers() {
295
  },
296
  browsercache_security_pkp_report_only:
297
  {
298
- 0: 'This instructs the browser to enforce the HPKP policy.',
299
- 1: 'This sets up HPKP without enforcement allowing you to use pinning to test its impact without the risk of a failed connection caused by your site being unreachable or HPKP being misconfigured.'
300
  }
301
  };
302
 
@@ -327,8 +327,9 @@ function w3tc_csp_reference() {
327
  id: 'w3tc-overlay',
328
  close: '',
329
  width: 890,
330
- height: 660,
331
- content: '<div id="w3tc_csp"></div>'
 
332
  });
333
  jQuery('div#overlay,.lightbox-content').click(function() {
334
  W3tc_Lightbox.close();
@@ -374,7 +375,7 @@ jQuery(function() {
374
 
375
  // pagecache page
376
  w3tc_input_enable('#pgcache_reject_roles input[type=checkbox]', jQuery('#pgcache__reject__logged_roles:checked').size());
377
- jQuery('#pgcache__reject__logged_roles').live('click', function(){
378
  w3tc_input_enable('#pgcache_reject_roles input[type=checkbox]', jQuery('#pgcache__reject__logged_roles:checked').size());
379
  });
380
 
@@ -405,6 +406,9 @@ jQuery(function() {
405
  w3tc_toggle2('browsercache_compression',
406
  ['browsercache__cssjs__compression', 'browsercache__html__compression',
407
  'browsercache__other__compression']);
 
 
 
408
  w3tc_toggle2('browsercache_replace',
409
  ['browsercache__cssjs__replace', 'browsercache__other__replace']);
410
  w3tc_toggle2('browsercache_querystring',
@@ -434,7 +438,7 @@ jQuery(function() {
434
  w3tc_input_enable('.css_enabled', jQuery(this).is(':checked'));
435
  });
436
 
437
- jQuery('.js_file_verify,.css_file_verify').live('click', function() {
438
  var file = jQuery(this).parents('li').find(':text').val();
439
  if (file == '') {
440
  alert('Empty URI');
@@ -449,19 +453,19 @@ jQuery(function() {
449
  }
450
  });
451
 
452
- jQuery('.js_file_template').live('change', function() {
453
  jQuery(this).parents('li').find(':text').attr('name', 'js_files[' + jQuery('#js_themes').val() + '][' + jQuery(this).val() + '][' + jQuery(this).parents('li').find('.js_file_location').val() + '][]');
454
  });
455
 
456
- jQuery('.css_file_template').live('change', function() {
457
  jQuery(this).parents('li').find(':text').attr('name', 'css_files[' + jQuery('#css_themes').val() + '][' + jQuery(this).val() + '][include][]');
458
  });
459
 
460
- jQuery('.js_file_location').live('change', function() {
461
  jQuery(this).parents('li').find(':text').attr('name', 'js_files[' + jQuery('#js_themes').val() + '][' + jQuery(this).parents('li').find('.js_file_template').val() + '][' + jQuery(this).val() + '][]');
462
  });
463
 
464
- jQuery('.js_file_delete').live('click', function() {
465
  var parent = jQuery(this).parents('li');
466
  if (parent.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this JS file?')) {
467
  parent.remove();
@@ -472,7 +476,7 @@ jQuery(function() {
472
  return false;
473
  });
474
 
475
- jQuery('.css_file_delete').live('click', function() {
476
  var parent = jQuery(this).parents('li');
477
  if (parent.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this CSS file?')) {
478
  parent.remove();
@@ -595,7 +599,7 @@ jQuery(function() {
595
  });
596
 
597
  w3tc_input_enable('#cdn_reject_roles input[type=checkbox]', jQuery('#cdn__reject__logged_roles:checked').size());
598
- jQuery('#cdn__reject__logged_roles').live('click', function() {
599
  w3tc_input_enable('#cdn_reject_roles input[type=checkbox]', jQuery('#cdn__reject__logged_roles:checked').size());
600
  });
601
 
@@ -654,7 +658,10 @@ jQuery(function() {
654
  'config[user]': jQuery('#cdn_ftp_user').val(),
655
  'config[path]': jQuery('#cdn_ftp_path').val(),
656
  'config[pass]': jQuery('#cdn_ftp_pass').val(),
657
- 'config[pasv]': jQuery('#cdn_ftp_pasv:checked').size()
 
 
 
658
  });
659
 
660
  if (cnames.length) {
@@ -837,7 +844,7 @@ jQuery(function() {
837
  });
838
  });
839
 
840
- jQuery('#cdn_create_container').live('click', function() {
841
  var me = jQuery(this);
842
  var metadata = me.metadata();
843
  var cnames = w3tc_cdn_get_cnames();
@@ -1049,7 +1056,7 @@ jQuery(function() {
1049
  jQuery(this).trigger("size_change");
1050
  });
1051
 
1052
- jQuery('.cdn_cname_delete').live('click', function() {
1053
  var p = jQuery(this).parent();
1054
  if (p.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this CNAME?')) {
1055
  p.remove();
@@ -1171,7 +1178,7 @@ jQuery(function() {
1171
  }
1172
  });
1173
 
1174
- jQuery('.mobile_delete').live('click', function() {
1175
  if (confirm('Are you sure want to delete this group?')) {
1176
  jQuery(this).parents('#mobile_groups li').remove();
1177
  w3tc_mobile_groups_clear();
@@ -1273,7 +1280,7 @@ jQuery(function() {
1273
  }
1274
  });
1275
 
1276
- jQuery('.referrer_delete').live('click', function() {
1277
  if (confirm('Are you sure want to delete this group?')) {
1278
  jQuery(this).parents('#referrer_groups li').remove();
1279
  w3tc_referrer_groups_clear();
@@ -1383,7 +1390,7 @@ jQuery(function() {
1383
  });
1384
 
1385
  // check for unsaved changes
1386
- jQuery('#w3tc input,#w3tc select,#w3tc textarea').live('change', function() {
1387
  var ignore = false;
1388
  jQuery(this).parents().andSelf().each(function() {
1389
  if (jQuery(this).hasClass('w3tc-ignore-change') || jQuery(this).hasClass('lightbox')) {
@@ -1452,25 +1459,25 @@ jQuery(function() {
1452
  var id = jQuery(this).attr('id');
1453
  var text = jQuery(this).text();
1454
  if (id)
1455
- ga('send', 'event', 'w3tc_error', id, text);
1456
  });
1457
  jQuery('.w3tc_note').each(function() {
1458
  var id = jQuery(this).attr('id');
1459
  var text = jQuery(this).text();
1460
  if (id)
1461
- ga('send', 'event', 'w3tc_note', id, text);
1462
  });
1463
 
1464
  jQuery('body').on('click', 'a', function() {
1465
  var url = jQuery(this).attr('href');
1466
  if (url)
1467
- ga('send', 'event', 'anchor', 'click', url, {useBeacon: true});
1468
  });
1469
 
1470
  jQuery('body').on('click', 'input[type="button"]', function() {
1471
  var name = jQuery(this).attr('name');
1472
  if (name)
1473
- ga('send', 'event', 'button', 'click', name, {useBeacon: true});
1474
  });
1475
  jQuery('body').on('click', 'input[type="submit"]', function() {
1476
  var name = jQuery(this).attr('name');
@@ -1479,7 +1486,7 @@ jQuery(function() {
1479
  id = name;
1480
 
1481
  if (name)
1482
- ga('send', 'event', 'button', id, name, {useBeacon: true});
1483
  });
1484
 
1485
  jQuery('body').on('click', 'input[type="checkbox"]', function() {
@@ -1487,7 +1494,7 @@ jQuery(function() {
1487
  var action = jQuery(this).is(':checked') ? 'check' : 'uncheck';
1488
 
1489
  if (name)
1490
- ga('send', 'event', 'checkbox', action, name);
1491
  });
1492
 
1493
  jQuery('body').on('change', 'select', function() {
@@ -1495,8 +1502,7 @@ jQuery(function() {
1495
  var value = jQuery(this).val();
1496
 
1497
  if (name && value)
1498
- ga('send', 'event', 'select', value, name);
1499
  });
1500
  }
1501
  });
1502
-
271
  {
272
  browsercache_security_hsts_directive:
273
  {
274
+ maxage: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym>. This only affects the site\'s main domain.',
275
+ maxagepre: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> with a request to be included in Chrome\'s HSTS preload list - a list of sites that are hardcoded into Chrome as being <acronym title="HyperText Transfer Protocol over SSL">https</acronym> only. This only affects the site\'s main domain.',
276
+ maxageinc: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym>. This affects the site\'s subdomains as well.',
277
+ maxageincpre: 'The time, in seconds (as defined under the "Expires Header Lifetime" box of "Media & Other Files"), that the browser should remember that this site is only to be accessed using <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> with a request to be included in Chrome\'s HSTS preload list - a list of sites that are hardcoded into Chrome as being <acronym title="HyperText Transfer Protocol over SSL">https</acronym> only. This affects the site\'s subdomains as well.'
278
  },
279
  browsercache_security_xfo_directive:
280
  {
286
  {
287
  0: "Disables XSS filtering.",
288
  1: "Enables XSS filtering (usually default in browsers). If a cross-site scripting attack is detected, the browser will sanitize the page (remove the unsafe parts).",
289
+ block: "Enables <acronym title='Cross-Site Scripting'>XSS</acronym> filtering. Rather than sanitizing the page, the browser will prevent rendering of the page if an attack is detected."
290
  },
291
  browsercache_security_pkp_extra:
292
  {
295
  },
296
  browsercache_security_pkp_report_only:
297
  {
298
+ 0: 'This instructs the browser to enforce the <acronym title="HTTP Public Key Pinning">HPKP</acronym> policy.',
299
+ 1: 'This sets up <acronym title="HTTP Public Key Pinning">HPKP</acronym> without enforcement allowing you to use pinning to test its impact without the risk of a failed connection caused by your site being unreachable or <acronym title="HTTP Public Key Pinning">HPKP</acronym> being misconfigured.'
300
  }
301
  };
302
 
327
  id: 'w3tc-overlay',
328
  close: '',
329
  width: 890,
330
+ height: 460,
331
+ url: ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
332
+ '&w3tc_action=browsercache_quick_reference',
333
  });
334
  jQuery('div#overlay,.lightbox-content').click(function() {
335
  W3tc_Lightbox.close();
375
 
376
  // pagecache page
377
  w3tc_input_enable('#pgcache_reject_roles input[type=checkbox]', jQuery('#pgcache__reject__logged_roles:checked').size());
378
+ jQuery('#pgcache__reject__logged_roles').on('click', function () {
379
  w3tc_input_enable('#pgcache_reject_roles input[type=checkbox]', jQuery('#pgcache__reject__logged_roles:checked').size());
380
  });
381
 
406
  w3tc_toggle2('browsercache_compression',
407
  ['browsercache__cssjs__compression', 'browsercache__html__compression',
408
  'browsercache__other__compression']);
409
+ w3tc_toggle2('browsercache_brotli',
410
+ ['browsercache__cssjs__brotli', 'browsercache__html__brotli',
411
+ 'browsercache__other__brotli']);
412
  w3tc_toggle2('browsercache_replace',
413
  ['browsercache__cssjs__replace', 'browsercache__other__replace']);
414
  w3tc_toggle2('browsercache_querystring',
438
  w3tc_input_enable('.css_enabled', jQuery(this).is(':checked'));
439
  });
440
 
441
+ jQuery('.js_file_verify,.css_file_verify').on('click', function () {
442
  var file = jQuery(this).parents('li').find(':text').val();
443
  if (file == '') {
444
  alert('Empty URI');
453
  }
454
  });
455
 
456
+ jQuery('.js_file_template').on('change', function () {
457
  jQuery(this).parents('li').find(':text').attr('name', 'js_files[' + jQuery('#js_themes').val() + '][' + jQuery(this).val() + '][' + jQuery(this).parents('li').find('.js_file_location').val() + '][]');
458
  });
459
 
460
+ jQuery('.css_file_template').on('change', function () {
461
  jQuery(this).parents('li').find(':text').attr('name', 'css_files[' + jQuery('#css_themes').val() + '][' + jQuery(this).val() + '][include][]');
462
  });
463
 
464
+ jQuery('.js_file_location').on('change', function () {
465
  jQuery(this).parents('li').find(':text').attr('name', 'js_files[' + jQuery('#js_themes').val() + '][' + jQuery(this).parents('li').find('.js_file_template').val() + '][' + jQuery(this).val() + '][]');
466
  });
467
 
468
+ jQuery('.js_file_delete').on('click', function () {
469
  var parent = jQuery(this).parents('li');
470
  if (parent.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this JS file?')) {
471
  parent.remove();
476
  return false;
477
  });
478
 
479
+ jQuery('.css_file_delete').on('click', function () {
480
  var parent = jQuery(this).parents('li');
481
  if (parent.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this CSS file?')) {
482
  parent.remove();
599
  });
600
 
601
  w3tc_input_enable('#cdn_reject_roles input[type=checkbox]', jQuery('#cdn__reject__logged_roles:checked').size());
602
+ jQuery('#cdn__reject__logged_roles').on('click', function () {
603
  w3tc_input_enable('#cdn_reject_roles input[type=checkbox]', jQuery('#cdn__reject__logged_roles:checked').size());
604
  });
605
 
658
  'config[user]': jQuery('#cdn_ftp_user').val(),
659
  'config[path]': jQuery('#cdn_ftp_path').val(),
660
  'config[pass]': jQuery('#cdn_ftp_pass').val(),
661
+ 'config[pasv]': jQuery('#cdn_ftp_pasv:checked').size(),
662
+ 'config[default_keys]': jQuery('#cdn__ftp__default_keys:checked').size(),
663
+ 'config[pubkey]': jQuery('#cdn_ftp_pubkey').val(),
664
+ 'config[privkey]': jQuery('#cdn_ftp_privkey').val()
665
  });
666
 
667
  if (cnames.length) {
844
  });
845
  });
846
 
847
+ jQuery('#cdn_create_container').on('click', function () {
848
  var me = jQuery(this);
849
  var metadata = me.metadata();
850
  var cnames = w3tc_cdn_get_cnames();
1056
  jQuery(this).trigger("size_change");
1057
  });
1058
 
1059
+ jQuery('.cdn_cname_delete').on('click', function () {
1060
  var p = jQuery(this).parent();
1061
  if (p.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this CNAME?')) {
1062
  p.remove();
1178
  }
1179
  });
1180
 
1181
+ jQuery('.mobile_delete').on('click', function () {
1182
  if (confirm('Are you sure want to delete this group?')) {
1183
  jQuery(this).parents('#mobile_groups li').remove();
1184
  w3tc_mobile_groups_clear();
1280
  }
1281
  });
1282
 
1283
+ jQuery('.referrer_delete').on('click', function () {
1284
  if (confirm('Are you sure want to delete this group?')) {
1285
  jQuery(this).parents('#referrer_groups li').remove();
1286
  w3tc_referrer_groups_clear();
1390
  });
1391
 
1392
  // check for unsaved changes
1393
+ jQuery('#w3tc input,#w3tc select,#w3tc textarea').on('change', function () {
1394
  var ignore = false;
1395
  jQuery(this).parents().andSelf().each(function() {
1396
  if (jQuery(this).hasClass('w3tc-ignore-change') || jQuery(this).hasClass('lightbox')) {
1459
  var id = jQuery(this).attr('id');
1460
  var text = jQuery(this).text();
1461
  if (id)
1462
+ w3tc_ga('send', 'event', 'w3tc_error', id, text);
1463
  });
1464
  jQuery('.w3tc_note').each(function() {
1465
  var id = jQuery(this).attr('id');
1466
  var text = jQuery(this).text();
1467
  if (id)
1468
+ w3tc_ga('send', 'event', 'w3tc_note', id, text);
1469
  });
1470
 
1471
  jQuery('body').on('click', 'a', function() {
1472
  var url = jQuery(this).attr('href');
1473
  if (url)
1474
+ w3tc_ga('send', 'event', 'anchor', 'click', url, {useBeacon: true});
1475
  });
1476
 
1477
  jQuery('body').on('click', 'input[type="button"]', function() {
1478
  var name = jQuery(this).attr('name');
1479
  if (name)
1480
+ w3tc_ga('send', 'event', 'button', 'click', name, {useBeacon: true});
1481
  });
1482
  jQuery('body').on('click', 'input[type="submit"]', function() {
1483
  var name = jQuery(this).attr('name');
1486
  id = name;
1487
 
1488
  if (name)
1489
+ w3tc_ga('send', 'event', 'button', id, name, {useBeacon: true});
1490
  });
1491
 
1492
  jQuery('body').on('click', 'input[type="checkbox"]', function() {
1494
  var action = jQuery(this).is(':checked') ? 'check' : 'uncheck';
1495
 
1496
  if (name)
1497
+ w3tc_ga('send', 'event', 'checkbox', action, name);
1498
  });
1499
 
1500
  jQuery('body').on('change', 'select', function() {
1502
  var value = jQuery(this).val();
1503
 
1504
  if (name && value)
1505
+ w3tc_ga('send', 'event', 'select', value, name);
1506
  });
1507
  }
1508
  });
 
pub/js/widget.js CHANGED
@@ -41,7 +41,7 @@ jQuery(function() {
41
  jQuery('#w3tc_generic_widgetservices_form_hash').val(o.attr('data-form_hash'));
42
  });
43
 
44
- jQuery('#buy-w3-service-cancel').live('click', function() {
45
  jQuery('input:radio[name=service]:checked').prop('checked', false);
46
  jQuery('#buy-w3-service-area').empty();
47
  jQuery('#buy-w3-service').attr("disabled", "disabled");
41
  jQuery('#w3tc_generic_widgetservices_form_hash').val(o.attr('data-form_hash'));
42
  });
43
 
44
+ jQuery('#buy-w3-service-cancel').on('click', function () {
45
  jQuery('input:radio[name=service]:checked').prop('checked', false);
46
  jQuery('#buy-w3-service-area').empty();
47
  jQuery('#buy-w3-service').attr("disabled", "disabled");
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: fredericktownes
3
  Tags: seo, cache, caching, compression, maxcdn, nginx, varnish, redis, new relic, aws, amazon web services, s3, cloudfront, rackspace, cloudflare, azure, apache
4
  Requires at least: 3.2
5
- Tested up to: 4.9.5
6
- Stable tag: 0.9.7
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -11,13 +11,13 @@ Search Engine (SEO) &amp; Performance Optimization (WPO) via caching. Integrated
11
 
12
  == Description ==
13
 
14
- W3 Total Cache improves the SEO and user experience of your site by increasing website performance, reducing download times via features like content delivery network (CDN) integration.
15
 
16
- The **only** web host agnostic WordPress Performance Optimization (WPO) framework recommended by countless web developers and web hosts. Trusted by numerous companies like: AT&T, stevesouders.com, mattcutts.com, mashable.com, smashingmagazine.com, makeuseof.com, kiss925.com, pearsonified.com, lockergnome.com, johnchow.com, ilovetypography.com, webdesignerdepot.com, css-tricks.com and tens of thousands of others.
17
 
18
  An inside look:
19
 
20
- http://www.youtube.com/watch?v=rkmrQP8S5KY
21
 
22
  *BENEFITS*
23
 
@@ -109,19 +109,6 @@ A good rule of thumb is to try auto mode, work with a developer to identify the
109
 
110
  We're always working to make this more simple and straight forward in future releases, but this is not an undertaking we can realize on our own. When you find a plugin, theme or file that is not compatible with minification reach out to the developer and ask them either to provide a minified version with their distribution or otherwise make sure their code is minification-friendly.
111
 
112
- = Who do you recommend as a CDN (Content Delivery Network) provider? =
113
-
114
- That depends on how you use your site and where most of your readers read your site (regionally). Here's a short list:
115
-
116
- * [MaxCDN](https://www.maxcdn.com/), [Discount Coupon Code](http://tracking.maxcdn.com/c/15753/3982/378?u=https%3A%2F%2Fsecure.maxcdn.com%2F%3Fpackage%3Dstarter%26coupon%3Dw3tc)
117
- * [Amazon Cloudfront](https://aws.amazon.com/cloudfront/)
118
- * [CloudFlare](https://www.cloudflare.com/features-cdn/)
119
- * [Verizon Digital Media Services (formerly EdgeCast)](https://www.verizondigitalmedia.com/)
120
- * [MediaTemple TrueSpeed (formerly ProCDN)](https://mediatemple.net/services/truespeed-cdn/)
121
- * [Rackspace Cloud Files](https://www.rackspace.com/cloud/files)
122
- * [Limelight Networks](https://www.limelight.com/)
123
- * [Akamai / Cotendo](https://www.akamai.com/)
124
-
125
  = What about comments? Does the plugin slow down the rate at which comments appear? =
126
 
127
  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.
@@ -283,6 +270,37 @@ Please reach out to all of these people and support their projects if you're so
283
 
284
  == Changelog ==
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  = 0.9.7 =
287
  * Fixed minified files not being hosted by CDN when enabled if "host minified files" is disabled
288
  * Fixed warning thrown when purge all was selected (via nigrosimone)
2
  Contributors: fredericktownes
3
  Tags: seo, cache, caching, compression, maxcdn, nginx, varnish, redis, new relic, aws, amazon web services, s3, cloudfront, rackspace, cloudflare, azure, apache
4
  Requires at least: 3.2
5
+ Tested up to: 5.0.3
6
+ Stable tag: 0.9.7.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
11
 
12
  == Description ==
13
 
14
+ W3 Total Cache improves the SEO and user experience of your site by increasing website performance, reducing load times via features like content delivery network (CDN) integration and the latest best practices.
15
 
16
+ The **only** web host agnostic Web Performance Optimization (WPO) framework for WordPress trusted by millions of publishers, web developers, and web hosts worldwide for more than a decade.
17
 
18
  An inside look:
19
 
20
+ https://youtu.be/7AsNSSrZq4Y
21
 
22
  *BENEFITS*
23
 
109
 
110
  We're always working to make this more simple and straight forward in future releases, but this is not an undertaking we can realize on our own. When you find a plugin, theme or file that is not compatible with minification reach out to the developer and ask them either to provide a minified version with their distribution or otherwise make sure their code is minification-friendly.
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  = What about comments? Does the plugin slow down the rate at which comments appear? =
113
 
114
  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.
270
 
271
  == Changelog ==
272
 
273
+ = 0.9.7.1 =
274
+ * Fixed undefined variable notice
275
+ * Fixed "No such file or directory" warning
276
+ * Fixed writing to PHP error log rather than WordPress debug log
277
+ * Fixed default referrer policy should be "no-referrer-when-downgrade"
278
+ * Fixed php_flag error related to browser cache, using ini_set instead
279
+ * Fixed CloudFlare IPv6 check undefined offset
280
+ * Fixed Undefined constant WP_ROOT
281
+ * Fixed frame-ancestors being overwritten by frame-src
282
+ * Fixed missing semicolon in nginx configuration
283
+ * Fixed HTTP/2 URLs handling for browser cache and CDN modules
284
+ * Fixed display of CDN debug information
285
+ * Fixed CSS Minification with Google Fonts when included via "Include external files/libraries" and non-latin character-sets are loaded
286
+ * Fixed media query string not updating when all caches were purged
287
+ * Fixed double slash with ABSPATH if file exists
288
+ * Fixed setting max-age and expires header simultaneously
289
+ * Fixed SASL detection for PECL Memcached
290
+ * Fixed handling of manually entered objects to be purged on CDN
291
+ * Fixed query string handling in Nginx
292
+ * Improved error handling with Cloudfront
293
+ * Improved page cache logging
294
+ * Improved multi-tenant support for memory-based caching engines
295
+ * Improved CSS minification
296
+ * Improved purge behavior for changed media objects when using CDN
297
+ * Improved compatibility with sitemap plugins
298
+ * Added support for Memcached for Nginx
299
+ * Added support for caching webm files
300
+ * Added Brotli HTTP compression support
301
+ * Added StackPath full site delivery support
302
+ * Added _wc_session_ to the list of ignored query stems for improved WooCommerce compatibility
303
+
304
  = 0.9.7 =
305
  * Fixed minified files not being hosted by CDN when enabled if "host minified files" is disabled
306
  * Fixed warning thrown when purge all was selected (via nigrosimone)
w3-total-cache-api.php CHANGED
@@ -5,38 +5,43 @@ if ( !defined( 'ABSPATH' ) ) {
5
  }
6
 
7
  define( 'W3TC', true );
8
- define( 'W3TC_VERSION', '0.9.7' );
9
  define( 'W3TC_POWERED_BY', 'W3 Total Cache' );
10
  define( 'W3TC_EMAIL', 'w3tc@w3-edge.com' );
11
  define( 'W3TC_TEXT_DOMAIN', 'w3-total-cache' );
12
- define( 'W3TC_LINK_URL', 'https://www.w3-edge.com/wordpress-plugins/' );
13
  define( 'W3TC_LINK_NAME', 'W3 EDGE, Optimization Products for WordPress' );
14
- define( 'W3TC_FEED_URL', 'http://feeds.feedburner.com/W3TOTALCACHE' );
15
- define( 'W3TC_NEWS_FEED_URL', 'http://feeds.feedburner.com/W3EDGE' );
16
- define( 'W3TC_README_URL', 'http://plugins.svn.wordpress.org/w3-total-cache/trunk/readme.txt' );
17
- define( 'W3TC_SUPPORT_US_PRODUCT_URL', 'https://www.w3-edge.com/products/w3-total-cache/' );
18
- define( 'W3TC_SUPPORT_US_RATE_URL', 'https://wordpress.org/support/plugin/w3-total-cache/reviews/#new-post' );
19
  define( 'W3TC_SUPPORT_US_TWEET', 'YES! I optimized the user experience of my website with the W3 Total Cache #WordPress #plugin by @w3edge! http://bit.ly/TeSBL3' );
20
  define( 'W3TC_EDGE_TIMEOUT', 7 * 24 * 60 * 60 );
21
- define( 'W3TC_SUPPORT_REQUEST_URL', 'https://www.w3-edge.com/w3tc-support/extra' );
22
- define( 'W3TC_SUPPORT_SERVICES_URL', 'https://www.w3-edge.com/w3tc/premium-widget.json' );
23
- define( 'W3TC_FAQ_URL', 'https://github.com/Auctollo/w3-total-cache-public/wiki/FAQ' );
24
- define( 'W3TC_TRACK_URL', 'https://www.w3-edge.com/w3tc/track/' );
25
- define( 'W3TC_MAILLINGLIST_SIGNUP_URL', 'https://www.w3-edge.com/w3tc/emailsignup/' );
26
- define( 'NEWRELIC_SIGNUP_URL', 'http://bit.ly/w3tc-partner-newrelic-signup' );
27
- define( 'MAXCDN_SIGNUP_URL', 'http://bit.ly/w3tc-cdn-maxcdn-create-account' );
28
- define( 'MAXCDN_AUTHORIZE_URL', 'http://bit.ly/w3tc-cdn-maxcdn-authorize' );
29
- define( 'NETDNA_AUTHORIZE_URL', 'https://cp.netdna.com/i/w3tc' );
30
- define( 'STACKPATH_SIGNUP_URL', 'http://bit.ly/w3tc-cdn-stackpath-create-account' );
31
- define( 'STACKPATH_AUTHORIZE_URL', 'http://bit.ly/w3tc-cdn-stackpath-authorize' );
32
- define( 'GOOGLE_DRIVE_AUTHORIZE_URL', 'https://www.w3-edge.com/w3tcoa/google-drive/' );
 
33
 
34
  // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed
35
- if ( !defined( 'EDD_W3EDGE_STORE_URL' ) ) define( 'EDD_W3EDGE_STORE_URL', 'https://www.w3-edge.com/' );
36
- if ( !defined( 'EDD_W3EDGE_STORE_URL_PLUGIN' ) ) define( 'EDD_W3EDGE_STORE_URL_PLUGIN', 'https://www.w3-edge.com/?w3tc_buy_pro_plugin' );
 
 
 
 
37
 
38
  // the name of your product. This should match the download name in EDD exactly
39
- define( 'EDD_W3EDGE_W3TC_NAME', 'W3 Total Cache Pro: Annual Subscription' );
40
 
41
  define( 'W3TC_WIN', ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) );
42
 
@@ -558,29 +563,29 @@ function w3tc_opcache_flush_file( $file, $http = false ) {
558
  */
559
  if ( defined( 'W3TC_CONFIG_HIDE' ) && W3TC_CONFIG_HIDE ) {
560
  class W3_Config {
561
- public function __construct( $master = false, $blog_id = null ) {
562
- }
563
 
564
  public function get_string( $key, $default = '', $trim = true ) {
565
  return '';
566
  }
567
 
568
- public function get_integer( $key, $default = 0 ) {
569
  return 0;
570
- }
571
 
572
  public function get_boolean( $key, $default = false ) {
573
  return false;
574
- }
575
  }
576
  } else {
577
  class W3_Config extends \W3TC\Config {
578
- public function __construct( $master = false, $blog_id = null ) {
579
- if ( $master )
580
- $blog_id = 0;
581
 
582
- return parent::__construct($blog_id);
583
- }
584
  }
585
  }
586
 
@@ -589,35 +594,71 @@ if ( defined( 'W3TC_CONFIG_HIDE' ) && W3TC_CONFIG_HIDE ) {
589
  */
590
  class W3_ConfigWriter {
591
  public function __construct( $p1 = 0, $p2 = 0 ) {
592
- }
593
- public function set( $p1 = 0, $p2 = 0 ) {
594
- }
595
- public function save( $p1 = 0, $p2 = 0 ) {
596
- }
597
- public function refresh_w3tc() {
598
- }
599
  }
600
 
601
  /**
602
  Deprecated. Retained for 3rd parties that use it. see w3tc_config()
603
  */
604
  function w3_instance( $class ) {
605
- $legacy_class_name = null;
606
-
607
- if ( $class == 'W3_Config' ) {
608
- if ( defined( 'W3TC_CONFIG_HIDE' ) && W3TC_CONFIG_HIDE )
609
- return new W3_Config();
610
-
611
- $legacy_class_name = 'Config';
612
- }
613
- elseif ( $class == 'W3_ObjectCacheBridge' )
614
- $legacy_class_name = 'ObjectCache_WpObjectCache';
615
- elseif ( $class == 'W3_PgCache' )
616
- $legacy_class_name = 'PgCache_ContentGrabber';
617
- elseif ( $class == 'W3_Redirect' )
618
- $legacy_class_name = 'Mobile_Redirect';
619
- else
620
- return null;
621
-
622
- return \W3TC\Dispatcher::component( $legacy_class_name );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  }
5
  }
6
 
7
  define( 'W3TC', true );
8
+ define( 'W3TC_VERSION', '0.9.7.1' );
9
  define( 'W3TC_POWERED_BY', 'W3 Total Cache' );
10
  define( 'W3TC_EMAIL', 'w3tc@w3-edge.com' );
11
  define( 'W3TC_TEXT_DOMAIN', 'w3-total-cache' );
12
+ define( 'W3TC_LINK_URL', 'https://api.w3-edge.com/v1/redirects/product-index' );
13
  define( 'W3TC_LINK_NAME', 'W3 EDGE, Optimization Products for WordPress' );
14
+ define( 'W3TC_FEED_URL', 'https://api.w3-edge.com/v1/redirects/product-rss' );
15
+ define( 'W3TC_NEWS_FEED_URL', 'https://api.w3-edge.com/v1/redirects/company-rss' );
16
+ define( 'W3TC_README_URL', 'https://api.w3-edge.com/v1/redirects/product-readme' );
17
+ define( 'W3TC_SUPPORT_US_PRODUCT_URL', 'https://api.w3-edge.com/v1/redirects/product-directory' );
18
+ define( 'W3TC_SUPPORT_US_RATE_URL', 'https://api.w3-edge.com/v1/redirects/support-ratings' );
19
  define( 'W3TC_SUPPORT_US_TWEET', 'YES! I optimized the user experience of my website with the W3 Total Cache #WordPress #plugin by @w3edge! http://bit.ly/TeSBL3' );
20
  define( 'W3TC_EDGE_TIMEOUT', 7 * 24 * 60 * 60 );
21
+ define( 'W3TC_SUPPORT_REQUEST_URL', 'https://api.w3-edge.com/v1/support-request' );
22
+ define( 'W3TC_SUPPORT_SERVICES_URL', 'https://api.w3-edge.com/v1/support-serviceinventory' );
23
+ define( 'W3TC_FAQ_URL', 'https://api.w3-edge.com/v1/redirects/faq' );
24
+ define( 'W3TC_TERMS_URL', 'https://api.w3-edge.com/v1/redirects/policies-terms' );
25
+ define( 'W3TC_TERMS_ACCEPT_URL', 'https://api.w3-edge.com/v1/redirects/policies-privacy' );
26
+ define( 'W3TC_MAILLINGLIST_SIGNUP_URL', 'https://api.w3-edge.com/v1/signup-newsletter' );
27
+ define( 'W3TC_NEWRELIC_SIGNUP_URL', 'https://api.w3-edge.com/v1/redirects/newrelic/signup' );
28
+ define( 'W3TC_MAXCDN_SIGNUP_URL', 'https://api.w3-edge.com/v1/redirects/maxcdn/signup' );
29
+ define( 'W3TC_MAXCDN_AUTHORIZE_URL', 'https://api.w3-edge.com/v1/redirects/maxcdn/authorize' );
30
+ define( 'W3TC_STACKPATH_SIGNUP_URL', 'https://api.w3-edge.com/v1/redirects/stackpath/signup' );
31
+ define( 'W3TC_STACKPATH_AUTHORIZE_URL', 'https://api.w3-edge.com/v1/redirects/stackpath/authorize' );
32
+ define( 'W3TC_STACKPATH2_AUTHORIZE_URL', 'https://api.w3-edge.com/v1/redirects/stackpath2/authorize' );
33
+ define( 'W3TC_GOOGLE_DRIVE_AUTHORIZE_URL', 'https://api.w3-edge.com/v1/googledrive/authorize' );
34
 
35
  // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed
36
+ if ( !defined( 'W3TC_LICENSE_API_URL' ) ) {
37
+ define( 'W3TC_LICENSE_API_URL', 'https://www.w3-edge.com/' );
38
+ }
39
+ if ( !defined( 'W3TC_PURCHASE_URL' ) ) {
40
+ define( 'W3TC_PURCHASE_URL', 'https://www.w3-edge.com/checkout/' );
41
+ }
42
 
43
  // the name of your product. This should match the download name in EDD exactly
44
+ define( 'W3TC_PURCHASE_PRODUCT_NAME', 'W3 Total Cache Pro: Annual Subscription' );
45
 
46
  define( 'W3TC_WIN', ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) );
47
 
563
  */
564
  if ( defined( 'W3TC_CONFIG_HIDE' ) && W3TC_CONFIG_HIDE ) {
565
  class W3_Config {
566
+ public function __construct( $master = false, $blog_id = null ) {
567
+ }
568
 
569
  public function get_string( $key, $default = '', $trim = true ) {
570
  return '';
571
  }
572
 
573
+ public function get_integer( $key, $default = 0 ) {
574
  return 0;
575
+ }
576
 
577
  public function get_boolean( $key, $default = false ) {
578
  return false;
579
+ }
580
  }
581
  } else {
582
  class W3_Config extends \W3TC\Config {
583
+ public function __construct( $master = false, $blog_id = null ) {
584
+ if ( $master )
585
+ $blog_id = 0;
586
 
587
+ return parent::__construct($blog_id);
588
+ }
589
  }
590
  }
591
 
594
  */
595
  class W3_ConfigWriter {
596
  public function __construct( $p1 = 0, $p2 = 0 ) {
597
+ }
598
+ public function set( $p1 = 0, $p2 = 0 ) {
599
+ }
600
+ public function save( $p1 = 0, $p2 = 0 ) {
601
+ }
602
+ public function refresh_w3tc() {
603
+ }
604
  }
605
 
606
  /**
607
  Deprecated. Retained for 3rd parties that use it. see w3tc_config()
608
  */
609
  function w3_instance( $class ) {
610
+ $legacy_class_name = null;
611
+
612
+ if ( $class == 'W3_Config' ) {
613
+ if ( defined( 'W3TC_CONFIG_HIDE' ) && W3TC_CONFIG_HIDE )
614
+ return new W3_Config();
615
+
616
+ $legacy_class_name = 'Config';
617
+ }
618
+ elseif ( $class == 'W3_ObjectCacheBridge' )
619
+ $legacy_class_name = 'ObjectCache_WpObjectCache';
620
+ elseif ( $class == 'W3_PgCache' )
621
+ $legacy_class_name = 'PgCache_ContentGrabber';
622
+ elseif ( $class == 'W3_Redirect' )
623
+ $legacy_class_name = 'Mobile_Redirect';
624
+ else
625
+ return null;
626
+
627
+ return \W3TC\Dispatcher::component( $legacy_class_name );
628
+ }
629
+
630
+
631
+
632
+ function w3tc_e( $key, $default_value ) {
633
+ echo w3tc_er( $key, $default_value);
634
+ }
635
+
636
+
637
+
638
+ function w3tc_er( $key, $default_value ) {
639
+ $v = get_site_option( 'w3tc_generic_widgetservices' );
640
+ try {
641
+ $v = json_decode( $v, true );
642
+ $v = $v['content'];
643
+ } catch ( \Exception $e ) {
644
+ return $default_value;
645
+ }
646
+
647
+ global $w3tc_locale;
648
+ if ( null === $w3tc_locale ) {
649
+ if ( function_exists( 'get_user_locale' ) ) {
650
+ $w3tc_locale = get_user_locale();
651
+ } else {
652
+ $w3tc_locale = '';
653
+ }
654
+ }
655
+
656
+ if ( isset( $v["ui_strings.$w3tc_locale"][$key] ) ) {
657
+ return $v["ui_strings.$w3tc_locale"][$key];
658
+ }
659
+ if ( isset( $v["ui_strings"][$key] ) ) {
660
+ return $v["ui_strings"][$key];
661
+ }
662
+
663
+ return $default_value;
664
  }
w3-total-cache.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: W3 Total Cache
4
  Description: The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
5
- Version: 0.9.7
6
  Plugin URI: https://www.w3-edge.com/wordpress-plugins/w3-total-cache/
7
  Author: Frederick Townes
8
  Author URI: http://www.linkedin.com/in/fredericktownes
2
  /*
3
  Plugin Name: W3 Total Cache
4
  Description: The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
5
+ Version: 0.9.7.1
6
  Plugin URI: https://www.w3-edge.com/wordpress-plugins/w3-total-cache/
7
  Author: Frederick Townes
8
  Author URI: http://www.linkedin.com/in/fredericktownes