W3 Total Cache - Version 2.2.2

Version Description

  • Security: PHPCS and WPCS updates
  • Security: Updated guzzlehttp/guzzle to 6.5.6
  • Security: Updated guzzlehttp/psr7 to 1.8.5
  • Fix: Cloudflare flush all cache
  • Fix: Access log test
  • Fix: Better handling for PHP 5.6
  • Fix: Convert Redis warnings to exceptions
  • Fix: WordPress 5.5 image lazy loading
  • Fix: Infinite loop when using database cluster configuration
  • Fix: Database cluster logic
  • Fix: FTP credentials form
  • Fix: Preview deploy button
  • Fix: Image Service links in multisite network admin
  • Fix: Enable Image Service settings changes in multisite blog/sub sites
  • Enhancement: Updated Cloudflare settings to allow a global API key or token
  • Enhancement: Added Cloudflare CDN public objects option to settings
  • Enhancement: Added timeout settings for Redis
  • Enhancement: Added TLS/SSL certificate verification option for Redis
  • Enhancement: Added Image Service visibility option
  • Enhancement: Updated Image Service limit notification
  • Enhancement: Better handling of trailing slash URLs
  • Update: Adjusted lightbox for accessibility
  • Update: Removed deprecated opcache flush
Download this release

Release Info

Developer joemoto
Plugin Icon 128x128 W3 Total Cache
Version 2.2.2
Comparing to
See all releases

Code changes from version 2.2.1 to 2.2.2

Files changed (220) hide show
  1. Base_Page_Settings.php +78 -59
  2. BrowserCache_Page_View_QuickReference.php +68 -68
  3. BrowserCache_Page_View_SectionSecurity.php +365 -91
  4. BrowserCache_Plugin.php +2 -2
  5. BrowserCache_Plugin_Admin.php +1 -1
  6. Cache.php +1 -1
  7. CacheGroups_Plugin_Admin_View.php +4 -4
  8. Cache_Redis.php +329 -130
  9. CdnEngine_Base.php +1 -4
  10. CdnEngine_CloudFront.php +6 -1
  11. CdnEngine_Ftp.php +4 -3
  12. CdnEngine_Mirror_CloudFront.php +1 -1
  13. CdnEngine_S3.php +33 -9
  14. Cdn_AdminNotes.php +1 -1
  15. Cdn_Core.php +1 -0
  16. Cdn_GeneralPage_View.php +134 -32
  17. Cdn_GoogleDrive_AdminActions.php +6 -6
  18. Cdn_GoogleDrive_Page.php +33 -12
  19. Cdn_GoogleDrive_Page_View.php +23 -22
  20. Cdn_GoogleDrive_Popup_AuthReturn.php +6 -6
  21. Cdn_GoogleDrive_Popup_AuthReturn_View.php +46 -37
  22. Cdn_Highwinds_Page_View.php +132 -22
  23. Cdn_Highwinds_Popup.php +7 -7
  24. Cdn_Highwinds_Popup_View_ConfigureCnamesForm.php +54 -8
  25. Cdn_Highwinds_Popup_View_Intro.php +9 -8
  26. Cdn_Highwinds_Popup_View_SelectHost.php +50 -40
  27. Cdn_Highwinds_Widget_View.php +34 -34
  28. Cdn_LimeLight_Page_View.php +88 -20
  29. Cdn_LimeLight_Popup.php +4 -4
  30. Cdn_LimeLight_Popup_View_Intro.php +50 -50
  31. Cdn_LimeLight_Popup_View_Success.php +28 -14
  32. Cdn_MaxCdn_Page_View.php +261 -63
  33. Cdn_MaxCdn_Popup.php +17 -17
  34. Cdn_MaxCdn_Popup_View_Intro.php +10 -9
  35. Cdn_MaxCdn_Popup_View_Success.php +14 -14
  36. Cdn_MaxCdn_Popup_View_Zone.php +58 -56
  37. Cdn_MaxCdn_Popup_View_Zones.php +44 -42
  38. Cdn_Page.php +1 -1
  39. Cdn_Page_View_Fsd_HeaderActions.php +29 -6
  40. Cdn_Page_View_Header.php +22 -8
  41. Cdn_Plugin.php +3 -5
  42. Cdn_Plugin_WidgetMaxCdn.php +0 -5
  43. Cdn_Plugin_WidgetMaxCdn_View_Authorized.php +64 -64
  44. Cdn_Plugin_WidgetMaxCdn_View_Unauthorized.php +48 -10
  45. Cdn_RackSpaceCdn_Page_View.php +158 -68
  46. Cdn_RackSpaceCdn_Popup.php +298 -309
  47. Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php +54 -8
  48. Cdn_RackSpaceCdn_Popup_View_Intro.php +31 -13
  49. Cdn_RackSpaceCdn_Popup_View_Regions.php +46 -37
  50. Cdn_RackSpaceCdn_Popup_View_Service_Actualize.php +32 -22
  51. Cdn_RackSpaceCdn_Popup_View_Service_Create.php +76 -29
  52. Cdn_RackSpaceCdn_Popup_View_Service_Created.php +54 -47
  53. Cdn_RackSpaceCdn_Popup_View_Services.php +53 -43
  54. Cdn_RackSpaceCloudFiles_Page_View.php +119 -29
  55. Cdn_RackSpaceCloudFiles_Popup.php +22 -17
  56. Cdn_RackSpaceCloudFiles_Popup_View_Containers.php +52 -46
  57. Cdn_RackSpaceCloudFiles_Popup_View_Intro.php +33 -15
  58. Cdn_RackSpaceCloudFiles_Popup_View_Regions.php +48 -37
  59. Cdn_StackPath2_Page_View.php +278 -77
  60. Cdn_StackPath2_Popup.php +5 -5
  61. Cdn_StackPath2_Popup_View_Intro.php +11 -10
  62. Cdn_StackPath2_Popup_View_Sites.php +12 -14
  63. Cdn_StackPath2_Popup_View_Stacks.php +11 -11
  64. Cdn_StackPath2_Popup_View_Success.php +14 -14
  65. Cdn_StackPath2_Widget_View_Authorized.php +9 -8
  66. Cdn_StackPath2_Widget_View_Unauthorized.php +43 -15
  67. Cdn_StackPath_Page_View.php +225 -68
  68. Cdn_StackPath_Popup.php +16 -16
  69. Cdn_StackPath_Popup_View_Intro.php +27 -11
  70. Cdn_StackPath_Popup_View_Success.php +14 -14
  71. Cdn_StackPath_Popup_View_Zone.php +34 -33
  72. Cdn_StackPath_Popup_View_Zones.php +44 -42
  73. Cdn_StackPath_Widget_View_Authorized.php +64 -64
  74. Cdn_StackPath_Widget_View_Unauthorized.php +10 -10
  75. Cdnfsd_CloudFront_Page_View.php +37 -24
  76. Cdnfsd_CloudFront_Popup.php +25 -37
  77. Cdnfsd_CloudFront_Popup_View_Distribution.php +49 -26
  78. Cdnfsd_CloudFront_Popup_View_Distributions.php +45 -43
  79. Cdnfsd_CloudFront_Popup_View_Intro.php +53 -33
  80. Cdnfsd_CloudFront_Popup_View_Success.php +16 -16
  81. Cdnfsd_GeneralPage_View.php +115 -28
  82. Cdnfsd_LimeLight_Page_View.php +14 -22
  83. Cdnfsd_LimeLight_Popup.php +3 -3
  84. Cdnfsd_LimeLight_Popup_View_Intro.php +42 -41
  85. Cdnfsd_LimeLight_Popup_View_Success.php +14 -14
  86. Cdnfsd_MaxCdn_Page_View.php +47 -29
  87. Cdnfsd_MaxCdn_Popup.php +184 -163
  88. Cdnfsd_MaxCdn_Popup_View_Intro.php +10 -9
  89. Cdnfsd_MaxCdn_Popup_View_Success.php +17 -17
  90. Cdnfsd_MaxCdn_Popup_View_Zone.php +46 -22
  91. Cdnfsd_MaxCdn_Popup_View_Zones.php +44 -46
  92. Cdnfsd_Page_View_Header.php +21 -7
  93. Cdnfsd_StackPath2_Page_View.php +43 -18
  94. Cdnfsd_StackPath2_Popup.php +5 -5
  95. Cdnfsd_StackPath2_Popup_View_Intro.php +11 -12
  96. Cdnfsd_StackPath2_Popup_View_Sites.php +12 -12
  97. Cdnfsd_StackPath2_Popup_View_Stacks.php +13 -14
  98. Cdnfsd_StackPath2_Popup_View_Success.php +14 -14
  99. Cdnfsd_StackPath_Page_View.php +35 -18
  100. Cdnfsd_StackPath_Popup.php +10 -10
  101. Cdnfsd_StackPath_Popup_View_Intro.php +10 -9
  102. Cdnfsd_StackPath_Popup_View_Success.php +17 -17
  103. Cdnfsd_StackPath_Popup_View_Zone.php +32 -22
  104. Cdnfsd_StackPath_Popup_View_Zones.php +42 -46
  105. Cdnfsd_TransparentCDN_Page_View.php +43 -43
  106. Cli.php +1 -44
  107. ConfigCompiler.php +2 -0
  108. ConfigDbStorage.php +4 -4
  109. ConfigKeys.php +78 -1
  110. DbCache_Core.php +4 -0
  111. DbCache_Environment.php +15 -15
  112. DbCache_WpdbInjection_QueryCaching.php +46 -19
  113. DbCache_WpdbLegacy.php +6 -3
  114. DbCache_WpdbNew.php +6 -3
  115. Enterprise_CacheFlush_MakeSnsEvent.php +2 -2
  116. Enterprise_Dbcache_WpdbInjection_Cluster.php +19 -13
  117. Extension_Amp_Page_View.php +20 -17
  118. Extension_CloudFlare_Api.php +71 -16
  119. Extension_CloudFlare_Cdn_Page_View.php +10 -14
  120. Extension_CloudFlare_GeneralPage_View.php +28 -31
  121. Extension_CloudFlare_Page.php +15 -6
  122. Extension_CloudFlare_Page_View.php +828 -431
  123. Extension_CloudFlare_Plugin.php +23 -11
  124. Extension_CloudFlare_Plugin_Admin.php +167 -162
  125. Extension_CloudFlare_Popup.php +54 -62
  126. Extension_CloudFlare_Popup_View_Intro.php +31 -11
  127. Extension_CloudFlare_Popup_View_Zones.php +39 -28
  128. Extension_CloudFlare_SettingsForUi.php +3 -0
  129. Extension_CloudFlare_Widget.php +3 -3
  130. Extension_CloudFlare_Widget_View.php +52 -53
  131. Extension_FeedBurner_Page_View.php +59 -25
  132. Extension_FragmentCache_Api.php +1 -1
  133. Extension_FragmentCache_GeneralPage_View.php +16 -12
  134. Extension_FragmentCache_Page_View.php +69 -61
  135. Extension_FragmentCache_Plugin.php +1 -0
  136. Extension_FragmentCache_WpObjectCache.php +4 -0
  137. Extension_Genesis_Page_View.php +217 -186
  138. Extension_Genesis_Plugin.php +2 -2
  139. Extension_ImageService_Page_View.php +20 -0
  140. Extension_ImageService_Plugin_Admin.js +12 -0
  141. Extension_ImageService_Plugin_Admin.php +48 -24
  142. Extension_NewRelic_GeneralPage_View.php +74 -35
  143. Extension_NewRelic_Page_View_Apm.php +336 -136
  144. Extension_NewRelic_Popup.php +42 -55
  145. Extension_NewRelic_Popup_View_Intro.php +46 -28
  146. Extension_NewRelic_Popup_View_ListApplications.php +58 -53
  147. Extension_NewRelic_Service.php +4 -3
  148. Extension_NewRelic_Widget_View_Apm.php +59 -59
  149. Extension_NewRelic_Widget_View_Browser.php +6 -6
  150. Extension_NewRelic_Widget_View_NotConfigured.php +3 -3
  151. Extension_Swarmify_AdminActions.php +4 -2
  152. Extension_Swarmify_Page_View.php +67 -69
  153. Extension_Swarmify_Widget_View_NotConfigured.php +10 -10
  154. Extensions_Page.php +12 -9
  155. Extensions_Plugin_Admin.php +20 -5
  156. FeatureShowcase_Plugin_Admin.php +9 -4
  157. Generic_AdminActions_Config.php +12 -14
  158. Generic_AdminActions_Default.php +264 -221
  159. Generic_AdminActions_Flush.php +1 -1
  160. Generic_AdminActions_Test.php +28 -19
  161. Generic_AdminNotes.php +380 -139
  162. Generic_Page_Dashboard.php +0 -1
  163. Generic_Page_PurgeLog_View.php +39 -23
  164. Generic_Plugin.php +189 -181
  165. Generic_Plugin_Admin.php +63 -39
  166. Generic_Plugin_AdminNotifications.php +0 -4
  167. Generic_Plugin_AdminRowActions.php +5 -3
  168. Generic_Plugin_Admin_View_Faq.php +33 -15
  169. Generic_Plugin_WidgetForum.php +72 -56
  170. Generic_Plugin_WidgetNews.php +72 -47
  171. Generic_WidgetServices_View.php +30 -28
  172. Generic_WidgetSpreadTheWord_View.php +5 -5
  173. Licensing_AdminActions.php +2 -2
  174. Licensing_Core.php +28 -0
  175. Licensing_Plugin_Admin.php +128 -97
  176. Minify_Core.php +13 -2
  177. Minify_Environment.php +1 -1
  178. Minify_HelpPopup_View.php +121 -42
  179. Minify_MinifiedFileRequestHandler.php +6 -2
  180. Minify_Plugin.php +8 -9
  181. Mobile_Referrer.php +9 -10
  182. Mobile_UserAgent.php +22 -7
  183. ObjectCache_Environment.php +36 -18
  184. ObjectCache_Page_View_PurgeLog.php +10 -9
  185. ObjectCache_WpObjectCache_Regular.php +9 -2
  186. PageSpeed_Plugin_Widget.php +1 -1
  187. PgCache_ContentGrabber.php +47 -26
  188. PgCache_Environment.php +12 -23
  189. PgCache_Plugin.php +1 -2
  190. Root_AdminActivation.php +68 -36
  191. Root_AdminMenu.php +1 -1
  192. Root_Loader.php +41 -36
  193. SetupGuide_Plugin_Admin.php +32 -56
  194. Support_AdminActions.php +3 -3
  195. Support_Page.php +8 -6
  196. SystemOpCache_GeneralPage_View.php +42 -39
  197. UsageStatistics_GeneralPage_View.php +1 -1
  198. UsageStatistics_Page.php +26 -29
  199. UsageStatistics_Page_DbRequests_View.php +23 -22
  200. UsageStatistics_Page_ObjectCacheLog_View.php +26 -25
  201. UsageStatistics_Page_PageCacheRequests_View.php +20 -19
  202. UsageStatistics_Page_View.php +115 -111
  203. UsageStatistics_Page_View_Ad.php +4 -6
  204. UsageStatistics_Page_View_Disabled.php +6 -5
  205. UsageStatistics_Page_View_Free.php +6 -5
  206. UsageStatistics_Page_View_NoDebugMode.php +6 -5
  207. UsageStatistics_Plugin_Admin.php +22 -16
  208. UsageStatistics_Widget_View_Disabled.php +6 -5
  209. UserExperience_GeneralPage_View.php +57 -48
  210. UserExperience_LazyLoad_Mutator.php +13 -0
  211. UserExperience_LazyLoad_Mutator_Unmutable.php +1 -1
  212. UserExperience_LazyLoad_Page_View.php +171 -66
  213. Util_Admin.php +9 -4
  214. Util_ConfigLabel.php +29 -11
  215. Util_Environment.php +670 -420
  216. Util_PageUrls.php +7 -7
  217. Util_Request.php +64 -50
  218. Util_Rule.php +15 -10
  219. Util_Ui.php +622 -484
  220. Util_Widget.php +47 -16
Base_Page_Settings.php CHANGED
@@ -1,8 +1,6 @@
1
  <?php
2
  namespace W3TC;
3
 
4
-
5
-
6
  class Base_Page_Settings {
7
  /**
8
  * Config
@@ -39,13 +37,17 @@ class Base_Page_Settings {
39
  */
40
  protected $_config_master;
41
 
 
 
 
 
 
42
  protected $_page;
43
 
44
  function __construct() {
45
- $this->_config = Dispatcher::config();
46
  $this->_config_master = Dispatcher::config_master();
47
-
48
- $this->_page = Util_Admin::get_current_page();
49
  }
50
 
51
  function options() {
@@ -59,7 +61,7 @@ class Base_Page_Settings {
59
  /**
60
  * Returns true if config section is sealed
61
  *
62
- * @param string $section
63
  * @return boolean
64
  */
65
  protected function is_sealed( $section ) {
@@ -78,30 +80,34 @@ class Base_Page_Settings {
78
  /**
79
  * Prints checkbox with config option value
80
  *
81
- * @param string $option_id
82
- * @param bool $disabled
83
- * @param string $class_prefix
84
- * @param bool $label
85
  */
86
- protected function checkbox( $option_id, $disabled = false,
87
- $class_prefix = '', $label = true, $force_value = null ) {
88
  $disabled = $disabled || $this->_config->is_sealed( $option_id );
89
- $name = Util_Ui::config_key_to_http_name( $option_id );
90
 
91
- if ( !$disabled )
92
- echo '<input type="hidden" name="' . $name . '" value="0" />';
 
93
 
94
- if ( $label )
95
  echo '<label>';
96
- echo '<input class="'.$class_prefix.'enabled" type="checkbox" id="' . $name .
97
- '" name="' . $name . '" value="1" ';
98
- if ( !is_null( $force_value ) )
 
 
99
  checked( $force_value, true );
100
- else
101
  checked( $this->_config->get_boolean( $option_id ), true );
 
102
 
103
- if ( $disabled )
104
  echo 'disabled="disabled" ';
 
105
 
106
  echo ' />';
107
  }
@@ -109,27 +115,29 @@ class Base_Page_Settings {
109
  /**
110
  * Prints a radio button and if config value matches value
111
  *
112
- * @param string $option_id config id
113
  * @param unknown $value
114
  * @param bool $disabled
115
  * @param string $class_prefix
116
  */
117
  protected function radio( $option_id, $value, $disabled = false, $class_prefix = '' ) {
118
- if ( is_bool( $value ) )
119
- $rValue = $value?'1':'0';
120
- else
121
- $rValue = $value;
122
- $disabled = $disabled || $this->_config->is_sealed( $option_id );
123
 
124
- $name = Util_Ui::config_key_to_http_name( $option_id );
 
125
 
126
  echo '<label>';
127
- echo '<input class="'.$class_prefix.'enabled" type="radio" id="' . $name .
128
- '" name="' . $name . '" value="', $rValue, '" ';
129
  checked( $this->_config->get_boolean( $option_id ), $value );
130
 
131
- if ( $disabled )
132
  echo 'disabled="disabled" ';
 
133
 
134
  echo ' />';
135
  }
@@ -137,75 +145,86 @@ class Base_Page_Settings {
137
  /**
138
  * Prints checkbox for debug option
139
  *
140
- * @param string $option_id
141
  */
142
  protected function checkbox_debug( $option_id ) {
143
  if ( is_array( $option_id ) ) {
144
- $section = $option_id[0];
145
  $section_enabled = $this->_config->is_extension_active_frontend( $section );
146
  } else {
147
- $section = substr( $option_id, 0, strrpos( $option_id, '.' ) );
148
  $section_enabled = $this->_config->get_boolean( $section . '.enabled' );
149
  }
150
 
151
- $disabled = $this->_config->is_sealed( $option_id ) || !$section_enabled;
152
- $name = Util_Ui::config_key_to_http_name( $option_id );
153
 
154
- if ( !$disabled )
155
- echo '<input type="hidden" name="' . $name . '" value="0" />';
 
156
 
157
  echo '<label>';
158
- echo '<input class="enabled" type="checkbox" id="' . $name .
159
- '" name="' . $name . '" value="1" ';
160
  checked( $this->_config->get_boolean( $option_id ) && $section_enabled, true );
161
 
162
- if ( $disabled )
163
  echo 'disabled="disabled" ';
 
164
 
165
  echo ' />';
166
  }
167
 
168
  protected function checkbox_debug_pro( $option_id, $label, $label_pro ) {
169
  if ( is_array( $option_id ) ) {
170
- $section = $option_id[0];
171
  $section_enabled = $this->_config->is_extension_active_frontend( $section );
172
  } else {
173
- $section = substr( $option_id, 0, strrpos( $option_id, '.' ) );
174
  $section_enabled = $this->_config->get_boolean( $section . '.enabled' );
175
  }
176
 
177
- $is_pro = Util_Environment::is_w3tc_pro( $this->_config );
178
- $disabled = $this->_config->is_sealed( $option_id ) || !$section_enabled ||
179
- !$is_pro;
180
- $name = Util_Ui::config_key_to_http_name( $option_id );
181
 
182
- if ( !$disabled )
183
- echo '<input type="hidden" name="' . $name . '" value="0" />';
 
184
 
185
  echo '<label>';
186
- echo '<input class="enabled" type="checkbox" id="' . $name .
187
- '" name="' . $name . '" value="1" ';
188
  checked( $this->_config->get_boolean( $option_id ) && $is_pro, true );
189
 
190
- if ( $disabled )
191
  echo 'disabled="disabled" ';
 
192
 
193
  echo ' />';
194
  echo esc_html( $label );
 
195
  if ( $is_pro ) {
196
- echo $label_pro;
 
 
 
 
 
 
 
 
 
197
  }
 
198
  echo '</label>';
199
  }
200
 
201
- protected function value_with_disabled( $option_id, $disabled,
202
- $value_when_disabled ) {
203
  if ( $disabled ) {
204
- echo 'value="' . esc_attr( $value_when_disabled ) . '" ';
205
- echo 'disabled="disabled" ';
206
  } else {
207
- echo 'value="' .
208
- esc_attr( $this->_config->get_string( $option_id ) ) . '" ';
209
  }
210
  }
211
 
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  class Base_Page_Settings {
5
  /**
6
  * Config
37
  */
38
  protected $_config_master;
39
 
40
+ /**
41
+ * Page
42
+ *
43
+ * @var number
44
+ */
45
  protected $_page;
46
 
47
  function __construct() {
48
+ $this->_config = Dispatcher::config();
49
  $this->_config_master = Dispatcher::config_master();
50
+ $this->_page = Util_Admin::get_current_page();
 
51
  }
52
 
53
  function options() {
61
  /**
62
  * Returns true if config section is sealed
63
  *
64
+ * @param string $section
65
  * @return boolean
66
  */
67
  protected function is_sealed( $section ) {
80
  /**
81
  * Prints checkbox with config option value
82
  *
83
+ * @param string $option_id
84
+ * @param bool $disabled
85
+ * @param string $class_prefix
86
+ * @param bool $label
87
  */
88
+ protected function checkbox( $option_id, $disabled = false, $class_prefix = '', $label = true, $force_value = null ) {
 
89
  $disabled = $disabled || $this->_config->is_sealed( $option_id );
90
+ $name = Util_Ui::config_key_to_http_name( $option_id );
91
 
92
+ if ( ! $disabled ) {
93
+ echo '<input type="hidden" name="' . esc_attr( $name ) . '" value="0" />';
94
+ }
95
 
96
+ if ( $label ) {
97
  echo '<label>';
98
+ }
99
+
100
+ echo '<input class="' . esc_attr( $class_prefix ) . 'enabled" type="checkbox" id="' . esc_attr( $name ) . '" name="' . esc_attr( $name ) . '" value="1" ';
101
+
102
+ if ( ! is_null( $force_value ) ) {
103
  checked( $force_value, true );
104
+ } else {
105
  checked( $this->_config->get_boolean( $option_id ), true );
106
+ }
107
 
108
+ if ( $disabled ) {
109
  echo 'disabled="disabled" ';
110
+ }
111
 
112
  echo ' />';
113
  }
115
  /**
116
  * Prints a radio button and if config value matches value
117
  *
118
+ * @param string $option_id config id.
119
  * @param unknown $value
120
  * @param bool $disabled
121
  * @param string $class_prefix
122
  */
123
  protected function radio( $option_id, $value, $disabled = false, $class_prefix = '' ) {
124
+ if ( is_bool( $value ) ) {
125
+ $r_value = $value ? '1' : '0';
126
+ } else {
127
+ $r_value = $value;
128
+ }
129
 
130
+ $disabled = $disabled || $this->_config->is_sealed( $option_id );
131
+ $name = Util_Ui::config_key_to_http_name( $option_id );
132
 
133
  echo '<label>';
134
+ echo '<input class="' . esc_attr( $class_prefix ) . 'enabled" type="radio" id="' . esc_attr( $name ) . '" name="' . esc_attr( $name ) . '" value="' . esc_attr( $r_value ) . '" ';
135
+
136
  checked( $this->_config->get_boolean( $option_id ), $value );
137
 
138
+ if ( $disabled ) {
139
  echo 'disabled="disabled" ';
140
+ }
141
 
142
  echo ' />';
143
  }
145
  /**
146
  * Prints checkbox for debug option
147
  *
148
+ * @param string $option_id
149
  */
150
  protected function checkbox_debug( $option_id ) {
151
  if ( is_array( $option_id ) ) {
152
+ $section = $option_id[0];
153
  $section_enabled = $this->_config->is_extension_active_frontend( $section );
154
  } else {
155
+ $section = substr( $option_id, 0, strrpos( $option_id, '.' ) );
156
  $section_enabled = $this->_config->get_boolean( $section . '.enabled' );
157
  }
158
 
159
+ $disabled = $this->_config->is_sealed( $option_id ) || ! $section_enabled;
160
+ $name = Util_Ui::config_key_to_http_name( $option_id );
161
 
162
+ if ( ! $disabled ) {
163
+ echo '<input type="hidden" name="' . esc_attr( $name ) . '" value="0" />';
164
+ }
165
 
166
  echo '<label>';
167
+ echo '<input class="enabled" type="checkbox" id="' . esc_attr( $name ) . '" name="' . esc_attr( $name ) . '" value="1" ';
168
+
169
  checked( $this->_config->get_boolean( $option_id ) && $section_enabled, true );
170
 
171
+ if ( $disabled ) {
172
  echo 'disabled="disabled" ';
173
+ }
174
 
175
  echo ' />';
176
  }
177
 
178
  protected function checkbox_debug_pro( $option_id, $label, $label_pro ) {
179
  if ( is_array( $option_id ) ) {
180
+ $section = $option_id[0];
181
  $section_enabled = $this->_config->is_extension_active_frontend( $section );
182
  } else {
183
+ $section = substr( $option_id, 0, strrpos( $option_id, '.' ) );
184
  $section_enabled = $this->_config->get_boolean( $section . '.enabled' );
185
  }
186
 
187
+ $is_pro = Util_Environment::is_w3tc_pro( $this->_config );
188
+ $disabled = $this->_config->is_sealed( $option_id ) || ! $section_enabled || ! $is_pro;
189
+ $name = Util_Ui::config_key_to_http_name( $option_id );
 
190
 
191
+ if ( ! $disabled ) {
192
+ echo '<input type="hidden" name="' . esc_attr( $name ) . '" value="0" />';
193
+ }
194
 
195
  echo '<label>';
196
+ echo '<input class="enabled" type="checkbox" id="' . esc_attr( $name ) . '" name="' . esc_attr( $name ) . '" value="1" ';
197
+
198
  checked( $this->_config->get_boolean( $option_id ) && $is_pro, true );
199
 
200
+ if ( $disabled ) {
201
  echo 'disabled="disabled" ';
202
+ }
203
 
204
  echo ' />';
205
  echo esc_html( $label );
206
+
207
  if ( $is_pro ) {
208
+ echo wp_kses(
209
+ $label_pro,
210
+ array(
211
+ 'a' => array(
212
+ 'href' => array(),
213
+ 'id' => array(),
214
+ 'class' => array(),
215
+ ),
216
+ )
217
+ );
218
  }
219
+
220
  echo '</label>';
221
  }
222
 
223
+ protected function value_with_disabled( $option_id, $disabled, $value_when_disabled ) {
 
224
  if ( $disabled ) {
225
+ echo 'value="' . esc_attr( $value_when_disabled ) . '" disabled="disabled" ';
 
226
  } else {
227
+ echo 'value="' . esc_attr( $this->_config->get_string( $option_id ) ) . '" ';
 
228
  }
229
  }
230
 
BrowserCache_Page_View_QuickReference.php CHANGED
@@ -1,78 +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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div class="lightbox-content-padded">
9
+ <h3><?php esc_html_e( 'Security Headers: Quick Reference', 'w3-total-cache' ); ?></h3>
10
 
11
+ <fieldset>
12
+ <legend><?php esc_html_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_Page_View_SectionSecurity.php CHANGED
@@ -19,151 +19,170 @@ $fp_values = $c->get_array( 'browsercache.security.fp.values' );
19
  $feature_policies = array(
20
  array(
21
  'label' => 'accelerometer',
22
- 'description' => __( 'Controls whether the current document is allowed to gather information about the acceleration of the device through the Accelerometer interface.', 'w3-total-cache' ),
23
  ),
24
  array(
25
  'label' => 'ambient-light-sensor',
26
- 'description' => __( 'Controls whether the current document is allowed to gather information about the amount of light in the environment around the device through the AmbientLightSensor interface.', 'w3-total-cache' ),
27
  ),
28
  array(
29
  'label' => 'autoplay',
30
- 'description' => __( 'Controls whether the current document is allowed to autoplay media requested through the HTMLMediaElement interface.', 'w3-total-cache' ),
31
  ),
32
  array(
33
  'label' => 'battery',
34
- 'description' => __( 'Controls whether the use of the Battery Status API is allowed. When this policy is disabled, the Promise returned by Navigator.getBattery() will reject with a NotAllowedError DOMException.', 'w3-total-cache' ),
35
  ),
36
  array(
37
  'label' => 'camera',
38
- 'description' => __( 'Controls whether the current document is allowed to use video input devices.', 'w3-total-cache' ),
39
  ),
40
  array(
41
  'label' => 'display-capture',
42
- 'description' => __( 'Controls whether or not the document is permitted to use Screen Capture API.', 'w3-total-cache' ),
43
  ),
44
  array(
45
  'label' => 'document-domain',
46
- 'description' => __( 'Controls whether the current document is allowed to set document.domain.', 'w3-total-cache' ),
47
  ),
48
  array(
49
  'label' => 'encrypted-media',
50
- 'description' => __( 'Controls whether the current document is allowed to use the Encrypted Media Extensions API (EME).', 'w3-total-cache' ),
51
  ),
52
  array(
53
  'label' => 'execution-while-not-rendered',
54
- 'description' => __( 'Controls whether tasks should execute in frames while they\'re not being rendered (e.g. if an iframe is hidden or display: none).', 'w3-total-cache' ),
55
  ),
56
  array(
57
  'label' => 'execution-while-out-of-viewport',
58
- 'description' => __( 'Controls whether tasks should execute in frames while they\'re outside of the visible viewport.', 'w3-total-cache' ),
59
  ),
60
  array(
61
  'label' => 'fullscreen',
62
- 'description' => __( 'Controls whether the current document is allowed to use Element.requestFullScreen().', 'w3-total-cache' ),
63
  ),
64
  array(
65
  'label' => 'gamepad',
66
- 'description' => __( 'Controls whether the current document is allowed to use the Gamepad API. When this policy is disabled, calls to Navigator.getGamepads() will throw a SecurityError DOMException, and the gamepadconnected and gamepaddisconnected events will not fire.', 'w3-total-cache' ),
67
  ),
68
  array(
69
  'label' => 'geolocation',
70
- 'description' => __( 'Controls whether the current document is allowed to use the Geolocation Interface.', 'w3-total-cache' ),
71
  ),
72
  array(
73
  'label' => 'gyroscope',
74
- 'description' => __( 'Controls whether the current document is allowed to gather information about the orientation of the device through the Gyroscope interface.', 'w3-total-cache' ),
75
  ),
76
  array(
77
  'label' => 'layout-animations',
78
- 'description' => __( 'Controls whether the current document is allowed to show layout animations.', 'w3-total-cache' ),
79
  ),
80
  array(
81
  'label' => 'legacy-image-formats',
82
- 'description' => __( 'Controls whether the current document is allowed to display images in legacy formats.', 'w3-total-cache' ),
83
  ),
84
  array(
85
  'label' => 'magnetometer',
86
- 'description' => __( 'Controls whether the current document is allowed to gather information about the orientation of the device through the Magnetometer interface.', 'w3-total-cache' ),
87
  ),
88
  array(
89
  'label' => 'microphone',
90
- 'description' => __( 'Controls whether the current document is allowed to use audio input devices.', 'w3-total-cache' ),
91
  ),
92
  array(
93
  'label' => 'midi',
94
- 'description' => __( 'Controls whether the current document is allowed to use the Web MIDI API.', 'w3-total-cache' ),
95
  ),
96
  array(
97
  'label' => 'navigation-override',
98
- 'description' => __( 'Controls the availability of mechanisms that enables the page author to take control over the behavior of spatial navigation, or to cancel it outright.', 'w3-total-cache' ),
99
  ),
100
  array(
101
  'label' => 'oversized-images',
102
- 'description' => __( 'Controls whether the current document is allowed to download and display large images.', 'w3-total-cache' ),
103
  ),
104
  array(
105
  'label' => 'payment',
106
- 'description' => __( 'Controls whether the current document is allowed to use the Payment Request API.', 'w3-total-cache' ),
107
  ),
108
  array(
109
  'label' => 'picture-in-picture',
110
- 'description' => __( 'Controls whether the current document is allowed to play a video in a Picture-in-Picture mode via the corresponding API.', 'w3-total-cache' ),
111
  ),
112
  array(
113
  'label' => 'publickey-credentials-get',
114
- 'description' => __( 'Controls whether the current document is allowed to use the Web Authentication API to retrieve already stored public-key credentials, i.e. via navigator.credentials.get({publicKey: ..., ...}).', 'w3-total-cache' ),
115
  ),
116
  array(
117
  'label' => 'screen-wake-lock',
118
- 'description' => __( 'Controls whether the current document is allowed to use Screen Wake Lock API to indicate that device should not turn off or dim the screen.', 'w3-total-cache' ),
119
  ),
120
  array(
121
  'label' => 'speaker',
122
- 'description' => __( 'Controls whether the current document is allowed to play audio via any methods.', 'w3-total-cache' ),
123
  ),
124
  array(
125
  'label' => 'sync-xhr',
126
- 'description' => __( 'Controls whether the current document is allowed to make synchronous XMLHttpRequest requests.', 'w3-total-cache' ),
127
  ),
128
  array(
129
  'label' => 'unoptimized-images',
130
- 'description' => __( 'Controls whether the current document is allowed to download and display unoptimized images.', 'w3-total-cache' ),
131
  ),
132
  array(
133
  'label' => 'unsized-media',
134
- 'description' => __( 'Controls whether the current document is allowed to change the size of media elements after the initial layout is complete.', 'w3-total-cache' ),
135
  ),
136
  array(
137
  'label' => 'usb',
138
- 'description' => __( 'Controls whether the current document is allowed to use the WebUSB API.', 'w3-total-cache' ),
139
  ),
140
  array(
141
  'label' => 'vibrate',
142
- 'description' => __( 'Controls whether the current document is allowed to trigger device vibrations via Navigator.vibrate() method of Vibration API.', 'w3-total-cache' ),
143
  ),
144
  array(
145
  'label' => 'vr',
146
- 'description' => __( 'Controls whether the current document is allowed to use the WebVR API. When this policy is disabled, the Promise returned by Navigator.getVRDisplays() will reject with a DOMException. Keep in mind that the WebVR standard is in the process of being replaced with WebXR.', 'w3-total-cache' ),
147
  ),
148
  array(
149
  'label' => 'wake-lock',
150
- 'description' => __( 'Controls whether the current document is allowed to use Wake Lock API to indicate that device should not enter power-saving mode.', 'w3-total-cache' ),
151
  ),
152
  array(
153
  'label' => 'web-share',
154
- 'description' => __( 'Controls whether or not the current document is allowed to use the Navigator.share() of Web Share API to share text, links, images, and other content to arbitrary destinations of user\'s choice, e.g. mobile apps.', 'w3-total-cache' ),
155
  ),
156
  array(
157
  'label' => 'xr-spatial-tracking',
158
- 'description' => __( 'Controls whether the current document is allowed to use the WebXR Device API.', 'w3-total-cache' ),
159
  ),
160
  );
161
 
162
  ?>
163
 
164
- <?php Util_Ui::postbox_header( __( 'Security Headers', 'w3-total-cache' ), '', 'security' ); ?>
165
- <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>
166
- <p><a onclick="w3tc_csp_reference()" href="javascript:void(0);">Quick Reference Chart</a></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
  <table class="form-table">
169
  <?php
@@ -172,7 +191,22 @@ $feature_policies = array(
172
  'key' => 'browsercache.security.session.use_only_cookies',
173
  'control' => 'selectbox',
174
  'selectbox_values' => $security_session_values,
175
- 'description' => __( 'This setting prevents attacks that are caused by passing session IDs in <acronym title="Uniform Resource Locator">URL</acronym>s.', 'w3-total-cache' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  )
177
  );
178
  ?>
@@ -182,7 +216,7 @@ $feature_policies = array(
182
  'key' => 'browsercache.security.session.cookie_httponly',
183
  'control' => 'selectbox',
184
  'selectbox_values' => $security_session_values,
185
- 'description' => __( 'This tells the user\'s browser not to make the session cookie accessible to client side scripting such as JavaScript. This makes it harder for an attacker to hijack the session ID and masquerade as the effected user.', 'w3-total-cache' ),
186
  )
187
  );
188
  ?>
@@ -192,14 +226,48 @@ $feature_policies = array(
192
  'key' => 'browsercache.security.session.cookie_secure',
193
  'control' => 'selectbox',
194
  'selectbox_values' => $security_session_values,
195
- 'description' => __( 'This will prevent the user\'s session ID from being transmitted in plain text, making it much harder to hijack the user\'s session.', 'w3-total-cache' ),
196
  )
197
  );
198
  ?>
199
  <tr>
200
  <th colspan="2">
201
  <?php $this->checkbox( 'browsercache.hsts' ); ?> <?php Util_Ui::e_config_label( 'browsercache.hsts' ); ?></label>
202
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  </th>
204
  </tr>
205
  <tr>
@@ -211,10 +279,10 @@ $feature_policies = array(
211
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
212
  name="browsercache__security__hsts__directive">
213
  <?php $value = $this->_config->get_string( 'browsercache.security.hsts.directive' ); ?>
214
- <option value="maxage"<?php selected( $value, 'maxage' ); ?>><?php _e( 'max-age=EXPIRES_SECONDS', 'w3-total-cache' ); ?></option>
215
- <option value="maxagepre"<?php selected( $value, 'maxagepre' ); ?>><?php _e( 'max-age=EXPIRES_SECONDS; preload', 'w3-total-cache' ); ?></option>
216
- <option value="maxageinc"<?php selected( $value, 'maxageinc' ); ?>><?php _e( 'max-age=EXPIRES_SECONDS; includeSubDomains', 'w3-total-cache' ); ?></option>
217
- <option value="maxageincpre"<?php selected( $value, 'maxageincpre' ); ?>><?php _e( 'max-age=EXPIRES_SECONDS; includeSubDomains; preload', 'w3-total-cache' ); ?></option>
218
  </select>
219
  <div id="browsercache_security_hsts_directive_description"></div>
220
  </td>
@@ -222,7 +290,9 @@ $feature_policies = array(
222
  <tr>
223
  <th colspan="2">
224
  <?php $this->checkbox( 'browsercache.security.xfo' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.xfo' ); ?></label>
225
- <p class="description"><?php _e( 'This tells the browser if it is permitted to render a page within a frame-like tag (i.e., &lt;frame&gt;, &lt;iframe&gt; or &lt;object&gt;). This is useful for preventing clickjacking attacks.', 'w3-total-cache' ); ?></p>
 
 
226
  </th>
227
  </tr>
228
  <tr>
@@ -234,9 +304,9 @@ $feature_policies = array(
234
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
235
  name="browsercache__security__xfo__directive">
236
  <?php $value = $this->_config->get_string( 'browsercache.security.xfo.directive' ); ?>
237
- <option value="same"<?php selected( $value, 'same' ); ?>><?php _e( 'SameOrigin', 'w3-total-cache' ); ?></option>
238
- <option value="deny"<?php selected( $value, 'deny' ); ?>><?php _e( 'Deny', 'w3-total-cache' ); ?></option>
239
- <option value="allow"<?php selected( $value, 'allow' ); ?>><?php _e( 'Allow-From', 'w3-total-cache' ); ?></option>
240
  </select>
241
  <input id="browsercache_security_xfo_allow" type="text" name="browsercache__security__xfo__allow"
242
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.xfo.allow' ) ); ?>" size="50" placeholder="Enter URL" />
@@ -246,7 +316,26 @@ $feature_policies = array(
246
  <tr>
247
  <th colspan="2">
248
  <?php $this->checkbox( 'browsercache.security.xss' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.xss' ); ?></label>
249
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  </th>
251
  </tr>
252
  <tr>
@@ -258,9 +347,9 @@ $feature_policies = array(
258
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
259
  name="browsercache__security__xss__directive">
260
  <?php $value = $this->_config->get_string( 'browsercache.security.xss.directive' ); ?>
261
- <option value="0"<?php selected( $value, '0' ); ?>><?php _e( '0', 'w3-total-cache' ); ?></option>
262
- <option value="1"<?php selected( $value, '1' ); ?>><?php _e( '1', 'w3-total-cache' ); ?></option>
263
- <option value="block"<?php selected( $value, 'block' ); ?>><?php _e( '1; mode=block', 'w3-total-cache' ); ?></option>
264
  </select>
265
  <div id="browsercache_security_xss_directive_description"></div>
266
  </td>
@@ -268,13 +357,40 @@ $feature_policies = array(
268
  <tr>
269
  <th colspan="2">
270
  <?php $this->checkbox( 'browsercache.security.xcto' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.xcto' ); ?></label>
271
- <p class="description"><?php _e( 'This instructs the browser to not MIME-sniff a response outside its declared content-type. It helps to reduce drive-by download attacks and stops sites from serving malevolent content that could masquerade as an executable or dynamic HTML file.', 'w3-total-cache' ); ?></p>
 
 
272
  </th>
273
  </tr>
274
  <tr>
275
  <th colspan="2">
276
  <?php $this->checkbox( 'browsercache.security.pkp' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.pkp' ); ?></label>
277
- <p class="description"><?php _e( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Public Key Pinning (<acronym title="HTTP Public Key Pinning">HPKP</acronym>) is a security feature for <acronym title="Hypertext Transfer Protocol">HTTP</acronym>S websites that can prevent fraudulently issued certificates from being used to impersonate existing secure websites.', 'w3-total-cache' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  </th>
279
  </tr>
280
  <tr>
@@ -284,7 +400,32 @@ $feature_policies = array(
284
  <td>
285
  <input id="browsercache_security_pkp_pin" type="text" name="browsercache__security__pkp__pin"
286
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.pkp.pin' ) ); ?>" size="50" placeholder="Enter the Base64-Encode of the SHA256 Hash" />
287
- <div><i><?php _e( 'This field is <b>required</b> and represents a <acronym title="Subject Public Key Information">SPKI</acronym> fingerprint. This pin is any public key within your current certificate chain.', 'w3-total-cache' ); ?></i></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  </td>
289
  </tr>
290
  <tr>
@@ -294,7 +435,32 @@ $feature_policies = array(
294
  <td>
295
  <input id="browsercache_security_pkp_pin_backup" type="text" name="browsercache__security__pkp__pin__backup"
296
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.pkp.pin.backup' ) ); ?>" size="50" placeholder="Enter the Base64-Encode of the SHA256 Hash" />
297
- <div><i><?php _e( 'This field is <b>also required</b> and represents your backup <acronym title="Subject Public Key Information">SPKI</acronym> fingerprint. This pin is any public key not in your current certificate chain and serves as a backup in case your certificate expires or has to be revoked.', 'w3-total-cache' ); ?></i></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  </td>
299
  </tr>
300
  <tr>
@@ -306,8 +472,8 @@ $feature_policies = array(
306
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
307
  name="browsercache__security__pkp__extra">
308
  <?php $value = $this->_config->get_string( 'browsercache.security.pkp.extra' ); ?>
309
- <option value="maxage"<?php selected( $value, 'maxage' ); ?>><?php _e( 'max-age=EXPIRES_SECONDS', 'w3-total-cache' ); ?></option>
310
- <option value="maxageinc"<?php selected( $value, 'maxageinc' ); ?>><?php _e( 'max-age=EXPIRES_SECONDS; includeSubDomains', 'w3-total-cache' ); ?></option>
311
  </select>
312
  <div id="browsercache_security_pkp_extra_description"></div>
313
  </td>
@@ -319,7 +485,28 @@ $feature_policies = array(
319
  <td>
320
  <input id="browsercache_security_pkp_report_url" type="text" name="browsercache__security__pkp__report__url"
321
  <?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" />
322
- <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.', 'w3-total-cache' ); ?></i></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  </td>
324
  </tr>
325
  <tr>
@@ -331,8 +518,8 @@ $feature_policies = array(
331
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
332
  name="browsercache__security__pkp__report__only">
333
  <?php $value = $this->_config->get_string( 'browsercache.security.pkp.report.only' ); ?>
334
- <option value="0"<?php selected( $value, '0' ); ?>><?php _e( 'No = Enforce HPKP', 'w3-total-cache' ); ?></option>
335
- <option value="1"<?php selected( $value, '1' ); ?>><?php _e( 'Yes = Don\'t Enforce HPKP', 'w3-total-cache' ); ?></option>
336
  </select>
337
  <div id="browsercache_security_pkp_report_only_description"></div>
338
  </td>
@@ -340,7 +527,9 @@ $feature_policies = array(
340
  <tr>
341
  <th colspan="2">
342
  <?php $this->checkbox( 'browsercache.security.referrer.policy' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.referrer.policy' ); ?></label>
343
- <p class="description"><?php _e( 'This header restricts the values of the referer header in outbound links.', 'w3-total-cache' ); ?></p>
 
 
344
  </th>
345
  </tr>
346
  <tr>
@@ -352,15 +541,15 @@ $feature_policies = array(
352
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
353
  name="browsercache__security__referrer__policy__directive">
354
  <?php $value = $this->_config->get_string( 'browsercache.security.referrer.policy.directive' ); ?>
355
- <option value="0"<?php selected( $value, '0' ); ?>><?php _e( 'Not Set', 'w3-total-cache' ); ?></option>
356
- <option value="no-referrer"<?php selected( $value, 'no-referrer' ); ?>><?php _e( 'no-referrer', 'w3-total-cache' ); ?></option>
357
- <option value="no-referrer-when-downgrade"<?php selected( $value, 'no-referrer-when-downgrade' ); ?>><?php _e( 'no-referrer-when-downgrade', 'w3-total-cache' ); ?></option>
358
- <option value="same-origin"<?php selected( $value, 'same-origin' ); ?>><?php _e( 'same-origin', 'w3-total-cache' ); ?></option>
359
- <option value="origin"<?php selected( $value, 'origin' ); ?>><?php _e( 'origin', 'w3-total-cache' ); ?></option>
360
- <option value="strict-origin"<?php selected( $value, 'strict-origin' ); ?>><?php _e( 'strict-origin', 'w3-total-cache' ); ?></option>
361
- <option value="origin-when-cross-origin"<?php selected( $value, 'origin-when-cross-origin' ); ?>><?php _e( 'origin-when-cross-origin', 'w3-total-cache' ); ?></option>
362
- <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>
363
- <option value="unsafe-url"<?php selected( $value, 'unsafe-url' ); ?>><?php _e( 'unsafe-url', 'w3-total-cache' ); ?></option>
364
  </select>
365
  <div id="browsercache_security_referrer_policy_directive_description"></div>
366
  </td>
@@ -368,7 +557,29 @@ $feature_policies = array(
368
  <tr>
369
  <th colspan="2">
370
  <?php $this->checkbox( 'browsercache.security.csp' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.csp' ); ?></label>
371
- <p 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.', 'w3-total-cache' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  </th>
373
  </tr>
374
  <tr>
@@ -378,7 +589,28 @@ $feature_policies = array(
378
  <td>
379
  <input id="browsercache_security_csp_base" type="text" name="browsercache__security__csp__base"
380
  <?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" />
381
- <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.', 'w3-total-cache' ); ?></i></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  </td>
383
  </tr>
384
  <tr>
@@ -388,7 +620,7 @@ $feature_policies = array(
388
  <td>
389
  <input id="browsercache_security_csp_connect" type="text" name="browsercache__security__csp__connect"
390
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.connect' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
391
- <div><i><?php _e( 'Limits the origins to which you can connect via XMLHttpRequest, WebSockets, and EventSource.', 'w3-total-cache' ); ?></i></div>
392
  </td>
393
  </tr>
394
  <tr>
@@ -398,7 +630,7 @@ $feature_policies = array(
398
  <td>
399
  <input id="browsercache_security_csp_font" type="text" name="browsercache__security__csp__font"
400
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.font' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
401
- <div><i><?php _e( 'Specifies the origins that can serve web fonts.', 'w3-total-cache' ); ?></i></div>
402
  </td>
403
  </tr>
404
  <tr>
@@ -408,7 +640,7 @@ $feature_policies = array(
408
  <td>
409
  <input id="browsercache_security_csp_frame" type="text" name="browsercache__security__csp__frame"
410
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.frame' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
411
- <div><i><?php _e( 'Restricts from where the protected resource can embed frames.', 'w3-total-cache' ); ?></i></div>
412
  </td>
413
  </tr>
414
  <tr>
@@ -418,7 +650,7 @@ $feature_policies = array(
418
  <td>
419
  <input id="browsercache_security_csp_img" type="text" name="browsercache__security__csp__img"
420
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.img' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
421
- <div><i><?php _e( 'Specifies valid sources for images and favicons.', 'w3-total-cache' ); ?></i></div>
422
  </td>
423
  </tr>
424
  <tr>
@@ -428,7 +660,7 @@ $feature_policies = array(
428
  <td>
429
  <input id="browsercache_security_csp_media" type="text" name="browsercache__security__csp__media"
430
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.media' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
431
- <div><i><?php _e( 'Specifies valid sources for loading media using the &lt;audio&gt; and &lt;video&gt; elements.', 'w3-total-cache' ); ?></i></div>
432
  </td>
433
  </tr>
434
  <tr>
@@ -438,7 +670,7 @@ $feature_policies = array(
438
  <td>
439
  <input id="browsercache_security_csp_object" type="text" name="browsercache__security__csp__object"
440
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.object' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
441
- <div><i><?php _e( 'Allows control over the &lt;object&gt;, &lt;embed&gt;, and &lt;applet&gt; elements used by Flash and other plugins.', 'w3-total-cache' ); ?></i></div>
442
  </td>
443
  </tr>
444
  <tr>
@@ -448,7 +680,7 @@ $feature_policies = array(
448
  <td>
449
  <input id="browsercache_security_csp_script" type="text" name="browsercache__security__csp__script"
450
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.script' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
451
- <div><i><?php _e( 'Specifies valid sources for JavaScript.', 'w3-total-cache' ); ?></i></div>
452
  </td>
453
  </tr>
454
  <tr>
@@ -458,7 +690,28 @@ $feature_policies = array(
458
  <td>
459
  <input id="browsercache_security_csp_style" type="text" name="browsercache__security__csp__style"
460
  <?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" />
461
- <div><i><?php _e( 'Specifies valid sources for <acronym title="Cascading Style Sheet">CSS</acronym> stylesheets.', 'w3-total-cache' ); ?></i></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  </td>
463
  </tr>
464
  <tr>
@@ -468,7 +721,28 @@ $feature_policies = array(
468
  <td>
469
  <input id="browsercache_security_csp_form" type="text" name="browsercache__security__csp__form"
470
  <?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" />
471
- <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.', 'w3-total-cache' ); ?></i></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  </td>
473
  </tr>
474
  <tr>
@@ -478,7 +752,7 @@ $feature_policies = array(
478
  <td>
479
  <input id="browsercache_security_csp_frame_ancestors" type="text" name="browsercache__security__csp__frame__ancestors"
480
  <?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'" />
481
- <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;.', 'w3-total-cache' ); ?></i></div>
482
  </td>
483
  </tr>
484
  <tr>
@@ -488,7 +762,7 @@ $feature_policies = array(
488
  <td>
489
  <input id="browsercache_security_csp_plugin" type="text" name="browsercache__security__csp__plugin"
490
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.plugin' ) ); ?>" size="50" placeholder="Example: application/x-shockwave-flash" />
491
- <div><i><?php _e( 'Restricts the set of plugins that can be embedded into a document by limiting the types of resources which can be loaded.', 'w3-total-cache' ); ?></i></div>
492
  </td>
493
  </tr>
494
  <tr>
@@ -498,7 +772,7 @@ $feature_policies = array(
498
  <td>
499
  <input id="browsercache_security_csp_sandbox" type="text" name="browsercache__security__csp__sandbox"
500
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.sandbox' ) ); ?>" size="50" placeholder="Example: allow-popups" />
501
- <div><i><?php _e( 'This directive operates similarly to the &lt;iframe&gt; sandbox attribute by applying restrictions to a page\'s actions, including preventing popups, preventing the execution of plugins and scripts, and enforcing a same-origin policy.', 'w3-total-cache' ); ?></i></div>
502
  </td>
503
  </tr>
504
  <tr>
@@ -508,7 +782,7 @@ $feature_policies = array(
508
  <td>
509
  <input id="browsercache_security_csp_default" type="text" name="browsercache__security__csp__default"
510
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.default' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
511
- <div><i><?php _e( 'Defines the defaults for directives you leave unspecified. Generally, this applies to any directive that ends with -src.', 'w3-total-cache' ); ?></i></div>
512
  </td>
513
  </tr>
514
  <?php
@@ -517,8 +791,8 @@ $feature_policies = array(
517
  'key' => 'browsercache.security.fp',
518
  'disabled' => Util_Ui::sealing_disabled( 'browsercache.' ),
519
  'control' => 'checkbox',
520
- 'checkbox_label' => __( 'Feature-Policy', 'w3-total-cache' ),
521
- 'description' => __( 'Allows you to control which origins can use which features.', 'w3-total-cache' ),
522
  'label_class' => 'w3tc_single_column',
523
  )
524
  );
@@ -534,7 +808,7 @@ $feature_policies = array(
534
  'control' => 'textbox',
535
  'label' => $i['label'],
536
  'textbox_size' => '50',
537
- 'textbox_placeholder' => "One of: * 'self' 'src' 'none' *.domain.com",
538
  'description' => $i['description'],
539
  )
540
  );
19
  $feature_policies = array(
20
  array(
21
  'label' => 'accelerometer',
22
+ 'description' => esc_html__( 'Controls whether the current document is allowed to gather information about the acceleration of the device through the Accelerometer interface.', 'w3-total-cache' ),
23
  ),
24
  array(
25
  'label' => 'ambient-light-sensor',
26
+ 'description' => esc_html__( 'Controls whether the current document is allowed to gather information about the amount of light in the environment around the device through the AmbientLightSensor interface.', 'w3-total-cache' ),
27
  ),
28
  array(
29
  'label' => 'autoplay',
30
+ 'description' => esc_html__( 'Controls whether the current document is allowed to autoplay media requested through the HTMLMediaElement interface.', 'w3-total-cache' ),
31
  ),
32
  array(
33
  'label' => 'battery',
34
+ 'description' => esc_html__( 'Controls whether the use of the Battery Status API is allowed. When this policy is disabled, the Promise returned by Navigator.getBattery() will reject with a NotAllowedError DOMException.', 'w3-total-cache' ),
35
  ),
36
  array(
37
  'label' => 'camera',
38
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use video input devices.', 'w3-total-cache' ),
39
  ),
40
  array(
41
  'label' => 'display-capture',
42
+ 'description' => esc_html__( 'Controls whether or not the document is permitted to use Screen Capture API.', 'w3-total-cache' ),
43
  ),
44
  array(
45
  'label' => 'document-domain',
46
+ 'description' => esc_html__( 'Controls whether the current document is allowed to set document.domain.', 'w3-total-cache' ),
47
  ),
48
  array(
49
  'label' => 'encrypted-media',
50
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the Encrypted Media Extensions API (EME).', 'w3-total-cache' ),
51
  ),
52
  array(
53
  'label' => 'execution-while-not-rendered',
54
+ 'description' => esc_html__( 'Controls whether tasks should execute in frames while they\'re not being rendered (e.g. if an iframe is hidden or display: none).', 'w3-total-cache' ),
55
  ),
56
  array(
57
  'label' => 'execution-while-out-of-viewport',
58
+ 'description' => esc_html__( 'Controls whether tasks should execute in frames while they\'re outside of the visible viewport.', 'w3-total-cache' ),
59
  ),
60
  array(
61
  'label' => 'fullscreen',
62
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use Element.requestFullScreen().', 'w3-total-cache' ),
63
  ),
64
  array(
65
  'label' => 'gamepad',
66
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the Gamepad API. When this policy is disabled, calls to Navigator.getGamepads() will throw a SecurityError DOMException, and the gamepadconnected and gamepaddisconnected events will not fire.', 'w3-total-cache' ),
67
  ),
68
  array(
69
  'label' => 'geolocation',
70
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the Geolocation Interface.', 'w3-total-cache' ),
71
  ),
72
  array(
73
  'label' => 'gyroscope',
74
+ 'description' => esc_html__( 'Controls whether the current document is allowed to gather information about the orientation of the device through the Gyroscope interface.', 'w3-total-cache' ),
75
  ),
76
  array(
77
  'label' => 'layout-animations',
78
+ 'description' => esc_html__( 'Controls whether the current document is allowed to show layout animations.', 'w3-total-cache' ),
79
  ),
80
  array(
81
  'label' => 'legacy-image-formats',
82
+ 'description' => esc_html__( 'Controls whether the current document is allowed to display images in legacy formats.', 'w3-total-cache' ),
83
  ),
84
  array(
85
  'label' => 'magnetometer',
86
+ 'description' => esc_html__( 'Controls whether the current document is allowed to gather information about the orientation of the device through the Magnetometer interface.', 'w3-total-cache' ),
87
  ),
88
  array(
89
  'label' => 'microphone',
90
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use audio input devices.', 'w3-total-cache' ),
91
  ),
92
  array(
93
  'label' => 'midi',
94
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the Web MIDI API.', 'w3-total-cache' ),
95
  ),
96
  array(
97
  'label' => 'navigation-override',
98
+ 'description' => esc_html__( 'Controls the availability of mechanisms that enables the page author to take control over the behavior of spatial navigation, or to cancel it outright.', 'w3-total-cache' ),
99
  ),
100
  array(
101
  'label' => 'oversized-images',
102
+ 'description' => esc_html__( 'Controls whether the current document is allowed to download and display large images.', 'w3-total-cache' ),
103
  ),
104
  array(
105
  'label' => 'payment',
106
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the Payment Request API.', 'w3-total-cache' ),
107
  ),
108
  array(
109
  'label' => 'picture-in-picture',
110
+ 'description' => esc_html__( 'Controls whether the current document is allowed to play a video in a Picture-in-Picture mode via the corresponding API.', 'w3-total-cache' ),
111
  ),
112
  array(
113
  'label' => 'publickey-credentials-get',
114
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the Web Authentication API to retrieve already stored public-key credentials, i.e. via navigator.credentials.get({publicKey: ..., ...}).', 'w3-total-cache' ),
115
  ),
116
  array(
117
  'label' => 'screen-wake-lock',
118
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use Screen Wake Lock API to indicate that device should not turn off or dim the screen.', 'w3-total-cache' ),
119
  ),
120
  array(
121
  'label' => 'speaker',
122
+ 'description' => esc_html__( 'Controls whether the current document is allowed to play audio via any methods.', 'w3-total-cache' ),
123
  ),
124
  array(
125
  'label' => 'sync-xhr',
126
+ 'description' => esc_html__( 'Controls whether the current document is allowed to make synchronous XMLHttpRequest requests.', 'w3-total-cache' ),
127
  ),
128
  array(
129
  'label' => 'unoptimized-images',
130
+ 'description' => esc_html__( 'Controls whether the current document is allowed to download and display unoptimized images.', 'w3-total-cache' ),
131
  ),
132
  array(
133
  'label' => 'unsized-media',
134
+ 'description' => esc_html__( 'Controls whether the current document is allowed to change the size of media elements after the initial layout is complete.', 'w3-total-cache' ),
135
  ),
136
  array(
137
  'label' => 'usb',
138
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the WebUSB API.', 'w3-total-cache' ),
139
  ),
140
  array(
141
  'label' => 'vibrate',
142
+ 'description' => esc_html__( 'Controls whether the current document is allowed to trigger device vibrations via Navigator.vibrate() method of Vibration API.', 'w3-total-cache' ),
143
  ),
144
  array(
145
  'label' => 'vr',
146
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the WebVR API. When this policy is disabled, the Promise returned by Navigator.getVRDisplays() will reject with a DOMException. Keep in mind that the WebVR standard is in the process of being replaced with WebXR.', 'w3-total-cache' ),
147
  ),
148
  array(
149
  'label' => 'wake-lock',
150
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use Wake Lock API to indicate that device should not enter power-saving mode.', 'w3-total-cache' ),
151
  ),
152
  array(
153
  'label' => 'web-share',
154
+ 'description' => esc_html__( 'Controls whether or not the current document is allowed to use the Navigator.share() of Web Share API to share text, links, images, and other content to arbitrary destinations of user\'s choice, e.g. mobile apps.', 'w3-total-cache' ),
155
  ),
156
  array(
157
  'label' => 'xr-spatial-tracking',
158
+ 'description' => esc_html__( 'Controls whether the current document is allowed to use the WebXR Device API.', 'w3-total-cache' ),
159
  ),
160
  );
161
 
162
  ?>
163
 
164
+ <?php Util_Ui::postbox_header( esc_html__( 'Security Headers', 'w3-total-cache' ), '', 'security' ); ?>
165
+ <p>
166
+ <?php
167
+ echo wp_kses(
168
+ sprintf(
169
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
170
+ __(
171
+ '%1$sHTTP%2$s security headers provide another layer of protection for your website by helping to mitigate attacks and security vulnerabilities.',
172
+ 'w3-total-cache'
173
+ ),
174
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
175
+ '</acronym>'
176
+ ),
177
+ array(
178
+ 'acronym' => array(
179
+ 'title' => array(),
180
+ ),
181
+ )
182
+ );
183
+ ?>
184
+ </p>
185
+ <p><a onclick="w3tc_csp_reference()" href="javascript:void(0);"><?php esc_html_e( 'Quick Reference Chart', 'w3-total-cache' ); ?></a></p>
186
 
187
  <table class="form-table">
188
  <?php
191
  'key' => 'browsercache.security.session.use_only_cookies',
192
  'control' => 'selectbox',
193
  'selectbox_values' => $security_session_values,
194
+ 'description' => wp_kses(
195
+ sprintf(
196
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
197
+ __(
198
+ 'This setting prevents attacks that are caused by passing session IDs in %1$sURL%2$ss.',
199
+ 'w3-total-cache'
200
+ ),
201
+ '<acronym title="' . esc_attr__( 'Uniform Resource Locator', 'w3-total-cache' ) . '">',
202
+ '</acronym>'
203
+ ),
204
+ array(
205
+ 'acronym' => array(
206
+ 'title' => array(),
207
+ ),
208
+ )
209
+ ),
210
  )
211
  );
212
  ?>
216
  'key' => 'browsercache.security.session.cookie_httponly',
217
  'control' => 'selectbox',
218
  'selectbox_values' => $security_session_values,
219
+ 'description' => esc_html__( 'This tells the user\'s browser not to make the session cookie accessible to client side scripting such as JavaScript. This makes it harder for an attacker to hijack the session ID and masquerade as the effected user.', 'w3-total-cache' ),
220
  )
221
  );
222
  ?>
226
  'key' => 'browsercache.security.session.cookie_secure',
227
  'control' => 'selectbox',
228
  'selectbox_values' => $security_session_values,
229
+ 'description' => esc_html__( 'This will prevent the user\'s session ID from being transmitted in plain text, making it much harder to hijack the user\'s session.', 'w3-total-cache' ),
230
  )
231
  );
232
  ?>
233
  <tr>
234
  <th colspan="2">
235
  <?php $this->checkbox( 'browsercache.hsts' ); ?> <?php Util_Ui::e_config_label( 'browsercache.hsts' ); ?></label>
236
+ <p class="description">
237
+ <?php
238
+ echo wp_kses(
239
+ sprintf(
240
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acornym tag,
241
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acornym tag,
242
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acornym tag,
243
+ // translators: 7 opening HTML acronym tag, 8 closing HTML acornym tag,
244
+ // translators: 9 opening HTML acronym tag, 10 closing HTML acornym tag,
245
+ // translators: 11 opening HTML acronym tag, 12 closing HTML acornym tag.
246
+ __(
247
+ '%1$sHTTP%2$s Strict-Transport-Security (%3$sHSTS%4$s) enforces secure (%5$sHTTP%6$s over %7$sSSL%8$s/%9$sTLS%10$s) 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 %11$sSSL%12$s negotiation warnings then users will not be permitted to ignore them.',
248
+ 'w3-total-cache'
249
+ ),
250
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
251
+ '</acronym>',
252
+ '<acronym title="' . esc_attr__( 'HTTP Strict Transport Security', 'w3-total-cache' ) . '">',
253
+ '</acronym>',
254
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
255
+ '</acronym>',
256
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
257
+ '</acronym>',
258
+ '<acronym title="' . esc_attr__( 'Transport Layer Security', 'w3-total-cache' ) . '">',
259
+ '</acronym>',
260
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
261
+ '</acronym>'
262
+ ),
263
+ array(
264
+ 'acronym' => array(
265
+ 'title' => array(),
266
+ ),
267
+ )
268
+ );
269
+ ?>
270
+ </p>
271
  </th>
272
  </tr>
273
  <tr>
279
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
280
  name="browsercache__security__hsts__directive">
281
  <?php $value = $this->_config->get_string( 'browsercache.security.hsts.directive' ); ?>
282
+ <option value="maxage"<?php selected( $value, 'maxage' ); ?>><?php echo esc_html( 'max-age=EXPIRES_SECONDS' ); ?></option>
283
+ <option value="maxagepre"<?php selected( $value, 'maxagepre' ); ?>><?php echo esc_html( 'max-age=EXPIRES_SECONDS; preload' ); ?></option>
284
+ <option value="maxageinc"<?php selected( $value, 'maxageinc' ); ?>><?php echo esc_html( 'max-age=EXPIRES_SECONDS; includeSubDomains' ); ?></option>
285
+ <option value="maxageincpre"<?php selected( $value, 'maxageincpre' ); ?>><?php echo esc_html( 'max-age=EXPIRES_SECONDS; includeSubDomains; preload' ); ?></option>
286
  </select>
287
  <div id="browsercache_security_hsts_directive_description"></div>
288
  </td>
290
  <tr>
291
  <th colspan="2">
292
  <?php $this->checkbox( 'browsercache.security.xfo' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.xfo' ); ?></label>
293
+ <p class="description">
294
+ <?php esc_html_e( 'This tells the browser if it is permitted to render a page within a frame-like tag (i.e., &lt;frame&gt;, &lt;iframe&gt; or &lt;object&gt;). This is useful for preventing clickjacking attacks.', 'w3-total-cache' ); ?>
295
+ </p>
296
  </th>
297
  </tr>
298
  <tr>
304
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
305
  name="browsercache__security__xfo__directive">
306
  <?php $value = $this->_config->get_string( 'browsercache.security.xfo.directive' ); ?>
307
+ <option value="same"<?php selected( $value, 'same' ); ?>><?php echo esc_html( 'SameOrigin' ); ?></option>
308
+ <option value="deny"<?php selected( $value, 'deny' ); ?>><?php echo esc_html( 'Deny' ); ?></option>
309
+ <option value="allow"<?php selected( $value, 'allow' ); ?>><?php echo esc_html( 'Allow-From' ); ?></option>
310
  </select>
311
  <input id="browsercache_security_xfo_allow" type="text" name="browsercache__security__xfo__allow"
312
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.xfo.allow' ) ); ?>" size="50" placeholder="Enter URL" />
316
  <tr>
317
  <th colspan="2">
318
  <?php $this->checkbox( 'browsercache.security.xss' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.xss' ); ?></label>
319
+ <p class="description">
320
+ <?php
321
+ echo wp_kses(
322
+ sprintf(
323
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acornym tag.
324
+ __(
325
+ 'This header enables the %1$sXSS%2$s 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.',
326
+ 'w3-total-cache'
327
+ ),
328
+ '<acronym title="' . esc_attr__( 'Cross-Site Scripting', 'w3-total-cache' ) . '">',
329
+ '</acronym>'
330
+ ),
331
+ array(
332
+ 'acronym' => array(
333
+ 'title' => array(),
334
+ ),
335
+ )
336
+ );
337
+ ?>
338
+ </p>
339
  </th>
340
  </tr>
341
  <tr>
347
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
348
  name="browsercache__security__xss__directive">
349
  <?php $value = $this->_config->get_string( 'browsercache.security.xss.directive' ); ?>
350
+ <option value="0"<?php selected( $value, '0' ); ?>><?php echo esc_html( '0' ); ?></option>
351
+ <option value="1"<?php selected( $value, '1' ); ?>><?php echo esc_html( '1' ); ?></option>
352
+ <option value="block"<?php selected( $value, 'block' ); ?>><?php echo esc_html( '1; mode=block' ); ?></option>
353
  </select>
354
  <div id="browsercache_security_xss_directive_description"></div>
355
  </td>
357
  <tr>
358
  <th colspan="2">
359
  <?php $this->checkbox( 'browsercache.security.xcto' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.xcto' ); ?></label>
360
+ <p class="description">
361
+ <?php esc_html_e( 'This instructs the browser to not MIME-sniff a response outside its declared content-type. It helps to reduce drive-by download attacks and stops sites from serving malevolent content that could masquerade as an executable or dynamic HTML file.', 'w3-total-cache' ); ?>
362
+ </p>
363
  </th>
364
  </tr>
365
  <tr>
366
  <th colspan="2">
367
  <?php $this->checkbox( 'browsercache.security.pkp' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.pkp' ); ?></label>
368
+ <p class="description">
369
+ <?php
370
+ echo wp_kses(
371
+ sprintf(
372
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acornym tag,
373
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acornym tag,
374
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acornym tag.
375
+ __(
376
+ '%1$sHTTP%2$s Public Key Pinning (%3$sHPKP%4$s) is a security feature for %5$sHTTP%6$sS websites that can prevent fraudulently issued certificates from being used to impersonate existing secure websites.',
377
+ 'w3-total-cache'
378
+ ),
379
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
380
+ '</acronym>',
381
+ '<acronym title="' . esc_attr__( 'HTTP Public Key Pinning', 'w3-total-cache' ) . '">',
382
+ '</acronym>',
383
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
384
+ '</acronym>'
385
+ ),
386
+ array(
387
+ 'acronym' => array(
388
+ 'title' => array(),
389
+ ),
390
+ )
391
+ );
392
+ ?>
393
+ </p>
394
  </th>
395
  </tr>
396
  <tr>
400
  <td>
401
  <input id="browsercache_security_pkp_pin" type="text" name="browsercache__security__pkp__pin"
402
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.pkp.pin' ) ); ?>" size="50" placeholder="Enter the Base64-Encode of the SHA256 Hash" />
403
+ <div>
404
+ <i>
405
+ <?php
406
+ echo wp_kses(
407
+ sprintf(
408
+ // translators: 1 opening HTML b tag, 2 closing HTML b tag,
409
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acornym tag.
410
+ __(
411
+ 'This field is %1$srequired%2$s and represents a %3$sSPKI%4$s fingerprint. This pin is any public key within your current certificate chain.',
412
+ 'w3-total-cache'
413
+ ),
414
+ '<b>',
415
+ '</b>',
416
+ '<acronym title="' . esc_attr__( 'Subject Public Key Information', 'w3-total-cache' ) . '">',
417
+ '</acronym>'
418
+ ),
419
+ array(
420
+ 'b' => array(),
421
+ 'acronym' => array(
422
+ 'title' => array(),
423
+ ),
424
+ )
425
+ );
426
+ ?>
427
+ </i>
428
+ </div>
429
  </td>
430
  </tr>
431
  <tr>
435
  <td>
436
  <input id="browsercache_security_pkp_pin_backup" type="text" name="browsercache__security__pkp__pin__backup"
437
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.pkp.pin.backup' ) ); ?>" size="50" placeholder="Enter the Base64-Encode of the SHA256 Hash" />
438
+ <div>
439
+ <i>
440
+ <?php
441
+ echo wp_kses(
442
+ sprintf(
443
+ // translators: 1 opening HTML b tag, 2 closing HTML b tag,
444
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
445
+ __(
446
+ 'This field is %1$salso required%2$s and represents your backup %3$sSPKI%4$s fingerprint. This pin is any public key not in your current certificate chain and serves as a backup in case your certificate expires or has to be revoked.',
447
+ 'w3-total-cache'
448
+ ),
449
+ '<b>',
450
+ '</b>',
451
+ '<acronym title="' . esc_attr__( 'Subject Public Key Information', 'w3-total-cache' ) . '">',
452
+ '</acronym>'
453
+ ),
454
+ array(
455
+ 'b' => array(),
456
+ 'acronym' => array(
457
+ 'title' => array(),
458
+ ),
459
+ )
460
+ );
461
+ ?>
462
+ </i>
463
+ </div>
464
  </td>
465
  </tr>
466
  <tr>
472
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
473
  name="browsercache__security__pkp__extra">
474
  <?php $value = $this->_config->get_string( 'browsercache.security.pkp.extra' ); ?>
475
+ <option value="maxage"<?php selected( $value, 'maxage' ); ?>><?php echo esc_html( 'max-age=EXPIRES_SECONDS' ); ?></option>
476
+ <option value="maxageinc"<?php selected( $value, 'maxageinc' ); ?>><?php echo esc_html( 'max-age=EXPIRES_SECONDS; includeSubDomains' ); ?></option>
477
  </select>
478
  <div id="browsercache_security_pkp_extra_description"></div>
479
  </td>
485
  <td>
486
  <input id="browsercache_security_pkp_report_url" type="text" name="browsercache__security__pkp__report__url"
487
  <?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" />
488
+ <div>
489
+ <i>
490
+ <?php
491
+ echo wp_kses(
492
+ sprintf(
493
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
494
+ __(
495
+ 'This optional field can be used to specify a %1$sURL%2$s that clients will send reports to if pin validation failures occur. The report is sent as a POST request with a JSON body.',
496
+ 'w3-total-cache'
497
+ ),
498
+ '<acronym title="' . esc_attr__( 'Uniform Resource Locator', 'w3-total-cache' ) . '">',
499
+ '</acronym>'
500
+ ),
501
+ array(
502
+ 'acronym' => array(
503
+ 'title' => array(),
504
+ ),
505
+ )
506
+ );
507
+ ?>
508
+ </i>
509
+ </div>
510
  </td>
511
  </tr>
512
  <tr>
518
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
519
  name="browsercache__security__pkp__report__only">
520
  <?php $value = $this->_config->get_string( 'browsercache.security.pkp.report.only' ); ?>
521
+ <option value="0"<?php selected( $value, '0' ); ?>><?php esc_html_e( 'No = Enforce HPKP', 'w3-total-cache' ); ?></option>
522
+ <option value="1"<?php selected( $value, '1' ); ?>><?php esc_html_e( 'Yes = Don\'t Enforce HPKP', 'w3-total-cache' ); ?></option>
523
  </select>
524
  <div id="browsercache_security_pkp_report_only_description"></div>
525
  </td>
527
  <tr>
528
  <th colspan="2">
529
  <?php $this->checkbox( 'browsercache.security.referrer.policy' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.referrer.policy' ); ?></label>
530
+ <p class="description">
531
+ <?php esc_html_e( 'This header restricts the values of the referer header in outbound links.', 'w3-total-cache' ); ?>
532
+ </p>
533
  </th>
534
  </tr>
535
  <tr>
541
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?>
542
  name="browsercache__security__referrer__policy__directive">
543
  <?php $value = $this->_config->get_string( 'browsercache.security.referrer.policy.directive' ); ?>
544
+ <option value="0"<?php selected( $value, '0' ); ?>><?php esc_html_e( 'Not Set', 'w3-total-cache' ); ?></option>
545
+ <option value="no-referrer"<?php selected( $value, 'no-referrer' ); ?>><?php echo esc_html( 'no-referrer' ); ?></option>
546
+ <option value="no-referrer-when-downgrade"<?php selected( $value, 'no-referrer-when-downgrade' ); ?>><?php echo esc_html( 'no-referrer-when-downgrade' ); ?></option>
547
+ <option value="same-origin"<?php selected( $value, 'same-origin' ); ?>><?php echo esc_html( 'same-origin' ); ?></option>
548
+ <option value="origin"<?php selected( $value, 'origin' ); ?>><?php echo esc_html( 'origin' ); ?></option>
549
+ <option value="strict-origin"<?php selected( $value, 'strict-origin' ); ?>><?php echo esc_html( 'strict-origin' ); ?></option>
550
+ <option value="origin-when-cross-origin"<?php selected( $value, 'origin-when-cross-origin' ); ?>><?php echo esc_html( 'origin-when-cross-origin' ); ?></option>
551
+ <option value="strict-origin-when-cross-origin"<?php selected( $value, 'strict-origin-when-cross-origin' ); ?>><?php echo esc_html( 'strict-origin-when-cross-origin' ); ?></option>
552
+ <option value="unsafe-url"<?php selected( $value, 'unsafe-url' ); ?>><?php echo esc_html( 'unsafe-url' ); ?></option>
553
  </select>
554
  <div id="browsercache_security_referrer_policy_directive_description"></div>
555
  </td>
557
  <tr>
558
  <th colspan="2">
559
  <?php $this->checkbox( 'browsercache.security.csp' ); ?> <?php Util_Ui::e_config_label( 'browsercache.security.csp' ); ?></label>
560
+ <p class="description">
561
+ <?php
562
+ echo wp_kses(
563
+ sprintf(
564
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
565
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
566
+ __(
567
+ 'The Content Security Policy (%1$sCSP%2$s) header reduces the risk of %3$sXSS%4$s 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.',
568
+ 'w3-total-cache'
569
+ ),
570
+ '<acronym title="' . esc_attr__( 'Content Security Policy', 'w3-total-cache' ) . '">',
571
+ '</acronym>',
572
+ '<acronym title="' . esc_attr__( 'Cross-Site Scripting', 'w3-total-cache' ) . '">',
573
+ '</acronym>'
574
+ ),
575
+ array(
576
+ 'acronym' => array(
577
+ 'title' => array(),
578
+ ),
579
+ )
580
+ );
581
+ ?>
582
+ </p>
583
  </th>
584
  </tr>
585
  <tr>
589
  <td>
590
  <input id="browsercache_security_csp_base" type="text" name="browsercache__security__csp__base"
591
  <?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" />
592
+ <div>
593
+ <i>
594
+ <?php
595
+ echo wp_kses(
596
+ sprintf(
597
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
598
+ __(
599
+ 'Restricts the %1$sURL%2$ss which can be used in a document\'s &lt;base&gt; element.',
600
+ 'w3-total-cache'
601
+ ),
602
+ '<acronym title="' . esc_attr__( 'Uniform Resource Locator', 'w3-total-cache' ) . '">',
603
+ '</acronym>'
604
+ ),
605
+ array(
606
+ 'acronym' => array(
607
+ 'title' => array(),
608
+ ),
609
+ )
610
+ );
611
+ ?>
612
+ </i>
613
+ </div>
614
  </td>
615
  </tr>
616
  <tr>
620
  <td>
621
  <input id="browsercache_security_csp_connect" type="text" name="browsercache__security__csp__connect"
622
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.connect' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
623
+ <div><i><?php esc_html_e( 'Limits the origins to which you can connect via XMLHttpRequest, WebSockets, and EventSource.', 'w3-total-cache' ); ?></i></div>
624
  </td>
625
  </tr>
626
  <tr>
630
  <td>
631
  <input id="browsercache_security_csp_font" type="text" name="browsercache__security__csp__font"
632
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.font' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
633
+ <div><i><?php esc_html_e( 'Specifies the origins that can serve web fonts.', 'w3-total-cache' ); ?></i></div>
634
  </td>
635
  </tr>
636
  <tr>
640
  <td>
641
  <input id="browsercache_security_csp_frame" type="text" name="browsercache__security__csp__frame"
642
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.frame' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
643
+ <div><i><?php esc_html_e( 'Restricts from where the protected resource can embed frames.', 'w3-total-cache' ); ?></i></div>
644
  </td>
645
  </tr>
646
  <tr>
650
  <td>
651
  <input id="browsercache_security_csp_img" type="text" name="browsercache__security__csp__img"
652
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.img' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
653
+ <div><i><?php esc_html_e( 'Specifies valid sources for images and favicons.', 'w3-total-cache' ); ?></i></div>
654
  </td>
655
  </tr>
656
  <tr>
660
  <td>
661
  <input id="browsercache_security_csp_media" type="text" name="browsercache__security__csp__media"
662
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.media' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
663
+ <div><i><?php esc_html_e( 'Specifies valid sources for loading media using the &lt;audio&gt; and &lt;video&gt; elements.', 'w3-total-cache' ); ?></i></div>
664
  </td>
665
  </tr>
666
  <tr>
670
  <td>
671
  <input id="browsercache_security_csp_object" type="text" name="browsercache__security__csp__object"
672
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.object' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
673
+ <div><i><?php esc_html_e( 'Allows control over the &lt;object&gt;, &lt;embed&gt;, and &lt;applet&gt; elements used by Flash and other plugins.', 'w3-total-cache' ); ?></i></div>
674
  </td>
675
  </tr>
676
  <tr>
680
  <td>
681
  <input id="browsercache_security_csp_script" type="text" name="browsercache__security__csp__script"
682
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.script' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
683
+ <div><i><?php esc_html_e( 'Specifies valid sources for JavaScript.', 'w3-total-cache' ); ?></i></div>
684
  </td>
685
  </tr>
686
  <tr>
690
  <td>
691
  <input id="browsercache_security_csp_style" type="text" name="browsercache__security__csp__style"
692
  <?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" />
693
+ <div>
694
+ <i>
695
+ <?php
696
+ echo wp_kses(
697
+ sprintf(
698
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
699
+ __(
700
+ 'Specifies valid sources for %1$sCSS%2$s stylesheets.',
701
+ 'w3-total-cache'
702
+ ),
703
+ '<acronym title="' . esc_attr__( 'Cascading Style Sheet', 'w3-total-cache' ) . '">',
704
+ '</acronym>'
705
+ ),
706
+ array(
707
+ 'acronym' => array(
708
+ 'title' => array(),
709
+ ),
710
+ )
711
+ );
712
+ ?>
713
+ </i>
714
+ </div>
715
  </td>
716
  </tr>
717
  <tr>
721
  <td>
722
  <input id="browsercache_security_csp_form" type="text" name="browsercache__security__csp__form"
723
  <?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" />
724
+ <div>
725
+ <i>
726
+ <?php
727
+ echo wp_kses(
728
+ sprintf(
729
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
730
+ __(
731
+ 'Restricts the %1$sURL%2$ss which can be used as the target of form submissions from a given context.',
732
+ 'w3-total-cache'
733
+ ),
734
+ '<acronym title="' . esc_attr__( 'Uniform Resource Locator', 'w3-total-cache' ) . '">',
735
+ '</acronym>'
736
+ ),
737
+ array(
738
+ 'acronym' => array(
739
+ 'title' => array(),
740
+ ),
741
+ )
742
+ );
743
+ ?>
744
+ </i>
745
+ </div>
746
  </td>
747
  </tr>
748
  <tr>
752
  <td>
753
  <input id="browsercache_security_csp_frame_ancestors" type="text" name="browsercache__security__csp__frame__ancestors"
754
  <?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'" />
755
+ <div><i><?php esc_html_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;.', 'w3-total-cache' ); ?></i></div>
756
  </td>
757
  </tr>
758
  <tr>
762
  <td>
763
  <input id="browsercache_security_csp_plugin" type="text" name="browsercache__security__csp__plugin"
764
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.plugin' ) ); ?>" size="50" placeholder="Example: application/x-shockwave-flash" />
765
+ <div><i><?php esc_html_e( 'Restricts the set of plugins that can be embedded into a document by limiting the types of resources which can be loaded.', 'w3-total-cache' ); ?></i></div>
766
  </td>
767
  </tr>
768
  <tr>
772
  <td>
773
  <input id="browsercache_security_csp_sandbox" type="text" name="browsercache__security__csp__sandbox"
774
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.sandbox' ) ); ?>" size="50" placeholder="Example: allow-popups" />
775
+ <div><i><?php esc_html_e( 'This directive operates similarly to the &lt;iframe&gt; sandbox attribute by applying restrictions to a page\'s actions, including preventing popups, preventing the execution of plugins and scripts, and enforcing a same-origin policy.', 'w3-total-cache' ); ?></i></div>
776
  </td>
777
  </tr>
778
  <tr>
782
  <td>
783
  <input id="browsercache_security_csp_default" type="text" name="browsercache__security__csp__default"
784
  <?php Util_Ui::sealing_disabled( 'browsercache.' ); ?> value="<?php echo esc_attr( $this->_config->get_string( 'browsercache.security.csp.default' ) ); ?>" size="50" placeholder="Example: 'self' 'unsafe-inline' *.domain.com" />
785
+ <div><i><?php esc_html_e( 'Defines the defaults for directives you leave unspecified. Generally, this applies to any directive that ends with -src.', 'w3-total-cache' ); ?></i></div>
786
  </td>
787
  </tr>
788
  <?php
791
  'key' => 'browsercache.security.fp',
792
  'disabled' => Util_Ui::sealing_disabled( 'browsercache.' ),
793
  'control' => 'checkbox',
794
+ 'checkbox_label' => esc_html__( 'Feature-Policy', 'w3-total-cache' ),
795
+ 'description' => esc_html__( 'Allows you to control which origins can use which features.', 'w3-total-cache' ),
796
  'label_class' => 'w3tc_single_column',
797
  )
798
  );
808
  'control' => 'textbox',
809
  'label' => $i['label'],
810
  'textbox_size' => '50',
811
+ 'textbox_placeholder' => esc_html__( 'One of:', 'w3-total-cache' ) . esc_html( " * 'self' 'src' 'none' *.domain.com" ),
812
  'description' => $i['description'],
813
  )
814
  );
BrowserCache_Plugin.php CHANGED
@@ -143,8 +143,8 @@ class BrowserCache_Plugin {
143
  /**
144
  * Check User Agent
145
  */
146
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
147
- stristr( $_SERVER['HTTP_USER_AGENT'], W3TC_POWERED_BY ) !== false ) {
148
  return false;
149
  }
150
 
143
  /**
144
  * Check User Agent
145
  */
146
+ $http_user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '';
147
+ if ( stristr( $http_user_agent, W3TC_POWERED_BY ) !== false ) {
148
  return false;
149
  }
150
 
BrowserCache_Plugin_Admin.php CHANGED
@@ -24,7 +24,7 @@ class BrowserCache_Plugin_Admin {
24
  $fp_values = array();
25
 
26
  foreach ( $_REQUEST as $key => $value ) {
27
- $value = stripslashes( $value ); // wp core add slashes
28
  if ( substr( $key, 0, $prefixl ) == $prefix ) {
29
  $k = substr( $key, $prefixl );
30
  if ( !empty( $value ) ) {
24
  $fp_values = array();
25
 
26
  foreach ( $_REQUEST as $key => $value ) {
27
+ $value = Util_Request::get_string( $key );
28
  if ( substr( $key, 0, $prefixl ) == $prefix ) {
29
  $k = substr( $key, $prefixl );
30
  if ( !empty( $value ) ) {
Cache.php CHANGED
@@ -71,7 +71,7 @@ class Cache {
71
  break;
72
 
73
  default:
74
- trigger_error( 'Incorrect cache engine ' . $engine, E_USER_WARNING );
75
  $instances[$instance_key] = new Cache_Base( $config );
76
  break;
77
  }
71
  break;
72
 
73
  default:
74
+ trigger_error( 'Incorrect cache engine ' . esc_html( $engine ), E_USER_WARNING );
75
  $instances[$instance_key] = new Cache_Base( $config );
76
  break;
77
  }
CacheGroups_Plugin_Admin_View.php CHANGED
@@ -32,7 +32,7 @@ if ( ! defined( 'W3TC' ) ) {
32
  /*]]>*/</script>
33
 
34
  <div class="metabox-holder">
35
- <?php Util_Ui::postbox_header( __( 'Manage User Agent Groups', 'w3-total-cache' ), '', 'manage-uag' ); ?>
36
  <p>
37
  <input id="mobile_add" type="button" class="button"
38
  <?php disabled( $useragent_groups['disabled'] ); ?>
@@ -81,7 +81,7 @@ if ( ! defined( 'W3TC' ) ) {
81
  <select id="mobile_groups_<?php echo esc_attr( $group ); ?>_theme"
82
  name="mobile_groups[<?php echo esc_attr( $group ); ?>][theme]"
83
  <?php disabled( $useragent_groups['disabled'] ); ?> >
84
- <option value="">-- Pass-through --</option>
85
  <?php foreach ( $useragent_themes as $theme_key => $theme_name ) : ?>
86
  <option value="<?php echo esc_attr( $theme_key ); ?>"<?php selected( $theme_key, $group_config['theme'] ); ?>><?php echo esc_html( $theme_name ); ?></option>
87
  <?php endforeach; ?>
@@ -159,7 +159,7 @@ if ( ! defined( 'W3TC' ) ) {
159
  /*]]>*/</script>
160
 
161
  <div class="metabox-holder">
162
- <?php Util_Ui::postbox_header( __( 'Manage Referrer Groups', 'w3-total-cache' ), '', 'manage-rg' ); ?>
163
  <p>
164
  <input id="referrer_add" type="button" class="button" value="<?php esc_html_e( 'Create a group', 'w3-total-cache' ); ?>" /> <?php esc_html_e( 'of referrers by specifying names in the referrers field. Assign a set of referrers to use a specific theme, redirect them to another domain, create referrer groups to ensure that a unique cache is created for each referrer group. Drag and drop groups into order (if needed) to determine their priority (top -&gt; down).', 'w3-total-cache' ); ?>
165
  </p>
@@ -235,7 +235,7 @@ if ( ! defined( 'W3TC' ) ) {
235
  <!-- Cookie Groups -->
236
 
237
  <div class="metabox-holder">
238
- <?php Util_Ui::postbox_header( __( 'Manage Cookie Groups', 'w3-total-cache' ), '', 'manage-cg' ); ?>
239
  <p>
240
  <input id="w3tc_cookiegroup_add" type="button" class="button"
241
  <?php disabled( $cookie_groups['disabled'] ); ?>
32
  /*]]>*/</script>
33
 
34
  <div class="metabox-holder">
35
+ <?php Util_Ui::postbox_header( esc_html__( 'Manage User Agent Groups', 'w3-total-cache' ), '', 'manage-uag' ); ?>
36
  <p>
37
  <input id="mobile_add" type="button" class="button"
38
  <?php disabled( $useragent_groups['disabled'] ); ?>
81
  <select id="mobile_groups_<?php echo esc_attr( $group ); ?>_theme"
82
  name="mobile_groups[<?php echo esc_attr( $group ); ?>][theme]"
83
  <?php disabled( $useragent_groups['disabled'] ); ?> >
84
+ <option value=""><?php esc_html_e( '-- Pass-through --', 'w3-total-cache' ); ?></option>
85
  <?php foreach ( $useragent_themes as $theme_key => $theme_name ) : ?>
86
  <option value="<?php echo esc_attr( $theme_key ); ?>"<?php selected( $theme_key, $group_config['theme'] ); ?>><?php echo esc_html( $theme_name ); ?></option>
87
  <?php endforeach; ?>
159
  /*]]>*/</script>
160
 
161
  <div class="metabox-holder">
162
+ <?php Util_Ui::postbox_header( esc_html__( 'Manage Referrer Groups', 'w3-total-cache' ), '', 'manage-rg' ); ?>
163
  <p>
164
  <input id="referrer_add" type="button" class="button" value="<?php esc_html_e( 'Create a group', 'w3-total-cache' ); ?>" /> <?php esc_html_e( 'of referrers by specifying names in the referrers field. Assign a set of referrers to use a specific theme, redirect them to another domain, create referrer groups to ensure that a unique cache is created for each referrer group. Drag and drop groups into order (if needed) to determine their priority (top -&gt; down).', 'w3-total-cache' ); ?>
165
  </p>
235
  <!-- Cookie Groups -->
236
 
237
  <div class="metabox-holder">
238
+ <?php Util_Ui::postbox_header( esc_html__( 'Manage Cookie Groups', 'w3-total-cache' ), '', 'manage-cg' ); ?>
239
  <p>
240
  <input id="w3tc_cookiegroup_add" type="button" class="button"
241
  <?php disabled( $cookie_groups['disabled'] ); ?>
Cache_Redis.php CHANGED
@@ -1,67 +1,142 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  namespace W3TC;
3
 
4
  /**
5
- * Redis cache engine
6
  */
7
  class Cache_Redis extends Cache_Base {
 
 
 
 
 
8
  private $_accessors = array();
 
 
 
 
 
 
9
  private $_key_version = array();
10
 
 
 
 
 
 
11
  private $_persistent;
 
 
 
 
 
 
12
  private $_password;
 
 
 
 
 
 
13
  private $_servers;
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  private $_dbid;
15
 
16
  /**
17
- * constructor
18
  *
19
- * @param array $config
20
  */
21
- function __construct( $config ) {
22
- parent::__construct( $config );
 
 
 
 
 
 
23
 
24
- $this->_persistent = ( isset( $config['persistent'] ) && $config['persistent'] );
25
- $this->_servers = (array)$config['servers'];
26
- $this->_password = $config['password'];
27
- $this->_dbid = $config['dbid'];
 
 
 
 
 
 
 
 
 
 
28
 
29
- // when disabled - no extra requests are made to obtain key version,
30
- // but flush operations not supported as a result
31
- // group should be always empty
32
- if ( isset( $config['key_version_mode'] ) &&
33
- $config['key_version_mode'] == 'disabled' ) {
 
 
 
 
 
 
 
 
 
34
  $this->_key_version[''] = 1;
35
  }
36
  }
37
 
38
  /**
39
- * Adds data
40
  *
41
- * @param string $key
42
- * @param mixed $var
43
- * @param integer $expire
44
- * @param string $group Used to differentiate between groups of cache values
45
- * @return boolean
46
  */
47
- function add( $key, &$var, $expire = 0, $group = '' ) {
48
  return $this->set( $key, $var, $expire, $group );
49
  }
50
 
51
  /**
52
- * Sets data
53
  *
54
- * @param string $key
55
- * @param mixed $var
56
- * @param integer $expire
57
- * @param string $group Used to differentiate between groups of cache values
58
- * @return boolean
59
  */
60
- function set( $key, $value, $expire = 0, $group = '' ) {
61
  $value['key_version'] = $this->_get_key_version( $group );
62
 
63
  $storage_key = $this->get_item_key( $key );
64
- $accessor = $this->_get_accessor( $storage_key );
 
65
  if ( is_null( $accessor ) ) {
66
  return false;
67
  }
@@ -76,27 +151,29 @@ class Cache_Redis extends Cache_Base {
76
  /**
77
  * Returns data
78
  *
79
- * @param string $key
80
- * @param string $group Used to differentiate between groups of cache values
81
  * @return mixed
82
  */
83
- function get_with_old( $key, $group = '' ) {
84
  $has_old_data = false;
85
 
86
  $storage_key = $this->get_item_key( $key );
87
- $accessor = $this->_get_accessor( $storage_key );
88
- if ( is_null( $accessor ) )
 
89
  return array( null, false );
 
90
 
91
  $v = $accessor->get( $storage_key );
92
  $v = @unserialize( $v );
93
 
94
- if ( !is_array( $v ) || !isset( $v['key_version'] ) ) {
95
  return array( null, $has_old_data );
96
  }
97
 
98
  $key_version = $this->_get_key_version( $group );
99
- if ( $v['key_version'] == $key_version ) {
100
  return array( $v, $has_old_data );
101
  }
102
 
@@ -105,14 +182,15 @@ class Cache_Redis extends Cache_Base {
105
  return array( $v, $has_old_data );
106
  }
107
 
108
- // key version is old
109
- if ( !$this->_use_expired_data )
110
  return array( null, $has_old_data );
 
111
 
112
- // if we have expired data - update it for future use and let
113
- // current process recalculate it
114
  $expires_at = isset( $v['expires_at'] ) ? $v['expires_at'] : null;
115
- if ( $expires_at == null || time() > $expires_at ) {
 
116
  $v['expires_at'] = time() + 30;
117
  $accessor->setex( $storage_key, 60, serialize( $v ) );
118
  $has_old_data = true;
@@ -120,39 +198,42 @@ class Cache_Redis extends Cache_Base {
120
  return array( null, $has_old_data );
121
  }
122
 
123
- // return old version
124
  return array( $v, $has_old_data );
125
  }
126
 
127
  /**
128
- * Replaces data
129
  *
130
- * @param string $key
131
- * @param mixed $var
132
- * @param integer $expire
133
- * @param string $group Used to differentiate between groups of cache values
134
- * @return boolean
135
  */
136
- function replace( $key, &$var, $expire = 0, $group = '' ) {
137
- return $this->set( $key, $var, $expire, $group );
138
  }
139
 
140
  /**
141
- * Deletes data
142
  *
143
- * @param string $key
144
- * @param string $group
145
- * @return boolean
146
  */
147
- function delete( $key, $group = '' ) {
148
  $storage_key = $this->get_item_key( $key );
149
- $accessor = $this->_get_accessor( $storage_key );
150
- if ( is_null( $accessor ) )
 
151
  return false;
 
152
 
153
  if ( $this->_use_expired_data ) {
154
- $v = $accessor->get( $storage_key );
155
  $ttl = $accessor->ttl( $storage_key );
 
156
  if ( is_array( $v ) ) {
157
  $v['key_version'] = 0;
158
  $accessor->setex( $storage_key, $ttl, $v );
@@ -166,36 +247,39 @@ class Cache_Redis extends Cache_Base {
166
  /**
167
  * Key to delete, deletes _old and primary if exists.
168
  *
169
- * @param unknown $key
 
170
  * @return bool
171
  */
172
- function hard_delete( $key, $group = '' ) {
173
  $storage_key = $this->get_item_key( $key );
174
- $accessor = $this->_get_accessor( $storage_key );
175
- if ( is_null( $accessor ) )
 
176
  return false;
 
177
 
178
  return $accessor->setex( $storage_key, 1, '' );
179
  }
180
 
181
  /**
182
- * Flushes all data
183
  *
184
- * @param string $group Used to differentiate between groups of cache values
185
- * @return boolean
186
  */
187
- function flush( $group = '' ) {
188
- $this->_get_key_version( $group ); // initialize $this->_key_version
189
- if (isset($this->_key_version[$group])) {
190
- $this->_key_version[$group]++;
191
- $this->_set_key_version( $this->_key_version[$group], $group );
192
  }
193
 
194
  return true;
195
  }
196
 
197
  /**
198
- * Checks if engine can function properly in this environment
199
  *
200
  * @return bool
201
  */
@@ -203,10 +287,17 @@ class Cache_Redis extends Cache_Base {
203
  return class_exists( 'Redis' );
204
  }
205
 
 
 
 
 
 
206
  public function get_statistics() {
207
- $accessor = $this->_get_accessor( '' ); // single-server mode used for stats
208
- if ( is_null( $accessor ) )
 
209
  return array();
 
210
 
211
  $a = $accessor->info();
212
 
@@ -214,170 +305,278 @@ class Cache_Redis extends Cache_Base {
214
  }
215
 
216
  /**
217
- * Returns key version
218
  *
219
- * @param string $group Used to differentiate between groups of cache values
220
- * @return integer
221
  */
222
  private function _get_key_version( $group = '' ) {
223
- if ( !isset( $this->_key_version[$group] ) || $this->_key_version[$group] <= 0 ) {
224
  $storage_key = $this->_get_key_version_key( $group );
225
- $accessor = $this->_get_accessor( $storage_key );
226
- if ( is_null( $accessor ) )
 
227
  return 0;
 
228
 
229
  $v_original = $accessor->get( $storage_key );
230
- $v = intval( $v_original );
231
- $v = ( $v > 0 ? $v : 1 );
232
 
233
- if ( (string)$v_original !== (string)$v ) {
234
  $accessor->set( $storage_key, $v );
235
  }
236
 
237
- $this->_key_version[$group] = $v;
238
  }
239
 
240
- return $this->_key_version[$group];
241
  }
242
 
243
  /**
244
- * Sets new key version
245
  *
246
- * @param unknown $v
247
- * @param string $group Used to differentiate between groups of cache values
248
- * @return boolean
249
  */
250
  private function _set_key_version( $v, $group = '' ) {
251
  $storage_key = $this->_get_key_version_key( $group );
252
- $accessor = $this->_get_accessor( $storage_key );
253
- if ( is_null( $accessor ) )
 
254
  return false;
 
255
 
256
  $accessor->set( $storage_key, $v );
 
257
  return true;
258
  }
259
 
260
  /**
261
- * Used to replace as atomically as possible known value to new one
 
 
 
 
262
  */
263
  public function set_if_maybe_equals( $key, $old_value, $new_value ) {
264
  $storage_key = $this->get_item_key( $key );
265
- $accessor = $this->_get_accessor( $storage_key );
266
- if ( is_null( $accessor ) )
 
267
  return false;
 
268
 
269
  $accessor->watch( $storage_key );
270
 
271
  $value = $accessor->get( $storage_key );
272
  $value = @unserialize( $value );
273
 
274
- if ( !is_array( $value ) ) {
275
  $accessor->unwatch();
276
  return false;
277
  }
278
 
279
- if ( isset( $old_value['content'] ) &&
280
- $value['content'] != $old_value['content'] ) {
281
  $accessor->unwatch();
282
  return false;
283
  }
284
 
285
- return $ret = $accessor->multi()
286
- ->set( $storage_key, $new_value )
287
- ->exec();
288
  }
289
 
290
  /**
291
- * Use key as a counter and add integet value to it
 
 
 
292
  */
293
  public function counter_add( $key, $value ) {
294
- if ( $value == 0 )
295
  return true;
 
296
 
297
  $storage_key = $this->get_item_key( $key );
298
- $accessor = $this->_get_accessor( $storage_key );
299
- if ( is_null( $accessor ) )
 
300
  return false;
 
301
 
302
  $r = $accessor->incrBy( $storage_key, $value );
303
- if ( !$r ) // it doesnt initialize counter by itself
 
304
  $this->counter_set( $key, 0 );
 
305
 
306
  return $r;
307
  }
308
 
309
  /**
310
- * Use key as a counter and add integet value to it
 
 
 
311
  */
312
  public function counter_set( $key, $value ) {
313
  $storage_key = $this->get_item_key( $key );
314
- $accessor = $this->_get_accessor( $storage_key );
315
- if ( is_null( $accessor ) )
 
316
  return false;
 
317
 
318
  return $accessor->set( $storage_key, $value );
319
  }
320
 
321
  /**
322
- * Get counter's value
 
 
323
  */
324
  public function counter_get( $key ) {
325
  $storage_key = $this->get_item_key( $key );
326
- $accessor = $this->_get_accessor( $storage_key );
327
- if ( is_null( $accessor ) )
 
328
  return 0;
 
329
 
330
- $v = (int)$accessor->get( $storage_key );
331
 
332
  return $v;
333
  }
334
 
 
 
 
 
 
 
335
  private function _get_accessor( $key ) {
336
- if ( count( $this->_servers ) <= 1 )
337
  $index = 0;
338
- else {
339
  $index = crc32( $key ) % count( $this->_servers );
340
  }
341
 
342
- if ( isset( $this->_accessors[$index] ) )
343
- return $this->_accessors[$index];
 
344
 
345
- if ( !isset( $this->_servers[$index] ) )
346
- $this->_accessors[$index] = null;
347
- else {
348
  try {
349
- $server = $this->_servers[$index];
350
  $accessor = new \Redis();
351
 
352
- if ( substr( $server, 0, 5 ) == 'unix:' ) {
353
  if ( $this->_persistent ) {
354
- $accessor->pconnect( trim( substr( $server, 5 ) ),
355
- null, null, $this->_instance_id . '_' . $this->_dbid );
 
 
 
 
 
 
356
  } else {
357
- $accessor->connect( trim( substr( $server, 5 ) ) );
 
 
 
 
 
 
358
  }
359
  } else {
360
  list( $ip, $port ) = Util_Content::endpoint_to_host_port( $server, null );
361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  if ( $this->_persistent ) {
363
- $accessor->pconnect( $ip, $port,
364
- null, $this->_instance_id . '_' . $this->_dbid );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  } else {
366
- $accessor->connect( $ip, $port );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  }
 
 
368
  }
369
 
370
- if ( !empty( $this->_password ) )
371
  $accessor->auth( $this->_password );
 
 
372
  $accessor->select( $this->_dbid );
373
  } catch ( \Exception $e ) {
374
- error_log( $e->getMessage() );
375
  $accessor = null;
376
  }
377
 
378
- $this->_accessors[$index] = $accessor;
379
  }
380
 
381
- return $this->_accessors[$index];
382
  }
383
  }
1
  <?php
2
+ /**
3
+ * File: Cache_Redis.php
4
+ *
5
+ * @package W3TC
6
+ *
7
+ * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore,PSR2.Classes.PropertyDeclaration.Underscore,WordPress.PHP.DiscouragedPHPFunctions,WordPress.PHP.NoSilencedErrors
8
+ */
9
+
10
  namespace W3TC;
11
 
12
  /**
13
+ * Redis cache engine.
14
  */
15
  class Cache_Redis extends Cache_Base {
16
+ /**
17
+ * Accessors.
18
+ *
19
+ * @var array
20
+ */
21
  private $_accessors = array();
22
+
23
+ /**
24
+ * Key value.
25
+ *
26
+ * @var array
27
+ */
28
  private $_key_version = array();
29
 
30
+ /**
31
+ * Persistent.
32
+ *
33
+ * @var bool
34
+ */
35
  private $_persistent;
36
+
37
+ /**
38
+ * Password.
39
+ *
40
+ * @var string
41
+ */
42
  private $_password;
43
+
44
+ /**
45
+ * Servers.
46
+ *
47
+ * @var array
48
+ */
49
  private $_servers;
50
+
51
+ /**
52
+ * Verify TLS certificate.
53
+ *
54
+ * @var bool
55
+ */
56
+ private $_verify_tls_certificates;
57
+
58
+ /**
59
+ * DB id.
60
+ *
61
+ * @var string
62
+ */
63
  private $_dbid;
64
 
65
  /**
66
+ * Timeout.
67
  *
68
+ * @var int.
69
  */
70
+ private $_timeout;
71
+
72
+ /**
73
+ * Retry interval.
74
+ *
75
+ * @var int
76
+ */
77
+ private $_retry_interval;
78
 
79
+ /**
80
+ * Retry timeout.
81
+ *
82
+ * @var int
83
+ */
84
+ private $_read_timeout;
85
+
86
+ /**
87
+ * Constructor.
88
+ *
89
+ * @param array $config Config.
90
+ */
91
+ public function __construct( $config ) {
92
+ parent::__construct( $config );
93
 
94
+ $this->_persistent = ( isset( $config['persistent'] ) && $config['persistent'] );
95
+ $this->_servers = (array) $config['servers'];
96
+ $this->_verify_tls_certificates = ( isset( $config['verify_tls_certificates'] ) && $config['verify_tls_certificates'] );
97
+ $this->_password = $config['password'];
98
+ $this->_dbid = $config['dbid'];
99
+ $this->_timeout = $config['timeout'];
100
+ $this->_retry_interval = $config['retry_interval'];
101
+ $this->_read_timeout = $config['read_timeout'];
102
+
103
+ /**
104
+ * When disabled - no extra requests are made to obtain key version,
105
+ * but flush operations not supported as a result group should be always empty.
106
+ */
107
+ if ( isset( $config['key_version_mode'] ) && 'disabled' === $config['key_version_mode'] ) {
108
  $this->_key_version[''] = 1;
109
  }
110
  }
111
 
112
  /**
113
+ * Adds data.
114
  *
115
+ * @param string $key Key.
116
+ * @param mixed $var Var.
117
+ * @param integer $expire Expire.
118
+ * @param string $group Used to differentiate between groups of cache values.
119
+ * @return bool
120
  */
121
+ public function add( $key, &$var, $expire = 0, $group = '' ) {
122
  return $this->set( $key, $var, $expire, $group );
123
  }
124
 
125
  /**
126
+ * Sets data.
127
  *
128
+ * @param string $key Key.
129
+ * @param mixed $value Value.
130
+ * @param integer $expire Expire.
131
+ * @param string $group Used to differentiate between groups of cache values.
132
+ * @return bool
133
  */
134
+ public function set( $key, $value, $expire = 0, $group = '' ) {
135
  $value['key_version'] = $this->_get_key_version( $group );
136
 
137
  $storage_key = $this->get_item_key( $key );
138
+ $accessor = $this->_get_accessor( $storage_key );
139
+
140
  if ( is_null( $accessor ) ) {
141
  return false;
142
  }
151
  /**
152
  * Returns data
153
  *
154
+ * @param string $key Key.
155
+ * @param string $group Used to differentiate between groups of cache values.
156
  * @return mixed
157
  */
158
+ public function get_with_old( $key, $group = '' ) {
159
  $has_old_data = false;
160
 
161
  $storage_key = $this->get_item_key( $key );
162
+ $accessor = $this->_get_accessor( $storage_key );
163
+
164
+ if ( is_null( $accessor ) ) {
165
  return array( null, false );
166
+ }
167
 
168
  $v = $accessor->get( $storage_key );
169
  $v = @unserialize( $v );
170
 
171
+ if ( ! is_array( $v ) || ! isset( $v['key_version'] ) ) {
172
  return array( null, $has_old_data );
173
  }
174
 
175
  $key_version = $this->_get_key_version( $group );
176
+ if ( $v['key_version'] === $key_version ) {
177
  return array( $v, $has_old_data );
178
  }
179
 
182
  return array( $v, $has_old_data );
183
  }
184
 
185
+ // Key version is old.
186
+ if ( ! $this->_use_expired_data ) {
187
  return array( null, $has_old_data );
188
+ }
189
 
190
+ // If we have expired data - update it for future use and let current process recalculate it.
 
191
  $expires_at = isset( $v['expires_at'] ) ? $v['expires_at'] : null;
192
+
193
+ if ( is_null( $expires_at ) || time() > $expires_at ) {
194
  $v['expires_at'] = time() + 30;
195
  $accessor->setex( $storage_key, 60, serialize( $v ) );
196
  $has_old_data = true;
198
  return array( null, $has_old_data );
199
  }
200
 
201
+ // Return old version.
202
  return array( $v, $has_old_data );
203
  }
204
 
205
  /**
206
+ * Replaces data.
207
  *
208
+ * @param string $key Key.
209
+ * @param mixed $value Value.
210
+ * @param integer $expire Expire.
211
+ * @param string $group Used to differentiate between groups of cache values.
212
+ * @return bool
213
  */
214
+ public function replace( $key, &$value, $expire = 0, $group = '' ) {
215
+ return $this->set( $key, $value, $expire, $group );
216
  }
217
 
218
  /**
219
+ * Deletes data.
220
  *
221
+ * @param string $key Key.
222
+ * @param string $group Group.
223
+ * @return bool
224
  */
225
+ public function delete( $key, $group = '' ) {
226
  $storage_key = $this->get_item_key( $key );
227
+ $accessor = $this->_get_accessor( $storage_key );
228
+
229
+ if ( is_null( $accessor ) ) {
230
  return false;
231
+ }
232
 
233
  if ( $this->_use_expired_data ) {
234
+ $v = $accessor->get( $storage_key );
235
  $ttl = $accessor->ttl( $storage_key );
236
+
237
  if ( is_array( $v ) ) {
238
  $v['key_version'] = 0;
239
  $accessor->setex( $storage_key, $ttl, $v );
247
  /**
248
  * Key to delete, deletes _old and primary if exists.
249
  *
250
+ * @param string $key Key.
251
+ * @param string $group Group.
252
  * @return bool
253
  */
254
+ public function hard_delete( $key, $group = '' ) {
255
  $storage_key = $this->get_item_key( $key );
256
+ $accessor = $this->_get_accessor( $storage_key );
257
+
258
+ if ( is_null( $accessor ) ) {
259
  return false;
260
+ }
261
 
262
  return $accessor->setex( $storage_key, 1, '' );
263
  }
264
 
265
  /**
266
+ * Flushes all data.
267
  *
268
+ * @param string $group Used to differentiate between groups of cache values.
269
+ * @return bool
270
  */
271
+ public function flush( $group = '' ) {
272
+ $this->_get_key_version( $group ); // Initialize $this->_key_version.
273
+ if ( isset( $this->_key_version[ $group ] ) ) {
274
+ $this->_key_version[ $group ]++;
275
+ $this->_set_key_version( $this->_key_version[ $group ], $group );
276
  }
277
 
278
  return true;
279
  }
280
 
281
  /**
282
+ * Checks if engine can function properly in this environment.
283
  *
284
  * @return bool
285
  */
287
  return class_exists( 'Redis' );
288
  }
289
 
290
+ /**
291
+ * Get statistics.
292
+ *
293
+ * @return array
294
+ */
295
  public function get_statistics() {
296
+ $accessor = $this->_get_accessor( '' ); // Single-server mode used for stats.
297
+
298
+ if ( is_null( $accessor ) ) {
299
  return array();
300
+ }
301
 
302
  $a = $accessor->info();
303
 
305
  }
306
 
307
  /**
308
+ * Returns key version.
309
  *
310
+ * @param string $group Used to differentiate between groups of cache values.
311
+ * @return int
312
  */
313
  private function _get_key_version( $group = '' ) {
314
+ if ( ! isset( $this->_key_version[ $group ] ) || $this->_key_version[ $group ] <= 0 ) {
315
  $storage_key = $this->_get_key_version_key( $group );
316
+ $accessor = $this->_get_accessor( $storage_key );
317
+
318
+ if ( is_null( $accessor ) ) {
319
  return 0;
320
+ }
321
 
322
  $v_original = $accessor->get( $storage_key );
323
+ $v = intval( $v_original );
324
+ $v = ( $v > 0 ? $v : 1 );
325
 
326
+ if ( (string) $v_original !== (string) $v ) {
327
  $accessor->set( $storage_key, $v );
328
  }
329
 
330
+ $this->_key_version[ $group ] = $v;
331
  }
332
 
333
+ return $this->_key_version[ $group ];
334
  }
335
 
336
  /**
337
+ * Sets new key version.
338
  *
339
+ * @param string $v Version.
340
+ * @param string $group Used to differentiate between groups of cache values.
341
+ * @return bool
342
  */
343
  private function _set_key_version( $v, $group = '' ) {
344
  $storage_key = $this->_get_key_version_key( $group );
345
+ $accessor = $this->_get_accessor( $storage_key );
346
+
347
+ if ( is_null( $accessor ) ) {
348
  return false;
349
+ }
350
 
351
  $accessor->set( $storage_key, $v );
352
+
353
  return true;
354
  }
355
 
356
  /**
357
+ * Used to replace as atomically as possible known value to new one.
358
+ *
359
+ * @param string $key Key.
360
+ * @param string $old_value Old value.
361
+ * @param string $new_value New value.
362
  */
363
  public function set_if_maybe_equals( $key, $old_value, $new_value ) {
364
  $storage_key = $this->get_item_key( $key );
365
+ $accessor = $this->_get_accessor( $storage_key );
366
+
367
+ if ( is_null( $accessor ) ) {
368
  return false;
369
+ }
370
 
371
  $accessor->watch( $storage_key );
372
 
373
  $value = $accessor->get( $storage_key );
374
  $value = @unserialize( $value );
375
 
376
+ if ( ! is_array( $value ) ) {
377
  $accessor->unwatch();
378
  return false;
379
  }
380
 
381
+ if ( isset( $old_value['content'] ) && $value['content'] !== $old_value['content'] ) {
 
382
  $accessor->unwatch();
383
  return false;
384
  }
385
 
386
+ return $accessor->multi()
387
+ ->set( $storage_key, $new_value )
388
+ ->exec();
389
  }
390
 
391
  /**
392
+ * Use key as a counter and add integet value to it.
393
+ *
394
+ * @param string $key Key.
395
+ * @param int $value Value.
396
  */
397
  public function counter_add( $key, $value ) {
398
+ if ( empty( $value ) ) {
399
  return true;
400
+ }
401
 
402
  $storage_key = $this->get_item_key( $key );
403
+ $accessor = $this->_get_accessor( $storage_key );
404
+
405
+ if ( is_null( $accessor ) ) {
406
  return false;
407
+ }
408
 
409
  $r = $accessor->incrBy( $storage_key, $value );
410
+
411
+ if ( ! $r ) { // It doesn't initialize counter by itself.
412
  $this->counter_set( $key, 0 );
413
+ }
414
 
415
  return $r;
416
  }
417
 
418
  /**
419
+ * Use key as a counter and add integet value to it.
420
+ *
421
+ * @param string $key Key.
422
+ * @param int $value Value.
423
  */
424
  public function counter_set( $key, $value ) {
425
  $storage_key = $this->get_item_key( $key );
426
+ $accessor = $this->_get_accessor( $storage_key );
427
+
428
+ if ( is_null( $accessor ) ) {
429
  return false;
430
+ }
431
 
432
  return $accessor->set( $storage_key, $value );
433
  }
434
 
435
  /**
436
+ * Get counter's value.
437
+ *
438
+ * @param string $key Key.
439
  */
440
  public function counter_get( $key ) {
441
  $storage_key = $this->get_item_key( $key );
442
+ $accessor = $this->_get_accessor( $storage_key );
443
+
444
+ if ( is_null( $accessor ) ) {
445
  return 0;
446
+ }
447
 
448
+ $v = (int) $accessor->get( $storage_key );
449
 
450
  return $v;
451
  }
452
 
453
+ /**
454
+ * Get accessor.
455
+ *
456
+ * @param string $key Key.
457
+ * @return object
458
+ */
459
  private function _get_accessor( $key ) {
460
+ if ( count( $this->_servers ) <= 1 ) {
461
  $index = 0;
462
+ } else {
463
  $index = crc32( $key ) % count( $this->_servers );
464
  }
465
 
466
+ if ( isset( $this->_accessors[ $index ] ) ) {
467
+ return $this->_accessors[ $index ];
468
+ }
469
 
470
+ if ( ! isset( $this->_servers[ $index ] ) ) {
471
+ $this->_accessors[ $index ] = null;
472
+ } else {
473
  try {
474
+ $server = $this->_servers[ $index ];
475
  $accessor = new \Redis();
476
 
477
+ if ( substr( $server, 0, 5 ) === 'unix:' ) {
478
  if ( $this->_persistent ) {
479
+ $accessor->pconnect(
480
+ trim( substr( $server, 5 ) ),
481
+ null,
482
+ $this->_timeout,
483
+ $this->_instance_id . '_' . $this->_dbid,
484
+ $this->_retry_interval,
485
+ $this->_read_timeout
486
+ );
487
  } else {
488
+ $accessor->connect(
489
+ trim( substr( $server, 5 ) ),
490
+ $this->_timeout,
491
+ null,
492
+ $this->_retry_interval,
493
+ $this->_read_timeout
494
+ );
495
  }
496
  } else {
497
  list( $ip, $port ) = Util_Content::endpoint_to_host_port( $server, null );
498
 
499
+ $context = array();
500
+
501
+ if ( substr( $server, 0, 4 ) === 'tls:' && ! $this->_verify_tls_certificates ) {
502
+ $context['stream'] = array(
503
+ 'verify_peer' => false,
504
+ 'verify_peer_name' => false,
505
+ );
506
+ }
507
+
508
+ // Catch PHP errors.
509
+ set_error_handler( // phpcs:ignore
510
+ function( $errno, $errstr, $errfile, $errline ) {
511
+ // Error was suppressed with the @-operator.
512
+ if ( 0 === error_reporting() ) { // phpcs:ignore
513
+ return false;
514
+ }
515
+
516
+ throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
517
+ }
518
+ );
519
+
520
  if ( $this->_persistent ) {
521
+ try {
522
+ $accessor->pconnect(
523
+ $ip,
524
+ $port,
525
+ $this->_timeout,
526
+ $this->_instance_id . '_' . $this->_dbid,
527
+ $this->_retry_interval,
528
+ $this->_read_timeout,
529
+ $context
530
+ );
531
+ } catch ( \ErrorException $e ) {
532
+ $accessor->pconnect(
533
+ $ip,
534
+ $port,
535
+ $this->_timeout,
536
+ $this->_instance_id . '_' . $this->_dbid,
537
+ $this->_retry_interval,
538
+ $this->_read_timeout
539
+ );
540
+ }
541
  } else {
542
+ try {
543
+ $accessor->connect(
544
+ $ip,
545
+ $port,
546
+ $this->_timeout,
547
+ null,
548
+ $this->_retry_interval,
549
+ $this->_read_timeout,
550
+ $context
551
+ );
552
+ } catch ( \ErrorException $e ) {
553
+ $accessor->connect(
554
+ $ip,
555
+ $port,
556
+ $this->_timeout,
557
+ null,
558
+ $this->_retry_interval,
559
+ $this->_read_timeout
560
+ );
561
+ }
562
  }
563
+
564
+ restore_error_handler();
565
  }
566
 
567
+ if ( ! empty( $this->_password ) ) {
568
  $accessor->auth( $this->_password );
569
+ }
570
+
571
  $accessor->select( $this->_dbid );
572
  } catch ( \Exception $e ) {
573
+ error_log( $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
574
  $accessor = null;
575
  }
576
 
577
+ $this->_accessors[ $index ] = $accessor;
578
  }
579
 
580
+ return $this->_accessors[ $index ];
581
  }
582
  }
CdnEngine_Base.php CHANGED
@@ -240,10 +240,7 @@ class CdnEngine_Base {
240
  function format_url( $path ) {
241
  $url = $this->_format_url( $path );
242
 
243
- if ( $url && $this->_config['compression'] &&
244
- isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) &&
245
- stristr( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) !== false &&
246
- $this->_may_gzip( $path ) ) {
247
  if ( ( $qpos = strpos( $url, '?' ) ) !== false ) {
248
  $url = substr_replace( $url, $this->_gzip_extension, $qpos, 0 );
249
  } else {
240
  function format_url( $path ) {
241
  $url = $this->_format_url( $path );
242
 
243
+ if ( $url && $this->_config['compression'] && ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ? stristr( sanitize_text_field( wp_unslash( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ), 'gzip' ) !== false : false ) && $this->_may_gzip( $path ) ) {
 
 
 
244
  if ( ( $qpos = strpos( $url, '?' ) ) !== false ) {
245
  $url = substr_replace( $url, $this->_gzip_extension, $qpos, 0 );
246
  } else {
CdnEngine_CloudFront.php CHANGED
@@ -147,7 +147,12 @@ class CdnEngine_CloudFront extends CdnEngine_Base {
147
  * Returns origin
148
  */
149
  function _get_origin() {
150
- return sprintf( '%s.s3.amazonaws.com', $this->_config['bucket'] );
 
 
 
 
 
151
  }
152
 
153
  /**
147
  * Returns origin
148
  */
149
  function _get_origin() {
150
+ if ( $this->_config['bucket_location'] === 'us-east-1' ) {
151
+ $region = "";
152
+ } else {
153
+ $region = $this->_config['bucket_location'] . '.';
154
+ }
155
+ return sprintf( '%s.s3.%samazonaws.com', $this->_config['bucket'], $region );
156
  }
157
 
158
  /**
CdnEngine_Ftp.php CHANGED
@@ -42,9 +42,10 @@ class CdnEngine_Ftp extends CdnEngine_Base {
42
  $config['host'] = $ip;
43
  $config['port'] = $port;
44
 
45
- if ( $config['type'] == 'sftp' && $config['default_keys'] ) {
46
- $config['pubkey'] = $_SERVER['HOME'] . '/.ssh/id_rsa.pub';
47
- $config['privkey'] = $_SERVER['HOME'] . '/.ssh/id_rsa';
 
48
  }
49
 
50
  parent::__construct( $config );
42
  $config['host'] = $ip;
43
  $config['port'] = $port;
44
 
45
+ if ( 'sftp' === $config['type'] && $config['default_keys'] ) {
46
+ $home = isset( $_SERVER['HOME'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HOME'] ) ) : '';
47
+ $config['pubkey'] = $home . '/.ssh/id_rsa.pub';
48
+ $config['privkey'] = $home . '/.ssh/id_rsa';
49
  }
50
 
51
  parent::__construct( $config );
CdnEngine_Mirror_CloudFront.php CHANGED
@@ -110,7 +110,7 @@ class CdnEngine_Mirror_CloudFront extends CdnEngine_Mirror {
110
  * @return bool
111
  */
112
  function purge_all( &$results ) {
113
- return $this->purge( array( 'remote_path' => '*' ), $results );
114
  }
115
 
116
  /**
110
  * @return bool
111
  */
112
  function purge_all( &$results ) {
113
+ return $this->purge( array( array( 'remote_path' => '*' ) ), $results );
114
  }
115
 
116
  /**
CdnEngine_S3.php CHANGED
@@ -108,6 +108,10 @@ class CdnEngine_S3 extends CdnEngine_Base {
108
  $this->_config['secret'] );
109
  }
110
 
 
 
 
 
111
  $this->api = new \Aws\S3\S3Client( array(
112
  'credentials' => $credentials,
113
  'region' => $this->_config['bucket_location'],
@@ -286,7 +290,10 @@ class CdnEngine_S3 extends CdnEngine_Base {
286
  * Wrapper to set headers well
287
  */
288
  private function _put_object( $data, $headers ) {
289
- $data['ACL'] = 'public-read';
 
 
 
290
  $data['Bucket'] = $this->_config['bucket'];
291
 
292
  $data['ContentType'] = $headers['Content-Type'];
@@ -381,16 +388,33 @@ class CdnEngine_S3 extends CdnEngine_Base {
381
  }
382
 
383
  if ( !$bucket_found ) {
384
- throw new \Exception( 'Bucket doesn\'t exist: %s.', $this->_config['bucket'] );
 
 
 
 
 
 
385
  }
386
 
387
- $result = $this->api->putObject( array(
388
- 'ACL' => 'public-read',
389
- 'Bucket' => $this->_config['bucket'],
390
- 'Key' => $key,
391
- 'Body' => $key
392
- )
393
- );
 
 
 
 
 
 
 
 
 
 
 
394
 
395
  $object = $this->api->getObject( array(
396
  'Bucket' => $this->_config['bucket'],
108
  $this->_config['secret'] );
109
  }
110
 
111
+ if ( isset( $this->_config['public_objects'] ) && 'enabled' === $this->_config['public_objects'] ) {
112
+ $this->_config['s3_acl'] = 'public-read';
113
+ }
114
+
115
  $this->api = new \Aws\S3\S3Client( array(
116
  'credentials' => $credentials,
117
  'region' => $this->_config['bucket_location'],
290
  * Wrapper to set headers well
291
  */
292
  private function _put_object( $data, $headers ) {
293
+ if ( ! empty( $this->_config['s3_acl'] ) ) {
294
+ $data['ACL'] = 'public-read';
295
+ }
296
+
297
  $data['Bucket'] = $this->_config['bucket'];
298
 
299
  $data['ContentType'] = $headers['Content-Type'];
388
  }
389
 
390
  if ( !$bucket_found ) {
391
+ throw new \Exception(
392
+ sprintf(
393
+ // translators: 1: AWS S3 bucket name.
394
+ esc_html__( 'Bucket doesn\'t exist: %1$s.', 'w3-total-cache' ),
395
+ $this->_config['bucket']
396
+ )
397
+ );
398
  }
399
 
400
+ if ( ! empty( $this->_config['s3_acl'] ) ) {
401
+ $result = $this->api->putObject(
402
+ array(
403
+ 'ACL' => $this->_config['s3_acl'],
404
+ 'Bucket' => $this->_config['bucket'],
405
+ 'Key' => $key,
406
+ 'Body' => $key
407
+ )
408
+ );
409
+ } else {
410
+ $result = $this->api->putObject(
411
+ array(
412
+ 'Bucket' => $this->_config['bucket'],
413
+ 'Key' => $key,
414
+ 'Body' => $key
415
+ )
416
+ );
417
+ }
418
 
419
  $object = $this->api->getObject( array(
420
  'Bucket' => $this->_config['bucket'],
Cdn_AdminNotes.php CHANGED
@@ -115,7 +115,7 @@ class Cdn_AdminNotes {
115
  $notes[] = sprintf(
116
  __( 'Make sure to whitelist your servers IPs. Follow the instructions on %s. The IP for this server is %s. %s', 'w3-total-cache' ),
117
  '<a href="http://support.maxcdn.com/tutorials/how-to-whitelist-your-server-ip-to-use-the-api/">MaxCDN</a>',
118
- $_SERVER['SERVER_ADDR'],
119
  Util_Ui::button_hide_note2( array(
120
  'w3tc_default_config_state' => 'y',
121
  'key' => 'cdn.hide_note_maxcdn_whitelist_ip',
115
  $notes[] = sprintf(
116
  __( 'Make sure to whitelist your servers IPs. Follow the instructions on %s. The IP for this server is %s. %s', 'w3-total-cache' ),
117
  '<a href="http://support.maxcdn.com/tutorials/how-to-whitelist-your-server-ip-to-use-the-api/">MaxCDN</a>',
118
+ isset( $_SERVER['SERVER_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) : '',
119
  Util_Ui::button_hide_note2( array(
120
  'w3tc_default_config_state' => 'y',
121
  'key' => 'cdn.hide_note_maxcdn_whitelist_ip',
Cdn_Core.php CHANGED
@@ -397,6 +397,7 @@ class Cdn_Core {
397
  'id' => $c->get_string( 'cdn.cf.id' ),
398
  'cname' => $c->get_array( 'cdn.cf.cname' ),
399
  'ssl' => $c->get_string( 'cdn.cf.ssl' ),
 
400
  'compression' => $compression
401
  );
402
  break;
397
  'id' => $c->get_string( 'cdn.cf.id' ),
398
  'cname' => $c->get_array( 'cdn.cf.cname' ),
399
  'ssl' => $c->get_string( 'cdn.cf.ssl' ),
400
+ 'public_objects' => $c->get_string( 'cdn.cf.public_objects' ),
401
  'compression' => $compression
402
  );
403
  break;
Cdn_GeneralPage_View.php CHANGED
@@ -1,48 +1,150 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- Util_Ui::postbox_header( __( '<acronym title="Content Delivery Network">CDN</acronym>', 'w3-total-cache' ), '', 'cdn' );
8
- Util_Ui::config_overloading_button( array(
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">
18
- <?php
19
- 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 quickly for site visitors.',
24
- 'w3-total-cache' )
25
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- Util_Ui::config_item( array(
28
- 'key' => 'cdn.engine',
29
- 'control' => 'selectbox',
30
- 'selectbox_values' => $engine_values,
31
- 'selectbox_optgroups' => $engine_optgroups,
32
- 'description' => __( 'Select the <acronym title="Content Delivery Network">CDN</acronym> type you wish to use.',
33
- 'w3-total-cache' )
34
- ) );
35
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  </table>
37
 
38
  <?php
39
  do_action( 'w3tc_settings_general_boxarea_cdn_footer' );
40
 
41
- Util_Ui::button_config_save( 'general_cdn',
42
- '<input id="cdn_purge" type="button" value="'.
43
- __( 'Empty cache', 'w3-total-cache' ) . '" ' .
44
- ( $cdn_enabled && Cdn_Util::can_purge_all( $config->get_string( 'cdn.engine' ) ) ? '' :
45
- ' disabled="disabled" ' ) .
46
- ' class="button {nonce: \'' . wp_create_nonce( 'w3tc' ) . '\'}" />' );
47
  ?>
48
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ Util_Ui::postbox_header(
9
+ wp_kses(
10
+ sprintf(
11
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
12
+ __(
13
+ '%1$sCDN%2$s',
14
+ 'w3-total-cache'
15
+ ),
16
+ '<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">',
17
+ '</acronym>'
18
+ ),
19
+ array(
20
+ 'acronym' => array(
21
+ 'title' => array(),
22
+ ),
23
+ )
24
+ ),
25
+ '',
26
+ 'cdn'
27
+ );
28
+ Util_Ui::config_overloading_button(
29
+ array(
30
+ 'key' => 'cdn.configuration_overloaded',
31
+ )
32
+ );
33
  ?>
34
+ <p>
35
+ <?php
36
+ w3tc_e(
37
+ 'cdn.general.header',
38
+ wp_kses(
39
+ sprintf(
40
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
41
+ __(
42
+ 'Host static files with your %1$sCDN%2$s to reduce page load time.',
43
+ 'w3-total-cache'
44
+ ),
45
+ '<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">',
46
+ '</acronym>'
47
+ ),
48
+ array(
49
+ 'acronym' => array(
50
+ 'title' => array(),
51
+ ),
52
+ )
53
+ )
54
+ );
55
+ ?>
56
+ <?php if ( ! $cdn_enabled ) : ?>
57
+ <?php
58
+ echo wp_kses(
59
+ sprintf(
60
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
61
+ // translators: 3 opening HTML a tag, 4 closing HTML a tag.
62
+ __(
63
+ 'If you do not have a %1$sCDN%2$s provider try StackPath. %3$sSign up now to enjoy a special offer!%4$s.',
64
+ 'w3-total-cache'
65
+ ),
66
+ '<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">',
67
+ '</acronym>',
68
+ '<a href="' . esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ) . '" target="_blank">',
69
+ '</a>'
70
+ ),
71
+ array(
72
+ 'acronym' => array(
73
+ 'title' => array(),
74
+ ),
75
+ 'a' => array(
76
+ 'href' => array(),
77
+ 'target' => array(),
78
+ ),
79
+ )
80
+ );
81
+ ?>
82
+ <?php endif; ?>
83
  </p>
84
  <table class="form-table">
85
+ <?php
86
+ Util_Ui::config_item(
87
+ array(
88
+ 'key' => 'cdn.enabled',
89
+ 'control' => 'checkbox',
90
+ 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
91
+ 'description' => wp_kses(
92
+ sprintf(
93
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
94
+ // translators: 3 opening HTML acronym tag, 4 closing acronym tag.
95
+ __(
96
+ 'Theme files, media library attachments, %1$sCSS%2$s, %3$sJS%4$s files etc will quickly for site visitors.',
97
+ 'w3-total-cache'
98
+ ),
99
+ '<acronym title="' . __( 'Cascading Style Sheet', 'w3-total-cache' ) . '">',
100
+ '</acronym>',
101
+ '<acronym title="' . __( 'JavaScript', 'w3-total-cache' ) . '">',
102
+ '</acronym>'
103
+ ),
104
+ array(
105
+ 'acronym' => array(
106
+ 'title' => array(),
107
+ ),
108
+ )
109
+ ),
110
+ )
111
+ );
112
 
113
+ Util_Ui::config_item(
114
+ array(
115
+ 'key' => 'cdn.engine',
116
+ 'control' => 'selectbox',
117
+ 'selectbox_values' => $engine_values,
118
+ 'selectbox_optgroups' => $engine_optgroups,
119
+ 'description' => wp_kses(
120
+ sprintf(
121
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
122
+ __(
123
+ 'Select the %1$sCDN%2$s type you wish to use.',
124
+ 'w3-total-cache'
125
+ ),
126
+ '<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">',
127
+ '</acronym>'
128
+ ),
129
+ array(
130
+ 'acronym' => array(
131
+ 'title' => array(),
132
+ ),
133
+ )
134
+ ),
135
+ )
136
+ );
137
+ ?>
138
  </table>
139
 
140
  <?php
141
  do_action( 'w3tc_settings_general_boxarea_cdn_footer' );
142
 
143
+ Util_Ui::button_config_save(
144
+ 'general_cdn',
145
+ '<input id="cdn_purge" type="button" value="' . __( 'Empty cache', 'w3-total-cache' ) .
146
+ '" ' . ( $cdn_enabled && Cdn_Util::can_purge_all( $config->get_string( 'cdn.engine' ) ) ? '' : ' disabled="disabled" ' ) .
147
+ ' class="button {nonce: \'' . wp_create_nonce( 'w3tc' ) . '\'}" />'
148
+ );
149
  ?>
150
  <?php Util_Ui::postbox_footer(); ?>
Cdn_GoogleDrive_AdminActions.php CHANGED
@@ -22,9 +22,9 @@ class Cdn_GoogleDrive_AdminActions {
22
 
23
  function w3tc_cdn_google_drive_auth_set() {
24
  // thanks wp core for wp_magic_quotes hell
25
- $client_id = stripslashes( $_POST['client_id'] );
26
- $access_token = stripslashes( $_POST['access_token'] );
27
- $refresh_token = stripslashes( $_POST['refresh_token'] );
28
 
29
  $client = new \W3TCG_Google_Client();
30
  $client->setClientId( $client_id );
@@ -35,15 +35,15 @@ class Cdn_GoogleDrive_AdminActions {
35
  //
36
  $service = new \W3TCG_Google_Service_Drive( $client );
37
 
38
- if ( empty( $_POST['folder'] ) ) {
39
  $file = new \W3TCG_Google_Service_Drive_DriveFile( array(
40
- 'title' => $_POST['folder_new'],
41
  'mimeType' => 'application/vnd.google-apps.folder' ) );
42
 
43
  $created_file = $service->files->insert( $file );
44
  $used_folder_id = $created_file->id;
45
  } else {
46
- $used_folder_id = $_POST['folder'];
47
  }
48
 
49
  $permission = new \W3TCG_Google_Service_Drive_Permission();
22
 
23
  function w3tc_cdn_google_drive_auth_set() {
24
  // thanks wp core for wp_magic_quotes hell
25
+ $client_id = Util_Request::get_string( 'client_id' );
26
+ $access_token = Util_Request::get_string( 'access_token' );
27
+ $refresh_token = Util_Request::get_string( 'refresh_token' );
28
 
29
  $client = new \W3TCG_Google_Client();
30
  $client->setClientId( $client_id );
35
  //
36
  $service = new \W3TCG_Google_Service_Drive( $client );
37
 
38
+ if ( empty( Util_Request::get_string( 'folder' ) ) ) {
39
  $file = new \W3TCG_Google_Service_Drive_DriveFile( array(
40
+ 'title' => Util_Request::get_string( 'folder_new' ),
41
  'mimeType' => 'application/vnd.google-apps.folder' ) );
42
 
43
  $created_file = $service->files->insert( $file );
44
  $used_folder_id = $created_file->id;
45
  } else {
46
+ $used_folder_id = Util_Request::get_string( 'folder' );
47
  }
48
 
49
  $permission = new \W3TCG_Google_Service_Drive_Permission();
Cdn_GoogleDrive_Page.php CHANGED
@@ -1,29 +1,47 @@
1
  <?php
 
 
 
 
 
 
2
  namespace W3TC;
3
 
 
 
 
4
  class Cdn_GoogleDrive_Page {
5
- // called from plugin-admin.
6
- static public function admin_print_scripts_w3tc_cdn() {
7
- wp_enqueue_script( 'w3tc_cdn_google_drive',
 
 
 
 
 
8
  plugins_url( 'Cdn_GoogleDrive_Page_View.js', W3TC_FILE ),
9
- array( 'jquery' ), '1.0' );
 
 
 
10
 
11
- $path = 'admin.php?page=w3tc_cdn';
12
  $return_url = self_admin_url( $path );
13
 
14
  wp_localize_script(
15
  'w3tc_cdn_google_drive',
16
  'w3tc_cdn_google_drive_url',
17
- array( W3TC_GOOGLE_DRIVE_AUTHORIZE_URL . '?return_url=' . urlencode( $return_url ) )
18
  );
19
 
20
- // it's return from google oauth
21
- if ( isset( $_GET['oa_client_id'] ) ) {
22
  $path = wp_nonce_url( 'admin.php', 'w3tc' ) .
23
  '&page=w3tc_cdn&w3tc_cdn_google_drive_auth_return';
24
- foreach ( $_GET as $key => $value ) {
25
- if ( substr( $key, 0, 3 ) == 'oa_' )
26
- $path .= '&' . urlencode( $key ) . '=' . urlencode( $value );
 
27
  }
28
 
29
  $popup_url = self_admin_url( $path );
@@ -37,8 +55,11 @@ class Cdn_GoogleDrive_Page {
37
  }
38
  }
39
 
 
 
 
40
  public static function w3tc_settings_cdn_boxarea_configuration() {
41
  $config = Dispatcher::config();
42
- include W3TC_DIR . '/Cdn_GoogleDrive_Page_View.php';
43
  }
44
  }
1
  <?php
2
+ /**
3
+ * File: Cdn_GoogleDrive_Page.php
4
+ *
5
+ * @package W3TC
6
+ */
7
+
8
  namespace W3TC;
9
 
10
+ /**
11
+ * Class: Cdn_GoogleDrive_Page
12
+ */
13
  class Cdn_GoogleDrive_Page {
14
+ /**
15
+ * Print scripts.
16
+ *
17
+ * Called from plugin-admin.
18
+ */
19
+ public static function admin_print_scripts_w3tc_cdn() {
20
+ wp_enqueue_script(
21
+ 'w3tc_cdn_google_drive',
22
  plugins_url( 'Cdn_GoogleDrive_Page_View.js', W3TC_FILE ),
23
+ array( 'jquery' ),
24
+ '1.0',
25
+ false
26
+ );
27
 
28
+ $path = 'admin.php?page=w3tc_cdn';
29
  $return_url = self_admin_url( $path );
30
 
31
  wp_localize_script(
32
  'w3tc_cdn_google_drive',
33
  'w3tc_cdn_google_drive_url',
34
+ array( W3TC_GOOGLE_DRIVE_AUTHORIZE_URL . '?return_url=' . rawurlencode( $return_url ) )
35
  );
36
 
37
+ // it's return from google oauth.
38
+ if ( ! empty( Util_Request::get_string( 'oa_client_id' ) ) ) {
39
  $path = wp_nonce_url( 'admin.php', 'w3tc' ) .
40
  '&page=w3tc_cdn&w3tc_cdn_google_drive_auth_return';
41
+ foreach ( $_GET as $key => $value ) { // phpcs:ignore
42
+ if ( substr( $key, 0, 3 ) === 'oa_' ) {
43
+ $path .= '&' . rawurlencode( $key ) . '=' . rawurlencode( Util_Request::get_string( $key ) );
44
+ }
45
  }
46
 
47
  $popup_url = self_admin_url( $path );
55
  }
56
  }
57
 
58
+ /**
59
+ * Load view.
60
+ */
61
  public static function w3tc_settings_cdn_boxarea_configuration() {
62
  $config = Dispatcher::config();
63
+ require W3TC_DIR . '/Cdn_GoogleDrive_Page_View.php';
64
  }
65
  }
Cdn_GoogleDrive_Page_View.php CHANGED
@@ -1,39 +1,40 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
  $refresh_token = $config->get_string( 'cdn.google_drive.refresh_token' );
8
 
9
  ?>
10
  <tr>
11
- <th style="width: 300px;"><label><?php _e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
12
  <td>
13
- <?php if ( empty( $refresh_token ) ): ?>
14
  <input class="w3tc_cdn_google_drive_authorize button" type="button"
15
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>" />
16
- <?php else: ?>
17
  <input class="w3tc_cdn_google_drive_authorize button" type="button"
18
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>" />
19
  <?php endif ?>
20
  </td>
21
  </tr>
22
 
23
- <?php if ( !empty( $refresh_token ) ): ?>
24
- <tr>
25
- <th><label for="cdn_s3_bucket"><?php _e( 'Folder:', 'w3-total-cache' ); ?></label></th>
26
- <td>
27
- <a href="<?php echo $config->get_string( 'cdn.google_drive.folder.url' ) ?>">/<?php echo $config->get_string( 'cdn.google_drive.folder.title' ) ?></a>
28
- </td>
29
- </tr>
30
- <tr>
31
- <th colspan="2">
32
- <input id="cdn_test"
33
- class="button {type: 'google_drive', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
34
- type="button"
35
- value="<?php _e( 'Test upload', 'w3-total-cache' ); ?>" />
36
- <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
37
- </th>
38
- </tr>
39
  <?php endif ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
  $refresh_token = $config->get_string( 'cdn.google_drive.refresh_token' );
9
 
10
  ?>
11
  <tr>
12
+ <th style="width: 300px;"><label><?php esc_html_e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
13
  <td>
14
+ <?php if ( empty( $refresh_token ) ) : ?>
15
  <input class="w3tc_cdn_google_drive_authorize button" type="button"
16
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
17
+ <?php else : ?>
18
  <input class="w3tc_cdn_google_drive_authorize button" type="button"
19
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
20
  <?php endif ?>
21
  </td>
22
  </tr>
23
 
24
+ <?php if ( ! empty( $refresh_token ) ) : ?>
25
+ <tr>
26
+ <th><label for="cdn_s3_bucket"><?php esc_html_e( 'Folder:', 'w3-total-cache' ); ?></label></th>
27
+ <td>
28
+ <a href="<?php echo esc_url( $config->get_string( 'cdn.google_drive.folder.url' ) ); ?>">/<?php echo esc_html( $config->get_string( 'cdn.google_drive.folder.title' ) ); ?></a>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <th colspan="2">
33
+ <input id="cdn_test"
34
+ class="button {type: 'google_drive', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}"
35
+ type="button"
36
+ value="<?php esc_attr_e( 'Test upload', 'w3-total-cache' ); ?>" />
37
+ <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
38
+ </th>
39
+ </tr>
40
  <?php endif ?>
Cdn_GoogleDrive_Popup_AuthReturn.php CHANGED
@@ -5,14 +5,14 @@ namespace W3TC;
5
 
6
  class Cdn_GoogleDrive_Popup_AuthReturn {
7
  function render() {
8
- $client_id = $_GET['oa_client_id'];
9
- $refresh_token = $_GET['oa_refresh_token'];
10
 
11
  $token_array = array(
12
- 'access_token' => $_GET['oa_access_token'],
13
- 'token_type' => $_GET['oa_token_type'],
14
- 'expires_in' => $_GET['oa_expires_in'],
15
- 'created' => $_GET['oa_created']
16
  );
17
  $access_token = json_encode( $token_array );
18
 
5
 
6
  class Cdn_GoogleDrive_Popup_AuthReturn {
7
  function render() {
8
+ $client_id = Util_Request::get_string( 'oa_client_id' );
9
+ $refresh_token = Util_Request::get_string( 'oa_refresh_token' );
10
 
11
  $token_array = array(
12
+ 'access_token' => Util_Request::get_string( 'oa_access_token' ),
13
+ 'token_type' => Util_Request::get_string( 'oa_token_type' ),
14
+ 'expires_in' => Util_Request::get_string( 'oa_expires_in' ),
15
+ 'created' => Util_Request::get_string( 'oa_created' )
16
  );
17
  $access_token = json_encode( $token_array );
18
 
Cdn_GoogleDrive_Popup_AuthReturn_View.php CHANGED
@@ -1,45 +1,54 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px">
8
- <?php
9
- Util_Ui::hidden( '', 'client_id', $client_id );
10
- Util_Ui::hidden( '', 'access_token', $access_token );
11
- Util_Ui::hidden( '', 'refresh_token', $refresh_token );
12
- echo Util_Ui::nonce_field( 'w3tc' );
13
- ?>
14
- <br /><br />
15
- <div class="metabox-holder">
16
- <?php Util_Ui::postbox_header( __( 'Select folder', 'w3-total-cache' ) ); ?>
17
- <table class="form-table">
18
- <tr>
19
- <td>Folder:</td>
20
- <td>
21
- <?php foreach ( $folders as $folder ): ?>
22
- <label>
23
- <input name="folder" type="radio" class="w3tc-ignore-change"
24
- value="<?php echo $folder->id ?>" />
25
- <?php echo $folder->title ?>
26
- </label><br />
27
- <?php endforeach ?>
28
-
29
- <label>
30
- <input name="folder" type="radio" class="w3tc-ignore-change" value=""
31
- />
32
- Add new folder:
33
- </label>
34
- <input name="folder_new" type="text" class="w3tc-ignore-change" />
35
- </tr>
36
- </table>
 
 
 
 
 
 
 
 
37
 
38
- <p class="submit">
39
- <input type="submit" name="w3tc_cdn_google_drive_auth_set"
40
- class="w3tc-button-save button-primary"
41
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
42
- </p>
43
- <?php Util_Ui::postbox_footer(); ?>
44
- </div>
45
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px">
9
+ <?php
10
+ Util_Ui::hidden( '', 'client_id', $client_id );
11
+ Util_Ui::hidden( '', 'access_token', $access_token );
12
+ Util_Ui::hidden( '', 'refresh_token', $refresh_token );
13
+ echo wp_kses(
14
+ Util_Ui::nonce_field( 'w3tc' ),
15
+ array(
16
+ 'input' => array(
17
+ 'type' => array(),
18
+ 'name' => array(),
19
+ 'value' => array(),
20
+ ),
21
+ )
22
+ );
23
+ ?>
24
+ <br /><br />
25
+ <div class="metabox-holder">
26
+ <?php Util_Ui::postbox_header( esc_html__( 'Select folder', 'w3-total-cache' ) ); ?>
27
+ <table class="form-table">
28
+ <tr>
29
+ <td><?php esc_html_e( 'Folder:', 'w3-total-cache' ); ?></td>
30
+ <td>
31
+ <?php foreach ( $folders as $folder ) : ?>
32
+ <label>
33
+ <input name="folder" type="radio" class="w3tc-ignore-change"
34
+ value="<?php echo esc_attr( $folder->id ); ?>" />
35
+ <?php echo esc_html( $folder->title ); ?>
36
+ </label><br />
37
+ <?php endforeach ?>
38
+ <label>
39
+ <input name="folder" type="radio" class="w3tc-ignore-change" value="" />
40
+ <?php esc_html_e( 'Add new folder:', 'w3-total-cache' ); ?>
41
+ </label>
42
+ <input name="folder_new" type="text" class="w3tc-ignore-change" />
43
+ </td>
44
+ </tr>
45
+ </table>
46
 
47
+ <p class="submit">
48
+ <input type="submit" name="w3tc_cdn_google_drive_auth_set"
49
+ class="w3tc-button-save button-primary"
50
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
51
+ </p>
52
+ <?php Util_Ui::postbox_footer(); ?>
53
+ </div>
54
  </form>
Cdn_Highwinds_Page_View.php CHANGED
@@ -1,57 +1,167 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  $hash_code = $config->get_string( 'cdn.highwinds.host.hash_code' );
8
  ?>
9
  <tr>
10
- <th style="width: 300px;"><label><?php _e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
11
  <td>
12
- <?php if ( empty( $hash_code ) ): ?>
13
  <input class="w3tc_cdn_highwinds_authorize button" type="button"
14
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>" />
15
- <?php else: ?>
16
  <input class="w3tc_cdn_highwinds_authorize button" type="button"
17
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>" />
18
  <?php endif ?>
19
  </td>
20
  </tr>
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>
28
  </tr>
29
  <tr>
30
- <th><label for="cdn_highwinds_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support:</label>', 'w3-total-cache' ); ?></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  <td>
32
  <select id="cdn_highwinds_ssl" name="cdn__highwinds__ssl">
33
- <option value="auto"<?php selected( $config->get_string( 'cdn.highwinds.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?></option>
34
- <option value="enabled"<?php selected( $config->get_string( 'cdn.highwinds.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
35
- <option value="disabled"<?php selected( $config->get_string( 'cdn.highwinds.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
36
  </select>
37
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  </td>
39
  </tr>
40
  <tr>
41
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
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
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </td>
48
  </tr>
49
  <tr>
50
  <th colspan="2">
51
  <input id="cdn_test"
52
- class="button {type: 'highwinds', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
53
  type="button"
54
- value="<?php _e( 'Test', 'w3-total-cache' ); ?>" />
55
  <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
56
  </th>
57
  </tr>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  $hash_code = $config->get_string( 'cdn.highwinds.host.hash_code' );
8
  ?>
9
  <tr>
10
+ <th style="width: 300px;"><label><?php esc_html_e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
11
  <td>
12
+ <?php if ( empty( $hash_code ) ) : ?>
13
  <input class="w3tc_cdn_highwinds_authorize button" type="button"
14
+ value="<?php esc_html_e( 'Authorize', 'w3-total-cache' ); ?>" />
15
+ <?php else : ?>
16
  <input class="w3tc_cdn_highwinds_authorize button" type="button"
17
+ value="<?php esc_html_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
18
  <?php endif ?>
19
  </td>
20
  </tr>
21
 
22
+ <?php if ( ! empty( $hash_code ) ) : ?>
23
  <tr>
24
+ <th>
25
+ <label>
26
+ <?php
27
+ echo wp_kses(
28
+ sprintf(
29
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
30
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
31
+ __(
32
+ '%1CDN%2 host (%3$sCNAME%4$s target):',
33
+ 'w3-total-cache'
34
+ ),
35
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
36
+ '</acronym>',
37
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
38
+ '</acronym>'
39
+ ),
40
+ array(
41
+ 'acronym' => array(
42
+ 'title' => array(),
43
+ ),
44
+ )
45
+ );
46
+ ?>
47
+ </label>
48
+ </th>
49
  <td class="w3tc_config_value_text">
50
+ cds.<?php echo esc_html( $config->get_string( 'cdn.highwinds.host.hash_code' ) ); ?>.hwcdn.net
51
  </td>
52
  </tr>
53
  <tr>
54
+ <th>
55
+ <label for="cdn_highwinds_ssl">
56
+ <?php
57
+ echo wp_kses(
58
+ sprintf(
59
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
60
+ __(
61
+ '%1$sSSL%2$s support:',
62
+ 'w3-total-cache'
63
+ ),
64
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
65
+ '</acronym>'
66
+ ),
67
+ array(
68
+ 'acronym' => array(
69
+ 'title' => array(),
70
+ ),
71
+ )
72
+ );
73
+ ?>
74
+ </label>
75
+ </th>
76
  <td>
77
  <select id="cdn_highwinds_ssl" name="cdn__highwinds__ssl">
78
+ <option value="auto"<?php selected( $config->get_string( 'cdn.highwinds.ssl' ), 'auto' ); ?>><?php esc_html_e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?></option>
79
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.highwinds.ssl' ), 'enabled' ); ?>><?php esc_html_e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
80
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.highwinds.ssl' ), 'disabled' ); ?>><?php esc_html_e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
81
  </select>
82
+ <p class="description">
83
+ <?php
84
+ echo wp_kses(
85
+ sprintf(
86
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
87
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
88
+ __(
89
+ 'Some %1$sCDN%2$s providers may or may not support %3$sSSL%4$s, contact your vendor for more information.',
90
+ 'w3-total-cache'
91
+ ),
92
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
93
+ '</acronym>',
94
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
95
+ '</acronym>'
96
+ ),
97
+ array(
98
+ 'acronym' => array(
99
+ 'title' => array(),
100
+ ),
101
+ )
102
+ );
103
+ ?>
104
+ </p>
105
  </td>
106
  </tr>
107
  <tr>
108
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
109
  <td>
110
+ <?php
111
+ $cnames = $config->get_array( 'cdn.highwinds.host.domains' );
112
+ include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php';
113
+ ?>
114
+ <input class="w3tc_cdn_highwinds_configure_cnames_form button" type="button" value="
115
+ <?php
116
+ echo wp_kses(
117
+ sprintf(
118
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
119
+ __(
120
+ 'Configure %1$sCNAME%2$ss',
121
+ 'w3-total-cache'
122
+ ),
123
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
124
+ '</acronym>'
125
+ ),
126
+ array(
127
+ 'acronym' => array(
128
+ 'title' => array(),
129
+ ),
130
+ )
131
+ );
132
+ ?>
133
+ " />
134
+ <p class="description">
135
+ <?php
136
+ echo wp_kses(
137
+ sprintf(
138
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
139
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
140
+ __(
141
+ 'Hostname provided by your %1$sCDN%2$s provider, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
142
+ 'w3-total-cache'
143
+ ),
144
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
145
+ '</acronym>',
146
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
147
+ '</acronym>'
148
+ ),
149
+ array(
150
+ 'acronym' => array(
151
+ 'title' => array(),
152
+ ),
153
+ )
154
+ );
155
+ ?>
156
+ </p>
157
  </td>
158
  </tr>
159
  <tr>
160
  <th colspan="2">
161
  <input id="cdn_test"
162
+ class="button {type: 'highwinds', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}"
163
  type="button"
164
+ value="<?php esc_html_e( 'Test', 'w3-total-cache' ); ?>" />
165
  <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
166
  </th>
167
  </tr>
Cdn_Highwinds_Popup.php CHANGED
@@ -30,7 +30,7 @@ class Cdn_Highwinds_Popup {
30
 
31
 
32
  public function w3tc_ajax_cdn_highwinds_select_host() {
33
- $api_token = $_REQUEST['api_token'];
34
 
35
  try {
36
  $user = Cdn_Highwinds_Api::users_me( $api_token );
@@ -60,8 +60,8 @@ class Cdn_Highwinds_Popup {
60
 
61
 
62
  public function w3tc_ajax_cdn_highwinds_configure_host() {
63
- $account_hash = $_REQUEST['account_hash'];
64
- $api_token = $_REQUEST['api_token'];
65
 
66
  $host = Util_Request::get( 'host', '' );
67
 
@@ -74,7 +74,7 @@ class Cdn_Highwinds_Popup {
74
 
75
  try {
76
  if ( empty( $host ) ) {
77
- $host = $this->_create_host( $api, $_REQUEST['host_new'] );
78
  }
79
  } catch ( \Exception $ex ) {
80
  $api_hosts = $api->hosts();
@@ -118,7 +118,7 @@ class Cdn_Highwinds_Popup {
118
  array(
119
  'cdn_configuration_saved' =>
120
  'CDN credentials are saved successfully' ) );
121
- echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
122
  exit();
123
  }
124
 
@@ -166,7 +166,7 @@ class Cdn_Highwinds_Popup {
166
  try {
167
  // create host
168
  $host_response = $api->host_add( array(
169
- 'name' => $_REQUEST['host_new'],
170
  'services' => $service_ids
171
  ) );
172
  $host = $host_response['hashCode'];
@@ -238,7 +238,7 @@ class Cdn_Highwinds_Popup {
238
 
239
  $postfix = Util_Admin::custom_message_id( array(),
240
  array( 'cdn_cnames_saved' => 'CNAMEs are saved successfully' ) );
241
- echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
242
  exit();
243
  } catch ( \Exception $ex ) {
244
  $details['error_message'] = $ex->getMessage();
30
 
31
 
32
  public function w3tc_ajax_cdn_highwinds_select_host() {
33
+ $api_token = Util_Request::get_string( 'api_token' );
34
 
35
  try {
36
  $user = Cdn_Highwinds_Api::users_me( $api_token );
60
 
61
 
62
  public function w3tc_ajax_cdn_highwinds_configure_host() {
63
+ $account_hash = Util_Request::get_string( 'account_hash' );
64
+ $api_token = Util_Request::get_string( 'api_token' );
65
 
66
  $host = Util_Request::get( 'host', '' );
67
 
74
 
75
  try {
76
  if ( empty( $host ) ) {
77
+ $host = $this->_create_host( $api, Util_Request::get_string( 'host_new' ) );
78
  }
79
  } catch ( \Exception $ex ) {
80
  $api_hosts = $api->hosts();
118
  array(
119
  'cdn_configuration_saved' =>
120
  'CDN credentials are saved successfully' ) );
121
+ echo 'Location admin.php?page=w3tc_cdn&' . esc_html( $postfix );
122
  exit();
123
  }
124
 
166
  try {
167
  // create host
168
  $host_response = $api->host_add( array(
169
+ 'name' => Util_Request::get_string( 'host_new' ),
170
  'services' => $service_ids
171
  ) );
172
  $host = $host_response['hashCode'];
238
 
239
  $postfix = Util_Admin::custom_message_id( array(),
240
  array( 'cdn_cnames_saved' => 'CNAMEs are saved successfully' ) );
241
+ echo 'Location admin.php?page=w3tc_cdn&' . esc_html( $postfix );
242
  exit();
243
  } catch ( \Exception $ex ) {
244
  $details['error_message'] = $ex->getMessage();
Cdn_Highwinds_Popup_View_ConfigureCnamesForm.php CHANGED
@@ -1,23 +1,69 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_highwinds_form">
8
  <?php
9
- 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( __( '<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
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  <p class="submit">
18
  <input type="button"
19
  class="w3tc_cdn_highwinds_configure_cnames w3tc-button-save button-primary"
20
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
21
  </p>
22
  <?php Util_Ui::postbox_footer(); ?>
23
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_highwinds_form">
9
  <?php
10
+ if ( ! empty( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php
16
+ Util_Ui::postbox_header(
17
+ wp_kses(
18
+ sprintf(
19
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
20
+ __(
21
+ '%1$sCNAME%2$ss to use',
22
+ 'w3-total-cache'
23
+ ),
24
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
25
+ '</acronym>'
26
+ ),
27
+ array(
28
+ 'acronym' => array(
29
+ 'title' => array(),
30
+ ),
31
+ )
32
+ )
33
+ );
34
+ ?>
35
+ <?php
36
+ $cname_class = 'w3tc-ignore-change';
37
+ require W3TC_INC_DIR . '/options/cdn/common/cnames.php';
38
+ ?>
39
+ <p class="description">
40
+ <?php
41
+ echo wp_kses(
42
+ sprintf(
43
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
44
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
45
+ __(
46
+ 'Enter hostname mapped to %1$sCDN%2$s host, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
47
+ 'w3-total-cache'
48
+ ),
49
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
50
+ '</acronym>',
51
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
52
+ '</acronym>'
53
+ ),
54
+ array(
55
+ 'acronym' => array(
56
+ 'title' => array(),
57
+ ),
58
+ )
59
+ );
60
+ ?>
61
+ </p>
62
 
63
  <p class="submit">
64
  <input type="button"
65
  class="w3tc_cdn_highwinds_configure_cnames w3tc-button-save button-primary"
66
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
67
  </p>
68
  <?php Util_Ui::postbox_footer(); ?>
69
  </div>
Cdn_Highwinds_Popup_View_Intro.php CHANGED
@@ -1,20 +1,21 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_highwinds_form" method="post" style="padding: 20px">
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 Highwinds API Token', 'w3-total-cache' ) ); ?>
15
  <table class="form-table">
16
  <tr>
17
- <td>API Token:</td>
18
  <td>
19
  <input name="api_token" type="text" class="w3tc-ignore-change"
20
  value="" style="width: 550px" />
@@ -25,7 +26,7 @@ if ( isset( $details['error_message'] ) )
25
  <p class="submit">
26
  <input type="button"
27
  class="w3tc_cdn_highwinds_select_host w3tc-button-save button-primary"
28
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
29
  </p>
30
  <?php Util_Ui::postbox_footer(); ?>
31
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_highwinds_form" method="post" style="padding: 20px">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your Highwinds API Token', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
+ <td><?php esc_html_e( 'API Token:', 'w3-total-cache' ); ?></td>
19
  <td>
20
  <input name="api_token" type="text" class="w3tc-ignore-change"
21
  value="" style="width: 550px" />
26
  <p class="submit">
27
  <input type="button"
28
  class="w3tc_cdn_highwinds_select_host w3tc-button-save button-primary"
29
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
30
  </p>
31
  <?php Util_Ui::postbox_footer(); ?>
32
  </div>
Cdn_Highwinds_Popup_View_SelectHost.php CHANGED
@@ -1,50 +1,60 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_highwinds_form">
9
- <?php
10
- Util_Ui::hidden( '', 'account_hash', $details['account_hash'] );
11
- Util_Ui::hidden( '', 'api_token', $details['api_token'] );
12
- echo Util_Ui::nonce_field( 'w3tc' );
13
 
14
- ?>
15
- <?php
16
- if ( isset( $details['error_message'] ) )
17
- echo '<div class="error">' . $details['error_message'] . '</div>';
18
- ?>
19
- <div class="metabox-holder">
20
- <?php Util_Ui::postbox_header( __( 'Select host to use', 'w3-total-cache' ) ); ?>
21
- <table class="form-table">
22
- <tr>
23
- <td>Host:</td>
24
- <td>
25
- <?php foreach ( $details['hosts'] as $host ): ?>
26
- <label>
27
- <input name="host" type="radio" class="w3tc-ignore-change"
28
- value="<?php echo $host['hashCode'] ?>" />
29
- <?php echo $host['name'] ?>
30
- (<?php echo $host['hashCode'] ?>)
31
- </label><br />
32
- <?php endforeach ?>
 
 
 
 
 
 
 
 
 
 
33
 
34
- <label>
35
- <input name="host" type="radio" class="w3tc-ignore-change" value=""
36
- />
37
- Add new host:
38
- </label>
39
- <input name="host_new" type="text" class="w3tc-ignore-change" />
40
- </tr>
41
- </table>
42
 
43
- <p class="submit">
44
- <input type="button"
45
- class="w3tc_cdn_highwinds_configure_host 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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
9
+ class="w3tc_cdn_highwinds_form">
10
+ <?php
11
+ Util_Ui::hidden( '', 'account_hash', $details['account_hash'] );
12
+ Util_Ui::hidden( '', 'api_token', $details['api_token'] );
 
13
 
14
+ echo wp_kses(
15
+ Util_Ui::nonce_field( 'w3tc' ),
16
+ array(
17
+ 'input' => array(
18
+ 'type' => array(),
19
+ 'name' => array(),
20
+ 'value' => array(),
21
+ ),
22
+ )
23
+ );
24
+
25
+ if ( isset( $details['error_message'] ) ) {
26
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
27
+ }
28
+ ?>
29
+ <div class="metabox-holder">
30
+ <?php Util_Ui::postbox_header( esc_html__( 'Select host to use', 'w3-total-cache' ) ); ?>
31
+ <table class="form-table">
32
+ <tr>
33
+ <td>Host:</td>
34
+ <td>
35
+ <?php foreach ( $details['hosts'] as $host ) : ?>
36
+ <label>
37
+ <input name="host" type="radio" class="w3tc-ignore-change"
38
+ value="<?php echo esc_attr( $host['hashCode'] ); ?>" />
39
+ <?php echo esc_html( $host['name'] ); ?>
40
+ (<?php echo esc_html( $host['hashCode'] ); ?>)
41
+ </label><br />
42
+ <?php endforeach; ?>
43
 
44
+ <label>
45
+ <input name="host" type="radio" class="w3tc-ignore-change" value="" />
46
+ Add new host:
47
+ </label>
48
+ <input name="host_new" type="text" class="w3tc-ignore-change" />
49
+ </td>
50
+ </tr>
51
+ </table>
52
 
53
+ <p class="submit">
54
+ <input type="button"
55
+ class="w3tc_cdn_highwinds_configure_host w3tc-button-save button-primary"
56
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
57
+ </p>
58
+ <?php Util_Ui::postbox_footer(); ?>
59
+ </div>
60
  </form>
Cdn_Highwinds_Widget_View.php CHANGED
@@ -1,42 +1,42 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <div class="wrapper">
9
- <div class="tools area">
10
- <ul class="w3tchw_tools">
11
- <li><a class="button"
12
- href="<?php echo $url_manage ?>"><?php _e( 'Manage', 'w3-total-cache' )?></a>
13
- </li>
14
- <li><a class="button"
15
- href="<?php echo $url_analyze ?>"><?php _e( 'Reports', 'w3-total-cache' )?></a>
16
- </li>
17
- <li><a class="button" href="<?php echo $url_purge ?>"
18
- onclick="w3tc_popupadmin_bar(this.href); return false"><?php _e( 'Purge', 'w3-total-cache' )?></a>
19
- </li>
20
- </ul>
21
- </div>
22
- <div class="w3tchw_loading w3tc_loading w3tc_hidden">Loading...</div>
23
- <div class="w3tchw_error w3tc_none">
24
- An error occurred
25
- <div class="w3tchw_error_details"></div>
26
- </div>
27
 
28
- <div class="w3tchw_content w3tc_hidden">
29
- <div class="summary area">
30
- <h4><?php _e( 'Report - 30 days', 'w3-total-cache' ) ?></h4>
31
- <ul id="w3tchw_report">
32
- <li>Transferred: <span class="w3tchw_transferred_size"></span></li>
33
- <li>Average rate Mb/s: <span class="w3tchw_average_mbps"></span></li>
34
- <li>Average requests/s: <span class="w3tchw_average_rps"></span></li>
35
- </ul>
36
- </div>
37
- <div class="charts area">
38
- <h4><?php _e( 'Requests', 'w3-total-cache' ) ?></h4>
39
- <div id="w3tchw_chart" style="width: 320px; height: 220px;margin-left: auto; margin-right: auto;"></div>
40
- </div>
41
- </div>
42
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div class="wrapper">
9
+ <div class="tools area">
10
+ <ul class="w3tchw_tools">
11
+ <li><a class="button"
12
+ href="<?php echo esc_url( $url_manage ); ?>"><?php esc_html_e( 'Manage', 'w3-total-cache' ); ?></a>
13
+ </li>
14
+ <li><a class="button"
15
+ href="<?php echo esc_url( $url_analyze ); ?>"><?php esc_html_e( 'Reports', 'w3-total-cache' ); ?></a>
16
+ </li>
17
+ <li><a class="button" href="<?php echo esc_url( $url_purge ); ?>"
18
+ onclick="w3tc_popupadmin_bar(this.href); return false"><?php esc_html_e( 'Purge', 'w3-total-cache' ); ?></a>
19
+ </li>
20
+ </ul>
21
+ </div>
22
+ <div class="w3tchw_loading w3tc_loading w3tc_hidden">Loading...</div>
23
+ <div class="w3tchw_error w3tc_none">
24
+ An error occurred
25
+ <div class="w3tchw_error_details"></div>
26
+ </div>
27
 
28
+ <div class="w3tchw_content w3tc_hidden">
29
+ <div class="summary area">
30
+ <h4><?php esc_html_e( 'Report - 30 days', 'w3-total-cache' ); ?></h4>
31
+ <ul id="w3tchw_report">
32
+ <li>Transferred: <span class="w3tchw_transferred_size"></span></li>
33
+ <li>Average rate Mb/s: <span class="w3tchw_average_mbps"></span></li>
34
+ <li>Average requests/s: <span class="w3tchw_average_rps"></span></li>
35
+ </ul>
36
+ </div>
37
+ <div class="charts area">
38
+ <h4><?php esc_html_e( 'Requests', 'w3-total-cache' ); ?></h4>
39
+ <div id="w3tchw_chart" style="width: 320px; height: 220px;margin-left: auto; margin-right: auto;"></div>
40
+ </div>
41
+ </div>
42
  </div>
Cdn_LimeLight_Page_View.php CHANGED
@@ -1,50 +1,118 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
  $api_key = $config->get_string( 'cdn.limelight.api_key' );
8
  ?>
9
  <tr>
10
- <th style="width: 300px;"><label><?php _e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
11
  <td>
12
- <?php if ( empty( $api_key ) ): ?>
13
  <input class="w3tc_cdn_limelight_authorize button" type="button"
14
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>" />
15
- <?php else: ?>
16
  <input class="w3tc_cdn_limelight_authorize button" type="button"
17
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>" />
18
- <?php endif ?>
19
  </td>
20
  </tr>
21
 
22
- <?php if ( !empty( $api_key ) ): ?>
23
  <tr>
24
- <th><label for="cdn_limelight_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support:</label>', 'w3-total-cache' ); ?></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  <td>
26
  <select id="cdn_limelight_ssl" name="cdn__limelight__ssl">
27
- <option value="auto"<?php selected( $config->get_string( 'cdn.limelight.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?></option>
28
- <option value="enabled"<?php selected( $config->get_string( 'cdn.limelight.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
29
- <option value="disabled"<?php selected( $config->get_string( 'cdn.limelight.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
30
  </select>
31
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </td>
33
  </tr>
34
  <tr>
35
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
36
  <td>
37
- <?php $cnames = $config->get_array( 'cdn.limelight.host.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
38
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  </td>
40
  </tr>
41
  <tr>
42
  <th colspan="2">
43
  <input id="cdn_test"
44
- class="button {type: 'limelight', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
45
- type="button"
46
- value="<?php _e( 'Test', 'w3-total-cache' ); ?>" />
47
  <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
48
  </th>
49
  </tr>
50
- <?php endif ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
  $api_key = $config->get_string( 'cdn.limelight.api_key' );
9
  ?>
10
  <tr>
11
+ <th style="width: 300px;"><label><?php esc_html_e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
12
  <td>
13
+ <?php if ( empty( $api_key ) ) : ?>
14
  <input class="w3tc_cdn_limelight_authorize button" type="button"
15
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
16
+ <?php else : ?>
17
  <input class="w3tc_cdn_limelight_authorize button" type="button"
18
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
19
+ <?php endif; ?>
20
  </td>
21
  </tr>
22
 
23
+ <?php if ( ! empty( $api_key ) ) : ?>
24
  <tr>
25
+ <th>
26
+ <label for="cdn_limelight_ssl">
27
+ <?php
28
+ echo wp_kses(
29
+ sprintf(
30
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
31
+ __(
32
+ '%1$sSSL%2$s support:',
33
+ 'w3-total-cache'
34
+ ),
35
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
36
+ '</acronym>'
37
+ ),
38
+ array(
39
+ 'acronym' => array(
40
+ 'title' => array(),
41
+ ),
42
+ )
43
+ );
44
+ ?>
45
+ </label>
46
+ </th>
47
  <td>
48
  <select id="cdn_limelight_ssl" name="cdn__limelight__ssl">
49
+ <option value="auto"<?php selected( $config->get_string( 'cdn.limelight.ssl' ), 'auto' ); ?>><?php esc_html_e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?></option>
50
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.limelight.ssl' ), 'enabled' ); ?>><?php esc_html_e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
51
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.limelight.ssl' ), 'disabled' ); ?>><?php esc_html_e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
52
  </select>
53
+ <p class="description">
54
+ <?php
55
+ echo wp_kses(
56
+ sprintf(
57
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
58
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
59
+ __(
60
+ 'Some %1$sCDN%2$s providers may or may not support %3$sSSL%4$s, contact your vendor for more information.',
61
+ 'w3-total-cache'
62
+ ),
63
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
64
+ '</acronym>',
65
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
66
+ '</acronym>'
67
+ ),
68
+ array(
69
+ 'acronym' => array(
70
+ 'title' => array(),
71
+ ),
72
+ )
73
+ );
74
+ ?>
75
+ </p>
76
  </td>
77
  </tr>
78
  <tr>
79
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
80
  <td>
81
+ <?php
82
+ $cnames = $config->get_array( 'cdn.limelight.host.domains' );
83
+ require W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php';
84
+ ?>
85
+ <p class="description">
86
+ <?php
87
+ echo wp_kses(
88
+ sprintf(
89
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
90
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
91
+ __(
92
+ 'Hostname provided by your %1$sCDN%2$s provider, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
93
+ 'w3-total-cache'
94
+ ),
95
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
96
+ '</acronym>',
97
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
98
+ '</acronym>'
99
+ ),
100
+ array(
101
+ 'acronym' => array(
102
+ 'title' => array(),
103
+ ),
104
+ )
105
+ );
106
+ ?>
107
+ </p>
108
  </td>
109
  </tr>
110
  <tr>
111
  <th colspan="2">
112
  <input id="cdn_test"
113
+ class="button {type: 'limelight', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}"
114
+ type="button" value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
 
115
  <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
116
  </th>
117
  </tr>
118
+ <?php endif; ?>
Cdn_LimeLight_Popup.php CHANGED
@@ -36,10 +36,10 @@ class Cdnfsd_LimeLight_Popup {
36
 
37
 
38
  public function w3tc_ajax_cdn_limelight_save() {
39
- $short_name = $_REQUEST['short_name'];
40
- $username = $_REQUEST['username'];
41
- $api_key = $_REQUEST['api_key'];
42
- $domain = $_REQUEST['domain'];
43
 
44
  try {
45
  $api = new Cdnfsd_LimeLight_Api( $short_name, $username, $api_key );
36
 
37
 
38
  public function w3tc_ajax_cdn_limelight_save() {
39
+ $short_name = Util_Request::get_string( 'short_name' );
40
+ $username = Util_Request::get_string( 'username' );
41
+ $api_key = Util_Request::get_string( 'api_key' );
42
+ $domain = Util_Request::get_string( 'domain' );
43
 
44
  try {
45
  $api = new Cdnfsd_LimeLight_Api( $short_name, $username, $api_key );
Cdn_LimeLight_Popup_View_Intro.php CHANGED
@@ -1,57 +1,57 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- 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 LimeLight Account credentials', 'w3-total-cache' ) ); ?>
15
- <table class="form-table">
16
- <tr>
17
- <td>Account Short Name:</td>
18
- <td>
19
- <input name="short_name" type="text" class="w3tc-ignore-change"
20
- style="width: 550px"
21
- value="<?php echo $config->get_string( 'cdn.limelight.short_name' ) ?>" />
22
- </td>
23
- </tr>
24
- <tr>
25
- <td>Username:</td>
26
- <td>
27
- <input name="username" type="text" class="w3tc-ignore-change"
28
- style="width: 550px"
29
- value="<?php echo $config->get_string( 'cdn.limelight.username' ) ?>" />
30
- </td>
31
- </tr>
32
- <tr>
33
- <td>API Key:</td>
34
- <td>
35
- <input name="api_key" type="text" class="w3tc-ignore-change"
36
- style="width: 550px"
37
- value="<?php echo $config->get_string( 'cdn.limelight.api_key' ) ?>" />
38
- </td>
39
- </tr>
40
- <tr>
41
- <td>CDN hostname:</td>
42
- <td>
43
- <input name="domain" type="text" class="w3tc-ignore-change"
44
- style="width: 550px"
45
- value="<?php echo esc_attr($domain) ?>" />
46
- </td>
47
- </tr>
48
- </table>
49
-
50
- <p class="submit">
51
- <input type="button"
52
- class="w3tc_cdn_limelight_save w3tc-button-save button-primary"
53
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
54
- </p>
55
- <?php Util_Ui::postbox_footer(); ?>
56
- </div>
57
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
+ <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your LimeLight Account credentials', 'w3-total-cache' ) ); ?>
16
+ <table class="form-table">
17
+ <tr>
18
+ <td><?php esc_html_e( 'Account Short Name:', 'w3-total-cache' ); ?></td>
19
+ <td>
20
+ <input name="short_name" type="text" class="w3tc-ignore-change"
21
+ style="width: 550px"
22
+ value="<?php echo esc_attr( $config->get_string( 'cdn.limelight.short_name' ) ); ?>" />
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td><?php esc_html_e( 'Username:', 'w3-total-cache' ); ?></td>
27
+ <td>
28
+ <input name="username" type="text" class="w3tc-ignore-change"
29
+ style="width: 550px"
30
+ value="<?php echo esc_attr( $config->get_string( 'cdn.limelight.username' ) ); ?>" />
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <td><?php esc_html_e( 'API Key:', 'w3-total-cache' ); ?></td>
35
+ <td>
36
+ <input name="api_key" type="text" class="w3tc-ignore-change"
37
+ style="width: 550px"
38
+ value="<?php echo esc_attr( $config->get_string( 'cdn.limelight.api_key' ) ); ?>" />
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <td><?php esc_html_e( 'CDN hostname:', 'w3-total-cache' ); ?></td>
43
+ <td>
44
+ <input name="domain" type="text" class="w3tc-ignore-change"
45
+ style="width: 550px"
46
+ value="<?php echo esc_attr( $domain ); ?>" />
47
+ </td>
48
+ </tr>
49
+ </table>
50
+ <p class="submit">
51
+ <input type="button"
52
+ class="w3tc_cdn_limelight_save w3tc-button-save button-primary"
53
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
54
+ </p>
55
+ <?php Util_Ui::postbox_footer(); ?>
56
+ </div>
 
57
  </form>
Cdn_LimeLight_Popup_View_Success.php CHANGED
@@ -1,22 +1,36 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_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
- Plugin was successfully configured to use this service.<br />
14
- Make sure you have updated domain DNS records.
15
- <p class="submit">
16
- <input type="button"
17
- class="w3tc_cdn_limelight_done w3tc-button-save button-primary"
18
- value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
19
- </p>
20
- <?php Util_Ui::postbox_footer(); ?>
21
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ <?php
14
+ echo wp_kses(
15
+ sprintf(
16
+ // translators: 1 HTML line break tag.
17
+ __(
18
+ 'Plugin was successfully configured to use this service.%1$sMake sure you have updated domain DNS records.',
19
+ 'w3-total-cache'
20
+ ),
21
+ '<br />'
22
+ ),
23
+ array(
24
+ 'br' => array(),
25
+ )
26
+ );
27
+ ?>
28
+ <p class="submit">
29
+ <input type="button"
30
+ class="w3tc_cdn_limelight_done w3tc-button-save button-primary"
31
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
32
+ </p>
33
+ <?php Util_Ui::postbox_footer(); ?>
34
+ </div>
35
+ </div>
36
  </form>
Cdn_MaxCdn_Page_View.php CHANGED
@@ -1,16 +1,16 @@
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 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
- <p 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!' ) ?></p>
14
  </td>
15
  </tr>
16
  <?php endif ?>
@@ -20,76 +20,274 @@ if ( !defined( 'W3TC' ) )
20
  <tr>
21
  <th style="width: 300px;">
22
  <label>
23
- <?php _e( 'Specify account credentials:', 'w3-total-cache' ); ?>
24
  </label>
25
  </th>
26
  <td>
27
- <?php if ( $authorized ): ?>
28
  <input class="w3tc_cdn_maxcdn_authorize button-primary"
29
  type="button"
30
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
31
  />
32
- <?php else: ?>
33
  <input class="w3tc_cdn_maxcdn_authorize button-primary"
34
  type="button"
35
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
36
  />
37
  <?php endif ?>
38
  </td>
39
  </tr>
40
 
41
- <?php if ( $authorized ): ?>
42
- <?php if ( !is_null( $http_domain ) ): ?>
43
- <tr>
44
- <th>
45
- <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>
46
- </th>
47
- <td class="w3tc_config_value_text">
48
- <?php echo htmlspecialchars( $http_domain ) ?>
49
- <p class="description">
50
- This website domain has to be CNAME pointing to this
51
- <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="Hypertext Transfer Protocol">HTTP</acronym> requests
52
- </p>
53
- </td>
54
- </tr>
55
- <?php endif ?>
56
- <?php if ( !is_null( $https_domain ) ): ?>
57
- <tr>
58
- <th>
59
- <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>
60
- </th>
61
- <td class="w3tc_config_value_text">
62
- <?php echo htmlspecialchars( $https_domain ) ?>
63
- <p class="description">
64
- This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
65
- <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
66
- </p>
67
- </td>
68
- </tr>
69
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
- <tr>
72
- <th><label for="cdn_maxcdn_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support', 'w3-total-cache' )?>:</label></th>
73
- <td>
74
- <select id="cdn_maxcdn_ssl" name="cdn__maxcdn__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
75
- <option value="auto"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
76
- <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>
77
- <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>
78
- </select>
79
- <p 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' )?></p>
80
- </td>
81
- </tr>
82
- <tr>
83
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' )?></th>
84
- <td>
85
- <?php $cnames = $config->get_array( 'cdn.maxcdn.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
86
- <p 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' )?></p>
87
- </td>
88
- </tr>
89
- <tr>
90
- <th colspan="2">
91
- <input id="cdn_test" class="button {type: 'maxcdn', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}" type="button" value="<?php _e( 'Test MaxCDN', 'w3-total-cache' )?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
92
- </th>
93
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  <?php endif ?>
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 esc_html_e( 'Create account:', 'w3-total-cache' ); ?></label></th>
11
  <td>
12
+ <a href="<?php echo esc_url( 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
+ <p 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!' ); ?></p>
14
  </td>
15
  </tr>
16
  <?php endif ?>
20
  <tr>
21
  <th style="width: 300px;">
22
  <label>
23
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
24
  </label>
25
  </th>
26
  <td>
27
+ <?php if ( $authorized ) : ?>
28
  <input class="w3tc_cdn_maxcdn_authorize button-primary"
29
  type="button"
30
+ value="<?php esc_html_e( 'Reauthorize', 'w3-total-cache' ); ?>"
31
  />
32
+ <?php else : ?>
33
  <input class="w3tc_cdn_maxcdn_authorize button-primary"
34
  type="button"
35
+ value="<?php esc_html_e( 'Authorize', 'w3-total-cache' ); ?>"
36
  />
37
  <?php endif ?>
38
  </td>
39
  </tr>
40
 
41
+ <?php if ( $authorized ) : ?>
42
+ <?php if ( ! is_null( $http_domain ) ) : ?>
43
+ <tr>
44
+ <th>
45
+ <label>
46
+ <?php
47
+ echo wp_kses(
48
+ sprintf(
49
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
50
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
51
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
52
+ __(
53
+ '%1$sCDN%2$s %3$sHTTP%4$s %5$sCNAME%6$s:',
54
+ 'w3-total-cache'
55
+ ),
56
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
57
+ '</acronym>',
58
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
59
+ '</acronym>',
60
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
61
+ '</acronym>'
62
+ ),
63
+ array(
64
+ 'acronym' => array(
65
+ 'title' => array(),
66
+ ),
67
+ )
68
+ );
69
+ ?>
70
+ </label>
71
+ </th>
72
+ <td class="w3tc_config_value_text">
73
+ <?php echo esc_html( $http_domain ); ?>
74
+ <p class="description">
75
+ <?php
76
+ echo wp_kses(
77
+ sprintf(
78
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acornym tag,
79
+ // translators: 3 opening HMTL acornym tag, 4 closing HTML acronym tag.
80
+ __(
81
+ 'This website domain has to be CNAME pointing to this %1$sCDN%2$s domain for %3$sHTTP%4$s requests',
82
+ 'w3-total-cache'
83
+ ),
84
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
85
+ '</acronym>',
86
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
87
+ '</acronym>'
88
+ ),
89
+ array(
90
+ 'acronym' => array(
91
+ 'title' => array(),
92
+ ),
93
+ )
94
+ );
95
+ ?>
96
+ </p>
97
+ </td>
98
+ </tr>
99
+ <?php endif ?>
100
+ <?php if ( ! is_null( $https_domain ) ) : ?>
101
+ <tr>
102
+ <th>
103
+ <label>
104
+ <?php
105
+ echo wp_kses(
106
+ sprintf(
107
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
108
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
109
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
110
+ __(
111
+ '%1$sCDN%2$s %3$sHTTP%4$sS %5$sCNAME%6$s:',
112
+ 'w3-total-cache'
113
+ ),
114
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
115
+ '</acronym>',
116
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
117
+ '</acronym>',
118
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
119
+ '</acronym>'
120
+ ),
121
+ array(
122
+ 'acronym' => array(
123
+ 'title' => array(),
124
+ ),
125
+ )
126
+ );
127
+ ?>
128
+ </label>
129
+ </th>
130
+ <td class="w3tc_config_value_text">
131
+ <?php echo esc_html( $https_domain ); ?>
132
+ <p class="description">
133
+ <?php
134
+ echo wp_kses(
135
+ sprintf(
136
+ // translators: 1 opening HTML acronym tag, 2 closing HMTL acronym tag,
137
+ // translators: 3 opening HTML acronym tag, 4 closing HMTL acronym tag,
138
+ // translators: 5 opening HTML acronym tag, 6 closing HMTL acronym tag.
139
+ __(
140
+ 'This website domain has to be %1$sCNAME%2$s pointing to this %3$sCDN%4$s domain for %5$sHTTPS%6$s requests'
141
+ ),
142
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
143
+ '</acronym>',
144
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
145
+ '</acronym>',
146
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol over SSL', 'w3-total-cache' ) . '">',
147
+ '</acronym>'
148
+ ),
149
+ array(
150
+ 'acronym' => array(
151
+ 'title' => array(),
152
+ ),
153
+ )
154
+ );
155
+ ?>
156
+ </p>
157
+ </td>
158
+ </tr>
159
+ <?php endif ?>
160
 
161
+ <tr>
162
+ <th>
163
+ <label for="cdn_maxcdn_ssl">
164
+ <?php
165
+ echo wp_kses(
166
+ sprintf(
167
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
168
+ __(
169
+ '%1$sSSL%2$s support:',
170
+ 'w3-total-cache'
171
+ ),
172
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
173
+ '</acronym>'
174
+ ),
175
+ array(
176
+ 'acronym' => array(
177
+ 'title' => array(),
178
+ ),
179
+ )
180
+ );
181
+ ?>
182
+ </label>
183
+ </th>
184
+ <td>
185
+ <select id="cdn_maxcdn_ssl" name="cdn__maxcdn__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ); ?>>
186
+ <option value="auto"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'auto' ); ?>>
187
+ <?php esc_html_e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?>
188
+ </option>
189
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'enabled' ); ?>>
190
+ <?php
191
+ echo wp_kses(
192
+ sprintf(
193
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
194
+ __(
195
+ 'Enabled (always use %1$sSSL%2$s)',
196
+ 'w3-total-cache'
197
+ ),
198
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
199
+ '</acronym>'
200
+ ),
201
+ array(
202
+ 'acronym' => array(
203
+ 'title' => array(),
204
+ ),
205
+ )
206
+ );
207
+ ?>
208
+ </option>
209
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.maxcdn.ssl' ), 'disabled' ); ?>>
210
+ <?php
211
+ echo wp_kses(
212
+ sprintf(
213
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
214
+ __(
215
+ 'Disabled (always use %1$sHTTP%2$s)',
216
+ 'w3-total-cache'
217
+ ),
218
+ '<acronym title="' . esc_attr__( 'Hypertext Transfer Protocol', 'w3-total-cache' ) . '">',
219
+ '</acronym>'
220
+ ),
221
+ array(
222
+ 'acronym' => array(
223
+ 'title' => array(),
224
+ ),
225
+ )
226
+ );
227
+ ?>
228
+ </option>
229
+ </select>
230
+ <p class="description">
231
+ <?php
232
+ echo wp_kses(
233
+ sprintf(
234
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
235
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
236
+ __(
237
+ 'Some %1$sCDN%2$s providers may or may not support %3$sSSL%4$s, contact your vendor for more information.',
238
+ 'w3-total-cache'
239
+ ),
240
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
241
+ '</acronym>',
242
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
243
+ '</acronym>'
244
+ ),
245
+ array(
246
+ 'acronym' => array(
247
+ 'title' => array(),
248
+ ),
249
+ )
250
+ );
251
+ ?>
252
+ </p>
253
+ </td>
254
+ </tr>
255
+ <tr>
256
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
257
+ <td>
258
+ <?php
259
+ $cnames = $config->get_array( 'cdn.maxcdn.domain' );
260
+ include W3TC_INC_DIR . '/options/cdn/common/cnames.php';
261
+ ?>
262
+ <p class="description">
263
+ <?php
264
+ echo wp_kses(
265
+ sprintf(
266
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
267
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
268
+ __(
269
+ 'Enter the hostname provided by your %1$sCDN%2$s provider, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
270
+ 'w3-total-cache'
271
+ ),
272
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
273
+ '</acronym>',
274
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
275
+ '</acronym>'
276
+ ),
277
+ array(
278
+ 'acronym' => array(
279
+ 'title' => array(),
280
+ ),
281
+ )
282
+ );
283
+ ?>
284
+ </p>
285
+ </td>
286
+ </tr>
287
+ <tr>
288
+ <th colspan="2">
289
+ <input id="cdn_test" class="button {type: 'maxcdn', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}" type="button" value="<?php esc_attr_e( 'Test MaxCDN', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
290
+ </th>
291
+ </tr>
292
 
293
  <?php endif ?>
Cdn_MaxCdn_Popup.php CHANGED
@@ -49,7 +49,7 @@ class Cdn_MaxCdn_Popup {
49
 
50
 
51
  public function w3tc_ajax_cdn_maxcdn_list_zones() {
52
- $api_key = $_REQUEST['api_key'];
53
 
54
  $api = \NetDNA::create( $api_key );
55
  if ( !$api->is_valid() ) {
@@ -89,8 +89,8 @@ class Cdn_MaxCdn_Popup {
89
 
90
  public function w3tc_ajax_cdn_maxcdn_view_zone() {
91
  $config = Dispatcher::config();
92
- $api_key = $_REQUEST['api_key'];
93
- $zone_id = Util_Request::get( 'zone_id', '' );
94
 
95
  $details = array(
96
  'api_key' => $api_key,
@@ -155,7 +155,7 @@ class Cdn_MaxCdn_Popup {
155
 
156
 
157
  public function w3tc_ajax_cdn_maxcdn_configure_zone() {
158
- $api_key = $_REQUEST['api_key'];
159
  $zone_id = Util_Request::get( 'zone_id', '' );
160
 
161
  if ( empty( $zone_id ) ) {
@@ -171,16 +171,16 @@ class Cdn_MaxCdn_Popup {
171
  } else {
172
  $zone = array();
173
 
174
- if ( isset( $_REQUEST['url_change'] ) ) {
175
- $zone['url'] = Util_Request::get( 'url' );
176
  }
177
- if ( isset( $_REQUEST['compress_change'] ) ) {
178
- $zone['compress'] = Util_Request::get( 'compress' );
179
  }
180
- if ( isset( $_REQUEST['cors_headers_change'] ) ) {
181
- $zone['cors_headers'] = Util_Request::get( 'cors_headers' );
182
  }
183
- if ( Util_Request::get( 'ssl' ) == 'shared' ) {
184
  $zone['sslshared'] = 1;
185
  $zone['http2'] = 1;
186
  }
@@ -229,20 +229,20 @@ class Cdn_MaxCdn_Popup {
229
 
230
  if ( !isset( $details[$field]['current'] ) ) {
231
  echo 'will be set to <strong>';
232
- echo htmlspecialchars( $details[$field]['new'] );
233
  echo '</strong>';
234
  } elseif ( $details[$field]['current'] == $details[$field]['new'] ) {
235
  echo '<strong>';
236
- echo htmlspecialchars( $details[$field]['new'] );
237
  echo '</strong>';
238
  } else {
239
  echo 'currently set to <strong>';
240
- echo htmlspecialchars( $details[$field]['current'] );
241
  echo '</strong><br />';
242
- echo '<label class="w3tc_change_label"><input type="checkbox" name="' . $field . '_change" value="y"' .
243
  ' checked="checked" /> ';
244
  echo 'change to <strong>';
245
- echo htmlspecialchars( $details[$field]['new'] );
246
  echo '</strong></label><br />';
247
  }
248
  }
@@ -263,7 +263,7 @@ class Cdn_MaxCdn_Popup {
263
  echo 'currently set to <strong>';
264
  $this->render_zone_boolean( $details[$field]['current'] );
265
  echo '</strong><br />';
266
- echo '<input type="checkbox" name="' . $field . '_change" value="y"' .
267
  ' checked="checked" /> ';
268
  echo 'change to <strong>';
269
  $this->render_zone_boolean( $details[$field]['new'] );
49
 
50
 
51
  public function w3tc_ajax_cdn_maxcdn_list_zones() {
52
+ $api_key = Util_Request::get_string( 'api_key' );
53
 
54
  $api = \NetDNA::create( $api_key );
55
  if ( !$api->is_valid() ) {
89
 
90
  public function w3tc_ajax_cdn_maxcdn_view_zone() {
91
  $config = Dispatcher::config();
92
+ $api_key = Util_Request::get_string( 'api_key' );
93
+ $zone_id = Util_Request::get_string( 'zone_id', '' );
94
 
95
  $details = array(
96
  'api_key' => $api_key,
155
 
156
 
157
  public function w3tc_ajax_cdn_maxcdn_configure_zone() {
158
+ $api_key = Util_Request::get_string( 'api_key' );
159
  $zone_id = Util_Request::get( 'zone_id', '' );
160
 
161
  if ( empty( $zone_id ) ) {
171
  } else {
172
  $zone = array();
173
 
174
+ if ( ! empty( Util_Request::get_string( 'url_change' ) ) ) {
175
+ $zone['url'] = Util_Request::get_string( 'url' );
176
  }
177
+ if ( ! empty( Util_Request::get_string( 'compress_change' ) ) ) {
178
+ $zone['compress'] = Util_Request::get_string( 'compress' );
179
  }
180
+ if ( ! empty( Util_Request::get_string( 'cors_headers_change' ) ) ) {
181
+ $zone['cors_headers'] = Util_Request::get_string( 'cors_headers' );
182
  }
183
+ if ( Util_Request::get_string( 'ssl' ) == 'shared' ) {
184
  $zone['sslshared'] = 1;
185
  $zone['http2'] = 1;
186
  }
229
 
230
  if ( !isset( $details[$field]['current'] ) ) {
231
  echo 'will be set to <strong>';
232
+ echo esc_html( $details[ $field ]['new'] );
233
  echo '</strong>';
234
  } elseif ( $details[$field]['current'] == $details[$field]['new'] ) {
235
  echo '<strong>';
236
+ echo esc_html( $details[ $field ]['new'] );
237
  echo '</strong>';
238
  } else {
239
  echo 'currently set to <strong>';
240
+ echo esc_html( $details[ $field ]['current'] );
241
  echo '</strong><br />';
242
+ echo '<label class="w3tc_change_label"><input type="checkbox" name="' . esc_attr( $field ) . '_change" value="y"' .
243
  ' checked="checked" /> ';
244
  echo 'change to <strong>';
245
+ echo esc_html( $details[ $field ]['new'] );
246
  echo '</strong></label><br />';
247
  }
248
  }
263
  echo 'currently set to <strong>';
264
  $this->render_zone_boolean( $details[$field]['current'] );
265
  echo '</strong><br />';
266
+ echo '<input type="checkbox" name="' . esc_attr( $field ) . '_change" value="y"' .
267
  ' checked="checked" /> ';
268
  echo 'change to <strong>';
269
  $this->render_zone_boolean( $details[$field]['new'] );
Cdn_MaxCdn_Popup_View_Intro.php CHANGED
@@ -1,27 +1,28 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_maxcdn_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 MaxCDN 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
  <p class="description">
23
  To obtain API key you can
24
- <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
25
  log in, and paste the key in above field.
26
  </p>
27
  </td>
@@ -31,7 +32,7 @@ if ( isset( $details['error_message'] ) )
31
  <p class="submit">
32
  <input type="button"
33
  class="w3tc_cdn_maxcdn_list_zones w3tc-button-save button-primary"
34
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
35
  </p>
36
  <?php Util_Ui::postbox_footer(); ?>
37
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_maxcdn_form">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your MaxCDN Account credentials', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
  <td>API Key:</td>
19
  <td>
20
  <input name="api_key" type="text" class="w3tc-ignore-change"
21
  style="width: 550px"
22
+ value="<?php echo esc_attr( $details['api_key'] ); ?>" />
23
  <p 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
  </p>
28
  </td>
32
  <p class="submit">
33
  <input type="button"
34
  class="w3tc_cdn_maxcdn_list_zones w3tc-button-save button-primary"
35
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
36
  </p>
37
  <?php Util_Ui::postbox_footer(); ?>
38
  </div>
Cdn_MaxCdn_Popup_View_Success.php CHANGED
@@ -1,23 +1,23 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_maxcdn_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
- Pull Zone was successfully configured.<br />
14
- </div>
15
 
16
- <p class="submit">
17
- <input type="button"
18
- class="w3tc_cdn_maxcdn_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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_maxcdn_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ Pull Zone was successfully configured.<br />
14
+ </div>
15
 
16
+ <p class="submit">
17
+ <input type="button"
18
+ class="w3tc_cdn_maxcdn_done w3tc-button-save button-primary"
19
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
20
+ </p>
21
+ <?php Util_Ui::postbox_footer(); ?>
22
+ </div>
23
  </form>
Cdn_MaxCdn_Popup_View_Zone.php CHANGED
@@ -1,55 +1,57 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_maxcdn_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
11
- Util_Ui::hidden( '', 'name', $details['name'] );
12
- ?>
13
 
14
- <div class="metabox-holder">
15
- <?php Util_Ui::postbox_header( __( 'Configure zone', 'w3-total-cache' ) ); ?>
16
- <table class="form-table">
17
- <tr>
18
- <th>Name:</th>
19
- <td><?php echo $details['name'] ?></td>
20
- </tr>
21
- <tr>
22
- <th>Origin URL:</th>
23
- <td><?php $this->render_zone_textbox_change( $details, 'url' ) ?></td>
24
- </tr>
25
- <tr>
26
- <th>Compress content:</th>
27
- <td><?php $this->render_zone_boolean_change( $details, 'compress' ) ?></td>
28
- </tr>
29
- <tr>
30
- <th>Add CORS header:</th>
31
- <td><?php $this->render_zone_boolean_change( $details, 'cors_headers' ) ?></td>
32
- </tr>
33
- <tr>
34
- <th>HTTPS support:</th>
35
- <td>
36
- <?php if ( !is_null( $details['ssl']['current'] ) ): ?>
37
- <strong>
38
- <?php
39
- $v = $details['ssl']['current'];
40
- if ( $v == 'dedicated' )
41
- echo 'Dedicated';
42
- elseif ( $v == 'sni' )
43
- echo 'SNI';
44
- elseif ( $v == 'shared' )
45
- echo 'Shared';
46
- else
47
- echo 'Not active';
48
- ?>
49
- </strong><br />
50
- <?php endif ?>
51
- <?php if ( !is_null( $details['ssl']['new'] ) ): ?>
52
- <?php Util_Ui::hidden( '', 'ssl', $details['ssl']['new'] ); ?>
 
53
  <label>
54
  <input type="radio" name="ssl" value="" checked="" /> Leave as is
55
  </label>
@@ -59,16 +61,16 @@ Util_Ui::hidden( '', 'name', $details['name'] );
59
  Enable Shared HTTPS
60
  </label>
61
  <br />
62
- <?php endif ?>
63
- </td>
64
- </tr>
65
- </table>
66
 
67
- <p class="submit">
68
- <input type="button"
69
- class="w3tc_cdn_maxcdn_configure_zone w3tc-button-save button-primary"
70
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
71
- </p>
72
- <?php Util_Ui::postbox_footer(); ?>
73
- </div>
74
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_maxcdn_form" method="post">
9
+ <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
12
+ Util_Ui::hidden( '', 'name', $details['name'] );
13
+ ?>
14
 
15
+ <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Configure zone', 'w3-total-cache' ) ); ?>
17
+ <table class="form-table">
18
+ <tr>
19
+ <th>Name:</th>
20
+ <td><?php echo esc_html( $details['name'] ); ?></td>
21
+ </tr>
22
+ <tr>
23
+ <th>Origin URL:</th>
24
+ <td><?php $this->render_zone_textbox_change( $details, 'url' ); ?></td>
25
+ </tr>
26
+ <tr>
27
+ <th>Compress content:</th>
28
+ <td><?php $this->render_zone_boolean_change( $details, 'compress' ); ?></td>
29
+ </tr>
30
+ <tr>
31
+ <th>Add CORS header:</th>
32
+ <td><?php $this->render_zone_boolean_change( $details, 'cors_headers' ); ?></td>
33
+ </tr>
34
+ <tr>
35
+ <th>HTTPS support:</th>
36
+ <td>
37
+ <?php if ( ! is_null( $details['ssl']['current'] ) ) : ?>
38
+ <strong>
39
+ <?php
40
+ $v = $details['ssl']['current'];
41
+ if ( 'dedicated' === $v ) {
42
+ esc_html_e( 'Dedicated', 'w3-total-cache' );
43
+ } elseif ( 'sni' === $v ) {
44
+ esc_html_e( 'SNI', 'w3-total-cache' );
45
+ } elseif ( 'shared' === $v ) {
46
+ esc_html_e( 'Shared', 'w3-total-cache' );
47
+ } else {
48
+ esc_html_e( 'Not active', 'w3-total-cache' );
49
+ }
50
+ ?>
51
+ </strong><br />
52
+ <?php endif; ?>
53
+ <?php if ( ! is_null( $details['ssl']['new'] ) ) : ?>
54
+ <?php Util_Ui::hidden( '', 'ssl', $details['ssl']['new'] ); ?>
55
  <label>
56
  <input type="radio" name="ssl" value="" checked="" /> Leave as is
57
  </label>
61
  Enable Shared HTTPS
62
  </label>
63
  <br />
64
+ <?php endif; ?>
65
+ </td>
66
+ </tr>
67
+ </table>
68
 
69
+ <p class="submit">
70
+ <input type="button"
71
+ class="w3tc_cdn_maxcdn_configure_zone w3tc-button-save button-primary"
72
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
73
+ </p>
74
+ <?php Util_Ui::postbox_footer(); ?>
75
+ </div>
76
  </form>
Cdn_MaxCdn_Popup_View_Zones.php CHANGED
@@ -1,53 +1,55 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_maxcdn_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- ?>
11
- <div class="metabox-holder">
12
- <?php Util_Ui::postbox_header( __( 'Select zone to use', 'w3-total-cache' ) ); ?>
13
- <table class="form-table">
14
- <tr>
15
- <td>Zone:</td>
16
- <td>
17
- <?php
18
- if ( count( $details['zones'] ) > 15 )
19
- echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
- ?>
 
21
 
22
- <?php foreach ( $details['zones'] as $zone ): ?>
23
- <label>
24
- <input name="zone_id" type="radio" class="w3tc-ignore-change"
25
- value="<?php echo $zone['id'] ?>" />
26
- <?php echo $zone['name'] ?>
27
- (<?php echo $zone['cdn_url'] ?>)
28
- </label><br />
29
- <?php endforeach ?>
30
 
31
- <label>
32
- <input name="zone_id" type="radio" class="w3tc-ignore-change" value=""
33
- />
34
- Add new zone:
35
- </label>
36
- <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
37
 
38
- <?php
39
- if ( count( $details['zones'] ) > 15 )
40
- echo '</div>';
41
- ?>
42
- </td>
43
- </tr>
44
- </table>
 
45
 
46
- <p class="submit">
47
- <input type="button"
48
- class="w3tc_cdn_maxcdn_view_zone w3tc-button-save button-primary"
49
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
50
- </p>
51
- <?php Util_Ui::postbox_footer(); ?>
52
- </div>
53
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_maxcdn_form" method="post">
9
+ <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ ?>
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( esc_html__( 'Select zone to use', 'w3-total-cache' ) ); ?>
14
+ <table class="form-table">
15
+ <tr>
16
+ <td>Zone:</td>
17
+ <td>
18
+ <?php
19
+ if ( count( $details['zones'] ) > 15 ) {
20
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
21
+ }
22
+ ?>
23
 
24
+ <?php foreach ( $details['zones'] as $zone ) : ?>
25
+ <label>
26
+ <input name="zone_id" type="radio" class="w3tc-ignore-change"
27
+ value="<?php echo esc_attr( $zone['id'] ); ?>" />
28
+ <?php echo esc_html( $zone['name'] ); ?>
29
+ (<?php echo esc_html( $zone['cdn_url'] ); ?>)
30
+ </label><br />
31
+ <?php endforeach ?>
32
 
33
+ <label>
34
+ <input name="zone_id" type="radio" class="w3tc-ignore-change" value="" />
35
+ Add new zone:
36
+ </label>
37
+ <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
 
38
 
39
+ <?php
40
+ if ( count( $details['zones'] ) > 15 ) {
41
+ echo '</div>';
42
+ }
43
+ ?>
44
+ </td>
45
+ </tr>
46
+ </table>
47
 
48
+ <p class="submit">
49
+ <input type="button"
50
+ class="w3tc_cdn_maxcdn_view_zone w3tc-button-save button-primary"
51
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
52
+ </p>
53
+ <?php Util_Ui::postbox_footer(); ?>
54
+ </div>
55
  </form>
Cdn_Page.php CHANGED
@@ -56,7 +56,7 @@ class Cdn_Page extends Base_Page_Settings {
56
  return $parse_url['host'];
57
  }
58
 
59
- return $_SERVER['HTTP_HOST'];
60
  }
61
 
62
  /**
56
  return $parse_url['host'];
57
  }
58
 
59
+ return isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
60
  }
61
 
62
  /**
Cdn_Page_View_Fsd_HeaderActions.php CHANGED
@@ -1,14 +1,37 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <p>
9
  <?php
10
- echo Util_Ui::button_link(
11
- __( 'Purge <acronym title="Content Delivery Network">CDN</acronym> completely', 'w3-total-cache' ),
12
- Util_Ui::url( array( 'w3tc_cdn_flush' => 'y' ) ) );
13
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  </p>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <p>
9
  <?php
10
+ echo wp_kses(
11
+ sprintf(
12
+ Util_Ui::button_link(
13
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
14
+ __(
15
+ 'Purge %1$sCDN%2$s completely',
16
+ 'w3-total-cache'
17
+ ),
18
+ Util_Ui::url( array( 'w3tc_cdn_flush' => 'y' ) )
19
+ ),
20
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
21
+ '</acronym>'
22
+ ),
23
+ array(
24
+ 'input' => array(
25
+ 'type' => array(),
26
+ 'name' => array(),
27
+ 'class' => array(),
28
+ 'value' => array(),
29
+ 'onclick' => array(),
30
+ ),
31
+ 'acronym' => array(
32
+ 'title' => array(),
33
+ ),
34
+ )
35
+ );
36
+ ?>
37
  </p>
Cdn_Page_View_Header.php CHANGED
@@ -1,16 +1,30 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
- <?php include W3TC_INC_DIR . '/options/common/header.php'; ?>
9
 
10
  <p>
11
- <?php echo sprintf(
12
- __( 'Content Delivery Network support via %1$s is currently %2$s.', 'w3-total-cache' ),
13
- '<strong>'.Cache::engine_name( $config->get_string( 'cdn.engine' ) ).'</strong>',
14
- '<span class="w3tc-' . ( $config->get_boolean( 'cdn.enabled' ) ? 'enabled">' . __( 'enabled', 'w3-total-cache' ) : 'disabled">' . __( 'disabled', 'w3-total-cache' ) ) . '</span>'
15
- ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  </p>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <?php require W3TC_INC_DIR . '/options/common/header.php'; ?>
9
 
10
  <p>
11
+ <?php
12
+ echo wp_kses(
13
+ sprintf(
14
+ // translators: 1 HTML strong element with CDN engine content, 2 HTML span element with CDN enabled/disabled status.
15
+ __(
16
+ 'Content Delivery Network support via %1$s is currently %2$s.',
17
+ 'w3-total-cache'
18
+ ),
19
+ '<strong>' . esc_html( Cache::engine_name( $config->get_string( 'cdn.engine' ) ) ) . '</strong>',
20
+ '<span class="w3tc-' . ( $config->get_boolean( 'cdn.enabled' ) ? 'enabled">' . __( 'enabled', 'w3-total-cache' ) : 'disabled">' . __( 'disabled', 'w3-total-cache' ) ) . '</span>'
21
+ ),
22
+ array(
23
+ 'strong' => array(),
24
+ 'span' => array(
25
+ 'class' => array(),
26
+ ),
27
+ )
28
+ );
29
+ ?>
30
  </p>
Cdn_Plugin.php CHANGED
@@ -435,7 +435,6 @@ class Cdn_Plugin {
435
  } else {
436
  foreach ( $urls as $url ) {
437
  $file = Util_Environment::normalize_file_minify( $url );
438
- $file = Util_Environment::translate_file( $file );
439
 
440
  if ( !Util_Environment::is_url( $file ) ) {
441
  $file = $document_root . '/' . $file;
@@ -607,10 +606,9 @@ class Cdn_Plugin {
607
 
608
  foreach ( $uas as $ua ) {
609
  if ( !empty( $ua ) ) {
610
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && stristr(
611
- $_SERVER['HTTP_USER_AGENT'], $ua ) !== false
612
- )
613
  return false;
 
614
  }
615
  }
616
 
@@ -630,7 +628,7 @@ class Cdn_Plugin {
630
  $expr = trim( $expr );
631
  $expr = str_replace( '~', '\~', $expr );
632
 
633
- if ( $expr != '' && preg_match( '~' . $expr . '~i', $_SERVER['REQUEST_URI'] ) ) {
634
  return false;
635
  }
636
  }
435
  } else {
436
  foreach ( $urls as $url ) {
437
  $file = Util_Environment::normalize_file_minify( $url );
 
438
 
439
  if ( !Util_Environment::is_url( $file ) ) {
440
  $file = $document_root . '/' . $file;
606
 
607
  foreach ( $uas as $ua ) {
608
  if ( !empty( $ua ) ) {
609
+ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && stristr( sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ), $ua ) !== false ) {
 
 
610
  return false;
611
+ }
612
  }
613
  }
614
 
628
  $expr = trim( $expr );
629
  $expr = str_replace( '~', '\~', $expr );
630
 
631
+ if ( $expr != '' && preg_match( '~' . $expr . '~i', isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' ) ) {
632
  return false;
633
  }
634
  }
Cdn_Plugin_WidgetMaxCdn.php CHANGED
@@ -38,11 +38,6 @@ class Cdn_Plugin_WidgetMaxCdn {
38
 
39
  add_action( 'w3tc_ajax_cdn_maxcdn_widgetdata', array(
40
  $this, 'w3tc_ajax_cdn_maxcdn_widgetdata' ) );
41
-
42
- if ( $this->have_zone && $this->authorized && isset( $_GET['page'] ) &&
43
- strpos( $_GET['page'], 'w3tc_dashboard' ) !== false ) {
44
-
45
- }
46
  }
47
 
48
  function w3tc_ajax_cdn_maxcdn_widgetdata() {
38
 
39
  add_action( 'w3tc_ajax_cdn_maxcdn_widgetdata', array(
40
  $this, 'w3tc_ajax_cdn_maxcdn_widgetdata' ) );
 
 
 
 
 
41
  }
42
 
43
  function w3tc_ajax_cdn_maxcdn_widgetdata() {
Cdn_Plugin_WidgetMaxCdn_View_Authorized.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  /**
8
  *
9
  *
@@ -17,70 +17,70 @@ if ( !defined( 'W3TC' ) )
17
  ?>
18
  <div class="w3tcmaxcdn_loading w3tc_loading w3tc_hidden">Loading...</div>
19
  <div class="w3tcmaxcdn_error w3tc_none">
20
- An error occurred
21
- <div class="w3tcmaxcdn_error_details"></div>
22
  </div>
23
 
24
  <div id="maxcdn-widget" class="maxcdn-netdna-widget-base w3tcmaxcdn_content w3tc_hidden">
25
- <div class="w3tcmaxcdn_wrapper">
26
- <div class="w3tcmaxcdn_status">
27
- <p>
28
- <span>
29
- <?php _e( 'Status', 'w3-total-cache' ) ?>
30
- <span class="w3tcmaxcdn_account_status"></span>
31
- </span>
32
- <span style="display:inline-block;float:right">
33
- <?php _e( 'Content Zone:', 'w3-total-cache' ) ?>
34
- <span class="w3tcmaxcdn_zone_name"></span>
35
- </span>
36
- </p>
37
 
38
- </div>
39
- <div class="w3tcmaxcdn_tools">
40
- <ul class="w3tcmaxcdn_ul">
41
- <li><a class="button w3tcmaxcdn_href_manage" href=""><?php _e( 'Manage', 'w3-total-cache' )?></a></li>
42
- <li><a class="button w3tcmaxcdn_href_reports" href=""><?php _e( 'Reports', 'w3-total-cache' )?></a></li>
43
- <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>
44
- </ul>
45
- </div>
46
- <div class="w3tcmaxcdn_summary">
47
- <h4 class="w3tcmaxcdn_summary_h4"><?php _e( 'Report - 30 days', 'w3-total-cache' ) ?></h4>
48
- </div>
49
- <ul class="w3tcmaxcdn_ul">
50
- <li>
51
- <span class="w3tcmaxcdn_summary_col1"><?php _e('Transferred', 'w3-total-cache') ?>:</span>
52
- <span class="w3tcmaxcdn_summary_col2 w3tcmaxcdn_summary_size"></span>
53
- </li>
54
- <li>
55
- <span class="w3tcmaxcdn_summary_col1"><?php _e('Cache Hits', 'w3-total-cache' ) ?>:</span>
56
- <span class="w3tcmaxcdn_summary_col2">
57
- <span class="w3tcmaxcdn_summary_cache_hit"></span>
58
- (<span class="w3tcmaxcdn_summary_cache_hit_percentage"></span>)
59
- </span>
60
- </li>
61
- <li>
62
- <span class="w3tcmaxcdn_summary_col1"><?php _e('Cache Misses', 'w3-total-cache') ?>:</span>
63
- <span class="w3tcmaxcdn_summary_col2">
64
- <span class="w3tcmaxcdn_summary_noncache_hit">
65
- (<span class="w3tcmaxcdn_summary_noncache_hit_percentage"></span>)
66
- </span>
67
- </li>
68
- </ul>
69
- <div class="w3tcmaxcdn_chart charts w3tcmaxcdn_area">
70
- <h4 class="w3tcmaxcdn_h4"><?php _e( 'Requests', 'w3-total-cache' ) ?></h4>
71
- <div id="chart_div" style="width: 320px; height: 220px;margin-left: auto ; margin-right: auto ;"></div>
72
- <h4 class="w3tcmaxcdn_h4"><?php _e( 'Content Breakdown', 'w3-total-cache' ) ?></h4>
73
- <p>
74
- <span><?php _e( 'File', 'w3-total-cache' )?></span>
75
- <span style="display:inline-block;float:right"><?php _e( 'Hits', 'w3-total-cache' ) ?></span>
76
- </p>
77
- <ul class="w3tcmaxcdn_file_hits">
78
- <li>A</li>
79
- <li>A</li>
80
- <li>A</li>
81
- <li>A</li>
82
- <li>A</li>
83
- </ul>
84
- </div>
85
- </div>
86
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  /**
8
  *
9
  *
17
  ?>
18
  <div class="w3tcmaxcdn_loading w3tc_loading w3tc_hidden">Loading...</div>
19
  <div class="w3tcmaxcdn_error w3tc_none">
20
+ An error occurred
21
+ <div class="w3tcmaxcdn_error_details"></div>
22
  </div>
23
 
24
  <div id="maxcdn-widget" class="maxcdn-netdna-widget-base w3tcmaxcdn_content w3tc_hidden">
25
+ <div class="w3tcmaxcdn_wrapper">
26
+ <div class="w3tcmaxcdn_status">
27
+ <p>
28
+ <span>
29
+ <?php esc_html_e( 'Status', 'w3-total-cache' ); ?>
30
+ <span class="w3tcmaxcdn_account_status"></span>
31
+ </span>
32
+ <span style="display:inline-block;float:right">
33
+ <?php esc_html_e( 'Content Zone:', 'w3-total-cache' ); ?>
34
+ <span class="w3tcmaxcdn_zone_name"></span>
35
+ </span>
36
+ </p>
37
 
38
+ </div>
39
+ <div class="w3tcmaxcdn_tools">
40
+ <ul class="w3tcmaxcdn_ul">
41
+ <li><a class="button w3tcmaxcdn_href_manage" href=""><?php esc_html_e( 'Manage', 'w3-total-cache' ); ?></a></li>
42
+ <li><a class="button w3tcmaxcdn_href_reports" href=""><?php esc_html_e( 'Reports', 'w3-total-cache' ); ?></a></li>
43
+ <li><a class="button" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=w3tc_cdn&amp;w3tc_cdn_purge' ) ) ); ?>" onclick="w3tc_popupadmin_bar(this.href); return false"><?php esc_html_e( 'Purge', 'w3-total-cache' ); ?></a></li>
44
+ </ul>
45
+ </div>
46
+ <div class="w3tcmaxcdn_summary">
47
+ <h4 class="w3tcmaxcdn_summary_h4"><?php esc_html_e( 'Report - 30 days', 'w3-total-cache' ); ?></h4>
48
+ </div>
49
+ <ul class="w3tcmaxcdn_ul">
50
+ <li>
51
+ <span class="w3tcmaxcdn_summary_col1"><?php esc_html_e( 'Transferred', 'w3-total-cache' ); ?>:</span>
52
+ <span class="w3tcmaxcdn_summary_col2 w3tcmaxcdn_summary_size"></span>
53
+ </li>
54
+ <li>
55
+ <span class="w3tcmaxcdn_summary_col1"><?php esc_html_e( 'Cache Hits', 'w3-total-cache' ); ?>:</span>
56
+ <span class="w3tcmaxcdn_summary_col2">
57
+ <span class="w3tcmaxcdn_summary_cache_hit"></span>
58
+ (<span class="w3tcmaxcdn_summary_cache_hit_percentage"></span>)
59
+ </span>
60
+ </li>
61
+ <li>
62
+ <span class="w3tcmaxcdn_summary_col1"><?php esc_html_e( 'Cache Misses', 'w3-total-cache' ); ?>:</span>
63
+ <span class="w3tcmaxcdn_summary_col2">
64
+ <span class="w3tcmaxcdn_summary_noncache_hit">
65
+ (<span class="w3tcmaxcdn_summary_noncache_hit_percentage"></span>)
66
+ </span>
67
+ </li>
68
+ </ul>
69
+ <div class="w3tcmaxcdn_chart charts w3tcmaxcdn_area">
70
+ <h4 class="w3tcmaxcdn_h4"><?php esc_html_e( 'Requests', 'w3-total-cache' ); ?></h4>
71
+ <div id="chart_div" style="width: 320px; height: 220px;margin-left: auto ; margin-right: auto ;"></div>
72
+ <h4 class="w3tcmaxcdn_h4"><?php esc_html_e( 'Content Breakdown', 'w3-total-cache' ); ?></h4>
73
+ <p>
74
+ <span><?php esc_html_e( 'File', 'w3-total-cache' ); ?></span>
75
+ <span style="display:inline-block;float:right"><?php esc_html_e( 'Hits', 'w3-total-cache' ); ?></span>
76
+ </p>
77
+ <ul class="w3tcmaxcdn_file_hits">
78
+ <li>A</li>
79
+ <li>A</li>
80
+ <li>A</li>
81
+ <li>A</li>
82
+ <li>A</li>
83
+ </ul>
84
+ </div>
85
+ </div>
86
  </div>
Cdn_Plugin_WidgetMaxCdn_View_Unauthorized.php CHANGED
@@ -1,17 +1,55 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div id="maxcdn-widget" class="w3tcmaxcdn_signup">
9
+ <p>
10
+ <?php
11
+ echo wp_kses(
12
+ sprintf(
13
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
14
+ __(
15
+ 'Dramatically increase website speeds in just a few clicks! Add the MaxCDN content delivery network (%1$sCDN%2$s) service to your site.',
16
+ 'w3-total-cache'
17
+ ),
18
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
19
+ '</acronym>'
20
+ ),
21
+ array(
22
+ 'acronym' => array(
23
+ 'title' => array(),
24
+ ),
25
+ )
26
+ );
27
+ ?>
28
+ </p>
29
+ <h4 class="w3tcmaxcdn_signup_h4"><?php esc_html_e( 'New customers', 'w3-total-cache' ); ?></h4>
30
+ <p><?php esc_html_e( 'MaxCDN works magically with W3 Total Cache.', 'w3-total-cache' ); ?></p>
31
+ <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ); ?>" target="_blank"><?php esc_html_e( 'Create an Account', 'w3-total-cache' ); ?></a>
32
+ <p><span class="desc"><?php esc_html_e( 'Exclusive offers availabel for W3TC users!', 'w3-total-cache' ); ?></span></p>
33
+ <h4 class="w3tcmaxcdn_signup_h4"><?php esc_html_e( 'Current customers', 'w3-total-cache' ); ?></h4>
34
+ <p>
35
+ <?php
36
+ echo wp_kses(
37
+ sprintf(
38
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
39
+ __(
40
+ 'Existing MaxCDN customers, enable %1$sCDN%2$s and:',
41
+ 'w3-total-cache'
42
+ ),
43
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
44
+ '</acronym>'
45
+ ),
46
+ array(
47
+ 'acronym' => array(
48
+ 'title' => array(),
49
+ ),
50
+ )
51
+ );
52
+ ?>
53
+ </p>
54
+ <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' ) ); ?>" target="_blank"><?php esc_html_e( 'Authorize', 'w3-total-cache' ); ?></a>
55
  </div>
Cdn_RackSpaceCdn_Page_View.php CHANGED
@@ -1,81 +1,171 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
  ?>
8
  <tr>
9
- <th style="width: 300px;"><label><?php _e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
10
  <td>
11
- <?php if ( $authorized ): ?>
12
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
13
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>" />
14
- <?php else: ?>
15
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
16
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>" />
17
- <?php endif ?>
18
  </td>
19
  </tr>
20
 
21
- <?php if ( $authorized ): ?>
22
- <tr>
23
- <th><?php _e( 'Username:', 'w3-total-cache' ); ?></th>
24
- <td class="w3tc_config_value_text">
25
- <?php echo $config->get_string( 'cdn.rackspace_cdn.user_name' ) ?>
26
- </td>
27
- </tr>
28
- <tr>
29
- <th><?php _e( 'Region:', 'w3-total-cache' ); ?></th>
30
- <td class="w3tc_config_value_text">
31
- <?php echo $config->get_string( 'cdn.rackspace_cdn.region' ) ?>
32
- </td>
33
- </tr>
34
- <tr>
35
- <th><?php _e( 'Service:', 'w3-total-cache' ); ?></th>
36
- <td class="w3tc_config_value_text">
37
- <?php echo $config->get_string( 'cdn.rackspace_cdn.service.name' ) ?>
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>
45
- </tr>
46
- <?php if ( $config->get_string( 'cdn.rackspace_cdn.service.protocol' ) == 'http' ): ?>
47
- <tr>
48
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
49
- <td>
50
- <?php $cnames = $config->get_array( 'cdn.rackspace_cdn.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
51
- <input class="w3tc_cdn_rackspace_configure_domains button" type="button"
52
- value="<?php _e( 'Configure CNAMEs', 'w3-total-cache' ); ?>" />
53
- <p class="description">
54
- <?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' ); ?>
55
- </p>
56
- </td>
57
- </tr>
58
- <?php else: ?>
59
- <tr>
60
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
61
- <td>
62
- <?php $cnames = $config->get_array( 'cdn.rackspace_cdn.domains' ); include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php'; ?>
63
- <input name="w3tc_cdn_rackspace_cdn_domains_reload"
64
- class="w3tc-button-save button" type="submit"
65
- value="<?php _e( 'Reload C<acronym title="Canonical Name">CNAME</acronym>s from RackSpace', 'w3-total-cache' ); ?>" />
66
- <p class="description">
67
- <?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' ); ?>
68
- </p>
69
- </td>
70
- </tr>
71
- <?php endif ?>
72
- <tr>
73
- <th colspan="2">
74
- <input id="cdn_test"
75
- class="button {type: 'rackspace_cdn', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
76
- type="button"
77
- value="<?php _e( 'Test', 'w3-total-cache' ); ?>" />
78
- <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
79
- </th>
80
- </tr>
81
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
  ?>
9
  <tr>
10
+ <th style="width: 300px;"><label><?php esc_html_e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
11
  <td>
12
+ <?php if ( $authorized ) : ?>
13
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
14
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
15
+ <?php else : ?>
16
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
17
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
18
+ <?php endif; ?>
19
  </td>
20
  </tr>
21
 
22
+ <?php if ( $authorized ) : ?>
23
+ <tr>
24
+ <th><?php esc_html_e( 'Username:', 'w3-total-cache' ); ?></th>
25
+ <td class="w3tc_config_value_text">
26
+ <?php echo esc_html( $config->get_string( 'cdn.rackspace_cdn.user_name' ) ); ?>
27
+ </td>
28
+ </tr>
29
+ <tr>
30
+ <th><?php esc_html_e( 'Region:', 'w3-total-cache' ); ?></th>
31
+ <td class="w3tc_config_value_text">
32
+ <?php echo esc_html( $config->get_string( 'cdn.rackspace_cdn.region' ) ); ?>
33
+ </td>
34
+ </tr>
35
+ <tr>
36
+ <th><?php esc_html_e( 'Service:', 'w3-total-cache' ); ?></th>
37
+ <td class="w3tc_config_value_text">
38
+ <?php echo esc_html( $config->get_string( 'cdn.rackspace_cdn.service.name' ) ); ?>
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <th>
43
+ <label>
44
+ <?php
45
+ echo wp_kses(
46
+ sprintf(
47
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
48
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
49
+ __(
50
+ '%1$sCDN%2$s host (%3$sCNAME%4$s target):',
51
+ 'w3-total-cache'
52
+ ),
53
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
54
+ '</acronym>',
55
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
56
+ '</acronym>'
57
+ ),
58
+ array(
59
+ 'acronym' => array(
60
+ 'title' => array(),
61
+ ),
62
+ )
63
+ );
64
+ ?>
65
+ </label>
66
+ </th>
67
+ <td class="w3tc_config_value_text">
68
+ <?php echo esc_html( $access_url_full ); ?>
69
+ </td>
70
+ </tr>
71
+ <?php if ( $config->get_string( 'cdn.rackspace_cdn.service.protocol' ) === 'http' ) : ?>
72
+ <tr>
73
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
74
+ <td>
75
+ <?php
76
+ $cnames = $config->get_array( 'cdn.rackspace_cdn.domains' );
77
+ include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php';
78
+ ?>
79
+ <input class="w3tc_cdn_rackspace_configure_domains button" type="button"
80
+ value="<?php esc_attr_e( 'Configure CNAMEs', 'w3-total-cache' ); ?>" />
81
+ <p class="description">
82
+ <?php
83
+ echo wp_kses(
84
+ sprintf(
85
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
86
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
87
+ __(
88
+ 'Enter hostname mapped to %1$sCDN%2$s host, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
89
+ 'w3-total-cache'
90
+ ),
91
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
92
+ '</acronym>',
93
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
94
+ '</acronym>'
95
+ ),
96
+ array(
97
+ 'acronym' => array(
98
+ 'title' => array(),
99
+ ),
100
+ )
101
+ );
102
+ ?>
103
+ </p>
104
+ </td>
105
+ </tr>
106
+ <?php else : ?>
107
+ <tr>
108
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
109
+ <td>
110
+ <?php
111
+ $cnames = $config->get_array( 'cdn.rackspace_cdn.domains' );
112
+ include W3TC_INC_DIR . '/options/cdn/common/cnames-readonly.php';
113
+ ?>
114
+ <input name="w3tc_cdn_rackspace_cdn_domains_reload"
115
+ class="w3tc-button-save button" type="submit"
116
+ value="
117
+ <?php
118
+ echo wp_kses(
119
+ sprintf(
120
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
121
+ __(
122
+ 'Reload %1$sCNAME%2$ss from RackSpace',
123
+ 'w3-total-cache'
124
+ ),
125
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
126
+ '</acronym>'
127
+ ),
128
+ array(
129
+ 'acronym' => array(
130
+ 'title' => array(),
131
+ ),
132
+ )
133
+ );
134
+ ?>
135
+ " />
136
+ <p class="description">
137
+ <?php
138
+ echo wp_kses(
139
+ sprintf(
140
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
141
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
142
+ __(
143
+ 'Hostname(s) mapped to %1$sCDN%2$s host, this value will replace your site\'s hostname in the %3$sHTML%4$s. You can manage them from RackSpace management console and load here afterwards.',
144
+ 'w3-total-cache'
145
+ ),
146
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
147
+ '</acronym>',
148
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
149
+ '</acronym>'
150
+ ),
151
+ array(
152
+ 'acronym' => array(
153
+ 'title' => array(),
154
+ ),
155
+ )
156
+ );
157
+ ?>
158
+ </p>
159
+ </td>
160
+ </tr>
161
+ <?php endif; ?>
162
+ <tr>
163
+ <th colspan="2">
164
+ <input id="cdn_test"
165
+ class="button {type: 'rackspace_cdn', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}"
166
+ type="button"
167
+ value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
168
+ <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
169
+ </th>
170
+ </tr>
171
+ <?php endif; ?>
Cdn_RackSpaceCdn_Popup.php CHANGED
@@ -1,441 +1,421 @@
1
  <?php
2
  namespace W3TC;
3
 
4
-
5
-
6
  class Cdn_RackSpaceCdn_Popup {
7
- static public function w3tc_ajax() {
8
  $o = new Cdn_RackSpaceCdn_Popup();
9
 
10
- add_action( 'w3tc_ajax_cdn_rackspace_intro',
11
- array( $o, 'w3tc_ajax_cdn_rackspace_intro' ) );
12
- add_action( 'w3tc_ajax_cdn_rackspace_intro_done',
13
- array( $o, 'w3tc_ajax_cdn_rackspace_intro_done' ) );
14
- add_action( 'w3tc_ajax_cdn_rackspace_regions_done',
15
- array( $o, 'w3tc_ajax_cdn_rackspace_regions_done' ) );
16
- add_action( 'w3tc_ajax_cdn_rackspace_services_done',
17
- array( $o, 'w3tc_ajax_cdn_rackspace_services_done' ) );
18
- add_action( 'w3tc_ajax_cdn_rackspace_service_create_done',
19
- array( $o, 'w3tc_ajax_cdn_rackspace_service_create_done' ) );
20
- add_action( 'w3tc_ajax_cdn_rackspace_service_get_state',
21
- array( $o, 'w3tc_ajax_cdn_rackspace_service_get_state' ) );
22
- add_action( 'w3tc_ajax_cdn_rackspace_service_created_done',
23
- array( $o, 'w3tc_ajax_cdn_rackspace_service_created_done' ) );
24
- add_action( 'w3tc_ajax_cdn_rackspace_service_actualize_done',
25
- array( $o, 'w3tc_ajax_cdn_rackspace_service_actualize_done' ) );
26
-
27
- add_action( 'w3tc_ajax_cdn_rackspace_configure_domains',
28
- array( $o, 'w3tc_ajax_cdn_rackspace_configure_domains' ) );
29
- add_action( 'w3tc_ajax_cdn_rackspace_configure_domains_done',
30
- array( $o, 'w3tc_ajax_cdn_rackspace_configure_domains_done' ) );
31
-
32
  }
33
 
34
-
35
-
36
  public function w3tc_ajax_cdn_rackspace_intro() {
37
  $c = Dispatcher::config();
38
 
39
  $details = array(
40
  'user_name' => $c->get_string( 'cdn.rackspace_cdn.user_name' ),
41
- 'api_key' => $c->get_string( 'cdn.rackspace_cdn.api_key' )
42
  );
43
 
44
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
45
  exit();
46
  }
47
 
48
-
49
-
50
  public function w3tc_ajax_cdn_rackspace_intro_done() {
51
- $this->_render_cdn_rackspace_regions( array(
52
- 'user_name' => $_REQUEST['user_name'],
53
- 'api_key' => $_REQUEST['api_key'] ) );
 
 
 
54
  }
55
 
56
-
57
-
58
  private function _render_cdn_rackspace_regions( $details ) {
59
  $user_name = $details['user_name'];
60
- $api_key = $details['api_key'];
61
 
62
  try {
63
- $r = Cdn_RackSpace_Api_Tokens::authenticate( $user_name,
64
- $api_key );
65
  } catch ( \Exception $ex ) {
66
  $details = array(
67
- 'user_name' => $user_name,
68
- 'api_key' => $api_key,
69
- 'error_message' => 'Can\'t authenticate: ' . $ex->getMessage()
70
  );
71
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
72
  exit();
73
  }
74
 
75
- $r['regions'] = Cdn_RackSpace_Api_Tokens::cdn_services_by_region(
76
- $r['services'] );
77
 
78
- $details['access_token'] = $r['access_token'];
79
  $details['region_descriptors'] = $r['regions'];
80
- // avoid fights with quotes, magic_quotes may break randomly
81
- $details['region_descriptors_serialized'] =
82
- strtr( json_encode( $r['regions'] ), '"\\', '!^' );
83
 
84
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Regions.php';
 
 
 
85
  exit();
86
  }
87
 
88
-
89
-
90
  public function w3tc_ajax_cdn_rackspace_regions_done() {
91
- $user_name = $_REQUEST['user_name'];
92
- $api_key = $_REQUEST['api_key'];
93
- $access_token = $_REQUEST['access_token'];
94
- $region = Util_Request::get( 'region' );
95
  $region_descriptors = json_decode(
96
- strtr( $_REQUEST['region_descriptors'], '!^', '"\\' ), true );
97
-
98
- if ( !isset( $region_descriptors[$region] ) ) {
99
- return $this->_render_cdn_rackspace_regions( array(
100
- 'user_name' => $user_name,
101
- 'api_key' => $api_key,
102
- 'error_message' => 'Please select region ' . $region
103
- ) );
 
 
 
 
104
  }
105
 
106
- $api = new Cdn_RackSpace_Api_Cdn( array(
107
- 'access_token' => $access_token,
108
- 'access_region_descriptor' => $region_descriptors[$region],
109
- 'new_access_required' => ''
110
- ) );
 
 
111
 
112
  try {
113
  $services = $api->services();
114
  } catch ( \Exception $ex ) {
115
  $details = array(
116
- 'user_name' => $user_name,
117
- 'api_key' => $api_key,
118
- 'error_message' => $ex->getMessage()
119
  );
120
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
121
  exit();
122
  }
123
 
124
  $details = array(
125
- 'user_name' => $user_name,
126
- 'api_key' => $api_key,
127
- 'access_token' => $access_token,
128
- 'access_region_descriptor_serialized' =>
129
- strtr( json_encode( $region_descriptors[$region] ), '"\\', '!^' ),
130
- 'region' => $region,
131
- // avoid fights with quotes, magic_quotes may break randomly
132
- 'services' => $services
133
  );
134
 
135
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Services.php';
136
  exit();
137
  }
138
 
139
-
140
-
141
  public function w3tc_ajax_cdn_rackspace_services_done() {
142
- $user_name = $_REQUEST['user_name'];
143
- $api_key = $_REQUEST['api_key'];
144
- $access_token = $_REQUEST['access_token'];
145
- $access_region_descriptor = json_decode(
146
- strtr( $_REQUEST['access_region_descriptor'], '!^', '"\\' ), true );
147
- $region = $_REQUEST['region'];
148
- $service = Util_Request::get( 'service' );
149
 
150
  if ( !empty( $service ) ) {
151
- $this->_render_service_actualize( array(
152
- 'user_name' => $user_name,
153
- 'api_key' => $api_key,
154
- 'access_token' => $access_token,
155
- 'access_region_descriptor_serialized' =>
156
- strtr( json_encode( $access_region_descriptor ), '"\\', '!^' ),
157
- 'region' => $region,
158
- 'service_id' => $service
159
- ) );
 
 
160
  exit();
161
  }
162
 
163
  $home_url = get_home_url();
164
- $parsed = parse_url( $home_url );
165
 
166
- $is_https = ( $parsed['scheme'] == 'https' );
167
 
168
  $details = array(
169
- 'user_name' => $user_name,
170
- 'api_key' => $api_key,
171
- 'access_token' => $access_token,
172
- 'access_region_descriptor_serialized' =>
173
- strtr( json_encode( $access_region_descriptor ), '"\\', '!^' ),
174
- 'region' => $region,
175
- 'name' => '',
176
- 'protocol' => ( $is_https ? 'https' : 'http' ),
177
- 'cname_http' => '',
178
- 'cname_http_style' => ( $is_https ? 'display: none' : '' ),
179
- 'cname_https_prefix' => '',
180
- 'cname_https_style' => ( $is_https ? '' : 'display: none' ),
181
- 'origin' => Util_Environment::home_url_host()
182
  );
183
 
184
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Create.php';
185
  exit();
186
  }
187
 
188
-
189
-
190
  public function w3tc_ajax_cdn_rackspace_service_create_done() {
191
- $user_name = $_REQUEST['user_name'];
192
- $api_key = $_REQUEST['api_key'];
193
- $access_token = $_REQUEST['access_token'];
194
- $access_region_descriptor = json_decode(
195
- strtr( $_REQUEST['access_region_descriptor'], '!^', '"\\' ), true );
196
- $region = $_REQUEST['region'];
197
-
198
- $name = $_REQUEST['name'];
199
- $protocol = $_REQUEST['protocol'];
200
- $cname_http = $_REQUEST['cname_http'];
201
- $cname_https_prefix = $_REQUEST['cname_https_prefix'];
202
-
203
- $is_https = ( $protocol == 'https' );
204
- $cname = ( $is_https ? $cname_https_prefix : $cname_http );
205
-
206
- $api = new Cdn_RackSpace_Api_Cdn( array(
207
- 'access_token' => $access_token,
208
  'access_region_descriptor' => $access_region_descriptor,
209
- 'new_access_required' => ''
210
- ) );
211
-
212
- $service_id = null;
213
- $access_url = null;
214
 
215
  try {
216
  $domain = array(
217
- 'domain' => $cname,
218
- 'protocol' => ( $is_https ? 'https' : 'http' )
219
  );
220
- if ( $is_https )
 
221
  $domain['certificate'] = 'shared';
 
222
 
223
- $service_id = $api->service_create( array(
224
- 'name' => $name,
 
225
  'domains' => array( $domain ),
226
  'origins' => array(
227
  array(
228
- 'origin' => Util_Environment::home_url_host(),
229
- 'port' => ( $is_https ? 443 : 80 ),
230
- 'ssl' => $is_https,
231
  'hostheadertype' => 'origin',
232
- 'rules' => array()
233
- )
234
  ),
235
  'caching' => array(
236
  array(
237
  'name' => 'default',
238
- 'ttl' => 86400
239
- )
240
- )
241
- ) );
 
242
  } catch ( \Exception $ex ) {
243
  $details = array(
244
- 'user_name' => $user_name,
245
- 'api_key' => $api_key,
246
- 'access_token' => $access_token,
247
- 'access_region_descriptor_serialized' =>
248
- strtr( json_encode( $access_region_descriptor ), '"\\', '!^' ),
249
- 'region' => $region,
250
- 'name' => $name,
251
- 'protocol' => ( $is_https ? 'https' : 'http' ),
252
- 'cname_http' => $cname_http,
253
- 'cname_http_style' => ( $is_https ? 'display: none' : '' ),
254
- 'cname_https_prefix' => $cname_https_prefix,
255
- 'cname_https_style' => ( $is_https ? '' : 'display: none' ),
256
- 'origin' => Util_Environment::home_url_host(),
257
- 'error_message' => $ex->getMessage()
258
  );
259
 
260
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Create.php';
261
  exit();
262
  }
263
 
264
  $details = array(
265
- 'user_name' => $user_name,
266
- 'api_key' => $api_key,
267
- 'access_token' => $access_token,
268
- 'access_region_descriptor_serialized' =>
269
- strtr( json_encode( $access_region_descriptor ), '"\\', '!^' ),
270
- 'region' => $region,
271
- 'name' => $name,
272
- 'is_https' => $is_https,
273
- 'cname' => $cname,
274
- 'service_id' => $service_id
275
  );
276
 
277
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Created.php';
278
  }
279
 
280
-
281
-
282
- // ajax returning json for js-script about service state
283
  public function w3tc_ajax_cdn_rackspace_service_get_state() {
284
- $access_token = $_REQUEST['access_token'];
285
- $access_region_descriptor = json_decode(
286
- strtr( $_REQUEST['access_region_descriptor'], '!^', '"\\' ), true );
287
- $service_id = $_REQUEST['service_id'];
288
-
289
- $api = new Cdn_RackSpace_Api_Cdn( array(
290
- 'access_token' => $access_token,
291
  'access_region_descriptor' => $access_region_descriptor,
292
- 'new_access_required' => ''
293
- ) );
294
-
295
- $service = $api->service_get( $service_id );
296
-
297
- $response = array( 'status' => 'Unknown' );
298
 
299
- if ( isset( $service['status'] ) )
300
  $response['status'] = $service['status'];
301
- if ( isset( $service['links_by_rel']['access_url'] ) )
 
 
302
  $response['access_url'] = $service['links_by_rel']['access_url']['href'];
303
- if ( isset( $service['domains'] ) )
 
 
304
  $response['cname'] = $service['domains'][0]['domain'];
 
305
 
306
- // decode to friendly name
307
- if ( $response['status'] == 'create_in_progress' )
308
  $response['status'] = 'Creation in progress...';
 
309
 
310
- echo json_encode( $response );
311
  }
312
 
313
-
314
-
315
  public function w3tc_ajax_cdn_rackspace_service_created_done() {
316
  $this->_save_config();
317
  }
318
 
319
-
320
-
321
  private function _render_service_actualize( $details ) {
322
- $access_region_descriptor = json_decode(
323
- strtr( $details['access_region_descriptor_serialized'],
324
- '!^', '"\\' ), true );
325
 
326
- $api = new Cdn_RackSpace_Api_Cdn( array(
327
- 'access_token' => $details['access_token'],
 
328
  'access_region_descriptor' => $access_region_descriptor,
329
- 'new_access_required' => ''
330
- ) );
 
331
 
332
  $service = null;
333
  try {
334
  $service = $api->service_get( $details['service_id'] );
335
  } catch ( \Exception $ex ) {
336
  $details['error_message'] = $ex->getMessage();
337
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
338
  exit();
339
  }
340
 
341
- $origin = '';
342
  $protocol = 'http';
343
  if ( isset( $service['origins'] ) && $service['origins'][0]['origin'] ) {
344
  $protocol = $service['origins'][0]['ssl'] ? 'https' : 'http';
345
- $origin = $service['origins'][0]['origin'];
346
  }
347
 
348
- $details['name'] = $service['name'];
349
  $details['protocol'] = $protocol;
350
- $details['origin'] = array(
351
  'current' => $origin,
352
- 'new' => Util_Environment::home_url_host()
353
  );
354
 
355
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Actualize.php';
356
  exit();
357
  }
358
 
359
-
360
-
361
  public function w3tc_ajax_cdn_rackspace_service_actualize_done() {
362
- $user_name = $_REQUEST['user_name'];
363
- $api_key = $_REQUEST['api_key'];
364
- $access_token = $_REQUEST['access_token'];
365
- $access_region_descriptor = json_decode(
366
- strtr( $_REQUEST['access_region_descriptor'], '!^', '"\\' ), true );
367
- $region = $_REQUEST['region'];
368
- $service_id = $_REQUEST['service_id'];
369
-
370
- $api = new Cdn_RackSpace_Api_Cdn( array(
371
  'access_token' => $access_token,
372
  'access_region_descriptor' => $access_region_descriptor,
373
- 'new_access_required' => ''
374
- ) );
 
375
 
376
  try {
377
  $service = $api->service_get( $service_id );
378
 
379
  $is_https = false;
380
- $origin = '';
381
  if ( isset( $service['origins'] ) && $service['origins'][0]['ssl'] ) {
382
  $is_https = $service['origins'][0]['ssl'];
383
- $origin = $service['origins'][0]['origin'];
384
  }
385
 
386
  $new_origin = Util_Environment::home_url_host();
387
- if ( $origin != $new_origin ) {
388
- $api->service_set( $service_id,
389
- array( array(
390
- 'op' => 'replace',
391
- 'path' => '/origins',
392
- 'value' => array( array(
393
- 'origin' => $new_origin,
394
- 'port' => ( $is_https ? 443 : 80 ),
395
- 'ssl' => $is_https,
 
 
 
396
  'hostheadertype' => 'origin',
397
- 'rules' => array()
398
- ) ) ) ) );
 
 
 
 
399
  }
400
  } catch ( \Exception $ex ) {
401
  $details = array(
402
- 'user_name' => $user_name,
403
- 'api_key' => $api_key,
404
- 'error_message' => $ex->getMessage()
405
  );
406
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
407
  exit();
408
  }
409
 
410
  $this->_save_config();
411
  }
412
 
413
-
414
-
415
  private function _save_config() {
416
- $user_name = $_REQUEST['user_name'];
417
- $api_key = $_REQUEST['api_key'];
418
- $access_token = $_REQUEST['access_token'];
419
- $access_region_descriptor = json_decode(
420
- strtr( $_REQUEST['access_region_descriptor'], '!^', '"\\' ), true );
421
- $region = $_REQUEST['region'];
422
- $service_id = $_REQUEST['service_id'];
423
-
424
- $api = new Cdn_RackSpace_Api_Cdn( array(
425
  'access_token' => $access_token,
426
  'access_region_descriptor' => $access_region_descriptor,
427
- 'new_access_required' => ''
428
- ) );
429
-
430
- $service = $api->service_get( $service_id );
431
-
432
- $access_url = $service['links_by_rel']['access_url']['href'];
433
- $protocol = 'http';
434
- $domain = '';
435
 
436
  if ( isset( $service['domains'] ) && $service['domains'][0]['protocol'] ) {
437
  $protocol = $service['domains'][0]['protocol'];
438
- $domain = $service['domains'][0]['domain'];
439
  }
440
 
441
  $c = Dispatcher::config();
@@ -448,26 +428,25 @@ class Cdn_RackSpaceCdn_Popup {
448
  $c->set( 'cdn.rackspace_cdn.service.access_url', $access_url );
449
  $c->set( 'cdn.rackspace_cdn.service.protocol', $protocol );
450
 
451
- if ( $protocol != 'https' )
452
  $c->set( 'cdn.rackspace_cdn.domains', array( $domain ) );
 
453
 
454
  $c->save();
455
 
456
- // reset calculated state
457
  $state = Dispatcher::config_state();
458
  $state->set( 'cdn.rackspace_cdn.access_state', '' );
459
  $state->save();
460
 
461
- $postfix = Util_Admin::custom_message_id( array(),
462
- array(
463
- 'cdn_configuration_saved' =>
464
- 'CDN credentials are saved successfully' ) );
465
- echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
466
  exit();
467
  }
468
 
469
-
470
-
471
  /**
472
  * CNAMEs popup
473
  */
@@ -476,27 +455,27 @@ class Cdn_RackSpaceCdn_Popup {
476
  exit();
477
  }
478
 
479
-
480
-
481
  public function w3tc_ajax_cdn_rackspace_configure_domains_done() {
482
  $details = array(
483
- 'cnames' => Util_Request::get_array( 'cdn_cnames' )
484
  );
485
 
486
  $core = Dispatcher::component( 'Cdn_Core' );
487
- $cdn = $core->get_cdn();
488
 
489
  try {
490
- // try to obtain CNAMEs
491
  $cdn->service_domains_set( $details['cnames'] );
492
 
493
  $c = Dispatcher::config();
494
  $c->set( 'cdn.rackspace_cdn.domains', $details['cnames'] );
495
  $c->save();
496
 
497
- $postfix = Util_Admin::custom_message_id( array(),
498
- array( 'cdn_cnames_saved' => 'CNAMEs are saved successfully' ) );
499
- echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
 
 
500
  exit();
501
  } catch ( \Exception $ex ) {
502
  $details['error_message'] = $ex->getMessage();
@@ -506,42 +485,52 @@ class Cdn_RackSpaceCdn_Popup {
506
  exit();
507
  }
508
 
509
-
510
-
511
  private function render_configure_domains_form( $details = array() ) {
512
- if ( isset( $details['cnames'] ) )
513
  $cnames = $details['cnames'];
514
- else {
515
  $core = Dispatcher::component( 'Cdn_Core' );
516
- $cdn = $core->get_cdn();
517
 
518
  try {
519
- // try to obtain CNAMEs
520
  $cnames = $cdn->service_domains_get();
521
  } catch ( \Exception $ex ) {
522
  $details['error_message'] = $ex->getMessage();
523
- $cnames = array();
524
  }
525
  }
526
 
527
- include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php';
528
  }
529
 
530
-
531
-
532
  private function render_service_value_change( $details, $field ) {
533
- Util_Ui::hidden( '', $field, $details[$field]['new'] );
534
-
535
- if ( !isset( $details[$field]['current'] ) ||
536
- $details[$field]['current'] == $details[$field]['new'] )
537
- echo htmlspecialchars( $details[$field]['new'] );
538
- else {
539
- echo 'currently set to <strong>' .
540
- htmlspecialchars( empty( $details[$field]['current'] ) ?
541
- '<empty>' : $details[$field]['current'] ) .
542
- '</strong><br />';
543
- echo 'will be changed to <strong>' .
544
- htmlspecialchars( $details[$field]['new'] ) . '</strong><br />';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
  }
546
  }
547
  }
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  class Cdn_RackSpaceCdn_Popup {
5
+ public static function w3tc_ajax() {
6
  $o = new Cdn_RackSpaceCdn_Popup();
7
 
8
+ add_action( 'w3tc_ajax_cdn_rackspace_intro', array( $o, 'w3tc_ajax_cdn_rackspace_intro' ) );
9
+ add_action( 'w3tc_ajax_cdn_rackspace_intro_done', array( $o, 'w3tc_ajax_cdn_rackspace_intro_done' ) );
10
+ add_action( 'w3tc_ajax_cdn_rackspace_regions_done', array( $o, 'w3tc_ajax_cdn_rackspace_regions_done' ) );
11
+ add_action( 'w3tc_ajax_cdn_rackspace_services_done', array( $o, 'w3tc_ajax_cdn_rackspace_services_done' ) );
12
+ add_action( 'w3tc_ajax_cdn_rackspace_service_create_done', array( $o, 'w3tc_ajax_cdn_rackspace_service_create_done' ) );
13
+ add_action( 'w3tc_ajax_cdn_rackspace_service_get_state', array( $o, 'w3tc_ajax_cdn_rackspace_service_get_state' ) );
14
+ add_action( 'w3tc_ajax_cdn_rackspace_service_created_done', array( $o, 'w3tc_ajax_cdn_rackspace_service_created_done' ) );
15
+ add_action( 'w3tc_ajax_cdn_rackspace_service_actualize_done', array( $o, 'w3tc_ajax_cdn_rackspace_service_actualize_done' ) );
16
+ add_action( 'w3tc_ajax_cdn_rackspace_configure_domains', array( $o, 'w3tc_ajax_cdn_rackspace_configure_domains' ) );
17
+ add_action( 'w3tc_ajax_cdn_rackspace_configure_domains_done', array( $o, 'w3tc_ajax_cdn_rackspace_configure_domains_done' ) );
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
 
 
20
  public function w3tc_ajax_cdn_rackspace_intro() {
21
  $c = Dispatcher::config();
22
 
23
  $details = array(
24
  'user_name' => $c->get_string( 'cdn.rackspace_cdn.user_name' ),
25
+ 'api_key' => $c->get_string( 'cdn.rackspace_cdn.api_key' ),
26
  );
27
 
28
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
29
  exit();
30
  }
31
 
 
 
32
  public function w3tc_ajax_cdn_rackspace_intro_done() {
33
+ $this->_render_cdn_rackspace_regions(
34
+ array(
35
+ 'user_name' => Util_Request::get_string( 'user_name' ),
36
+ 'api_key' => Util_Request::get_string( 'api_key' ),
37
+ )
38
+ );
39
  }
40
 
 
 
41
  private function _render_cdn_rackspace_regions( $details ) {
42
  $user_name = $details['user_name'];
43
+ $api_key = $details['api_key'];
44
 
45
  try {
46
+ $r = Cdn_RackSpace_Api_Tokens::authenticate( $user_name, $api_key );
 
47
  } catch ( \Exception $ex ) {
48
  $details = array(
49
+ 'user_name' => $user_name,
50
+ 'api_key' => $api_key,
51
+ 'error_message' => 'Can\'t authenticate: ' . $ex->getMessage(),
52
  );
53
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
54
  exit();
55
  }
56
 
57
+ $r['regions'] = Cdn_RackSpace_Api_Tokens::cdn_services_by_region( $r['services'] );
 
58
 
59
+ $details['access_token'] = $r['access_token'];
60
  $details['region_descriptors'] = $r['regions'];
 
 
 
61
 
62
+ // avoid fights with quotes, magic_quotes may break randomly.
63
+ $details['region_descriptors_serialized'] = strtr( wp_json_encode( $r['regions'] ), '"\\', '!^' );
64
+
65
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Regions.php';
66
  exit();
67
  }
68
 
 
 
69
  public function w3tc_ajax_cdn_rackspace_regions_done() {
70
+ $user_name = Util_Request::get_string( 'user_name' );
71
+ $api_key = Util_Request::get_string( 'api_key' );
72
+ $access_token = Util_Request::get_string( 'access_token' );
73
+ $region = Util_Request::get_string( 'region' );
74
  $region_descriptors = json_decode(
75
+ strtr( Util_Request::get_string( 'region_descriptors' ), '!^', '"\\' ),
76
+ true
77
+ );
78
+
79
+ if ( ! isset( $region_descriptors[$region] ) ) {
80
+ return $this->_render_cdn_rackspace_regions(
81
+ array(
82
+ 'user_name' => $user_name,
83
+ 'api_key' => $api_key,
84
+ 'error_message' => 'Please select region ' . $region,
85
+ )
86
+ );
87
  }
88
 
89
+ $api = new Cdn_RackSpace_Api_Cdn(
90
+ array(
91
+ 'access_token' => $access_token,
92
+ 'access_region_descriptor' => $region_descriptors[ $region ],
93
+ 'new_access_required' => '',
94
+ )
95
+ );
96
 
97
  try {
98
  $services = $api->services();
99
  } catch ( \Exception $ex ) {
100
  $details = array(
101
+ 'user_name' => $user_name,
102
+ 'api_key' => $api_key,
103
+ 'error_message' => $ex->getMessage(),
104
  );
105
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
106
  exit();
107
  }
108
 
109
  $details = array(
110
+ 'user_name' => $user_name,
111
+ 'api_key' => $api_key,
112
+ 'access_token' => $access_token,
113
+ 'access_region_descriptor_serialized' => strtr( wp_json_encode( $region_descriptors[ $region ] ), '"\\', '!^' ),
114
+ 'region' => $region,
115
+ // avoid fights with quotes, magic_quotes may break randomly.
116
+ 'services' => $services,
 
117
  );
118
 
119
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Services.php';
120
  exit();
121
  }
122
 
 
 
123
  public function w3tc_ajax_cdn_rackspace_services_done() {
124
+ $user_name = Util_Request::get_string( 'user_name' );
125
+ $api_key = Util_Request::get_string( 'api_key' );
126
+ $access_token = Util_Request::get_string( 'access_token' );
127
+ $access_region_descriptor = json_decode( strtr( Util_Request::get_string( 'access_region_descriptor' ), '!^', '"\\' ), true );
128
+ $region = Util_Request::get_string( 'region' );
129
+ $service = Util_Request::get( 'service' );
 
130
 
131
  if ( !empty( $service ) ) {
132
+ $this->_render_service_actualize(
133
+ array(
134
+ 'user_name' => $user_name,
135
+ 'api_key' => $api_key,
136
+ 'access_token' => $access_token,
137
+ 'access_region_descriptor_serialized' => strtr( json_encode( $access_region_descriptor ), '"\\', '!^' ),
138
+ 'region' => $region,
139
+ 'service_id' => $service,
140
+ )
141
+ );
142
+
143
  exit();
144
  }
145
 
146
  $home_url = get_home_url();
147
+ $parsed = wp_parse_url( $home_url );
148
 
149
+ $is_https = ( 'https' === $parsed['scheme'] );
150
 
151
  $details = array(
152
+ 'user_name' => $user_name,
153
+ 'api_key' => $api_key,
154
+ 'access_token' => $access_token,
155
+ 'access_region_descriptor_serialized' => strtr( wp_json_encode( $access_region_descriptor ), '"\\', '!^' ),
156
+ 'region' => $region,
157
+ 'name' => '',
158
+ 'protocol' => ( $is_https ? 'https' : 'http' ),
159
+ 'cname_http' => '',
160
+ 'cname_http_style' => ( $is_https ? 'display: none' : '' ),
161
+ 'cname_https_prefix' => '',
162
+ 'cname_https_style' => ( $is_https ? '' : 'display: none' ),
163
+ 'origin' => Util_Environment::home_url_host(),
 
164
  );
165
 
166
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Create.php';
167
  exit();
168
  }
169
 
 
 
170
  public function w3tc_ajax_cdn_rackspace_service_create_done() {
171
+ $user_name = Util_Request::get_string( 'user_name' );
172
+ $api_key = Util_Request::get_string( 'api_key' );
173
+ $access_token = Util_Request::get_string( 'access_token' );
174
+ $access_region_descriptor = json_decode( strtr( Util_Request::get_string( 'access_region_descriptor' ), '!^', '"\\' ), true );
175
+ $region = Util_Request::get_string( 'region' );
176
+ $name = Util_Request::get_string( 'name' );
177
+ $protocol = Util_Request::get_string( 'protocol' );
178
+ $cname_http = Util_Request::get_string( 'cname_http' );
179
+ $cname_https_prefix = Util_Request::get_string( 'cname_https_prefix' );
180
+ $is_https = ( 'https' === $protocol );
181
+ $cname = ( $is_https ? $cname_https_prefix : $cname_http );
182
+ $api = new Cdn_RackSpace_Api_Cdn(
183
+ array(
184
+ 'access_token' => $access_token,
 
 
 
185
  'access_region_descriptor' => $access_region_descriptor,
186
+ 'new_access_required' => '',
187
+ )
188
+ );
189
+ $service_id = null;
190
+ $access_url = null;
191
 
192
  try {
193
  $domain = array(
194
+ 'domain' => $cname,
195
+ 'protocol' => ( $is_https ? 'https' : 'http' ),
196
  );
197
+
198
+ if ( $is_https ) {
199
  $domain['certificate'] = 'shared';
200
+ }
201
 
202
+ $service_id = $api->service_create(
203
+ array(
204
+ 'name' => $name,
205
  'domains' => array( $domain ),
206
  'origins' => array(
207
  array(
208
+ 'origin' => Util_Environment::home_url_host(),
209
+ 'port' => ( $is_https ? 443 : 80 ),
210
+ 'ssl' => $is_https,
211
  'hostheadertype' => 'origin',
212
+ 'rules' => array(),
213
+ ),
214
  ),
215
  'caching' => array(
216
  array(
217
  'name' => 'default',
218
+ 'ttl' => 86400,
219
+ ),
220
+ ),
221
+ )
222
+ );
223
  } catch ( \Exception $ex ) {
224
  $details = array(
225
+ 'user_name' => $user_name,
226
+ 'api_key' => $api_key,
227
+ 'access_token' => $access_token,
228
+ 'access_region_descriptor_serialized' => strtr( wp_json_encode( $access_region_descriptor ), '"\\', '!^' ),
229
+ 'region' => $region,
230
+ 'name' => $name,
231
+ 'protocol' => ( $is_https ? 'https' : 'http' ),
232
+ 'cname_http' => $cname_http,
233
+ 'cname_http_style' => ( $is_https ? 'display: none' : '' ),
234
+ 'cname_https_prefix' => $cname_https_prefix,
235
+ 'cname_https_style' => ( $is_https ? '' : 'display: none' ),
236
+ 'origin' => Util_Environment::home_url_host(),
237
+ 'error_message' => $ex->getMessage(),
 
238
  );
239
 
240
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Create.php';
241
  exit();
242
  }
243
 
244
  $details = array(
245
+ 'user_name' => $user_name,
246
+ 'api_key' => $api_key,
247
+ 'access_token' => $access_token,
248
+ 'access_region_descriptor_serialized' => strtr( wp_json_encode( $access_region_descriptor ), '"\\', '!^' ),
249
+ 'region' => $region,
250
+ 'name' => $name,
251
+ 'is_https' => $is_https,
252
+ 'cname' => $cname,
253
+ 'service_id' => $service_id,
 
254
  );
255
 
256
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Created.php';
257
  }
258
 
259
+ /**
260
+ * AJAX returning json for js-script about service state.
261
+ */
262
  public function w3tc_ajax_cdn_rackspace_service_get_state() {
263
+ $access_token = Util_Request::get_string( 'access_token' );
264
+ $access_region_descriptor = json_decode( strtr( Util_Request::get_string( 'access_region_descriptor' ), '!^', '"\\' ), true );
265
+ $service_id = Util_Request::get_string( 'service_id' );
266
+ $api = new Cdn_RackSpace_Api_Cdn(
267
+ array(
268
+ 'access_token' => $access_token,
 
269
  'access_region_descriptor' => $access_region_descriptor,
270
+ 'new_access_required' => '',
271
+ )
272
+ );
273
+ $service = $api->service_get( $service_id );
274
+ $response = array( 'status' => 'Unknown' );
 
275
 
276
+ if ( isset( $service['status'] ) ) {
277
  $response['status'] = $service['status'];
278
+ }
279
+
280
+ if ( isset( $service['links_by_rel']['access_url'] ) ) {
281
  $response['access_url'] = $service['links_by_rel']['access_url']['href'];
282
+ }
283
+
284
+ if ( isset( $service['domains'] ) ) {
285
  $response['cname'] = $service['domains'][0]['domain'];
286
+ }
287
 
288
+ // decode to friendly name.
289
+ if ( 'create_in_progress' === $response['status'] ) {
290
  $response['status'] = 'Creation in progress...';
291
+ }
292
 
293
+ echo esc_html( wp_json_encode( $response ) );
294
  }
295
 
 
 
296
  public function w3tc_ajax_cdn_rackspace_service_created_done() {
297
  $this->_save_config();
298
  }
299
 
 
 
300
  private function _render_service_actualize( $details ) {
301
+ $access_region_descriptor = json_decode( strtr( $details['access_region_descriptor_serialized'], '!^', '"\\' ), true );
 
 
302
 
303
+ $api = new Cdn_RackSpace_Api_Cdn(
304
+ array(
305
+ 'access_token' => $details['access_token'],
306
  'access_region_descriptor' => $access_region_descriptor,
307
+ 'new_access_required' => '',
308
+ )
309
+ );
310
 
311
  $service = null;
312
  try {
313
  $service = $api->service_get( $details['service_id'] );
314
  } catch ( \Exception $ex ) {
315
  $details['error_message'] = $ex->getMessage();
316
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
317
  exit();
318
  }
319
 
320
+ $origin = '';
321
  $protocol = 'http';
322
  if ( isset( $service['origins'] ) && $service['origins'][0]['origin'] ) {
323
  $protocol = $service['origins'][0]['ssl'] ? 'https' : 'http';
324
+ $origin = $service['origins'][0]['origin'];
325
  }
326
 
327
+ $details['name'] = $service['name'];
328
  $details['protocol'] = $protocol;
329
+ $details['origin'] = array(
330
  'current' => $origin,
331
+ 'new' => Util_Environment::home_url_host(),
332
  );
333
 
334
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Service_Actualize.php';
335
  exit();
336
  }
337
 
 
 
338
  public function w3tc_ajax_cdn_rackspace_service_actualize_done() {
339
+ $user_name = Util_Request::get_string( 'user_name' );
340
+ $api_key = Util_Request::get_string( 'api_key' );
341
+ $access_token = Util_Request::get_string( 'access_token' );
342
+ $access_region_descriptor = json_decode( strtr( Util_Request::get_string( 'access_region_descriptor' ), '!^', '"\\' ), true );
343
+ $region = Util_Request::get_string( 'region' );
344
+ $service_id = Util_Request::get_string( 'service_id' );
345
+ $api = new Cdn_RackSpace_Api_Cdn(
346
+ array(
 
347
  'access_token' => $access_token,
348
  'access_region_descriptor' => $access_region_descriptor,
349
+ 'new_access_required' => '',
350
+ )
351
+ );
352
 
353
  try {
354
  $service = $api->service_get( $service_id );
355
 
356
  $is_https = false;
357
+ $origin = '';
358
  if ( isset( $service['origins'] ) && $service['origins'][0]['ssl'] ) {
359
  $is_https = $service['origins'][0]['ssl'];
360
+ $origin = $service['origins'][0]['origin'];
361
  }
362
 
363
  $new_origin = Util_Environment::home_url_host();
364
+ if ( $origin !== $new_origin ) {
365
+ $api->service_set(
366
+ $service_id,
367
+ array(
368
+ array(
369
+ 'op' => 'replace',
370
+ 'path' => '/origins',
371
+ 'value' => array(
372
+ array(
373
+ 'origin' => $new_origin,
374
+ 'port' => ( $is_https ? 443 : 80 ),
375
+ 'ssl' => $is_https,
376
  'hostheadertype' => 'origin',
377
+ 'rules' => array(),
378
+ ),
379
+ ),
380
+ ),
381
+ )
382
+ );
383
  }
384
  } catch ( \Exception $ex ) {
385
  $details = array(
386
+ 'user_name' => $user_name,
387
+ 'api_key' => $api_key,
388
+ 'error_message' => $ex->getMessage(),
389
  );
390
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_Intro.php';
391
  exit();
392
  }
393
 
394
  $this->_save_config();
395
  }
396
 
 
 
397
  private function _save_config() {
398
+ $user_name = Util_Request::get_string( 'user_name' );
399
+ $api_key = Util_Request::get_string( 'api_key' );
400
+ $access_token = Util_Request::get_string( 'access_token' );
401
+ $access_region_descriptor = json_decode( strtr( Util_Request::get_string( 'access_region_descriptor' ), '!^', '"\\' ), true );
402
+ $region = Util_Request::get_string( 'region' );
403
+ $service_id = Util_Request::get_string( 'service_id' );
404
+ $api = new Cdn_RackSpace_Api_Cdn(
405
+ array(
 
406
  'access_token' => $access_token,
407
  'access_region_descriptor' => $access_region_descriptor,
408
+ 'new_access_required' => '',
409
+ )
410
+ );
411
+ $service = $api->service_get( $service_id );
412
+ $access_url = $service['links_by_rel']['access_url']['href'];
413
+ $protocol = 'http';
414
+ $domain = '';
 
415
 
416
  if ( isset( $service['domains'] ) && $service['domains'][0]['protocol'] ) {
417
  $protocol = $service['domains'][0]['protocol'];
418
+ $domain = $service['domains'][0]['domain'];
419
  }
420
 
421
  $c = Dispatcher::config();
428
  $c->set( 'cdn.rackspace_cdn.service.access_url', $access_url );
429
  $c->set( 'cdn.rackspace_cdn.service.protocol', $protocol );
430
 
431
+ if ( 'https' !== $protocol ) {
432
  $c->set( 'cdn.rackspace_cdn.domains', array( $domain ) );
433
+ }
434
 
435
  $c->save();
436
 
437
+ // reset calculated state.
438
  $state = Dispatcher::config_state();
439
  $state->set( 'cdn.rackspace_cdn.access_state', '' );
440
  $state->save();
441
 
442
+ $postfix = Util_Admin::custom_message_id(
443
+ array(),
444
+ array( 'cdn_configuration_saved' => 'CDN credentials are saved successfully' )
445
+ );
446
+ echo esc_url( 'Location admin.php?page=w3tc_cdn&' . $postfix );
447
  exit();
448
  }
449
 
 
 
450
  /**
451
  * CNAMEs popup
452
  */
455
  exit();
456
  }
457
 
 
 
458
  public function w3tc_ajax_cdn_rackspace_configure_domains_done() {
459
  $details = array(
460
+ 'cnames' => Util_Request::get_array( 'cdn_cnames' ),
461
  );
462
 
463
  $core = Dispatcher::component( 'Cdn_Core' );
464
+ $cdn = $core->get_cdn();
465
 
466
  try {
467
+ // try to obtain CNAMEs.
468
  $cdn->service_domains_set( $details['cnames'] );
469
 
470
  $c = Dispatcher::config();
471
  $c->set( 'cdn.rackspace_cdn.domains', $details['cnames'] );
472
  $c->save();
473
 
474
+ $postfix = Util_Admin::custom_message_id(
475
+ array(),
476
+ array( 'cdn_cnames_saved' => 'CNAMEs are saved successfully' )
477
+ );
478
+ echo esc_url( 'Location admin.php?page=w3tc_cdn&' . $postfix );
479
  exit();
480
  } catch ( \Exception $ex ) {
481
  $details['error_message'] = $ex->getMessage();
485
  exit();
486
  }
487
 
 
 
488
  private function render_configure_domains_form( $details = array() ) {
489
+ if ( isset( $details['cnames'] ) ) {
490
  $cnames = $details['cnames'];
491
+ } else {
492
  $core = Dispatcher::component( 'Cdn_Core' );
493
+ $cdn = $core->get_cdn();
494
 
495
  try {
496
+ // try to obtain CNAMEs.
497
  $cnames = $cdn->service_domains_get();
498
  } catch ( \Exception $ex ) {
499
  $details['error_message'] = $ex->getMessage();
500
+ $cnames = array();
501
  }
502
  }
503
 
504
+ include W3TC_DIR . '/Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php';
505
  }
506
 
 
 
507
  private function render_service_value_change( $details, $field ) {
508
+ Util_Ui::hidden( '', $field, $details[ $field ]['new'] );
509
+
510
+ if ( ! isset( $details[ $field ]['current'] ) || $details[ $field ]['current'] === $details[ $field ]['new'] ) {
511
+ echo esc_html( $details[ $field ]['new'] );
512
+ } else {
513
+ echo wp_kses(
514
+ sprintf(
515
+ // translators: 1 opening HTML strong tag, 2 current setting value, 3 closing HTML strong tag followed by HTML line break,
516
+ // translators: 4 opening HTML strong tag, 5 new setting value, 6 closing HTML strong tag followed by HTML line break.
517
+ __(
518
+ 'currently set to %1$s%2$s%3$s will be changed to %4$s%5$s%6$s',
519
+ 'w3-total-cache'
520
+ ),
521
+ '<strong>',
522
+ empty( $details[ $field ]['current'] ) ? '<empty>' : $details[ $field ]['current'],
523
+ '</strong><br />',
524
+ '<strong>',
525
+ $details[ $field ]['new'],
526
+ '</strong><br />'
527
+ ),
528
+ array(
529
+ 'strong' => array(),
530
+ 'empty' => array(),
531
+ 'br' => array(),
532
+ )
533
+ );
534
  }
535
  }
536
  }
Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php CHANGED
@@ -1,23 +1,69 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_rackspace_form">
8
  <?php
9
- 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( __( '<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
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  <p class="submit">
18
  <input type="button"
19
  class="w3tc_cdn_rackspace_configure_domains_done w3tc-button-save button-primary"
20
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
21
  </p>
22
  <?php Util_Ui::postbox_footer(); ?>
23
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_rackspace_form">
9
  <?php
10
+ if ( ! empty( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php
16
+ Util_Ui::postbox_header(
17
+ wp_kses(
18
+ sprintf(
19
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
20
+ __(
21
+ '%1$sCNAME%2$ss to use',
22
+ 'w3-total-cache'
23
+ ),
24
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
25
+ '</acronym>'
26
+ ),
27
+ array(
28
+ 'acronym' => array(
29
+ 'title' => array(),
30
+ ),
31
+ )
32
+ )
33
+ );
34
+ ?>
35
+ <?php
36
+ $cname_class = 'w3tc-ignore-change';
37
+ require W3TC_INC_DIR . '/options/cdn/common/cnames.php';
38
+ ?>
39
+ <p class="description">
40
+ <?php
41
+ echo wp_kses(
42
+ sprintf(
43
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
44
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
45
+ __(
46
+ 'Enter hostname mapped to %1$sCDN%2$s host, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
47
+ 'w3-total-cache'
48
+ ),
49
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
50
+ '</acronym>',
51
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
52
+ '</acronym>'
53
+ ),
54
+ array(
55
+ 'acronym' => array(
56
+ 'title' => array(),
57
+ ),
58
+ )
59
+ );
60
+ ?>
61
+ </p>
62
 
63
  <p class="submit">
64
  <input type="button"
65
  class="w3tc_cdn_rackspace_configure_domains_done w3tc-button-save button-primary"
66
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
67
  </p>
68
  <?php Util_Ui::postbox_footer(); ?>
69
  </div>
Cdn_RackSpaceCdn_Popup_View_Intro.php CHANGED
@@ -1,33 +1,51 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_rackspace_form" method="post" style="padding: 20px">
8
  <?php Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_intro_done' ); ?>
9
  <?php
10
- if ( isset( $details['error_message'] ) )
11
- echo '<div class="error">' . $details['error_message'] . '</div>';
12
- ?>
 
13
  <div class="metabox-holder">
14
- <?php Util_Ui::postbox_header(
15
- __( 'Your RackSpace API key', 'w3-total-cache' ) ); ?>
16
  <table class="form-table">
17
  <tr>
18
- <th><?php _e( 'Username:', 'w3-total-cache' ) ?></td>
19
  <td>
20
  <input name="user_name" type="text" class="w3tc-ignore-change"
21
- style="width: 100px"
22
- value="<?php echo esc_attr( $details['user_name'] ) ?>" />
23
  </td>
24
  </tr>
25
  <tr>
26
- <th><?php _e( '<acronym title="Application Programming Interface">API</acronym> key:', 'w3-total-cache' ); ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  <td>
28
  <input name="api_key" type="text" class="w3tc-ignore-change"
29
- style="width: 550px"
30
- value="<?php echo esc_attr( $details['api_key'] ) ?>" />
31
  </td>
32
  </tr>
33
  </table>
@@ -35,7 +53,7 @@ if ( isset( $details['error_message'] ) )
35
  <p class="submit">
36
  <input type="button"
37
  class="w3tc_popup_submit w3tc-button-save button-primary"
38
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
39
  </p>
40
  <?php Util_Ui::postbox_footer(); ?>
41
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_rackspace_form" method="post" style="padding: 20px">
9
  <?php Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_intro_done' ); ?>
10
  <?php
11
+ if ( isset( $details['error_message'] ) ) {
12
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
13
+ }
14
+ ?>
15
  <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Your RackSpace API key', 'w3-total-cache' ) ); ?>
 
17
  <table class="form-table">
18
  <tr>
19
+ <th><?php esc_html_e( 'Username:', 'w3-total-cache' ); ?></td>
20
  <td>
21
  <input name="user_name" type="text" class="w3tc-ignore-change"
22
+ style="width: 100px" value="<?php echo esc_attr( $details['user_name'] ); ?>" />
 
23
  </td>
24
  </tr>
25
  <tr>
26
+ <th>
27
+ <?php
28
+ echo wp_kses(
29
+ sprintf(
30
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
31
+ __(
32
+ '%1$sAPI%2$s key:',
33
+ 'w3-total-cache'
34
+ ),
35
+ '<acronym title="' . esc_attr__( 'Application Programming Interface', 'w3-total-cache' ) . '">',
36
+ '</acronym>'
37
+ ),
38
+ array(
39
+ 'acronym' => array(
40
+ 'title' => array(),
41
+ ),
42
+ )
43
+ );
44
+ ?>
45
+ </th>
46
  <td>
47
  <input name="api_key" type="text" class="w3tc-ignore-change"
48
+ style="width: 550px" value="<?php echo esc_attr( $details['api_key'] ); ?>" />
 
49
  </td>
50
  </tr>
51
  </table>
53
  <p class="submit">
54
  <input type="button"
55
  class="w3tc_popup_submit w3tc-button-save button-primary"
56
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
57
  </p>
58
  <?php Util_Ui::postbox_footer(); ?>
59
  </div>
Cdn_RackSpaceCdn_Popup_View_Regions.php CHANGED
@@ -1,45 +1,54 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
- <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_rackspace_form">
9
- <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_regions_done' );
11
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
- Util_Ui::hidden( '', 'region_descriptors', $details['region_descriptors_serialized'] );
15
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
16
 
17
- ?>
18
- <?php
19
- if ( isset( $details['error_message'] ) )
20
- echo '<div class="error">' . $details['error_message'] . '</div>';
21
- ?>
22
- <div class="metabox-holder">
23
- <?php Util_Ui::postbox_header( __( 'Select region', 'w3-total-cache' ) ); ?>
24
- <table class="form-table">
25
- <tr>
26
- <th>Region:</td>
27
- <td>
28
- <?php foreach ( $details['region_descriptors'] as $region => $region_details ): ?>
29
- <label>
30
- <input name="region" type="radio" class="w3tc-ignore-change"
31
- value="<?php echo $region ?>" />
32
- <?php echo $region_details['name'] ?>
33
- </label><br />
34
- <?php endforeach ?>
35
- </tr>
36
- </table>
37
 
38
- <p class="submit">
39
- <input type="button"
40
- class="w3tc_popup_submit w3tc-button-save button-primary"
41
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
42
- </p>
43
- <?php Util_Ui::postbox_footer(); ?>
44
- </div>
45
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_rackspace_form">
9
+ <?php
10
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_regions_done' );
11
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
+ Util_Ui::hidden( '', 'region_descriptors', $details['region_descriptors_serialized'] );
15
+ echo wp_kses(
16
+ Util_Ui::nonce_field( 'w3tc' ),
17
+ array(
18
+ 'input' => array(
19
+ 'type' => array(),
20
+ 'name' => array(),
21
+ 'value' => array(),
22
+ ),
23
+ )
24
+ );
25
 
26
+ if ( isset( $details['error_message'] ) ) {
27
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
28
+ }
29
+ ?>
30
+ <div class="metabox-holder">
31
+ <?php Util_Ui::postbox_header( esc_html__( 'Select region', 'w3-total-cache' ) ); ?>
32
+ <table class="form-table">
33
+ <tr>
34
+ <th>Region:</td>
35
+ <td>
36
+ <?php foreach ( $details['region_descriptors'] as $region => $region_details ) : ?>
37
+ <label>
38
+ <input name="region" type="radio" class="w3tc-ignore-change"
39
+ value="<?php echo esc_attr( $region ); ?>" />
40
+ <?php echo esc_html( $region_details['name'] ); ?>
41
+ </label><br />
42
+ <?php endforeach; ?>
43
+ </td>
44
+ </tr>
45
+ </table>
46
 
47
+ <p class="submit">
48
+ <input type="button"
49
+ class="w3tc_popup_submit w3tc-button-save button-primary"
50
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
51
+ </p>
52
+ <?php Util_Ui::postbox_footer(); ?>
53
+ </div>
54
  </form>
Cdn_RackSpaceCdn_Popup_View_Service_Actualize.php CHANGED
@@ -1,39 +1,49 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
- <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_rackspace_form">
9
  <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_service_actualize_done' );
11
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
- Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
- Util_Ui::hidden( '', 'region', $details['region'] );
16
- Util_Ui::hidden( '', 'service_id', $details['service_id'] );
17
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
 
18
 
19
- if ( isset( $details['error_message'] ) )
20
- echo '<div class="error">' . $details['error_message'] . '</div>';
21
- ?>
 
22
 
23
  <div class="metabox-holder">
24
- <?php Util_Ui::postbox_header( __( 'Configure service', 'w3-total-cache' ) ); ?>
25
  <table class="form-table">
26
  <tr>
27
- <th>Name:</th>
28
- <td><?php echo $details['name'] ?></td>
29
  </tr>
30
  <tr>
31
- <th>Origin host:</th>
32
- <td><?php $this->render_service_value_change( $details, 'origin' ) ?></td>
33
  </tr>
34
  <tr>
35
- <th>Origin protocol:</th>
36
- <td><?php echo $details['protocol'] ?><br />
37
  </td>
38
  </tr>
39
  </table>
@@ -41,7 +51,7 @@ if ( isset( $details['error_message'] ) )
41
  <p class="submit">
42
  <input type="button"
43
  class="w3tc_popup_submit w3tc-button-save button-primary"
44
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
45
  </p>
46
  <?php Util_Ui::postbox_footer(); ?>
47
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_rackspace_form">
 
9
  <?php
10
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_service_actualize_done' );
11
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
+ Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
+ Util_Ui::hidden( '', 'region', $details['region'] );
16
+ Util_Ui::hidden( '', 'service_id', $details['service_id'] );
17
+ echo wp_kses(
18
+ Util_Ui::nonce_field( 'w3tc' ),
19
+ array(
20
+ 'input' => array(
21
+ 'type' => array(),
22
+ 'name' => array(),
23
+ 'value' => array(),
24
+ ),
25
+ )
26
+ );
27
 
28
+ if ( isset( $details['error_message'] ) ) {
29
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
30
+ }
31
+ ?>
32
 
33
  <div class="metabox-holder">
34
+ <?php Util_Ui::postbox_header( esc_html__( 'Configure service', 'w3-total-cache' ) ); ?>
35
  <table class="form-table">
36
  <tr>
37
+ <th><?php esc_html_e( 'Name:', 'w3-total-cache' ); ?></th>
38
+ <td><?php echo esc_html( $details['name'] ); ?></td>
39
  </tr>
40
  <tr>
41
+ <th><?php esc_html_e( 'Origin host:', 'w3-total-cache' ); ?></th>
42
+ <td><?php $this->render_service_value_change( $details, 'origin' ); ?></td>
43
  </tr>
44
  <tr>
45
+ <th><?php esc_html_e( 'Origin protocol:', 'w3-total-cache' ); ?></th>
46
+ <td><?php echo esc_html( $details['protocol'] ); ?><br />
47
  </td>
48
  </tr>
49
  </table>
51
  <p class="submit">
52
  <input type="button"
53
  class="w3tc_popup_submit w3tc-button-save button-primary"
54
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
55
  </p>
56
  <?php Util_Ui::postbox_footer(); ?>
57
  </div>
Cdn_RackSpaceCdn_Popup_View_Service_Create.php CHANGED
@@ -1,43 +1,52 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
  class="w3tc_cdn_rackspace_form">
9
  <?php
10
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
11
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
12
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
13
- Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
14
- Util_Ui::hidden( '', 'region', $details['region'] );
15
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
 
16
 
17
- ?>
18
- <?php
19
- if ( isset( $details['error_message'] ) )
20
- echo '<div class="error">' . $details['error_message'] . '</div>';
21
- ?>
22
  <div class="metabox-holder">
23
- <?php Util_Ui::postbox_header( __( 'Create new service', 'w3-total-cache' ) ); ?>
24
  <table class="form-table" style="width: 100%">
25
  <tr>
26
- <th style="width: 150px">Name:</td>
27
  <td>
28
  <input name="name" type="text" class="w3tc-ignore-change"
29
  style="width: 100px"
30
- value="<?php echo esc_attr( $details['name'] ) ?>" />
31
  </td>
32
  </tr>
33
  <tr>
34
- <th style="white-space: nowrap">Traffic Type:</td>
35
  <td>
36
  <label>
37
  <input name="protocol" type="radio"
38
  class="w3tc-ignore-change w3tc_cdn_rackspace_protocol"
39
  value="http"
40
- <?php checked( $details['protocol'], 'http' ) ?> />
41
  http://
42
  </label>
43
  <br />
@@ -45,40 +54,78 @@ if ( isset( $details['error_message'] ) )
45
  <input name="protocol" type="radio"
46
  class="w3tc-ignore-change w3tc_cdn_rackspace_protocol"
47
  value="https"
48
- <?php checked( $details['protocol'], 'https' ) ?> />
49
  https://
50
  </label>
51
  </td>
52
  </tr>
53
  <tr>
54
- <th>Origin:</td>
55
  <td>
56
- <?php echo $details['origin'] ?>
57
  </td>
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"
65
- value="<?php echo esc_attr( $details['cname_http'] ) ?>" />
66
  <p class="description">
67
- <?php _e( 'The domain name through which visitors retrieve content. You will be provided with a target domain to use as an alias for this CNAME', 'w3-total-cache' ); ?>
68
  </p>
69
  </td>
70
  </tr>
71
  <tr class="w3tc_cdn_rackspace_cname_https"
72
- style="<?php echo $details['cname_https_style'] ?>">
73
- <th style="white-space: nowrap">Primary <acronym title="Canonical Name">CNAME</acronym>:</td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  <td>
75
  <input name="cname_https_prefix" type="text" class="w3tc-ignore-change"
76
  style="width: 100px"
77
- value="<?php echo esc_attr( $details['cname_https_prefix'] ) ?>" />
78
  <input name="" type="text" readonly="readonly"
79
  value=".xxxx.secure.raxcdn.com" />
80
  <p class="description">
81
- <?php _e( 'The name should be a single word, and cannot contain any dots (.).', 'w3-total-cache' ) ?>
82
  </p>
83
  </td>
84
  </tr>
@@ -87,7 +134,7 @@ if ( isset( $details['error_message'] ) )
87
  <p class="submit">
88
  <input type="button"
89
  class="w3tc_cdn_rackspace_service_create_done w3tc-button-save button-primary"
90
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
91
  </p>
92
  <?php Util_Ui::postbox_footer(); ?>
93
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
9
  class="w3tc_cdn_rackspace_form">
10
  <?php
11
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
+ Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
+ Util_Ui::hidden( '', 'region', $details['region'] );
16
+ echo wp_kses(
17
+ Util_Ui::nonce_field( 'w3tc' ),
18
+ array(
19
+ 'input' => array(
20
+ 'type' => array(),
21
+ 'name' => array(),
22
+ 'value' => array(),
23
+ ),
24
+ )
25
+ );
26
 
27
+ if ( isset( $details['error_message'] ) ) {
28
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
29
+ }
30
+ ?>
 
31
  <div class="metabox-holder">
32
+ <?php Util_Ui::postbox_header( esc_html__( 'Create new service', 'w3-total-cache' ) ); ?>
33
  <table class="form-table" style="width: 100%">
34
  <tr>
35
+ <th style="width: 150px"><?php esc_html_e( 'Name:', 'w3-total-cache' ); ?></td>
36
  <td>
37
  <input name="name" type="text" class="w3tc-ignore-change"
38
  style="width: 100px"
39
+ value="<?php echo esc_attr( $details['name'] ); ?>" />
40
  </td>
41
  </tr>
42
  <tr>
43
+ <th style="white-space: nowrap"><?php esc_html_e( 'Traffic Type:', 'w3-total-cache' ); ?></td>
44
  <td>
45
  <label>
46
  <input name="protocol" type="radio"
47
  class="w3tc-ignore-change w3tc_cdn_rackspace_protocol"
48
  value="http"
49
+ <?php checked( $details['protocol'], 'http' ); ?> />
50
  http://
51
  </label>
52
  <br />
54
  <input name="protocol" type="radio"
55
  class="w3tc-ignore-change w3tc_cdn_rackspace_protocol"
56
  value="https"
57
+ <?php checked( $details['protocol'], 'https' ); ?> />
58
  https://
59
  </label>
60
  </td>
61
  </tr>
62
  <tr>
63
+ <th><?php esc_html_e( 'Origin:', 'w3-total-cache' ); ?></td>
64
  <td>
65
+ <?php echo esc_html( $details['origin'] ); ?>
66
  </td>
67
  </tr>
68
  <tr class="w3tc_cdn_rackspace_cname_http"
69
+ style="<?php echo esc_attr( $details['cname_http_style'] ); ?>">
70
+ <th style="white-space: nowrap">
71
+ <?php
72
+ echo wp_kses(
73
+ sprintf(
74
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
75
+ __(
76
+ 'Primary %1$sCNAME%2$s:',
77
+ 'w3-total-cache'
78
+ ),
79
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
80
+ '</acronym>'
81
+ ),
82
+ array(
83
+ 'acronym' => array(
84
+ 'title' => array(),
85
+ ),
86
+ )
87
+ );
88
+ ?>
89
+ </th>
90
  <td>
91
  <input name="cname_http" type="text" class="w3tc-ignore-change"
92
  style="width: 200px"
93
+ value="<?php echo esc_attr( $details['cname_http'] ); ?>" />
94
  <p class="description">
95
+ <?php esc_html_e( 'The domain name through which visitors retrieve content. You will be provided with a target domain to use as an alias for this CNAME', 'w3-total-cache' ); ?>
96
  </p>
97
  </td>
98
  </tr>
99
  <tr class="w3tc_cdn_rackspace_cname_https"
100
+ style="<?php echo esc_attr( $details['cname_https_style'] ); ?>">
101
+ <th style="white-space: nowrap">
102
+ <?php
103
+ echo wp_kses(
104
+ sprintf(
105
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
106
+ __(
107
+ 'Primary %1$sCNAME%2$s:',
108
+ 'w3-total-cache'
109
+ ),
110
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
111
+ '</acronym>'
112
+ ),
113
+ array(
114
+ 'acronym' => array(
115
+ 'title' => array(),
116
+ ),
117
+ )
118
+ );
119
+ ?>
120
+ </td>
121
  <td>
122
  <input name="cname_https_prefix" type="text" class="w3tc-ignore-change"
123
  style="width: 100px"
124
+ value="<?php echo esc_attr( $details['cname_https_prefix'] ); ?>" />
125
  <input name="" type="text" readonly="readonly"
126
  value=".xxxx.secure.raxcdn.com" />
127
  <p class="description">
128
+ <?php esc_html_e( 'The name should be a single word, and cannot contain any dots (.).', 'w3-total-cache' ); ?>
129
  </p>
130
  </td>
131
  </tr>
134
  <p class="submit">
135
  <input type="button"
136
  class="w3tc_cdn_rackspace_service_create_done w3tc-button-save button-primary"
137
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
138
  </p>
139
  <?php Util_Ui::postbox_footer(); ?>
140
  </div>
Cdn_RackSpaceCdn_Popup_View_Service_Created.php CHANGED
@@ -1,57 +1,64 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
- <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_rackspace_form">
9
- <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_service_created_done' );
11
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
- Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
- Util_Ui::hidden( '', 'region', $details['region'] );
16
- Util_Ui::hidden( '', 'service_id', $details['service_id'] );
17
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- ?>
20
- <form class="w3tc_popup_form">
21
- <div class="metabox-holder">
22
- <?php Util_Ui::postbox_header( __( 'Succeeded', 'w3-total-cache' ) ); ?>
23
-
24
- <div style="text-align: center" class="w3tc_rackspace_created_in_progress">
25
- <div class="spinner" style="float: right; display: block"></div>
26
- <div style="text-align: left">
27
- Service <?php echo $details['name'] ?> was successfully created.<br />
28
- Waiting for RackSpace to finish the provisioning process.<br />
29
- <br />
30
 
31
- Actual state is:
32
- <strong><span class="w3tc_rackspace_created_status">Initiated</span></strong>
33
- </div>
34
- </div>
35
 
36
- <div style="display: none" class="w3tc_rackspace_created_done">
37
- <div style="text-align: center">
38
- <div style="text-align: left">
39
- Service <?php echo $details['name'] ?> was successfully configured.<br />
40
- <?php if ( !$is_https ): ?>
41
- <br />
42
- Next, update the domain's <acronym title="Domain Name System">DNS</acronym> records
43
- <strong><?php echo $details['cname'] ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to<br />
44
- <strong class="w3tc_rackspace_access_url"></strong> to enable caching.
45
- <?php endif; ?>
46
- </div>
47
- </div>
48
 
49
- <p class="submit">
50
- <input type="button"
51
- class="w3tc_popup_submit w3tc-button-save button-primary"
52
- value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
53
- </p>
54
- </div>
55
- <?php Util_Ui::postbox_footer(); ?>
56
- </div>
57
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_rackspace_form">
9
+ <?php
10
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_service_created_done' );
11
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
+ Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
+ Util_Ui::hidden( '', 'region', $details['region'] );
16
+ Util_Ui::hidden( '', 'service_id', $details['service_id'] );
17
+ echo wp_kses(
18
+ Util_Ui::nonce_field( 'w3tc' ),
19
+ array(
20
+ 'input' => array(
21
+ 'type' => array(),
22
+ 'name' => array(),
23
+ 'value' => array(),
24
+ ),
25
+ )
26
+ );
27
+ ?>
28
+ <div class="metabox-holder">
29
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
30
 
31
+ <div style="text-align: center" class="w3tc_rackspace_created_in_progress">
32
+ <div class="spinner" style="float: right; display: block"></div>
33
+ <div style="text-align: left">
34
+ Service <?php echo esc_html( $details['name'] ); ?> was successfully created.<br />
35
+ Waiting for RackSpace to finish the provisioning process.<br />
36
+ <br />
 
 
 
 
 
37
 
38
+ Actual state is:
39
+ <strong><span class="w3tc_rackspace_created_status">Initiated</span></strong>
40
+ </div>
41
+ </div>
42
 
43
+ <div style="display: none" class="w3tc_rackspace_created_done">
44
+ <div style="text-align: center">
45
+ <div style="text-align: left">
46
+ Service <?php echo esc_html( $details['name'] ); ?> was successfully configured.<br />
47
+ <?php if ( ! $is_https ) : ?>
48
+ <br />
49
+ Next, update the domain's <acronym title="Domain Name System">DNS</acronym> records
50
+ <strong><?php echo esc_html( $details['cname'] ); ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to<br />
51
+ <strong class="w3tc_rackspace_access_url"></strong> to enable caching.
52
+ <?php endif; ?>
53
+ </div>
54
+ </div>
55
 
56
+ <p class="submit">
57
+ <input type="button"
58
+ class="w3tc_popup_submit w3tc-button-save button-primary"
59
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
60
+ </p>
61
+ </div>
62
+ <?php Util_Ui::postbox_footer(); ?>
63
+ </div>
64
  </form>
Cdn_RackSpaceCdn_Popup_View_Services.php CHANGED
@@ -1,53 +1,63 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_rackspace_form">
9
- <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_services_done' );
11
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
- Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
- Util_Ui::hidden( '', 'region', $details['region'] );
16
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
 
17
 
18
- ?>
19
- <?php
20
- if ( isset( $details['error_message'] ) )
21
- echo '<div class="error">' . $details['error_message'] . '</div>';
22
- ?>
23
- <div class="metabox-holder">
24
- <?php Util_Ui::postbox_header( __( 'Select service to use', 'w3-total-cache' ) ); ?>
25
- <table class="form-table w3tc_popup_form">
26
- <tr>
27
- <th>Service:</td>
28
- <td>
29
- <?php foreach ( $details['services'] as $service ): ?>
30
- <label>
31
- <input name="service" type="radio"
32
- class="w3tc-ignore-change"
33
- value="<?php echo $service['id'] ?>" />
34
- <?php echo $service['name'] ?>
35
- </label><br />
36
- <?php endforeach ?>
37
 
38
- <label>
39
- <input name="service" type="radio"
40
- class="w3tc-ignore-change" value="" />
41
- Add new service
42
- </label>
43
- </tr>
44
- </table>
 
45
 
46
- <p class="submit">
47
- <input type="button"
48
- class="w3tc_popup_submit w3tc-button-save button-primary"
49
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
50
- </p>
51
- <?php Util_Ui::postbox_footer(); ?>
52
- </div>
53
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
9
+ class="w3tc_cdn_rackspace_form">
10
+ <?php
11
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_services_done' );
12
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
13
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
14
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
15
+ Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
16
+ Util_Ui::hidden( '', 'region', $details['region'] );
17
+ echo wp_kses(
18
+ Util_Ui::nonce_field( 'w3tc' ),
19
+ array(
20
+ 'input' => array(
21
+ 'type' => array(),
22
+ 'name' => array(),
23
+ 'value' => array(),
24
+ ),
25
+ )
26
+ );
27
 
28
+ if ( isset( $details['error_message'] ) ) {
29
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
30
+ }
31
+ ?>
32
+ <div class="metabox-holder">
33
+ <?php Util_Ui::postbox_header( esc_html__( 'Select service to use', 'w3-total-cache' ) ); ?>
34
+ <table class="form-table w3tc_popup_form">
35
+ <tr>
36
+ <th>Service:</td>
37
+ <td>
38
+ <?php foreach ( $details['services'] as $service ) : ?>
39
+ <label>
40
+ <input name="service" type="radio"
41
+ class="w3tc-ignore-change"
42
+ value="<?php echo esc_attr( $service['id'] ); ?>" />
43
+ <?php echo esc_html( $service['name'] ); ?>
44
+ </label><br />
45
+ <?php endforeach; ?>
 
46
 
47
+ <label>
48
+ <input name="service" type="radio"
49
+ class="w3tc-ignore-change" value="" />
50
+ Add new service
51
+ </label>
52
+ </td>
53
+ </tr>
54
+ </table>
55
 
56
+ <p class="submit">
57
+ <input type="button"
58
+ class="w3tc_popup_submit w3tc-button-save button-primary"
59
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
60
+ </p>
61
+ <?php Util_Ui::postbox_footer(); ?>
62
+ </div>
63
  </form>
Cdn_RackSpaceCloudFiles_Page_View.php CHANGED
@@ -1,76 +1,166 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <tr>
9
- <th style="width: 300px;"><label><?php _e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
10
  <td>
11
- <?php if ( !$authorized ): ?>
12
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
13
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>" />
14
- <?php else: ?>
15
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
16
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>" />
17
- <?php endif ?>
18
  </td>
19
  </tr>
20
 
21
- <?php if ( $authorized ): ?>
22
  <tr>
23
- <th><?php _e( 'Username:', 'w3-total-cache' ); ?></th>
24
  <td class="w3tc_config_value_text">
25
- <?php echo $config->get_string( 'cdn.rscf.user' ) ?>
26
  </td>
27
  </tr>
28
  <tr>
29
- <th><?php _e( 'Region:', 'w3-total-cache' ); ?></th>
30
  <td class="w3tc_config_value_text">
31
- <?php echo $config->get_string( 'cdn.rscf.location' ) ?>
32
  </td>
33
  </tr>
34
  <tr>
35
- <th><?php _e( 'Container:', 'w3-total-cache' ); ?></th>
36
  <td class="w3tc_config_value_text">
37
- <?php echo $config->get_string( 'cdn.rscf.container' ) ?>
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 ?>
45
  </td>
46
  </tr>
47
  <tr>
48
- <th><label for="cdn_rackspace_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support:</label>', 'w3-total-cache' ); ?></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  <td>
50
  <select id="cdn_rackspace_ssl" name="cdn__rscf__ssl">
51
- <option value="auto"<?php selected( $config->get_string( 'cdn.rscf.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?></option>
52
- <option value="enabled"<?php selected( $config->get_string( 'cdn.rscf.ssl' ), 'enabled' ); ?>><?php _e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
53
- <option value="disabled"<?php selected( $config->get_string( 'cdn.rscf.ssl' ), 'disabled' ); ?>><?php _e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
54
  </select>
55
- <p 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' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </td>
57
  </tr>
58
  <tr>
59
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
60
  <td>
61
- <?php $cnames = $config->get_array( 'cdn.rscf.cname' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
 
 
 
62
  <p class="description">
63
- <?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' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  </p>
65
  </td>
66
  </tr>
67
  <tr>
68
  <th colspan="2">
69
  <input id="cdn_test"
70
- class="button {type: 'highwinds', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}"
71
  type="button"
72
- value="<?php _e( 'Test', 'w3-total-cache' ); ?>" />
73
  <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
74
  </th>
75
  </tr>
76
- <?php endif ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <tr>
9
+ <th style="width: 300px;"><label><?php esc_html_e( 'Authorize:', 'w3-total-cache' ); ?></label></th>
10
  <td>
11
+ <?php if ( ! $authorized ) : ?>
12
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
13
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
14
+ <?php else : ?>
15
  <input class="w3tc_cdn_rackspace_authorize button" type="button"
16
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
17
+ <?php endif; ?>
18
  </td>
19
  </tr>
20
 
21
+ <?php if ( $authorized ) : ?>
22
  <tr>
23
+ <th><?php esc_html_e( 'Username:', 'w3-total-cache' ); ?></th>
24
  <td class="w3tc_config_value_text">
25
+ <?php echo esc_html( $config->get_string( 'cdn.rscf.user' ) ); ?>
26
  </td>
27
  </tr>
28
  <tr>
29
+ <th><?php esc_html_e( 'Region:', 'w3-total-cache' ); ?></th>
30
  <td class="w3tc_config_value_text">
31
+ <?php echo esc_html( $config->get_string( 'cdn.rscf.location' ) ); ?>
32
  </td>
33
  </tr>
34
  <tr>
35
+ <th><?php esc_html_e( 'Container:', 'w3-total-cache' ); ?></th>
36
  <td class="w3tc_config_value_text">
37
+ <?php echo esc_html( $config->get_string( 'cdn.rscf.container' ) ); ?>
38
  </td>
39
  </tr>
40
  <tr>
41
+ <th>
42
+ <label>
43
+ <?php
44
+ echo wp_kses(
45
+ sprintf(
46
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
47
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
48
+ __(
49
+ '%1$sCDN%2$s host (%3$sCNAME%4$s target):',
50
+ 'w3-total-cache'
51
+ ),
52
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
53
+ '</acronym>',
54
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
55
+ '</acronym>'
56
+ ),
57
+ array(
58
+ 'acronym' => array(
59
+ 'title' => array(),
60
+ ),
61
+ )
62
+ );
63
+ ?>
64
+ </label>
65
+ </th>
66
  <td class="w3tc_config_value_text">
67
+ http: <?php echo esc_url( $cdn_host_http ); ?><br />
68
+ https: <?php echo esc_url( $cdn_host_https ); ?>
69
  </td>
70
  </tr>
71
  <tr>
72
+ <th>
73
+ <label for="cdn_rackspace_ssl">
74
+ <?php
75
+ echo wp_kses(
76
+ sprintf(
77
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
78
+ __(
79
+ '%1$sSSL%2$s support:',
80
+ 'w3-total-cache'
81
+ ),
82
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
83
+ '</acronym>'
84
+ ),
85
+ array(
86
+ 'acronym' => array(
87
+ 'title' => array(),
88
+ ),
89
+ )
90
+ );
91
+ ?>
92
+ </label>
93
+ </th>
94
  <td>
95
  <select id="cdn_rackspace_ssl" name="cdn__rscf__ssl">
96
+ <option value="auto"<?php selected( $config->get_string( 'cdn.rscf.ssl' ), 'auto' ); ?>><?php esc_html_e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?></option>
97
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.rscf.ssl' ), 'enabled' ); ?>><?php esc_html_e( 'Enabled (always use SSL)', 'w3-total-cache' ); ?></option>
98
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.rscf.ssl' ), 'disabled' ); ?>><?php esc_html_e( 'Disabled (always use HTTP)', 'w3-total-cache' ); ?></option>
99
  </select>
100
+ <p class="description">
101
+ <?php
102
+ echo wp_kses(
103
+ sprintf(
104
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
105
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
106
+ __(
107
+ 'Some %1$sCDN%2$s providers may or may not support %3$sSSL%4$s, contact your vendor for more information.',
108
+ 'w3-total-cache'
109
+ ),
110
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
111
+ '</acronym>',
112
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
113
+ '</acronym>'
114
+ ),
115
+ array(
116
+ 'acronym' => array(
117
+ 'title' => array(),
118
+ ),
119
+ )
120
+ );
121
+ ?>
122
+ </p>
123
  </td>
124
  </tr>
125
  <tr>
126
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
127
  <td>
128
+ <?php
129
+ $cnames = $config->get_array( 'cdn.rscf.cname' );
130
+ include W3TC_INC_DIR . '/options/cdn/common/cnames.php';
131
+ ?>
132
  <p class="description">
133
+ <?php
134
+ echo wp_kses(
135
+ sprintf(
136
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
137
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
138
+ __(
139
+ 'Enter hostname mapped to %1$sCDN%2$s host, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
140
+ 'w3-total-cache'
141
+ ),
142
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
143
+ '</acronym>',
144
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
145
+ '</acronym>'
146
+ ),
147
+ array(
148
+ 'acronym' => array(
149
+ 'title' => array(),
150
+ ),
151
+ )
152
+ );
153
+ ?>
154
  </p>
155
  </td>
156
  </tr>
157
  <tr>
158
  <th colspan="2">
159
  <input id="cdn_test"
160
+ class="button {type: 'highwinds', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}"
161
  type="button"
162
+ value="<?php esc_attr_e( 'Test', 'w3-total-cache' ); ?>" />
163
  <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
164
  </th>
165
  </tr>
166
+ <?php endif; ?>
Cdn_RackSpaceCloudFiles_Popup.php CHANGED
@@ -34,8 +34,8 @@ class Cdn_RackSpaceCloudFiles_Popup {
34
 
35
 
36
  public function w3tc_ajax_cdn_rackspace_intro_done() {
37
- $user_name = $_REQUEST['user_name'];
38
- $api_key = $_REQUEST['api_key'];
39
 
40
  try {
41
  $r = Cdn_RackSpace_Api_Tokens::authenticate( $user_name,
@@ -70,12 +70,14 @@ class Cdn_RackSpaceCloudFiles_Popup {
70
 
71
 
72
  public function w3tc_ajax_cdn_rackspace_regions_done() {
73
- $user_name = $_REQUEST['user_name'];
74
- $api_key = $_REQUEST['api_key'];
75
- $access_token = $_REQUEST['access_token'];
76
  $region = Util_Request::get( 'region' );
77
  $region_descriptors = json_decode(
78
- strtr( $_REQUEST['region_descriptors'], '!^', '"\\' ), true );
 
 
79
 
80
  if ( !isset( $region_descriptors[$region] ) ) {
81
  $details = array(
@@ -123,12 +125,14 @@ class Cdn_RackSpaceCloudFiles_Popup {
123
 
124
 
125
  public function w3tc_ajax_cdn_rackspace_containers_done() {
126
- $user_name = $_REQUEST['user_name'];
127
- $api_key = $_REQUEST['api_key'];
128
- $access_token = $_REQUEST['access_token'];
129
  $access_region_descriptor = json_decode(
130
- strtr( $_REQUEST['access_region_descriptor'], '!^', '"\\' ), true );
131
- $region = $_REQUEST['region'];
 
 
132
  $container = Util_Request::get( 'container' );
133
 
134
  $api_files = new Cdn_RackSpace_Api_CloudFiles( array(
@@ -144,7 +148,8 @@ class Cdn_RackSpaceCloudFiles_Popup {
144
 
145
  try {
146
  if ( empty( $container ) ) {
147
- $container_new = $_REQUEST['container_new'];
 
148
  if ( empty( $container_new ) )
149
  throw new \Exception( 'Please select container' );
150
 
@@ -182,11 +187,11 @@ class Cdn_RackSpaceCloudFiles_Popup {
182
  $state->set( 'cdn.rackspace_cf.access_state', '' );
183
  $state->save();
184
 
185
- $postfix = Util_Admin::custom_message_id( array(),
186
- array(
187
- 'cdn_configuration_saved' =>
188
- 'CDN credentials are saved successfully' ) );
189
- echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
190
  exit();
191
  }
192
  }
34
 
35
 
36
  public function w3tc_ajax_cdn_rackspace_intro_done() {
37
+ $user_name = Util_Request::get_string( 'user_name' );
38
+ $api_key = Util_Request::get_string( 'api_key' );
39
 
40
  try {
41
  $r = Cdn_RackSpace_Api_Tokens::authenticate( $user_name,
70
 
71
 
72
  public function w3tc_ajax_cdn_rackspace_regions_done() {
73
+ $user_name = Util_Request::get_string( 'user_name' );
74
+ $api_key = Util_Request::get_string( 'api_key' );
75
+ $access_token = Util_Request::get_string( 'access_token' );
76
  $region = Util_Request::get( 'region' );
77
  $region_descriptors = json_decode(
78
+ strtr( Util_Request::get_string( 'region_descriptors' ), '!^', '"\\' ),
79
+ true
80
+ );
81
 
82
  if ( !isset( $region_descriptors[$region] ) ) {
83
  $details = array(
125
 
126
 
127
  public function w3tc_ajax_cdn_rackspace_containers_done() {
128
+ $user_name = Util_Request::get_string( 'user_name' );
129
+ $api_key = Util_Request::get_string( 'api_key' );
130
+ $access_token = Util_Request::get_string( 'access_token' );
131
  $access_region_descriptor = json_decode(
132
+ strtr( Util_Request::get_string( 'access_region_descriptor' ), '!^', '"\\' ),
133
+ true
134
+ );
135
+ $region = Util_Request::get_string( 'region' );
136
  $container = Util_Request::get( 'container' );
137
 
138
  $api_files = new Cdn_RackSpace_Api_CloudFiles( array(
148
 
149
  try {
150
  if ( empty( $container ) ) {
151
+ $container_new = Util_Request::get_string( 'container_new' );
152
+
153
  if ( empty( $container_new ) )
154
  throw new \Exception( 'Please select container' );
155
 
187
  $state->set( 'cdn.rackspace_cf.access_state', '' );
188
  $state->save();
189
 
190
+ $postfix = Util_Admin::custom_message_id(
191
+ array(),
192
+ array( 'cdn_configuration_saved' => 'CDN credentials are saved successfully' )
193
+ );
194
+ echo 'Location admin.php?page=w3tc_cdn&' . wp_kses( $postfix, Util_Ui::get_allowed_html_for_wp_kses_from_content( $postfix ) );
195
  exit();
196
  }
197
  }
Cdn_RackSpaceCloudFiles_Popup_View_Containers.php CHANGED
@@ -1,53 +1,59 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
- <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_rackspace_form">
9
- <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_containers_done' );
11
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
- Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
- Util_Ui::hidden( '', 'region', $details['region'] );
16
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
17
 
18
- ?>
19
- <?php
20
- if ( isset( $details['error_message'] ) )
21
- echo '<div class="error">' . $details['error_message'] . '</div>';
22
- ?>
23
- <div class="metabox-holder">
24
- <?php Util_Ui::postbox_header( __( 'Select container to use', 'w3-total-cache' ) ); ?>
25
- <table class="form-table">
26
- <tr>
27
- <td>Container:</td>
28
- <td>
29
- <?php foreach ( $details['containers'] as $container ): ?>
30
- <label>
31
- <input name="container" type="radio" class="w3tc-ignore-change"
32
- value="<?php echo $container['name'] ?>" />
33
- <?php echo $container['name'] ?>
34
- </label><br />
35
- <?php endforeach ?>
36
-
37
- <label>
38
- <input name="container" type="radio" class="w3tc-ignore-change" value=""
39
- />
40
- Add new container:
41
- </label>
42
- <input name="container_new" type="text" class="w3tc-ignore-change" />
43
- </tr>
44
- </table>
45
-
46
- <p class="submit">
47
- <input type="button"
48
- class="w3tc_popup_submit w3tc-button-save button-primary"
49
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
50
- </p>
51
- <?php Util_Ui::postbox_footer(); ?>
52
- </div>
53
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px" class="w3tc_cdn_rackspace_form">
9
+ <?php
10
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_containers_done' );
11
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
+ Util_Ui::hidden( '', 'access_region_descriptor', $details['access_region_descriptor_serialized'] );
15
+ Util_Ui::hidden( '', 'region', $details['region'] );
16
+ echo wp_kses(
17
+ Util_Ui::nonce_field( 'w3tc' ),
18
+ array(
19
+ 'input' => array(
20
+ 'type' => array(),
21
+ 'name' => array(),
22
+ 'value' => array(),
23
+ ),
24
+ )
25
+ );
26
 
27
+ if ( isset( $details['error_message'] ) ) {
28
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
29
+ }
30
+ ?>
31
+ <div class="metabox-holder">
32
+ <?php Util_Ui::postbox_header( esc_html__( 'Select container to use', 'w3-total-cache' ) ); ?>
33
+ <table class="form-table">
34
+ <tr>
35
+ <td>Container:</td>
36
+ <td>
37
+ <?php foreach ( $details['containers'] as $container ) : ?>
38
+ <label>
39
+ <input name="container" type="radio" class="w3tc-ignore-change"
40
+ value="<?php echo esc_attr( $container['name'] ); ?>" />
41
+ <?php echo esc_html( $container['name'] ); ?>
42
+ </label><br />
43
+ <?php endforeach; ?>
44
+ <label>
45
+ <input name="container" type="radio" class="w3tc-ignore-change" value="" />
46
+ Add new container:
47
+ </label>
48
+ <input name="container_new" type="text" class="w3tc-ignore-change" />
49
+ </td>
50
+ </tr>
51
+ </table>
52
+ <p class="submit">
53
+ <input type="button"
54
+ class="w3tc_popup_submit w3tc-button-save button-primary"
55
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
56
+ </p>
57
+ <?php Util_Ui::postbox_footer(); ?>
58
+ </div>
 
 
 
59
  </form>
Cdn_RackSpaceCloudFiles_Popup_View_Intro.php CHANGED
@@ -1,34 +1,52 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_rackspace_form" method="post" style="padding: 20px">
8
- <?php
9
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_intro_done' );
10
 
11
- if ( isset( $details['error_message'] ) )
12
- echo '<div class="error">' . $details['error_message'] . '</div>';
13
- ?>
 
14
  <div class="metabox-holder">
15
- <?php Util_Ui::postbox_header(
16
- __( 'Your RackSpace API key', 'w3-total-cache' ) ); ?>
17
  <table class="form-table">
18
  <tr>
19
- <td><?php _e( 'Username:', 'w3-total-cache' ) ?></td>
20
  <td>
21
  <input name="user_name" type="text" class="w3tc-ignore-change"
22
- style="width: 100px"
23
- value="<?php echo esc_attr( $details['user_name'] ) ?>" />
24
  </td>
25
  </tr>
26
  <tr>
27
- <td><?php _e( '<acronym title="Application Programming Interface">API</acronym> key:', 'w3-total-cache' ); ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  <td>
29
  <input name="api_key" type="text" class="w3tc-ignore-change"
30
- style="width: 550px"
31
- value="<?php echo esc_attr( $details['api_key'] ) ?>" />
32
  </td>
33
  </tr>
34
  </table>
@@ -36,7 +54,7 @@ if ( isset( $details['error_message'] ) )
36
  <p class="submit">
37
  <input type="button"
38
  class="w3tc_popup_submit w3tc-button-save button-primary"
39
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
40
  </p>
41
  <?php Util_Ui::postbox_footer(); ?>
42
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_rackspace_form" method="post" style="padding: 20px">
9
+ <?php
10
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_intro_done' );
11
 
12
+ if ( isset( $details['error_message'] ) ) {
13
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
14
+ }
15
+ ?>
16
  <div class="metabox-holder">
17
+ <?php Util_Ui::postbox_header( esc_html__( 'Your RackSpace API key', 'w3-total-cache' ) ); ?>
 
18
  <table class="form-table">
19
  <tr>
20
+ <td><?php esc_html_e( 'Username:', 'w3-total-cache' ); ?></td>
21
  <td>
22
  <input name="user_name" type="text" class="w3tc-ignore-change"
23
+ style="width: 100px" value="<?php echo esc_attr( $details['user_name'] ); ?>" />
 
24
  </td>
25
  </tr>
26
  <tr>
27
+ <td>
28
+ <?php
29
+ echo wp_kses(
30
+ sprintf(
31
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
32
+ __(
33
+ '%1$sAPI%2$s key:',
34
+ 'w3-total-cache'
35
+ ),
36
+ '<acronym title="' . esc_attr__( 'Application Programming Interface', 'w3-total-cache' ) . '">',
37
+ '</acronym>'
38
+ ),
39
+ array(
40
+ 'acronym' => array(
41
+ 'title' => array(),
42
+ ),
43
+ )
44
+ );
45
+ ?>
46
+ </td>
47
  <td>
48
  <input name="api_key" type="text" class="w3tc-ignore-change"
49
+ style="width: 550px" value="<?php echo esc_attr( $details['api_key'] ); ?>" />
 
50
  </td>
51
  </tr>
52
  </table>
54
  <p class="submit">
55
  <input type="button"
56
  class="w3tc_popup_submit w3tc-button-save button-primary"
57
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
58
  </p>
59
  <?php Util_Ui::postbox_footer(); ?>
60
  </div>
Cdn_RackSpaceCloudFiles_Popup_View_Regions.php CHANGED
@@ -1,45 +1,56 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
- class="w3tc_cdn_rackspace_form">
9
- <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_regions_done' );
11
- Util_Ui::hidden( '', 'user_name', $details['user_name'] );
12
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
13
- Util_Ui::hidden( '', 'access_token', $details['access_token'] );
14
- Util_Ui::hidden( '', 'region_descriptors', $details['region_descriptors_serialized'] );
15
- echo Util_Ui::nonce_field( 'w3tc' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- ?>
18
- <?php
19
- if ( isset( $details['error_message'] ) )
20
- echo '<div class="error">' . $details['error_message'] . '</div>';
21
- ?>
22
- <div class="metabox-holder">
23
- <?php Util_Ui::postbox_header( __( 'Select region', 'w3-total-cache' ) ); ?>
24
- <table class="form-table">
25
- <tr>
26
- <td>Region:</td>
27
- <td>
28
- <?php foreach ( $details['region_descriptors'] as $region => $region_details ): ?>
29
- <label>
30
- <input name="region" type="radio" class="w3tc-ignore-change"
31
- value="<?php echo $region ?>" />
32
- <?php echo $region_details['name'] ?>
33
- </label><br />
34
- <?php endforeach ?>
35
- </tr>
36
- </table>
37
-
38
- <p class="submit">
39
- <input type="button"
40
- class="w3tc_popup_submit w3tc-button-save button-primary"
41
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
42
- </p>
43
- <?php Util_Ui::postbox_footer(); ?>
44
- </div>
45
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
9
+ class="w3tc_cdn_rackspace_form">
10
+ <?php
11
+ Util_Ui::hidden( '', 'w3tc_action', 'cdn_rackspace_regions_done' );
12
+ Util_Ui::hidden( '', 'user_name', $details['user_name'] );
13
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
14
+ Util_Ui::hidden( '', 'access_token', $details['access_token'] );
15
+ Util_Ui::hidden( '', 'region_descriptors', $details['region_descriptors_serialized'] );
16
+ echo wp_kses(
17
+ Util_Ui::nonce_field( 'w3tc' ),
18
+ array(
19
+ 'input' => array(
20
+ 'type' => array(),
21
+ 'name' => array(),
22
+ 'value' => array(),
23
+ ),
24
+ )
25
+ );
26
+ ?>
27
+ <?php
28
+ if ( isset( $details['error_message'] ) ) {
29
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
30
+ }
31
+ ?>
32
+ <div class="metabox-holder">
33
+ <?php Util_Ui::postbox_header( esc_html__( 'Select region', 'w3-total-cache' ) ); ?>
34
+ <table class="form-table">
35
+ <tr>
36
+ <td>Region:</td>
37
+ <td>
38
+ <?php foreach ( $details['region_descriptors'] as $region => $region_details ) : ?>
39
+ <label>
40
+ <input name="region" type="radio" class="w3tc-ignore-change"
41
+ value="<?php echo esc_attr( $region ); ?>" />
42
+ <?php echo esc_html( $region_details['name'] ); ?>
43
+ </label><br />
44
+ <?php endforeach; ?>
45
+ </td>
46
+ </tr>
47
+ </table>
48
 
49
+ <p class="submit">
50
+ <input type="button"
51
+ class="w3tc_popup_submit w3tc-button-save button-primary"
52
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
53
+ </p>
54
+ <?php Util_Ui::postbox_footer(); ?>
55
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </form>
Cdn_StackPath2_Page_View.php CHANGED
@@ -1,113 +1,314 @@
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
  <p class="notice notice-error">
13
- <?php w3tc_e( 'cdn.stackpath.widget.v2.no_cdn',
14
- 'W3 Total Cache has detected that you do not have a <acronym title="Content Delivery Network">CDN</acronym> configured' ) ?>
 
 
 
 
15
  </p>
16
-
17
  <p>
18
- Enhance your website Performance with StackPath's CDN services. StackPath works magically with W3 Total Cache to speed up your site around the world for as little as $10 a month.
19
  </p>
20
  <p>
21
- <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>
22
  </p>
23
- <p 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!' ) ?></p>
24
  </td>
25
  </tr>
26
- <?php endif ?>
27
-
28
-
29
 
30
  <tr>
31
  <th style="width: 300px;">
32
  <label>
33
- <?php _e( 'Specify account credentials:', 'w3-total-cache' ); ?>
34
  </label>
35
  </th>
36
  <td>
37
  <p>
38
- If you're an existing StackPath customer, enable CDN and Authorize.
39
- If you need help configuring your CDN, we also offer Premium Services to assist you.
40
  </p>
41
 
42
  <p>
43
- <?php if ( $authorized ): ?>
44
  <input class="w3tc_cdn_stackpath2_authorize button-primary"
45
  type="button"
46
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
47
- />
48
- <?php else: ?>
49
  <input class="w3tc_cdn_stackpath2_authorize button-primary"
50
  type="button"
51
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
52
- />
53
- <?php endif ?>
54
- <a class="button" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_support' ), 'w3tc' )?>"><?php _e( 'Premium Services', 'w3-total-cache' )?></a>
55
  </p>
56
  </td>
57
  </tr>
58
 
59
- <?php if ( $authorized ): ?>
60
- <?php if ( !is_null( $http_domain ) ): ?>
61
- <tr>
62
- <th>
63
- <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>
64
- </th>
65
- <td class="w3tc_config_value_text">
66
- <?php echo htmlspecialchars( $http_domain ) ?>
67
- <p class="description">
68
- This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
69
- <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol">HTTP</acronym> requests
70
- </p>
71
- </td>
72
- </tr>
73
- <?php endif ?>
74
- <?php if ( !is_null( $https_domain ) ): ?>
75
- <tr>
76
- <th>
77
- <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>
78
- </th>
79
- <td class="w3tc_config_value_text">
80
- <?php echo htmlspecialchars( $https_domain ) ?>
81
- <p class="description">
82
- This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
83
- <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
84
- </p>
85
- </td>
86
- </tr>
87
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
- <tr>
90
- <th><label for="cdn_stackpath_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support', 'w3-total-cache' )?>:</label></th>
91
- <td>
92
- <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
93
- <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
94
- <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>
95
- <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>
96
- </select>
97
- <p 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' )?></p>
98
- </td>
99
- </tr>
100
- <tr>
101
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' )?></th>
102
- <td>
103
- <?php $cnames = $config->get_array( 'cdn.stackpath2.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
104
- <p 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' )?></p>
105
- </td>
106
- </tr>
107
- <tr>
108
- <th colspan="2">
109
- <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>
110
- </th>
111
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
- <?php endif ?>
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 esc_html_e( 'Create account:', 'w3-total-cache' ); ?></label></th>
11
  <td>
12
  <p class="notice notice-error">
13
+ <?php
14
+ w3tc_e(
15
+ 'cdn.stackpath.widget.v2.no_cdn',
16
+ 'W3 Total Cache has detected that you do not have a <acronym title="Content Delivery Network">CDN</acronym> configured'
17
+ );
18
+ ?>
19
  </p>
 
20
  <p>
21
+ <?php esc_html_e( 'Enhance your website Performance with StackPath\'s CDN services. StackPath works magically with W3 Total Cache to speed up your site around the world for as little as $10 a month.', 'w3-total-cache' ); ?>
22
  </p>
23
  <p>
24
+ <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>
25
  </p>
26
+ <p 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!' ); ?></p>
27
  </td>
28
  </tr>
29
+ <?php endif; ?>
 
 
30
 
31
  <tr>
32
  <th style="width: 300px;">
33
  <label>
34
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
35
  </label>
36
  </th>
37
  <td>
38
  <p>
39
+ <?php esc_html_e( 'If you\'re an existing StackPath customer, enable CDN and Authorize. If you need help configuring your CDN, we also offer Premium Services to assist you.', 'w3-total-cache' ); ?>
 
40
  </p>
41
 
42
  <p>
43
+ <?php if ( $authorized ) : ?>
44
  <input class="w3tc_cdn_stackpath2_authorize button-primary"
45
  type="button"
46
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
47
+ <?php else : ?>
 
48
  <input class="w3tc_cdn_stackpath2_authorize button-primary"
49
  type="button"
50
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
51
+ <?php endif; ?>
52
+ <a class="button" href="<?php echo esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_support' ), 'w3tc' ) ); ?>"><?php esc_html_e( 'Premium Services', 'w3-total-cache' ); ?></a>
 
53
  </p>
54
  </td>
55
  </tr>
56
 
57
+ <?php if ( $authorized ) : ?>
58
+ <?php if ( ! is_null( $http_domain ) ) : ?>
59
+ <tr>
60
+ <th>
61
+ <label>
62
+ <?php
63
+ echo wp_kses(
64
+ sprintf(
65
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
66
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
67
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
68
+ __(
69
+ '%1$sCDN%2$s %3$sHTTP%4$s %5$sCNAME%6$s:',
70
+ 'w3-total-cache'
71
+ ),
72
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
73
+ '</acronym>',
74
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol', 'w3-total-cache' ) . '">',
75
+ '</acronym>',
76
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
77
+ '</acronym>'
78
+ ),
79
+ array(
80
+ 'acronym' => array(
81
+ 'title' => array(),
82
+ ),
83
+ )
84
+ );
85
+ ?>
86
+ </label>
87
+ </th>
88
+ <td class="w3tc_config_value_text">
89
+ <?php echo esc_html( $http_domain ); ?>
90
+ <p class="description">
91
+ <?php
92
+ echo wp_kses(
93
+ sprintf(
94
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
95
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
96
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
97
+ __(
98
+ 'This website domain has to be %1$sCNAME%2$s pointing to this %3$sCDN%4$s domain for %5$sHTTP%6$s requests',
99
+ 'w3-total-cache'
100
+ ),
101
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
102
+ '</acronym>',
103
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
104
+ '</acronym>',
105
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol', 'w3-total-cache' ) . '">',
106
+ '</acronym>'
107
+ ),
108
+ array(
109
+ 'acronym' => array(
110
+ 'title' => array(),
111
+ ),
112
+ )
113
+ );
114
+ ?>
115
+ </p>
116
+ </td>
117
+ </tr>
118
+ <?php endif; ?>
119
 
120
+ <?php if ( ! is_null( $https_domain ) ) : ?>
121
+ <tr>
122
+ <th>
123
+ <label>
124
+ <?php
125
+ echo wp_kses(
126
+ sprintf(
127
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
128
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
129
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
130
+ __(
131
+ '%1$sCDN%2$s %3$sHTTPS%4$s %5$sCNAME%6$s:',
132
+ 'w3-total-cache'
133
+ ),
134
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
135
+ '</acronym>',
136
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol over SSL', 'w3-total-cache' ) . '">',
137
+ '</acronym>',
138
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
139
+ '</acronym>'
140
+ ),
141
+ array(
142
+ 'acronym' => array(
143
+ 'title' => array(),
144
+ ),
145
+ )
146
+ );
147
+ ?>
148
+ </label>
149
+ </th>
150
+ <td class="w3tc_config_value_text">
151
+ <?php echo esc_html( $https_domain ); ?>
152
+ <p class="description">
153
+ <?php
154
+ echo wp_kses(
155
+ sprintf(
156
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
157
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
158
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
159
+ __(
160
+ 'This website domain has to be %1$sCNAME%2$s pointing to this %3$sCDN%4$s domain for %5$sHTTPS%6$s requests',
161
+ 'w3-total-cache'
162
+ ),
163
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
164
+ '</acronym>',
165
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
166
+ '</acronym>',
167
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol over SSL', 'w3-total-cache' ) . '">',
168
+ '</acronym>'
169
+ ),
170
+ array(
171
+ 'acronym' => array(
172
+ 'title' => array(),
173
+ ),
174
+ )
175
+ );
176
+ ?>
177
+ </p>
178
+ </td>
179
+ </tr>
180
+ <?php endif; ?>
181
+
182
+ <tr>
183
+ <th>
184
+ <label for="cdn_stackpath_ssl">
185
+ <?php
186
+ echo wp_kses(
187
+ sprintf(
188
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
189
+ __(
190
+ '%1$sSSL%2$s support:',
191
+ 'w3-total-cache'
192
+ ),
193
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
194
+ '</acronym>'
195
+ ),
196
+ array(
197
+ 'acronym' => array(
198
+ 'title' => array(),
199
+ ),
200
+ )
201
+ );
202
+ ?>
203
+ </label>
204
+ </th>
205
+ <td>
206
+ <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ); ?>>
207
+ <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>>
208
+ <?php esc_html_e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?>
209
+ </option>
210
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'enabled' ); ?>>
211
+ <?php
212
+ echo wp_kses(
213
+ sprintf(
214
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
215
+ __(
216
+ 'Enabled (always use %1$sSSL%2$s)',
217
+ 'w3-total-cache'
218
+ ),
219
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
220
+ '</acronym>'
221
+ ),
222
+ array(
223
+ 'acronym' => array(
224
+ 'title' => array(),
225
+ ),
226
+ )
227
+ );
228
+ ?>
229
+ </option>
230
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'disabled' ); ?>>
231
+ <?php
232
+ echo wp_kses(
233
+ sprintf(
234
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
235
+ __(
236
+ 'Disabled (always use %1$sHTTP%2$s)',
237
+ 'w3-total-cache'
238
+ ),
239
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol', 'w3-total-cache' ) . '">',
240
+ '</acronym>'
241
+ ),
242
+ array(
243
+ 'acronym' => array(
244
+ 'title' => array(),
245
+ ),
246
+ )
247
+ );
248
+ ?>
249
+ </option>
250
+ </select>
251
+ <p class="description">
252
+ <?php
253
+ echo wp_kses(
254
+ sprintf(
255
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
256
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
257
+ __(
258
+ 'Some %1$sCDN%2$s providers may or may not support %3$sSSL%4$s, contact your vendor for more information.',
259
+ 'w3-total-cache'
260
+ ),
261
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
262
+ '</acronym>',
263
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
264
+ '</acronym>'
265
+ ),
266
+ array(
267
+ 'acronym' => array(
268
+ 'title' => array(),
269
+ ),
270
+ )
271
+ );
272
+ ?>
273
+ </p>
274
+ </td>
275
+ </tr>
276
+ <tr>
277
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
278
+ <td>
279
+ <?php
280
+ $cnames = $config->get_array( 'cdn.stackpath2.domain' );
281
+ include W3TC_INC_DIR . '/options/cdn/common/cnames.php';
282
+ ?>
283
+ <p class="description">
284
+ <?php
285
+ echo wp_kses(
286
+ sprintf(
287
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
288
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
289
+ __(
290
+ 'Enter the hostname provided by your %1$sCDN%2$s provider, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
291
+ 'w3-total-cache'
292
+ ),
293
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
294
+ '</acronym>',
295
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
296
+ '</acronym>'
297
+ ),
298
+ array(
299
+ 'acronym' => array(
300
+ 'title' => array(),
301
+ ),
302
+ )
303
+ );
304
+ ?>
305
+ </p>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <th colspan="2">
310
+ <input id="cdn_test" class="button {type: 'stackpath', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}" type="button" value="<?php esc_attr_e( 'Test StackPath', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
311
+ </th>
312
+ </tr>
313
 
314
+ <?php endif; ?>
Cdn_StackPath2_Popup.php CHANGED
@@ -42,8 +42,8 @@ class Cdn_StackPath2_Popup {
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 );
@@ -89,8 +89,8 @@ class Cdn_StackPath2_Popup {
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
 
@@ -127,7 +127,7 @@ class Cdn_StackPath2_Popup {
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 );
42
 
43
  public function w3tc_ajax_cdn_stackpath2_list_stacks() {
44
  $api_config = array(
45
+ 'client_id' => Util_Request::get_string( 'client_id' ),
46
+ 'client_secret' => Util_Request::get_string( 'client_secret' )
47
  );
48
 
49
  $api = new Cdn_StackPath2_Api( $api_config );
89
 
90
 
91
  public function w3tc_ajax_cdn_stackpath2_list_sites() {
92
+ $api_config = $this->api_config_decode( Util_Request::get_string( 'api_config' ) );
93
+ $api_config['stack_id'] = Util_Request::get_string( 'stack_id' );
94
  $this->_w3tc_ajax_cdn_stackpath2_list_sites( $api_config );
95
  }
96
 
127
 
128
 
129
  public function w3tc_ajax_cdn_stackpath2_configure_site() {
130
+ $api_config = $this->api_config_decode( Util_Request::get_string( 'api_config' ) );
131
  $site_id = Util_Request::get( 'site_id', '' );
132
 
133
  $api = new Cdn_StackPath2_Api( $api_config );
Cdn_StackPath2_Popup_View_Intro.php CHANGED
@@ -1,24 +1,25 @@
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>
@@ -26,10 +27,10 @@ if ( isset( $details['error_message'] ) )
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
  <p class="description">
31
  To obtain API key you can
32
- <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
33
  log in, and paste the key in above field.
34
  </p>
35
  </td>
@@ -39,7 +40,7 @@ if ( isset( $details['error_message'] ) )
39
  <p class="submit">
40
  <input type="button"
41
  class="w3tc_cdn_stackpath2_list_stacks w3tc-button-save button-primary"
42
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
43
  </p>
44
  <?php Util_Ui::postbox_footer(); ?>
45
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_form">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
  <td>API Client ID:</td>
19
  <td>
20
  <input name="client_id" type="text" class="w3tc-ignore-change"
21
  style="width: 550px"
22
+ value="<?php echo esc_attr( $details['client_id'] ); ?>" />
23
  </td>
24
  </tr>
25
  <tr>
27
  <td>
28
  <input name="client_secret" type="text" class="w3tc-ignore-change"
29
  style="width: 550px"
30
+ value="<?php echo esc_attr( $details['client_secret'] ); ?>" />
31
  <p 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
  </p>
36
  </td>
40
  <p class="submit">
41
  <input type="button"
42
  class="w3tc_cdn_stackpath2_list_stacks w3tc-button-save button-primary"
43
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
44
  </p>
45
  <?php Util_Ui::postbox_footer(); ?>
46
  </div>
Cdn_StackPath2_Popup_View_Sites.php CHANGED
@@ -1,18 +1,18 @@
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 ) {
@@ -20,19 +20,17 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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
@@ -47,7 +45,7 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_form" method="post">
9
+ <?php Util_Ui::hidden( '', 'api_config', $details['api_config'] ); ?>
10
+
 
11
  <div class="metabox-holder">
12
+ <?php Util_Ui::postbox_header( esc_html__( 'Select site to use', 'w3-total-cache' ) ); ?>
13
  <table class="form-table">
14
  <tr>
15
+ <td><?php esc_html_e( 'Site:', 'w3-total-cache' ); ?></td>
16
  <td>
17
  <?php
18
  if ( count( $details['sites'] ) > 15 ) {
20
  }
21
  ?>
22
 
23
+ <?php foreach ( $details['sites'] as $i ) : ?>
 
24
  <label>
25
  <input name="site_id" type="radio" class="w3tc-ignore-change"
26
+ value="<?php echo esc_attr( $i['id'] ); ?>" />
27
+ <?php echo esc_html( $i['label'] ); ?>
28
  </label><br />
29
  <?php endforeach ?>
30
 
31
  <label>
32
+ <input name="site_id" type="radio" class="w3tc-ignore-change" value="" />
33
+ <?php echo esc_html__( 'Add new site: ', 'w3-total-cache' ) . esc_html( $details['new_hostname'] ); ?>
 
34
  </label>
35
 
36
  <?php
45
  <p class="submit">
46
  <input type="button"
47
  class="w3tc_cdn_stackpath2_configure_site w3tc-button-save button-primary"
48
+ value="<?php esc_html_e( 'Apply', 'w3-total-cache' ); ?>" />
49
  </p>
50
  <?php Util_Ui::postbox_footer(); ?>
51
  </div>
Cdn_StackPath2_Popup_View_Stacks.php CHANGED
@@ -1,15 +1,16 @@
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>
@@ -20,14 +21,13 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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 ?>
@@ -44,7 +44,7 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_form" method="post">
9
  <?php
10
+ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
11
+ ?>
12
  <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( esc_html__( 'Select stack to use', 'w3-total-cache' ) ); ?>
14
  <table class="form-table">
15
  <tr>
16
  <td>Site:</td>
21
  }
22
  ?>
23
 
24
+ <?php foreach ( $details['stacks'] as $i ) : ?>
 
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 ( 'ACTIVE' !== $i['status'] ) : ?>
30
+ (<?php echo esc_html( $i['status'] ); ?>)
31
  <?php endif ?>
32
  </label><br />
33
  <?php endforeach ?>
44
  <p class="submit">
45
  <input type="button"
46
  class="w3tc_cdn_stackpath2_list_sites w3tc-button-save button-primary"
47
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
48
  </p>
49
  <?php Util_Ui::postbox_footer(); ?>
50
  </div>
Cdn_StackPath2_Popup_View_Success.php CHANGED
@@ -1,23 +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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ <?php esc_html_e( 'Site was successfully configured.', 'w3-total-cache' ); ?><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 esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
20
+ </p>
21
+ <?php Util_Ui::postbox_footer(); ?>
22
+ </div>
23
  </form>
Cdn_StackPath2_Widget_View_Authorized.php CHANGED
@@ -1,8 +1,9 @@
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">
@@ -14,26 +15,26 @@ if ( !defined( 'W3TC' ) )
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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div class="w3tcstackpath2_loading w3tc_loading w3tc_hidden">Loading...</div>
9
  <div class="w3tcstackpath2_error w3tc_none">
15
  <div class="w3tcstackpath2_wrapper">
16
  <div class="w3tcstackpath2_tools">
17
  <ul class="w3tcstackpath2_ul">
18
+ <li><a class="button w3tcstackpath2_href_manage" href=""><?php esc_html_e( 'Manage', 'w3-total-cache' ); ?></a></li>
19
+ <li><a class="button w3tcstackpath2_href_reports" href=""><?php esc_html_e( 'Reports', 'w3-total-cache' ); ?></a></li>
20
+ <li><a class="button" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=w3tc_cdn&amp;w3tc_cdn_purge' ) ) ); ?>" onclick="w3tc_popupadmin_bar( this.href ); return false;"><?php esc_html_e( 'Purge', 'w3-total-cache' ); ?></a></li>
21
  </ul>
22
  </div>
23
  <div class="w3tcstackpath2_summary">
24
+ <h4 class="w3tcstackpath2_summary_h4"><?php esc_html_e( 'Report - 7 days', 'w3-total-cache' ); ?></h4>
25
  </div>
26
  <ul class="w3tcstackpath2_ul">
27
  <li>
28
+ <span class="w3tcstackpath2_summary_col1"><?php esc_html_e( 'Transferred', 'w3-total-cache' ); ?>:</span>
29
  <span class="w3tcstackpath2_summary_col2 w3tcstackpath2_summary_mb"></span>
30
  </li>
31
  <li>
32
+ <span class="w3tcstackpath2_summary_col1"><?php esc_html_e( 'Requests', 'w3-total-cache' ); ?>:</span>
33
  <span class="w3tcstackpath2_summary_col2 w3tcstackpath2_summary_requests"></span>
34
  </li>
35
  </ul>
36
  <div class="w3tcstackpath2_chart charts w3tcstackpath2_area">
37
+ <h4 class="w3tcstackpath2_h4"><?php esc_html_e( 'Requests', 'w3-total-cache' ); ?></h4>
38
  <div id="chart_div" style="width: 320px; height: 220px;margin-left: auto ; margin-right: auto ;"></div>
39
  </div>
40
  </div>
Cdn_StackPath2_Widget_View_Unauthorized.php CHANGED
@@ -1,33 +1,61 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <div id="stackpath-widget" class="w3tcstackpath_signup">
9
- <?php if ( !$c->get_boolean( 'cdn.enabled' ) ): ?>
10
  <p class="notice notice-error">
11
- <?php w3tc_e( 'cdn.stackpath.widget.v2.no_cdn',
12
- 'W3 Total Cache has detected that you do not have a <acronym title="Content Delivery Network">CDN</acronym> configured' ) ?>
 
 
 
 
 
13
  </p>
14
  <?php endif ?>
15
 
16
  <p>
17
- <?php w3tc_e( 'cdn.stackpath.widget.v2.header',
18
- "Enhance your website performance by adding StackPath's (<acronym title='Content Delivery Network'>CDN</acronym>) service to your site." ) ?>
 
 
 
 
 
19
  </p>
20
- <h4 class="w3tcstackpath_signup_h4"><?php _e( 'New customer? Sign up now to speed up your site!', 'w3-total-cache' )?></h4>
21
 
22
  <p>
23
- <?php w3tc_e( 'cdn.stackpath2.widget.v2.works_magically',
24
- 'StackPath works magically with W3 Total Cache to speed up your site around the world for as little as $10 per month.' )?>
 
 
 
 
25
  </p>
26
- <a class="button-primary" href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL )?>" target="_blank"><?php _e( 'Sign Up Now ', 'w3-total-cache' )?></a>
 
 
27
  <p>
28
- <h4 class="w3tcstackpath_signup_h4"><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
29
  <p>
30
- <?php w3tc_e( 'cdn.stackpath2.widget.v2.existing', "If you're an existing StackPath customer, enable <acronym title='Content Delivery Network'>CDN</acronym> and Authorize. If you need help configuring your <acronym title='Content Delivery Network'>CDN</acronym>, we also offer Premium Services to assist you." )?></p>
31
- <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>
32
- <a class="button" href="<?php echo wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_support' ), 'w3tc' )?>"><?php _e( 'Premium Services', 'w3-total-cache' )?></a>
 
 
 
 
 
 
 
 
 
 
 
 
33
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div id="stackpath-widget" class="w3tcstackpath_signup">
9
+ <?php if ( ! $c->get_boolean( 'cdn.enabled' ) ) : ?>
10
  <p class="notice notice-error">
11
+ <?php
12
+ w3tc_e(
13
+ 'cdn.stackpath.widget.v2.no_cdn',
14
+ 'W3 Total Cache has detected that you do not have a <acronym title="Content Delivery Network">CDN</acronym>
15
+ configured'
16
+ );
17
+ ?>
18
  </p>
19
  <?php endif ?>
20
 
21
  <p>
22
+ <?php
23
+ w3tc_e(
24
+ 'cdn.stackpath.widget.v2.header',
25
+ "Enhance your website performance by adding StackPath's (<acronym title='Content Delivery Network'>CDN</acronym>)
26
+ service to your site."
27
+ );
28
+ ?>
29
  </p>
30
+ <h4 class="w3tcstackpath_signup_h4"><?php esc_html_e( 'New customer? Sign up now to speed up your site!', 'w3-total-cache' ); ?></h4>
31
 
32
  <p>
33
+ <?php
34
+ w3tc_e(
35
+ 'cdn.stackpath2.widget.v2.works_magically',
36
+ 'StackPath works magically with W3 Total Cache to speed up your site around the world for as little as $10 per month.'
37
+ );
38
+ ?>
39
  </p>
40
+ <a class="button-primary" href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL ); ?>" target="_blank">
41
+ <?php esc_html_e( 'Sign Up Now ', 'w3-total-cache' ); ?>
42
+ </a>
43
  <p>
44
+ <h4 class="w3tcstackpath_signup_h4"><?php esc_html_e( 'Current customers', 'w3-total-cache' ); ?></h4>
45
  <p>
46
+ <?php
47
+ w3tc_e(
48
+ 'cdn.stackpath2.widget.v2.existing',
49
+ "If you're an existing StackPath customer, enable <acronym title='Content Delivery Network'>CDN</acronym>
50
+ and Authorize. If you need help configuring your <acronym title='Content Delivery Network'>CDN</acronym>,
51
+ we also offer Premium Services to assist you."
52
+ );
53
+ ?>
54
+ </p>
55
+ <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' ) ); ?>" target="_blank">
56
+ <?php esc_html_e( 'Authorize', 'w3-total-cache' ); ?>
57
+ </a>
58
+ <a class="button" href="<?php echo esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_support' ), 'w3tc' ) ); ?>">
59
+ <?php esc_html_e( 'Premium Services', 'w3-total-cache' ); ?>
60
+ </a>
61
  </div>
Cdn_StackPath_Page_View.php CHANGED
@@ -1,95 +1,252 @@
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.stackpath.signUpAndSave', 'Sign Up Now and save!' ) ?></a>
13
- <p 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!' )?></p>
14
  </td>
15
  </tr>
16
- <?php endif ?>
17
-
18
-
19
 
20
  <tr>
21
  <th style="width: 300px;">
22
  <label>
23
- <?php _e( 'Specify account credentials:', 'w3-total-cache' ); ?>
24
  </label>
25
  </th>
26
  <td>
27
- <?php if ( $authorized ): ?>
28
  <input class="w3tc_cdn_stackpath_authorize button-primary"
29
  type="button"
30
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
31
  />
32
- <?php else: ?>
33
  <input class="w3tc_cdn_stackpath_authorize button-primary"
34
  type="button"
35
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
36
  />
37
- <?php endif ?>
38
  </td>
39
  </tr>
40
 
41
- <?php if ( $authorized ): ?>
42
- <?php if ( !is_null( $http_domain ) ): ?>
43
- <tr>
44
- <th>
45
- <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>
46
- </th>
47
- <td class="w3tc_config_value_text">
48
- <?php echo htmlspecialchars( $http_domain ) ?>
49
- <p class="description">
50
- This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
51
- <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol">HTTP</acronym> requests
52
- </p>
53
- </td>
54
- </tr>
55
- <?php endif ?>
56
- <?php if ( !is_null( $https_domain ) ): ?>
57
- <tr>
58
- <th>
59
- <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>
60
- </th>
61
- <td class="w3tc_config_value_text">
62
- <?php echo htmlspecialchars( $https_domain ) ?>
63
- <p class="description">
64
- This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
65
- <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
66
- </p>
67
- </td>
68
- </tr>
69
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
70
 
71
- <tr>
72
- <th><label for="cdn_stackpath_ssl"><?php _e( '<acronym title="Secure Sockets Layer">SSL</acronym> support', 'w3-total-cache' )?>:</label></th>
73
- <td>
74
- <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ) ?>>
75
- <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>><?php _e( 'Auto (determine connection type automatically)', 'w3-total-cache' )?></option>
76
- <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>
77
- <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>
78
- </select>
79
- <p 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' )?></p>
80
- </td>
81
- </tr>
82
- <tr>
83
- <th><?php _e( 'Replace site\'s hostname with:', 'w3-total-cache' )?></th>
84
- <td>
85
- <?php $cnames = $config->get_array( 'cdn.stackpath.domain' ); include W3TC_INC_DIR . '/options/cdn/common/cnames.php'; ?>
86
- <p 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' )?></p>
87
- </td>
88
- </tr>
89
- <tr>
90
- <th colspan="2">
91
- <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>
92
- </th>
93
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
- <?php endif ?>
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 esc_html_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
+ <p 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!' ); ?></p>
14
  </td>
15
  </tr>
16
+ <?php endif; ?>
 
 
17
 
18
  <tr>
19
  <th style="width: 300px;">
20
  <label>
21
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
22
  </label>
23
  </th>
24
  <td>
25
+ <?php if ( $authorized ) : ?>
26
  <input class="w3tc_cdn_stackpath_authorize button-primary"
27
  type="button"
28
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>"
29
  />
30
+ <?php else : ?>
31
  <input class="w3tc_cdn_stackpath_authorize button-primary"
32
  type="button"
33
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>"
34
  />
35
+ <?php endif; ?>
36
  </td>
37
  </tr>
38
 
39
+ <?php if ( $authorized ) : ?>
40
+ <?php if ( ! is_null( $http_domain ) ) : ?>
41
+ <tr>
42
+ <th>
43
+ <label>
44
+ <?php
45
+ wp_kses(
46
+ sprintf(
47
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
48
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
49
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
50
+ __(
51
+ '%1$sCDN%2$s %3$sHTTP%4$s %5$sCNAME%6$s:',
52
+ 'w3-total-cache'
53
+ ),
54
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
55
+ '</acronym>',
56
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol', 'w3-total-cache' ) . '">',
57
+ '</acronym>',
58
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
59
+ '</acronym>'
60
+ ),
61
+ array(
62
+ 'acronym' => array(
63
+ 'title' => array(),
64
+ ),
65
+ )
66
+ );
67
+ ?>
68
+ </label>
69
+ </th>
70
+ <td class="w3tc_config_value_text">
71
+ <?php echo esc_html( $http_domain ); ?>
72
+ <p class="description">
73
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
74
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol">HTTP</acronym> requests
75
+ </p>
76
+ </td>
77
+ </tr>
78
+ <?php endif; ?>
79
 
80
+ <?php if ( ! is_null( $https_domain ) ) : ?>
81
+ <tr>
82
+ <th>
83
+ <label>
84
+ <?php
85
+ wp_kses(
86
+ sprintf(
87
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
88
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
89
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
90
+ __(
91
+ '%1$sCDN%2$s %3$sHTTPS%4$s %5$sCNAME%6$s:',
92
+ 'w3-total-cache'
93
+ ),
94
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
95
+ '</acronym>',
96
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol over SSL', 'w3-total-cache' ) . '">',
97
+ '</acronym>',
98
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
99
+ '</acronym>'
100
+ ),
101
+ array(
102
+ 'acronym' => array(
103
+ 'title' => array(),
104
+ ),
105
+ )
106
+ );
107
+ ?>
108
+ </label>
109
+ </th>
110
+ <td class="w3tc_config_value_text">
111
+ <?php echo esc_html( $https_domain ); ?>
112
+ <p class="description">
113
+ This website domain has to be <acronym title="Canonical Name">CNAME</acronym> pointing to this
114
+ <acronym title="Content Delivery Network">CDN</acronym> domain for <acronym title="HyperText Transfer Protocol over SSL">HTTPS</acronym> requests
115
+ </p>
116
+ </td>
117
+ </tr>
118
+ <?php endif; ?>
119
+
120
+ <tr>
121
+ <th>
122
+ <label for="cdn_stackpath_ssl">
123
+ <?php
124
+ echo wp_kses(
125
+ sprintf(
126
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
127
+ __(
128
+ '%1$sSSL%2$s support:',
129
+ 'w3-total-cache'
130
+ ),
131
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
132
+ '</acronym>'
133
+ ),
134
+ array(
135
+ 'acronym' => array(
136
+ 'title' => array(),
137
+ ),
138
+ )
139
+ );
140
+ ?>
141
+ </label>
142
+ </th>
143
+ <td>
144
+ <select id="cdn_stackpath_ssl" name="cdn__stackpath__ssl" <?php Util_Ui::sealing_disabled( 'cdn.' ); ?>>
145
+ <option value="auto"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'auto' ); ?>>
146
+ <?php esc_html_e( 'Auto (determine connection type automatically)', 'w3-total-cache' ); ?>
147
+ </option>
148
+ <option value="enabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'enabled' ); ?>>
149
+ <?php
150
+ echo wp_kses(
151
+ sprintf(
152
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
153
+ __(
154
+ 'Enabled (always use %1$sSSL%2$s)',
155
+ 'w3-total-cache'
156
+ ),
157
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
158
+ '</acronym>'
159
+ ),
160
+ array(
161
+ 'acronym' => array(
162
+ 'title' => array(),
163
+ ),
164
+ )
165
+ );
166
+ ?>
167
+ </option>
168
+ <option value="disabled"<?php selected( $config->get_string( 'cdn.stackpath.ssl' ), 'disabled' ); ?>>
169
+ <?php
170
+ echo wp_kses(
171
+ sprintf(
172
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
173
+ __(
174
+ 'Disabled (always use %1$sHTTP%2$s)',
175
+ 'w3-total-cache'
176
+ ),
177
+ '<acronym title="' . esc_attr__( 'HyperText Transfer Protocol', 'w3-total-cache' ) . '">',
178
+ '</acronym>'
179
+ ),
180
+ array(
181
+ 'acronym' => array(
182
+ 'title' => array(),
183
+ ),
184
+ )
185
+ );
186
+ ?>
187
+ </option>
188
+ </select>
189
+ <p class="description">
190
+ <?php
191
+ echo wp_kses(
192
+ sprintf(
193
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
194
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
195
+ __(
196
+ 'Some %1$sCDN%2$s providers may or may not support %3$sSSL%4$s, contact your vendor for more information.',
197
+ 'w3-total-cache'
198
+ ),
199
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
200
+ '</acronym>',
201
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
202
+ '</acronym>'
203
+ ),
204
+ array(
205
+ 'acronym' => array(
206
+ 'title' => array(),
207
+ ),
208
+ )
209
+ );
210
+ ?>
211
+ </p>
212
+ </td>
213
+ </tr>
214
+ <tr>
215
+ <th><?php esc_html_e( 'Replace site\'s hostname with:', 'w3-total-cache' ); ?></th>
216
+ <td>
217
+ <?php
218
+ $cnames = $config->get_array( 'cdn.stackpath.domain' );
219
+ include W3TC_INC_DIR . '/options/cdn/common/cnames.php';
220
+ ?>
221
+ <p class="description">
222
+ <?php
223
+ echo wp_kses(
224
+ sprintf(
225
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
226
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
227
+ __(
228
+ 'Enter the hostname provided by your %1$sCDN%2$s provider, this value will replace your site\'s hostname in the %3$sHTML%4$s.',
229
+ 'w3-total-cache'
230
+ ),
231
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
232
+ '</acronym>',
233
+ '<acronym title="' . esc_attr__( 'Hypertext Markup Language', 'w3-total-cache' ) . '">',
234
+ '</acronym>'
235
+ ),
236
+ array(
237
+ 'acronym' => array(
238
+ 'title' => array(),
239
+ ),
240
+ )
241
+ );
242
+ ?>
243
+ </p>
244
+ </td>
245
+ </tr>
246
+ <tr>
247
+ <th colspan="2">
248
+ <input id="cdn_test" class="button {type: 'stackpath', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}" type="button" value="<?php esc_attr_e( 'Test StackPath', 'w3-total-cache' ); ?>" /> <span id="cdn_test_status" class="w3tc-status w3tc-process"></span>
249
+ </th>
250
+ </tr>
251
 
252
+ <?php endif; ?>
Cdn_StackPath_Popup.php CHANGED
@@ -39,7 +39,7 @@ class Cdn_StackPath_Popup {
39
 
40
 
41
  public function w3tc_ajax_cdn_stackpath_list_zones() {
42
- $api_key = $_REQUEST['api_key'];
43
 
44
  $api = Cdn_StackPath_Api::create( $api_key );
45
  if ( !$api->is_valid() ) {
@@ -79,7 +79,7 @@ class Cdn_StackPath_Popup {
79
 
80
  public function w3tc_ajax_cdn_StackPath_view_zone() {
81
  $config = Dispatcher::config();
82
- $api_key = $_REQUEST['api_key'];
83
  $zone_id = Util_Request::get( 'zone_id', '' );
84
 
85
  $details = array(
@@ -147,7 +147,7 @@ class Cdn_StackPath_Popup {
147
 
148
 
149
  public function w3tc_ajax_cdn_stackpath_configure_zone() {
150
- $api_key = $_REQUEST['api_key'];
151
  $zone_id = Util_Request::get( 'zone_id', '' );
152
 
153
  if ( empty( $zone_id ) ) {
@@ -163,16 +163,16 @@ class Cdn_StackPath_Popup {
163
  } else {
164
  $zone = array();
165
 
166
- if ( isset( $_REQUEST['url_change'] ) ) {
167
- $zone['url'] = Util_Request::get( 'url' );
168
  }
169
- if ( isset( $_REQUEST['compress_change'] ) ) {
170
- $zone['compress'] = Util_Request::get( 'compress' );
171
  }
172
- if ( isset( $_REQUEST['cors_headers_change'] ) ) {
173
- $zone['cors_headers'] = Util_Request::get( 'cors_headers' );
174
  }
175
- if ( Util_Request::get( 'ssl' ) == 'shared' ) {
176
  $zone['sslshared'] = 1;
177
  $zone['http2'] = 1;
178
  }
@@ -221,21 +221,21 @@ class Cdn_StackPath_Popup {
221
 
222
  if ( !isset( $details[$field]['current'] ) ) {
223
  echo 'will be set to <strong>';
224
- echo htmlspecialchars( $details[$field]['new'] );
225
  echo '</strong>';
226
  } elseif ( $details[$field]['current'] == $details[$field]['new'] ) {
227
  echo '<strong>';
228
- echo htmlspecialchars( $details[$field]['new'] );
229
  echo '</strong>';
230
  } else {
231
  echo 'currently set to <strong>';
232
- echo htmlspecialchars( $details[$field]['current'] );
233
  echo '</strong><br />';
234
  echo '<label class="w3tc_change_label">';
235
- echo '<input type="checkbox" name="' . $field . '_change" value="y"' .
236
  ' checked="checked" /> ';
237
  echo 'change to <strong>';
238
- echo htmlspecialchars( $details[$field]['new'] );
239
  echo '</strong></label><br />';
240
  }
241
  }
@@ -257,7 +257,7 @@ class Cdn_StackPath_Popup {
257
  $this->render_zone_boolean( $details[$field]['current'] );
258
  echo '</strong><br />';
259
  echo '<label class="w3tc_change_label">';
260
- echo '<input type="checkbox" name="' . $field . '_change" value="y"' .
261
  ' checked="checked" /> ';
262
  echo 'change to <strong>';
263
  $this->render_zone_boolean( $details[$field]['new'] );
39
 
40
 
41
  public function w3tc_ajax_cdn_stackpath_list_zones() {
42
+ $api_key = Util_Request::get_string( 'api_key' );
43
 
44
  $api = Cdn_StackPath_Api::create( $api_key );
45
  if ( !$api->is_valid() ) {
79
 
80
  public function w3tc_ajax_cdn_StackPath_view_zone() {
81
  $config = Dispatcher::config();
82
+ $api_key = Util_Request::get_string( 'api_key' );
83
  $zone_id = Util_Request::get( 'zone_id', '' );
84
 
85
  $details = array(
147
 
148
 
149
  public function w3tc_ajax_cdn_stackpath_configure_zone() {
150
+ $api_key = Util_Request::get_string( 'api_key' );
151
  $zone_id = Util_Request::get( 'zone_id', '' );
152
 
153
  if ( empty( $zone_id ) ) {
163
  } else {
164
  $zone = array();
165
 
166
+ if ( ! empty( Util_Request::get_string( 'url_change' ) ) ) {
167
+ $zone['url'] = Util_Request::get_string( 'url' );
168
  }
169
+ if ( ! empty( Util_Request::get_string( 'compress_change' ) ) ) {
170
+ $zone['compress'] = Util_Request::get_string( 'compress' );
171
  }
172
+ if ( ! empty( Util_Request::get_string( 'cors_headers_change' ) ) ) {
173
+ $zone['cors_headers'] = Util_Request::get_string( 'cors_headers' );
174
  }
175
+ if ( Util_Request::get_string( 'ssl' ) == 'shared' ) {
176
  $zone['sslshared'] = 1;
177
  $zone['http2'] = 1;
178
  }
221
 
222
  if ( !isset( $details[$field]['current'] ) ) {
223
  echo 'will be set to <strong>';
224
+ echo esc_html( $details[ $field ]['new'] );
225
  echo '</strong>';
226
  } elseif ( $details[$field]['current'] == $details[$field]['new'] ) {
227
  echo '<strong>';
228
+ echo esc_html( $details[ $field ]['new'] );
229
  echo '</strong>';
230
  } else {
231
  echo 'currently set to <strong>';
232
+ echo esc_html( $details[ $field ]['current'] );
233
  echo '</strong><br />';
234
  echo '<label class="w3tc_change_label">';
235
+ echo '<input type="checkbox" name="' . esc_attr( $field ) . '_change" value="y"' .
236
  ' checked="checked" /> ';
237
  echo 'change to <strong>';
238
+ echo esc_html( $details[ $field ]['new'] );
239
  echo '</strong></label><br />';
240
  }
241
  }
257
  $this->render_zone_boolean( $details[$field]['current'] );
258
  echo '</strong><br />';
259
  echo '<label class="w3tc_change_label">';
260
+ echo '<input type="checkbox" name="' . esc_attr( $field ) . '_change" value="y"' .
261
  ' checked="checked" /> ';
262
  echo 'change to <strong>';
263
  $this->render_zone_boolean( $details[$field]['new'] );
Cdn_StackPath_Popup_View_Intro.php CHANGED
@@ -1,28 +1,44 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_stackpath_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
  <p class="description">
23
- To obtain API key you can
24
- <a target="_blank" href="<?php echo $url_obtain_key ?>">click here</a>,
25
- log in, and paste the key in above field.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  </p>
27
  </td>
28
  </tr>
@@ -31,7 +47,7 @@ if ( isset( $details['error_message'] ) )
31
  <p class="submit">
32
  <input type="button"
33
  class="w3tc_cdn_stackpath_list_zones w3tc-button-save button-primary"
34
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
35
  </p>
36
  <?php Util_Ui::postbox_footer(); ?>
37
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath_form">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
  <td>API Key:</td>
19
  <td>
20
  <input name="api_key" type="text" class="w3tc-ignore-change"
21
  style="width: 550px"
22
+ value="<?php echo esc_attr( $details['api_key'] ); ?>" />
23
  <p class="description">
24
+ <?php
25
+ echo wp_kses(
26
+ sprintf(
27
+ // translators: 1 HTML a tag to Stackpath API key page.
28
+ __(
29
+ 'To obtain API key you can %1$s, log in, and paste the key in above field.',
30
+ 'w3-total-cache'
31
+ ),
32
+ '<a target="_blank" href="' . esc_url( $url_obtain_key ) . '">' . esc_html__( 'click here', 'w3-total-cache' ) . '</a>'
33
+ ),
34
+ array(
35
+ 'a' => array(
36
+ 'target' => array(),
37
+ 'href' => array(),
38
+ ),
39
+ )
40
+ );
41
+ ?>
42
  </p>
43
  </td>
44
  </tr>
47
  <p class="submit">
48
  <input type="button"
49
  class="w3tc_cdn_stackpath_list_zones w3tc-button-save button-primary"
50
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
51
  </p>
52
  <?php Util_Ui::postbox_footer(); ?>
53
  </div>
Cdn_StackPath_Popup_View_Success.php CHANGED
@@ -1,23 +1,23 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_stackpath_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_stackpath_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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( __( '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_stackpath_done w3tc-button-save button-primary"
19
+ value="<?php esc_html_e( 'Done', 'w3-total-cache' ); ?>" />
20
+ </p>
21
+ <?php Util_Ui::postbox_footer(); ?>
22
+ </div>
23
  </form>
Cdn_StackPath_Popup_View_Zone.php CHANGED
@@ -1,42 +1,43 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_stackpath_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
11
- Util_Ui::hidden( '', 'name', $details['name'] );
12
- ?>
13
 
14
- <div class="metabox-holder">
15
- <?php Util_Ui::postbox_header( __( 'Configure zone', 'w3-total-cache' ) ); ?>
16
- <table class="form-table">
17
- <tr>
18
- <th>Name:</th>
19
- <td><?php echo $details['name'] ?></td>
20
- </tr>
21
- <tr>
22
- <th>Origin URL:</th>
23
- <td><?php $this->render_zone_textbox_change( $details, 'url' ) ?></td>
24
- </tr>
25
- <tr>
26
- <th>Compress content:</th>
27
- <td><?php $this->render_zone_boolean_change( $details, 'compress' ) ?></td>
28
- </tr>
29
- <tr>
30
- <th>Add CORS header:</th>
31
- <td><?php $this->render_zone_boolean_change( $details, 'cors_headers' ) ?></td>
32
- </tr>
33
- </table>
34
 
35
- <p class="submit">
36
- <input type="button"
37
- class="w3tc_cdn_stackpath_configure_zone w3tc-button-save button-primary"
38
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
39
- </p>
40
- <?php Util_Ui::postbox_footer(); ?>
41
- </div>
42
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath_form" method="post">
9
+ <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
12
+ Util_Ui::hidden( '', 'name', $details['name'] );
13
+ ?>
14
 
15
+ <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Configure zone', 'w3-total-cache' ) ); ?>
17
+ <table class="form-table">
18
+ <tr>
19
+ <th>Name:</th>
20
+ <td><?php echo esc_html( $details['name'] ); ?></td>
21
+ </tr>
22
+ <tr>
23
+ <th>Origin URL:</th>
24
+ <td><?php $this->render_zone_textbox_change( $details, 'url' ); ?></td>
25
+ </tr>
26
+ <tr>
27
+ <th>Compress content:</th>
28
+ <td><?php $this->render_zone_boolean_change( $details, 'compress' ); ?></td>
29
+ </tr>
30
+ <tr>
31
+ <th>Add CORS header:</th>
32
+ <td><?php $this->render_zone_boolean_change( $details, 'cors_headers' ); ?></td>
33
+ </tr>
34
+ </table>
35
 
36
+ <p class="submit">
37
+ <input type="button"
38
+ class="w3tc_cdn_stackpath_configure_zone w3tc-button-save button-primary"
39
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
40
+ </p>
41
+ <?php Util_Ui::postbox_footer(); ?>
42
+ </div>
43
  </form>
Cdn_StackPath_Popup_View_Zones.php CHANGED
@@ -1,53 +1,55 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_cdn_stackpath_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- ?>
11
- <div class="metabox-holder">
12
- <?php Util_Ui::postbox_header( __( 'Select zone to use', 'w3-total-cache' ) ); ?>
13
- <table class="form-table">
14
- <tr>
15
- <td>Zone:</td>
16
- <td>
17
- <?php
18
- if ( count( $details['zones'] ) > 15 )
19
- echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
- ?>
 
21
 
22
- <?php foreach ( $details['zones'] as $zone ): ?>
23
- <label>
24
- <input name="zone_id" type="radio" class="w3tc-ignore-change"
25
- value="<?php echo $zone['id'] ?>" />
26
- <?php echo $zone['name'] ?>
27
- (<?php echo $zone['cdn_url'] ?>)
28
- </label><br />
29
- <?php endforeach ?>
30
 
31
- <label>
32
- <input name="zone_id" type="radio" class="w3tc-ignore-change" value=""
33
- />
34
- Add new zone:
35
- </label>
36
- <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
37
 
38
- <?php
39
- if ( count( $details['zones'] ) > 15 )
40
- echo '</div>';
41
- ?>
42
- </td>
43
- </tr>
44
- </table>
 
45
 
46
- <p class="submit">
47
- <input type="button"
48
- class="w3tc_cdn_stackpath_view_zone w3tc-button-save button-primary"
49
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
50
- </p>
51
- <?php Util_Ui::postbox_footer(); ?>
52
- </div>
53
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath_form" method="post">
9
+ <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ ?>
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( esc_html__( 'Select zone to use', 'w3-total-cache' ) ); ?>
14
+ <table class="form-table">
15
+ <tr>
16
+ <td>Zone:</td>
17
+ <td>
18
+ <?php
19
+ if ( count( $details['zones'] ) > 15 ) {
20
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
21
+ }
22
+ ?>
23
 
24
+ <?php foreach ( $details['zones'] as $zone ) : ?>
25
+ <label>
26
+ <input name="zone_id" type="radio" class="w3tc-ignore-change"
27
+ value="<?php echo esc_attr( $zone['id'] ); ?>" />
28
+ <?php echo esc_html( $zone['name'] ); ?>
29
+ (<?php echo esc_html( $zone['cdn_url'] ); ?>)
30
+ </label><br />
31
+ <?php endforeach ?>
32
 
33
+ <label>
34
+ <input name="zone_id" type="radio" class="w3tc-ignore-change" value="" />
35
+ Add new zone:
36
+ </label>
37
+ <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
 
38
 
39
+ <?php
40
+ if ( count( $details['zones'] ) > 15 ) {
41
+ echo '</div>';
42
+ }
43
+ ?>
44
+ </td>
45
+ </tr>
46
+ </table>
47
 
48
+ <p class="submit">
49
+ <input type="button"
50
+ class="w3tc_cdn_stackpath_view_zone w3tc-button-save button-primary"
51
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
52
+ </p>
53
+ <?php Util_Ui::postbox_footer(); ?>
54
+ </div>
55
  </form>
Cdn_StackPath_Widget_View_Authorized.php CHANGED
@@ -1,75 +1,75 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <div class="w3tcstackpath_loading w3tc_loading w3tc_hidden">Loading...</div>
8
  <div class="w3tcstackpath_error w3tc_none">
9
- An error occurred
10
- <div class="w3tcstackpath_error_details"></div>
11
  </div>
12
 
13
  <div id="stackpath-widget" class="stackpath-netdna-widget-base w3tcstackpath_content w3tc_hidden">
14
- <div class="w3tcstackpath_wrapper">
15
- <div class="w3tcstackpath_status">
16
- <p>
17
- <span>
18
- <?php _e( 'Status', 'w3-total-cache' ) ?>
19
- <span class="w3tcstackpath_account_status"></span>
20
- </span>
21
- <span style="display:inline-block;float:right">
22
- <?php _e( 'Content Zone:', 'w3-total-cache' ) ?>
23
- <span class="w3tcstackpath_zone_name"></span>
24
- </span>
25
- </p>
26
-
27
- </div>
28
- <div class="w3tcstackpath_tools">
29
- <ul class="w3tcstackpath_ul">
30
- <li><a class="button w3tcstackpath_href_manage" href=""><?php _e( 'Manage', 'w3-total-cache' )?></a></li>
31
- <li><a class="button w3tcstackpath_href_reports" href=""><?php _e( 'Reports', 'w3-total-cache' )?></a></li>
32
- <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>
33
- </ul>
34
- </div>
35
- <div class="w3tcstackpath_summary">
36
- <h4 class="w3tcstackpath_summary_h4"><?php _e( 'Report - 30 days', 'w3-total-cache' ) ?></h4>
37
- </div>
38
- <ul class="w3tcstackpath_ul">
39
- <li>
40
- <span class="w3tcstackpath_summary_col1"><?php _e('Transferred', 'w3-total-cache') ?>:</span>
41
- <span class="w3tcstackpath_summary_col2 w3tcstackpath_summary_size"></span>
42
- </li>
43
- <li>
44
- <span class="w3tcstackpath_summary_col1"><?php _e('Cache Hits', 'w3-total-cache' ) ?>:</span>
45
- <span class="w3tcstackpath_summary_col2">
46
- <span class="w3tcstackpath_summary_cache_hit"></span>
47
- (<span class="w3tcstackpath_summary_cache_hit_percentage"></span>)
48
- </span>
49
- </li>
50
- <li>
51
- <span class="w3tcstackpath_summary_col1"><?php _e('Cache Misses', 'w3-total-cache') ?>:</span>
52
- <span class="w3tcstackpath_summary_col2">
53
- <span class="w3tcstackpath_summary_noncache_hit">
54
- (<span class="w3tcstackpath_summary_noncache_hit_percentage"></span>)
55
- </span>
56
- </li>
57
- </ul>
58
- <div class="w3tcstackpath_chart charts w3tcstackpath_area">
59
- <h4 class="w3tcstackpath_h4"><?php _e( 'Requests', 'w3-total-cache' ) ?></h4>
60
- <div id="chart_div" style="width: 320px; height: 220px;margin-left: auto ; margin-right: auto ;"></div>
61
- <h4 class="w3tcstackpath_h4"><?php _e( 'Content Breakdown', 'w3-total-cache' ) ?></h4>
62
- <p>
63
- <span><?php _e( 'File', 'w3-total-cache' )?></span>
64
- <span style="display:inline-block;float:right"><?php _e( 'Hits', 'w3-total-cache' ) ?></span>
65
- </p>
66
- <ul class="w3tcstackpath_file_hits">
67
- <li>A</li>
68
- <li>A</li>
69
- <li>A</li>
70
- <li>A</li>
71
- <li>A</li>
72
- </ul>
73
- </div>
74
- </div>
75
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div class="w3tcstackpath_loading w3tc_loading w3tc_hidden">Loading...</div>
9
  <div class="w3tcstackpath_error w3tc_none">
10
+ An error occurred
11
+ <div class="w3tcstackpath_error_details"></div>
12
  </div>
13
 
14
  <div id="stackpath-widget" class="stackpath-netdna-widget-base w3tcstackpath_content w3tc_hidden">
15
+ <div class="w3tcstackpath_wrapper">
16
+ <div class="w3tcstackpath_status">
17
+ <p>
18
+ <span>
19
+ <?php esc_html_e( 'Status', 'w3-total-cache' ); ?>
20
+ <span class="w3tcstackpath_account_status"></span>
21
+ </span>
22
+ <span style="display:inline-block;float:right">
23
+ <?php esc_html_e( 'Content Zone:', 'w3-total-cache' ); ?>
24
+ <span class="w3tcstackpath_zone_name"></span>
25
+ </span>
26
+ </p>
27
+ </div>
28
+ <div class="w3tcstackpath_tools">
29
+ <ul class="w3tcstackpath_ul">
30
+ <li><a class="button w3tcstackpath_href_manage" href=""><?php esc_html_e( 'Manage', 'w3-total-cache' ); ?></a></li>
31
+ <li><a class="button w3tcstackpath_href_reports" href=""><?php esc_html_e( 'Reports', 'w3-total-cache' ); ?></a></li>
32
+ <li><a class="button" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=w3tc_cdn&amp;w3tc_cdn_purge' ) ) ); ?>" onclick="w3tc_popupadmin_bar(this.href); return false;"><?php esc_html_e( 'Purge', 'w3-total-cache' ); ?></a></li>
33
+ </ul>
34
+ </div>
35
+ <div class="w3tcstackpath_summary">
36
+ <h4 class="w3tcstackpath_summary_h4"><?php esc_html_e( 'Report - 30 days', 'w3-total-cache' ); ?></h4>
37
+ </div>
38
+ <ul class="w3tcstackpath_ul">
39
+ <li>
40
+ <span class="w3tcstackpath_summary_col1"><?php esc_html_e( 'Transferred', 'w3-total-cache' ); ?>:</span>
41
+ <span class="w3tcstackpath_summary_col2 w3tcstackpath_summary_size"></span>
42
+ </li>
43
+ <li>
44
+ <span class="w3tcstackpath_summary_col1"><?php esc_html_e( 'Cache Hits', 'w3-total-cache' ); ?>:</span>
45
+ <span class="w3tcstackpath_summary_col2">
46
+ <span class="w3tcstackpath_summary_cache_hit"></span>
47
+ (<span class="w3tcstackpath_summary_cache_hit_percentage"></span>)
48
+ </span>
49
+ </li>
50
+ <li>
51
+ <span class="w3tcstackpath_summary_col1"><?php esc_html_e( 'Cache Misses', 'w3-total-cache' ); ?>:</span>
52
+ <span class="w3tcstackpath_summary_col2">
53
+ <span class="w3tcstackpath_summary_noncache_hit">
54
+ (<span class="w3tcstackpath_summary_noncache_hit_percentage"></span>)
55
+ </span>
56
+ </li>
57
+ </ul>
58
+ <div class="w3tcstackpath_chart charts w3tcstackpath_area">
59
+ <h4 class="w3tcstackpath_h4"><?php esc_html_e( 'Requests', 'w3-total-cache' ); ?></h4>
60
+ <div id="chart_div" style="width: 320px; height: 220px;margin-left: auto ; margin-right: auto ;"></div>
61
+ <h4 class="w3tcstackpath_h4"><?php esc_html_e( 'Content Breakdown', 'w3-total-cache' ); ?></h4>
62
+ <p>
63
+ <span><?php esc_html_e( 'File', 'w3-total-cache' ); ?></span>
64
+ <span style="display:inline-block;float:right"><?php esc_html_e( 'Hits', 'w3-total-cache' ); ?></span>
65
+ </p>
66
+ <ul class="w3tcstackpath_file_hits">
67
+ <li>A</li>
68
+ <li>A</li>
69
+ <li>A</li>
70
+ <li>A</li>
71
+ <li>A</li>
72
+ </ul>
73
+ </div>
74
+ </div>
 
75
  </div>
Cdn_StackPath_Widget_View_Unauthorized.php CHANGED
@@ -1,17 +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.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>
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.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 esc_html_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 esc_html_e( 'Sign Up Now ', 'w3-total-cache' ); ?></a>
13
+ <p><!--span class="desc"><?php esc_html_e( 'Exclusive offers availabel for W3TC users!', 'w3-total-cache' ); ?></span></p>-->
14
+ <h4 class="w3tcstackpath_signup_h4"><?php esc_html_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 esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' ) ); ?>" target="_blank"><?php esc_html_e( 'Authorize', 'w3-total-cache' ); ?></a>
17
  </div>
Cdnfsd_CloudFront_Page_View.php CHANGED
@@ -1,58 +1,71 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- $key = $config->get_string( 'cdnfsd.cloudfront.access_key' );
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_cloudfront_fsd_authorize button-primary"
28
- type="button"
29
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
30
- />
31
- <?php else: ?>
32
  <input class="w3tc_cdn_cloudfront_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 $config->get_string( 'cdnfsd.cloudfront.distribution_domain' )
48
- ?>
49
  <p class="description">
50
  The website domain has to be a CNAME pointing to this
51
  <acronym title="Content Delivery Network">CDN</acronym> domain
52
  </p>
53
  </td>
54
  </tr>
55
- <?php endif ?>
56
  </table>
57
 
58
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ $key = $config->get_string( 'cdnfsd.cloudfront.access_key' );
9
+ $authorized = ! empty( $key );
10
 
11
  ?>
12
  <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
13
  <div class="metabox-holder">
14
+ <?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
 
15
  <table class="form-table">
16
  <tr>
17
  <th style="width: 300px;">
18
  <label>
19
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
 
 
 
20
  </label>
21
  </th>
22
  <td>
23
+ <?php if ( $authorized ) : ?>
24
  <input class="w3tc_cdn_cloudfront_fsd_authorize button-primary"
25
+ type="button" value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
26
+ <?php else : ?>
 
 
27
  <input class="w3tc_cdn_cloudfront_fsd_authorize button-primary"
28
+ type="button" value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
29
+ <?php endif; ?>
 
 
30
  </td>
31
  </tr>
32
 
33
+ <?php if ( $authorized ) : ?>
34
  <tr>
35
  <th>
36
+ <label>
37
+ <?php
38
+ echo wp_kses(
39
+ sprintf(
40
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
41
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
42
+ __(
43
+ '%1$sCDN%2$s %3$sCNAME%4$s:',
44
+ 'w3-total-cache'
45
+ ),
46
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
47
+ '</acronym>',
48
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
49
+ '</acronym>'
50
+ ),
51
+ array(
52
+ 'acronym' => array(
53
+ 'title' => array(),
54
+ ),
55
+ )
56
+ );
57
+ ?>
58
+ </label>
59
  </th>
60
  <td class="w3tc_config_value_text">
61
+ <?php echo esc_html( $config->get_string( 'cdnfsd.cloudfront.distribution_domain' ) ); ?>
 
 
62
  <p class="description">
63
  The website domain has to be a CNAME pointing to this
64
  <acronym title="Content Delivery Network">CDN</acronym> domain
65
  </p>
66
  </td>
67
  </tr>
68
+ <?php endif; ?>
69
  </table>
70
 
71
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
Cdnfsd_CloudFront_Popup.php CHANGED
@@ -45,8 +45,8 @@ class Cdnfsd_CloudFront_Popup {
45
 
46
 
47
  public function w3tc_ajax_cdn_cloudfront_fsd_list_distributions() {
48
- $access_key = $_REQUEST['access_key'];
49
- $secret_key = $_REQUEST['secret_key'];
50
 
51
  if ( empty( $access_key ) || empty( $secret_key ) ) {
52
  $this->render_intro( array(
@@ -100,8 +100,8 @@ class Cdnfsd_CloudFront_Popup {
100
 
101
 
102
  public function w3tc_ajax_cdn_cloudfront_fsd_view_distribution() {
103
- $access_key = $_REQUEST['access_key'];
104
- $secret_key = $_REQUEST['secret_key'];
105
  $distribution_id = Util_Request::get( 'distribution_id', '' );
106
 
107
  $details = array(
@@ -188,39 +188,29 @@ class Cdnfsd_CloudFront_Popup {
188
  private function render_zone_value_change( $details, $field ) {
189
  Util_Ui::hidden( '', $field, $details[$field]['new'] );
190
 
191
- if ( !isset( $details[$field]['current'] ) ||
192
- $details[$field]['current'] == $details[$field]['new'] )
193
- echo htmlspecialchars( $details[$field]['new'] );
194
- else {
195
  echo 'currently set to <strong>' .
196
- htmlspecialchars( empty( $details[$field]['current'] ) ?
197
- '<empty>' : $details[$field]['current'] ) .
198
  '</strong><br />';
199
- echo 'will be changed to <strong>' .
200
- htmlspecialchars( $details[$field]['new'] ) . '</strong><br />';
201
  }
202
  }
203
 
204
 
205
 
206
  private function render_zone_boolean_change( $details, $field ) {
207
- Util_Ui::hidden( '', $field, $details[$field]['new'] );
208
 
209
- if ( !isset( $details[$field]['current'] ) ) {
210
- echo 'will be set to <strong>';
211
- echo $this->render_zone_boolean( $details[$field]['new'] );
212
- echo '</strong>';
213
- } else if ( $details[$field]['current'] == $details[$field]['new'] ) {
214
- echo '<strong>';
215
- echo $this->render_zone_boolean( $details[$field]['new'] );
216
- echo '</strong>';
217
- } else {
218
- echo 'currently set to <strong>';
219
- $this->render_zone_boolean( $details[$field]['current'] );
220
- echo '</strong><br />';
221
- echo 'will be changed to <strong>';
222
- $this->render_zone_boolean( $details[$field]['new'] );
223
- echo '</strong><br />';
224
  }
225
  }
226
 
@@ -236,20 +226,18 @@ class Cdnfsd_CloudFront_Popup {
236
 
237
 
238
  private function render_zone_ip_change( $details, $field ) {
239
- Util_Ui::textbox( '', $field, $details[$field]['new'] );
240
 
241
- if ( isset( $details[$field]['current'] ) &&
242
- $details[$field]['current'] != $details[$field]['new'] ) {
243
- echo '<p class="description">currently set to <strong>' .
244
- $details[$field]['current'] . '</strong></p>';
245
  }
246
  }
247
 
248
 
249
 
250
  public function w3tc_ajax_cdn_cloudfront_fsd_configure_distribution() {
251
- $access_key = $_REQUEST['access_key'];
252
- $secret_key = $_REQUEST['secret_key'];
253
  $distribution_id = Util_Request::get( 'distribution_id', '' );
254
 
255
  $origin_id = rand();
@@ -363,8 +351,8 @@ class Cdnfsd_CloudFront_Popup {
363
 
364
 
365
  public function w3tc_ajax_cdn_cloudfront_fsd_configure_distribution_skip() {
366
- $access_key = $_REQUEST['access_key'];
367
- $secret_key = $_REQUEST['secret_key'];
368
  $distribution_id = Util_Request::get( 'distribution_id', '' );
369
 
370
  $origin_id = rand();
45
 
46
 
47
  public function w3tc_ajax_cdn_cloudfront_fsd_list_distributions() {
48
+ $access_key = Util_Request::get_string( 'access_key' );
49
+ $secret_key = Util_Request::get_string( 'secret_key' );
50
 
51
  if ( empty( $access_key ) || empty( $secret_key ) ) {
52
  $this->render_intro( array(
100
 
101
 
102
  public function w3tc_ajax_cdn_cloudfront_fsd_view_distribution() {
103
+ $access_key = Util_Request::get_string( 'access_key' );
104
+ $secret_key = Util_Request::get_string( 'secret_key' );
105
  $distribution_id = Util_Request::get( 'distribution_id', '' );
106
 
107
  $details = array(
188
  private function render_zone_value_change( $details, $field ) {
189
  Util_Ui::hidden( '', $field, $details[$field]['new'] );
190
 
191
+ if ( ! isset( $details[ $field ]['current'] ) || $details[ $field ]['current'] === $details[ $field ]['new'] ) {
192
+ echo esc_html( $details[ $field ]['new'] );
193
+ } else {
 
194
  echo 'currently set to <strong>' .
195
+ ( empty( $details[ $field ]['current'] ) ? '<empty>' : esc_html( $details[ $field ]['current'] ) ) .
 
196
  '</strong><br />';
197
+ echo 'will be changed to <strong>' . esc_html( $details[ $field ]['new'] ) . '</strong><br />';
 
198
  }
199
  }
200
 
201
 
202
 
203
  private function render_zone_boolean_change( $details, $field ) {
204
+ Util_Ui::hidden( '', $field, $details[ $field ]['new'] );
205
 
206
+ if ( !isset( $details[ $field ]['current'] ) ) {
207
+ echo 'will be set to <strong>' . esc_html( $this->render_zone_boolean( $details[ $field ]['new'] ) ) . '</strong>';
208
+ } elseif ( $details[ $field ]['current'] === $details[ $field ]['new'] ) {
209
+ echo '<strong>' . esc_html( $this->render_zone_boolean( $details[ $field ]['new'] ) ) . '</strong>';
210
+ } else {
211
+ echo 'currently set to <strong>' . esc_html( $this->render_zone_boolean( $details[ $field ]['current'] ) ) .
212
+ '</strong><br />will be changed to <strong>' . esc_html( $this->render_zone_boolean( $details[ $field ]['new'] ) ) .
213
+ '</strong><br />';
 
 
 
 
 
 
 
214
  }
215
  }
216
 
226
 
227
 
228
  private function render_zone_ip_change( $details, $field ) {
229
+ Util_Ui::textbox( '', $field, $details[ $field ]['new'] );
230
 
231
+ if ( isset( $details[ $field ]['current'] ) && $details[ $field ]['current'] !== $details[ $field ]['new'] ) {
232
+ echo '<p class="description">currently set to <strong>' . esc_html( $details[ $field ]['current'] ) . '</strong></p>';
 
 
233
  }
234
  }
235
 
236
 
237
 
238
  public function w3tc_ajax_cdn_cloudfront_fsd_configure_distribution() {
239
+ $access_key = Util_Request::get_string( 'access_key' );
240
+ $secret_key = Util_Request::get_string( 'secret_key' );
241
  $distribution_id = Util_Request::get( 'distribution_id', '' );
242
 
243
  $origin_id = rand();
351
 
352
 
353
  public function w3tc_ajax_cdn_cloudfront_fsd_configure_distribution_skip() {
354
+ $access_key = Util_Request::get_string( 'access_key' );
355
+ $secret_key = Util_Request::get_string( 'secret_key' );
356
  $distribution_id = Util_Request::get( 'distribution_id', '' );
357
 
358
  $origin_id = rand();
Cdnfsd_CloudFront_Popup_View_Distribution.php CHANGED
@@ -1,60 +1,83 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_form" method="post">
8
  <?php
9
- Util_Ui::hidden( '', 'access_key', $details['access_key'] );
10
- Util_Ui::hidden( '', 'secret_key', $details['secret_key'] );
11
- Util_Ui::hidden( '', 'distribution_id', $details['distribution_id'] );
12
- Util_Ui::hidden( '', 'distribution_comment', $details['distribution_comment'] );
13
- ?>
14
 
15
  <div class="metabox-holder">
16
- <?php Util_Ui::postbox_header( __( 'Configure distribution', 'w3-total-cache' ) ); ?>
17
  <table class="form-table">
18
  <tr>
19
  <th>Distribution:</th>
20
- <td><?php echo $details['distribution_comment'] ?></td>
21
  </tr>
22
  <tr>
23
- <th>Origin:</th>
24
- <td><?php $this->render_zone_ip_change( $details, 'origin' ) ?>
25
  <p class="description">
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
  </p>
33
  </td>
34
  </tr>
35
  <tr>
36
- <th>Forward Cookies:</th>
37
- <td><?php $this->render_zone_boolean_change( $details, 'forward_cookies' ) ?></td>
38
  </tr>
39
  <tr>
40
- <th>Forward Query String:</th>
41
- <td><?php $this->render_zone_boolean_change( $details, 'forward_querystring' ) ?></td>
42
  </tr>
43
  <tr>
44
- <th>Forward Host Header:</th>
45
- <td><?php $this->render_zone_boolean_change( $details, 'forward_host' ) ?></td>
46
  </tr>
47
  </table>
48
 
49
  <p class="submit">
50
  <input type="button"
51
  class="w3tc_cdn_cloudfront_fsd_configure_distribution w3tc-button-save button-primary"
52
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
53
- <?php if ( !empty( $details['distribution_id'] ) ): ?>
54
  <input type="button"
55
  class="w3tc_cdn_cloudfront_fsd_configure_distribution_skip w3tc-button-save button"
56
- value="<?php _e( 'Don\'t reconfigure, I know what I\'m doing', 'w3-total-cache' ); ?>" />
57
- <?php endif ?>
58
  </p>
59
  <?php Util_Ui::postbox_footer(); ?>
60
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form" method="post">
9
  <?php
10
+ Util_Ui::hidden( '', 'access_key', $details['access_key'] );
11
+ Util_Ui::hidden( '', 'secret_key', $details['secret_key'] );
12
+ Util_Ui::hidden( '', 'distribution_id', $details['distribution_id'] );
13
+ Util_Ui::hidden( '', 'distribution_comment', $details['distribution_comment'] );
14
+ ?>
15
 
16
  <div class="metabox-holder">
17
+ <?php Util_Ui::postbox_header( esc_html__( 'Configure distribution', 'w3-total-cache' ) ); ?>
18
  <table class="form-table">
19
  <tr>
20
  <th>Distribution:</th>
21
+ <td><?php echo esc_html( $details['distribution_comment'] ); ?></td>
22
  </tr>
23
  <tr>
24
+ <th><?php esc_html_e( 'Origin:', 'w3-total-cache' ); ?></th>
25
+ <td><?php $this->render_zone_ip_change( $details, 'origin' ); ?>
26
  <p class="description">
27
+ <?php
28
+ echo wp_kses(
29
+ sprintf(
30
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
31
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
32
+ // translators: 5 HTML line break tag, 6 HTML line break tag,
33
+ // translators: 7 opening HTML acronym tag, 8 closing HTML acronym tag.
34
+ __(
35
+ 'Create an apex %1$sDNS%2$s record pointing to your WordPress host %3$sIP%4$s.%5$sCloudFront will use this host to mirror your site.%6$sTip: If your real domain name is domain.com, then the host for the apex record should be origin.domain.com with the host %7$sIP%8$s of domain.com, e.g.:',
36
+ 'w3-total-cache'
37
+ ),
38
+ '<acronym title="' . esc_attr__( 'Domain Name System', 'w3-total-cache' ) . '">',
39
+ '</acronym>',
40
+ '<acronym title="' . esc_attr__( 'Internet Protocol', 'w3-total-cache' ) . '">',
41
+ '</acronym>',
42
+ '<br />',
43
+ '<br />',
44
+ '<acronym title="' . esc_attr__( 'Internet Protocol', 'w3-total-cache' ) . '">',
45
+ '</acronym>'
46
+ ),
47
+ array(
48
+ 'acronym' => array(
49
+ 'title' => array(),
50
+ ),
51
+ 'br' => array(),
52
+ )
53
+ );
54
+ ?>
55
  </p>
56
  </td>
57
  </tr>
58
  <tr>
59
+ <th><?php esc_html_e( 'Forward Cookies:', 'w3-total-cache' ); ?></th>
60
+ <td><?php $this->render_zone_boolean_change( $details, 'forward_cookies' ); ?></td>
61
  </tr>
62
  <tr>
63
+ <th><?php esc_html_e( 'Forward Query String:', 'w3-total-cache' ); ?></th>
64
+ <td><?php $this->render_zone_boolean_change( $details, 'forward_querystring' ); ?></td>
65
  </tr>
66
  <tr>
67
+ <th><?php esc_html_e( 'Forward Host Header:', 'w3-total-cache' ); ?></th>
68
+ <td><?php $this->render_zone_boolean_change( $details, 'forward_host' ); ?></td>
69
  </tr>
70
  </table>
71
 
72
  <p class="submit">
73
  <input type="button"
74
  class="w3tc_cdn_cloudfront_fsd_configure_distribution w3tc-button-save button-primary"
75
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
76
+ <?php if ( ! empty( $details['distribution_id'] ) ) : ?>
77
  <input type="button"
78
  class="w3tc_cdn_cloudfront_fsd_configure_distribution_skip w3tc-button-save button"
79
+ value="<?php esc_attr_e( 'Don\'t reconfigure, I know what I\'m doing', 'w3-total-cache' ); ?>" />
80
+ <?php endif; ?>
81
  </p>
82
  <?php Util_Ui::postbox_footer(); ?>
83
  </div>
Cdnfsd_CloudFront_Popup_View_Distributions.php CHANGED
@@ -1,54 +1,56 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'access_key', $details['access_key'] );
10
- Util_Ui::hidden( '', 'secret_key', $details['secret_key'] );
11
- ?>
12
- <div class="metabox-holder">
13
- <?php Util_Ui::postbox_header( __( 'Select distribution to use', 'w3-total-cache' ) ); ?>
14
- <table class="form-table">
15
- <tr>
16
- <td>Distribution:</td>
17
- <td>
18
- <?php
19
- if ( count( $details['distributions'] ) > 15 )
20
- echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
21
- ?>
 
22
 
23
- <?php foreach ( $details['distributions'] as $distribution ): ?>
24
- <label>
25
- <input name="distribution_id" type="radio" class="w3tc-ignore-change"
26
- value="<?php echo $distribution['Id'] ?>" />
27
- <?php echo $distribution['Comment'] ?>
28
- (origin <?php echo $distribution['Origin_DomainName'] ?>)
29
- </label><br />
30
- <?php endforeach ?>
31
 
32
- <label>
33
- <input name="distribution_id" type="radio" class="w3tc-ignore-change" value=""
34
- />
35
- Add new distribution
36
- <input name="comment_new" type="text" class="w3tc-ignore-change" />
37
- </label>
38
 
39
- <?php
40
- if ( count( $details['distributions'] ) > 15 )
41
- echo '</div>';
42
- ?>
43
- </td>
44
- </tr>
45
- </table>
 
46
 
47
- <p class="submit">
48
- <input type="button"
49
- class="w3tc_cdn_cloudfront_fsd_view_distribution 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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form" method="post">
9
+ <?php
10
+ Util_Ui::hidden( '', 'access_key', $details['access_key'] );
11
+ Util_Ui::hidden( '', 'secret_key', $details['secret_key'] );
12
+ ?>
13
+ <div class="metabox-holder">
14
+ <?php Util_Ui::postbox_header( esc_html__( 'Select distribution to use', 'w3-total-cache' ) ); ?>
15
+ <table class="form-table">
16
+ <tr>
17
+ <td>Distribution:</td>
18
+ <td>
19
+ <?php
20
+ if ( count( $details['distributions'] ) > 15 ) {
21
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
22
+ }
23
+ ?>
24
 
25
+ <?php foreach ( $details['distributions'] as $distribution ) : ?>
26
+ <label>
27
+ <input name="distribution_id" type="radio" class="w3tc-ignore-change"
28
+ value="<?php echo esc_attr( $distribution['Id'] ); ?>" />
29
+ <?php echo esc_html( $distribution['Comment'] ); ?>
30
+ (origin <?php echo esc_html( $distribution['Origin_DomainName'] ); ?>)
31
+ </label><br />
32
+ <?php endforeach; ?>
33
 
34
+ <label>
35
+ <input name="distribution_id" type="radio" class="w3tc-ignore-change" value="" />
36
+ Add new distribution
37
+ <input name="comment_new" type="text" class="w3tc-ignore-change" />
38
+ </label>
 
39
 
40
+ <?php
41
+ if ( count( $details['distributions'] ) > 15 ) {
42
+ echo '</div>';
43
+ }
44
+ ?>
45
+ </td>
46
+ </tr>
47
+ </table>
48
 
49
+ <p class="submit">
50
+ <input type="button"
51
+ class="w3tc_cdn_cloudfront_fsd_view_distribution w3tc-button-save button-primary"
52
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
53
+ </p>
54
+ <?php Util_Ui::postbox_footer(); ?>
55
+ </div>
56
  </form>
Cdnfsd_CloudFront_Popup_View_Intro.php CHANGED
@@ -1,41 +1,61 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- 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 <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>
18
- <td>
19
- <input name="access_key" type="text" class="w3tc-ignore-change"
20
- style="width: 550px"
21
- value="<?php echo $config->get_string( 'cdnfsd.cloudfront.access_key' ) ?>" />
22
- </td>
23
- </tr>
24
- <tr>
25
- <td>Access Secret:</td>
26
- <td>
27
- <input name="secret_key" type="text" class="w3tc-ignore-change"
28
- style="width: 550px"
29
- value="<?php echo $config->get_string( 'cdnfsd.cloudfront.secret_key' ) ?>" />
30
- </td>
31
- </tr>
32
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- <p class="submit">
35
- <input type="button"
36
- class="w3tc_cdn_cloudfront_fsd_list_distributions w3tc-button-save button-primary"
37
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
38
- </p>
39
- <?php Util_Ui::postbox_footer(); ?>
40
- </div>
41
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
+ <div class="metabox-holder">
15
+ <?php
16
+ Util_Ui::postbox_header(
17
+ wp_kses(
18
+ sprintf(
19
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
20
+ __(
21
+ 'Your %1$sAWS%2$s CloudFront Account Credentials',
22
+ 'w3-total-cache'
23
+ ),
24
+ '<acronym title="' . esc_attr__( 'Amazon Web Services', 'w3-total-cache' ) . '">',
25
+ '</acronym>'
26
+ ),
27
+ array(
28
+ 'acronym' => array(
29
+ 'title' => array(),
30
+ ),
31
+ )
32
+ )
33
+ );
34
+ ?>
35
+ <table class="form-table">
36
+ <tr>
37
+ <td><?php esc_html_e( 'Access Key:', 'w3-total-cache' ); ?></td>
38
+ <td>
39
+ <input name="access_key" type="text" class="w3tc-ignore-change"
40
+ style="width: 550px"
41
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.cloudfront.access_key' ) ); ?>" />
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <td><?php esc_html_e( 'Access Secret:', 'w3-total-cache' ); ?></td>
46
+ <td>
47
+ <input name="secret_key" type="text" class="w3tc-ignore-change"
48
+ style="width: 550px"
49
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.cloudfront.secret_key' ) ); ?>" />
50
+ </td>
51
+ </tr>
52
+ </table>
53
 
54
+ <p class="submit">
55
+ <input type="button"
56
+ class="w3tc_cdn_cloudfront_fsd_list_distributions w3tc-button-save button-primary"
57
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
58
+ </p>
59
+ <?php Util_Ui::postbox_footer(); ?>
60
+ </div>
61
  </form>
Cdnfsd_CloudFront_Popup_View_Success.php CHANGED
@@ -1,25 +1,25 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_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
- 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
 
18
- <p class="submit">
19
- <input type="button"
20
- class="w3tc_cdn_maxcdn_fsd_done w3tc-button-save button-primary"
21
- value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
22
- </p>
23
- <?php Util_Ui::postbox_footer(); ?>
24
- </div>
25
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ Pull Zone <?php echo esc_html( $details['name'] ); ?> was successfully configured.<br />
14
+ Next, update the domain <acronym title="Domain Name System">DNS</acronym> records
15
+ <strong><?php echo esc_html( $details['home_domain'] ); ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to
16
+ <strong><?php echo esc_html( $details['dns_cname_target'] ); ?></strong> to enable caching.
17
 
18
+ <p class="submit">
19
+ <input type="button"
20
+ class="w3tc_cdn_maxcdn_fsd_done w3tc-button-save button-primary"
21
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
22
+ </p>
23
+ <?php Util_Ui::postbox_footer(); ?>
24
+ </div>
25
  </form>
Cdnfsd_GeneralPage_View.php CHANGED
@@ -1,49 +1,136 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
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
 
14
  <table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
15
  <?php
16
- Util_Ui::config_item_pro( array(
17
- 'key' => 'cdnfsd.enabled',
18
- 'label' => __( '<acronym title="Full Site Delivery">FSD</acronym> <acronym title="Content Delivery Network">CDN</acronym>:', 'w3-total-cache' ),
19
- 'control' => 'checkbox',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
21
- 'disabled' => ( $is_pro ? null : true ),
22
- 'excerpt' => __( 'Deliver visitors the lowest possible response and load times for all site content including HTML, media (e.g. images or fonts), CSS, and JavaScript.', 'w3-total-cache' ),
23
- 'description' => array(
24
  __( 'Want even faster speeds? The full site delivery Content Delivery Network will speed up your website by over 60% to increase conversions, revenue and reach your website visitors globally. With a Full Site Content Delivery Network (CDN), your website and all its assets will be available instantly to your visitors all over the world at blazing fast speeds.', 'w3-total-cache' ),
25
  wp_kses(
26
  sprintf(
27
- // translators: 1 The opening anchor tag linking to our support page, 2 its closing tag.
28
- __( 'For even better performance, combine FSD with other powerful features like Browser Cache, Minify, Fragment caching, or Lazy Load! Did you know that we offer premium support, customization and audit services? %1$sClick here for more information%2$s.', 'w3-total-cache' ),
 
 
 
29
  '<a href="' . esc_url( admin_url( 'admin.php?page=w3tc_support' ) ) . '">',
30
  '</a>'
31
  ),
32
- array( 'a' => array( 'href' => array() ) )
 
 
 
 
33
  ),
34
- )
35
- ) );
 
36
 
37
- Util_Ui::config_item( array(
38
- 'key' => 'cdnfsd.engine',
39
- 'label' => __( '<acronym title="Full Site Delivery">FSD</acronym> <acronym title="Content Delivery Network">CDN</acronym> Type:', 'w3-total-cache' ),
40
- 'control' => 'selectbox',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  'selectbox_values' => $cdnfsd_engine_values,
42
- 'value' => $cdnfsd_engine,
43
- 'disabled' => ( $is_pro ? null : true ),
44
- 'description' => __( 'Select the <acronym title="Content Delivery Network">CDN</acronym> type you wish to use.',
45
- 'w3-total-cache' ) . $cdnfsd_engine_extra_description,
46
- 'show_in_free' => false,
47
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  ?>
49
  </table>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
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
11
+ wp_kses(
12
+ sprintf(
13
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
14
+ // translators: 3 opening HTML a tag to W3TC MaxCDN Signup admin page, 4 closing HTML a tag.
15
+ __(
16
+ 'If you do not have a %1$sCDN%2$s provider try StackPath. %3$sSign up now to enjoy a special offer!%4$s.',
17
+ 'w3-total-cache'
18
+ ),
19
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
20
+ '</acronym>',
21
+ '<a href="' . esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_maxcdn_signup' ), 'w3tc' ) ) . '" target="_blank">',
22
+ '</a>'
23
+ ),
24
+ array(
25
+ 'acronym' => array(
26
+ 'title' => array(),
27
+ ),
28
+ 'a' => array(
29
+ 'href' => array(),
30
+ 'target' => array(),
31
+ ),
32
+ )
33
+ );
34
+ ?>
35
+ <?php endif; ?>
36
  </p>
37
 
38
  <table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
39
  <?php
40
+ Util_Ui::config_item_pro(
41
+ array(
42
+ 'key' => 'cdnfsd.enabled',
43
+ 'label' => wp_kses(
44
+ sprintf(
45
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
46
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
47
+ __(
48
+ '%1$sFSD%2$s %3$sCDN%4$s:',
49
+ 'w3-total-cache'
50
+ ),
51
+ '<acronym title="' . esc_attr__( 'Full Site Delivery', 'w3-total-cache' ) . '">',
52
+ '</acronym>',
53
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
54
+ '</acronym>'
55
+ ),
56
+ array(
57
+ 'acronym' => array(
58
+ 'title' => array(),
59
+ ),
60
+ )
61
+ ),
62
+ 'control' => 'checkbox',
63
  'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
64
+ 'disabled' => ( $is_pro ? null : true ),
65
+ 'excerpt' => __( 'Deliver visitors the lowest possible response and load times for all site content including HTML, media (e.g. images or fonts), CSS, and JavaScript.', 'w3-total-cache' ),
66
+ 'description' => array(
67
  __( 'Want even faster speeds? The full site delivery Content Delivery Network will speed up your website by over 60% to increase conversions, revenue and reach your website visitors globally. With a Full Site Content Delivery Network (CDN), your website and all its assets will be available instantly to your visitors all over the world at blazing fast speeds.', 'w3-total-cache' ),
68
  wp_kses(
69
  sprintf(
70
+ // translators: 1 opening HTML a tag to W3TC admin support page, 2 closing HTML a tag.
71
+ __(
72
+ 'For even better performance, combine FSD with other powerful features like Browser Cache, Minify, Fragment caching, or Lazy Load! Did you know that we offer premium support, customization and audit services? %1$sClick here for more information%2$s.',
73
+ 'w3-total-cache'
74
+ ),
75
  '<a href="' . esc_url( admin_url( 'admin.php?page=w3tc_support' ) ) . '">',
76
  '</a>'
77
  ),
78
+ array(
79
+ 'a' => array(
80
+ 'href' => array(),
81
+ ),
82
+ )
83
  ),
84
+ ),
85
+ )
86
+ );
87
 
88
+ Util_Ui::config_item(
89
+ array(
90
+ 'key' => 'cdnfsd.engine',
91
+ 'label' => wp_kses(
92
+ sprintf(
93
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
94
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
95
+ __(
96
+ '%1$sFSD%2$s %3$sCDN%4$s Type:',
97
+ 'w3-total-cache'
98
+ ),
99
+ '<acronym title="' . esc_attr__( 'Full Site Delivery', 'w3-total-cache' ) . '">',
100
+ '</acronym>',
101
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
102
+ '</acronym>'
103
+ ),
104
+ array(
105
+ 'acronym' => array(
106
+ 'title' => array(),
107
+ ),
108
+ )
109
+ ),
110
+ 'control' => 'selectbox',
111
  'selectbox_values' => $cdnfsd_engine_values,
112
+ 'value' => $cdnfsd_engine,
113
+ 'disabled' => ( $is_pro ? null : true ),
114
+ 'description' => wp_kses(
115
+ sprintf(
116
+ // translators: 1 opening HTML acronym tag, closing HTML acronym tag,
117
+ // translators: 3 CDNFSD engine extra description.
118
+ __(
119
+ 'Select the %1$sCDN%2$s type you wish to use. %3$s',
120
+ 'w3-total-cache'
121
+ ),
122
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
123
+ '</acronym>',
124
+ $cdnfsd_engine_extra_description
125
+ ),
126
+ array(
127
+ 'acronym' => array(
128
+ 'title' => array(),
129
+ ),
130
+ )
131
+ ),
132
+ 'show_in_free' => false,
133
+ )
134
+ );
135
  ?>
136
  </table>
Cdnfsd_LimeLight_Page_View.php CHANGED
@@ -1,43 +1,35 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- $key = $config->get_string( 'cdnfsd.limelight.api_key' );
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_cdnfsd_limelight_authorize button-primary"
28
- type="button"
29
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
30
- />
31
- <?php else: ?>
32
  <input class="w3tc_cdnfsd_limelight_authorize button-primary"
33
- type="button"
34
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
35
- />
36
  <?php endif ?>
37
  </td>
38
  </tr>
39
  </table>
40
-
41
- <?php Util_Ui::postbox_footer(); ?>
42
- </div>
43
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ $key = $config->get_string( 'cdnfsd.limelight.api_key' );
9
+ $authorized = ! empty( $key );
10
 
11
  ?>
12
  <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
13
+ <div class="metabox-holder">
14
+ <?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
15
+ <table class="form-table">
 
16
  <tr>
17
  <th style="width: 300px;">
18
  <label>
19
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
 
 
 
20
  </label>
21
  </th>
22
  <td>
23
+ <?php if ( $authorized ) : ?>
24
  <input class="w3tc_cdnfsd_limelight_authorize button-primary"
25
+ type="button" value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>" />
26
+ <?php else : ?>
 
 
27
  <input class="w3tc_cdnfsd_limelight_authorize button-primary"
28
+ type="button" value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>" />
 
 
29
  <?php endif ?>
30
  </td>
31
  </tr>
32
  </table>
33
+ <?php Util_Ui::postbox_footer(); ?>
34
+ </div>
 
35
  </form>
Cdnfsd_LimeLight_Popup.php CHANGED
@@ -31,9 +31,9 @@ class Cdnfsd_LimeLight_Popup {
31
 
32
 
33
  public function w3tc_ajax_cdnfsd_limelight_save() {
34
- $short_name = $_REQUEST['short_name'];
35
- $username = $_REQUEST['username'];
36
- $api_key = $_REQUEST['api_key'];
37
 
38
  try {
39
  $api = new Cdnfsd_LimeLight_Api( $short_name, $username, $api_key );
31
 
32
 
33
  public function w3tc_ajax_cdnfsd_limelight_save() {
34
+ $short_name = Util_Request::get_string( 'short_name' );
35
+ $username = Util_Request::get_string( 'username' );
36
+ $api_key = Util_Request::get_string( 'api_key' );
37
 
38
  try {
39
  $api = new Cdnfsd_LimeLight_Api( $short_name, $username, $api_key );
Cdnfsd_LimeLight_Popup_View_Intro.php CHANGED
@@ -1,49 +1,50 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- 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 LimeLight Account credentials', 'w3-total-cache' ) ); ?>
15
- <table class="form-table">
16
- <tr>
17
- <td>Account Short Name:</td>
18
- <td>
19
- <input name="short_name" type="text" class="w3tc-ignore-change"
20
- style="width: 550px"
21
- value="<?php echo $config->get_string( 'cdnfsd.limelight.short_name' ) ?>" />
22
- </td>
23
- </tr>
24
- <tr>
25
- <td>Username:</td>
26
- <td>
27
- <input name="username" type="text" class="w3tc-ignore-change"
28
- style="width: 550px"
29
- value="<?php echo $config->get_string( 'cdnfsd.limelight.username' ) ?>" />
30
- </td>
31
- </tr>
32
- <tr>
33
- <td>API Key:</td>
34
- <td>
35
- <input name="api_key" type="text" class="w3tc-ignore-change"
36
- style="width: 550px"
37
- value="<?php echo $config->get_string( 'cdnfsd.limelight.api_key' ) ?>" />
38
- </td>
39
- </tr>
40
- </table>
41
 
42
- <p class="submit">
43
- <input type="button"
44
- class="w3tc_cdnfsd_limelight_save w3tc-button-save button-primary"
45
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
46
- </p>
47
- <?php Util_Ui::postbox_footer(); ?>
48
- </div>
49
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
+ <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your LimeLight Account credentials', 'w3-total-cache' ) ); ?>
16
+ <table class="form-table">
17
+ <tr>
18
+ <td>Account Short Name:</td>
19
+ <td>
20
+ <input name="short_name" type="text" class="w3tc-ignore-change"
21
+ style="width: 550px"
22
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.limelight.short_name' ) ); ?>" />
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td>Username:</td>
27
+ <td>
28
+ <input name="username" type="text" class="w3tc-ignore-change"
29
+ style="width: 550px"
30
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.limelight.username' ) ); ?>" />
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <td>API Key:</td>
35
+ <td>
36
+ <input name="api_key" type="text" class="w3tc-ignore-change"
37
+ style="width: 550px"
38
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.limelight.api_key' ) ); ?>" />
39
+ </td>
40
+ </tr>
41
+ </table>
42
 
43
+ <p class="submit">
44
+ <input type="button"
45
+ class="w3tc_cdnfsd_limelight_save w3tc-button-save button-primary"
46
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
47
+ </p>
48
+ <?php Util_Ui::postbox_footer(); ?>
49
+ </div>
50
  </form>
Cdnfsd_LimeLight_Popup_View_Success.php CHANGED
@@ -1,22 +1,22 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_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
- Plugin was successfully configured to use this service.<br />
14
- Make sure you have updated domain DNS records.
15
- <p class="submit">
16
- <input type="button"
17
- class="w3tc_cdnfsd_limelight_done w3tc-button-save button-primary"
18
- value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
19
- </p>
20
- <?php Util_Ui::postbox_footer(); ?>
21
- </div>
22
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ Plugin was successfully configured to use this service.<br />
14
+ Make sure you have updated domain DNS records.
15
+ <p class="submit">
16
+ <input type="button"
17
+ class="w3tc_cdnfsd_limelight_done w3tc-button-save button-primary"
18
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
19
+ </p>
20
+ <?php Util_Ui::postbox_footer(); ?>
21
+ </div>
22
  </form>
Cdnfsd_MaxCdn_Page_View.php CHANGED
@@ -1,56 +1,74 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- $key = $config->get_string( 'cdnfsd.maxcdn.api_key' );
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_maxcdn_fsd_authorize button-primary"
28
  type="button"
29
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
30
  />
31
- <?php else: ?>
32
  <input class="w3tc_cdn_maxcdn_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 echo $config->get_string( 'cdnfsd.maxcdn.zone_domain' ) ?>
47
- <p class="description">
48
- The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
49
- <acronym title="Content Delivery Network">CDN</acronym> domain
50
- </p>
51
- </td>
52
- </tr>
53
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  </table>
55
 
56
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ $key = $config->get_string( 'cdnfsd.maxcdn.api_key' );
9
+ $authorized = ! empty( $key );
 
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( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
 
14
  <table class="form-table">
15
  <tr>
16
  <th style="width: 300px;">
17
  <label>
18
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
 
 
 
19
  </label>
20
  </th>
21
  <td>
22
+ <?php if ( $authorized ) : ?>
23
  <input class="w3tc_cdn_maxcdn_fsd_authorize button-primary"
24
  type="button"
25
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>"
26
  />
27
+ <?php else : ?>
28
  <input class="w3tc_cdn_maxcdn_fsd_authorize button-primary"
29
  type="button"
30
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>"
31
  />
32
+ <?php endif; ?>
33
  </td>
34
  </tr>
35
 
36
+ <?php if ( $authorized ) : ?>
37
+ <tr>
38
+ <th>
39
+ <label>
40
+ <?php
41
+ echo wp_kses(
42
+ sprintf(
43
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
44
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
45
+ __(
46
+ '%1$sCDN%2$s %3$sCNAME%4$s:',
47
+ 'w3-total-cache'
48
+ ),
49
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
50
+ '</acronym>',
51
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
52
+ '</acronym>'
53
+ ),
54
+ array(
55
+ 'acronym' => array(
56
+ 'title' => array(),
57
+ ),
58
+ )
59
+ );
60
+ ?>
61
+ </label>
62
+ </th>
63
+ <td class="w3tc_config_value_text">
64
+ <?php echo esc_html( $config->get_string( 'cdnfsd.maxcdn.zone_domain' ) ); ?>
65
+ <p class="description">
66
+ The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
67
+ <acronym title="Content Delivery Network">CDN</acronym> domain
68
+ </p>
69
+ </td>
70
+ </tr>
71
+ <?php endif; ?>
72
  </table>
73
 
74
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
Cdnfsd_MaxCdn_Popup.php CHANGED
@@ -1,64 +1,57 @@
1
  <?php
2
  namespace W3TC;
3
 
4
-
5
-
6
  class Cdnfsd_MaxCdn_Popup {
7
- static public function w3tc_ajax() {
8
  $o = new Cdnfsd_MaxCdn_Popup();
9
 
10
- add_action( 'w3tc_ajax_cdn_maxcdn_fsd_intro',
11
- array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_intro' ) );
12
- add_action( 'w3tc_ajax_cdn_maxcdn_fsd_list_zones',
13
- array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_list_zones' ) );
14
- add_action( 'w3tc_ajax_cdn_maxcdn_fsd_view_zone',
15
- array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_view_zone' ) );
16
- add_action( 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone',
17
- array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone' ) );
18
- add_action( 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone_skip',
19
- array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone_skip' ) );
20
  }
21
 
22
-
23
-
24
  public function __construct() {
25
- if ( !class_exists( 'NetDNA' ) )
26
  require_once W3TC_LIB_NETDNA_DIR . '/NetDNA.php';
 
27
  }
28
 
29
-
30
-
31
  public function w3tc_ajax_cdn_maxcdn_fsd_intro() {
32
  $config = Dispatcher::config();
33
 
34
- $this->render_intro( array(
35
- 'api_key' => $config->get_string( 'cdnfsd.maxcdn.api_key' ) ) );
 
 
 
36
  }
37
 
38
-
39
-
40
  private function render_intro( $details ) {
41
- $config = Dispatcher::config();
42
- $url_obtain_key = Util_Ui::url( array(
43
- 'page' => 'w3tc_dashboard',
44
- 'w3tc_cdn_maxcdn_authorize' => 'y'
45
- ) );
 
 
46
 
47
- include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Intro.php';
48
  exit();
49
  }
50
 
51
-
52
-
53
  public function w3tc_ajax_cdn_maxcdn_fsd_list_zones() {
54
- $api_key = $_REQUEST['api_key'];
55
-
56
- $api = \NetDNA::create( $api_key );
57
- if ( !$api->is_valid() ) {
58
- $this->render_intro( array(
59
- 'api_key' => $api_key,
60
- 'error_message' => 'Can\'t authenticate: API key not valid'
 
61
  ) );
 
62
  exit();
63
  }
64
 
@@ -68,66 +61,60 @@ class Cdnfsd_MaxCdn_Popup {
68
  $error_message = 'Can\'t authenticate: ' . $ex->getMessage();
69
 
70
  if ( strpos( $error_message, 'not whitelisted' ) > 0 ) {
71
- $error_message .= '. You can whitelist IP ' .
72
- '<a target="_blank" href="https://cp.maxcdn.com/account/api/whitelist">here</a>';
73
  }
74
- $this->render_intro( array(
75
- 'api_key' => $api_key,
76
- 'error_message' => $error_message
77
- ) );
 
 
 
78
  exit();
79
  }
80
 
81
  $details = array(
82
  'api_key' => $api_key,
83
- 'zones' => $zones
84
  );
85
 
86
- include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Zones.php';
87
  exit();
88
  }
89
 
90
-
91
-
92
  public function w3tc_ajax_cdn_maxcdn_fsd_view_zone() {
93
- $api_key = $_REQUEST['api_key'];
94
  $zone_id = Util_Request::get( 'zone_id', '' );
95
 
96
  $details = array(
97
- 'api_key' => $api_key,
98
- 'zone_id' => $zone_id,
99
- 'name' => '',
100
- 'url' => array(
101
- 'new' => get_home_url() ),
102
- 'ip' => array(),
103
- // needs to be off since original DNS will be replaced with maxcdn's
104
- 'dns_check' => array(
105
- 'new' => 0
106
- ),
107
- // needs to be off, since WP issues no-cache headers for wp-admin
108
- // and logged-in users
109
- 'ignore_cache_control' => array(
110
- 'new' => 0
111
- ),
112
- 'custom_domain' => array(
113
- 'new' => Util_Environment::home_url_host()
114
- )
115
  );
116
 
117
  if ( empty( $zone_id ) ) {
118
- // create new zone mode
119
- $details['name'] = Util_Request::get( 'zone_new_name' );
120
  $details['ip']['new'] = Cdnfsd_Util::get_suggested_home_ip();
121
  } else {
122
  $api = \NetDNA::create( $api_key );
123
  try {
124
- $zone = $api->get_zone( $zone_id );
125
  $custom_domains = $api->get_custom_domains( $zone_id );
126
  } catch ( \Exception $ex ) {
127
- $this->render_intro( array(
128
- 'api_key' => $api_key,
129
- 'error_message' => 'Can\'t obtain zone: ' . $ex->getMessage()
130
- ) );
 
 
131
  exit();
132
  }
133
 
@@ -135,137 +122,171 @@ class Cdnfsd_MaxCdn_Popup {
135
 
136
  foreach ( $custom_domains as $d ) {
137
  $details['custom_domain']['current'] = $d;
138
- if ( $d == Util_Environment::home_url_host() )
139
  break;
 
140
  }
141
 
142
- $details['name'] = $zone['name'];
143
  $details['dns_check']['current'] = $zone['dns_check'];
144
  $details['ignore_cache_control'] = $zone['ignore_cache_control'];
145
- $details['url']['current'] = $zone['url'];
146
- $details['ip']['current'] = $zone['ip'];
147
 
148
  $origin_ip = Cdnfsd_Util::get_suggested_home_ip();
149
- $cdn_ip = gethostbyname( $zone['tmp_url'] );
150
 
151
- if ( $origin_ip != $cdn_ip )
152
  $details['ip']['new'] = $origin_ip;
 
153
  }
154
 
155
-
156
-
157
- include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Zone.php';
158
  exit();
159
  }
160
 
161
-
162
-
163
  private function render_zone_value_change( $details, $field ) {
164
- Util_Ui::hidden( '', $field, $details[$field]['new'] );
165
-
166
- if ( !isset( $details[$field]['current'] ) ||
167
- $details[$field]['current'] == $details[$field]['new'] )
168
- echo htmlspecialchars( $details[$field]['new'] );
169
- else {
170
- echo 'currently set to <strong>' .
171
- htmlspecialchars( empty( $details[$field]['current'] ) ?
172
- '<empty>' : $details[$field]['current'] ) .
173
- '</strong><br />';
174
- echo 'will be changed to <strong>' .
175
- htmlspecialchars( $details[$field]['new'] ) . '</strong><br />';
 
 
 
 
 
 
 
 
 
176
  }
177
  }
178
 
179
-
180
-
181
  private function render_zone_boolean_change( $details, $field ) {
182
- Util_Ui::hidden( '', $field, $details[$field]['new'] );
183
-
184
- if ( !isset( $details[$field]['current'] ) ) {
185
- echo 'will be set to <strong>';
186
- echo $this->render_zone_boolean( $details[$field]['new'] );
187
- echo '</strong>';
188
- } else if ( $details[$field]['current'] == $details[$field]['new'] ) {
189
- echo '<strong>';
190
- echo $this->render_zone_boolean( $details[$field]['new'] );
191
- echo '</strong>';
192
- } else {
193
- echo 'currently set to <strong>';
194
- $this->render_zone_boolean( $details[$field]['current'] );
195
- echo '</strong><br />';
196
- echo 'will be changed to <strong>';
197
- $this->render_zone_boolean( $details[$field]['new'] );
198
- echo '</strong><br />';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
  }
201
 
202
-
203
-
204
  private function render_zone_boolean( $v ) {
205
- if ( $v == 0 )
206
  echo 'disabled';
207
- else
208
  echo 'enabled';
 
209
  }
210
 
211
-
212
-
213
  private function render_zone_ip_change( $details, $field ) {
214
- Util_Ui::textbox( '', $field, $details[$field]['new'] );
215
-
216
- if ( isset( $details[$field]['current'] ) &&
217
- $details[$field]['current'] != $details[$field]['new'] ) {
218
- echo '<p class="description">currently set to <strong>' .
219
- $details[$field]['current'] . '</strong></p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  }
221
  }
222
 
223
-
224
-
225
  public function w3tc_ajax_cdn_maxcdn_fsd_configure_zone() {
226
- $api_key = $_REQUEST['api_key'];
227
  $zone_id = Util_Request::get( 'zone_id', '' );
228
-
229
- $zone = array(
230
- 'name' => Util_Request::get( 'name' ),
231
- 'label' => Util_Request::get( 'name' ),
232
- 'url' => Util_Request::get( 'url' ),
233
- 'use_stale' => 1,
234
- 'queries' => 1,
235
- 'compress' => 1,
236
  'backend_compress' => 1,
237
- 'dns_check' => Util_Request::get( 'dns_check' ),
238
- 'ip' => Util_Request::get( 'ip' )
239
  );
240
-
241
- $api = \NetDNA::create( $api_key );
242
 
243
  try {
244
  if ( empty( $zone_id ) ) {
245
  $response = $api->create_pull_zone( $zone );
246
- $zone_id = $response['id'];
247
  } else {
248
  $response = $api->update_pull_zone( $zone_id, $zone );
249
  }
250
 
251
  $custom_domains = $api->get_custom_domains( $zone_id );
252
- $custom_domain = Util_Request::get( 'custom_domain' );
253
 
254
  $added = false;
255
  foreach ( $custom_domains as $d ) {
256
- if ( $d == $custom_domain ) {
257
  $added = true;
258
  break;
259
  }
260
  }
261
- if ( !$added ) {
262
  $api->create_custom_domain( $zone_id, $custom_domain );
263
  }
264
  } catch ( \Exception $ex ) {
265
- $this->render_intro( array(
266
- 'api_key' => $api_key,
267
- 'error_message' => 'Failed to configure custom domain ' . $custom_domain . ': ' . $ex->getMessage()
268
- ) );
 
 
269
  exit();
270
  }
271
 
@@ -278,19 +299,17 @@ class Cdnfsd_MaxCdn_Popup {
278
  $c->save();
279
 
280
  $details = array(
281
- 'name' => $zone['name'],
282
- 'home_domain' => Util_Environment::home_url_host(),
283
  'dns_cname_target' => $zone_domain,
284
  );
285
 
286
- include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Success.php';
287
  exit();
288
  }
289
 
290
-
291
-
292
  public function w3tc_ajax_cdn_maxcdn_fsd_configure_zone_skip() {
293
- $api_key = $_REQUEST['api_key'];
294
  $zone_id = Util_Request::get( 'zone_id', '' );
295
 
296
  $api = \NetDNA::create( $api_key );
@@ -298,10 +317,12 @@ class Cdnfsd_MaxCdn_Popup {
298
  try {
299
  $zone = $api->get_zone( $zone_id );
300
  } catch ( \Exception $ex ) {
301
- $this->render_intro( array(
302
- 'api_key' => $api_key,
303
- 'error_message' => 'Failed to obtain custom domains: ' . $ex->getMessage()
304
- ) );
 
 
305
  exit();
306
  }
307
 
@@ -314,12 +335,12 @@ class Cdnfsd_MaxCdn_Popup {
314
  $c->save();
315
 
316
  $details = array(
317
- 'name' => $zone['name'],
318
- 'home_domain' => Util_Environment::home_url_host(),
319
  'dns_cname_target' => $zone_domain,
320
  );
321
 
322
- include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Success.php';
323
  exit();
324
  }
325
  }
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  class Cdnfsd_MaxCdn_Popup {
5
+ public static function w3tc_ajax() {
6
  $o = new Cdnfsd_MaxCdn_Popup();
7
 
8
+ add_action( 'w3tc_ajax_cdn_maxcdn_fsd_intro', array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_intro' ) );
9
+ add_action( 'w3tc_ajax_cdn_maxcdn_fsd_list_zones', array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_list_zones' ) );
10
+ add_action( 'w3tc_ajax_cdn_maxcdn_fsd_view_zone', array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_view_zone' ) );
11
+ add_action( 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone', array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone' ) );
12
+ add_action( 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone_skip', array( $o, 'w3tc_ajax_cdn_maxcdn_fsd_configure_zone_skip' ) );
 
 
 
 
 
13
  }
14
 
 
 
15
  public function __construct() {
16
+ if ( ! class_exists( 'NetDNA' ) ) {
17
  require_once W3TC_LIB_NETDNA_DIR . '/NetDNA.php';
18
+ }
19
  }
20
 
 
 
21
  public function w3tc_ajax_cdn_maxcdn_fsd_intro() {
22
  $config = Dispatcher::config();
23
 
24
+ $this->render_intro(
25
+ array(
26
+ 'api_key' => $config->get_string( 'cdnfsd.maxcdn.api_key' ),
27
+ )
28
+ );
29
  }
30
 
 
 
31
  private function render_intro( $details ) {
32
+ $config = Dispatcher::config();
33
+ $url_obtain_key = Util_Ui::url(
34
+ array(
35
+ 'page' => 'w3tc_dashboard',
36
+ 'w3tc_cdn_maxcdn_authorize' => 'y',
37
+ )
38
+ );
39
 
40
+ include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Intro.php';
41
  exit();
42
  }
43
 
 
 
44
  public function w3tc_ajax_cdn_maxcdn_fsd_list_zones() {
45
+ $api_key = Util_Request::get_string( 'api_key' );
46
+ $api = \NetDNA::create( $api_key );
47
+
48
+ if ( ! $api->is_valid() ) {
49
+ $this->render_intro(
50
+ array(
51
+ 'api_key' => $api_key,
52
+ 'error_message' => 'Can\'t authenticate: API key not valid',
53
  ) );
54
+
55
  exit();
56
  }
57
 
61
  $error_message = 'Can\'t authenticate: ' . $ex->getMessage();
62
 
63
  if ( strpos( $error_message, 'not whitelisted' ) > 0 ) {
64
+ $error_message .= '. You can whitelist IP <a target="_blank" href="https://cp.maxcdn.com/account/api/whitelist">here</a>';
 
65
  }
66
+
67
+ $this->render_intro(
68
+ array(
69
+ 'api_key' => $api_key,
70
+ 'error_message' => $error_message,
71
+ )
72
+ );
73
  exit();
74
  }
75
 
76
  $details = array(
77
  'api_key' => $api_key,
78
+ 'zones' => $zones,
79
  );
80
 
81
+ include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Zones.php';
82
  exit();
83
  }
84
 
 
 
85
  public function w3tc_ajax_cdn_maxcdn_fsd_view_zone() {
86
+ $api_key = Util_Request::get_string( 'api_key' );
87
  $zone_id = Util_Request::get( 'zone_id', '' );
88
 
89
  $details = array(
90
+ 'api_key' => $api_key,
91
+ 'zone_id' => $zone_id,
92
+ 'name' => '',
93
+ 'url' => array( 'new' => get_home_url() ),
94
+ 'ip' => array(),
95
+ // needs to be off since original DNS will be replaced with maxcdn's.
96
+ 'dns_check' => array( 'new' => 0 ),
97
+ // needs to be off, since WP issues no-cache headers for wp-admin and logged-in users.
98
+ 'ignore_cache_control' => array( 'new' => 0 ),
99
+ 'custom_domain' => array( 'new' => Util_Environment::home_url_host() ),
 
 
 
 
 
 
 
 
100
  );
101
 
102
  if ( empty( $zone_id ) ) {
103
+ // create new zone mode.
104
+ $details['name'] = Util_Request::get( 'zone_new_name' );
105
  $details['ip']['new'] = Cdnfsd_Util::get_suggested_home_ip();
106
  } else {
107
  $api = \NetDNA::create( $api_key );
108
  try {
109
+ $zone = $api->get_zone( $zone_id );
110
  $custom_domains = $api->get_custom_domains( $zone_id );
111
  } catch ( \Exception $ex ) {
112
+ $this->render_intro(
113
+ array(
114
+ 'api_key' => $api_key,
115
+ 'error_message' => 'Can\'t obtain zone: ' . $ex->getMessage(),
116
+ )
117
+ );
118
  exit();
119
  }
120
 
122
 
123
  foreach ( $custom_domains as $d ) {
124
  $details['custom_domain']['current'] = $d;
125
+ if ( Util_Environment::home_url_host() === $d ) {
126
  break;
127
+ }
128
  }
129
 
130
+ $details['name'] = $zone['name'];
131
  $details['dns_check']['current'] = $zone['dns_check'];
132
  $details['ignore_cache_control'] = $zone['ignore_cache_control'];
133
+ $details['url']['current'] = $zone['url'];
134
+ $details['ip']['current'] = $zone['ip'];
135
 
136
  $origin_ip = Cdnfsd_Util::get_suggested_home_ip();
137
+ $cdn_ip = gethostbyname( $zone['tmp_url'] );
138
 
139
+ if ( $origin_ip !== $cdn_ip ) {
140
  $details['ip']['new'] = $origin_ip;
141
+ }
142
  }
143
 
144
+ include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Zone.php';
 
 
145
  exit();
146
  }
147
 
 
 
148
  private function render_zone_value_change( $details, $field ) {
149
+ Util_Ui::hidden( '', $field, $details[ $field ]['new'] );
150
+
151
+ if ( ! isset( $details[ $field ]['current'] ) || $details[ $field ]['current'] === $details[ $field ]['new'] ) {
152
+ echo esc_html( $details[ $field ]['new'] );
153
+ } else {
154
+ echo wp_kses(
155
+ sprintf(
156
+ // translators: 1 HTML strong tag containing current zone value followed by line break tag,
157
+ // translators: 2 HTML strong tag containing new zone value followed by line break tag.
158
+ __(
159
+ 'currently set to %1$s will be changed to %2$s',
160
+ 'w3-total-cache'
161
+ ),
162
+ '<strong>' . empty( $details[ $field ]['current'] ) ? '<empty>' : $details[ $field ]['current'] . '</strong><br />',
163
+ '<strong>' . $details[ $field ]['new'] . '</strong><br />'
164
+ ),
165
+ array(
166
+ 'strong' => array(),
167
+ 'br' => array(),
168
+ )
169
+ );
170
  }
171
  }
172
 
 
 
173
  private function render_zone_boolean_change( $details, $field ) {
174
+ Util_Ui::hidden( '', $field, $details[ $field ]['new'] );
175
+
176
+ if ( ! isset( $details[ $field ]['current'] ) ) {
177
+ echo wp_kses(
178
+ sprintf(
179
+ // translators: 1 HTML strong tag containing new zone boolean value.
180
+ __(
181
+ 'will be set to %1$s',
182
+ 'w3-total-cache'
183
+ ),
184
+ '<strong>' . $this->render_zone_boolean( $details[ $field ]['new'] ) . '</strong>'
185
+ ),
186
+ array(
187
+ 'strong' => array(),
188
+ )
189
+ );
190
+ } elseif ( $details[ $field ]['current'] === $details[ $field ]['new'] ) {
191
+ echo '<strong>' . esc_html( $this->render_zone_boolean( $details[ $field ]['new'] ) ) . '</strong>';
192
+ } else {
193
+ echo wp_kses(
194
+ sprintf(
195
+ // translators: 1 HTML strong tag containing current zone boolean value followed by line break tag,
196
+ // translators: 2 HTML strong tag containing new zone boolean value followed by line break tag.
197
+ __(
198
+ 'currently set to %1$s will be changed to %2$s',
199
+ 'w3-total-cache'
200
+ ),
201
+ '<strong>' . $this->render_zone_boolean( $details[ $field ]['current'] ) . '</strong><br />',
202
+ '<strong>' . $this->render_zone_boolean( $details[ $field ]['new'] ) . '</strong><br />'
203
+ ),
204
+ array(
205
+ 'strong' => array(),
206
+ 'br' => array(),
207
+ )
208
+ );
209
  }
210
  }
211
 
 
 
212
  private function render_zone_boolean( $v ) {
213
+ if ( 0 === $v ) {
214
  echo 'disabled';
215
+ } else {
216
  echo 'enabled';
217
+ }
218
  }
219
 
 
 
220
  private function render_zone_ip_change( $details, $field ) {
221
+ Util_Ui::textbox( '', $field, $details[ $field ]['new'] );
222
+
223
+ if ( isset( $details[ $field ]['current'] ) && $details[ $field ]['current'] !== $details[ $field ]['new'] ) {
224
+ echo wp_kses(
225
+ sprintf(
226
+ // translators: 1 opening HTML p tag, 2 HTML strong tag containing current zone IP,
227
+ // translators: 3 closing HTML p tag.
228
+ __(
229
+ '%1$scurrently set to %2$s%3$s',
230
+ 'w3-total-cache'
231
+ ),
232
+ '<p class="description">',
233
+ '<strong>' . $details[ $field ]['current'] . '</strong>',
234
+ '</p>'
235
+ ),
236
+ array(
237
+ 'p' => array(
238
+ 'class' => array(),
239
+ ),
240
+ 'strong' => array(),
241
+ )
242
+ );
243
  }
244
  }
245
 
 
 
246
  public function w3tc_ajax_cdn_maxcdn_fsd_configure_zone() {
247
+ $api_key = Util_Request::get_string( 'api_key' );
248
  $zone_id = Util_Request::get( 'zone_id', '' );
249
+ $zone = array(
250
+ 'name' => Util_Request::get( 'name' ),
251
+ 'label' => Util_Request::get( 'name' ),
252
+ 'url' => Util_Request::get( 'url' ),
253
+ 'use_stale' => 1,
254
+ 'queries' => 1,
255
+ 'compress' => 1,
 
256
  'backend_compress' => 1,
257
+ 'dns_check' => Util_Request::get( 'dns_check' ),
258
+ 'ip' => Util_Request::get( 'ip' ),
259
  );
260
+ $api = \NetDNA::create( $api_key );
 
261
 
262
  try {
263
  if ( empty( $zone_id ) ) {
264
  $response = $api->create_pull_zone( $zone );
265
+ $zone_id = $response['id'];
266
  } else {
267
  $response = $api->update_pull_zone( $zone_id, $zone );
268
  }
269
 
270
  $custom_domains = $api->get_custom_domains( $zone_id );
271
+ $custom_domain = Util_Request::get( 'custom_domain' );
272
 
273
  $added = false;
274
  foreach ( $custom_domains as $d ) {
275
+ if ( $d === $custom_domain ) {
276
  $added = true;
277
  break;
278
  }
279
  }
280
+ if ( ! $added ) {
281
  $api->create_custom_domain( $zone_id, $custom_domain );
282
  }
283
  } catch ( \Exception $ex ) {
284
+ $this->render_intro(
285
+ array(
286
+ 'api_key' => $api_key,
287
+ 'error_message' => 'Failed to configure custom domain ' . $custom_domain . ': ' . $ex->getMessage(),
288
+ )
289
+ );
290
  exit();
291
  }
292
 
299
  $c->save();
300
 
301
  $details = array(
302
+ 'name' => $zone['name'],
303
+ 'home_domain' => Util_Environment::home_url_host(),
304
  'dns_cname_target' => $zone_domain,
305
  );
306
 
307
+ include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Success.php';
308
  exit();
309
  }
310
 
 
 
311
  public function w3tc_ajax_cdn_maxcdn_fsd_configure_zone_skip() {
312
+ $api_key = Util_Request::get_string( 'api_key' );
313
  $zone_id = Util_Request::get( 'zone_id', '' );
314
 
315
  $api = \NetDNA::create( $api_key );
317
  try {
318
  $zone = $api->get_zone( $zone_id );
319
  } catch ( \Exception $ex ) {
320
+ $this->render_intro(
321
+ array(
322
+ 'api_key' => $api_key,
323
+ 'error_message' => 'Failed to obtain custom domains: ' . $ex->getMessage(),
324
+ )
325
+ );
326
  exit();
327
  }
328
 
335
  $c->save();
336
 
337
  $details = array(
338
+ 'name' => $zone['name'],
339
+ 'home_domain' => Util_Environment::home_url_host(),
340
  'dns_cname_target' => $zone_domain,
341
  );
342
 
343
+ include W3TC_DIR . '/Cdnfsd_MaxCdn_Popup_View_Success.php';
344
  exit();
345
  }
346
  }
Cdnfsd_MaxCdn_Popup_View_Intro.php CHANGED
@@ -1,27 +1,28 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- 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 MaxCDN 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
  <p class="description">
23
  To obtain API key you can
24
- <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
25
  log in, and paste the key in above field.
26
  </p>
27
  </td>
@@ -31,7 +32,7 @@ if ( isset( $details['error_message'] ) )
31
  <p class="submit">
32
  <input type="button"
33
  class="w3tc_cdn_maxcdn_fsd_list_zones w3tc-button-save button-primary"
34
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
35
  </p>
36
  <?php Util_Ui::postbox_footer(); ?>
37
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your MaxCDN Account credentials', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
  <td>API Key:</td>
19
  <td>
20
  <input name="api_key" type="text" class="w3tc-ignore-change"
21
  style="width: 550px"
22
+ value="<?php echo esc_attr( $details['api_key'] ); ?>" />
23
  <p class="description">
24
  To obtain API key you can
25
+ <a target="_blank" href="<?php echo esc_url( $url_obtain_key ); ?>">click here</a>,
26
  log in, and paste the key in above field.
27
  </p>
28
  </td>
32
  <p class="submit">
33
  <input type="button"
34
  class="w3tc_cdn_maxcdn_fsd_list_zones w3tc-button-save button-primary"
35
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
36
  </p>
37
  <?php Util_Ui::postbox_footer(); ?>
38
  </div>
Cdnfsd_MaxCdn_Popup_View_Success.php CHANGED
@@ -1,26 +1,26 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_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
- 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
- </div>
18
 
19
- <p class="submit">
20
- <input type="button"
21
- class="w3tc_cdn_maxcdn_fsd_done w3tc-button-save button-primary"
22
- value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
23
- </p>
24
- <?php Util_Ui::postbox_footer(); ?>
25
- </div>
26
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ Pull Zone <?php echo esc_html( $details['name'] ); ?> was successfully configured.<br />
14
+ Next, update the domain <acronym title="Domain Name System">DNS</acronym> records
15
+ <strong><?php echo esc_html( $details['home_domain'] ); ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to
16
+ <strong><?php echo esc_html( $details['dns_cname_target'] ); ?></strong> to enable caching.
17
+ </div>
18
 
19
+ <p class="submit">
20
+ <input type="button"
21
+ class="w3tc_cdn_maxcdn_fsd_done w3tc-button-save button-primary"
22
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
23
+ </p>
24
+ <?php Util_Ui::postbox_footer(); ?>
25
+ </div>
26
  </form>
Cdnfsd_MaxCdn_Popup_View_Zone.php CHANGED
@@ -1,46 +1,70 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_form" method="post">
8
  <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
11
- Util_Ui::hidden( '', 'name', $details['name'] );
12
- ?>
13
 
14
  <div class="metabox-holder">
15
- <?php Util_Ui::postbox_header( __( 'Configure zone', 'w3-total-cache' ) ); ?>
16
  <table class="form-table">
17
  <tr>
18
- <th>Name:</th>
19
- <td><?php echo $details['name'] ?></td>
20
  </tr>
21
  <tr>
22
- <th>Origin URL:</th>
23
- <td><?php $this->render_zone_value_change( $details, 'url' ) ?></td>
24
  </tr>
25
  <tr>
26
- <th>Origin IP:</th>
27
- <td><?php $this->render_zone_ip_change( $details, 'ip' ) ?>
28
- <p class="description">IP of your WordPress host</p>
29
  </td>
30
  </tr>
31
  <tr>
32
- <th>Origin IP Resolution:</th>
33
- <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ) ?></td>
34
  </tr>
35
  <tr>
36
- <th>Ignore Cache Control:</th>
37
- <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ) ?></td>
38
  </tr>
39
  <tr>
40
- <th><acronym title="Content Delivery Network">CDN</acronym> Domain:</th>
 
 
 
 
41
  <td>
42
- <?php $this->render_zone_value_change( $details, 'custom_domain' ) ?>
43
- <p class="description">Domain <acronym title="Content Delivery Network">CDN</acronym> will handle</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  </td>
45
  </tr>
46
  </table>
@@ -48,10 +72,10 @@ Util_Ui::hidden( '', 'name', $details['name'] );
48
  <p class="submit">
49
  <input type="button"
50
  class="w3tc_cdn_maxcdn_fsd_configure_zone w3tc-button-save button-primary"
51
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
52
  <input type="button"
53
  class="w3tc_cdn_maxcdn_fsd_configure_zone_skip w3tc-button-save button"
54
- value="<?php _e( 'Don\'t reconfigure, I know what I\'m doing', 'w3-total-cache' ); ?>" />
55
 
56
  </p>
57
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form" method="post">
9
  <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
12
+ Util_Ui::hidden( '', 'name', $details['name'] );
13
+ ?>
14
 
15
  <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Configure zone', 'w3-total-cache' ) ); ?>
17
  <table class="form-table">
18
  <tr>
19
+ <th><?php esc_html_e( 'Name:', 'w3-total-cache' ); ?></th>
20
+ <td><?php echo esc_html( $details['name'] ); ?></td>
21
  </tr>
22
  <tr>
23
+ <th><?php esc_html_e( 'Origin URL:', 'w3-total-cache' ); ?></th>
24
+ <td><?php $this->render_zone_value_change( $details, 'url' ); ?></td>
25
  </tr>
26
  <tr>
27
+ <th><?php esc_html_e( 'Origin IP:', 'w3-total-cache' ); ?></th>
28
+ <td><?php $this->render_zone_ip_change( $details, 'ip' ); ?>
29
+ <p class="description"><?php esc_html_e( 'IP of your WordPress host', 'w3-total-cache' ); ?></p>
30
  </td>
31
  </tr>
32
  <tr>
33
+ <th><?php esc_html_e( 'Origin IP Resolution:', 'w3-total-cache' ); ?></th>
34
+ <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ); ?></td>
35
  </tr>
36
  <tr>
37
+ <th><?php esc_html_e( 'Ignore Cache Control:', 'w3-total-cache' ); ?></th>
38
+ <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ); ?></td>
39
  </tr>
40
  <tr>
41
+ <th>
42
+ <acronym title="<?php esc_attr_e( 'Content Delivery Network', 'w3-total-cache' ); ?>">
43
+ <?php esc_html_e( 'CDN', 'w3-total-cache' ); ?>
44
+ </acronym> <?php esc_html_e( 'Domain:', 'w3-total-cache' ); ?>
45
+ </th>
46
  <td>
47
+ <?php $this->render_zone_value_change( $details, 'custom_domain' ); ?>
48
+ <p class="description">
49
+ <?php
50
+ echo wp_kses(
51
+ sprintf(
52
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
53
+ __(
54
+ 'Domain %1$sCDN%2$s will handle',
55
+ 'w3-total-cache'
56
+ ),
57
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
58
+ '</acronym>'
59
+ ),
60
+ array(
61
+ 'acronym' => array(
62
+ 'title' => array(),
63
+ ),
64
+ )
65
+ );
66
+ ?>
67
+ </p>
68
  </td>
69
  </tr>
70
  </table>
72
  <p class="submit">
73
  <input type="button"
74
  class="w3tc_cdn_maxcdn_fsd_configure_zone w3tc-button-save button-primary"
75
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
76
  <input type="button"
77
  class="w3tc_cdn_maxcdn_fsd_configure_zone_skip w3tc-button-save button"
78
+ value="<?php esc_attr_e( 'Don\'t reconfigure, I know what I\'m doing', 'w3-total-cache' ); ?>" />
79
 
80
  </p>
81
  <?php Util_Ui::postbox_footer(); ?>
Cdnfsd_MaxCdn_Popup_View_Zones.php CHANGED
@@ -1,53 +1,51 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- ?>
11
- <div class="metabox-holder">
12
- <?php Util_Ui::postbox_header( __( 'Select zone to use', 'w3-total-cache' ) ); ?>
13
- <table class="form-table">
14
- <tr>
15
- <td>Zone:</td>
16
- <td>
17
- <?php
18
- if ( count( $details['zones'] ) > 15 )
19
- echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
- ?>
21
-
22
- <?php foreach ( $details['zones'] as $zone ): ?>
23
- <label>
24
- <input name="zone_id" type="radio" class="w3tc-ignore-change"
25
- value="<?php echo $zone['id'] ?>" />
26
- <?php echo $zone['name'] ?>
27
- (<?php echo $zone['cdn_url'] ?>)
28
- </label><br />
29
- <?php endforeach ?>
30
-
31
- <label>
32
- <input name="zone_id" type="radio" class="w3tc-ignore-change" value=""
33
- />
34
- Add new zone:
35
- </label>
36
- <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
37
-
38
- <?php
39
- if ( count( $details['zones'] ) > 15 )
40
- echo '</div>';
41
- ?>
42
- </td>
43
- </tr>
44
- </table>
45
-
46
- <p class="submit">
47
- <input type="button"
48
- class="w3tc_cdn_maxcdn_fsd_view_zone w3tc-button-save button-primary"
49
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
50
- </p>
51
- <?php Util_Ui::postbox_footer(); ?>
52
- </div>
53
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form" method="post">
9
+ <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ ?>
12
+ <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( esc_html__( 'Select zone to use', 'w3-total-cache' ) ); ?>
14
+ <table class="form-table">
15
+ <tr>
16
+ <td>Zone:</td>
17
+ <td>
18
+ <?php
19
+ if ( count( $details['zones'] ) > 15 ) {
20
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
21
+ }
22
+ ?>
23
+ <?php foreach ( $details['zones'] as $zone ) : ?>
24
+ <label>
25
+ <input name="zone_id" type="radio" class="w3tc-ignore-change"
26
+ value="<?php echo esc_attr( $zone['id'] ); ?>" />
27
+ <?php echo esc_html( $zone['name'] ); ?>
28
+ (<?php echo esc_html( $zone['cdn_url'] ); ?>)
29
+ </label><br />
30
+ <?php endforeach; ?>
31
+ <label>
32
+ <input name="zone_id" type="radio" class="w3tc-ignore-change" value=""/>
33
+ Add new zone:
34
+ </label>
35
+ <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
36
+ <?php
37
+ if ( count( $details['zones'] ) > 15 ) {
38
+ echo '</div>';
39
+ }
40
+ ?>
41
+ </td>
42
+ </tr>
43
+ </table>
44
+ <p class="submit">
45
+ <input type="button"
46
+ class="w3tc_cdn_maxcdn_fsd_view_zone w3tc-button-save button-primary"
47
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
48
+ </p>
49
+ <?php Util_Ui::postbox_footer(); ?>
50
+ </div>
 
 
 
51
  </form>
Cdnfsd_Page_View_Header.php CHANGED
@@ -1,15 +1,29 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
 
9
  <p>
10
- <?php echo sprintf(
11
- __( 'Content Delivery Network support via %1$s is currently %2$s.', 'w3-total-cache' ),
12
- '<strong>'.Cdnfsd_Util::engine_name( $config->get_string( 'cdnfsd.engine' ) ).'</strong>',
13
- '<span class="w3tc-' . ( $config->get_boolean( 'cdnfsd.enabled' ) ? 'enabled">' . __( 'enabled', 'w3-total-cache' ) : 'disabled">' . __( 'disabled', 'w3-total-cache' ) ) . '</span>'
14
- ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  </p>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
 
9
  <p>
10
+ <?php
11
+ echo wp_kses(
12
+ sprintf(
13
+ // translators: 1 HTML strong tag containing CDNFSD engine name, 2 HTML span tag containing CDNFSD engine enabled/disabled.
14
+ __(
15
+ 'Content Delivery Network support via %1$s is currently %2$s.',
16
+ 'w3-total-cache'
17
+ ),
18
+ '<strong>' . Cdnfsd_Util::engine_name( $config->get_string( 'cdnfsd.engine' ) ) . '</strong>',
19
+ '<span class="w3tc-' . ( $config->get_boolean( 'cdnfsd.enabled' ) ? 'enabled">' . __( 'enabled', 'w3-total-cache' ) : 'disabled">' . __( 'disabled', 'w3-total-cache' ) ) . '</span>'
20
+ ),
21
+ array(
22
+ 'strong' => array(),
23
+ 'span' => array(
24
+ 'class' => array(),
25
+ ),
26
+ )
27
+ );
28
+ ?>
29
  </p>
Cdnfsd_StackPath2_Page_View.php CHANGED
@@ -1,56 +1,81 @@
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 echo implode( ', ', $config->get_array( 'cdnfsd.stackpath2.domain' ) ) ?>
47
  <p class="description">
48
  The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
49
  <acronym title="Content Delivery Network">CDN</acronym> domain
50
  </p>
51
  </td>
52
  </tr>
53
- <?php endif ?>
54
  </table>
55
 
56
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ $key = $config->get_string( 'cdnfsd.stackpath2.client_id' );
9
+ $authorized = ! empty( $key );
10
 
11
  ?>
12
  <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
13
  <div class="metabox-holder">
14
+ <?php
15
+ Util_Ui::postbox_header(
16
+ esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ),
17
+ '',
18
+ 'configuration'
19
+ );
20
+ ?>
21
  <table class="form-table">
22
  <tr>
23
  <th style="width: 300px;">
24
  <label>
25
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
 
 
 
26
  </label>
27
  </th>
28
  <td>
29
+ <?php if ( $authorized ) : ?>
30
  <input class="w3tc_cdn_stackpath2_fsd_authorize button-primary"
31
  type="button"
32
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>"
33
  />
34
+ <?php else : ?>
35
  <input class="w3tc_cdn_stackpath2_fsd_authorize button-primary"
36
  type="button"
37
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>"
38
  />
39
+ <?php endif; ?>
40
  </td>
41
  </tr>
42
 
43
+ <?php if ( $authorized ) : ?>
44
  <tr>
45
  <th>
46
+ <label>
47
+ <?php
48
+ echo wp_kses(
49
+ sprintf(
50
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
51
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
52
+ __(
53
+ '%1$sCDN%2$s %3$sCNAME%4$s:',
54
+ 'w3-total-cache'
55
+ ),
56
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
57
+ '</acronym>',
58
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
59
+ '</acronym>'
60
+ ),
61
+ array(
62
+ 'acronym' => array(
63
+ 'title' => array(),
64
+ ),
65
+ )
66
+ );
67
+ ?>
68
+ </label>
69
  </th>
70
  <td class="w3tc_config_value_text">
71
+ <?php echo esc_html( implode( ', ', $config->get_array( 'cdnfsd.stackpath2.domain' ) ) ); ?>
72
  <p class="description">
73
  The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
74
  <acronym title="Content Delivery Network">CDN</acronym> domain
75
  </p>
76
  </td>
77
  </tr>
78
+ <?php endif; ?>
79
  </table>
80
 
81
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
Cdnfsd_StackPath2_Popup.php CHANGED
@@ -43,8 +43,8 @@ class Cdnfsd_StackPath2_Popup {
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 );
@@ -90,8 +90,8 @@ class Cdnfsd_StackPath2_Popup {
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
  }
@@ -129,7 +129,7 @@ class Cdnfsd_StackPath2_Popup {
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 );
43
 
44
  public function w3tc_ajax_cdn_stackpath2_fsd_list_stacks() {
45
  $api_config = array(
46
+ 'client_id' => Util_Request::get_string( 'client_id' ),
47
+ 'client_secret' => Util_Request::get_string( 'client_secret' )
48
  );
49
 
50
  $api = new Cdn_StackPath2_Api( $api_config );
90
 
91
 
92
  public function w3tc_ajax_cdn_stackpath2_fsd_list_sites() {
93
+ $api_config = $this->api_config_decode( Util_Request::get_string( 'api_config' ) );
94
+ $api_config['stack_id'] = Util_Request::get_string( 'stack_id' );
95
 
96
  $this->_w3tc_ajax_cdn_stackpath2_fsd_list_sites( $api_config );
97
  }
129
 
130
 
131
  public function w3tc_ajax_cdn_stackpath2_fsd_configure_site() {
132
+ $api_config = $this->api_config_decode( Util_Request::get_string( 'api_config' ) );
133
  $site_id = Util_Request::get( 'site_id', '' );
134
 
135
  $api = new Cdn_StackPath2_Api( $api_config );
Cdnfsd_StackPath2_Popup_View_Intro.php CHANGED
@@ -1,35 +1,34 @@
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
  <p class="description">
31
  To obtain API key you can
32
- <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
33
  log in, and paste the key in above field.
34
  </p>
35
  </td>
@@ -39,7 +38,7 @@ if ( isset( $details['error_message'] ) )
39
  <p class="submit">
40
  <input type="button"
41
  class="w3tc_cdn_stackpath2_fsd_list_stacks w3tc-button-save button-primary"
42
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
43
  </p>
44
  <?php Util_Ui::postbox_footer(); ?>
45
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_fsd_form">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
  <td>API Client ID:</td>
19
  <td>
20
  <input name="client_id" type="text" class="w3tc-ignore-change"
21
+ style="width: 550px" 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" value="<?php echo esc_attr( $details['client_secret'] ); ?>" />
 
29
  <p class="description">
30
  To obtain API key you can
31
+ <a target="_blank" href="<?php echo esc_url( $url_obtain_key ); ?>">click here</a>,
32
  log in, and paste the key in above field.
33
  </p>
34
  </td>
38
  <p class="submit">
39
  <input type="button"
40
  class="w3tc_cdn_stackpath2_fsd_list_stacks w3tc-button-save button-primary"
41
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
42
  </p>
43
  <?php Util_Ui::postbox_footer(); ?>
44
  </div>
Cdnfsd_StackPath2_Popup_View_Sites.php CHANGED
@@ -1,18 +1,19 @@
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 ) {
@@ -20,19 +21,18 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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
@@ -47,7 +47,7 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_fsd_form" method="post">
9
  <?php
10
+ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
11
+ ?>
12
  <div class="metabox-holder">
13
+ <?php Util_Ui::postbox_header( esc_html__( 'Select site to use', 'w3-total-cache' ) ); ?>
14
  <table class="form-table">
15
  <tr>
16
+ <td><?php esc_html_e( 'Site:', 'w3-total-cache' ); ?></td>
17
  <td>
18
  <?php
19
  if ( count( $details['sites'] ) > 15 ) {
21
  }
22
  ?>
23
 
24
+ <?php foreach ( $details['sites'] as $i ) : ?>
25
 
26
  <label>
27
  <input name="site_id" type="radio" class="w3tc-ignore-change"
28
+ value="<?php echo esc_attr( $i['id'] ); ?>" />
29
+ <?php echo esc_html( $i['label'] ); ?>
30
  </label><br />
31
  <?php endforeach ?>
32
 
33
  <label>
34
+ <input name="site_id" type="radio" class="w3tc-ignore-change" value="" />
35
+ <?php esc_html_e( 'Add new site: ', 'w3-total-cache' ); ?><?php echo esc_html( $details['new_hostname'] ); ?>
 
36
  </label>
37
 
38
  <?php
47
  <p class="submit">
48
  <input type="button"
49
  class="w3tc_cdn_stackpath2_fsd_configure_site w3tc-button-save button-primary"
50
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
51
  </p>
52
  <?php Util_Ui::postbox_footer(); ?>
53
  </div>
Cdnfsd_StackPath2_Popup_View_Stacks.php CHANGED
@@ -1,18 +1,17 @@
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 ) {
@@ -20,16 +19,16 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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 ) {
@@ -43,7 +42,7 @@ Util_Ui::hidden( '', 'api_config', $details['api_config'] );
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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_fsd_form" method="post">
9
+ <?php Util_Ui::hidden( '', 'api_config', $details['api_config'] ); ?>
 
 
10
  <div class="metabox-holder">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Select stack to use', 'w3-total-cache' ) ); ?>
12
  <table class="form-table">
13
  <tr>
14
+ <td><?php esc_html_e( 'Site:', 'w3-total-cache' ); ?></td>
15
  <td>
16
  <?php
17
  if ( count( $details['stacks'] ) > 15 ) {
19
  }
20
  ?>
21
 
22
+ <?php foreach ( $details['stacks'] as $i ) : ?>
23
  <label>
24
  <input name="stack_id" type="radio" class="w3tc-ignore-change"
25
+ value="<?php echo esc_attr( $i['id'] ); ?>" />
26
+ <?php echo esc_html( $i['name'] ); ?>
27
+ <?php if ( 'ACTIVE' !== $i['status'] ) : ?>
28
+ (<?php echo esc_html( $i['status'] ); ?>)
29
+ <?php endif; ?>
30
  </label><br />
31
+ <?php endforeach; ?>
32
 
33
  <?php
34
  if ( count( $details['stacks'] ) > 15 ) {
42
  <p class="submit">
43
  <input type="button"
44
  class="w3tc_cdn_stackpath2_fsd_list_sites w3tc-button-save button-primary"
45
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
46
  </p>
47
  <?php Util_Ui::postbox_footer(); ?>
48
  </div>
Cdnfsd_StackPath2_Popup_View_Success.php CHANGED
@@ -1,23 +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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_cdn_stackpath2_fsd_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( '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 esc_html_e( 'Done', 'w3-total-cache' ); ?>" />
20
+ </p>
21
+ <?php Util_Ui::postbox_footer(); ?>
22
+ </div>
23
  </form>
Cdnfsd_StackPath_Page_View.php CHANGED
@@ -1,51 +1,68 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- $key = $config->get_string( 'cdnfsd.stackpath.api_key' );
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_stackpath_fsd_authorize button-primary"
28
  type="button"
29
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
30
  />
31
- <?php else: ?>
32
  <input class="w3tc_cdn_stackpath_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 $config->get_string( 'cdnfsd.stackpath.zone_domain' )
48
- ?>
49
  <p 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
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ $key = $config->get_string( 'cdnfsd.stackpath.api_key' );
9
+ $authorized = ! empty( $key );
10
 
11
  ?>
12
  <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
13
  <div class="metabox-holder">
14
+ <?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
 
15
  <table class="form-table">
16
  <tr>
17
  <th style="width: 300px;">
18
  <label>
19
+ <?php esc_html_e( 'Specify account credentials:', 'w3-total-cache' ); ?>
 
 
 
20
  </label>
21
  </th>
22
  <td>
23
+ <?php if ( $authorized ) : ?>
24
  <input class="w3tc_cdn_stackpath_fsd_authorize button-primary"
25
  type="button"
26
+ value="<?php esc_html_e( 'Reauthorize', 'w3-total-cache' ); ?>"
27
  />
28
+ <?php else : ?>
29
  <input class="w3tc_cdn_stackpath_fsd_authorize button-primary"
30
  type="button"
31
+ value="<?php esc_html_e( 'Authorize', 'w3-total-cache' ); ?>"
32
  />
33
  <?php endif ?>
34
  </td>
35
  </tr>
36
 
37
+ <?php if ( $authorized ) : ?>
38
  <tr>
39
  <th>
40
+ <label>
41
+ <?php
42
+ echo wp_kses(
43
+ sprintf(
44
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
45
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
46
+ __(
47
+ '%1$sCDN%2$s %3$sCNAME%4$s:',
48
+ 'w3-total-cache'
49
+ ),
50
+ '<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
51
+ '</acronym>',
52
+ '<acronym title="' . esc_attr__( 'Canonical Name', 'w3-total-cache' ) . '">',
53
+ '</acronym>'
54
+ ),
55
+ array(
56
+ 'acronym' => array(
57
+ 'title' => array(),
58
+ ),
59
+ )
60
+ );
61
+ ?>
62
+ </label>
63
  </th>
64
  <td class="w3tc_config_value_text">
65
+ <?php echo esc_html( $config->get_string( 'cdnfsd.stackpath.zone_domain' ) ); ?>
 
 
66
  <p class="description">
67
  The website domain must <acronym title="Canonical Name">CNAME</acronym> point to the
68
  <acronym title="Content Delivery Network">CDN</acronym> domain
Cdnfsd_StackPath_Popup.php CHANGED
@@ -41,7 +41,7 @@ class Cdnfsd_StackPath_Popup {
41
 
42
 
43
  public function w3tc_ajax_cdn_stackpath_fsd_list_zones() {
44
- $api_key = $_REQUEST['api_key'];
45
 
46
  $api = Cdn_StackPath_Api::create( $api_key );
47
  if ( !$api->is_valid() ) {
@@ -80,7 +80,7 @@ class Cdnfsd_StackPath_Popup {
80
 
81
 
82
  public function w3tc_ajax_cdn_stackpath_fsd_view_zone() {
83
- $api_key = $_REQUEST['api_key'];
84
  $zone_id = Util_Request::get( 'zone_id', '' );
85
 
86
  $details = array(
@@ -155,14 +155,14 @@ class Cdnfsd_StackPath_Popup {
155
 
156
  if ( !isset( $details[$field]['current'] ) ||
157
  $details[$field]['current'] == $details[$field]['new'] )
158
- echo htmlspecialchars( $details[$field]['new'] );
159
  else {
160
  echo 'currently set to <strong>' .
161
- htmlspecialchars( empty( $details[$field]['current'] ) ?
162
  '<empty>' : $details[$field]['current'] ) .
163
  '</strong><br />';
164
  echo 'will be changed to <strong>' .
165
- htmlspecialchars( $details[$field]['new'] ) . '</strong><br />';
166
  }
167
  }
168
 
@@ -173,11 +173,11 @@ class Cdnfsd_StackPath_Popup {
173
 
174
  if ( !isset( $details[$field]['current'] ) ) {
175
  echo 'will be set to <strong>';
176
- echo $this->render_zone_boolean( $details[$field]['new'] );
177
  echo '</strong>';
178
  } else if ( $details[$field]['current'] == $details[$field]['new'] ) {
179
  echo '<strong>';
180
- echo $this->render_zone_boolean( $details[$field]['new'] );
181
  echo '</strong>';
182
  } else {
183
  echo 'currently set to <strong>';
@@ -206,14 +206,14 @@ class Cdnfsd_StackPath_Popup {
206
  if ( isset( $details[$field]['current'] ) &&
207
  $details[$field]['current'] != $details[$field]['new'] ) {
208
  echo '<p class="description">currently set to <strong>' .
209
- $details[$field]['current'] . '</strong></p>';
210
  }
211
  }
212
 
213
 
214
 
215
  public function w3tc_ajax_cdn_stackpath_fsd_configure_zone() {
216
- $api_key = $_REQUEST['api_key'];
217
  $zone_id = Util_Request::get( 'zone_id', '' );
218
 
219
  $zone = array(
@@ -284,7 +284,7 @@ class Cdnfsd_StackPath_Popup {
284
 
285
 
286
  public function w3tc_ajax_cdn_stackpath_fsd_configure_zone_skip() {
287
- $api_key = $_REQUEST['api_key'];
288
  $zone_id = Util_Request::get( 'zone_id', '' );
289
 
290
  $api = Cdn_StackPath_Api::create( $api_key );
41
 
42
 
43
  public function w3tc_ajax_cdn_stackpath_fsd_list_zones() {
44
+ $api_key = Util_Request::get_string( 'api_key' );
45
 
46
  $api = Cdn_StackPath_Api::create( $api_key );
47
  if ( !$api->is_valid() ) {
80
 
81
 
82
  public function w3tc_ajax_cdn_stackpath_fsd_view_zone() {
83
+ $api_key = Util_Request::get_string( 'api_key' );
84
  $zone_id = Util_Request::get( 'zone_id', '' );
85
 
86
  $details = array(
155
 
156
  if ( !isset( $details[$field]['current'] ) ||
157
  $details[$field]['current'] == $details[$field]['new'] )
158
+ echo esc_html( $details[ $field ]['new'] );
159
  else {
160
  echo 'currently set to <strong>' .
161
+ esc_html( empty( $details[ $field ]['current'] ) ?
162
  '<empty>' : $details[$field]['current'] ) .
163
  '</strong><br />';
164
  echo 'will be changed to <strong>' .
165
+ esc_html( $details[ $field ]['new'] ) . '</strong><br />';
166
  }
167
  }
168
 
173
 
174
  if ( !isset( $details[$field]['current'] ) ) {
175
  echo 'will be set to <strong>';
176
+ echo esc_html( $this->render_zone_boolean( $details[ $field ]['new'] ) );
177
  echo '</strong>';
178
  } else if ( $details[$field]['current'] == $details[$field]['new'] ) {
179
  echo '<strong>';
180
+ echo esc_html( $this->render_zone_boolean( $details[ $field ]['new'] ) );
181
  echo '</strong>';
182
  } else {
183
  echo 'currently set to <strong>';
206
  if ( isset( $details[$field]['current'] ) &&
207
  $details[$field]['current'] != $details[$field]['new'] ) {
208
  echo '<p class="description">currently set to <strong>' .
209
+ esc_html( $details[ $field ]['current'] ) . '</strong></p>';
210
  }
211
  }
212
 
213
 
214
 
215
  public function w3tc_ajax_cdn_stackpath_fsd_configure_zone() {
216
+ $api_key = Util_Request::get_string( 'api_key' );
217
  $zone_id = Util_Request::get( 'zone_id', '' );
218
 
219
  $zone = array(
284
 
285
 
286
  public function w3tc_ajax_cdn_stackpath_fsd_configure_zone_skip() {
287
+ $api_key = Util_Request::get_string( 'api_key' );
288
  $zone_id = Util_Request::get( 'zone_id', '' );
289
 
290
  $api = Cdn_StackPath_Api::create( $api_key );
Cdnfsd_StackPath_Popup_View_Intro.php CHANGED
@@ -1,27 +1,28 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- 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 esc_attr( $details['api_key'] ) ?>" />
22
  <p class="description">
23
  To obtain API key you can
24
- <a target="_blank" href="<?php echo esc_attr( $url_obtain_key ) ?>">click here</a>,
25
  log in, and paste the key in above field.
26
  </p>
27
  </td>
@@ -31,7 +32,7 @@ if ( isset( $details['error_message'] ) )
31
  <p class="submit">
32
  <input type="button"
33
  class="w3tc_cdn_stackpath_fsd_list_zones w3tc-button-save button-primary"
34
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
35
  </p>
36
  <?php Util_Ui::postbox_footer(); ?>
37
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
  <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
  <div class="metabox-holder">
15
+ <?php Util_Ui::postbox_header( esc_html__( 'Your StackPath Account credentials', 'w3-total-cache' ) ); ?>
 
16
  <table class="form-table">
17
  <tr>
18
  <td>API Key:</td>
19
  <td>
20
  <input name="api_key" type="text" class="w3tc-ignore-change"
21
  style="width: 550px"
22
+ value="<?php echo esc_attr( $details['api_key'] ); ?>" />
23
  <p class="description">
24
  To obtain API key you can
25
+ <a target="_blank" href="<?php echo esc_url( $url_obtain_key ); ?>">click here</a>,
26
  log in, and paste the key in above field.
27
  </p>
28
  </td>
32
  <p class="submit">
33
  <input type="button"
34
  class="w3tc_cdn_stackpath_fsd_list_zones w3tc-button-save button-primary"
35
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
36
  </p>
37
  <?php Util_Ui::postbox_footer(); ?>
38
  </div>
Cdnfsd_StackPath_Popup_View_Success.php CHANGED
@@ -1,26 +1,26 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_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 <?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
- </div>
18
 
19
- <p class="submit">
20
- <input type="button"
21
- class="w3tc_cdn_stackpath_fsd_done w3tc-button-save button-primary"
22
- value="<?php _e( 'Done', 'w3-total-cache' ); ?>" />
23
- </p>
24
- <?php Util_Ui::postbox_footer(); ?>
25
- </div>
26
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Succeeded', 'w3-total-cache' ) ); ?>
 
11
 
12
+ <div style="text-align: center">
13
+ Site <?php echo esc_html( $details['name'] ); ?> was successfully configured.<br />
14
+ Next, update the domain <acronym title="Domain Name System">DNS</acronym> records
15
+ <strong><?php echo esc_html( $details['home_domain'] ); ?></strong> and add <acronym title="Canonical Name">CNAME</acronym> alias to
16
+ <strong><?php echo esc_html( $details['dns_cname_target'] ); ?></strong> to enable caching.
17
+ </div>
18
 
19
+ <p class="submit">
20
+ <input type="button"
21
+ class="w3tc_cdn_stackpath_fsd_done w3tc-button-save button-primary"
22
+ value="<?php esc_attr_e( 'Done', 'w3-total-cache' ); ?>" />
23
+ </p>
24
+ <?php Util_Ui::postbox_footer(); ?>
25
+ </div>
26
  </form>
Cdnfsd_StackPath_Popup_View_Zone.php CHANGED
@@ -1,46 +1,56 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_form" method="post">
8
  <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
11
- Util_Ui::hidden( '', 'name', $details['name'] );
12
- ?>
13
 
14
  <div class="metabox-holder">
15
- <?php Util_Ui::postbox_header( __( 'Configure zone', 'w3-total-cache' ) ); ?>
16
  <table class="form-table">
17
  <tr>
18
- <th>Name:</th>
19
- <td><?php echo $details['name'] ?></td>
20
  </tr>
21
  <tr>
22
- <th>Origin URL:</th>
23
- <td><?php $this->render_zone_value_change( $details, 'url' ) ?></td>
24
  </tr>
25
  <tr>
26
- <th>Origin IP:</th>
27
- <td><?php $this->render_zone_ip_change( $details, 'ip' ) ?>
28
- <p class="description">IP of your WordPress host</p>
29
  </td>
30
  </tr>
31
  <tr>
32
- <th>Origin IP Resolution:</th>
33
- <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ) ?></td>
34
  </tr>
35
  <tr>
36
- <th>Ignore Cache Control:</th>
37
- <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ) ?></td>
38
  </tr>
39
  <tr>
40
- <th><acronym title="Content Delivery Network">CDN</acronym> Domain:</th>
 
 
 
 
41
  <td>
42
- <?php $this->render_zone_value_change( $details, 'custom_domain' ) ?>
43
- <p class="description">Domain <acronym title="Content Delivery Network">CDN</acronym> will handle</p>
 
 
 
 
 
44
  </td>
45
  </tr>
46
  </table>
@@ -48,10 +58,10 @@ Util_Ui::hidden( '', 'name', $details['name'] );
48
  <p class="submit">
49
  <input type="button"
50
  class="w3tc_cdn_stackpath_fsd_configure_zone w3tc-button-save button-primary"
51
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
52
  <input type="button"
53
  class="w3tc_cdn_stackpath_fsd_configure_zone_skip w3tc-button-save button"
54
- value="<?php _e( 'Don\'t reconfigure, I know what I\'m doing', 'w3-total-cache' ); ?>" />
55
 
56
  </p>
57
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form" method="post">
9
  <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ Util_Ui::hidden( '', 'zone_id', $details['zone_id'] );
12
+ Util_Ui::hidden( '', 'name', $details['name'] );
13
+ ?>
14
 
15
  <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Configure zone', 'w3-total-cache' ) ); ?>
17
  <table class="form-table">
18
  <tr>
19
+ <th><?php esc_html_e( 'Name:', 'w3-total-cache' ); ?></th>
20
+ <td><?php echo esc_html( $details['name'] ); ?></td>
21
  </tr>
22
  <tr>
23
+ <th><?php esc_html_e( 'Origin URL:', 'w3-total-cache' ); ?></th>
24
+ <td><?php $this->render_zone_value_change( $details, 'url' ); ?></td>
25
  </tr>
26
  <tr>
27
+ <th><?php esc_html_e( 'Origin IP:', 'w3-total-cache' ); ?></th>
28
+ <td><?php $this->render_zone_ip_change( $details, 'ip' ); ?>
29
+ <p class="description"><?php esc_html_e( 'IP of your WordPress host', 'w3-total-cache' ); ?></p>
30
  </td>
31
  </tr>
32
  <tr>
33
+ <th><?php esc_html_e( 'Origin IP Resolution:', 'w3-total-cache' ); ?></th>
34
+ <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ); ?></td>
35
  </tr>
36
  <tr>
37
+ <th><?php esc_html_e( 'Ignore Cache Control:', 'w3-total-cache' ); ?></th>
38
+ <td><?php $this->render_zone_boolean_change( $details, 'dns_check' ); ?></td>
39
  </tr>
40
  <tr>
41
+ <th>
42
+ <acronym title="<?php esc_attr_e( 'Content Delivery Network', 'w3-total-cache' ); ?>">
43
+ <?php esc_html_e( 'CDN', 'w3-total-cache' ); ?>
44
+ </acronym><?php esc_html_e( ' Domain:', 'w3-total-cache' ); ?>
45
+ </th>
46
  <td>
47
+ <?php $this->render_zone_value_change( $details, 'custom_domain' ); ?>
48
+ <p class="description">
49
+ <?php esc_html_e( 'Domain ', 'w3-total-cache' ); ?>
50
+ <acronym title="<?php esc_attr_e( 'Content Delivery Network', 'w3-total-cache' ); ?>">
51
+ <?php esc_html_e( 'CDN', 'w3-total-cache' ); ?>
52
+ </acronym><?php esc_html_e( ' will handle', 'w3-total-cache' ); ?>
53
+ </p>
54
  </td>
55
  </tr>
56
  </table>
58
  <p class="submit">
59
  <input type="button"
60
  class="w3tc_cdn_stackpath_fsd_configure_zone w3tc-button-save button-primary"
61
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
62
  <input type="button"
63
  class="w3tc_cdn_stackpath_fsd_configure_zone_skip w3tc-button-save button"
64
+ value="<?php esc_attr_e( 'Don\'t reconfigure, I know what I\'m doing', 'w3-total-cache' ); ?>" />
65
 
66
  </p>
67
  <?php Util_Ui::postbox_footer(); ?>
Cdnfsd_StackPath_Popup_View_Zones.php CHANGED
@@ -1,53 +1,49 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_popup_form" method="post">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- ?>
11
- <div class="metabox-holder">
12
- <?php Util_Ui::postbox_header( __( 'Select zone to use', 'w3-total-cache' ) ); ?>
13
- <table class="form-table">
14
- <tr>
15
- <td>Zone:</td>
16
- <td>
17
- <?php
18
- if ( count( $details['zones'] ) > 15 )
19
- echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
20
- ?>
21
-
22
- <?php foreach ( $details['zones'] as $zone ): ?>
23
- <label>
24
- <input name="zone_id" type="radio" class="w3tc-ignore-change"
25
- value="<?php echo $zone['id'] ?>" />
26
- <?php echo $zone['name'] ?>
27
- (<?php echo $zone['cdn_url'] ?>)
28
- </label><br />
29
- <?php endforeach ?>
30
-
31
- <label>
32
- <input name="zone_id" type="radio" class="w3tc-ignore-change" value=""
33
- />
34
- Add new zone:
35
- </label>
36
- <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
37
-
38
- <?php
39
- if ( count( $details['zones'] ) > 15 )
40
- echo '</div>';
41
- ?>
42
- </td>
43
- </tr>
44
- </table>
45
-
46
- <p class="submit">
47
- <input type="button"
48
- class="w3tc_cdn_stackpath_fsd_view_zone w3tc-button-save button-primary"
49
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
50
- </p>
51
- <?php Util_Ui::postbox_footer(); ?>
52
- </div>
53
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_popup_form" method="post">
9
+ <?php Util_Ui::hidden( '', 'api_key', $details['api_key'] ); ?>
10
+ <div class="metabox-holder">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Select zone to use', 'w3-total-cache' ) ); ?>
12
+ <table class="form-table">
13
+ <tr>
14
+ <td>Zone:</td>
15
+ <td>
16
+ <?php
17
+ if ( count( $details['zones'] ) > 15 ) {
18
+ echo '<div style="width: 100%; height: 300px; overflow-y: scroll">';
19
+ }
20
+ ?>
21
+ <?php foreach ( $details['zones'] as $zone ) : ?>
22
+ <label>
23
+ <input name="zone_id" type="radio" class="w3tc-ignore-change"
24
+ value="<?php echo esc_attr( $zone['id'] ); ?>" />
25
+ <?php echo esc_html( $zone['name'] ); ?>
26
+ (<?php echo esc_html( $zone['cdn_url'] ); ?>)
27
+ </label><br />
28
+ <?php endforeach; ?>
29
+ <label>
30
+ <input name="zone_id" type="radio" class="w3tc-ignore-change" value="" />
31
+ Add new zone:
32
+ </label>
33
+ <input name="zone_new_name" type="text" class="w3tc-ignore-change" />
34
+ <?php
35
+ if ( count( $details['zones'] ) > 15 ) {
36
+ echo '</div>';
37
+ }
38
+ ?>
39
+ </td>
40
+ </tr>
41
+ </table>
42
+ <p class="submit">
43
+ <input type="button"
44
+ class="w3tc_cdn_stackpath_fsd_view_zone w3tc-button-save button-primary"
45
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
46
+ </p>
47
+ <?php Util_Ui::postbox_footer(); ?>
48
+ </div>
 
 
 
 
 
49
  </form>
Cdnfsd_TransparentCDN_Page_View.php CHANGED
@@ -7,7 +7,7 @@
7
 
8
  namespace W3TC;
9
 
10
- if ( !defined( 'W3TC' ) ) {
11
  die();
12
  }
13
 
@@ -24,48 +24,48 @@ $authorized = ! empty( $key );
24
  'configuration'
25
  );
26
  ?>
27
- <table class="form-table">
28
- <tr>
29
- <th style="width: 300px;">
30
- <label for="cdnfsd_transparentcdn_company_id"> <?php _e( 'Company id:', 'w3-total-cache' ); ?> </label>
31
- </th>
32
- <td>
33
- <input id="cdnfsd_transparentcdn_company_id" class="w3tc-ignore-change" type="text"
34
- <?php Util_Ui::sealing_disabled( 'cdnfsd.transparentcdn.company_id' ) ?>
35
- name="cdnfsd__transparentcdn__company_id"
36
- value="<?php echo esc_attr( $config->get_string( 'cdnfsd.transparentcdn.company_id' ) ); ?>" size="60" />
37
- </td>
38
- </tr>
39
- <tr>
40
- <th style="width: 300px;"><label for="cdnfsd_transparentcdn_clientid"><?php _e( 'Client id:', 'w3-total-cache' ); ?></label></th>
41
- <td>
42
- <input id="cdnfsd_transparentcdn_clientid" class="w3tc-ignore-change"
43
- <?php Util_Ui::sealing_disabled( 'cdnfsd.transparentcdn.client_id' ) ?> type="text"
44
- name="cdnfsd__transparentcdn__client_id"
45
- value="<?php echo esc_attr( $config->get_string( 'cdnfsd.transparentcdn.client_id' ) ); ?>" size="60" />
46
- </td>
47
- </tr>
48
- <tr>
49
- <th style="width: 300px;"><label for="cdnfsd_transparentcdn_clientsecret"><?php _e( 'Client secret:', 'w3-total-cache' ); ?></label></th>
50
- <td>
51
- <input id="cdnfsd_transparentcdn_clientsecret" class="w3tc-ignore-change"
52
- <?php Util_Ui::sealing_disabled( 'cdnfsd.transparentcdn.client_secret' ) ?> type="text"
53
- name="cdnfsd__transparentcdn__client_secret"
54
- value="<?php echo esc_attr( $config->get_string( 'cdnfsd.transparentcdn.client_secret' ) ); ?>" size="60" />
55
- </td>
56
- </tr>
57
- <tr>
58
- <td>
59
- <span id="transparentcdn_test" class="button {type: 'transparentcdn', nonce: '<?php echo wp_create_nonce( 'w3tc' ); ?>'}">
60
- <?php _e( 'Test TransparentCDN', 'w3-total-cache' ); ?>
61
- </span>
62
- </td>
63
- <td colspan="1">
64
- <span id="tcdn_test_status" class="w3tc-status w3tc-process">
65
- </span>
66
- </td>
67
- </tr>
68
- </table>
69
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
70
  <?php Util_Ui::postbox_footer(); ?>
71
  </div>
7
 
8
  namespace W3TC;
9
 
10
+ if ( ! defined( 'W3TC' ) ) {
11
  die();
12
  }
13
 
24
  'configuration'
25
  );
26
  ?>
27
+ <table class="form-table">
28
+ <tr>
29
+ <th style="width: 300px;">
30
+ <label for="cdnfsd_transparentcdn_company_id"> <?php esc_html_e( 'Company id:', 'w3-total-cache' ); ?> </label>
31
+ </th>
32
+ <td>
33
+ <input id="cdnfsd_transparentcdn_company_id" class="w3tc-ignore-change" type="text"
34
+ <?php Util_Ui::sealing_disabled( 'cdnfsd.transparentcdn.company_id' ); ?>
35
+ name="cdnfsd__transparentcdn__company_id"
36
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.transparentcdn.company_id' ) ); ?>" size="60" />
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th style="width: 300px;"><label for="cdnfsd_transparentcdn_clientid"><?php esc_html_e( 'Client id:', 'w3-total-cache' ); ?></label></th>
41
+ <td>
42
+ <input id="cdnfsd_transparentcdn_clientid" class="w3tc-ignore-change"
43
+ <?php Util_Ui::sealing_disabled( 'cdnfsd.transparentcdn.client_id' ); ?> type="text"
44
+ name="cdnfsd__transparentcdn__client_id"
45
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.transparentcdn.client_id' ) ); ?>" size="60" />
46
+ </td>
47
+ </tr>
48
+ <tr>
49
+ <th style="width: 300px;"><label for="cdnfsd_transparentcdn_clientsecret"><?php esc_html_e( 'Client secret:', 'w3-total-cache' ); ?></label></th>
50
+ <td>
51
+ <input id="cdnfsd_transparentcdn_clientsecret" class="w3tc-ignore-change"
52
+ <?php Util_Ui::sealing_disabled( 'cdnfsd.transparentcdn.client_secret' ); ?> type="text"
53
+ name="cdnfsd__transparentcdn__client_secret"
54
+ value="<?php echo esc_attr( $config->get_string( 'cdnfsd.transparentcdn.client_secret' ) ); ?>" size="60" />
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <td>
59
+ <span id="transparentcdn_test" class="button {type: 'transparentcdn', nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}">
60
+ <?php esc_html_e( 'Test TransparentCDN', 'w3-total-cache' ); ?>
61
+ </span>
62
+ </td>
63
+ <td colspan="1">
64
+ <span id="tcdn_test_status" class="w3tc-status w3tc-process">
65
+ </span>
66
+ </td>
67
+ </tr>
68
+ </table>
69
  <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
70
  <?php Util_Ui::postbox_footer(); ?>
71
  </div>
Cli.php CHANGED
@@ -252,7 +252,7 @@ class W3TotalCache_Command extends \WP_CLI_Command {
252
  return;
253
  }
254
 
255
- echo $v . "\n";
256
  } elseif ( $op == 'set' ) {
257
  $type =( isset( $vars['type'] ) ? $vars['type'] : 'string' );
258
 
@@ -369,49 +369,6 @@ class W3TotalCache_Command extends \WP_CLI_Command {
369
 
370
  }
371
 
372
- /**
373
- * SNS/local file.php Tells opcache to compile files
374
- *
375
- * @param array $args
376
- */
377
- function opcache_flush( $args = array() ) {
378
- try {
379
- $method = array_shift( $args );
380
- if ( !in_array( $method, array( 'SNS', 'local' ) ) )
381
- \WP_CLI::error( $method . __( ' is not supported. Change to SNS or local to delete opcache files', 'w3-total-cache' ) );
382
-
383
- if ( $method == 'SNS' ) {
384
- $w3_cache = Dispatcher::component( 'CacheFlush' );
385
- $w3_cache->opcache_flush();
386
- } else {
387
- $url = WP_PLUGIN_URL . '/' . dirname( W3TC_FILE ) . '/pub/opcache.php';
388
- $path = parse_url( $url, PHP_URL_PATH );
389
- $post = array(
390
- 'method' => 'POST',
391
- 'timeout' => 45,
392
- 'redirection' => 5,
393
- 'httpversion' => '1.0',
394
- 'blocking' => true,
395
- 'body' => array(
396
- 'nonce' => wp_hash( $path ),
397
- 'command' => 'flush'
398
- ),
399
- );
400
- $result = wp_remote_post( $url, $post );
401
- if ( is_wp_error( $result ) ) {
402
- \WP_CLI::error( __( 'Files did not successfully delete with error %s', 'w3-total-cache' ), $result );
403
- } elseif ( $result['response']['code'] != '200' ) {
404
- \WP_CLI::error( __( 'Files did not successfully delete with message: ', 'w3-total-cache' ). $result['body'] );
405
- }
406
- }
407
- }
408
- catch ( \Exception $e ) {
409
- \WP_CLI::error( __( 'Files did not successfully delete with error %s', 'w3-total-cache' ), $e );
410
- }
411
- \WP_CLI::success( __( 'Files deleted successfully.', 'w3-total-cache' ) );
412
-
413
- }
414
-
415
  /**
416
  * Generally triggered from a cronjob, performs manual page cache Garbage collection
417
  */
252
  return;
253
  }
254
 
255
+ echo esc_html( $v ) . "\n";
256
  } elseif ( $op == 'set' ) {
257
  $type =( isset( $vars['type'] ) ? $vars['type'] : 'string' );
258
 
369
 
370
  }
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  /**
373
  * Generally triggered from a cronjob, performs manual page cache Garbage collection
374
  */
ConfigCompiler.php CHANGED
@@ -418,6 +418,8 @@ class ConfigCompiler {
418
  'fragmentcache', 'redis.persistent' );
419
  $this->_set_if_exists( $file_data, 'fragmentcache.redis.servers',
420
  'fragmentcache', 'redis.servers' );
 
 
421
  $this->_set_if_exists( $file_data, 'fragmentcache.redis.password',
422
  'fragmentcache', 'redis.password' );
423
  $this->_set_if_exists( $file_data, 'fragmentcache.redis.dbid',
418
  'fragmentcache', 'redis.persistent' );
419
  $this->_set_if_exists( $file_data, 'fragmentcache.redis.servers',
420
  'fragmentcache', 'redis.servers' );
421
+ $this->_set_if_exists( $file_data, 'fragmentcache.redis.verify_tls_certificates',
422
+ 'fragmentcache', 'redis.verify_tls_certificates' );
423
  $this->_set_if_exists( $file_data, 'fragmentcache.redis.password',
424
  'fragmentcache', 'redis.password' );
425
  $this->_set_if_exists( $file_data, 'fragmentcache.redis.dbid',
ConfigDbStorage.php CHANGED
@@ -223,7 +223,7 @@ class _WpdbEssentials {
223
  $this->last_error =
224
  'Connection failed with ' . $this->dbh->connect_errno . ' error code';
225
  if ( WP_DEBUG ) {
226
- echo $this->last_error;
227
  }
228
  }
229
  } else {
@@ -240,7 +240,7 @@ class _WpdbEssentials {
240
  $this->select( $this->dbname, $this->dbh );
241
  } else {
242
  if ( WP_DEBUG ) {
243
- echo 'Failed to connect to mysql server';
244
  }
245
  }
246
  }
@@ -256,7 +256,7 @@ class _WpdbEssentials {
256
  if ( ! $success ) {
257
  $this->ready = false;
258
  if ( WP_DEBUG ) {
259
- echo 'Failed to select database';
260
  }
261
  }
262
  }
@@ -335,7 +335,7 @@ class _WpdbEssentials {
335
 
336
  if ( $this->last_error ) {
337
  if ( WP_DEBUG ) {
338
- echo $this->last_error;
339
  }
340
  return false;
341
  }
223
  $this->last_error =
224
  'Connection failed with ' . $this->dbh->connect_errno . ' error code';
225
  if ( WP_DEBUG ) {
226
+ echo esc_html( $this->last_error );
227
  }
228
  }
229
  } else {
240
  $this->select( $this->dbname, $this->dbh );
241
  } else {
242
  if ( WP_DEBUG ) {
243
+ esc_html_e( 'Failed to connect to mysql server', 'w3-total-cache' );
244
  }
245
  }
246
  }
256
  if ( ! $success ) {
257
  $this->ready = false;
258
  if ( WP_DEBUG ) {
259
+ esc_html_e( 'Failed to select database', 'w3-total-cache' );
260
  }
261
  }
262
  }
335
 
336
  if ( $this->last_error ) {
337
  if ( WP_DEBUG ) {
338
+ echo esc_html( $this->last_error );
339
  }
340
  return false;
341
  }
ConfigKeys.php CHANGED
@@ -101,6 +101,10 @@ $keys = array(
101
  '127.0.0.1:6379'
102
  )
103
  ),
 
 
 
 
104
  'dbcache.redis.password' => array(
105
  'type' => 'string',
106
  'default' => ''
@@ -109,6 +113,18 @@ $keys = array(
109
  'type' => 'integer',
110
  'default' => 0
111
  ),
 
 
 
 
 
 
 
 
 
 
 
 
112
  'dbcache.use_filters' => array(
113
  'type' => 'boolean',
114
  'default' => false
@@ -298,6 +314,10 @@ $keys = array(
298
  '127.0.0.1:6379'
299
  )
300
  ),
 
 
 
 
301
  'objectcache.redis.password' => array(
302
  'type' => 'string',
303
  'default' => ''
@@ -306,6 +326,18 @@ $keys = array(
306
  'type' => 'integer',
307
  'default' => 0
308
  ),
 
 
 
 
 
 
 
 
 
 
 
 
309
  'objectcache.groups.global' => array(
310
  'type' => 'array',
311
  'default' => array(
@@ -414,6 +446,10 @@ $keys = array(
414
  '127.0.0.1:6379'
415
  )
416
  ),
 
 
 
 
417
  'pgcache.redis.password' => array(
418
  'type' => 'string',
419
  'default' => ''
@@ -422,6 +458,18 @@ $keys = array(
422
  'type' => 'integer',
423
  'default' => 0
424
  ),
 
 
 
 
 
 
 
 
 
 
 
 
425
  'pgcache.cache.query' => array(
426
  'type' => 'boolean',
427
  'default' => false
@@ -784,6 +832,10 @@ $keys = array(
784
  '127.0.0.1:6379'
785
  )
786
  ),
 
 
 
 
787
  'minify.redis.password' => array(
788
  'type' => 'string',
789
  'default' => ''
@@ -792,6 +844,18 @@ $keys = array(
792
  'type' => 'integer',
793
  'default' => 0
794
  ),
 
 
 
 
 
 
 
 
 
 
 
 
795
  'minify.rewrite' => array(
796
  'type' => 'boolean',
797
  'default' => true
@@ -1338,6 +1402,10 @@ $keys = array(
1338
  'type' => 'string',
1339
  'default' => 'auto'
1340
  ),
 
 
 
 
1341
  'cdn.cf2.key' => array(
1342
  'type' => 'string',
1343
  'default' => ''
@@ -2451,8 +2519,13 @@ $keys = array(
2451
  'default' => array(
2452
  'compression' => 'lossy',
2453
  'auto' => 'enabled',
 
2454
  ),
2455
  ),
 
 
 
 
2456
 
2457
  // extensions keys:
2458
  //
@@ -2544,5 +2617,9 @@ $overloading_keys_scope = array(
2544
  array(
2545
  'key' => 'varnish.configuration_overloaded',
2546
  'prefix' => 'varnish.'
2547
- )
 
 
 
 
2548
  );
101
  '127.0.0.1:6379'
102
  )
103
  ),
104
+ 'dbcache.redis.verify_tls_certificates' => array(
105
+ 'type' => 'boolean',
106
+ 'default' => true
107
+ ),
108
  'dbcache.redis.password' => array(
109
  'type' => 'string',
110
  'default' => ''
113
  'type' => 'integer',
114
  'default' => 0
115
  ),
116
+ 'dbcache.redis.timeout' => array(
117
+ 'type' => 'integer',
118
+ 'default' => 0
119
+ ),
120
+ 'dbcache.redis.retry_interval' => array(
121
+ 'type' => 'integer',
122
+ 'default' => 0
123
+ ),
124
+ 'dbcache.redis.read_timeout' => array(
125
+ 'type' => 'integer',
126
+ 'default' => 0
127
+ ),
128
  'dbcache.use_filters' => array(
129
  'type' => 'boolean',
130
  'default' => false
314
  '127.0.0.1:6379'
315
  )
316
  ),
317
+ 'objectcache.redis.verify_tls_certificates' => array(
318
+ 'type' => 'boolean',
319
+ 'default' => true
320
+ ),
321
  'objectcache.redis.password' => array(
322
  'type' => 'string',
323
  'default' => ''
326
  'type' => 'integer',
327
  'default' => 0
328
  ),
329
+ 'objectcache.redis.timeout' => array(
330
+ 'type' => 'integer',
331
+ 'default' => 0
332
+ ),
333
+ 'objectcache.redis.retry_interval' => array(
334
+ 'type' => 'integer',
335
+ 'default' => 0
336
+ ),
337
+ 'objectcache.redis.read_timeout' => array(
338
+ 'type' => 'integer',
339
+ 'default' => 0
340
+ ),
341
  'objectcache.groups.global' => array(
342
  'type' => 'array',
343
  'default' => array(
446
  '127.0.0.1:6379'
447
  )
448
  ),
449
+ 'pgcache.redis.verify_tls_certificates' => array(
450
+ 'type' => 'boolean',
451
+ 'default' => true
452
+ ),
453
  'pgcache.redis.password' => array(
454
  'type' => 'string',
455
  'default' => ''
458
  'type' => 'integer',
459
  'default' => 0
460
  ),
461
+ 'pgcache.redis.timeout' => array(
462
+ 'type' => 'integer',
463
+ 'default' => 0
464
+ ),
465
+ 'pgcache.redis.retry_interval' => array(
466
+ 'type' => 'integer',
467
+ 'default' => 0
468
+ ),
469
+ 'pgcache.redis.read_timeout' => array(
470
+ 'type' => 'integer',
471
+ 'default' => 0
472
+ ),
473
  'pgcache.cache.query' => array(
474
  'type' => 'boolean',
475
  'default' => false
832
  '127.0.0.1:6379'
833
  )
834
  ),
835
+ 'minify.redis.verify_tls_certificates' => array(
836
+ 'type' => 'boolean',
837
+ 'default' => true
838
+ ),
839
  'minify.redis.password' => array(
840
  'type' => 'string',
841
  'default' => ''
844
  'type' => 'integer',
845
  'default' => 0
846
  ),
847
+ 'minify.redis.timeout' => array(
848
+ 'type' => 'integer',
849
+ 'default' => 0
850
+ ),
851
+ 'minify.redis.retry_interval' => array(
852
+ 'type' => 'integer',
853
+ 'default' => 0
854
+ ),
855
+ 'minify.redis.read_timeout' => array(
856
+ 'type' => 'integer',
857
+ 'default' => 0
858
+ ),
859
  'minify.rewrite' => array(
860
  'type' => 'boolean',
861
  'default' => true
1402
  'type' => 'string',
1403
  'default' => 'auto'
1404
  ),
1405
+ 'cdn.cf.public_objects' => array(
1406
+ 'type' => 'string',
1407
+ 'default' => 'enabled'
1408
+ ),
1409
  'cdn.cf2.key' => array(
1410
  'type' => 'string',
1411
  'default' => ''
2519
  'default' => array(
2520
  'compression' => 'lossy',
2521
  'auto' => 'enabled',
2522
+ 'visibility' => 'never',
2523
  ),
2524
  ),
2525
+ 'imageservice.configuration_overloaded' => array(
2526
+ 'type' => 'boolean',
2527
+ 'default' => true,
2528
+ ),
2529
 
2530
  // extensions keys:
2531
  //
2617
  array(
2618
  'key' => 'varnish.configuration_overloaded',
2619
  'prefix' => 'varnish.'
2620
+ ),
2621
+ array(
2622
+ 'key' => 'imageservice.configuration_overloaded',
2623
+ 'prefix' => 'imageservice.'
2624
+ ),
2625
  );
DbCache_Core.php CHANGED
@@ -24,7 +24,11 @@ class DbCache_Core {
24
  case 'redis':
25
  $engineConfig = array(
26
  'servers' => $c->get_array( 'dbcache.redis.servers' ),
 
27
  'persistent' => $c->get_boolean( 'dbcache.redis.persistent' ),
 
 
 
28
  'dbid' => $c->get_integer( 'dbcache.redis.dbid' ),
29
  'password' => $c->get_string( 'dbcache.redis.password' )
30
  );
24
  case 'redis':
25
  $engineConfig = array(
26
  'servers' => $c->get_array( 'dbcache.redis.servers' ),
27
+ 'verify_tls_certificates' => $c->get_boolean( 'dbcache.redis.verify_tls_certificates' ),
28
  'persistent' => $c->get_boolean( 'dbcache.redis.persistent' ),
29
+ 'timeout' => $c->get_integer( 'dbcache.redis.timeout' ),
30
+ 'retry_interval' => $c->get_integer( 'dbcache.redis.retry_interval' ),
31
+ 'read_timeout' => $c->get_integer( 'dbcache.redis.read_timeout' ),
32
  'dbid' => $c->get_integer( 'dbcache.redis.dbid' ),
33
  'password' => $c->get_string( 'dbcache.redis.password' )
34
  );
DbCache_Environment.php CHANGED
@@ -107,22 +107,22 @@ class DbCache_Environment {
107
  if ( $script_data == @file_get_contents( $src ) )
108
  return;
109
  } else if ( get_transient( 'w3tc_remove_add_in_dbcache' ) == 'yes' ) {
110
- // user already manually asked to remove another plugin's add in,
111
- // we should try to apply ours
112
- // (in case of missing permissions deletion could fail)
113
- } else if ( !$this->db_check_old_add_in() ) {
114
-
115
-
116
- if ( isset( $_GET['page'] ) )
117
- $url = 'admin.php?page=' . $_GET['page'] . '&amp;';
118
- else
119
- $url = basename( Util_Environment::remove_query_all( $_SERVER['REQUEST_URI'] ) ) . '?page=w3tc_dashboard&amp;';
120
- $remove_url = Util_Ui::admin_url( $url . 'w3tc_default_remove_add_in=dbcache' );
121
- throw new Util_WpFile_FilesystemOperationException(
122
- sprintf( __( 'The Database add-in file db.php is not a W3 Total Cache drop-in.
123
- Remove it or disable Database Caching. %s', 'w3-total-cache' ),
124
- Util_Ui::button_link( __( 'Remove it for me', 'w3-total-cache' ), wp_nonce_url( $remove_url, 'w3tc' ) ) ) );
125
  }
 
 
 
 
 
 
126
  }
127
 
128
  Util_WpFile::copy_file( $src, $dst );
107
  if ( $script_data == @file_get_contents( $src ) )
108
  return;
109
  } else if ( get_transient( 'w3tc_remove_add_in_dbcache' ) == 'yes' ) {
110
+ // user already manually asked to remove another plugin's add in,
111
+ // we should try to apply ours
112
+ // (in case of missing permissions deletion could fail)
113
+ } else if ( !$this->db_check_old_add_in() ) {
114
+ $page_val = Util_Request::get_string( 'page' );
115
+ if ( isset( $page_val ) ) {
116
+ $url = 'admin.php?page=' . $page_val . '&amp;';
117
+ } else {
118
+ $url = basename( Util_Environment::remove_query_all( isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' ) ) . '?page=w3tc_dashboard&amp;';
 
 
 
 
 
 
119
  }
120
+ $remove_url = Util_Ui::admin_url( $url . 'w3tc_default_remove_add_in=dbcache' );
121
+ throw new Util_WpFile_FilesystemOperationException(
122
+ sprintf( __( 'The Database add-in file db.php is not a W3 Total Cache drop-in.
123
+ Remove it or disable Database Caching. %s', 'w3-total-cache' ),
124
+ Util_Ui::button_link( __( 'Remove it for me', 'w3-total-cache' ), wp_nonce_url( $remove_url, 'w3tc' ) ) ) );
125
+ }
126
  }
127
 
128
  Util_WpFile::copy_file( $src, $dst );
DbCache_WpdbInjection_QueryCaching.php CHANGED
@@ -1,8 +1,16 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  namespace W3TC;
3
 
4
  /**
5
- * class DbCache_WpdbInjection_QueryCaching
6
  */
7
  class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
8
  /**
@@ -192,24 +200,33 @@ class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
192
  $filter_data = apply_filters( 'w3tc_dbcache_cache_set', $filter_data );
193
  }
194
 
195
- $cache->set( md5( $filter_data['query'] ),
 
196
  $filter_data['content'],
197
  $filter_data['expiration'],
198
- $filter_data['group'] );
 
199
  }
200
  }
201
 
202
  if ( $this->debug ) {
203
- $this->log_query( array(
204
- date( 'r' ),
205
- strtr( $_SERVER['REQUEST_URI'], "<>\r\n", '.. ' ),
206
- strtr( $query, "<>\r\n", '.. ' ), // 'query'
207
- (int)($time_total * 1000000), // 'time_total' (microsecs)
208
- $reject_reason, // 'reason'
209
- $is_cache_hit, // 'cached'
210
- ( $data ? strlen( serialize( $data ) ) : 0 ), // 'data_size'
211
- strtr( $group, "<>\r\n", '.. ' ) // 'group'
212
- ) );
 
 
 
 
 
 
 
213
  }
214
 
215
  $this->time_total += $time_total;
@@ -350,7 +367,11 @@ class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
350
  case 'redis':
351
  $engineConfig = array(
352
  'servers' => $this->_config->get_array( 'dbcache.redis.servers' ),
 
353
  'persistent' => $this->_config->get_boolean( 'dbcache.redis.persistent' ),
 
 
 
354
  'dbid' => $this->_config->get_integer( 'dbcache.redis.dbid' ),
355
  'password' => $this->_config->get_string( 'dbcache.redis.password' )
356
  );
@@ -424,10 +445,13 @@ class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
424
  */
425
  $ajax_skip = false;
426
  if ( defined( 'DOING_AJAX' ) ) {
427
- // wp_admin is always defined for ajax requests, check by referrer
428
- if ( isset( $_SERVER['HTTP_REFERER'] ) &&
429
- strpos( $_SERVER['HTTP_REFERER'], '/wp-admin/' ) === false )
 
 
430
  $ajax_skip = true;
 
431
  }
432
 
433
  /**
@@ -531,11 +555,14 @@ class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
531
  function _check_request_uri() {
532
  $auto_reject_uri = array(
533
  'wp-login',
534
- 'wp-register'
535
  );
536
 
 
 
 
537
  foreach ( $auto_reject_uri as $uri ) {
538
- if ( strstr( $_SERVER['REQUEST_URI'], $uri ) !== false ) {
539
  return false;
540
  }
541
  }
@@ -545,7 +572,7 @@ class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
545
 
546
  foreach ( $reject_uri as $expr ) {
547
  $expr = trim( $expr );
548
- if ( $expr != '' && preg_match( '~' . $expr . '~i', $_SERVER['REQUEST_URI'] ) ) {
549
  return false;
550
  }
551
  }
1
  <?php
2
+ /**
3
+ * File: DbCache_WpdbInjection_QueryCaching.php
4
+ *
5
+ * @package W3TC
6
+ *
7
+ * phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
8
+ */
9
+
10
  namespace W3TC;
11
 
12
  /**
13
+ * Class: DbCache_WpdbInjection_QueryCaching
14
  */
15
  class DbCache_WpdbInjection_QueryCaching extends DbCache_WpdbInjection {
16
  /**
200
  $filter_data = apply_filters( 'w3tc_dbcache_cache_set', $filter_data );
201
  }
202
 
203
+ $cache->set(
204
+ md5( $filter_data['query'] ),
205
  $filter_data['content'],
206
  $filter_data['expiration'],
207
+ $filter_data['group']
208
+ );
209
  }
210
  }
211
 
212
  if ( $this->debug ) {
213
+ $this->log_query(
214
+ array(
215
+ gmdate( 'r' ),
216
+ strtr(
217
+ isset( $_SERVER['REQUEST_URI'] ) ?
218
+ esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '',
219
+ "<>\r\n",
220
+ '.. '
221
+ ),
222
+ strtr( $query, "<>\r\n", '.. ' ), // 'query'.
223
+ (int) ( $time_total * 1000000 ), // 'time_total' (microsecs).
224
+ $reject_reason, // 'reason'.
225
+ $is_cache_hit, // 'cached'.
226
+ ( $data ? strlen( serialize( $data ) ) : 0 ), // 'data_size'.
227
+ strtr( $group, "<>\r\n", '.. ' ), // 'group'.
228
+ )
229
+ );
230
  }
231
 
232
  $this->time_total += $time_total;
367
  case 'redis':
368
  $engineConfig = array(
369
  'servers' => $this->_config->get_array( 'dbcache.redis.servers' ),
370
+ 'verify_tls_certificates' => $this->_config->get_boolean( 'dbcache.redis.verify_tls_certificates' ),
371
  'persistent' => $this->_config->get_boolean( 'dbcache.redis.persistent' ),
372
+ 'timeout' => $this->_config->get_integer( 'dbcache.redis.timeout' ),
373
+ 'retry_interval' => $this->_config->get_integer( 'dbcache.redis.retry_interval' ),
374
+ 'read_timeout' => $this->_config->get_integer( 'dbcache.redis.read_timeout' ),
375
  'dbid' => $this->_config->get_integer( 'dbcache.redis.dbid' ),
376
  'password' => $this->_config->get_string( 'dbcache.redis.password' )
377
  );
445
  */
446
  $ajax_skip = false;
447
  if ( defined( 'DOING_AJAX' ) ) {
448
+ $http_referer = isset( $_SERVER['HTTP_REFERER'] ) ?
449
+ filter_var( wp_unslash( $_SERVER['HTTP_REFERER'] ), FILTER_SANITIZE_URL ) : '';
450
+
451
+ // wp_admin is always defined for ajax requests, check by referrer.
452
+ if ( strpos( $http_referer, '/wp-admin/' ) === false ) {
453
  $ajax_skip = true;
454
+ }
455
  }
456
 
457
  /**
555
  function _check_request_uri() {
556
  $auto_reject_uri = array(
557
  'wp-login',
558
+ 'wp-register',
559
  );
560
 
561
+ $request_uri = isset( $_SERVER['REQUEST_URI'] ) ?
562
+ filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : '';
563
+
564
  foreach ( $auto_reject_uri as $uri ) {
565
+ if ( strstr( $request_uri, $uri ) !== false ) {
566
  return false;
567
  }
568
  }
572
 
573
  foreach ( $reject_uri as $expr ) {
574
  $expr = trim( $expr );
575
+ if ( '' !== $expr && preg_match( '~' . $expr . '~i', $request_uri ) ) {
576
  return false;
577
  }
578
  }
DbCache_WpdbLegacy.php CHANGED
@@ -67,9 +67,12 @@ class DbCache_WpdbLegacy extends DbCache_WpdbBase {
67
 
68
  $request_time_total = microtime( true ) - $this->request_time_start;
69
 
70
- $data = sprintf( "\n[%s] [%s] [%s]\n", date( 'r' ),
71
- $_SERVER['REQUEST_URI'], round( $request_time_total, 4 ) ) .
72
- implode( "\n", $strings ) . "\n";
 
 
 
73
  $data = strtr( $data, '<>', '..' );
74
 
75
  $filename = Util_Debug::log_filename( 'dbcache' );
67
 
68
  $request_time_total = microtime( true ) - $this->request_time_start;
69
 
70
+ $data = sprintf(
71
+ "\n[%s] [%s] [%s]\n",
72
+ gmdate( 'r' ),
73
+ isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '',
74
+ round( $request_time_total, 4 )
75
+ ) . implode( "\n", $strings ) . "\n";
76
  $data = strtr( $data, '<>', '..' );
77
 
78
  $filename = Util_Debug::log_filename( 'dbcache' );
DbCache_WpdbNew.php CHANGED
@@ -67,9 +67,12 @@ class DbCache_WpdbNew extends DbCache_WpdbBase {
67
 
68
  $request_time_total = microtime( true ) - $this->request_time_start;
69
 
70
- $data = sprintf( "\n[%s] [%s] [%s]\n", date( 'r' ),
71
- $_SERVER['REQUEST_URI'], round( $request_time_total, 4 ) ) .
72
- implode( "\n", $strings ) . "\n";
 
 
 
73
  $data = strtr( $data, '<>', '..' );
74
 
75
  $filename = Util_Debug::log_filename( 'dbcache' );
67
 
68
  $request_time_total = microtime( true ) - $this->request_time_start;
69
 
70
+ $data = sprintf(
71
+ "\n[%s] [%s] [%s]\n",
72
+ gmdate( 'r' ),
73
+ isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '',
74
+ round( $request_time_total, 4 )
75
+ ) . implode( "\n", $strings ) . "\n";
76
  $data = strtr( $data, '<>', '..' );
77
 
78
  $filename = Util_Debug::log_filename( 'dbcache' );
Enterprise_CacheFlush_MakeSnsEvent.php CHANGED
@@ -193,7 +193,7 @@ class Enterprise_CacheFlush_MakeSnsEvent extends Enterprise_SnsBase {
193
  $message = array();
194
  $message['actions'] = $this->messages;
195
  $message['blog_id'] = Util_Environment::blog_id();
196
- $message['host'] = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : null;
197
  $message['hostname'] = @gethostname();
198
  $v = json_encode( $message );
199
 
@@ -206,7 +206,7 @@ class Enterprise_CacheFlush_MakeSnsEvent extends Enterprise_SnsBase {
206
  $this->_log( $origin . ' sending message ' . $v );
207
  $this->_log( 'Host: ' . $message['host'] );
208
  if ( isset( $_SERVER['REQUEST_URI'] ) )
209
- $this->_log( 'URL: ' . $_SERVER['REQUEST_URI'] );
210
  if ( function_exists( 'current_filter' ) )
211
  $this->_log( 'Current WP hook: ' . current_filter() );
212
 
193
  $message = array();
194
  $message['actions'] = $this->messages;
195
  $message['blog_id'] = Util_Environment::blog_id();
196
+ $message['host'] = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : null;
197
  $message['hostname'] = @gethostname();
198
  $v = json_encode( $message );
199
 
206
  $this->_log( $origin . ' sending message ' . $v );
207
  $this->_log( 'Host: ' . $message['host'] );
208
  if ( isset( $_SERVER['REQUEST_URI'] ) )
209
+ $this->_log( 'URL: ' . sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
210
  if ( function_exists( 'current_filter' ) )
211
  $this->_log( 'Current WP hook: ' . current_filter() );
212
 
Enterprise_Dbcache_WpdbInjection_Cluster.php CHANGED
@@ -122,11 +122,13 @@ class Enterprise_Dbcache_WpdbInjection_Cluster extends DbCache_WpdbInjection {
122
  global $wpdb_cluster;
123
  $wpdb_cluster = $this;
124
 
125
- if ( isset( $GLOBALS['w3tc_dbcluster_config'] ) ) {
126
- $this->apply_configuration( $GLOBALS['w3tc_dbcluster_config'] );
127
- } elseif ( file_exists( WP_CONTENT_DIR . '/db-cluster-config.php' ) ) {
128
  // The config file resides in WP_CONTENT_DIR
129
  require WP_CONTENT_DIR . '/db-cluster-config.php';
 
 
 
 
130
  } else {
131
  $this->_reject_reason = 'w3tc dbcluster configuration not found, ' .
132
  'using single-server configuration';
@@ -454,21 +456,25 @@ class Enterprise_Dbcache_WpdbInjection_Cluster extends DbCache_WpdbInjection {
454
  * @return boolean
455
  */
456
  function _is_current_zone( $zone ) {
457
- // obsolete
 
458
  if ( isset( $zone['SERVER_NAME'] ) ) {
459
- if ( $_SERVER['SERVER_NAME'] == $zone['SERVER_NAME'] )
460
  return true;
 
461
  }
462
 
463
  if ( isset( $zone['server_names'] ) ) {
464
- if ( !is_array( $zone['server_names'] ) )
465
  die( 'server_names must be defined as array' );
466
-
467
- foreach ( $zone['server_names'] as $server_name ) {
468
- if ( $server_name == '*' )
469
  return true;
470
- if ( $_SERVER['SERVER_NAME'] == $server_name )
 
471
  return true;
 
472
  }
473
  }
474
 
@@ -555,7 +561,7 @@ class Enterprise_Dbcache_WpdbInjection_Cluster extends DbCache_WpdbInjection {
555
  $this->wpdb_mixin->last_query = $query;
556
 
557
  if ( preg_match( '/^\s*SELECT\s+FOUND_ROWS(\s*)/i', $query )
558
- && is_resource( $this->wpdb_mixin->_last_found_rows_result ) ) {
559
  $this->wpdb_mixin->result = $this->wpdb_mixin->_last_found_rows_result;
560
  $elapsed = 0;
561
  } else {
@@ -870,9 +876,9 @@ class Enterprise_Dbcache_WpdbInjection_Cluster extends DbCache_WpdbInjection {
870
  if ( !mysqli_select_db( $this->wpdb_mixin->dbh, DB_NAME ) )
871
  return $this->wpdb_mixin->bail( "We were unable to select the database." );
872
  if ( !empty( $this->wpdb_mixin->charset ) ) {
873
- $collation_query = "SET NAMES '$this->wpdb_mixin->charset'";
874
  if ( !empty( $this->wpdb_mixin->collate ) )
875
- $collation_query .= " COLLATE '$this->wpdb_mixin->collate'";
876
  mysqli_query( $this->wpdb_mixin->dbh, $collation_query );
877
  }
878
 
122
  global $wpdb_cluster;
123
  $wpdb_cluster = $this;
124
 
125
+ if ( !isset( $GLOBALS['w3tc_dbcluster_config'] ) && file_exists( WP_CONTENT_DIR . '/db-cluster-config.php' ) ) {
 
 
126
  // The config file resides in WP_CONTENT_DIR
127
  require WP_CONTENT_DIR . '/db-cluster-config.php';
128
+ }
129
+
130
+ if ( isset( $GLOBALS['w3tc_dbcluster_config'] ) ) {
131
+ $this->apply_configuration( $GLOBALS['w3tc_dbcluster_config'] );
132
  } else {
133
  $this->_reject_reason = 'w3tc dbcluster configuration not found, ' .
134
  'using single-server configuration';
456
  * @return boolean
457
  */
458
  function _is_current_zone( $zone ) {
459
+ $server_name = isset( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ) : '';
460
+ // obsolete.
461
  if ( isset( $zone['SERVER_NAME'] ) ) {
462
+ if ( $server_name === $zone['SERVER_NAME'] ) {
463
  return true;
464
+ }
465
  }
466
 
467
  if ( isset( $zone['server_names'] ) ) {
468
+ if ( ! is_array( $zone['server_names'] ) ) {
469
  die( 'server_names must be defined as array' );
470
+ }
471
+ foreach ( $zone['server_names'] as $zone_server_name ) {
472
+ if ( '*' === $zone_server_name ) {
473
  return true;
474
+ }
475
+ if ( $server_name === $zone_server_name ) {
476
  return true;
477
+ }
478
  }
479
  }
480
 
561
  $this->wpdb_mixin->last_query = $query;
562
 
563
  if ( preg_match( '/^\s*SELECT\s+FOUND_ROWS(\s*)/i', $query )
564
+ && is_object( $this->wpdb_mixin->_last_found_rows_result ) ) {
565
  $this->wpdb_mixin->result = $this->wpdb_mixin->_last_found_rows_result;
566
  $elapsed = 0;
567
  } else {
876
  if ( !mysqli_select_db( $this->wpdb_mixin->dbh, DB_NAME ) )
877
  return $this->wpdb_mixin->bail( "We were unable to select the database." );
878
  if ( !empty( $this->wpdb_mixin->charset ) ) {
879
+ $collation_query = "SET NAMES '{$this->wpdb_mixin->charset}'";
880
  if ( !empty( $this->wpdb_mixin->collate ) )
881
+ $collation_query .= " COLLATE '{$this->wpdb_mixin->collate}'";
882
  mysqli_query( $this->wpdb_mixin->dbh, $collation_query );
883
  }
884
 
Extension_Amp_Page_View.php CHANGED
@@ -1,33 +1,36 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
-
8
  ?>
9
  <form action="admin.php?page=w3tc_extensions&amp;extension=amp&amp;action=view" method="post">
10
  <div class="metabox-holder">
11
- <?php Util_Ui::postbox_header( __( 'Configuration', 'w3-total-cache' ), '', '' ) ?>
12
  <table class="form-table">
13
  <?php
14
- Util_Ui::config_item( array(
15
- 'key' => array( 'amp', 'url_type' ),
16
- 'label' => __( 'AMP URL Type:', 'w3-total-cache' ),
17
- 'control' => 'radiogroup',
 
18
  'radiogroup_values' => array(
19
- 'tag' => 'tag',
20
- 'querystring' => 'query string'
 
 
 
 
21
  ),
22
- 'description' =>
23
- 'If AMP page URLs are tag based (/my-page/amp/) or query string based (/my-page?amp)'
24
  )
25
  );
26
- Util_Ui::config_item( array(
27
- 'key' => array( 'amp', 'url_postfix' ),
28
- 'label' => __( 'AMP URL Postfix:', 'w3-total-cache' ),
29
- 'control' => 'textbox',
30
- 'description' => 'Postfix used'
 
31
  )
32
  );
33
  ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
 
7
  ?>
8
  <form action="admin.php?page=w3tc_extensions&amp;extension=amp&amp;action=view" method="post">
9
  <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', '' ); ?>
11
  <table class="form-table">
12
  <?php
13
+ Util_Ui::config_item(
14
+ array(
15
+ 'key' => array( 'amp', 'url_type' ),
16
+ 'label' => esc_html__( 'AMP URL Type:', 'w3-total-cache' ),
17
+ 'control' => 'radiogroup',
18
  'radiogroup_values' => array(
19
+ 'tag' => 'tag',
20
+ 'querystring' => 'query string',
21
+ ),
22
+ 'description' => esc_html__(
23
+ 'If AMP page URLs are tag based (/my-page/amp/) or query string based (/my-page?amp)',
24
+ 'w3-total-cache'
25
  ),
 
 
26
  )
27
  );
28
+ Util_Ui::config_item(
29
+ array(
30
+ 'key' => array( 'amp', 'url_postfix' ),
31
+ 'label' => esc_html__( 'AMP URL Postfix:', 'w3-total-cache' ),
32
+ 'control' => 'textbox',
33
+ 'description' => 'Postfix used',
34
  )
35
  );
36
  ?>
Extension_CloudFlare_Api.php CHANGED
@@ -116,6 +116,12 @@ class Extension_CloudFlare_Api {
116
  json_encode( array( 'value' => $value ) ) );
117
  }
118
 
 
 
 
 
 
 
119
  public function analytics_dashboard( $start, $end, $type = 'day' ) {
120
  $dataset = 'httpRequests1dGroups';
121
  $datetime_filter = 'date';
@@ -165,18 +171,22 @@ class Extension_CloudFlare_Api {
165
  '{"purge_everything":true}' );
166
  }
167
 
 
 
 
 
 
 
168
  private function _wp_remote_request( $method, $url, $body = array() ) {
169
  if ( empty( $this->_email ) || empty( $this->_key ) ) {
170
  throw new \Exception('Not authenticated');
171
  }
172
 
 
 
173
  $result = wp_remote_request( $url, array(
174
  'method' => $method,
175
- 'headers' => array(
176
- 'Content-Type' => 'application/json',
177
- 'X-Auth-Key' => $this->_key,
178
- 'X-Auth-Email' => $this->_email
179
- ),
180
  'timeout' => $this->_timelimit_api_request,
181
  'body' => $body
182
  ) );
@@ -192,7 +202,7 @@ class Extension_CloudFlare_Api {
192
  str_replace( '<', '.', str_replace( '>', '.', $result['body'] ) ) );
193
  }
194
 
195
- if ( !isset( $response_json['success'] ) ) {
196
  $errors = array();
197
 
198
  if ( isset( $response_json['errors'] ) ) {
@@ -215,18 +225,22 @@ class Extension_CloudFlare_Api {
215
  return array();
216
  }
217
 
 
 
 
 
 
 
218
  private function _wp_remote_request_with_meta( $method, $url, $body = array() ) {
219
  if ( empty( $this->_email ) || empty( $this->_key ) ) {
220
  throw new \Exception('Not authenticated');
221
  }
222
 
 
 
223
  $result = wp_remote_request( $url, array(
224
  'method' => $method,
225
- 'headers' => array(
226
- 'Content-Type' => 'application/json',
227
- 'X-Auth-Key' => $this->_key,
228
- 'X-Auth-Email' => $this->_email
229
- ),
230
  'timeout' => $this->_timelimit_api_request,
231
  'body' => $body
232
  ) );
@@ -263,20 +277,24 @@ class Extension_CloudFlare_Api {
263
  return array();
264
  }
265
 
 
 
 
 
 
 
266
  private function _wp_remote_request_graphql( $method, $url, $body ) {
267
  if ( empty( $this->_email ) || empty( $this->_key ) ) {
268
  throw new \Exception('Not authenticated');
269
  }
270
 
 
 
271
  $body = preg_replace( '/\s\s+/', ' ', $body );
272
 
273
  $result = wp_remote_request( $url, array(
274
  'method' => $method,
275
- 'headers' => array(
276
- 'Content-Type' => 'application/json',
277
- 'X-Auth-Key' => $this->_key,
278
- 'X-Auth-Email' => $this->_email
279
- ),
280
  'timeout' => $this->_timelimit_api_request,
281
  'body' => $body
282
  ) );
@@ -312,4 +330,41 @@ class Extension_CloudFlare_Api {
312
 
313
  return array();
314
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  }
116
  json_encode( array( 'value' => $value ) ) );
117
  }
118
 
119
+ /**
120
+ * Prepares the analytics dashboard widget query to be performed via the CF GraphQL API
121
+ *
122
+ * @throws Exception
123
+ * @return array
124
+ */
125
  public function analytics_dashboard( $start, $end, $type = 'day' ) {
126
  $dataset = 'httpRequests1dGroups';
127
  $datetime_filter = 'date';
171
  '{"purge_everything":true}' );
172
  }
173
 
174
+ /**
175
+ * Performs the CF API request
176
+ *
177
+ * @throws Exception
178
+ * @return array
179
+ */
180
  private function _wp_remote_request( $method, $url, $body = array() ) {
181
  if ( empty( $this->_email ) || empty( $this->_key ) ) {
182
  throw new \Exception('Not authenticated');
183
  }
184
 
185
+ $headers = $this->_generate_wp_remote_request_headers();
186
+
187
  $result = wp_remote_request( $url, array(
188
  'method' => $method,
189
+ 'headers' => $headers,
 
 
 
 
190
  'timeout' => $this->_timelimit_api_request,
191
  'body' => $body
192
  ) );
202
  str_replace( '<', '.', str_replace( '>', '.', $result['body'] ) ) );
203
  }
204
 
205
+ if ( !$response_json['success'] ) {
206
  $errors = array();
207
 
208
  if ( isset( $response_json['errors'] ) ) {
225
  return array();
226
  }
227
 
228
+ /**
229
+ * Performs the CF API request with meta
230
+ *
231
+ * @throws Exception
232
+ * @return array
233
+ */
234
  private function _wp_remote_request_with_meta( $method, $url, $body = array() ) {
235
  if ( empty( $this->_email ) || empty( $this->_key ) ) {
236
  throw new \Exception('Not authenticated');
237
  }
238
 
239
+ $headers = $this->_generate_wp_remote_request_headers();
240
+
241
  $result = wp_remote_request( $url, array(
242
  'method' => $method,
243
+ 'headers' => $headers,
 
 
 
 
244
  'timeout' => $this->_timelimit_api_request,
245
  'body' => $body
246
  ) );
277
  return array();
278
  }
279
 
280
+ /**
281
+ * Performs the CF GraphQL API request
282
+ *
283
+ * @throws Exception
284
+ * @return array
285
+ */
286
  private function _wp_remote_request_graphql( $method, $url, $body ) {
287
  if ( empty( $this->_email ) || empty( $this->_key ) ) {
288
  throw new \Exception('Not authenticated');
289
  }
290
 
291
+ $headers = $this->_generate_wp_remote_request_headers();
292
+
293
  $body = preg_replace( '/\s\s+/', ' ', $body );
294
 
295
  $result = wp_remote_request( $url, array(
296
  'method' => $method,
297
+ 'headers' => $headers,
 
 
 
 
298
  'timeout' => $this->_timelimit_api_request,
299
  'body' => $body
300
  ) );
330
 
331
  return array();
332
  }
333
+
334
+ /**
335
+ * Generates the appropriate request headers for CF API requests based on token or global key presence
336
+ *
337
+ * @since 2.2.1
338
+ *
339
+ * @throws Exception
340
+ * @return array
341
+ */
342
+ private function _generate_wp_remote_request_headers() {
343
+ if ( empty( $this->_email ) || empty( $this->_key ) ) {
344
+ throw new \Exception('Missing authentication email and/or API token / global key');
345
+ }
346
+
347
+ $headers = array();
348
+
349
+ // CF API Token
350
+ if( strlen( $this->_key ) == 40 ) {
351
+ $headers = array(
352
+ 'Content-Type' => 'application/json',
353
+ 'Authorization' => 'Bearer ' . $this->_key
354
+ );
355
+ }
356
+ // CF Legacy API Global Key
357
+ else if ( strlen( $this->_key ) == 37 ) {
358
+ $headers = array(
359
+ 'Content-Type' => 'application/json',
360
+ 'X-Auth-Key' => $this->_key,
361
+ 'X-Auth-Email' => $this->_email
362
+ );
363
+ }
364
+ else {
365
+ throw new \Exception('Improper API token / global key length');
366
+ }
367
+
368
+ return $headers;
369
+ }
370
  }
Extension_CloudFlare_Cdn_Page_View.php CHANGED
@@ -1,31 +1,27 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
9
- <div class="metabox-holder">
10
- <?php Util_Ui::postbox_header( __( 'Configuration: Full-Site Delivery', 'w3-total-cache' ),
11
- '', 'configuration' ); ?>
12
- <table class="form-table">
13
  <tr>
14
  <th style="width: 300px;">
15
  <label>
16
- <?php
17
- _e( 'Configuration:',
18
- 'w3-total-cache' );
19
- ?>
20
  </label>
21
  </th>
22
  <td>
23
  <a href="admin.php?page=w3tc_extensions&extension=cloudflare&action=view">Open Configuration Page</a>
24
  </td>
25
  </tr>
26
- </table>
27
 
28
- <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
29
- <?php Util_Ui::postbox_footer(); ?>
30
- </div>
31
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
9
+ <div class="metabox-holder">
10
+ <?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
11
+ <table class="form-table">
 
12
  <tr>
13
  <th style="width: 300px;">
14
  <label>
15
+ <?php esc_html_e( 'Configuration:', 'w3-total-cache' ); ?>
 
 
 
16
  </label>
17
  </th>
18
  <td>
19
  <a href="admin.php?page=w3tc_extensions&extension=cloudflare&action=view">Open Configuration Page</a>
20
  </td>
21
  </tr>
22
+ </table>
23
 
24
+ <?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
25
+ <?php Util_Ui::postbox_footer(); ?>
26
+ </div>
27
  </form>
Extension_CloudFlare_GeneralPage_View.php CHANGED
@@ -1,46 +1,43 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
- ?>
8
- <?php Util_Ui::postbox_header( __( 'Network Performance &amp; Security powered by CloudFlare', 'w3-total-cache' ), '', 'cloudflare' ); ?>
9
- <?php
10
- Util_Ui::config_overloading_button( array(
11
- 'key' => 'cloudflare.configuration_overloaded'
12
- ) );
13
  ?>
 
 
14
  <p>
15
- <?php _e( 'CloudFlare protects and accelerates websites.', 'w3-total-cache' ) ?>
16
  </p>
17
 
18
  <table class="form-table">
19
- <?php
20
- Util_Ui::config_item( array(
21
- 'key' => array( 'cloudflare', 'widget_cache_mins' ),
22
- 'label' => __( 'Cache time:', 'w3-total-cache' ),
23
- 'control' => 'textbox',
24
- 'description' =>
25
- 'How many minutes data retrieved from CloudFlare ' .
26
- 'should be stored. Minimum is 1 minute.'
27
- ) );
28
 
29
- Util_Ui::config_item( array(
30
- 'key' => array( 'cloudflare', 'pagecache' ),
31
- 'label' => __( 'Page Caching:', 'w3-total-cache' ),
32
- 'control' => 'checkbox',
33
- 'checkbox_label' => 'Flush CloudFlare on Post Modifications',
34
- 'description' =>
35
- 'Enable when you have html pages cached on CloudFlare level.'
36
- ) );
37
- ?>
 
38
  </table>
39
 
40
  <?php
41
- Util_Ui::button_config_save( 'general_cloudflare',
42
- '<input type="submit" name="w3tc_cloudflare_flush" value="' .
43
- __( 'Empty cache', 'w3-total-cache' ) . '"' .
44
- ' class="button" />' );
45
  ?>
46
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
 
 
 
 
 
 
7
  ?>
8
+ <?php Util_Ui::postbox_header( esc_html__( 'Network Performance &amp; Security powered by CloudFlare', 'w3-total-cache' ), '', 'cloudflare' ); ?>
9
+ <?php Util_Ui::config_overloading_button( array( 'key' => 'cloudflare.configuration_overloaded' ) ); ?>
10
  <p>
11
+ <?php esc_html_e( 'CloudFlare protects and accelerates websites.', 'w3-total-cache' ); ?>
12
  </p>
13
 
14
  <table class="form-table">
15
+ <?php
16
+ Util_Ui::config_item(
17
+ array(
18
+ 'key' => array( 'cloudflare', 'widget_cache_mins' ),
19
+ 'label' => esc_html__( 'Cache time:', 'w3-total-cache' ),
20
+ 'control' => 'textbox',
21
+ 'description' => esc_html__( 'How many minutes data retrieved from CloudFlare should be stored. Minimum is 1 minute.', 'w3-total-cache' ),
22
+ )
23
+ );
24
 
25
+ Util_Ui::config_item(
26
+ array(
27
+ 'key' => array( 'cloudflare', 'pagecache' ),
28
+ 'label' => esc_html__( 'Page Caching:', 'w3-total-cache' ),
29
+ 'control' => 'checkbox',
30
+ 'checkbox_label' => esc_html__( 'Flush CloudFlare on Post Modifications', 'w3-total-cache' ),
31
+ 'description' => esc_html__( 'Enable when you have html pages cached on CloudFlare level.', 'w3-total-cache' ),
32
+ )
33
+ );
34
+ ?>
35
  </table>
36
 
37
  <?php
38
+ Util_Ui::button_config_save(
39
+ 'general_cloudflare',
40
+ '<input type="submit" name="w3tc_cloudflare_flush" value="' . esc_attr__( 'Empty cache', 'w3-total-cache' ) . '" class="button" />'
41
+ );
42
  ?>
43
  <?php Util_Ui::postbox_footer(); ?>
Extension_CloudFlare_Page.php CHANGED
@@ -4,9 +4,9 @@ namespace W3TC;
4
  class Extension_CloudFlare_Page {
5
  static public function admin_print_scripts_w3tc_extensions() {
6
  if ( ( isset( $_REQUEST['extension'] ) &&
7
- $_REQUEST['extension'] == 'cloudflare' ) ||
8
  ( isset( $_REQUEST['page'] ) &&
9
- $_REQUEST['page'] == 'w3tc_cdnfsd' ) ) {
10
  wp_enqueue_script( 'w3tc_extension_cloudflare',
11
  plugins_url( 'Extension_CloudFlare_Page_View.js', W3TC_FILE ),
12
  array( 'jquery' ), '1.0' );
@@ -120,11 +120,20 @@ class Extension_CloudFlare_Page {
120
  $b1_id = 'w3tc_cloudflare_save_' . $id;
121
 
122
  echo '<p class="submit">';
123
- echo Util_Ui::nonce_field( 'w3tc' );
124
- echo '<input type="submit" id="' . $b1_id .
 
 
 
 
 
 
 
 
 
125
  '" name="w3tc_cloudflare_save_settings" ' .
126
- ' class="w3tc-button-save button-primary" '.
127
- ' value="' . __( 'Save CloudFlare settings', 'w3-total-cache' ) .
128
  '" />';
129
  echo '</p>';
130
  }
4
  class Extension_CloudFlare_Page {
5
  static public function admin_print_scripts_w3tc_extensions() {
6
  if ( ( isset( $_REQUEST['extension'] ) &&
7
+ Util_Request::get_string( 'extension' ) == 'cloudflare' ) ||
8
  ( isset( $_REQUEST['page'] ) &&
9
+ Util_Request::get_string( 'page' ) == 'w3tc_cdnfsd' ) ) {
10
  wp_enqueue_script( 'w3tc_extension_cloudflare',
11
  plugins_url( 'Extension_CloudFlare_Page_View.js', W3TC_FILE ),
12
  array( 'jquery' ), '1.0' );
120
  $b1_id = 'w3tc_cloudflare_save_' . $id;
121
 
122
  echo '<p class="submit">';
123
+ echo wp_kses(
124
+ Util_Ui::nonce_field( 'w3tc' ),
125
+ array(
126
+ 'input' => array(
127
+ 'type' => array(),
128
+ 'name' => array(),
129
+ 'value' => array(),
130
+ ),
131
+ )
132
+ );
133
+ echo '<input type="submit" id="' . esc_attr( $b1_id ) .
134
  '" name="w3tc_cloudflare_save_settings" ' .
135
+ ' class="w3tc-button-save button-primary" ' .
136
+ ' value="' . esc_attr( __( 'Save CloudFlare settings', 'w3-total-cache' ) ) .
137
  '" />';
138
  echo '</p>';
139
  }
Extension_CloudFlare_Page_View.php CHANGED
@@ -1,464 +1,861 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <p id="w3tc-options-menu">
8
- Jump to:
9
- <a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
10
- <a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a> |
11
- <a href="#credentials"><?php _e( 'Credentials', 'w3-total-cache' ); ?></a> |
12
- <a href="#general"><?php _e( 'General', 'w3-total-cache' ); ?></a> |
13
- <a href="#info"><?php _e( 'Information', 'w3-total-cache' ); ?></a>
14
  </p>
15
  <p>
16
- CloudFlare extension is currently <?php
17
- if ( $config->is_extension_active_frontend( 'cloudflare' ) )
18
- echo '<span class="w3tc-enabled">enabled</span>';
19
- else
20
- echo '<span class="w3tc-disabled">disabled</span>';
21
- ?>.
 
 
 
22
  <p>
23
 
24
  <form action="admin.php?page=w3tc_extensions&amp;extension=cloudflare&amp;action=view" method="post">
25
- <p>
26
- <?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
27
- <input type="submit" name="w3tc_cloudflare_flush" value="<?php _e( 'Purge CloudFlare cache', 'w3-total-cache' ) ?>" class="button" />
28
- <?php _e( 'if needed.', 'w3-total-cache' ) ?>
29
- </p>
 
 
 
 
 
 
 
 
 
 
 
30
  </form>
31
 
32
  <form action="admin.php?page=w3tc_extensions&amp;extension=cloudflare&amp;action=view" method="post">
33
- <div class="metabox-holder">
34
- <?php Util_Ui::postbox_header( __( 'Credentials', 'w3-total-cache' ), '', 'credentials' ); ?>
35
- <table class="form-table">
36
  <tr>
37
  <th style="width: 300px;">
38
  <label>
39
- <?php
40
- _e( 'Specify account credentials:',
41
- 'w3-total-cache' );
42
- ?>
43
  </label>
44
  </th>
45
  <td>
46
- <?php if ( $state != 'not_configured' ): ?>
47
  <input class="w3tc_extension_cloudflare_authorize button-primary"
48
  type="button"
49
- value="<?php _e( 'Reauthorize', 'w3-total-cache' ); ?>"
50
  />
51
- <?php else: ?>
52
  <input class="w3tc_extension_cloudflare_authorize button-primary"
53
  type="button"
54
- value="<?php _e( 'Authorize', 'w3-total-cache' ); ?>"
55
  />
56
  <?php endif ?>
57
  </td>
58
  </tr>
59
 
60
- <?php if ( $state != 'not_configured' ): ?>
61
- <tr>
62
- <th>
63
- <label><?php _e( 'Zone:', 'w3-total-cache' ); ?></label>
64
- </th>
65
- <td class="w3tc_config_value_text">
66
- <?php echo $config->get_string( array( 'cloudflare', 'zone_name' ) ) ?>
67
- </td>
68
- </tr>
69
  <?php endif ?>
70
- </table>
71
-
72
-
73
- <?php Util_Ui::postbox_footer(); ?>
74
- <?php Util_Ui::postbox_header( __( 'General', 'w3-total-cache' ), '', 'general' ); ?>
75
-
76
-
77
- <?php if ( $state == 'not_configured' ): ?>
78
- <table class="form-table">
79
- <tr><td colspan="2">
80
- Authenticate your account in order to access settings.
81
- </td></tr>
82
- </table>
83
- <?php endif ?>
84
-
85
-
86
- <?php if ( $state == 'not_available' ): ?>
87
- <table class="form-table">
88
- <tr><td colspan="2">
89
- CloudFlare not available: <?php echo $error_message; ?>
90
- </td></tr>
91
- </table>
92
- <?php endif ?>
93
-
94
-
95
- <?php if ( $state == 'available' ): ?>
96
- <table class="form-table">
97
- <?php
98
-
99
- Util_Ui::config_item( array(
100
- 'key' => array( 'cloudflare', 'widget_interval' ),
101
- 'label' => __( 'Widget statistics interval:', 'w3-total-cache' ),
102
- 'control' => 'selectbox',
103
- 'selectbox_values' => array(
104
- '-30' => 'Last 30 minutes',
105
- '-360' => 'Last 6 hours',
106
- '-720' => 'Last 12 hours',
107
- '-1440' => 'Last 24 hours',
108
- '-10080' => 'Last week',
109
- '-43200' => 'Last month'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  )
111
- )
112
- );
113
-
114
- Util_Ui::config_item( array(
115
- 'key' => array( 'cloudflare', 'widget_cache_mins' ),
116
- 'label' => __( 'Cache time:', 'w3-total-cache' ),
117
- 'control' => 'textbox',
118
- 'description' =>
119
- 'How many minutes data retrieved from CloudFlare:' .
120
- 'should be stored. Minimum is 1 minute.'
121
- )
122
- );
123
-
124
- Util_Ui::config_item( array(
125
- 'key' => array( 'cloudflare', 'pagecache' ),
126
- 'label' => __( 'Page caching:', 'w3-total-cache' ),
127
- 'control' => 'checkbox',
128
- 'checkbox_label' => 'Flush CloudFlare on Post Modifications:',
129
- 'description' =>
130
- 'Enable when you have html pages cached on CloudFlare level.'
131
- )
132
- );
133
-
134
- Util_Ui::config_item( array(
135
- 'key' => array( 'cloudflare', 'minify_js_rl_exclude' ),
136
- 'label' => __( 'Minified JS Rocket Loader Exclude:', 'w3-total-cache' ),
137
- 'checkbox_label' => 'Exclude minified JS files from being processed by Rocket Loader:',
138
- 'control' => 'checkbox',
139
- 'description' => 'Exclusion achieved by adding data-cfasync="false" to script tags.'
140
- )
141
- );
142
-
143
- ?>
144
- </table>
145
- <?php endif; ?>
146
-
147
-
148
- <?php Util_Ui::button_config_save( 'extension_cloudflare_general' ); ?>
149
- <?php Util_Ui::postbox_footer(); ?>
150
-
151
-
152
- <?php if ( $state == 'available' ): ?>
153
- <?php Util_Ui::postbox_header( __( 'CloudFlare: Caching', 'w3-total-cache' ), '', 'general' ); ?>
154
- <table class="form-table">
155
-
156
- <?php
157
- self::cloudflare_checkbox( $settings, array(
158
- 'key' => 'development_mode',
159
- 'label' => 'Development mode:',
160
- 'description' => 'Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. This will bypass CloudFlare\'s accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away.'
161
- ) );
162
- self::cloudflare_selectbox( $settings, array(
163
- 'key' => 'cache_level',
164
- 'label' => __( 'Cache level:', 'w3-total-cache' ),
165
- 'values' => array(
166
- '' => '',
167
- 'aggressive' => 'Aggressive (cache all static resources, including ones with a query string)',
168
- 'basic' => 'Basic (cache most static resources (i.e., css, images, and JavaScript)',
169
- 'simplified' => 'Simplified (ignore the query string when delivering a cached resource)'
170
- ),
171
- 'description' => 'How the content is cached by CloudFlare'
172
- ) );
173
- self::cloudflare_checkbox( $settings, array(
174
- 'key' => 'sort_query_string_for_cache',
175
- 'label' => 'Query string sorting:',
176
- 'description' => 'CloudFlare will treat files with the same query strings as the same file in cache, regardless of the order of the query strings.',
177
- ) );
178
- self::cloudflare_selectbox( $settings, array(
179
- 'key' => 'browser_cache_ttl',
180
- 'label' => 'Browser cache <acronym title="Time-to-Live ">TTL</acronym>:',
181
- 'values' => array(
182
- '' => '',
183
- '30' => '30',
184
- '60' => '60',
185
- '300' => '300',
186
- '1200' => '1200',
187
- '1800' => '1800',
188
- '3600' => '3600',
189
- '7200' => '7200',
190
- '10800' => '10800',
191
- '14400' => '14400',
192
- '18000' => '18000',
193
- '28800' => '28800',
194
- '43200' => '43200',
195
- '57600' => '57600',
196
- '72000' => '72000',
197
- '86400' => '86400',
198
- '172800' => '172800',
199
- '259200' => '259200',
200
- '345600' => '345600',
201
- '432000' => '432000',
202
- '691200' => '691200',
203
- '1382400' => '1382400',
204
- '2073600' => '2073600',
205
- '2678400' => '2678400',
206
- '5356800' => '5356800',
207
- '16070400' => '16070400',
208
- '31536000' => '31536000'
209
- ),
210
- 'description' => 'Browser cache <acronym title="Time-to-Live ">TTL</acronym> (in seconds) specifies how long CloudFlare-cached resources will remain on your visitors\' computers.',
211
- ) );
212
- self::cloudflare_selectbox( $settings, array(
213
- 'key' => 'challenge_ttl',
214
- 'label' => 'Challenge <acronym title="Time-to-Live ">TTL</acronym>:',
215
- 'values' => array(
216
- '' => '',
217
- '300' => '300',
218
- '900' => '900',
219
- '1800' => '1800',
220
- '2700' => '2700',
221
- '3600' => '3600',
222
- '7200' => '7200',
223
- '10800' => '10800',
224
- '14400' => '14400',
225
- '28800' => '28800',
226
- '57600' => '57600',
227
- '86400' => '86400',
228
- '604800' => '604800',
229
- '2592000' => '2592000',
230
- '31536000' => '31536000'
231
- ),
232
- 'description' => 'Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the <acronym title="Time-to-Live ">TTL</acronym> has expired the visitor will have to complete a new challenge.',
233
- ) );
234
- self::cloudflare_selectbox( $settings, array(
235
- 'key' => 'edge_cache_ttl',
236
- 'label' => 'Edge cache TTL:',
237
- 'values' => array(
238
- '' => '',
239
- '300' => '300',
240
- '900' => '900',
241
- '1800' => '1800',
242
- '2700' => '2700',
243
- '3600' => '3600',
244
- '7200' => '7200',
245
- '10800' => '10800',
246
- '14400' => '14400',
247
- '28800' => '28800',
248
- '57600' => '57600',
249
- '86400' => '86400',
250
- '604800' => '604800',
251
- '2592000' => '2592000',
252
- '31536000' => '31536000'
253
- ),
254
- 'description' => 'Controls how long CloudFlare\'s edge servers will cache a resource before getting back to your server for a fresh copy.',
255
- ) );
256
-
257
- echo '</table>';
258
- self::cloudflare_button_save( 'caching' );
259
- Util_Ui::postbox_footer();
260
- Util_Ui::postbox_header( __( 'CloudFlare: Content Processing', 'w3-total-cache' ), '', 'general' );
261
- echo '<table class="form-table">';
262
-
263
-
264
- self::cloudflare_selectbox( $settings, array(
265
- 'key' => 'rocket_loader',
266
- 'label' => __( 'Rocket Loader:', 'w3-total-cache' ),
267
- 'values' => array(
268
- '' => '',
269
- 'off' => 'Off',
270
- 'on' => 'On (automatically run on the JavaScript resources on your site)',
271
- 'manual' => 'Manual (run when attribute present only)'
272
- ),
273
- 'description' => 'Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload.'
274
- ) );
275
- self::cloudflare_checkbox( $settings, array(
276
- 'key' => 'minify_js',
277
- 'label' => 'Minify <acronym title="JavaScript">JS</acronym>:',
278
- 'description' => 'Minify JavaScript files.',
279
- ) );
280
- self::cloudflare_checkbox( $settings, array(
281
- 'key' => 'minify_css',
282
- 'label' => 'Minify <acronym title="Cascading Style Sheet">CSS</acronym>:',
283
- 'description' => 'Minify CSS files.',
284
- ) );
285
- self::cloudflare_checkbox( $settings, array(
286
- 'key' => 'minify_html',
287
- 'label' => 'Minify <acronym title="HyperText Markup Language">HTML</acronym>:',
288
- 'description' => 'Minify <acronym title="HyperText Markup Language">HTML</acronym> content.',
289
- ) );
290
- self::cloudflare_checkbox( $settings, array(
291
- 'key' => 'server_side_exclude',
292
- 'label' => 'Server side exclude:',
293
- 'description' => 'If there is sensitive content on your website that you want visible to real visitors, but that you want to hide from suspicious visitors, all you have to do is wrap the content with CloudFlare SSE tags.',
294
- ) );
295
- self::cloudflare_checkbox( $settings, array(
296
- 'key' => 'email_obfuscation',
297
- 'label' => 'Email obfuscation:',
298
- 'description' => 'Encrypt email adresses on your web page from bots, while keeping them visible to humans. ',
299
- ) );
300
- self::cloudflare_checkbox( $settings, array(
301
- 'key' => 'response_buffering',
302
- 'label' => 'Response buffering"',
303
- 'description' => 'CloudFlare may buffer the whole payload to deliver it at once to the client versus allowing it to be delivered in chunks.',
304
- ) );
305
- self::cloudflare_checkbox( $settings, array(
306
- 'key' => 'prefetch_preload',
307
- 'label' => 'Prefetch preload:',
308
- 'description' => 'CloudFlare will prefetch any URLs that are included in the response headers.',
309
- ) );
310
- self::cloudflare_checkbox( $settings, array(
311
- 'key' => 'mobile_redirect',
312
- 'label' => 'Mobile redirect:',
313
- 'description' => 'Automatically redirect visitors on mobile devices to a mobile-optimized subdomain',
314
- ) );
315
- self::cloudflare_checkbox( $settings, array(
316
- 'key' => 'origin_error_page_pass_thru',
317
- 'label' => 'Enable error pages:',
318
- 'description' => 'CloudFlare will proxy customer error pages on any 502,504 errors on origin server instead of showing a default CloudFlare error page. This does not apply to 522 errors and is limited to Enterprise Zones.',
319
- ) );
320
-
321
-
322
- echo '</table>';
323
- self::cloudflare_button_save( 'content_processing' );
324
- Util_Ui::postbox_footer();
325
- Util_Ui::postbox_header( __( 'CloudFlare: Image Processing', 'w3-total-cache' ), '', 'general' );
326
- echo '<table class="form-table">';
327
-
328
-
329
- self::cloudflare_checkbox( $settings, array(
330
- 'key' => 'hotlink_protection',
331
- 'label' => 'Hotlink protection:',
332
- 'description' => 'When enabled, the Hotlink Protection option ensures that other sites cannot suck up your bandwidth by building pages that use images hosted on your site.',
333
- ) );
334
- self::cloudflare_checkbox( $settings, array(
335
- 'key' => 'mirage',
336
- 'label' => 'Mirage:',
337
- 'description' => 'Automatically optimize image loading for website visitors on mobile devices',
338
- ) );
339
- self::cloudflare_selectbox( $settings, array(
340
- 'key' => 'polish',
341
- 'label' => __( 'Images polishing:', 'w3-total-cache' ),
342
- 'values' => array(
343
- '' => '',
344
- 'off' => 'Off',
345
- 'lossless' => 'Lossless (Reduce the size of PNG, JPEG, and GIF files - no impact on visual quality)',
346
- 'lossy' => 'Lossy (Further reduce the size of JPEG files for faster image loading)'
347
- ),
348
- 'description' => 'Strips metadata and compresses your images for faster page load times.'
349
- ) );
350
-
351
-
352
- echo '</table>';
353
- self::cloudflare_button_save( 'image_processing' );
354
- Util_Ui::postbox_footer();
355
- Util_Ui::postbox_header( __( 'CloudFlare: Protection', 'w3-total-cache' ), '', 'general' );
356
- echo '<table class="form-table">';
357
-
358
-
359
- self::cloudflare_selectbox( $settings, array(
360
- 'key' => 'security_level',
361
- 'label' => __( 'Security level:', 'w3-total-cache' ),
362
- 'values' => array(
363
- '' => '',
364
- 'essentially_off' => 'Off',
365
- 'low' => 'Low',
366
- 'medium' => 'Medium',
367
- 'high' => 'High',
368
- 'under_attack' => 'Under Attack'
369
- ),
370
- 'description' => 'security profile for your website, which will automatically adjust each of the security settings.'
371
- ) );
372
- self::cloudflare_checkbox( $settings, array(
373
- 'key' => 'browser_check',
374
- 'label' => 'Browser integrity check:',
375
- 'description' => 'Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors).',
376
- ) );
377
- self::cloudflare_checkbox( $settings, array(
378
- 'key' => 'always_online',
379
- 'label' => 'Always online:',
380
- 'description' => 'When enabled, Always Online will serve pages from our cache if your server is offline',
381
- ) );
382
- self::cloudflare_checkbox( $settings, array(
383
- 'key' => 'waf',
384
- 'label' => 'Web application firewall:',
385
- 'description' => 'The Web Application Firewall (WAF) examines HTTP requests to your website. It inspects both GET and POST requests and applies rules to help filter out illegitimate traffic from legitimate website visitors.'
386
- ) );
387
- self::cloudflare_checkbox( $settings, array(
388
- 'key' => 'advanced_ddos',
389
- 'label' => 'Advanced <acronym title="Distributed Denial of Service">DDoS</acronym> protection:',
390
- 'description' => 'Advanced protection from Distributed Denial of Service (DDoS) attacks on your website.',
391
- ) );
392
- self::cloudflare_textbox( $settings, array(
393
- 'key' => 'max_upload',
394
- 'label' => 'Max upload:',
395
- 'description' => 'Max size of file allowed for uploading',
396
- ) );
397
-
398
-
399
- echo '</table>';
400
- self::cloudflare_button_save( 'protection' );
401
- Util_Ui::postbox_footer();
402
- Util_Ui::postbox_header( __( 'CloudFlare: <acronym title="Internet Protocol">IP</acronym>', 'w3-total-cache' ), '', 'general' );
403
- echo '<table class="form-table">';
404
-
405
-
406
- self::cloudflare_checkbox( $settings, array(
407
- 'key' => 'ip_geolocation',
408
- 'label' => '<acronym title="Internet Protocol">IP</acronym> geolocation:',
409
- 'description' => 'Enable <acronym title="Internet Protocol">IP</acronym> Geolocation to have CloudFlare geolocate visitors to your website and pass the country code to you.',
410
- ) );
411
- self::cloudflare_checkbox( $settings, array(
412
- 'key' => 'ipv6',
413
- 'label' => 'IPv6:',
414
- 'description' => 'Enable IPv6.',
415
- ) );
416
- self::cloudflare_checkbox( $settings, array(
417
- 'key' => 'true_client_ip_header',
418
- 'label' => 'True client IP:',
419
- 'description' => 'Allows customer to continue to use True Client IP (Akamai feature) in the headers we send to the origin.',
420
- ) );
421
-
422
-
423
- echo '</table>';
424
- self::cloudflare_button_save( 'ip' );
425
- Util_Ui::postbox_footer();
426
- Util_Ui::postbox_header( __( 'CloudFlare: <acronym title="Secure Sockets Layer">SSL</acronym>', 'w3-total-cache' ), '', 'general' );
427
- echo '<table class="form-table">';
428
-
429
-
430
- self::cloudflare_selectbox( $settings, array(
431
- 'key' => 'ssl',
432
- 'label' => '<acronym title="Secure Sockets Layer">SSL</acronym>:',
433
- 'values' => array(
434
- '' => '',
435
- 'off' => 'Off',
436
- 'flexible' => 'Flexible (HTTPS to end-user only)',
437
- 'full' => 'Full (https everywhere)',
438
- 'full_strict' => 'Strict'
439
- ),
440
- 'description' => '<acronym title="Secure Sockets Layer">SSL</acronym> encrypts your visitor\'s connection and safeguards credit card numbers and other personal data to and from your website.',
441
- ) );
442
- self::cloudflare_checkbox( $settings, array(
443
- 'key' => 'security_header',
444
- 'label' => 'Security header (<acronym title="Secure Sockets Layer">SSL</acronym>):',
445
- 'description' => 'Enables or disables <acronym title="Secure Sockets Layer">SSL</acronym> header.',
446
- ) );
447
- self::cloudflare_checkbox( $settings, array(
448
- 'key' => 'tls_1_2_only',
449
- 'label' => '<acronym title="Transport Layer Security">TLS</acronym> 1.2 only:',
450
- 'description' => 'Enable Crypto <acronym title="Transport Layer Security">TLS</acronym> 1.2 feature for this zone and prevent use of previous versions.',
451
- ) );
452
- self::cloudflare_checkbox( $settings, array(
453
- 'key' => 'tls_client_auth',
454
- 'label' => '<acronym title="Transport Layer Security">TLS</acronym> client auth:',
455
- 'description' => '<acronym title="Transport Layer Security">TLS</acronym> Client authentication requires CloudFlare to connect to your origin server using a client certificate',
456
- ) );
457
-
458
- echo '</table>';
459
- self::cloudflare_button_save( 'ssl' );
460
- Util_Ui::postbox_footer();
461
- endif;
462
- ?>
463
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <p id="w3tc-options-menu">
9
+ <?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
10
+ <a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
+ <a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a> |
12
+ <a href="#credentials"><?php esc_html_e( 'Credentials', 'w3-total-cache' ); ?></a> |
13
+ <a href="#general"><?php esc_html_e( 'General', 'w3-total-cache' ); ?></a> |
14
+ <a href="#info"><?php esc_html_e( 'Information', 'w3-total-cache' ); ?></a>
15
  </p>
16
  <p>
17
+ <?php esc_html_e( 'CloudFlare extension is currently ', 'w3-total-cache' ); ?>
18
+ <?php
19
+ if ( $config->is_extension_active_frontend( 'cloudflare' ) ) {
20
+ echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>';
21
+ } else {
22
+ echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>';
23
+ }
24
+ ?>
25
+ .
26
  <p>
27
 
28
  <form action="admin.php?page=w3tc_extensions&amp;extension=cloudflare&amp;action=view" method="post">
29
+ <p>
30
+ <?php
31
+ echo wp_kses(
32
+ Util_Ui::nonce_field( 'w3tc' ),
33
+ array(
34
+ 'input' => array(
35
+ 'type' => array(),
36
+ 'name' => array(),
37
+ 'value' => array(),
38
+ ),
39
+ )
40
+ );
41
+ ?>
42
+ <input type="submit" name="w3tc_cloudflare_flush" value="<?php esc_html_e( 'Purge CloudFlare cache', 'w3-total-cache' ); ?>" class="button" />
43
+ <?php esc_html_e( 'if needed.', 'w3-total-cache' ); ?>
44
+ </p>
45
  </form>
46
 
47
  <form action="admin.php?page=w3tc_extensions&amp;extension=cloudflare&amp;action=view" method="post">
48
+ <div class="metabox-holder">
49
+ <?php Util_Ui::postbox_header( esc_html__( 'Credentials', 'w3-total-cache' ), '', 'credentials' ); ?>
50
+ <table class="form-table">
51
  <tr>
52
  <th style="width: 300px;">
53
  <label>
54
+ <?php
55
+ esc_html_e( 'Specify account credentials:', 'w3-total-cache' );
56
+ ?>
 
57
  </label>
58
  </th>
59
  <td>
60
+ <?php if ( 'not_cofigured' !== $state ) : ?>
61
  <input class="w3tc_extension_cloudflare_authorize button-primary"
62
  type="button"
63
+ value="<?php esc_attr_e( 'Reauthorize', 'w3-total-cache' ); ?>"
64
  />
65
+ <?php else : ?>
66
  <input class="w3tc_extension_cloudflare_authorize button-primary"
67
  type="button"
68
+ value="<?php esc_attr_e( 'Authorize', 'w3-total-cache' ); ?>"
69
  />
70
  <?php endif ?>
71
  </td>
72
  </tr>
73
 
74
+ <?php if ( 'not_configured' !== $state ) : ?>
75
+ <tr>
76
+ <th>
77
+ <label><?php esc_attr_e( 'Zone:', 'w3-total-cache' ); ?></label>
78
+ </th>
79
+ <td class="w3tc_config_value_text">
80
+ <?php echo esc_html( $config->get_string( array( 'cloudflare', 'zone_name' ) ) ); ?>
81
+ </td>
82
+ </tr>
83
  <?php endif ?>
84
+ </table>
85
+ <?php Util_Ui::postbox_footer(); ?>
86
+
87
+ <?php Util_Ui::postbox_header( esc_html__( 'General', 'w3-total-cache' ), '', 'general' ); ?>
88
+ <?php if ( 'not_configured' === $state ) : ?>
89
+ <table class="form-table">
90
+ <tr>
91
+ <td colspan="2">
92
+ <?php esc_html_e( 'Authenticate your account in order to access settings.', 'w3-total-cache' ); ?>
93
+ </td>
94
+ </tr>
95
+ </table>
96
+ <?php elseif ( 'not_available' === $state ) : ?>
97
+ <table class="form-table">
98
+ <tr>
99
+ <td colspan="2">
100
+ <?php esc_html__( 'CloudFlare not available: ', 'w3-total-cache' ) . esc_html( $error_message ); ?>
101
+ </td>
102
+ </tr>
103
+ </table>
104
+ <?php elseif ( 'available' === $state ) : ?>
105
+ <table class="form-table">
106
+ <?php
107
+ Util_Ui::config_item(
108
+ array(
109
+ 'key' => array( 'cloudflare', 'widget_interval' ),
110
+ 'label' => esc_html__( 'Widget statistics interval:', 'w3-total-cache' ),
111
+ 'control' => 'selectbox',
112
+ 'selectbox_values' => array(
113
+ '-30' => esc_html__( 'Last 30 minutes', 'w3-total-cache' ),
114
+ '-360' => esc_html__( 'Last 6 hours', 'w3-total-cache' ),
115
+ '-720' => esc_html__( 'Last 12 hours', 'w3-total-cache' ),
116
+ '-1440' => esc_html__( 'Last 24 hours', 'w3-total-cache' ),
117
+ '-10080' => esc_html__( 'Last week', 'w3-total-cache' ),
118
+ '-43200' => esc_html__( 'Last month', 'w3-total-cache' ),
119
+ ),
120
+ )
121
+ );
122
+
123
+ Util_Ui::config_item(
124
+ array(
125
+ 'key' => array( 'cloudflare', 'widget_cache_mins' ),
126
+ 'label' => esc_html__( 'Cache time:', 'w3-total-cache' ),
127
+ 'control' => 'textbox',
128
+ 'description' => esc_html__( 'How many minutes data retrieved from CloudFlare: should be stored. Minimum is 1 minute.', 'w3-total-cache' ),
129
+ )
130
+ );
131
+
132
+ Util_Ui::config_item(
133
+ array(
134
+ 'key' => array( 'cloudflare', 'pagecache' ),
135
+ 'label' => esc_html__( 'Page caching:', 'w3-total-cache' ),
136
+ 'control' => 'checkbox',
137
+ 'checkbox_label' => esc_html__( 'Flush CloudFlare on Post Modifications:', 'w3-total-cache' ),
138
+ 'description' => esc_html__( 'Enable when you have html pages cached on CloudFlare level.', 'w3-total-cache' ),
139
+ )
140
+ );
141
+
142
+ Util_Ui::config_item(
143
+ array(
144
+ 'key' => array( 'cloudflare', 'minify_js_rl_exclude' ),
145
+ 'label' => esc_html__( 'Minified JS Rocket Loader Exclude:', 'w3-total-cache' ),
146
+ 'checkbox_label' => esc_html__( 'Exclude minified JS files from being processed by Rocket Loader:', 'w3-total-cache' ),
147
+ 'control' => 'checkbox',
148
+ 'description' => esc_html__( 'Exclusion achieved by adding data-cfasync="false" to script tags.', 'w3-total-cache' ),
149
+ )
150
+ );
151
+ ?>
152
+ </table>
153
+ <?php endif; ?>
154
+
155
+ <?php Util_Ui::button_config_save( 'extension_cloudflare_general' ); ?>
156
+ <?php Util_Ui::postbox_footer(); ?>
157
+
158
+
159
+ <?php if ( 'available' === $state ) : ?>
160
+ <?php Util_Ui::postbox_header( esc_html__( 'CloudFlare: Caching', 'w3-total-cache' ), '', 'general' ); ?>
161
+ <table class="form-table">
162
+ <?php
163
+ self::cloudflare_checkbox(
164
+ $settings,
165
+ array(
166
+ 'key' => 'development_mode',
167
+ 'label' => esc_html__( 'Development mode:', 'w3-total-cache' ),
168
+ 'description' => esc_html__( 'Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. This will bypass CloudFlare\'s accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away.', 'w3-total-cache' ),
169
+ )
170
+ );
171
+ self::cloudflare_selectbox(
172
+ $settings,
173
+ array(
174
+ 'key' => 'cache_level',
175
+ 'label' => esc_html__( 'Cache level:', 'w3-total-cache' ),
176
+ 'values' => array(
177
+ '' => '',
178
+ 'aggressive' => esc_html__( 'Aggressive (cache all static resources, including ones with a query string)', 'w3-total-cache' ),
179
+ 'basic' => esc_html__( 'Basic (cache most static resources (i.e., css, images, and JavaScript)', 'w3-total-cache' ),
180
+ 'simplified' => esc_html__( 'Simplified (ignore the query string when delivering a cached resource)', 'w3-total-cache' ),
181
+ ),
182
+ 'description' => esc_html__( 'How the content is cached by CloudFlare', 'w3-total-cache' ),
183
+ )
184
+ );
185
+ self::cloudflare_checkbox(
186
+ $settings,
187
+ array(
188
+ 'key' => 'sort_query_string_for_cache',
189
+ 'label' => esc_html__( 'Query string sorting:', 'w3-total-cache' ),
190
+ 'description' => esc_html__( 'CloudFlare will treat files with the same query strings as the same file in cache, regardless of the order of the query strings.', 'w3-total-cache' ),
191
+ )
192
+ );
193
+ self::cloudflare_selectbox(
194
+ $settings,
195
+ array(
196
+ 'key' => 'browser_cache_ttl',
197
+ 'label' => wp_kses(
198
+ sprintf(
199
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
200
+ __(
201
+ 'Browser cache %1$sTTL%2$s:',
202
+ 'w3-total-cache'
203
+ ),
204
+ '<acronym title="' . esc_attr__( 'Time-to-Live', 'w3-total-cache' ) . '">',
205
+ '</acronym>'
206
+ ),
207
+ array(
208
+ 'acronym' => array(
209
+ 'title' => array(),
210
+ ),
211
+ )
212
+ ),
213
+ 'values' => array(
214
+ '' => '',
215
+ '30' => '30',
216
+ '60' => '60',
217
+ '300' => '300',
218
+ '1200' => '1200',
219
+ '1800' => '1800',
220
+ '3600' => '3600',
221
+ '7200' => '7200',
222
+ '10800' => '10800',
223
+ '14400' => '14400',
224
+ '18000' => '18000',
225
+ '28800' => '28800',
226
+ '43200' => '43200',
227
+ '57600' => '57600',
228
+ '72000' => '72000',
229
+ '86400' => '86400',
230
+ '172800' => '172800',
231
+ '259200' => '259200',
232
+ '345600' => '345600',
233
+ '432000' => '432000',
234
+ '691200' => '691200',
235
+ '1382400' => '1382400',
236
+ '2073600' => '2073600',
237
+ '2678400' => '2678400',
238
+ '5356800' => '5356800',
239
+ '16070400' => '16070400',
240
+ '31536000' => '31536000',
241
+ ),
242
+ 'description' => wp_kses(
243
+ sprintf(
244
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
245
+ __(
246
+ 'Browser cache %1$sTTL%2$s (in seconds) specifies how long CloudFlare-cached resources will remain on your visitors\' computers.',
247
+ 'w3-total-cache'
248
+ ),
249
+ '<acronym title="' . esc_attr__( 'Time-to-Live', 'w3-total-cache' ) . '">',
250
+ '</acronym>'
251
+ ),
252
+ array(
253
+ 'acronym' => array(
254
+ 'title' => array(),
255
+ ),
256
+ )
257
+ ),
258
+ )
259
+ );
260
+ self::cloudflare_selectbox(
261
+ $settings,
262
+ array(
263
+ 'key' => 'challenge_ttl',
264
+ 'label' => wp_kses(
265
+ sprintf(
266
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
267
+ __(
268
+ 'Challenge %1$sTTL%2$s:',
269
+ 'w3-total-cache'
270
+ ),
271
+ '<acronym title="' . esc_attr__( 'Time-to-Live', 'w3-total-cache' ) . '">',
272
+ '</acronym>'
273
+ ),
274
+ array(
275
+ 'acronym' => array(
276
+ 'title' => array(),
277
+ ),
278
+ )
279
+ ),
280
+ 'values' => array(
281
+ '' => '',
282
+ '300' => '300',
283
+ '900' => '900',
284
+ '1800' => '1800',
285
+ '2700' => '2700',
286
+ '3600' => '3600',
287
+ '7200' => '7200',
288
+ '10800' => '10800',
289
+ '14400' => '14400',
290
+ '28800' => '28800',
291
+ '57600' => '57600',
292
+ '86400' => '86400',
293
+ '604800' => '604800',
294
+ '2592000' => '2592000',
295
+ '31536000' => '31536000',
296
+ ),
297
+ 'description' => wp_kses(
298
+ sprintf(
299
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
300
+ __(
301
+ 'Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the %1$sTTL%2$s has expired the visitor will have to complete a new challenge.',
302
+ 'w3-total-cache'
303
+ ),
304
+ '<acronym title="' . esc_attr__( 'Time-to-Live', 'w3-total-cache' ) . '">',
305
+ '</acronym>'
306
+ ),
307
+ array(
308
+ 'acronym' => array(
309
+ 'title' => array(),
310
+ ),
311
+ )
312
+ ),
313
+ )
314
+ );
315
+ self::cloudflare_selectbox(
316
+ $settings,
317
+ array(
318
+ 'key' => 'edge_cache_ttl',
319
+ 'label' => esc_html__( 'Edge cache TTL:', 'w3-total-cache' ),
320
+ 'values' => array(
321
+ '' => '',
322
+ '300' => '300',
323
+ '900' => '900',
324
+ '1800' => '1800',
325
+ '2700' => '2700',
326
+ '3600' => '3600',
327
+ '7200' => '7200',
328
+ '10800' => '10800',
329
+ '14400' => '14400',
330
+ '28800' => '28800',
331
+ '57600' => '57600',
332
+ '86400' => '86400',
333
+ '604800' => '604800',
334
+ '2592000' => '2592000',
335
+ '31536000' => '31536000',
336
+ ),
337
+ 'description' => esc_html__( 'Controls how long CloudFlare\'s edge servers will cache a resource before getting back to your server for a fresh copy.', 'w3-total-cache' ),
338
+ )
339
+ );
340
+ ?>
341
+ </table>
342
+ <?php
343
+ self::cloudflare_button_save( 'caching' );
344
+ Util_Ui::postbox_footer();
345
+
346
+ Util_Ui::postbox_header( esc_html__( 'CloudFlare: Content Processing', 'w3-total-cache' ), '', 'general' );
347
+ echo '<table class="form-table">';
348
+ self::cloudflare_selectbox(
349
+ $settings,
350
+ array(
351
+ 'key' => 'rocket_loader',
352
+ 'label' => esc_html__( 'Rocket Loader:', 'w3-total-cache' ),
353
+ 'values' => array(
354
+ '' => '',
355
+ 'off' => esc_html__( 'Off', 'w3-total-cache' ),
356
+ 'on' => esc_html__( 'On (automatically run on the JavaScript resources on your site)', 'w3-total-cache' ),
357
+ 'manual' => esc_html__( 'Manual (run when attribute present only)', 'w3-total-cache' ),
358
+ ),
359
+ 'description' => esc_html__( 'Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload.', 'w3-total-cache' ),
360
  )
361
+ );
362
+ self::cloudflare_checkbox(
363
+ $settings,
364
+ array(
365
+ 'key' => 'minify_js',
366
+ 'label' => wp_kses(
367
+ sprintf(
368
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
369
+ __(
370
+ 'Minify %1$sJS%2$s:',
371
+ 'w3-total-cache'
372
+ ),
373
+ '<acronym title="' . esc_attr__( 'JavaScript', 'w3-total-cache' ) . '">',
374
+ '</acronym>'
375
+ ),
376
+ array(
377
+ 'acronym' => array(
378
+ 'title' => array(),
379
+ ),
380
+ )
381
+ ),
382
+ 'description' => esc_html__( 'Minify JavaScript files.', 'w3-total-cache' ),
383
+ )
384
+ );
385
+ self::cloudflare_checkbox(
386
+ $settings,
387
+ array(
388
+ 'key' => 'minify_css',
389
+ 'label' => wp_kses(
390
+ sprintf(
391
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
392
+ __(
393
+ 'Minify %1$sCSS%2$s:',
394
+ 'w3-total-cache'
395
+ ),
396
+ '<acronym title="' . esc_attr__( 'Cascading Style Sheet', 'w3-total-cache' ) . '">',
397
+ '</acronym>'
398
+ ),
399
+ array(
400
+ 'acronym' => array(
401
+ 'title' => array(),
402
+ ),
403
+ )
404
+ ),
405
+ 'description' => 'Minify CSS files.',
406
+ )
407
+ );
408
+ self::cloudflare_checkbox(
409
+ $settings,
410
+ array(
411
+ 'key' => 'minify_html',
412
+ 'label' => wp_kses(
413
+ sprintf(
414
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
415
+ __(
416
+ 'Minify %1$sHTML%2$s:',
417
+ 'w3-total-cache'
418
+ ),
419
+ '<acronym title="' . esc_attr__( 'HyperText Markup Language', 'w3-total-cache' ) . '">',
420
+ '</acronym>'
421
+ ),
422
+ array(
423
+ 'acronym' => array(
424
+ 'title' => array(),
425
+ ),
426
+ )
427
+ ),
428
+ 'description' => wp_kses(
429
+ sprintf(
430
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
431
+ __(
432
+ 'Minify %1$sHTML%2$s content.',
433
+ 'w3-total-cache'
434
+ ),
435
+ '<acronym title="' . esc_attr__( 'HyperText Markup Language', 'w3-total-cache' ) . '">',
436
+ '</acronym>'
437
+ ),
438
+ array(
439
+ 'acronym' => array(
440
+ 'title' => array(),
441
+ ),
442
+ )
443
+ ),
444
+ )
445
+ );
446
+ self::cloudflare_checkbox(
447
+ $settings,
448
+ array(
449
+ 'key' => 'server_side_exclude',
450
+ 'label' => esc_html__( 'Server side exclude:', 'w3-total-cache' ),
451
+ 'description' => esc_html__( 'If there is sensitive content on your website that you want visible to real visitors, but that you want to hide from suspicious visitors, all you have to do is wrap the content with CloudFlare SSE tags.', 'w3-total-cache' ),
452
+ )
453
+ );
454
+ self::cloudflare_checkbox(
455
+ $settings,
456
+ array(
457
+ 'key' => 'email_obfuscation',
458
+ 'label' => esc_html__( 'Email obfuscation:', 'w3-total-cache' ),
459
+ 'description' => esc_html__( 'Encrypt email adresses on your web page from bots, while keeping them visible to humans. ', 'w3-total-cache' ),
460
+ )
461
+ );
462
+ self::cloudflare_checkbox(
463
+ $settings,
464
+ array(
465
+ 'key' => 'response_buffering',
466
+ 'label' => esc_html__( 'Response buffering"', 'w3-total-cache' ),
467
+ 'description' => esc_html__( 'CloudFlare may buffer the whole payload to deliver it at once to the client versus allowing it to be delivered in chunks.', 'w3-total-cache' ),
468
+ )
469
+ );
470
+ self::cloudflare_checkbox(
471
+ $settings,
472
+ array(
473
+ 'key' => 'prefetch_preload',
474
+ 'label' => esc_html__( 'Prefetch preload:', 'w3-total-cache' ),
475
+ 'description' => esc_html__( 'CloudFlare will prefetch any URLs that are included in the response headers.', 'w3-total-cache' ),
476
+ )
477
+ );
478
+ self::cloudflare_checkbox(
479
+ $settings,
480
+ array(
481
+ 'key' => 'mobile_redirect',
482
+ 'label' => esc_html__( 'Mobile redirect:', 'w3-total-cache' ),
483
+ 'description' => esc_html__( 'Automatically redirect visitors on mobile devices to a mobile-optimized subdomain', 'w3-total-cache' ),
484
+ )
485
+ );
486
+ self::cloudflare_checkbox(
487
+ $settings,
488
+ array(
489
+ 'key' => 'origin_error_page_pass_thru',
490
+ 'label' => esc_html__( 'Enable error pages:', 'w3-total-cache' ),
491
+ 'description' => esc_html__( 'CloudFlare will proxy customer error pages on any 502,504 errors on origin server instead of showing a default CloudFlare error page. This does not apply to 522 errors and is limited to Enterprise Zones.', 'w3-total-cache' ),
492
+ )
493
+ );
494
+ echo '</table>';
495
+ self::cloudflare_button_save( 'content_processing' );
496
+ Util_Ui::postbox_footer();
497
+
498
+ Util_Ui::postbox_header( esc_html__( 'CloudFlare: Image Processing', 'w3-total-cache' ), '', 'general' );
499
+ echo '<table class="form-table">';
500
+ self::cloudflare_checkbox(
501
+ $settings,
502
+ array(
503
+ 'key' => 'hotlink_protection',
504
+ 'label' => esc_html__( 'Hotlink protection:', 'w3-total-cache' ),
505
+ 'description' => esc_html__( 'When enabled, the Hotlink Protection option ensures that other sites cannot suck up your bandwidth by building pages that use images hosted on your site.', 'w3-total-cache' ),
506
+ )
507
+ );
508
+ self::cloudflare_checkbox(
509
+ $settings,
510
+ array(
511
+ 'key' => 'mirage',
512
+ 'label' => esc_html__( 'Mirage:', 'w3-total-cache' ),
513
+ 'description' => esc_html__( 'Automatically optimize image loading for website visitors on mobile devices', 'w3-total-cache' ),
514
+ )
515
+ );
516
+ self::cloudflare_selectbox(
517
+ $settings,
518
+ array(
519
+ 'key' => 'polish',
520
+ 'label' => esc_html__( 'Images polishing:', 'w3-total-cache' ),
521
+ 'values' => array(
522
+ '' => '',
523
+ 'off' => esc_html__( 'Off', 'w3-total-cache' ),
524
+ 'lossless' => esc_html__( 'Lossless (Reduce the size of PNG, JPEG, and GIF files - no impact on visual quality)', 'w3-total-cache' ),
525
+ 'lossy' => esc_html__( 'Lossy (Further reduce the size of JPEG files for faster image loading)', 'w3-total-cache' ),
526
+ ),
527
+ 'description' => esc_html__( 'Strips metadata and compresses your images for faster page load times.', 'w3-total-cache' ),
528
+ )
529
+ );
530
+ echo '</table>';
531
+ self::cloudflare_button_save( 'image_processing' );
532
+ Util_Ui::postbox_footer();
533
+
534
+ Util_Ui::postbox_header( esc_html__( 'CloudFlare: Protection', 'w3-total-cache' ), '', 'general' );
535
+ echo '<table class="form-table">';
536
+ self::cloudflare_selectbox(
537
+ $settings,
538
+ array(
539
+ 'key' => 'security_level',
540
+ 'label' => esc_html__( 'Security level:', 'w3-total-cache' ),
541
+ 'values' => array(
542
+ '' => '',
543
+ 'essentially_off' => esc_html__( 'Off', 'w3-total-cache' ),
544
+ 'low' => esc_html__( 'Low', 'w3-total-cache' ),
545
+ 'medium' => esc_html__( 'Medium', 'w3-total-cache' ),
546
+ 'high' => esc_html__( 'High', 'w3-total-cache' ),
547
+ 'under_attack' => esc_html__( 'Under Attack', 'w3-total-cache' ),
548
+ ),
549
+ 'description' => esc_html__( 'security profile for your website, which will automatically adjust each of the security settings.', 'w3-total-cache' ),
550
+ )
551
+ );
552
+ self::cloudflare_checkbox(
553
+ $settings,
554
+ array(
555
+ 'key' => 'browser_check',
556
+ 'label' => esc_html__( 'Browser integrity check:', 'w3-total-cache' ),
557
+ 'description' => esc_html__( 'Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors).', 'w3-total-cache' ),
558
+ )
559
+ );
560
+ self::cloudflare_checkbox(
561
+ $settings,
562
+ array(
563
+ 'key' => 'always_online',
564
+ 'label' => esc_html__( 'Always online:', 'w3-total-cache' ),
565
+ 'description' => esc_html__( 'When enabled, Always Online will serve pages from our cache if your server is offline', 'w3-total-cache' ),
566
+ )
567
+ );
568
+ self::cloudflare_checkbox(
569
+ $settings,
570
+ array(
571
+ 'key' => 'waf',
572
+ 'label' => esc_html__( 'Web application firewall:', 'w3-total-cache' ),
573
+ 'description' => esc_html__( 'The Web Application Firewall (WAF) examines HTTP requests to your website. It inspects both GET and POST requests and applies rules to help filter out illegitimate traffic from legitimate website visitors.', 'w3-total-cache' ),
574
+ )
575
+ );
576
+ self::cloudflare_checkbox(
577
+ $settings,
578
+ array(
579
+ 'key' => 'advanced_ddos',
580
+ 'label' => wp_kses(
581
+ sprintf(
582
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
583
+ __(
584
+ 'Advanced %1$sDDoS%2$s protection:',
585
+ 'w3-total-cache'
586
+ ),
587
+ '<acronym title="' . esc_attr__( 'Distributed Denial of Service', 'w3-total-cache' ) . '">',
588
+ '</acronym>'
589
+ ),
590
+ array(
591
+ 'acronym' => array(
592
+ 'title' => array(),
593
+ ),
594
+ )
595
+ ),
596
+ 'description' => esc_html__( 'Advanced protection from Distributed Denial of Service (DDoS) attacks on your website.', 'w3-total-cache' ),
597
+ )
598
+ );
599
+ self::cloudflare_textbox(
600
+ $settings,
601
+ array(
602
+ 'key' => 'max_upload',
603
+ 'label' => esc_html__( 'Max upload:', 'w3-total-cache' ),
604
+ 'description' => esc_html__( 'Max size of file allowed for uploading', 'w3-total-cache' ),
605
+ )
606
+ );
607
+ echo '</table>';
608
+ self::cloudflare_button_save( 'protection' );
609
+ Util_Ui::postbox_footer();
610
+
611
+ Util_Ui::postbox_header(
612
+ wp_kses(
613
+ sprintf(
614
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
615
+ __(
616
+ 'CloudFlare: %1$sIP%2$s',
617
+ 'w3-total-cache'
618
+ ),
619
+ '<acronym title="' . esc_attr__( 'Internet Protocol', 'w3-total-cache' ) . '">',
620
+ '</acornym>'
621
+ ),
622
+ array(
623
+ 'acronym' => array(
624
+ 'title' => array(),
625
+ ),
626
+ )
627
+ ),
628
+ '',
629
+ 'general'
630
+ );
631
+ echo '<table class="form-table">';
632
+ self::cloudflare_checkbox(
633
+ $settings,
634
+ array(
635
+ 'key' => 'ip_geolocation',
636
+ 'label' => wp_kses(
637
+ sprintf(
638
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
639
+ __(
640
+ '%1$sIP%2$s geolocation:',
641
+ 'w3-total-cache'
642
+ ),
643
+ '<acronym title="' . esc_attr__( 'Internet Protocol', 'w3-total-cache' ) . '">',
644
+ '</acronym>'
645
+ ),
646
+ array(
647
+ 'acronym' => array(
648
+ 'title' => array(),
649
+ ),
650
+ )
651
+ ),
652
+ 'description' => wp_kses(
653
+ sprintf(
654
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
655
+ __(
656
+ 'Enable %1$sIP%2$s Geolocation to have CloudFlare geolocate visitors to your website and pass the country code to you.',
657
+ 'w3-total-cache'
658
+ ),
659
+ '<acronym title="' . esc_attr__( 'Internet Protocol', 'w3-total-cache' ) . '">',
660
+ '</acronym>'
661
+ ),
662
+ array(
663
+ 'acronym' => array(
664
+ 'title' => array(),
665
+ ),
666
+ )
667
+ ),
668
+ )
669
+ );
670
+ self::cloudflare_checkbox(
671
+ $settings,
672
+ array(
673
+ 'key' => 'ipv6',
674
+ 'label' => esc_html__( 'IPv6:', 'w3-total-cache' ),
675
+ 'description' => esc_html__( 'Enable IPv6.', 'w3-total-cache' ),
676
+ )
677
+ );
678
+ self::cloudflare_checkbox(
679
+ $settings,
680
+ array(
681
+ 'key' => 'true_client_ip_header',
682
+ 'label' => esc_html__( 'True client IP:', 'w3-total-cache' ),
683
+ 'description' => esc_html__( 'Allows customer to continue to use True Client IP (Akamai feature) in the headers we send to the origin.', 'w3-total-cache' ),
684
+ )
685
+ );
686
+ echo '</table>';
687
+ self::cloudflare_button_save( 'ip' );
688
+ Util_Ui::postbox_footer();
689
+
690
+ Util_Ui::postbox_header(
691
+ wp_kses(
692
+ sprintf(
693
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
694
+ __(
695
+ 'CloudFlare: %1$sSSL%2$s',
696
+ 'w3-total-cache'
697
+ ),
698
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
699
+ '</acronym>'
700
+ ),
701
+ array(
702
+ 'acronym' => array(
703
+ 'title' => array(),
704
+ ),
705
+ )
706
+ ),
707
+ '',
708
+ 'general'
709
+ );
710
+ echo '<table class="form-table">';
711
+ self::cloudflare_selectbox(
712
+ $settings,
713
+ array(
714
+ 'key' => 'ssl',
715
+ 'label' => wp_kses(
716
+ sprintf(
717
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
718
+ __(
719
+ '%1$sSSL%2$s:',
720
+ 'w3-total-cache'
721
+ ),
722
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer">', 'w3-total-cache' ) . '">',
723
+ '</acronym>'
724
+ ),
725
+ array(
726
+ 'acronym' => array(
727
+ 'title' => array(),
728
+ ),
729
+ )
730
+ ),
731
+ 'values' => array(
732
+ '' => '',
733
+ 'off' => esc_html__( 'Off', 'w3-total-cache' ),
734
+ 'flexible' => esc_html__( 'Flexible (HTTPS to end-user only)', 'w3-total-cache' ),
735
+ 'full' => esc_html__( 'Full (https everywhere)', 'w3-total-cache' ),
736
+ 'full_strict' => esc_html__( 'Strict', 'w3-total-cache' ),
737
+ ),
738
+ 'description' => wp_kses(
739
+ sprintf(
740
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
741
+ __(
742
+ '%1$sSSL%2$s encrypts your visitor\'s connection and safeguards credit card numbers and other personal data to and from your website.',
743
+ 'w3-total-cache'
744
+ ),
745
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
746
+ '</acronym>'
747
+ ),
748
+ array(
749
+ 'acronym' => array(
750
+ 'title' => array(),
751
+ ),
752
+ )
753
+ ),
754
+ )
755
+ );
756
+ self::cloudflare_checkbox(
757
+ $settings,
758
+ array(
759
+ 'key' => 'security_header',
760
+ 'label' => wp_kses(
761
+ sprintf(
762
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
763
+ __(
764
+ 'Security header (%1$sSSL%2$s):',
765
+ 'w3-total-cache'
766
+ ),
767
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
768
+ '</acronym>'
769
+ ),
770
+ array(
771
+ 'acronym' => array(
772
+ 'title' => array(),
773
+ ),
774
+ )
775
+ ),
776
+ 'description' => wp_kses(
777
+ sprintf(
778
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
779
+ __(
780
+ 'Enables or disables %1$sSSL%2$s header.',
781
+ 'w3-total-cache'
782
+ ),
783
+ '<acronym title="' . esc_attr__( 'Secure Sockets Layer', 'w3-total-cache' ) . '">',
784
+ '</acronym>'
785
+ ),
786
+ array(
787
+ 'acronym' => array(
788
+ 'title' => array(),
789
+ ),
790
+ )
791
+ ),
792
+ )
793
+ );
794
+ self::cloudflare_checkbox(
795
+ $settings,
796
+ array(
797
+ 'key' => 'tls_1_2_only',
798
+ 'label' => wp_kses(
799
+ sprintf(
800
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
801
+ __(
802
+ '%1$sTLS%2$s 1.2 only:',
803
+ 'w3-total-cache'
804
+ ),
805
+ '<acronym title="' . esc_attr__( 'Transport Layer Security', 'w3-total-cache' ) . '">',
806
+ '</acronym>'
807
+ ),
808
+ array(
809
+ 'acronym' => array(
810
+ 'title' => array(),
811
+ ),
812
+ )
813
+ ),
814
+ 'description' => wp_kses(
815
+ sprintf(
816
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
817
+ __(
818
+ 'Enable Crypto %1$sTLS%2$s 1.2 feature for this zone and prevent use of previous versions.',
819
+ 'w3-total-cache'
820
+ ),
821
+ '<acronym title="' . esc_attr__( 'Transport Layer Security', 'w3-total-cache' ) . '">',
822
+ '</acronym>'
823
+ ),
824
+ array(
825
+ 'acronym' => array(
826
+ 'title' => array(),
827
+ ),
828
+ )
829
+ ),
830
+ )
831
+ );
832
+ self::cloudflare_checkbox(
833
+ $settings,
834
+ array(
835
+ 'key' => 'tls_client_auth',
836
+ 'label' => '<acronym title="Transport Layer Security">TLS</acronym> client auth:',
837
+ 'description' => wp_kses(
838
+ sprintf(
839
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
840
+ __(
841
+ '%1$sTLS%2$s Client authentication requires CloudFlare to connect to your origin server using a client certificate',
842
+ 'w3-total-cache'
843
+ ),
844
+ '<acronym title="' . esc_attr__( 'Transport Layer Security', 'w3-total-cache' ) . '">',
845
+ '</acronym>'
846
+ ),
847
+ array(
848
+ 'acronym' => array(
849
+ 'title' => array(),
850
+ ),
851
+ )
852
+ ),
853
+ )
854
+ );
855
+ echo '</table>';
856
+ self::cloudflare_button_save( 'ssl' );
857
+ Util_Ui::postbox_footer();
858
+ endif;
859
+ ?>
860
+ </div>
861
  </form>
Extension_CloudFlare_Plugin.php CHANGED
@@ -178,25 +178,37 @@ class Extension_CloudFlare_Plugin {
178
  * Fix client's IP-address
179
  */
180
  private function fix_remote_addr() {
181
- if ( empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) )
 
 
 
182
  return;
 
183
 
184
- if ( strpos( $_SERVER["REMOTE_ADDR"], ":" ) === FALSE ) {
185
- $ip4_ranges = $this->_config->get_array( array(
186
- 'cloudflare', 'ips.ip4' ) );
 
 
 
 
187
  foreach ( $ip4_ranges as $range ) {
188
- if ( $this->ipv4_in_range( $_SERVER['REMOTE_ADDR'], $range ) ) {
189
- $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
190
  break;
191
  }
192
  }
193
- } elseif ( !empty( $_SERVER["REMOTE_ADDR"] ) ) {
194
- $ip6_ranges = $this->_config->get_array( array(
195
- 'cloudflare', 'ips.ip6' ) );
196
- $ip6 = $this->get_ipv6_full( $_SERVER["REMOTE_ADDR"] );
 
 
 
 
197
  foreach ( $ip6_ranges as $range ) {
198
  if ( $this->ipv6_in_range( $ip6, $range ) ) {
199
- $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
200
  break;
201
  }
202
  }
178
  * Fix client's IP-address
179
  */
180
  private function fix_remote_addr() {
181
+ $remote_addr = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
182
+ $http_cf_connecting_ip = isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) : '';
183
+
184
+ if ( empty( $http_cf_connecting_ip ) ) {
185
  return;
186
+ }
187
 
188
+ if ( strpos( $remote_addr, ':' ) === false ) {
189
+ $ip4_ranges = $this->_config->get_array(
190
+ array(
191
+ 'cloudflare',
192
+ 'ips.ip4',
193
+ )
194
+ );
195
  foreach ( $ip4_ranges as $range ) {
196
+ if ( $this->ipv4_in_range( $remote_addr, $range ) ) {
197
+ $_SERVER['REMOTE_ADDR'] = $http_cf_connecting_ip;
198
  break;
199
  }
200
  }
201
+ } elseif ( ! empty( $remote_addr ) ) {
202
+ $ip6_ranges = $this->_config->get_array(
203
+ array(
204
+ 'cloudflare',
205
+ 'ips.ip6',
206
+ )
207
+ );
208
+ $ip6 = $this->get_ipv6_full( $remote_addr );
209
  foreach ( $ip6_ranges as $range ) {
210
  if ( $this->ipv6_in_range( $ip6, $range ) ) {
211
+ $_SERVER['REMOTE_ADDR'] = $http_cf_connecting_ip;
212
  break;
213
  }
214
  }
Extension_CloudFlare_Plugin_Admin.php CHANGED
@@ -5,157 +5,169 @@ class Extension_CloudFlare_Plugin_Admin {
5
  private $_config;
6
  private $api;
7
 
8
-
9
-
10
- static public function w3tc_extensions( $extensions, $config ) {
11
- $current_user = wp_get_current_user();
12
-
13
- $message = array();
14
- $message[] = 'CloudFlare';
15
  $cloudflare_signup_email = '';
16
- $cloudflare_signup_user = '';
17
 
18
  if ( is_a( $current_user, 'WP_User' ) ) {
19
  if ( $current_user->user_email ) {
20
  $cloudflare_signup_email = $current_user->user_email;
21
  }
22
 
23
- if ( $current_user->user_login && $current_user->user_login != 'admin' ) {
24
  $cloudflare_signup_user = $current_user->user_login;
25
  }
26
  }
27
- $extensions['cloudflare'] = array (
28
- 'name' => 'CloudFlare',
29
- 'author' => 'W3 EDGE',
30
- 'description' => sprintf( __( 'CloudFlare protects and accelerates websites. <a href="%s" target="_blank">Sign up now for free</a> to get started,
31
- or if you have an account simply log in to obtain your <abbr title="Application Programming Interface">API</abbr> key from the <a target="_blank" href="https://www.cloudflare.com/my-account">account page</a> to enter it on the General Settings box that appears after plugin activation.
32
- Contact the CloudFlare <a href="http://www.cloudflare.com/help.html" target="_blank">support team</a> with any questions.', 'w3-total-cache' ), 'https://www.cloudflare.com/sign-up.html?affiliate=w3edge&amp;seed_domain=' . Util_Environment::host() . '&amp;email=' . htmlspecialchars( $cloudflare_signup_email ) . '&amp;username=' . htmlspecialchars( $cloudflare_signup_user ) ),
33
- 'author_uri' => 'https://www.w3-edge.com/',
34
- 'extension_uri' => 'https://www.w3-edge.com/',
35
- 'extension_id' => 'cloudflare',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  'settings_exists' => true,
37
- 'version' => '0.3',
38
- 'enabled' => true,
39
- 'requirements' => implode( ', ', $message ),
40
- 'path' => 'w3-total-cache/Extension_CloudFlare_Plugin.php'
41
  );
42
 
43
  return $extensions;
44
  }
45
 
46
-
47
-
48
  function run() {
49
- $c = Dispatcher::config();
50
- $this->api = new Extension_CloudFlare_Api( array(
51
- 'email' => $c->get_string( array( 'cloudflare', 'email' ) ),
52
- 'key' => $c->get_string( array( 'cloudflare', 'key' ) ),
53
- 'zone_id' => $c->get_string( array( 'cloudflare', 'zone_id' ) ),
54
- 'timelimit_api_request' => $c->get_integer(
55
- array( 'cloudflare', 'timelimit.api_request' ) )
56
  )
57
  );
58
  $this->_config = $c;
59
 
60
- add_filter( 'w3tc_dashboard_actions',
61
- array( $this, 'w3tc_dashboard_actions' ) );
62
 
63
  $widget = new Extension_CloudFlare_Widget();
64
  $widget->init();
65
 
66
- // modify settings page
67
- add_filter( 'w3tc_ui_config_item_cdnfsd.enabled',
68
- array( $this, 'w3tc_ui_config_item_cdnfsd_enabled' ) );
69
- add_filter( 'w3tc_ui_config_item_cdnfsd.engine',
70
- array( $this, 'w3tc_ui_config_item_cdnfsd_engine' ) );
71
 
72
- add_filter( 'w3tc_settings_general_anchors',
73
- array( $this, 'w3tc_settings_general_anchors' ) );
74
- add_action( 'w3tc_settings_general_boxarea_cloudflare',
75
- array( $this, 'w3tc_settings_general_boxarea_cloudflare' ) );
76
 
77
- add_action( 'wp_ajax_w3tc_cloudflare_api_request',
78
- array( $this, 'action_cloudflare_api_request' ) );
79
 
80
- // modify main menu
81
  add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) );
82
 
83
- // dashboard
84
- add_action( 'admin_print_scripts-toplevel_page_w3tc_dashboard',
85
- array( $this, 'admin_print_scripts_w3tc_dashboard' ) );
86
  add_filter( 'w3tc_admin_actions', array( $this, 'w3tc_admin_actions' ) );
87
 
88
- // own settings page
89
- add_action( 'w3tc_extension_page_cloudflare', array(
90
- '\W3TC\Extension_CloudFlare_Page',
91
- 'w3tc_extension_page_cloudflare'
92
- ) );
93
- add_action( 'admin_print_scripts-performance_page_w3tc_extensions',
94
- array( '\W3TC\Extension_CloudFlare_Page',
95
- 'admin_print_scripts_w3tc_extensions'
96
- ) );
97
 
98
- add_action( 'w3tc_ajax',
99
- array( '\W3TC\Extension_CloudFlare_Popup', 'w3tc_ajax' ) );
100
 
101
  $cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
102
 
103
- if ( empty( $cdnfsd_engine ) || $cdnfsd_engine == 'cloudflare' ) {
104
- add_action( 'w3tc_settings_box_cdnfsd', array(
105
- '\W3TC\Extension_CloudFlare_Page',
106
- 'w3tc_settings_box_cdnfsd'
107
- ) );
108
- add_action( 'admin_print_scripts-performance_page_w3tc_cdn',
109
- array( '\W3TC\Extension_CloudFlare_Page',
110
- 'admin_print_scripts_w3tc_extensions'
111
- ) );
112
  }
113
 
114
- // add notices about api health
115
  if ( Util_Admin::is_w3tc_admin_page() ) {
116
- add_action( 'admin_notices', array(
117
- $this,
118
- 'admin_notices'
119
- ) );
120
- add_action( 'network_admin_notices', array(
121
- $this,
122
- 'admin_notices'
123
- ) );
124
  }
125
 
126
  $this->check_ip_versions();
127
  }
128
 
129
-
130
-
 
131
  public function admin_notices() {
132
  $plugins = get_plugins();
133
  if ( array_key_exists( 'cloudflare/cloudflare.php', $plugins ) && $this->_config->get_boolean( 'notes.cloudflare_plugin' ) ) {
134
-
135
- echo sprintf( '<div class="error"><p>%s %s</p></div>', __( 'CloudFlare plugin detected. We recommend removing the
136
- plugin as it offers no additional capabilities when W3 Total Cache is installed. This message will disappear
137
- when CloudFlare is removed.', 'w3-total-cache' ),
138
- Util_Ui::button_hide_note( 'Hide this message', 'cloudflare_plugin' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  );
140
  }
141
  }
142
 
143
-
144
-
145
  public function w3tc_admin_bar_menu( $menu_items ) {
146
  $menu_items['20810.cloudflare'] = array(
147
- 'id' => 'w3tc_flush_cloudflare',
148
  'parent' => 'w3tc_flush',
149
- 'title' => __( 'CloudFlare: All', 'w3-total-cache' ),
150
- 'href' => wp_nonce_url( admin_url(
151
- 'admin.php?page=w3tc_dashboard&amp;w3tc_cloudflare_flush' ), 'w3tc' )
152
  );
153
 
154
  return $menu_items;
155
  }
156
 
157
-
158
-
159
  /**
160
  * Check if last check has expired. If so update CloudFlare ips
161
  */
@@ -163,19 +175,20 @@ class Extension_CloudFlare_Plugin_Admin {
163
  $state = Dispatcher::config_state_master();
164
 
165
  if ( $state->get_integer( 'extension.cloudflare.next_ips_check' ) < time() ) {
166
- // update asap to avoid multiple processes entering the check
167
- $state->set( 'extension.cloudflare.next_ips_check',
168
- time() + 7 * 24 * 60 * 60 );
169
 
170
  $data = array();
171
  try {
172
  $data = $this->api->get_ip_ranges();
173
  } catch ( \Exception $ex ) {
 
174
  }
175
 
176
  if ( isset( $data['ip4'] ) ) {
177
  $state->set( 'extension.cloudflare.ips.ip4', $data['ip4'] );
178
  }
 
179
  if ( isset( $data['ip6'] ) ) {
180
  $state->set( 'extension.cloudflare.ips.ip6', $data['ip6'] );
181
  }
@@ -184,49 +197,45 @@ class Extension_CloudFlare_Plugin_Admin {
184
  }
185
  }
186
 
187
-
188
-
189
  /**
190
  * Send CloudFlare API request
191
  *
192
  * @return void
193
  */
194
  function action_cloudflare_api_request() {
195
- $result = false;
196
  $response = null;
197
-
198
- $actions = array(
199
  'dev_mode',
200
  'sec_lvl',
201
- 'fpurge_ts'
202
  );
203
-
204
- $email = Util_Request::get_string( 'email' );
205
- $key = Util_Request::get_string( 'key' );
206
- $zone = Util_Request::get_string( 'zone' );
207
- $action = Util_Request::get_string( 'command' );
208
- $value = Util_Request::get_string( 'value' );
209
- $nonce = Util_Request::get_string( '_wpnonce' );
210
-
211
- if ( !wp_verify_nonce( $nonce, 'w3tc' ) ) {
212
- $error ='Access denied.';
213
- } elseif ( !$email ) {
214
  $error = 'Empty email.';
215
- } elseif ( !filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
216
  $error = 'Invalid email.';
217
- } elseif ( !$key ) {
218
- $error = 'Empty key.';
219
- } elseif ( !$zone ) {
220
  $error = 'Empty zone.';
221
  } elseif ( strpos( $zone, '.' ) === false ) {
222
  $error = 'Invalid domain.';
223
- } elseif ( !in_array( $action, $actions ) ) {
224
  $error = 'Invalid action.';
225
  } else {
226
  $config = array(
227
  'email' => $email,
228
- 'key' => $key,
229
- 'zone' => $zone
230
  );
231
 
232
  @$this->api = new Extension_CloudFlare_Api( $config );
@@ -235,9 +244,9 @@ class Extension_CloudFlare_Plugin_Admin {
235
  $response = $this->api->api_request( $action, $value );
236
 
237
  if ( $response ) {
238
- if ( $response->result == 'success' ) {
239
  $result = true;
240
- $error = 'OK';
241
  } else {
242
  $error = $response->msg;
243
  }
@@ -247,17 +256,14 @@ class Extension_CloudFlare_Plugin_Admin {
247
  }
248
 
249
  $return = array(
250
- 'result' => $result,
251
- 'error' => $error,
252
- 'response' => $response
253
  );
254
 
255
- echo json_encode( $return );
256
- exit();
257
  }
258
 
259
-
260
-
261
  /**
262
  * W3TC Dashboard page modifications
263
  */
@@ -266,80 +272,79 @@ class Extension_CloudFlare_Plugin_Admin {
266
  return $handlers;
267
  }
268
 
269
-
270
-
271
  public function admin_print_scripts_w3tc_dashboard() {
272
- wp_enqueue_script( 'w3tc_extension_cloudflare_dashboard',
 
273
  plugins_url( 'Extension_CloudFlare_View_Dashboard.js', W3TC_FILE ),
274
- array( 'jquery' ), '1.0' );
 
 
 
275
  }
276
 
277
-
278
-
279
  public function w3tc_dashboard_actions( $actions ) {
280
  $email = $this->_config->get_string( array( 'cloudflare', 'email' ) );
281
- $key = $this->_config->get_string( array( 'cloudflare', 'key' ) );
282
 
283
- if ( empty( $email ) || empty( $key ) )
284
  return $actions;
 
285
 
286
- $modules = Dispatcher::component( 'ModuleStatus' );
287
  $can_empty_memcache = $modules->can_empty_memcache();
288
- $can_empty_opcode = $modules->can_empty_opcode();
289
- $can_empty_file = $modules->can_empty_file();
290
- $can_empty_varnish = $modules->can_empty_varnish();
291
-
292
- $actions[] = ' or <input id="flush_all_except_cf" class="button" type="submit" name="w3tc_cloudflare_flush_all_except_cf" value="'.
293
- __( 'empty all caches except CloudFlare', 'w3-total-cache' ).'"'.
294
- ( ( ! $can_empty_memcache && ! $can_empty_opcode && ! $can_empty_file && ! $can_empty_varnish ) ?
295
- 'disabled="disabled"':'' ) . '> ' . __( 'at once', 'w3-total-cache' );
296
- return $actions;
297
- }
298
 
 
 
 
 
 
 
299
 
 
 
300
 
301
  public function w3tc_ui_config_item_cdnfsd_enabled( $a ) {
302
- $c = Dispatcher::config();
303
  $cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
304
 
305
- // overwrite behavior if controlled by extension
306
- if ( empty( $cdnfsd_engine ) || $cdnfsd_engine == 'cloudflare' ) {
307
  $a['value'] = true;
308
  }
309
 
310
  return $a;
311
  }
312
 
313
-
314
-
315
  public function w3tc_ui_config_item_cdnfsd_engine( $a ) {
316
- $c = Dispatcher::config();
317
  $cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
318
 
319
- // overwrite behavior if controlled by extension
320
- if ( empty( $cdnfsd_engine ) || $cdnfsd_engine == 'cloudflare' ) {
321
  $a['value'] = 'cloudflare';
322
  }
323
 
324
  if ( isset( $a['selectbox_values']['cloudflare'] ) ) {
325
- $a['selectbox_values']['cloudflare']['label'] = 'CloudFlare';
326
  $a['selectbox_values']['cloudflare']['disabled'] = null;
327
  }
328
 
329
  return $a;
330
  }
331
 
332
-
333
-
334
  public function w3tc_settings_general_anchors( $anchors ) {
335
- $anchors[] = array( 'id' => 'cloudflare', 'text' => 'CloudFlare' );
 
 
 
336
  return $anchors;
337
  }
338
 
339
-
340
-
341
  public function w3tc_settings_general_boxarea_cloudflare() {
342
  $config = $this->_config;
343
- include W3TC_DIR . '/Extension_CloudFlare_GeneralPage_View.php';
344
  }
345
  }
5
  private $_config;
6
  private $api;
7
 
8
+ public static function w3tc_extensions( $extensions, $config ) {
9
+ $current_user = wp_get_current_user();
10
+ $message = array();
11
+ $message[] = 'CloudFlare';
 
 
 
12
  $cloudflare_signup_email = '';
13
+ $cloudflare_signup_user = '';
14
 
15
  if ( is_a( $current_user, 'WP_User' ) ) {
16
  if ( $current_user->user_email ) {
17
  $cloudflare_signup_email = $current_user->user_email;
18
  }
19
 
20
+ if ( $current_user->user_login && 'admin' !== $current_user->user_login ) {
21
  $cloudflare_signup_user = $current_user->user_login;
22
  }
23
  }
24
+
25
+ $extensions['cloudflare'] = array(
26
+ 'name' => 'CloudFlare',
27
+ 'author' => 'W3 EDGE',
28
+ 'description' => wp_kses(
29
+ sprintf(
30
+ // translators: 1 opening HTML a tag to CloudFlare signup page with affiliate association, 2 closing HTML a tag,
31
+ // translators: 3 opening HTML abbr tag, 4 closing HTML abbr tag,
32
+ // translators: 5 opening HTML a tag to CloudFlare account page, 6 closing HTML a tag,
33
+ // translators: 7 opening HTML a tag to CloudFlare help page, 8 closing HTML a tag.
34
+ __(
35
+ 'CloudFlare protects and accelerates websites. %1$sSign up now for free%2$s to get started, or if you have an account simply log in to obtain your %3$sAPI%4$s token / global key from the %5$saccount page%6$s to enter it on the General Settings box that appears after plugin activation. Contact the CloudFlare %7$ssupport team%8$s with any questions.',
36
+ 'w3-total-cache'
37
+ ),
38
+ '<a href="' . esc_url( 'https://www.cloudflare.com/sign-up.html?affiliate=w3edge&amp;seed_domain=' . Util_Environment::host() . '&amp;email=' . $cloudflare_signup_email . '&amp;username=' . $cloudflare_signup_user ) . '" target="_blank">',
39
+ '</a>',
40
+ '<abbr title="' . esc_attr__( 'Application Programming Interface', 'w3-total-cache' ) . '">',
41
+ '</abbr>',
42
+ '<a target="_blank" href="https://www.cloudflare.com/my-account">',
43
+ '</a>',
44
+ '<a href="http://www.cloudflare.com/help.html" target="_blank">',
45
+ '</a>'
46
+ ),
47
+ array(
48
+ 'a' => array(
49
+ 'href' => array(),
50
+ 'target' => array(),
51
+ ),
52
+ 'abbr' => array(
53
+ 'title' => array(),
54
+ ),
55
+ )
56
+ ),
57
+ 'author_uri' => 'https://www.w3-edge.com/',
58
+ 'extension_uri' => 'https://www.w3-edge.com/',
59
+ 'extension_id' => 'cloudflare',
60
  'settings_exists' => true,
61
+ 'version' => '0.3',
62
+ 'enabled' => true,
63
+ 'requirements' => implode( ', ', $message ),
64
+ 'path' => 'w3-total-cache/Extension_CloudFlare_Plugin.php',
65
  );
66
 
67
  return $extensions;
68
  }
69
 
 
 
70
  function run() {
71
+ $c = Dispatcher::config();
72
+ $this->api = new Extension_CloudFlare_Api(
73
+ array(
74
+ 'email' => $c->get_string( array( 'cloudflare', 'email' ) ),
75
+ 'key' => $c->get_string( array( 'cloudflare', 'key' ) ),
76
+ 'zone_id' => $c->get_string( array( 'cloudflare', 'zone_id' ) ),
77
+ 'timelimit_api_request' => $c->get_integer( array( 'cloudflare', 'timelimit.api_request' ) ),
78
  )
79
  );
80
  $this->_config = $c;
81
 
82
+ add_filter( 'w3tc_dashboard_actions', array( $this, 'w3tc_dashboard_actions' ) );
 
83
 
84
  $widget = new Extension_CloudFlare_Widget();
85
  $widget->init();
86
 
87
+ // modify settings page.
88
+ add_filter( 'w3tc_ui_config_item_cdnfsd.enabled', array( $this, 'w3tc_ui_config_item_cdnfsd_enabled' ) );
89
+ add_filter( 'w3tc_ui_config_item_cdnfsd.engine', array( $this, 'w3tc_ui_config_item_cdnfsd_engine' ) );
 
 
90
 
91
+ add_filter( 'w3tc_settings_general_anchors', array( $this, 'w3tc_settings_general_anchors' ) );
92
+ add_action( 'w3tc_settings_general_boxarea_cloudflare', array( $this, 'w3tc_settings_general_boxarea_cloudflare' ) );
 
 
93
 
94
+ add_action( 'wp_ajax_w3tc_cloudflare_api_request', array( $this, 'action_cloudflare_api_request' ) );
 
95
 
96
+ // modify main menu.
97
  add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) );
98
 
99
+ // dashboard.
100
+ add_action( 'admin_print_scripts-toplevel_page_w3tc_dashboard', array( $this, 'admin_print_scripts_w3tc_dashboard' ) );
 
101
  add_filter( 'w3tc_admin_actions', array( $this, 'w3tc_admin_actions' ) );
102
 
103
+ // own settings page.
104
+ add_action( 'w3tc_extension_page_cloudflare', array( '\W3TC\Extension_CloudFlare_Page', 'w3tc_extension_page_cloudflare' ) );
105
+ add_action( 'admin_print_scripts-performance_page_w3tc_extensions', array( '\W3TC\Extension_CloudFlare_Page', 'admin_print_scripts_w3tc_extensions' ) );
 
 
 
 
 
 
106
 
107
+ add_action( 'w3tc_ajax', array( '\W3TC\Extension_CloudFlare_Popup', 'w3tc_ajax' ) );
 
108
 
109
  $cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
110
 
111
+ if ( empty( $cdnfsd_engine ) || 'cloudflare' === $cdnfsd_engine ) {
112
+ add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Extension_CloudFlare_Page', 'w3tc_settings_box_cdnfsd' ) );
113
+ add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array( '\W3TC\Extension_CloudFlare_Page', 'admin_print_scripts_w3tc_extensions' ) );
 
 
 
 
 
 
114
  }
115
 
116
+ // add notices about api health.
117
  if ( Util_Admin::is_w3tc_admin_page() ) {
118
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
119
+ add_action( 'network_admin_notices', array( $this, 'admin_notices' ) );
 
 
 
 
 
 
120
  }
121
 
122
  $this->check_ip_versions();
123
  }
124
 
125
+ /**
126
+ * Admin notices.
127
+ */
128
  public function admin_notices() {
129
  $plugins = get_plugins();
130
  if ( array_key_exists( 'cloudflare/cloudflare.php', $plugins ) && $this->_config->get_boolean( 'notes.cloudflare_plugin' ) ) {
131
+ echo wp_kses(
132
+ sprintf(
133
+ // translators: 1 opening HTML div tag with class "error" followed by opening HTML p tag,
134
+ // translators: 2 HTML button with lable "Hide this message" that will hide the error message,
135
+ // translators: 3 closing HTML p tag followed by closing HTML div tag.
136
+ __(
137
+ '%1$sCloudFlare plugin detected. We recommend removing the plugin as it offers no additional capabilities when W3 Total Cache is installed. This message will disappear when CloudFlare is removed. %2$s%3$s',
138
+ 'w3-total-cache'
139
+ ),
140
+ '<div class="error"><p>',
141
+ Util_Ui::button_hide_note( 'Hide this message', 'cloudflare_plugin' ),
142
+ '</p></div>'
143
+ ),
144
+ array(
145
+ 'div' => array(
146
+ 'class' => array(),
147
+ ),
148
+ 'input' => array(
149
+ 'class' => array(),
150
+ 'value' => array(),
151
+ 'type' => array(),
152
+ 'onclick' => array(),
153
+ ),
154
+ 'p' => array(),
155
+ )
156
  );
157
  }
158
  }
159
 
 
 
160
  public function w3tc_admin_bar_menu( $menu_items ) {
161
  $menu_items['20810.cloudflare'] = array(
162
+ 'id' => 'w3tc_flush_cloudflare',
163
  'parent' => 'w3tc_flush',
164
+ 'title' => __( 'CloudFlare: All', 'w3-total-cache' ),
165
+ 'href' => wp_nonce_url( admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_cloudflare_flush' ), 'w3tc' ),
 
166
  );
167
 
168
  return $menu_items;
169
  }
170
 
 
 
171
  /**
172
  * Check if last check has expired. If so update CloudFlare ips
173
  */
175
  $state = Dispatcher::config_state_master();
176
 
177
  if ( $state->get_integer( 'extension.cloudflare.next_ips_check' ) < time() ) {
178
+ // update asap to avoid multiple processes entering the check.
179
+ $state->set( 'extension.cloudflare.next_ips_check', time() + 7 * 24 * 60 * 60 );
 
180
 
181
  $data = array();
182
  try {
183
  $data = $this->api->get_ip_ranges();
184
  } catch ( \Exception $ex ) {
185
+ // Missing exception handling?
186
  }
187
 
188
  if ( isset( $data['ip4'] ) ) {
189
  $state->set( 'extension.cloudflare.ips.ip4', $data['ip4'] );
190
  }
191
+
192
  if ( isset( $data['ip6'] ) ) {
193
  $state->set( 'extension.cloudflare.ips.ip6', $data['ip6'] );
194
  }
197
  }
198
  }
199
 
 
 
200
  /**
201
  * Send CloudFlare API request
202
  *
203
  * @return void
204
  */
205
  function action_cloudflare_api_request() {
206
+ $result = false;
207
  $response = null;
208
+ $actions = array(
 
209
  'dev_mode',
210
  'sec_lvl',
211
+ 'fpurge_ts',
212
  );
213
+ $email = Util_Request::get_string( 'email' );
214
+ $key = Util_Request::get_string( 'key' );
215
+ $zone = Util_Request::get_string( 'zone' );
216
+ $action = Util_Request::get_string( 'command' );
217
+ $value = Util_Request::get_string( 'value' );
218
+ $nonce = Util_Request::get_string( '_wpnonce' );
219
+
220
+ if ( ! wp_verify_nonce( $nonce, 'w3tc' ) ) {
221
+ $error = 'Access denied.';
222
+ } elseif ( ! $email ) {
 
223
  $error = 'Empty email.';
224
+ } elseif ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
225
  $error = 'Invalid email.';
226
+ } elseif ( ! $key ) {
227
+ $error = 'Empty token / global key.';
228
+ } elseif ( ! $zone ) {
229
  $error = 'Empty zone.';
230
  } elseif ( strpos( $zone, '.' ) === false ) {
231
  $error = 'Invalid domain.';
232
+ } elseif ( ! in_array( $action, $actions, true ) ) {
233
  $error = 'Invalid action.';
234
  } else {
235
  $config = array(
236
  'email' => $email,
237
+ 'key' => $key,
238
+ 'zone' => $zone,
239
  );
240
 
241
  @$this->api = new Extension_CloudFlare_Api( $config );
244
  $response = $this->api->api_request( $action, $value );
245
 
246
  if ( $response ) {
247
+ if ( 'success' === $response->result ) {
248
  $result = true;
249
+ $error = 'OK';
250
  } else {
251
  $error = $response->msg;
252
  }
256
  }
257
 
258
  $return = array(
259
+ 'result' => $result,
260
+ 'error' => $error,
261
+ 'response' => $response,
262
  );
263
 
264
+ wp_send_json( $return );
 
265
  }
266
 
 
 
267
  /**
268
  * W3TC Dashboard page modifications
269
  */
272
  return $handlers;
273
  }
274
 
 
 
275
  public function admin_print_scripts_w3tc_dashboard() {
276
+ wp_enqueue_script(
277
+ 'w3tc_extension_cloudflare_dashboard',
278
  plugins_url( 'Extension_CloudFlare_View_Dashboard.js', W3TC_FILE ),
279
+ array( 'jquery' ),
280
+ '1.0',
281
+ true
282
+ );
283
  }
284
 
 
 
285
  public function w3tc_dashboard_actions( $actions ) {
286
  $email = $this->_config->get_string( array( 'cloudflare', 'email' ) );
287
+ $key = $this->_config->get_string( array( 'cloudflare', 'key' ) );
288
 
289
+ if ( empty( $email ) || empty( $key ) ) {
290
  return $actions;
291
+ }
292
 
293
+ $modules = Dispatcher::component( 'ModuleStatus' );
294
  $can_empty_memcache = $modules->can_empty_memcache();
295
+ $can_empty_opcode = $modules->can_empty_opcode();
296
+ $can_empty_file = $modules->can_empty_file();
297
+ $can_empty_varnish = $modules->can_empty_varnish();
 
 
 
 
 
 
 
298
 
299
+ $actions[] = __( ' or ', 'w3-total-cache' ) . '<input id="flush_all_except_cf" class="button" type="submit"
300
+ name="w3tc_cloudflare_flush_all_except_cf" value="' . __( 'empty all caches except CloudFlare', 'w3-total-cache' ) . '"' .
301
+ (
302
+ ( ! $can_empty_memcache && ! $can_empty_opcode && ! $can_empty_file && ! esc_attr( $can_empty_varnish ) ) ?
303
+ 'disabled="disabled"' : ''
304
+ ) . '> at once';
305
 
306
+ return $actions;
307
+ }
308
 
309
  public function w3tc_ui_config_item_cdnfsd_enabled( $a ) {
310
+ $c = Dispatcher::config();
311
  $cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
312
 
313
+ // overwrite behavior if controlled by extension.
314
+ if ( empty( $cdnfsd_engine ) || 'cloudflare' === $cdnfsd_engine ) {
315
  $a['value'] = true;
316
  }
317
 
318
  return $a;
319
  }
320
 
 
 
321
  public function w3tc_ui_config_item_cdnfsd_engine( $a ) {
322
+ $c = Dispatcher::config();
323
  $cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
324
 
325
+ // overwrite behavior if controlled by extension.
326
+ if ( empty( $cdnfsd_engine ) || 'cloudflare' === $cdnfsd_engine ) {
327
  $a['value'] = 'cloudflare';
328
  }
329
 
330
  if ( isset( $a['selectbox_values']['cloudflare'] ) ) {
331
+ $a['selectbox_values']['cloudflare']['label'] = 'CloudFlare';
332
  $a['selectbox_values']['cloudflare']['disabled'] = null;
333
  }
334
 
335
  return $a;
336
  }
337
 
 
 
338
  public function w3tc_settings_general_anchors( $anchors ) {
339
+ $anchors[] = array(
340
+ 'id' => 'cloudflare',
341
+ 'text' => 'CloudFlare',
342
+ );
343
  return $anchors;
344
  }
345
 
 
 
346
  public function w3tc_settings_general_boxarea_cloudflare() {
347
  $config = $this->_config;
348
+ include W3TC_DIR . '/Extension_CloudFlare_GeneralPage_View.php';
349
  }
350
  }
Extension_CloudFlare_Popup.php CHANGED
@@ -1,107 +1,98 @@
1
  <?php
2
  namespace W3TC;
3
 
4
-
5
-
6
  class Extension_CloudFlare_Popup {
7
- static public function w3tc_ajax() {
8
  $o = new Extension_CloudFlare_Popup();
9
 
10
- add_action( 'w3tc_ajax_extension_cloudflare_intro',
11
- array( $o, 'w3tc_ajax_extension_cloudflare_intro' ) );
12
- add_action( 'w3tc_ajax_extension_cloudflare_intro_done',
13
- array( $o, 'w3tc_ajax_extension_cloudflare_intro_done' ) );
14
- add_action( 'w3tc_ajax_extension_cloudflare_zones_done',
15
- array( $o, 'w3tc_ajax_extension_cloudflare_zones_done' ) );
16
  }
17
 
18
-
19
-
20
  public function w3tc_ajax_extension_cloudflare_intro() {
21
- $c = Dispatcher::config();
22
-
23
  $details = array(
24
  'email' => $c->get_string( array( 'cloudflare', 'email' ) ),
25
- 'key' => $c->get_string( array( 'cloudflare', 'key' ) )
26
  );
27
 
28
- include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
29
  exit();
30
  }
31
 
32
-
33
-
34
  public function w3tc_ajax_extension_cloudflare_intro_done() {
35
- $this->_render_extension_cloudflare_zones( array(
36
- 'email' => $_REQUEST['email'],
37
- 'key' => $_REQUEST['key'],
38
- 'page' => empty( $_REQUEST['page'] ) ? 1 : (int) $_REQUEST['page']
 
39
  )
40
  );
41
  }
42
 
43
-
44
-
45
  private function _render_extension_cloudflare_zones( $details ) {
46
- $email = $details['email'];
47
- $key = $details['key'];
48
- $page = $details['page'];
49
-
50
  $details = array(
51
- 'email' => $email,
52
- 'key' => $key,
53
- 'page' => $page,
54
- 'zones' => array(),
55
- 'total_pages' => 1
56
  );
57
 
58
  try {
59
- $api = new Extension_CloudFlare_Api( array(
 
60
  'email' => $email,
61
- 'key' => $key ) );
62
- $r = $api->zones( $page );
63
- $details['zones'] = $r['result'];
64
-
 
65
  $details['total_pages'] = $r['result_info']['total_pages'];
66
  } catch ( \Exception $ex ) {
67
- $details['error_message'] = 'Can\'t authenticate: ' .
68
- $ex->getMessage();
69
- include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
70
  exit();
71
  }
72
 
73
- include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Zones.php';
74
  exit();
75
  }
76
 
77
-
78
-
79
  public function w3tc_ajax_extension_cloudflare_zones_done() {
80
- $email = $_REQUEST['email'];
81
- $key = $_REQUEST['key'];
82
  $zone_id = Util_Request::get( 'zone_id' );
83
 
84
  if ( empty( $zone_id ) ) {
85
- return $this->_render_extension_cloudflare_zones( array(
86
- 'email' => $email,
87
- 'key' => $key,
88
- 'error_message' => 'Please select zone'
89
- ) );
 
 
90
  }
91
 
92
  $zone_name = '';
93
 
94
- // get zone name
95
  try {
96
- $api = new Extension_CloudFlare_Api( array(
 
97
  'email' => $email,
98
- 'key' => $key ) );
99
- $zone = $api->zone($zone_id);
 
 
100
  $zone_name = $zone['name'];
101
  } catch ( \Exception $ex ) {
102
- $details['error_message'] = 'Can\'t authenticate: ' .
103
- $ex->getMessage();
104
- include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
105
  exit();
106
  }
107
 
@@ -115,12 +106,13 @@ class Extension_CloudFlare_Popup {
115
 
116
  delete_transient( 'w3tc_cloudflare_stats' );
117
 
118
- $postfix = Util_Admin::custom_message_id( array(),
 
119
  array(
120
- 'extension_cloudflare_configuration_saved' =>
121
- 'CloudFlare credentials are saved successfully' ) );
122
- echo 'Location admin.php?page=w3tc_extensions&extension=cloudflare&' .
123
- 'action=view&' . $postfix;
124
  exit();
125
  }
126
  }
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  class Extension_CloudFlare_Popup {
5
+ public static function w3tc_ajax() {
6
  $o = new Extension_CloudFlare_Popup();
7
 
8
+ add_action( 'w3tc_ajax_extension_cloudflare_intro', array( $o, 'w3tc_ajax_extension_cloudflare_intro' ) );
9
+ add_action( 'w3tc_ajax_extension_cloudflare_intro_done', array( $o, 'w3tc_ajax_extension_cloudflare_intro_done' ) );
10
+ add_action( 'w3tc_ajax_extension_cloudflare_zones_done', array( $o, 'w3tc_ajax_extension_cloudflare_zones_done' ) );
 
 
 
11
  }
12
 
 
 
13
  public function w3tc_ajax_extension_cloudflare_intro() {
14
+ $c = Dispatcher::config();
 
15
  $details = array(
16
  'email' => $c->get_string( array( 'cloudflare', 'email' ) ),
17
+ 'key' => $c->get_string( array( 'cloudflare', 'key' ) ),
18
  );
19
 
20
+ include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
21
  exit();
22
  }
23
 
 
 
24
  public function w3tc_ajax_extension_cloudflare_intro_done() {
25
+ $this->_render_extension_cloudflare_zones(
26
+ array(
27
+ 'email' => Util_Request::get_string( 'email' ),
28
+ 'key' => Util_Request::get_string( 'key' ),
29
+ 'page' => empty( Util_Request::get_integer( 'page' ) ) ? 1 : Util_Request::get_integer( 'page' ),
30
  )
31
  );
32
  }
33
 
 
 
34
  private function _render_extension_cloudflare_zones( $details ) {
35
+ $email = $details['email'];
36
+ $key = $details['key'];
37
+ $page = $details['page'];
 
38
  $details = array(
39
+ 'email' => $email,
40
+ 'key' => $key,
41
+ 'page' => $page,
42
+ 'zones' => array(),
43
+ 'total_pages' => 1,
44
  );
45
 
46
  try {
47
+ $api = new Extension_CloudFlare_Api(
48
+ array(
49
  'email' => $email,
50
+ 'key' => $key,
51
+ )
52
+ );
53
+ $r = $api->zones( $page );
54
+ $details['zones'] = $r['result'];
55
  $details['total_pages'] = $r['result_info']['total_pages'];
56
  } catch ( \Exception $ex ) {
57
+ $details['error_message'] = 'Can\'t authenticate: ' . $ex->getMessage();
58
+ include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
 
59
  exit();
60
  }
61
 
62
+ include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Zones.php';
63
  exit();
64
  }
65
 
 
 
66
  public function w3tc_ajax_extension_cloudflare_zones_done() {
67
+ $email = Util_Request::get_string( 'email' );
68
+ $key = Util_Request::get_string( 'key' );
69
  $zone_id = Util_Request::get( 'zone_id' );
70
 
71
  if ( empty( $zone_id ) ) {
72
+ return $this->_render_extension_cloudflare_zones(
73
+ array(
74
+ 'email' => $email,
75
+ 'key' => $key,
76
+ 'error_message' => 'Please select zone',
77
+ )
78
+ );
79
  }
80
 
81
  $zone_name = '';
82
 
83
+ // get zone name.
84
  try {
85
+ $api = new Extension_CloudFlare_Api(
86
+ array(
87
  'email' => $email,
88
+ 'key' => $key,
89
+ )
90
+ );
91
+ $zone = $api->zone( $zone_id );
92
  $zone_name = $zone['name'];
93
  } catch ( \Exception $ex ) {
94
+ $details['error_message'] = 'Can\'t authenticate: ' . $ex->getMessage();
95
+ include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
 
96
  exit();
97
  }
98
 
106
 
107
  delete_transient( 'w3tc_cloudflare_stats' );
108
 
109
+ $postfix = Util_Admin::custom_message_id(
110
+ array(),
111
  array(
112
+ 'extension_cloudflare_configuration_saved' => 'CloudFlare credentials are saved successfully',
113
+ )
114
+ );
115
+ echo 'Location admin.php?page=w3tc_extensions&extension=cloudflare&action=view&' . esc_attr( $postfix );
116
  exit();
117
  }
118
  }
Extension_CloudFlare_Popup_View_Intro.php CHANGED
@@ -1,33 +1,53 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form class="w3tc_extension_cloudflare_form" method="post" style="padding: 20px">
8
  <?php Util_Ui::hidden( '', 'w3tc_action', 'extension_cloudflare_intro_done' ); ?>
9
  <?php
10
- if ( isset( $details['error_message'] ) )
11
- echo '<div class="error">' . $details['error_message'] . '</div>';
12
- ?>
 
13
  <div class="metabox-holder">
14
- <?php Util_Ui::postbox_header(
15
- __( 'Your CloudFlare API key', 'w3-total-cache' ) ); ?>
16
  <table class="form-table">
17
  <tr>
18
- <th><?php _e( 'Email:', 'w3-total-cache' ) ?></td>
19
  <td>
20
  <input name="email" type="text" class="w3tc-ignore-change"
21
  style="width: 300px"
22
- value="<?php echo esc_attr( $details['email'] ) ?>" />
23
  </td>
24
  </tr>
25
  <tr>
26
- <th><?php _e( '<acronym title="Application Programming Interface">API</acronym> key:', 'w3-total-cache' ); ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  <td>
28
  <input name="key" type="text" class="w3tc-ignore-change"
29
  style="width: 550px"
30
- value="<?php echo esc_attr( $details['key'] ) ?>" />
31
  </td>
32
  </tr>
33
  </table>
@@ -35,7 +55,7 @@ if ( isset( $details['error_message'] ) )
35
  <p class="submit">
36
  <input type="button"
37
  class="w3tc_popup_submit w3tc-button-save button-primary"
38
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
39
  </p>
40
  <?php Util_Ui::postbox_footer(); ?>
41
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form class="w3tc_extension_cloudflare_form" method="post" style="padding: 20px">
9
  <?php Util_Ui::hidden( '', 'w3tc_action', 'extension_cloudflare_intro_done' ); ?>
10
  <?php
11
+ if ( isset( $details['error_message'] ) ) {
12
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
13
+ }
14
+ ?>
15
  <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Your CloudFlare API token / global key', 'w3-total-cache' ) ); ?>
 
17
  <table class="form-table">
18
  <tr>
19
+ <th><?php esc_html_e( 'Email:', 'w3-total-cache' ); ?></td>
20
  <td>
21
  <input name="email" type="text" class="w3tc-ignore-change"
22
  style="width: 300px"
23
+ value="<?php echo esc_attr( $details['email'] ); ?>" />
24
  </td>
25
  </tr>
26
  <tr>
27
+ <th>
28
+ <?php
29
+ echo wp_kses(
30
+ sprintf(
31
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
32
+ __(
33
+ '%1$sAPI%2$s token / global key:',
34
+ 'w3-total-cache'
35
+ ),
36
+ '<acronym title="' . esc_attr__( 'Application Programming Interface', 'w3-total-cache' ) . '">',
37
+ '</acronym>'
38
+ ),
39
+ array(
40
+ 'acronym' => array(
41
+ 'title' => array(),
42
+ ),
43
+ )
44
+ );
45
+ ?>
46
+ </td>
47
  <td>
48
  <input name="key" type="text" class="w3tc-ignore-change"
49
  style="width: 550px"
50
+ value="<?php echo esc_attr( $details['key'] ); ?>" />
51
  </td>
52
  </tr>
53
  </table>
55
  <p class="submit">
56
  <input type="button"
57
  class="w3tc_popup_submit w3tc-button-save button-primary"
58
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
59
  </p>
60
  <?php Util_Ui::postbox_footer(); ?>
61
  </div>
Extension_CloudFlare_Popup_View_Zones.php CHANGED
@@ -1,52 +1,63 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
8
  class="w3tc_extension_cloudflare_form">
9
  <?php
10
- Util_Ui::hidden( '', 'w3tc_action', 'extension_cloudflare_zones_done' );
11
- Util_Ui::hidden( '', 'email', $details['email'] );
12
- Util_Ui::hidden( '', 'key', $details['key'] );
13
- Util_Ui::hidden( '', 'page', '' );
14
- echo Util_Ui::nonce_field( 'w3tc' );
15
-
16
- ?>
 
 
 
 
 
 
 
 
17
  <?php
18
- if ( isset( $details['error_message'] ) )
19
- echo '<div class="error">' . $details['error_message'] . '</div>';
20
-
21
- ?>
22
  <div class="metabox-holder">
23
- <?php Util_Ui::postbox_header( __( 'Select zone', 'w3-total-cache' ) ); ?>
24
  <table class="form-table">
25
  <tr>
26
- <td>Zone:</td>
27
  <td>
28
- <?php foreach ( $details['zones'] as $z ): ?>
29
  <label>
30
  <input name="zone_id" type="radio" class="w3tc-ignore-change"
31
- value="<?php echo $z['id'] ?>" />
32
- <?php echo htmlspecialchars( $z['name'] ) ?>
33
  </label><br />
34
  <?php endforeach ?>
 
35
  </tr>
36
  <tr>
37
  <td></td>
38
  <td>
39
  <?php
40
- if ( $details['total_pages'] > 1 ):
41
- for ( $page = 1; $page <= $details['total_pages']; $page++ ):
42
- if ( $page == $details['page']):
43
- echo $page;
44
- else: ?>
45
- <a href="#" class="w3tc_cloudflare_zone_page" data-page="<?php echo $page ?>"><?php echo $page ?></a>
46
- <?php endif ?>
47
- &nbsp;
48
- <?php endfor ?>
49
- <?php endif ?>
 
50
  </td>
51
  </tr>
52
  </table>
@@ -54,7 +65,7 @@ if ( isset( $details['error_message'] ) )
54
  <p class="submit">
55
  <input type="button"
56
  class="w3tc_popup_submit w3tc-button-save button-primary"
57
- value="<?php _e( 'Next', 'w3-total-cache' ); ?>" />
58
  </p>
59
  <?php Util_Ui::postbox_footer(); ?>
60
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php?page=w3tc_cdn" method="post" style="padding: 20px"
9
  class="w3tc_extension_cloudflare_form">
10
  <?php
11
+ Util_Ui::hidden( '', 'w3tc_action', 'extension_cloudflare_zones_done' );
12
+ Util_Ui::hidden( '', 'email', $details['email'] );
13
+ Util_Ui::hidden( '', 'key', $details['key'] );
14
+ Util_Ui::hidden( '', 'page', '' );
15
+ echo wp_kses(
16
+ Util_Ui::nonce_field( 'w3tc' ),
17
+ array(
18
+ 'input' => array(
19
+ 'type' => array(),
20
+ 'name' => array(),
21
+ 'value' => array(),
22
+ ),
23
+ )
24
+ );
25
+ ?>
26
  <?php
27
+ if ( isset( $details['error_message'] ) ) {
28
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
29
+ }
30
+ ?>
31
  <div class="metabox-holder">
32
+ <?php Util_Ui::postbox_header( esc_html__( 'Select zone', 'w3-total-cache' ) ); ?>
33
  <table class="form-table">
34
  <tr>
35
+ <td><?php esc_html_e( 'Zone:', 'w3-total-cache' ); ?></td>
36
  <td>
37
+ <?php foreach ( $details['zones'] as $z ) : ?>
38
  <label>
39
  <input name="zone_id" type="radio" class="w3tc-ignore-change"
40
+ value="<?php echo esc_attr( $z['id'] ); ?>" />
41
+ <?php echo esc_html( $z['name'] ); ?>
42
  </label><br />
43
  <?php endforeach ?>
44
+ </td>
45
  </tr>
46
  <tr>
47
  <td></td>
48
  <td>
49
  <?php
50
+ if ( $details['total_pages'] > 1 ) :
51
+ for ( $page = 1; $page <= $details['total_pages']; $page++ ) :
52
+ if ( $page === $details['page'] ) :
53
+ echo esc_html( $page );
54
+ else :
55
+ echo '<a href="#" class="w3tc_cloudflare_zone_page" data-page="' . esc_attr( $page ) . '">' . esc_html( $page ) . '</a>';
56
+ endif;
57
+ echo '&nbsp;';
58
+ endfor;
59
+ endif;
60
+ ?>
61
  </td>
62
  </tr>
63
  </table>
65
  <p class="submit">
66
  <input type="button"
67
  class="w3tc_popup_submit w3tc-button-save button-primary"
68
+ value="<?php esc_attr_e( 'Next', 'w3-total-cache' ); ?>" />
69
  </p>
70
  <?php Util_Ui::postbox_footer(); ?>
71
  </div>
Extension_CloudFlare_SettingsForUi.php CHANGED
@@ -79,6 +79,9 @@ class Extension_CloudFlare_SettingsForUi {
79
  continue;
80
  if ( $value == '' )
81
  continue;
 
 
 
82
  $settings_key = substr( $key, strlen( $prefix ) );
83
 
84
  if ( !isset( $settings[$settings_key] ) ) {
79
  continue;
80
  if ( $value == '' )
81
  continue;
82
+
83
+ $value = Util_Request::get_string( $key );
84
+
85
  $settings_key = substr( $key, strlen( $prefix ) );
86
 
87
  if ( !isset( $settings[$settings_key] ) ) {
Extension_CloudFlare_Widget.php CHANGED
@@ -103,14 +103,14 @@ class Extension_CloudFlare_Widget {
103
  }
104
 
105
  private function date( $value ) {
106
- echo date( 'n/j/Y', strtotime( $value ) );
107
  }
108
 
109
  private function date_time( $value ) {
110
- echo date( 'n/j/Y g:i a', strtotime( $value ) );
111
  }
112
 
113
  private function date_time_sec( $value ) {
114
- echo date( 'n/j/Y g:i:s a', strtotime( $value ) );
115
  }
116
  }
103
  }
104
 
105
  private function date( $value ) {
106
+ echo esc_html( date( 'n/j/Y', strtotime( $value ) ) );
107
  }
108
 
109
  private function date_time( $value ) {
110
+ echo esc_html( date( 'n/j/Y g:i a', strtotime( $value ) ) );
111
  }
112
 
113
  private function date_time_sec( $value ) {
114
+ echo esc_html( date( 'n/j/Y g:i:s a', strtotime( $value ) ) );
115
  }
116
  }
Extension_CloudFlare_Widget_View.php CHANGED
@@ -1,61 +1,60 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- ?>
8
- <?php if ( is_null( $stats ) ): ?>
9
- <?php _e( 'You have not configured well email, API key or domain', 'w3-total-cache' ) ?>
10
- <?php else: ?>
 
 
 
 
 
 
 
 
11
 
12
- <p class="cloudflare_p">
13
- Period
14
- <?php
15
- if( $stats['interval'] >= -1440 ) {
16
- echo $this->date_time( $stats['since'] );
17
- } else {
18
- echo $this->date( $stats['since'] );
19
- }
20
- ?>
21
- -
22
- <?php
23
- if( $stats['interval'] >= -1440 ) {
24
- echo $this->date_time( $stats['until'] );
25
- } else {
26
- echo $this->date( $stats['until'] );
27
- }
28
- ?>
29
- </p>
30
- <table class="cloudflare_table">
31
- <tr>
32
- <td></td>
33
- <td class="cloudflare_td_header">All</td>
34
- <td class="cloudflare_td_header">Cached</td>
35
- </tr>
36
- <tr>
37
- <td class="cloudflare_td">Bandwidth</td>
38
- <?php $this->value( $stats['bandwidth_all'] ) ?>
39
- <?php $this->value( $stats['bandwidth_cached'] ) ?>
40
- </tr>
41
- <tr>
42
- <td class="cloudflare_td">Requests</td>
43
- <?php $this->value( $stats['requests_all'] ) ?>
44
- <?php $this->value( $stats['requests_cached'] ) ?>
45
- </tr>
46
- <tr>
47
- <td class="cloudflare_td">Page Views</td>
48
- <?php $this->value( $stats['pageviews_all'] ) ?>
49
- </tr>
50
- <tr>
51
- <td class="cloudflare_td">Uniques</td>
52
- <?php $this->value( $stats['uniques_all'] ) ?>
53
- </tr>
54
- <tr>
55
- <td class="cloudflare_td">Threats</td>
56
- <?php $this->value( $stats['threats_all'] ) ?>
57
- </tr>
58
- </table>
59
- <p class="cloudflare_p"><small>Statistics cached for <?php $this->value( $stats['cached_tf'] ) ?> minutes on <?php $this->date_time( $stats['cached_ts'] ) ?></small></p>
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  <?php endif; ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ if ( is_null( $stats ) ) :
9
+ esc_html_e( 'You have not configured well email, API token / global key or domain', 'w3-total-cache' );
10
+ else :
11
+ ?>
12
+ <p class="cloudflare_p">
13
+ Period
14
+ <?php
15
+ if ( $stats['interval'] >= -1440 ) {
16
+ echo esc_html( $this->date_time( $stats['since'] ) );
17
+ } else {
18
+ echo esc_html( $this->date( $stats['since'] ) );
19
+ }
20
 
21
+ echo ' - ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
+ if ( $stats['interval'] >= -1440 ) {
24
+ echo esc_html( $this->date_time( $stats['until'] ) );
25
+ } else {
26
+ echo esc_html( $this->date( $stats['until'] ) );
27
+ }
28
+ ?>
29
+ </p>
30
+ <table class="cloudflare_table">
31
+ <tr>
32
+ <td></td>
33
+ <td class="cloudflare_td_header">All</td>
34
+ <td class="cloudflare_td_header">Cached</td>
35
+ </tr>
36
+ <tr>
37
+ <td class="cloudflare_td">Bandwidth</td>
38
+ <?php $this->value( $stats['bandwidth_all'] ); ?>
39
+ <?php $this->value( $stats['bandwidth_cached'] ); ?>
40
+ </tr>
41
+ <tr>
42
+ <td class="cloudflare_td">Requests</td>
43
+ <?php $this->value( $stats['requests_all'] ); ?>
44
+ <?php $this->value( $stats['requests_cached'] ); ?>
45
+ </tr>
46
+ <tr>
47
+ <td class="cloudflare_td">Page Views</td>
48
+ <?php $this->value( $stats['pageviews_all'] ); ?>
49
+ </tr>
50
+ <tr>
51
+ <td class="cloudflare_td">Uniques</td>
52
+ <?php $this->value( $stats['uniques_all'] ); ?>
53
+ </tr>
54
+ <tr>
55
+ <td class="cloudflare_td">Threats</td>
56
+ <?php $this->value( $stats['threats_all'] ); ?>
57
+ </tr>
58
+ </table>
59
+ <p class="cloudflare_p"><small>Statistics cached for <?php $this->value( $stats['cached_tf'] ); ?> minutes on <?php $this->date_time( $stats['cached_ts'] ); ?></small></p>
60
  <?php endif; ?>
Extension_FeedBurner_Page_View.php CHANGED
@@ -1,37 +1,71 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <p>
9
- Jump to:
10
- <a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
- <a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a>
12
  </p>
13
  <p>
14
- FeedBurner extension is currently <?php
15
- if ( $config->is_extension_active_frontend( 'feedburner' ) )
16
- echo '<span class="w3tc-enabled">enabled</span>';
17
- else
18
- echo '<span class="w3tc-disabled">disabled</span>';
19
- ?>.
 
 
 
20
  <p>
21
 
22
  <div class="metabox-holder">
23
- <?php Util_Ui::postbox_header( __( 'Google FeedBurner', 'w3-total-cache' ) ); ?>
24
- <table class="form-table">
25
- <?php
26
- Util_Ui::config_item( array(
27
- 'key' => array( 'feedburner', 'urls' ),
28
- 'control' => 'textarea',
29
- 'label' => __( 'Additional <acronym title="Uniform Resource Locator">URL</acronym>s:', 'w3-total-cache' ),
30
- 'description' => __( 'Specify any additional feed <acronym title="Uniform Resource Locator">URL</acronym>s to ping on FeedBurner.',
31
- 'w3-total-cache' )
32
- ) )
33
- ?>
34
- </table>
35
- <?php Util_Ui::button_config_save( 'extension_feedburner' ); ?>
36
- <?php Util_Ui::postbox_footer(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <p>
9
+ Jump to:
10
+ <a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
+ <a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a>
12
  </p>
13
  <p>
14
+ FeedBurner extension is currently
15
+ <?php
16
+ if ( $config->is_extension_active_frontend( 'feedburner' ) ) {
17
+ echo '<span class="w3tc-enabled">enabled</span>';
18
+ } else {
19
+ echo '<span class="w3tc-disabled">disabled</span>';
20
+ }
21
+ ?>
22
+ .
23
  <p>
24
 
25
  <div class="metabox-holder">
26
+ <?php Util_Ui::postbox_header( esc_html__( 'Google FeedBurner', 'w3-total-cache' ) ); ?>
27
+ <table class="form-table">
28
+ <?php
29
+ Util_Ui::config_item(
30
+ array(
31
+ 'key' => array( 'feedburner', 'urls' ),
32
+ 'control' => 'textarea',
33
+ 'label' => wp_kses(
34
+ sprintf(
35
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
36
+ __(
37
+ 'Additional %1$sURL%2$ss:',
38
+ 'w3-total-cache'
39
+ ),
40
+ '<acronym title="' . esc_attr__( 'Uniform Resource Locator', 'w3-total-cache' ) . '">',
41
+ '</acronym>'
42
+ ),
43
+ array(
44
+ 'acronym' => array(
45
+ 'title' => array(),
46
+ ),
47
+ )
48
+ ),
49
+ 'description' => wp_kses(
50
+ sprintf(
51
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
52
+ __(
53
+ 'Specify any additional feed %1$sURL%2$ss to ping on FeedBurner.',
54
+ 'w3-total-cache'
55
+ ),
56
+ '<acronym title="' . esc_attr__( 'Uniform Resource Locator', 'w3-total-cache' ) . '">',
57
+ '</acronym>'
58
+ ),
59
+ array(
60
+ 'acronym' => array(
61
+ 'title' => array(),
62
+ ),
63
+ )
64
+ ),
65
+ )
66
+ );
67
+ ?>
68
+ </table>
69
+ <?php Util_Ui::button_config_save( 'extension_feedburner' ); ?>
70
+ <?php Util_Ui::postbox_footer(); ?>
71
  </div>
Extension_FragmentCache_Api.php CHANGED
@@ -69,7 +69,7 @@ function w3tc_fragmentcache_start( $id, $group = '', $hook = '' ) {
69
  _w3tc_caching_fragment( $id, $group );
70
  ob_start();
71
  } else {
72
- echo $fragment;
73
  if ( $hook ) {
74
  remove_all_filters($hook);
75
  }
69
  _w3tc_caching_fragment( $id, $group );
70
  ob_start();
71
  } else {
72
+ echo esc_html( $fragment );
73
  if ( $hook ) {
74
  remove_all_filters($hook);
75
  }
Extension_FragmentCache_GeneralPage_View.php CHANGED
@@ -1,26 +1,30 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
  Util_Ui::postbox_header( 'Fragment Cache', '', 'fragmentcache' );
8
  ?>
9
- <p><?php _e( 'Enable fragment caching reduce execution time for common operations.', 'w3-total-cache' ); ?></p>
10
 
11
  <table class="form-table">
12
- <?php
13
- Util_Ui::config_item_engine( array(
14
- 'key' => array( 'fragmentcache', 'engine' ),
15
- 'label' => __( 'Fragment Cache Method:', 'w3-total-cache' ),
16
- 'empty_value' => true
17
- ) );
18
- ?>
 
 
19
  </table>
20
 
21
  <?php
22
- Util_Ui::button_config_save( 'general_feedburner',
23
- '<input type="submit" name="w3tc_flush_fragmentcache" value="' .
24
- __( 'Empty cache', 'w3-total-cache' ) . '" class="button" />' );
 
25
  ?>
26
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
  Util_Ui::postbox_header( 'Fragment Cache', '', 'fragmentcache' );
9
  ?>
10
+ <p><?php esc_html_e( 'Enable fragment caching reduce execution time for common operations.', 'w3-total-cache' ); ?></p>
11
 
12
  <table class="form-table">
13
+ <?php
14
+ Util_Ui::config_item_engine(
15
+ array(
16
+ 'key' => array( 'fragmentcache', 'engine' ),
17
+ 'label' => __( 'Fragment Cache Method:', 'w3-total-cache' ),
18
+ 'empty_value' => true,
19
+ )
20
+ );
21
+ ?>
22
  </table>
23
 
24
  <?php
25
+ Util_Ui::button_config_save(
26
+ 'general_feedburner',
27
+ '<input type="submit" name="w3tc_flush_fragmentcache" value="' . __( 'Empty cache', 'w3-total-cache' ) . '" class="button" />'
28
+ );
29
  ?>
30
  <?php Util_Ui::postbox_footer(); ?>
Extension_FragmentCache_Page_View.php CHANGED
@@ -1,113 +1,121 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
  $engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
8
 
9
  ?>
10
  <p id="w3tc-options-menu">
11
- Jump to:
12
- <a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
13
- <a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a> |
14
- <a href="#overview"><?php _e( 'Overview', 'w3-total-cache' ); ?></a> |
15
- <a href="#advanced"><?php _e( 'Advanced', 'w3-total-cache' ); ?></a>
16
  </p>
17
  <p>
18
- <?php Util_Ui::pro_wrap_maybe_start2() ?>
19
 
20
- Fragment caching
21
- <?php if ( !empty( $engine ) ): ?>
22
- via
23
- <strong><?php echo Cache::engine_name( $engine ); ?></strong>
24
- <?php endif ?>
25
 
26
- is currently
27
- <?php if ( $config->is_extension_active_frontend( 'fragmentcache' ) ): ?>
28
- <span class="w3tc-enabled">enabled</span>
29
- <?php else: ?>
30
- <span class="w3tc-disabled">disabled</span>
31
  <?php
32
  $ext = Extensions_Util::get_extension( $config, 'fragmentcache' );
33
- if ( !empty( $ext['requirements'] ) ) {
34
- echo ' (<p class="description">' .
35
- $ext['requirements'] .
36
- '</p>)';
37
  }
38
  ?>
39
- <?php endif ?>
40
  .
41
 
42
- <?php Util_Ui::pro_wrap_maybe_end2('fragmentcache_header') ?>
43
  <p>
44
 
45
  <form action="admin.php?page=w3tc_fragmentcache" method="post">
46
  <p>
47
- <?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
48
- <input type="submit" name="w3tc_flush_fragmentcache" value="<?php _e( 'Empty the entire cache', 'w3-total-cache' ) ?>" class="button" />
49
- <?php _e( 'if needed.', 'w3-total-cache' ) ?>
 
 
 
 
 
 
 
 
 
 
 
50
  </p>
51
  </form>
52
 
53
  <form action="admin.php?page=w3tc_fragmentcache" method="post">
54
  <div class="metabox-holder">
55
- <?php Util_Ui::postbox_header( __( 'Overview', 'w3-total-cache' ), '', 'overview' ); ?>
56
  <table class="form-table">
57
  <tr>
58
- <th><?php _e( 'Registered fragment groups:', 'w3-total-cache' ); ?></th>
59
  <td>
60
- <?php if ( $registered_groups ): ?>
61
- <ul>
62
- <?php
63
- foreach ( $registered_groups as $group => $descriptor )
64
- echo '<li>', $group,
65
- ' (', $descriptor['expiration'], ' secs): ',
66
- implode( ',', $descriptor['actions'] ), '</li>';
67
- ?>
68
- </ul>
69
- <p class="description"><?php _e( 'The groups above will be flushed upon setting changes.', 'w3-total-cache' ); ?></p>
70
- <?php else: ?>
71
- <p class="description"><?php _e( 'No groups have been registered.', 'w3-total-cache' ); ?></p>
72
- <?php endif ?>
73
  </td>
74
  </tr>
75
  </table>
76
  <?php Util_Ui::postbox_footer(); ?>
77
 
78
- <?php Util_Ui::postbox_header( __( 'Advanced', 'w3-total-cache' ), '', 'advanced' ); ?>
79
  <table class="form-table">
80
  <?php
81
- if ( $config->get_string( array( 'fragmentcache', 'engine' ) ) == 'memcached' ) {
82
- $module = 'fragmentcache';
83
- include W3TC_INC_DIR . '/options/parts/memcached_extension.php';
84
- } elseif ( $config->get_string( array( 'fragmentcache', 'engine' ) ) == 'redis' ) {
85
- $module = 'fragmentcache';
86
- include W3TC_INC_DIR . '/options/parts/redis_extension.php';
87
- }
88
- ?>
89
-
90
  <tr>
91
- <th style="width: 250px;"><label for="fragmentcache_lifetime"><?php _e( 'Default lifetime of cached fragments:', 'w3-total-cache' ) ?></label></th>
92
  <td>
93
- <input id="fragmentcache_lifetime" type="text" <?php Util_Ui::sealing_disabled( 'fragmentcache.' ) ?> name="fragmentcache___lifetime" value="<?php echo esc_attr( $config->get_integer( array( 'fragmentcache', 'lifetime' ) ) ) ?>" size="8" /><?php _e( 'seconds', 'w3-total-cache' ) ?>
94
- <p class="description"><?php _e( 'Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.', 'w3-total-cache' ); ?></p>
95
  </td>
96
  </tr>
97
  <tr>
98
- <th><label for="fragmentcache_file_gc"><?php _e( 'Garbage collection interval:', 'w3-total-cache' ) ?></label></th>
99
  <td>
100
- <input id="fragmentcache_file_gc" type="text" <?php Util_Ui::sealing_disabled( 'fragmentcache.' ) ?> name="fragmentcache___file__gc" value="<?php echo esc_attr( $config->get_integer( array( 'fragmentcache', 'file.gc' ) ) ) ?>" size="8" /> <?php _e( 'seconds', 'w3-total-cache' ) ?>
101
- <p class="description"><?php _e( 'If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.', 'w3-total-cache' ); ?></p>
102
  </td>
103
  </tr>
104
  <tr>
105
- <th><label for="fragmentcache_groups"><?php _e( 'Manual fragment groups:', 'w3-total-cache' ) ?></label></th>
106
  <td>
107
  <textarea id="fragmentcache_groups" name="fragmentcache___groups"
108
- <?php Util_Ui::sealing_disabled( 'fragmentcache.' ) ?>
109
- cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $config->get_array( array( 'fragmentcache', 'groups' ) ) ) ); ?></textarea>
110
- <p class="description"><?php _e( 'Specify fragment groups that should be managed by W3 Total Cache. Enter one action per line comma delimited, e.g. (group, action1, action2). Include the prefix used for a transient by a theme or plugin.', 'w3-total-cache' ); ?></p>
111
  </td>
112
  </tr>
113
  </table>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
  $engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
9
 
10
  ?>
11
  <p id="w3tc-options-menu">
12
+ <?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
13
+ <a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
14
+ <a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a> |
15
+ <a href="#overview"><?php esc_html_e( 'Overview', 'w3-total-cache' ); ?></a> |
16
+ <a href="#advanced"><?php esc_html_e( 'Advanced', 'w3-total-cache' ); ?></a>
17
  </p>
18
  <p>
19
+ <?php Util_Ui::pro_wrap_maybe_start2(); ?>
20
 
21
+ <?php esc_html_e( 'Fragment caching', 'w3-total-cache' ); ?>
22
+ <?php if ( ! empty( $engine ) ) : ?>
23
+ <?php esc_html_e( 'via', 'w3-total-cache' ); ?>
24
+ <strong><?php echo esc_html( Cache::engine_name( $engine ) ); ?></strong>
25
+ <?php endif; ?>
26
 
27
+ <?php esc_html_e( 'is currently', 'w3-total-cache' ); ?>
28
+ <?php if ( $config->is_extension_active_frontend( 'fragmentcache' ) ) : ?>
29
+ <span class="w3tc-enabled"><?php esc_html_e( 'enabled', 'w3-total-cache' ); ?></span>
30
+ <?php else : ?>
31
+ <span class="w3tc-disabled"><?php esc_html_e( 'disabled', 'w3-total-cache' ); ?></span>
32
  <?php
33
  $ext = Extensions_Util::get_extension( $config, 'fragmentcache' );
34
+ if ( ! empty( $ext['requirements'] ) ) {
35
+ echo ' (<p class="description">' . esc_html( $ext['requirements'] ) . '</p>)';
 
 
36
  }
37
  ?>
38
+ <?php endif; ?>
39
  .
40
 
41
+ <?php Util_Ui::pro_wrap_maybe_end2( 'fragmentcache_header' ); ?>
42
  <p>
43
 
44
  <form action="admin.php?page=w3tc_fragmentcache" method="post">
45
  <p>
46
+ <?php
47
+ echo wp_kses(
48
+ Util_Ui::nonce_field( 'w3tc' ),
49
+ array(
50
+ 'input' => array(
51
+ 'type' => array(),
52
+ 'name' => array(),
53
+ 'value' => array(),
54
+ ),
55
+ )
56
+ );
57
+ ?>
58
+ <input type="submit" name="w3tc_flush_fragmentcache" value="<?php esc_attr_e( 'Empty the entire cache', 'w3-total-cache' ); ?>" class="button" />
59
+ <?php esc_html_e( 'if needed.', 'w3-total-cache' ); ?>
60
  </p>
61
  </form>
62
 
63
  <form action="admin.php?page=w3tc_fragmentcache" method="post">
64
  <div class="metabox-holder">
65
+ <?php Util_Ui::postbox_header( esc_html__( 'Overview', 'w3-total-cache' ), '', 'overview' ); ?>
66
  <table class="form-table">
67
  <tr>
68
+ <th><?php esc_html_e( 'Registered fragment groups:', 'w3-total-cache' ); ?></th>
69
  <td>
70
+ <?php if ( $registered_groups ) : ?>
71
+ <ul>
72
+ <?php
73
+ foreach ( $registered_groups as $group => $descriptor ) :
74
+ echo '<li>' . esc_html( $group ) . ' (' . esc_html( $descriptor['expiration'] ) . ' secs): ' . implode( ',', esc_html( $descriptor['actions'] ) ) . '</li>';
75
+ endforeach;
76
+ ?>
77
+ </ul>
78
+ <p class="description"><?php esc_html_e( 'The groups above will be flushed upon setting changes.', 'w3-total-cache' ); ?></p>
79
+ <?php else : ?>
80
+ <p class="description"><?php esc_html_e( 'No groups have been registered.', 'w3-total-cache' ); ?></p>
81
+ <?php endif; ?>
 
82
  </td>
83
  </tr>
84
  </table>
85
  <?php Util_Ui::postbox_footer(); ?>
86
 
87
+ <?php Util_Ui::postbox_header( esc_html__( 'Advanced', 'w3-total-cache' ), '', 'advanced' ); ?>
88
  <table class="form-table">
89
  <?php
90
+ if ( 'memcached' === $config->get_string( array( 'fragmentcache', 'engine' ) ) ) {
91
+ $module = 'fragmentcache';
92
+ include W3TC_INC_DIR . '/options/parts/memcached_extension.php';
93
+ } elseif ( 'redis' === $config->get_string( array( 'fragmentcache', 'engine' ) ) ) {
94
+ $module = 'fragmentcache';
95
+ include W3TC_INC_DIR . '/options/parts/redis_extension.php';
96
+ }
97
+ ?>
 
98
  <tr>
99
+ <th style="width: 250px;"><label for="fragmentcache_lifetime"><?php esc_html_e( 'Default lifetime of cached fragments:', 'w3-total-cache' ); ?></label></th>
100
  <td>
101
+ <input id="fragmentcache_lifetime" type="text" <?php Util_Ui::sealing_disabled( 'fragmentcache.' ); ?> name="fragmentcache___lifetime" value="<?php echo esc_attr( $config->get_integer( array( 'fragmentcache', 'lifetime' ) ) ); ?>" size="8" /><?php esc_html_e( 'seconds', 'w3-total-cache' ); ?>
102
+ <p class="description"><?php esc_html_e( 'Determines the natural expiration time of unchanged cache items. The higher the value, the larger the cache.', 'w3-total-cache' ); ?></p>
103
  </td>
104
  </tr>
105
  <tr>
106
+ <th><label for="fragmentcache_file_gc"><?php esc_html_e( 'Garbage collection interval:', 'w3-total-cache' ); ?></label></th>
107
  <td>
108
+ <input id="fragmentcache_file_gc" type="text" <?php Util_Ui::sealing_disabled( 'fragmentcache.' ); ?> name="fragmentcache___file__gc" value="<?php echo esc_attr( $config->get_integer( array( 'fragmentcache', 'file.gc' ) ) ); ?>" size="8" /> <?php esc_html_e( 'seconds', 'w3-total-cache' ); ?>
109
+ <p class="description"><?php esc_html_e( 'If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.', 'w3-total-cache' ); ?></p>
110
  </td>
111
  </tr>
112
  <tr>
113
+ <th><label for="fragmentcache_groups"><?php esc_html_e( 'Manual fragment groups:', 'w3-total-cache' ); ?></label></th>
114
  <td>
115
  <textarea id="fragmentcache_groups" name="fragmentcache___groups"
116
+ <?php Util_Ui::sealing_disabled( 'fragmentcache.' ); ?>
117
+ cols="40" rows="5"><?php echo esc_textarea( implode( "\r\n", $config->get_array( array( 'fragmentcache', 'groups' ) ) ) ); ?></textarea>
118
+ <p class="description"><?php esc_html_e( 'Specify fragment groups that should be managed by W3 Total Cache. Enter one action per line comma delimited, e.g. (group, action1, action2). Include the prefix used for a transient by a theme or plugin.', 'w3-total-cache' ); ?></p>
119
  </td>
120
  </tr>
121
  </table>
Extension_FragmentCache_Plugin.php CHANGED
@@ -90,6 +90,7 @@ class Extension_FragmentCache_Plugin {
90
  'memcached.persistent' => true,
91
  'redis.persistent' => true,
92
  'redis.servers' => array( '127.0.0.1:6379' ),
 
93
  'lifetime' => 180
94
  );
95
 
90
  'memcached.persistent' => true,
91
  'redis.persistent' => true,
92
  'redis.servers' => array( '127.0.0.1:6379' ),
93
+ 'redis.verify_tls_certificates' => true,
94
  'lifetime' => 180
95
  );
96
 
Extension_FragmentCache_WpObjectCache.php CHANGED
@@ -480,7 +480,11 @@ class Extension_FragmentCache_WpObjectCache {
480
  case 'redis':
481
  $engineConfig = array(
482
  'servers' => $this->_config->get_array( array( 'fragmentcache', 'redis.servers' ) ),
 
483
  'persistent' => $this->_config->get_boolean( array( 'fragmentcache', 'redis.persistent' ) ),
 
 
 
484
  'dbid' => $this->_config->get_integer( array( 'fragmentcache', 'redis.dbid' ) ),
485
  'password' => $this->_config->get_string( array( 'fragmentcache', 'redis.password' ) )
486
  );
480
  case 'redis':
481
  $engineConfig = array(
482
  'servers' => $this->_config->get_array( array( 'fragmentcache', 'redis.servers' ) ),
483
+ 'verify_tls_certificates' => $this->_config->get_boolean( array( 'fragmentcache', 'redis.verify_tls_certificates' ) ),
484
  'persistent' => $this->_config->get_boolean( array( 'fragmentcache', 'redis.persistent' ) ),
485
+ 'timeout' => $this->_config->get_integer( array( 'fragmentcache', 'redis.timeout' ) ),
486
+ 'retry_interval' => $this->_config->get_integer( array( 'fragmentcache', 'redis.retry_interval' ) ),
487
+ 'read_timeout' => $this->_config->get_integer( array( 'fragmentcache', 'redis.read_timeout' ) ),
488
  'dbid' => $this->_config->get_integer( array( 'fragmentcache', 'redis.dbid' ) ),
489
  'password' => $this->_config->get_string( array( 'fragmentcache', 'redis.password' ) )
490
  );
Extension_Genesis_Page_View.php CHANGED
@@ -1,242 +1,273 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <p id="w3tc-options-menu">
9
- Jump to:
10
- <a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
- <a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a> |
12
- <a href="#header"><?php _e( 'Header', 'w3-total-cache' ); ?></a> |
13
- <a href="#content"><?php _e( 'Content', 'w3-total-cache' ); ?></a> |
14
- <a href="#sidebar"><?php _e( 'Sidebar', 'w3-total-cache' ); ?></a> |
15
- <a href="#exclusions"><?php _e( 'Exclusions', 'w3-total-cache' ); ?></a>
16
  </p>
17
  <p>
18
- Genesis extension is currently <?php
19
- if ( $config->is_extension_active_frontend( 'genesis.theme' ) )
20
- echo '<span class="w3tc-enabled">enabled</span>';
21
- else
22
- echo '<span class="w3tc-disabled">disabled</span>';
23
- ?>.
 
 
 
24
  <p>
25
 
26
  <div class="metabox-holder">
27
- <?php Util_Ui::postbox_header( __( 'Header', 'w3-total-cache' ), '', 'header' ); ?>
28
  <table class="form-table">
29
  <?php
30
- Util_Ui::config_item( array(
31
- 'key' => array( 'genesis.theme', 'wp_head' ),
32
- 'control' => 'checkbox',
33
- 'label' => __( 'Cache wp_head loop:', 'w3-total-cache' ),
34
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
35
- 'description' =>__( 'Cache wp_head. This includes the embedded CSS, JS etc.', 'w3-total-cache' )
36
- ) );
37
- Util_Ui::config_item( array(
38
- 'key' => array( 'genesis.theme', 'genesis_header' ),
39
- 'control' => 'checkbox',
40
- 'label' => __( 'Cache header:', 'w3-total-cache' ),
41
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
42
- 'description' => __( 'Cache header loop. This is the area where the logo is located.', 'w3-total-cache' )
43
- ) );
44
- Util_Ui::config_item( array(
45
- 'key' => array( 'genesis.theme', 'genesis_do_nav' ),
46
- 'control' => 'checkbox',
47
- 'label' => __( 'Cache primary navigation:', 'w3-total-cache' ),
48
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
49
- 'description' => __( 'Caches the navigation filter; per page.', 'w3-total-cache' )
50
- ) );
51
- Util_Ui::config_item( array(
52
- 'key' => array( 'genesis.theme', 'genesis_do_subnav' ),
53
- 'control' => 'checkbox',
54
- 'label' => __( 'Cache secondary navigation:', 'w3-total-cache' ),
55
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
56
- 'description' => __( 'Caches secondary navigation filter; per page.', 'w3-total-cache' )
57
- ) );
58
-
59
- ?>
 
 
 
 
 
 
 
60
  </table>
61
  <?php Util_Ui::button_config_save( 'extension_genesis_header' ); ?>
62
  <?php Util_Ui::postbox_footer(); ?>
63
 
64
-
65
-
66
- <?php Util_Ui::postbox_header( __( 'Content', 'w3-total-cache' ), '', 'content' ); ?>
67
  <table class="form-table">
68
  <?php
69
- Util_Ui::config_item( array(
70
- 'key' => array( 'genesis.theme', 'loop_front_page' ),
71
- 'control' => 'checkbox',
72
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
73
- 'label' => __( 'Cache front page post loop:', 'w3-total-cache' ),
74
- 'description' => __( 'Caches the front page post loop, pagination is supported.', 'w3-total-cache' )
75
- ) );
76
- Util_Ui::config_item( array(
77
- 'key' => array( 'genesis.theme', 'loop_terms' ),
78
- 'control' => 'checkbox',
79
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
80
- 'label' => __( 'Cache author/tag/categories/term post loop:', 'w3-total-cache' ),
81
- 'description' => __( 'Caches the posts listed on tag, categories, author and other term pages, pagination is supported.', 'w3-total-cache' )
82
- ) );
83
- Util_Ui::config_item( array(
84
- 'key' => array( 'genesis.theme', 'loop_terms_excluded' ),
85
- 'control' => 'textarea',
86
- 'label' => __( 'Excluded terms pages / posts:', 'w3-total-cache' ),
87
- 'description' => __( 'List of pages / posts that should not have the terms loop cached. Specify one page / post per line. This area supports regular expressions.', 'w3-total-cache' )
88
- ) );
89
- Util_Ui::config_item( array(
90
- 'key' => array( 'genesis.theme', 'flush_terms' ),
91
- 'control' => 'checkbox',
92
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
93
- 'label' => __( 'Flush posts loop:', 'w3-total-cache' ),
94
- 'description' => __( 'Flushes the posts loop cache on post updates. See setting above for affected loops.', 'w3-total-cache' )
95
- ) );
96
- Util_Ui::config_item( array(
97
- 'key' => array( 'genesis.theme', 'loop_single' ),
98
- 'control' => 'checkbox',
99
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
100
- 'label' => __( 'Cache single post / page:', 'w3-total-cache' ),
101
- 'description' => __( 'Caches the single post / page loop, pagination is supported.', 'w3-total-cache' )
102
- ) );
103
- Util_Ui::config_item( array(
104
- 'key' => array( 'genesis.theme', 'loop_single_excluded' ),
105
- 'control' => 'textarea',
106
- 'label' => __( 'Excluded single pages / posts:', 'w3-total-cache' ),
107
- 'description' => __( 'List of pages / posts that should not have the single post / post loop cached. Specify one page / post per line. This area supports regular expressions.', 'w3-total-cache' )
108
- ) );
109
- Util_Ui::config_item( array(
110
- 'key' => array( 'genesis.theme', 'loop_single_genesis_comments' ),
111
- 'control' => 'checkbox',
112
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
113
- 'label' => __( 'Cache comments:', 'w3-total-cache' ),
114
- 'description' => __( 'Caches the comments loop, pagination is supported.', 'w3-total-cache' )
115
- ) );
116
- Util_Ui::config_item( array(
117
- 'key' => array( 'genesis.theme', 'loop_single_genesis_pings' ),
118
- 'control' => 'checkbox',
119
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
120
- 'label' => __( 'Cache pings:', 'w3-total-cache' ),
121
- 'description' => __( 'Caches the ping loop, pagination is supported. One per line.', 'w3-total-cache' )
122
- ) );
123
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  </table>
125
  <?php Util_Ui::button_config_save( 'extension_genesis_content' ); ?>
126
  <?php Util_Ui::postbox_footer(); ?>
127
 
128
-
129
-
130
- <?php Util_Ui::postbox_header( __( 'Sidebar', 'w3-total-cache' ), '', 'sidebar' ); ?>
131
  <table class="form-table">
132
  <?php
133
- Util_Ui::config_item( array(
134
- 'key' => array( 'genesis.theme', 'sidebar' ),
135
- 'control' => 'checkbox',
136
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
137
- 'label' => __( 'Cache sidebar:', 'w3-total-cache' ),
138
- 'description' => __( 'Caches sidebar loop, the widget area.', 'w3-total-cache' )
139
- ) );
140
- Util_Ui::config_item( array(
141
- 'key' => array( 'genesis.theme', 'sidebar_excluded' ),
142
- 'control' => 'textarea',
143
- 'label' => __( 'Exclude pages:', 'w3-total-cache' ),
144
- 'description' => __( 'List of pages that should not have sidebar cached. Specify one page / post per line. This area supports regular expressions.', 'w3-total-cache' )
145
- ) );
146
- ?>
 
 
 
 
147
  </table>
148
  <?php Util_Ui::button_config_save( 'extension_genesis_sidebar' ); ?>
149
  <?php Util_Ui::postbox_footer(); ?>
150
 
151
-
152
-
153
- <?php Util_Ui::postbox_header( __( 'Footer', 'w3-total-cache' ) ); ?>
154
  <table class="form-table">
155
  <?php
156
- Util_Ui::config_item( array(
157
- 'key' => array( 'genesis.theme', 'genesis_footer' ),
158
- 'control' => 'checkbox',
159
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
160
- 'label' => __( 'Cache genesis footer:', 'w3-total-cache' ),
161
- 'description' => __( 'Caches footer loop.', 'w3-total-cache' )
162
- ) );
163
- Util_Ui::config_item( array(
164
- 'key' => array( 'genesis.theme', 'wp_footer' ),
165
- 'control' => 'checkbox',
166
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
167
- 'label' => __( 'Cache footer:', 'w3-total-cache' ),
168
- 'description' => __( 'Caches wp_footer loop.', 'w3-total-cache' )
169
- ) );
170
- Util_Ui::config_item( array(
171
- 'key' => array( 'genesis.theme', 'reject_logged_roles' ),
172
- 'control' => 'checkbox',
173
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
174
- 'label' => __( 'Disable fragment cache:', 'w3-total-cache' ),
175
- 'description' => 'Don\'t use fragment cache with the following hooks and for the specified user roles.'
176
- ) );
177
- ?>
 
 
 
 
 
 
178
  </table>
179
  <?php Util_Ui::button_config_save( 'extension_genesis_footer' ); ?>
180
  <?php Util_Ui::postbox_footer(); ?>
181
 
182
-
183
- <?php Util_Ui::postbox_header( __( 'Exclusions', 'w3-total-cache' ), '', 'exclusions' ); ?>
184
  <table class="form-table">
185
  <tr>
186
- <td><?php _e( 'Select hooks', 'w3-total-cache' ) ?></td>
187
  <td>
188
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
- $saved_hooks = $config->get_array( array( 'genesis.theme', 'reject_logged_roles_on_actions' ) );
191
- $name = Util_Ui::config_key_to_http_name( array( 'genesis.theme', 'reject_logged_roles_on_actions' ) );
192
- $hooks = array(
193
- 'genesis_header' => 'Header',
194
- 'genesis_footer' => 'Footer',
195
- 'genesis_sidebar' => 'Sidebar',
196
- 'genesis_loop' =>'The Loop',
197
- 'wp_head' => 'wp_head',
198
- 'wp_footer' => 'wp_footer',
199
- 'genesis_comments' => 'Comments',
200
- 'genesis_pings' => 'Pings',
201
- 'genesis_do_nav'=>'Primary navigation',
202
- 'genesis_do_subnav' => 'Secondary navigation'
203
- );
204
- ?>
205
-
206
- <input <?php disabled( $config->is_sealed( 'genesis.theme' ) ) ?>
207
- type="hidden" name="<?php echo esc_attr( $name )?>" value="" />
208
  <?php foreach ( $hooks as $hook => $hook_label ) : ?>
209
- <input <?php disabled( $config->is_sealed( 'genesis.theme' ) ) ?>
210
- type="checkbox" name="<?php echo esc_attr( $name )?>[]"
211
- value="<?php echo $hook ?>"
212
- <?php checked( in_array( $hook, $saved_hooks ) ) ?>
213
- id="role_<?php echo $hook ?>" />
214
- <label for="role_<?php echo $hook ?>"><?php echo $hook_label ?></label><br />
 
 
215
  <?php endforeach; ?>
216
 
217
  <p class="description">
218
- <?php _e( 'Select hooks from the list that should not be cached if user belongs to any of the roles selected below.', 'w3-total-cache' ) ?>
219
  </p>
220
  </td>
221
  </tr>
222
  <tr>
223
- <td><?php _e( 'Select roles:', 'w3-total-cache' ) ?></td>
224
  <td>
225
  <?php
226
- $saved_roles = $config->get_array( array( 'genesis.theme', 'reject_roles' ) );
227
- $name = Util_Ui::config_key_to_http_name( array( 'genesis.theme', 'reject_roles' ) );
228
-
229
- ?>
230
- <input type="hidden" name="<?php echo esc_attr( $name )?>" value="" />
231
  <?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
232
- <input <?php disabled( $config->is_sealed( 'genesis.theme' ) ) ?>
233
- type="checkbox"
234
- name="<?php echo esc_attr( $name )?>[]"
235
- value="<?php echo $role_name ?>" <?php checked( in_array( $role_name, $saved_roles ) ) ?> id="role_<?php echo $role_name ?>" />
236
- <label for="role_<?php echo $role_name ?>"><?php echo $role_data['name'] ?></label>
 
 
 
237
  <?php endforeach; ?>
238
  <p class="description">
239
- <?php _e( 'Select user roles that should not use the fragment cache.', 'w3-total-cache' ) ?>
240
  </p>
241
  </td>
242
  </tr>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <p id="w3tc-options-menu">
9
+ <?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
10
+ <a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
+ <a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a> |
12
+ <a href="#header"><?php esc_html_e( 'Header', 'w3-total-cache' ); ?></a> |
13
+ <a href="#content"><?php esc_html_e( 'Content', 'w3-total-cache' ); ?></a> |
14
+ <a href="#sidebar"><?php esc_html_e( 'Sidebar', 'w3-total-cache' ); ?></a> |
15
+ <a href="#exclusions"><?php esc_html_e( 'Exclusions', 'w3-total-cache' ); ?></a>
16
  </p>
17
  <p>
18
+ <?php esc_html_e( 'Genesis extension is currently ', 'w3-total-cache' ); ?>
19
+ <?php
20
+ if ( $config->is_extension_active_frontend( 'genesis.theme' ) ) {
21
+ echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>';
22
+ } else {
23
+ echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>';
24
+ }
25
+ ?>
26
+ .
27
  <p>
28
 
29
  <div class="metabox-holder">
30
+ <?php Util_Ui::postbox_header( esc_html__( 'Header', 'w3-total-cache' ), '', 'header' ); ?>
31
  <table class="form-table">
32
  <?php
33
+ Util_Ui::config_item(
34
+ array(
35
+ 'key' => array( 'genesis.theme', 'wp_head' ),
36
+ 'control' => 'checkbox',
37
+ 'label' => esc_html__( 'Cache wp_head loop:', 'w3-total-cache' ),
38
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
39
+ 'description' => esc_html__( 'Cache wp_head. This includes the embedded CSS, JS etc.', 'w3-total-cache' ),
40
+ )
41
+ );
42
+ Util_Ui::config_item(
43
+ array(
44
+ 'key' => array( 'genesis.theme', 'genesis_header' ),
45
+ 'control' => 'checkbox',
46
+ 'label' => esc_html__( 'Cache header:', 'w3-total-cache' ),
47
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
48
+ 'description' => esc_html__( 'Cache header loop. This is the area where the logo is located.', 'w3-total-cache' ),
49
+ )
50
+ );
51
+ Util_Ui::config_item(
52
+ array(
53
+ 'key' => array( 'genesis.theme', 'genesis_do_nav' ),
54
+ 'control' => 'checkbox',
55
+ 'label' => esc_html__( 'Cache primary navigation:', 'w3-total-cache' ),
56
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
57
+ 'description' => esc_html__( 'Caches the navigation filter; per page.', 'w3-total-cache' ),
58
+ )
59
+ );
60
+ Util_Ui::config_item(
61
+ array(
62
+ 'key' => array( 'genesis.theme', 'genesis_do_subnav' ),
63
+ 'control' => 'checkbox',
64
+ 'label' => esc_html__( 'Cache secondary navigation:', 'w3-total-cache' ),
65
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
66
+ 'description' => esc_html__( 'Caches secondary navigation filter; per page.', 'w3-total-cache' ),
67
+ )
68
+ );
69
+ ?>
70
  </table>
71
  <?php Util_Ui::button_config_save( 'extension_genesis_header' ); ?>
72
  <?php Util_Ui::postbox_footer(); ?>
73
 
74
+ <?php Util_Ui::postbox_header( esc_html__( 'Content', 'w3-total-cache' ), '', 'content' ); ?>
 
 
75
  <table class="form-table">
76
  <?php
77
+ Util_Ui::config_item(
78
+ array(
79
+ 'key' => array( 'genesis.theme', 'loop_front_page' ),
80
+ 'control' => 'checkbox',
81
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
82
+ 'label' => esc_html__( 'Cache front page post loop:', 'w3-total-cache' ),
83
+ 'description' => esc_html__( 'Caches the front page post loop, pagination is supported.', 'w3-total-cache' ),
84
+ )
85
+ );
86
+ Util_Ui::config_item(
87
+ array(
88
+ 'key' => array( 'genesis.theme', 'loop_terms' ),
89
+ 'control' => 'checkbox',
90
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
91
+ 'label' => esc_html__( 'Cache author/tag/categories/term post loop:', 'w3-total-cache' ),
92
+ 'description' => esc_html__( 'Caches the posts listed on tag, categories, author and other term pages, pagination is supported.', 'w3-total-cache' ),
93
+ )
94
+ );
95
+ Util_Ui::config_item(
96
+ array(
97
+ 'key' => array( 'genesis.theme', 'loop_terms_excluded' ),
98
+ 'control' => 'textarea',
99
+ 'label' => esc_html__( 'Excluded terms pages / posts:', 'w3-total-cache' ),
100
+ 'description' => esc_html__( 'List of pages / posts that should not have the terms loop cached. Specify one page / post per line. This area supports regular expressions.', 'w3-total-cache' ),
101
+ )
102
+ );
103
+ Util_Ui::config_item(
104
+ array(
105
+ 'key' => array( 'genesis.theme', 'flush_terms' ),
106
+ 'control' => 'checkbox',
107
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
108
+ 'label' => esc_html__( 'Flush posts loop:', 'w3-total-cache' ),
109
+ 'description' => esc_html__( 'Flushes the posts loop cache on post updates. See setting above for affected loops.', 'w3-total-cache' ),
110
+ )
111
+ );
112
+ Util_Ui::config_item(
113
+ array(
114
+ 'key' => array( 'genesis.theme', 'loop_single' ),
115
+ 'control' => 'checkbox',
116
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
117
+ 'label' => esc_html__( 'Cache single post / page:', 'w3-total-cache' ),
118
+ 'description' => esc_html__( 'Caches the single post / page loop, pagination is supported.', 'w3-total-cache' ),
119
+ )
120
+ );
121
+ Util_Ui::config_item(
122
+ array(
123
+ 'key' => array( 'genesis.theme', 'loop_single_excluded' ),
124
+ 'control' => 'textarea',
125
+ 'label' => esc_html__( 'Excluded single pages / posts:', 'w3-total-cache' ),
126
+ 'description' => esc_html__( 'List of pages / posts that should not have the single post / post loop cached. Specify one page / post per line. This area supports regular expressions.', 'w3-total-cache' ),
127
+ )
128
+ );
129
+ Util_Ui::config_item(
130
+ array(
131
+ 'key' => array( 'genesis.theme', 'loop_single_genesis_comments' ),
132
+ 'control' => 'checkbox',
133
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
134
+ 'label' => esc_html__( 'Cache comments:', 'w3-total-cache' ),
135
+ 'description' => esc_html__( 'Caches the comments loop, pagination is supported.', 'w3-total-cache' ),
136
+ )
137
+ );
138
+ Util_Ui::config_item(
139
+ array(
140
+ 'key' => array( 'genesis.theme', 'loop_single_genesis_pings' ),
141
+ 'control' => 'checkbox',
142
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
143
+ 'label' => esc_html__( 'Cache pings:', 'w3-total-cache' ),
144
+ 'description' => esc_html__( 'Caches the ping loop, pagination is supported. One per line.', 'w3-total-cache' ),
145
+ )
146
+ );
147
+ ?>
148
  </table>
149
  <?php Util_Ui::button_config_save( 'extension_genesis_content' ); ?>
150
  <?php Util_Ui::postbox_footer(); ?>
151
 
152
+ <?php Util_Ui::postbox_header( esc_html__( 'Sidebar', 'w3-total-cache' ), '', 'sidebar' ); ?>
 
 
153
  <table class="form-table">
154
  <?php
155
+ Util_Ui::config_item(
156
+ array(
157
+ 'key' => array( 'genesis.theme', 'sidebar' ),
158
+ 'control' => 'checkbox',
159
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
160
+ 'label' => esc_html__( 'Cache sidebar:', 'w3-total-cache' ),
161
+ 'description' => esc_html__( 'Caches sidebar loop, the widget area.', 'w3-total-cache' ),
162
+ )
163
+ );
164
+ Util_Ui::config_item(
165
+ array(
166
+ 'key' => array( 'genesis.theme', 'sidebar_excluded' ),
167
+ 'control' => 'textarea',
168
+ 'label' => esc_html__( 'Exclude pages:', 'w3-total-cache' ),
169
+ 'description' => esc_html__( 'List of pages that should not have sidebar cached. Specify one page / post per line. This area supports regular expressions.', 'w3-total-cache' ),
170
+ )
171
+ );
172
+ ?>
173
  </table>
174
  <?php Util_Ui::button_config_save( 'extension_genesis_sidebar' ); ?>
175
  <?php Util_Ui::postbox_footer(); ?>
176
 
177
+ <?php Util_Ui::postbox_header( esc_html__( 'Footer', 'w3-total-cache' ) ); ?>
 
 
178
  <table class="form-table">
179
  <?php
180
+ Util_Ui::config_item(
181
+ array(
182
+ 'key' => array( 'genesis.theme', 'genesis_footer' ),
183
+ 'control' => 'checkbox',
184
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
185
+ 'label' => esc_html__( 'Cache genesis footer:', 'w3-total-cache' ),
186
+ 'description' => esc_html__( 'Caches footer loop.', 'w3-total-cache' ),
187
+ )
188
+ );
189
+ Util_Ui::config_item(
190
+ array(
191
+ 'key' => array( 'genesis.theme', 'wp_footer' ),
192
+ 'control' => 'checkbox',
193
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
194
+ 'label' => esc_html__( 'Cache footer:', 'w3-total-cache' ),
195
+ 'description' => esc_html__( 'Caches wp_footer loop.', 'w3-total-cache' ),
196
+ )
197
+ );
198
+ Util_Ui::config_item(
199
+ array(
200
+ 'key' => array( 'genesis.theme', 'reject_logged_roles' ),
201
+ 'control' => 'checkbox',
202
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
203
+ 'label' => esc_html__( 'Disable fragment cache:', 'w3-total-cache' ),
204
+ 'description' => esc_html__( 'Don\'t use fragment cache with the following hooks and for the specified user roles.' ),
205
+ )
206
+ );
207
+ ?>
208
  </table>
209
  <?php Util_Ui::button_config_save( 'extension_genesis_footer' ); ?>
210
  <?php Util_Ui::postbox_footer(); ?>
211
 
212
+ <?php Util_Ui::postbox_header( esc_html__( 'Exclusions', 'w3-total-cache' ), '', 'exclusions' ); ?>
 
213
  <table class="form-table">
214
  <tr>
215
+ <td><?php esc_html_e( 'Select hooks', 'w3-total-cache' ); ?></td>
216
  <td>
217
  <?php
218
+ $saved_hooks = $config->get_array( array( 'genesis.theme', 'reject_logged_roles_on_actions' ) );
219
+ $name = Util_Ui::config_key_to_http_name( array( 'genesis.theme', 'reject_logged_roles_on_actions' ) );
220
+ $hooks = array(
221
+ 'genesis_header' => esc_html__( 'Header', 'w3-total-cache' ),
222
+ 'genesis_footer' => esc_html__( 'Footer', 'w3-total-cache' ),
223
+ 'genesis_sidebar' => esc_html__( 'Sidebar', 'w3-total-cache' ),
224
+ 'genesis_loop' => esc_html__( 'The Loop', 'w3-total-cache' ),
225
+ 'wp_head' => 'wp_head',
226
+ 'wp_footer' => 'wp_footer',
227
+ 'genesis_comments' => esc_html__( 'Comments', 'w3-total-cache' ),
228
+ 'genesis_pings' => esc_html__( 'Pings', 'w3-total-cache' ),
229
+ 'genesis_do_nav' => esc_html__( 'Primary navigation', 'w3-total-cache' ),
230
+ 'genesis_do_subnav' => esc_html__( 'Secondary navigation', 'w3-total-cache' ),
231
+ );
232
+ ?>
233
 
234
+ <input <?php disabled( $config->is_sealed( 'genesis.theme' ) ); ?> type="hidden" name="<?php echo esc_attr( $name ); ?>" value="" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  <?php foreach ( $hooks as $hook => $hook_label ) : ?>
236
+ <input <?php disabled( $config->is_sealed( 'genesis.theme' ) ); ?>
237
+ type="checkbox" name="<?php echo esc_attr( $name ); ?>[]"
238
+ value="<?php echo esc_attr( $hook ); ?>"
239
+ <?php checked( in_array( $hook, $saved_hooks, true ) ); ?>
240
+ id="role_<?php echo esc_attr( $hook ); ?>" />
241
+ <label for="role_<?php echo esc_attr( $hook ); ?>">
242
+ <?php echo esc_html( $hook_label ); ?>
243
+ </label><br />
244
  <?php endforeach; ?>
245
 
246
  <p class="description">
247
+ <?php esc_html_e( 'Select hooks from the list that should not be cached if user belongs to any of the roles selected below.', 'w3-total-cache' ); ?>
248
  </p>
249
  </td>
250
  </tr>
251
  <tr>
252
+ <td><?php esc_html_e( 'Select roles:', 'w3-total-cache' ); ?></td>
253
  <td>
254
  <?php
255
+ $saved_roles = $config->get_array( array( 'genesis.theme', 'reject_roles' ) );
256
+ $name = Util_Ui::config_key_to_http_name( array( 'genesis.theme', 'reject_roles' ) );
257
+ ?>
258
+ <input type="hidden" name="<?php echo esc_attr( $name ); ?>" value="" />
 
259
  <?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
260
+ <input <?php disabled( $config->is_sealed( 'genesis.theme' ) ); ?>
261
+ type="checkbox" name="<?php echo esc_attr( $name ); ?>[]"
262
+ value="<?php echo esc_attr( $role_name ); ?>"
263
+ <?php checked( in_array( $role_name, $saved_roles, true ) ); ?>
264
+ id="role_<?php echo esc_attr( $role_name ); ?>" />
265
+ <label for="role_<?php echo esc_attr( $role_name ); ?>">
266
+ <?php echo esc_html( $role_data['name'] ); ?>
267
+ </label>
268
  <?php endforeach; ?>
269
  <p class="description">
270
+ <?php esc_html_e( 'Select user roles that should not use the fragment cache.', 'w3-total-cache' ); ?>
271
  </p>
272
  </td>
273
  </tr>
Extension_Genesis_Plugin.php CHANGED
@@ -43,7 +43,7 @@ class Extension_Genesis_Plugin {
43
  add_action( 'clean_post_cache', array( $this, 'flush_post_fragment' ) );
44
  add_action( 'clean_post_cache', array( $this, 'flush_terms_fragment' ), 0, 0 );
45
 
46
- $this->_request_uri = $_SERVER['REQUEST_URI'];
47
  }
48
  }
49
 
@@ -376,7 +376,7 @@ class Extension_Genesis_Plugin {
376
  }
377
  if ( is_front_page() )
378
  return 'front_page';
379
- return str_replace( '/', '-', trim( $_SERVER['REQUEST_URI'], "/" ) );
380
  }
381
 
382
  /**
43
  add_action( 'clean_post_cache', array( $this, 'flush_post_fragment' ) );
44
  add_action( 'clean_post_cache', array( $this, 'flush_terms_fragment' ), 0, 0 );
45
 
46
+ $this->_request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
47
  }
48
  }
49
 
376
  }
377
  if ( is_front_page() )
378
  return 'front_page';
379
+ return isset( $_SERVER['REQUEST_URI'] ) ? str_replace( '/', '-', trim( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' ) ) : '';
380
  }
381
 
382
  /**
Extension_ImageService_Page_View.php CHANGED
@@ -65,6 +65,7 @@ Util_Ui::config_item(
65
  'lossless' => 'Lossless',
66
  ),
67
  'description' => esc_html__( 'Image compression type.', 'w3-total-cache' ),
 
68
  )
69
  );
70
 
@@ -81,6 +82,25 @@ Util_Ui::config_item(
81
  'disabled' => 'Disabled',
82
  ),
83
  'description' => esc_html__( 'Auto-convert images on upload.', 'w3-total-cache' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  )
85
  );
86
  ?>
65
  'lossless' => 'Lossless',
66
  ),
67
  'description' => esc_html__( 'Image compression type.', 'w3-total-cache' ),
68
+ 'disabled' => false,
69
  )
70
  );
71
 
82
  'disabled' => 'Disabled',
83
  ),
84
  'description' => esc_html__( 'Auto-convert images on upload.', 'w3-total-cache' ),
85
+ 'disabled' => false,
86
+ )
87
+ );
88
+
89
+ Util_Ui::config_item(
90
+ array(
91
+ 'key' => array(
92
+ 'imageservice',
93
+ 'visibility',
94
+ ),
95
+ 'label' => esc_html__( 'Visibility:', 'w3-total-cache' ),
96
+ 'control' => 'selectbox',
97
+ 'selectbox_values' => array(
98
+ 'never' => array( 'label' => __( 'Never', 'w3-total-cache' ) ),
99
+ 'extension' => array( 'label' => __( 'If extension is active', 'w3-total-cache' ) ),
100
+ 'always' => array( 'label' => __( 'Always', 'w3-total-cache' ) ),
101
+ ),
102
+ 'description' => esc_html__( 'Show converted image attachments in the Media Library.', 'w3-total-cache' ),
103
+ 'disabled' => false,
104
  )
105
  );
106
  ?>
Extension_ImageService_Plugin_Admin.js CHANGED
@@ -435,6 +435,18 @@
435
  ) {
436
  message = response.responseJSON.data.message;
437
  rebindBuyClick = true;
 
 
 
 
 
 
 
 
 
 
 
 
438
  } else {
439
  message = w3tcData.lang.ajaxFail;
440
  }
435
  ) {
436
  message = response.responseJSON.data.message;
437
  rebindBuyClick = true;
438
+
439
+ if ( 'accept' === w3tcData.tos_choice && w3tcData.track_usage ) {
440
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
441
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
442
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
443
+ })(window,document,'script','https://api.w3-edge.com/v1/analytics','w3tc_ga');
444
+
445
+ if ( window.w3tc_ga ) {
446
+ w3tc_ga( 'create', w3tcData.ga_profile, 'auto' );
447
+ w3tc_ga( 'send', 'event', 'w3tc_error', 'imageservice', response.responseJSON.data.code );
448
+ }
449
+ }
450
  } else {
451
  message = w3tcData.lang.ajaxFail;
452
  }
Extension_ImageService_Plugin_Admin.php CHANGED
@@ -111,10 +111,6 @@ class Extension_ImageService_Plugin_Admin {
111
  'disabled_message' => '',
112
  'requirements' => '',
113
  'path' => 'w3-total-cache/Extension_ImageService_Plugin.php',
114
- 'extra_links' => array(
115
- '<a class="edit" href="' . $settings_url . '">' . esc_html__( 'Settings', 'w3-total-cache' ) . '</a>',
116
- '<a class="edit" href="' . $library_url . '">' . esc_html__( 'Media Library', 'w3-total-cache' ) . '</a>',
117
- ),
118
  'notice' => sprintf(
119
  // translators: 1: HTML anchor open tag, 2: HTML anchor close tag, 3: HTML anchor open tag, 4: HTML anchor open tag.
120
  __(
@@ -130,6 +126,14 @@ class Extension_ImageService_Plugin_Admin {
130
  ),
131
  );
132
 
 
 
 
 
 
 
 
 
133
  return $extensions;
134
  }
135
 
@@ -438,15 +442,20 @@ class Extension_ImageService_Plugin_Admin {
438
  delete_transient( 'w3tc_activation_imageservice' );
439
 
440
  // Save submitted settings.
441
- if ( isset( $_POST['_wpnonce'], $_POST['imageservice___compression'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'w3tc' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
442
- $settings = $c->get_array( 'imageservice' );
443
-
444
- if ( isset( $_POST['imageservice___compression'] ) ) {
445
- $settings['compression'] = sanitize_key( $_POST['imageservice___compression'] );
 
 
 
 
446
  }
447
 
448
- if ( isset( $_POST['imageservice___auto'] ) ) {
449
- $settings['auto'] = sanitize_key( $_POST['imageservice___auto'] );
 
450
  }
451
 
452
  $c->set( 'imageservice', $settings );
@@ -494,10 +503,14 @@ class Extension_ImageService_Plugin_Admin {
494
  * Runs on the "admin_enqueue_scripts" action.
495
  *
496
  * @since 2.2.0
 
 
 
497
  */
498
  public function admin_enqueue_scripts() {
499
  // Enqueue JavaScript for the Media Library (upload) and extension settings admin pages.
500
- $is_settings_page = isset( $_GET['page'] ) && 'w3tc_extension_page_imageservice' === $_GET['page']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
 
501
  $is_media_page = 'upload' === get_current_screen()->id;
502
 
503
  if ( $is_settings_page ) {
@@ -557,6 +570,9 @@ class Extension_ImageService_Plugin_Admin {
557
  '</a>'
558
  ),
559
  ),
 
 
 
560
  'settings' => $this->config->get_array( 'imageservice' ),
561
  'settingsUrl' => esc_url( Util_Ui::admin_url( 'upload.php?page=w3tc_extension_page_imageservice' ) ),
562
  )
@@ -821,14 +837,19 @@ class Extension_ImageService_Plugin_Admin {
821
  * @uses $_GET['w3tc_imageservice_invalid'] Number of invalid submissions.
822
  */
823
  public function display_notices() {
824
- // phpcs:disable WordPress.Security.NonceVerification.Recommended
825
- if ( isset( $_GET['w3tc_imageservice_submitted'] ) ) {
826
- $submitted = intval( $_GET['w3tc_imageservice_submitted'] );
827
- $successful = isset( $_GET['w3tc_imageservice_successful'] ) ? intval( $_GET['w3tc_imageservice_successful'] ) : 0;
828
- $skipped = isset( $_GET['w3tc_imageservice_skipped'] ) ? intval( $_GET['w3tc_imageservice_skipped'] ) : 0;
829
- $errored = isset( $_GET['w3tc_imageservice_errored'] ) ? intval( $_GET['w3tc_imageservice_errored'] ) : 0;
830
- $invalid = isset( $_GET['w3tc_imageservice_invalid'] ) ? intval( $_GET['w3tc_imageservice_invalid'] ) : 0;
831
- // phpcs:enable WordPress.Security.NonceVerification.Recommended
 
 
 
 
 
832
 
833
  ?>
834
  <script>history.pushState( null, '', location.href.split( '?' )[0] );</script>
@@ -875,7 +896,7 @@ class Extension_ImageService_Plugin_Admin {
875
  </div>
876
  <?php
877
 
878
- } elseif ( isset( $_GET['w3tc_imageservice_reverted'] ) ) { // phpcs:ignore
879
  ?>
880
  <script>history.pushState( null, '', location.href.split( '?' )[0] );</script>
881
 
@@ -1139,7 +1160,8 @@ class Extension_ImageService_Plugin_Admin {
1139
  );
1140
 
1141
  // Check for post id.
1142
- $post_id = isset( $_POST['post_id'] ) ? (int) sanitize_key( $_POST['post_id'] ) : null;
 
1143
 
1144
  if ( ! $post_id ) {
1145
  wp_send_json_error(
@@ -1222,7 +1244,8 @@ class Extension_ImageService_Plugin_Admin {
1222
  public function ajax_get_postmeta() {
1223
  check_ajax_referer( 'w3tc_imageservice_postmeta' );
1224
 
1225
- $post_id = isset( $_POST['post_id'] ) ? (int) sanitize_key( $_POST['post_id'] ) : null;
 
1226
 
1227
  if ( $post_id ) {
1228
  wp_send_json_success( (array) get_post_meta( $post_id, 'w3tc_imageservice', true ) );
@@ -1246,7 +1269,8 @@ class Extension_ImageService_Plugin_Admin {
1246
  public function ajax_revert() {
1247
  check_ajax_referer( 'w3tc_imageservice_revert' );
1248
 
1249
- $post_id = isset( $_POST['post_id'] ) ? (int) sanitize_key( $_POST['post_id'] ) : null;
 
1250
 
1251
  if ( $post_id ) {
1252
  $result = $this->remove_optimizations( $post_id );
111
  'disabled_message' => '',
112
  'requirements' => '',
113
  'path' => 'w3-total-cache/Extension_ImageService_Plugin.php',
 
 
 
 
114
  'notice' => sprintf(
115
  // translators: 1: HTML anchor open tag, 2: HTML anchor close tag, 3: HTML anchor open tag, 4: HTML anchor open tag.
116
  __(
126
  ),
127
  );
128
 
129
+ // The settings and Media Library links are only valid for single and network sites; not the admin section.
130
+ if ( ! is_network_admin() ) {
131
+ $extensions['imageservice']['extra_links'] = array(
132
+ '<a class="edit" href="' . $settings_url . '">' . esc_html__( 'Settings', 'w3-total-cache' ) . '</a>',
133
+ '<a class="edit" href="' . $library_url . '">' . esc_html__( 'Media Library', 'w3-total-cache' ) . '</a>',
134
+ );
135
+ }
136
+
137
  return $extensions;
138
  }
139
 
442
  delete_transient( 'w3tc_activation_imageservice' );
443
 
444
  // Save submitted settings.
445
+ $nonce_val = Util_Request::get_string( '_wpnonce' );
446
+ $imageservice_compression_val = Util_Request::get_string( 'imageservice___compression' );
447
+ if ( ! empty( $imageservice_compression_val ) && ! empty( $nonce_val ) && wp_verify_nonce( $nonce_val, 'w3tc' ) ) {
448
+ $settings = $c->get_array( 'imageservice' );
449
+ $settings['compression'] = $imageservice_compression_val;
450
+
451
+ $imageservice_auto_val = Util_Request::get_string( 'imageservice___auto' );
452
+ if ( ! empty( $imageservice_auto_val ) ) {
453
+ $settings['auto'] = $imageservice_auto_val;
454
  }
455
 
456
+ $imageservice_visibility_val = Util_Request::get_string( 'imageservice___visibility' );
457
+ if ( ! empty( $imageservice_visibility_val ) ) {
458
+ $settings['visibility'] = $imageservice_visibility_val;
459
  }
460
 
461
  $c->set( 'imageservice', $settings );
503
  * Runs on the "admin_enqueue_scripts" action.
504
  *
505
  * @since 2.2.0
506
+ *
507
+ * @see Util_Ui::admin_url()
508
+ * @see Licensing_Core::get_tos_choice()
509
  */
510
  public function admin_enqueue_scripts() {
511
  // Enqueue JavaScript for the Media Library (upload) and extension settings admin pages.
512
+ $page_val = Util_Request::get_string( 'page' );
513
+ $is_settings_page = ! empty( $page_val ) && 'w3tc_extension_page_imageservice' === $page_val;
514
  $is_media_page = 'upload' === get_current_screen()->id;
515
 
516
  if ( $is_settings_page ) {
570
  '</a>'
571
  ),
572
  ),
573
+ 'tos_choice' => Licensing_Core::get_tos_choice(),
574
+ 'track_usage' => $this->config->get_boolean( 'common.track_usage' ),
575
+ 'ga_profile' => ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) ? 'UA-2264433-7' : 'UA-2264433-8',
576
  'settings' => $this->config->get_array( 'imageservice' ),
577
  'settingsUrl' => esc_url( Util_Ui::admin_url( 'upload.php?page=w3tc_extension_page_imageservice' ) ),
578
  )
837
  * @uses $_GET['w3tc_imageservice_invalid'] Number of invalid submissions.
838
  */
839
  public function display_notices() {
840
+ $submitted = Util_Request::get_integer( 'w3tc_imageservice_submitted' );
841
+ if ( ! empty( $submitted ) ) {
842
+ $successful_val = Util_Request::get_integer( 'w3tc_imageservice_successful' );
843
+ $successful = ! empty( $successful_val ) ? $successful_val : 0;
844
+
845
+ $skipped_val = Util_Request::get_integer( 'w3tc_imageservice_skipped' );
846
+ $skipped = ! empty( $skipped_val ) ? $skipped_val : 0;
847
+
848
+ $errored_val = Util_Request::get_integer( 'w3tc_imageservice_errored' );
849
+ $errored = ! empty( $errored_val ) ? $errored_val : 0;
850
+
851
+ $invalid_val = Util_Request::get_integer( 'w3tc_imageservice_invalid' );
852
+ $invalid = ! empty( $invalid_val ) ? $invalid_val : 0;
853
 
854
  ?>
855
  <script>history.pushState( null, '', location.href.split( '?' )[0] );</script>
896
  </div>
897
  <?php
898
 
899
+ } elseif ( ! empty( Util_Request::get_string( 'w3tc_imageservice_reverted' ) ) ) {
900
  ?>
901
  <script>history.pushState( null, '', location.href.split( '?' )[0] );</script>
902
 
1160
  );
1161
 
1162
  // Check for post id.
1163
+ $post_id_val = Util_Request::get_integer( 'post_id' );
1164
+ $post_id = ! empty( $post_id_val ) ? $post_id_val : null;
1165
 
1166
  if ( ! $post_id ) {
1167
  wp_send_json_error(
1244
  public function ajax_get_postmeta() {
1245
  check_ajax_referer( 'w3tc_imageservice_postmeta' );
1246
 
1247
+ $post_id_val = Util_Request::get_integer( 'post_id' );
1248
+ $post_id = ! empty( $post_id_val ) ? $post_id_val : null;
1249
 
1250
  if ( $post_id ) {
1251
  wp_send_json_success( (array) get_post_meta( $post_id, 'w3tc_imageservice', true ) );
1269
  public function ajax_revert() {
1270
  check_ajax_referer( 'w3tc_imageservice_revert' );
1271
 
1272
+ $post_id_val = Util_Request::get_integer( 'post_id' );
1273
+ $post_id = ! empty( $post_id_val ) ? $post_id_val : null;
1274
 
1275
  if ( $post_id ) {
1276
  $result = $this->remove_optimizations( $post_id );
Extension_NewRelic_GeneralPage_View.php CHANGED
@@ -1,50 +1,89 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <?php
9
- Util_Ui::postbox_header( __( 'Monitoring', 'w3-total-cache' ), '', 'monitoring' );
10
- Util_Ui::config_overloading_button( array(
11
- 'key' => 'newrelic.configuration_overloaded'
12
- ) );
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; ?>
23
 
24
  <table class="form-table">
25
- <tr>
26
- <th>
27
- <label for="newrelic_api_key"><?php
28
- _e( '<acronym title="Application Programming Interface">API</acronym> key:', 'w3-total-cache' )
29
- ?></label>
30
- </th>
31
- <td class="w3tc-td-with-button">
32
- <?php echo htmlspecialchars( $config->get_string( array( 'newrelic', 'api_key' ) ) ) ?>
33
- <input type="button" class="button w3tcnr_configure" value="Configure"
34
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
35
- </td>
36
- </tr>
37
- <tr>
38
- <th>
39
- <label><?php _e( 'Application name:' , 'w3-total-cache' ) ?></label>
40
- </th>
41
- <td class="w3tc-td-with-button"><?php
42
- if ( $config->get_string( array( 'newrelic', 'monitoring_type' ) ) == 'browser' )
43
- echo '(browser) ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- echo htmlspecialchars( $effective_appname );
46
- ?></td>
47
- </tr>
 
48
  </table>
49
  <?php Util_Ui::button_config_save( 'general_newrelic' ); ?>
50
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <?php
9
+ Util_Ui::postbox_header( esc_html__( 'Monitoring', 'w3-total-cache' ), '', 'monitoring' );
10
+ Util_Ui::config_overloading_button( array( 'key' => 'newrelic.configuration_overloaded' ) );
 
 
11
  ?>
12
 
13
+ <?php if ( ! $new_relic_installed ) : ?>
14
+ <p>
15
+ <?php
16
+ echo wp_kses(
17
+ sprintf(
18
+ w3tc_er(
19
+ 'newrelic.general.header',
20
+ // translators: 1 opening HTML a tag to W3TC NewRelic Signup page, 2 closing HTML a tag,
21
+ // translators: 3 opening HTML a tag to NewRelic documentation for PHP, 4 closing HTML a tag.
22
+ __(
23
+ 'New Relic may not be installed or not active on this server. %1$sSign up for a (free) account%2$s. Visit %3$sNew Relic%4$s for installation instructions.',
24
+ 'w3-total-cache'
25
+ )
26
+ ),
27
+ '<a href="' . esc_url( W3TC_NEWRELIC_SIGNUP_URL ) . '" target="_blank">',
28
+ '</a>',
29
+ '<a href="' . esc_url( 'https://newrelic.com/docs/php/new-relic-for-php' ) . '" target="_blank">',
30
+ '</a>'
31
+ ),
32
+ array(
33
+ 'a' => array(
34
+ 'href' => array(),
35
+ 'target' => array(),
36
+ ),
37
+ )
38
+ );
39
+ ?>
40
+ </p>
41
  <?php endif; ?>
42
 
43
  <table class="form-table">
44
+ <tr>
45
+ <th>
46
+ <label for="newrelic_api_key">
47
+ <?php
48
+ echo wp_kses(
49
+ sprintf(
50
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
51
+ __(
52
+ '%1$sAPI%2$s key:',
53
+ 'w3-total-cache'
54
+ ),
55
+ '<acronym title="' . esc_attr__( 'Application Programming Interface', 'w3-total-cache' ) . '">',
56
+ '</acronym>'
57
+ ),
58
+ array(
59
+ 'acronym' => array(
60
+ 'title' => array(),
61
+ ),
62
+ )
63
+ );
64
+ ?>
65
+ </label>
66
+ </th>
67
+ <td class="w3tc-td-with-button">
68
+ <?php echo esc_html( $config->get_string( array( 'newrelic', 'api_key' ) ) ); ?>
69
+ <input type="button" class="button w3tcnr_configure" value="Configure"
70
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
71
+ </td>
72
+ </tr>
73
+ <tr>
74
+ <th>
75
+ <label><?php esc_html_e( 'Application name:', 'w3-total-cache' ); ?></label>
76
+ </th>
77
+ <td class="w3tc-td-with-button">
78
+ <?php
79
+ if ( 'browser' === $config->get_string( array( 'newrelic', 'monitoring_type' ) ) ) {
80
+ echo '(browser) ';
81
+ }
82
 
83
+ echo esc_html( $effective_appname );
84
+ ?>
85
+ </td>
86
+ </tr>
87
  </table>
88
  <?php Util_Ui::button_config_save( 'general_newrelic' ); ?>
89
  <?php Util_Ui::postbox_footer(); ?>
Extension_NewRelic_Page_View_Apm.php CHANGED
@@ -1,117 +1,190 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
  ?>
8
  <p>
9
  Jump to:
10
- <a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
- <a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a>
12
  </p>
13
  <p>
14
- NewRelic extension is currently <?php
15
- if ( $config->is_extension_active_frontend( 'newrelic' ) )
16
- echo '<span class="w3tc-enabled">enabled</span>';
17
- else
18
- echo '<span class="w3tc-disabled">disabled</span>';
19
- ?>.
 
 
 
20
  <p>
21
 
22
  <form action="admin.php?page=w3tc_monitoring" method="post">
23
- <div class="metabox-holder">
24
- <?php Util_Ui::postbox_header( __( 'Application Settings', 'w3-total-cache' ), '', 'application' ); ?>
25
- <?php if ( $application_settings ): ?>
26
- <table class="form-table">
27
- <tr>
28
- <th>
29
- <label>Application ID:</label>
30
- </th>
31
- <td>
32
- <?php esc_attr_e( $application_settings['application-id'] )?>
33
- </td>
34
- </tr>
35
- <tr>
36
- <th>
37
- <label>Application name:</label>
38
- </th>
39
- <td>
40
- <?php esc_attr_e( $application_settings['name'] )?>
41
- </td>
42
- </tr>
43
- <tr>
44
- <th>
45
- <label for="alerts-enabled">Alerts enabled:</label>
46
- </th>
47
- <td>
48
- <input name="alerts-enabled]" type="hidden" value="false" />
49
- <input id="alerts-enabled" name="application[alerts_enabled]"
50
- type="checkbox" value="1" <?php checked( $application_settings['alerts-enabled'], 'true' ) ?> <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
51
- </td>
52
- </tr>
53
- <tr>
54
- <th>
55
- <label for="app-apdex-t">Application ApDex Threshold:</label>
56
- </th>
57
- <td>
58
- <input id="app-apdex-t" name="application[app_apdex_t]" type="text"
59
- value="<?php echo esc_attr( $application_settings['app-apdex-t'] )?>"
60
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
61
- </td>
62
- </tr>
63
- <tr>
64
- <th>
65
- <label for="rum-apdex-t"><acronym title="Real User Monitoring">RUM</acronym> ApDex Threshold:</label>
66
- </th>
67
- <td>
68
- <input id="rum-apdex-t" name="application[rum_apdex_t]" type="text"
69
- value="<?php echo esc_attr( $application_settings['rum-apdex-t'] )?>"
70
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
71
- </td>
72
- </tr>
73
- <tr>
74
- <th>
75
- <label for="rum-enabled"><acronym title="Real User Monitoring">RUM</acronym> enabled:</label>
76
- </th>
77
- <td>
78
- <input name="application[rum_enabled]" type="hidden" value="false"
79
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
80
- <input id="rum-enabled" name="application[rum_enabled]"
81
- type="checkbox" value="1"
82
- <?php checked( $application_settings['rum-enabled'], 'true' ) ?>
83
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
84
- </td>
85
- </tr>
86
- </table>
87
- <p class="submit">
88
- <?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
89
- <input type="submit" name="w3tc_save_new_relic"
90
- class="w3tc-button-save button-primary"
91
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>
92
- value="Save New Relic settings" />
93
- </p>
94
- <?php elseif ( empty( $application_settings ) ): ?>
95
- <p class="description"><?php echo sprintf( __( 'Application settings could not be retrieved. New Relic may not be properly configured, <a href="%s">review the settings</a>.', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_general#monitoring' ) ) ?></p>
96
- <?php else: ?>
97
- <p><?php _e( 'Application settings are only visible when New Relic is enabled', 'w3-total-cache', 'w3-total-cache' ) ?></p>
98
- <?php endif; ?>
99
- <?php Util_Ui::postbox_footer(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  </form>
101
  <form action="admin.php?page=w3tc_monitoring" method="post">
102
 
103
- <?php Util_Ui::postbox_header( __( 'Dashboard Settings', 'w3-total-cache' ), '', 'dashboard' ); ?>
104
  <table class="form-table">
105
  <tr>
106
  <th>
107
- <label for="newrelic_cache_time"><?php
108
- _e( 'Cache time:', 'w3-total-cache' )
109
- ?></label></th>
 
110
  <td><input id="newrelic_cache_time" name="extension__newrelic__cache_time"
111
- type="text" value="<?php echo esc_attr( $config->get_integer( array( 'newrelic', 'cache_time', 5 ) ) ) ?>"
112
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
113
  <p class="description">
114
- <?php _e( 'How many minutes data retrieved from New Relic should be stored. Minimum is 1 minute.', 'w3-total-cache' ) ?>
115
  </p>
116
  </td>
117
  </tr>
@@ -119,97 +192,224 @@ _e( 'Cache time:', 'w3-total-cache' )
119
  <?php Util_Ui::button_config_save( 'extension_newrelic_dashboard' ); ?>
120
  <?php Util_Ui::postbox_footer(); ?>
121
 
122
- <?php Util_Ui::postbox_header( __( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
123
  <table class="form-table">
124
  <tr>
125
  <th colspan="2">
126
  <?php
127
- Util_Ui::checkbox( '',
128
- Util_Ui::config_key_to_http_name( array( 'newrelic', 'accept.logged_roles' ) ),
129
- $config->get_boolean( array( 'newrelic', 'accept.logged_roles' ) ),
130
- $config->is_sealed( 'newrelic' ) );
131
- _e( 'Use <acronym title="Real User Monitoring">RUM</acronym> only for following user roles', 'w3-total-cache' )
132
- ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  <p class="description">
134
- <?php _e( 'Select user roles that <acronym title="Real User Monitoring">RUM</acronym> should be enabled for:', 'w3-total-cache' ) ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  </p>
136
 
137
  <div id="newrelic_accept_roles" class="w3tc_reject_roles">
138
  <?php $saved_roles = $config->get_array( array( 'newrelic', 'accept.roles' ) ); ?>
139
  <input type="hidden" name="newrelic___accept__roles" value="" /><br />
140
  <?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
141
- <input type="checkbox" name="newrelic___accept__roles[]" value="<?php echo $role_name ?>"
142
- <?php checked( in_array( $role_name, $saved_roles ) ) ?>
143
- id="role_<?php echo $role_name ?>"
144
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
145
- <label for="role_<?php echo $role_name ?>"><?php echo $role_data['name'] ?></label>
146
  <?php endforeach; ?>
147
  </div>
148
  </th>
149
  </tr>
150
  <tr>
151
  <th>
152
- <label for="newrelic_include_rum"><?php
153
- _e( 'Include <acronym title="Real User Monitoring">RUM</acronym> in compressed or cached pages:', 'w3-total-cache' )
154
- ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  </th>
156
  <td>
157
  <input name="extension__newrelic__include_rum" type="hidden" value="0"
158
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
159
  <input id="newrelic_include_rum" name="extension__newrelic__include_rum"
160
  type="checkbox" value="1"
161
- <?php checked( $config->get_boolean( array( 'newrelic', 'include_rum' ) ) ) ?>
162
- <?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
163
  <p class="description">
164
- <?php _e( 'This enables inclusion of <acronym title="Real User Monitoring">RUM</acronym> when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced', 'w3-total-cache' )?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  </p>
166
  </td>
167
  </tr>
168
  <tr>
169
  <th>
170
- <label for="newrelic_use_php_function"><?php
171
- _e( 'Use <acronym title=\"Hypertext Preprocessor\">PHP</acronym> function to set application name:', 'w3-total-cache' )
172
- ?></label></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  <td>
174
- <?php if ( Util_Environment::is_wpmu() ): ?>
175
  <input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" checked="checked" disabled="disabled" />
176
  <p class="description">
177
- <?php _e( 'This is required when using New Relic on a network install to set the proper names for sites.', 'w3-total-cache' ) ?>
178
  </p>
179
- <?php else: ?>
180
  <input name="extension__newrelic__use_php_function" type="hidden" value="0" />
181
- <input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'use_php_function' ) ) ) ?>/>
182
  <p class="description">
183
- <?php _e( 'Enable this to dynamically set proper application name. (See New Relic <a href="https://newrelic.com/docs/php/per-directory-settings">Per-directory settings</a> for other methods.', 'w3-total-cache' ) ?>
184
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  <?php endif ?>
186
  </td>
187
  </tr>
188
  <tr>
189
  <th>
190
- <label for="newrelic_enable_xmit"><?php
191
- _e( 'Enable XMIT:', 'w3-total-cache' )
192
- ?></label>
 
 
193
  </th>
194
  <td><input name="" type="hidden" value="0" />
195
- <input id="newrelic_enable_xmit" name="extension__newrelic__enable_xmit" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'enable_xmit' ) ) ) ?> <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
196
- <p class="description"><?php _e( sprintf( 'Enable this if you want to record the metric and transaction data (until the name is changed using PHP function), specify a value of true for this argument to make the agent send the transaction to the daemon. There is a slight performance impact as it takes a few milliseconds for the agent to dump its data. <em>From %s</em>',
197
- '<a href="https://newrelic.com/docs/php/the-php-api">New Relic PHP API doc</a>' )
198
- , 'w3-total-cache' )?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  </td>
200
  </tr>
201
  </table>
202
  <?php Util_Ui::button_config_save( 'extension_newrelic_behaviour' ); ?>
203
  <?php Util_Ui::postbox_footer(); ?>
204
- </form>
205
- </div>
206
- <?php if ( $view_metric ):?>
207
  <table>
208
- <?php foreach ( $metric_names as $metric ):?>
209
  <tr>
210
- <th style="text-align: right"><strong><?php echo $metric->name ?></strong></th>
211
- <td><?php echo implode( ', ', $metric->fields ) ?></td>
212
  </tr>
213
- <?php endforeach; ?>
214
  </table>
215
  <?php endif; ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
  ?>
9
  <p>
10
  Jump to:
11
+ <a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
12
+ <a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a>
13
  </p>
14
  <p>
15
+ NewRelic extension is currently
16
+ <?php
17
+ if ( $config->is_extension_active_frontend( 'newrelic' ) ) {
18
+ echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>';
19
+ } else {
20
+ echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>';
21
+ }
22
+ ?>
23
+ .
24
  <p>
25
 
26
  <form action="admin.php?page=w3tc_monitoring" method="post">
27
+ <div class="metabox-holder">
28
+ <?php Util_Ui::postbox_header( esc_html__( 'Application Settings', 'w3-total-cache' ), '', 'application' ); ?>
29
+ <?php if ( $application_settings ) : ?>
30
+ <table class="form-table">
31
+ <tr>
32
+ <th>
33
+ <label><?php esc_html_e( 'Application ID:', 'w3-total-cache' ); ?></label>
34
+ </th>
35
+ <td>
36
+ <?php echo esc_html( $application_settings['application-id'] ); ?>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th>
41
+ <label><?php esc_html_e( 'Application name:', 'w3-total-cache' ); ?></label>
42
+ </th>
43
+ <td>
44
+ <?php echo esc_html( $application_settings['name'] ); ?>
45
+ </td>
46
+ </tr>
47
+ <tr>
48
+ <th>
49
+ <label for="alerts-enabled"><?php esc_html_e( 'Alerts enabled:', 'w3-total-cache' ); ?></label>
50
+ </th>
51
+ <td>
52
+ <input name="alerts-enabled]" type="hidden" value="false" />
53
+ <input id="alerts-enabled" name="application[alerts_enabled]"
54
+ type="checkbox" value="1" <?php checked( $application_settings['alerts-enabled'], 'true' ); ?> <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>/>
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <th>
59
+ <label for="app-apdex-t"><?php esc_html_e( 'Application ApDex Threshold:', 'w3-total-cache' ); ?></label>
60
+ </th>
61
+ <td>
62
+ <input id="app-apdex-t" name="application[app_apdex_t]" type="text"
63
+ value="<?php echo esc_attr( $application_settings['app-apdex-t'] ); ?>"
64
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
65
+ </td>
66
+ </tr>
67
+ <tr>
68
+ <th>
69
+ <label for="rum-apdex-t">
70
+ <?php
71
+ echo wp_kses(
72
+ sprintf(
73
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
74
+ __(
75
+ '%1$sRUM%2$s ApDex Threshold:',
76
+ 'w3-total-cache'
77
+ ),
78
+ '<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
79
+ '</acronym>'
80
+ ),
81
+ array(
82
+ 'acronym' => array(
83
+ 'title' => array(),
84
+ ),
85
+ )
86
+ );
87
+ ?>
88
+ </label>
89
+ </th>
90
+ <td>
91
+ <input id="rum-apdex-t" name="application[rum_apdex_t]" type="text"
92
+ value="<?php echo esc_attr( $application_settings['rum-apdex-t'] ); ?>"
93
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>/>
94
+ </td>
95
+ </tr>
96
+ <tr>
97
+ <th>
98
+ <label for="rum-enabled">
99
+ <?php
100
+ echo wp_kses(
101
+ sprintf(
102
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
103
+ __(
104
+ '%1$sRUM%2$s enabled:',
105
+ 'w3-total-cache'
106
+ ),
107
+ '<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
108
+ '</acronym>'
109
+ ),
110
+ array(
111
+ 'acronym' => array(
112
+ 'title' => array(),
113
+ ),
114
+ )
115
+ );
116
+ ?>
117
+ </label>
118
+ </th>
119
+ <td>
120
+ <input name="application[rum_enabled]" type="hidden" value="false"
121
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
122
+ <input id="rum-enabled" name="application[rum_enabled]"
123
+ type="checkbox" value="1"
124
+ <?php checked( $application_settings['rum-enabled'], 'true' ); ?>
125
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>/>
126
+ </td>
127
+ </tr>
128
+ </table>
129
+ <p class="submit">
130
+ <?php
131
+ echo wp_kses(
132
+ Util_Ui::nonce_field( 'w3tc' ),
133
+ array(
134
+ 'input' => array(
135
+ 'type' => array(),
136
+ 'name' => array(),
137
+ 'value' => array(),
138
+ ),
139
+ )
140
+ );
141
+ ?>
142
+ <input type="submit" name="w3tc_save_new_relic"
143
+ class="w3tc-button-save button-primary"
144
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>
145
+ value="<?php esc_attr_e( 'Save New Relic settings', 'w3-total-cache' ); ?>" />
146
+ </p>
147
+ <?php elseif ( empty( $application_settings ) ) : ?>
148
+ <p class="description">
149
+ <?php
150
+ echo wp_kses(
151
+ sprintf(
152
+ // translators: 1 opening HTML a tag to W3TC monitoring settings page, 2 closing HTML a tag.
153
+ __(
154
+ 'Application settings could not be retrieved. New Relic may not be properly configured, %1$sreview the settings%2$s.',
155
+ 'w3-total-cache'
156
+ ),
157
+ '<a href="' . esc_url( network_admin_url( 'admin.php?page=w3tc_general#monitoring' ) ) . '">',
158
+ '</a>'
159
+ ),
160
+ array(
161
+ 'a' => array(
162
+ 'href' => array(),
163
+ ),
164
+ )
165
+ );
166
+ ?>
167
+ </p>
168
+ <?php else : ?>
169
+ <p><?php esc_html_e( 'Application settings are only visible when New Relic is enabled', 'w3-total-cache' ); ?></p>
170
+ <?php endif; ?>
171
+ <?php Util_Ui::postbox_footer(); ?>
172
  </form>
173
  <form action="admin.php?page=w3tc_monitoring" method="post">
174
 
175
+ <?php Util_Ui::postbox_header( esc_html__( 'Dashboard Settings', 'w3-total-cache' ), '', 'dashboard' ); ?>
176
  <table class="form-table">
177
  <tr>
178
  <th>
179
+ <label for="newrelic_cache_time">
180
+ <?php esc_html_e( 'Cache time:', 'w3-total-cache' ); ?>
181
+ </label>
182
+ </th>
183
  <td><input id="newrelic_cache_time" name="extension__newrelic__cache_time"
184
+ type="text" value="<?php echo esc_attr( $config->get_integer( array( 'newrelic', 'cache_time', 5 ) ) ); ?>"
185
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
186
  <p class="description">
187
+ <?php esc_html_e( 'How many minutes data retrieved from New Relic should be stored. Minimum is 1 minute.', 'w3-total-cache' ); ?>
188
  </p>
189
  </td>
190
  </tr>
192
  <?php Util_Ui::button_config_save( 'extension_newrelic_dashboard' ); ?>
193
  <?php Util_Ui::postbox_footer(); ?>
194
 
195
+ <?php Util_Ui::postbox_header( esc_html__( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
196
  <table class="form-table">
197
  <tr>
198
  <th colspan="2">
199
  <?php
200
+ Util_Ui::checkbox(
201
+ '',
202
+ Util_Ui::config_key_to_http_name( array( 'newrelic', 'accept.logged_roles' ) ),
203
+ $config->get_boolean( array( 'newrelic', 'accept.logged_roles' ) ),
204
+ $config->is_sealed( 'newrelic' )
205
+ );
206
+ echo wp_kses(
207
+ sprintf(
208
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
209
+ __(
210
+ 'Use %1$sRUM%2$s only for following user roles',
211
+ 'w3-total-cache'
212
+ ),
213
+ '<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
214
+ '</acronym>'
215
+ ),
216
+ array(
217
+ 'acronym' => array(
218
+ 'title' => array(),
219
+ ),
220
+ )
221
+ );
222
+ ?>
223
+ </label>
224
  <p class="description">
225
+ <?php
226
+ echo wp_kses(
227
+ sprintf(
228
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
229
+ __(
230
+ 'Select user roles that %1$sRUM%2$s should be enabled for:',
231
+ 'w3-total-cache'
232
+ ),
233
+ '<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
234
+ '</acronym>'
235
+ ),
236
+ array(
237
+ 'acronym' => array(
238
+ 'title' => array(),
239
+ ),
240
+ )
241
+ );
242
+ ?>
243
  </p>
244
 
245
  <div id="newrelic_accept_roles" class="w3tc_reject_roles">
246
  <?php $saved_roles = $config->get_array( array( 'newrelic', 'accept.roles' ) ); ?>
247
  <input type="hidden" name="newrelic___accept__roles" value="" /><br />
248
  <?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
249
+ <input type="checkbox" name="newrelic___accept__roles[]" value="<?php echo esc_attr( $role_name ); ?>"
250
+ <?php checked( in_array( $role_name, $saved_roles, true ) ); ?>
251
+ id="role_<?php echo esc_attr( $role_name ); ?>"
252
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
253
+ <label for="role_<?php echo esc_attr( $role_name ); ?>"><?php echo esc_html( $role_data['name'] ); ?></label>
254
  <?php endforeach; ?>
255
  </div>
256
  </th>
257
  </tr>
258
  <tr>
259
  <th>
260
+ <label for="newrelic_include_rum">
261
+ <?php
262
+ wp_kses(
263
+ sprintf(
264
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
265
+ __(
266
+ 'Include %1$sRUM%2$s in compressed or cached pages:',
267
+ 'w3-total-cache'
268
+ ),
269
+ '<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
270
+ '</acronym>'
271
+ ),
272
+ array(
273
+ 'acronym' => array(
274
+ 'title' => array(),
275
+ ),
276
+ )
277
+ );
278
+ ?>
279
+ </label>
280
  </th>
281
  <td>
282
  <input name="extension__newrelic__include_rum" type="hidden" value="0"
283
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
284
  <input id="newrelic_include_rum" name="extension__newrelic__include_rum"
285
  type="checkbox" value="1"
286
+ <?php checked( $config->get_boolean( array( 'newrelic', 'include_rum' ) ) ); ?>
287
+ <?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
288
  <p class="description">
289
+ <?php
290
+ echo wp_kses(
291
+ sprintf(
292
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
293
+ __(
294
+ 'This enables inclusion of %1$sRUM%2$s when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced',
295
+ 'w3-total-cache'
296
+ ),
297
+ '<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
298
+ '</acronym>'
299
+ ),
300
+ array(
301
+ 'acronym' => array(
302
+ 'title' => array(),
303
+ ),
304
+ )
305
+ );
306
+ ?>
307
  </p>
308
  </td>
309
  </tr>
310
  <tr>
311
  <th>
312
+ <label for="newrelic_use_php_function">
313
+ <?php
314
+ echo wp_kses(
315
+ sprintf(
316
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
317
+ __(
318
+ 'Use %1$sPHP%2$s function to set application name:',
319
+ 'w3-total-cache'
320
+ ),
321
+ '<acronym title="' . esc_attr__( 'Hypertext Preprocessor', 'w3-total-cache' ) . '">',
322
+ '</acronym>'
323
+ ),
324
+ array(
325
+ 'acronym' => array(
326
+ 'title' => array(),
327
+ ),
328
+ )
329
+ );
330
+ ?>
331
+ </label>
332
+ </th>
333
  <td>
334
+ <?php if ( Util_Environment::is_wpmu() ) : ?>
335
  <input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" checked="checked" disabled="disabled" />
336
  <p class="description">
337
+ <?php esc_html_e( 'This is required when using New Relic on a network install to set the proper names for sites.', 'w3-total-cache' ); ?>
338
  </p>
339
+ <?php else : ?>
340
  <input name="extension__newrelic__use_php_function" type="hidden" value="0" />
341
+ <input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'use_php_function' ) ) ); ?>/>
342
  <p class="description">
343
+ <?php
344
+ echo wp_kses(
345
+ sprintf(
346
+ // translators: 1 opening HTML a tag to NewRelic per directory settings documentation, 2 closing HTML a tag.
347
+ __(
348
+ 'Enable this to dynamically set proper application name. (See New Relic %1$sPer-directory settings%2$s for other methods.',
349
+ 'w3-total-cache'
350
+ ),
351
+ '<a href="https://newrelic.com/docs/php/per-directory-settings">',
352
+ '</a>'
353
+ ),
354
+ array(
355
+ 'a' => array(
356
+ 'href' => array(),
357
+ ),
358
+ )
359
+ );
360
+ ?>
361
+ </p>
362
  <?php endif ?>
363
  </td>
364
  </tr>
365
  <tr>
366
  <th>
367
+ <label for="newrelic_enable_xmit">
368
+ <?php
369
+ esc_html_e( 'Enable XMIT:', 'w3-total-cache' )
370
+ ?>
371
+ </label>
372
  </th>
373
  <td><input name="" type="hidden" value="0" />
374
+ <input id="newrelic_enable_xmit" name="extension__newrelic__enable_xmit" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'enable_xmit' ) ) ); ?> <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>/>
375
+ <p class="description">
376
+ <?php
377
+ echo wp_kses(
378
+ sprintf(
379
+ // translators: 1 opening HTML em tag, 2 opening HTML a tag to NewRelic PHP API documentation,
380
+ // translators: 3 closing HTML a tag, 4 closing HTML em tag.
381
+ __(
382
+ 'Enable this if you want to record the metric and transaction data (until the name is changed using PHP function), specify a value of true for this argument to make the agent send the transaction to the daemon. There is a slight performance impact as it takes a few milliseconds for the agent to dump its data. %1$sFrom %2$sNew Relic PHP API doc%3$s%4$s',
383
+ 'w3-total-cache'
384
+ ),
385
+ '<em>',
386
+ '<a href="https://newrelic.com/docs/php/the-php-api">',
387
+ '</a>',
388
+ '</em>'
389
+ ),
390
+ array(
391
+ 'a' => array(
392
+ 'href' => array(),
393
+ ),
394
+ 'em' => array(),
395
+ )
396
+ );
397
+ ?>
398
+ </p>
399
  </td>
400
  </tr>
401
  </table>
402
  <?php Util_Ui::button_config_save( 'extension_newrelic_behaviour' ); ?>
403
  <?php Util_Ui::postbox_footer(); ?>
404
+ </div>
405
+ </form>
406
+ <?php if ( $view_metric ) : ?>
407
  <table>
408
+ <?php foreach ( $metric_names as $metric ) : ?>
409
  <tr>
410
+ <th style="text-align: right"><strong><?php echo esc_html( $metric->name ); ?></strong></th>
411
+ <td><?php echo esc_html( implode( ', ', $metric->fields ) ); ?></td>
412
  </tr>
413
+ <?php endforeach; ?>
414
  </table>
415
  <?php endif; ?>
Extension_NewRelic_Popup.php CHANGED
@@ -1,106 +1,93 @@
1
  <?php
2
  namespace W3TC;
3
 
4
-
5
-
6
  class Extension_NewRelic_Popup {
7
- static public function w3tc_ajax() {
8
  $o = new Extension_NewRelic_Popup();
9
 
10
- add_action( 'w3tc_ajax_newrelic_popup',
11
- array( $o, 'w3tc_ajax_newrelic_popup' ) );
12
- add_action( 'w3tc_ajax_newrelic_list_applications',
13
- array( $o, 'w3tc_ajax_newrelic_list_applications' ) );
14
- add_action( 'w3tc_ajax_newrelic_apply_configuration',
15
- array( $o, 'w3tc_ajax_newrelic_apply_configuration' ) );
16
  }
17
 
18
-
19
-
20
  public function w3tc_ajax_newrelic_popup() {
21
  $c = Dispatcher::config();
22
 
23
- $this->render_intro( array(
24
- 'api_key' => $c->get_string( array( 'newrelic', 'api_key' ) )
25
- ) );
 
 
26
  }
27
 
28
-
29
-
30
  private function render_intro( $details ) {
31
- include W3TC_DIR . '/Extension_NewRelic_Popup_View_Intro.php';
32
  }
33
 
34
-
35
-
36
  public function w3tc_ajax_newrelic_list_applications() {
37
- $api_key = $_REQUEST['api_key'];
38
-
39
- $c = Dispatcher::config();
40
  $details = array(
41
- 'api_key' => $api_key,
42
- 'monitoring_type' => $c->get_string( array(
43
- 'newrelic', 'monitoring_type' ) ),
44
- 'apm.application_name' => $c->get_string( array(
45
- 'newrelic', 'apm.application_name' ) ),
46
- 'browser.application_id' => $c->get_string( array(
47
- 'newrelic', 'browser.application_id' ) )
48
  );
49
- if ( $details['monitoring_type'] != 'browser' )
 
50
  $details['monitoring_type'] = 'apm';
 
51
 
52
  $service = new Extension_NewRelic_Service( $api_key );
53
 
54
  try {
55
- $details['apm_applications'] = $service->get_applications();
56
-
57
- $api = new Extension_NewRelic_Api( $api_key );
58
  $details['browser_applications'] = $api->get_browser_applications();
59
  } catch ( \Exception $ex ) {
60
  $details = array(
61
- 'api_key' => $api_key,
62
- 'error_message' => 'API key verification failed: ' .
63
- $ex->getMessage()
64
  );
65
  $this->render_intro( $details );
66
  return;
67
  }
68
 
69
- $details['browser_disabled'] = !Util_Environment::is_w3tc_pro( $c );
70
 
71
- include W3TC_DIR . '/Extension_NewRelic_Popup_View_ListApplications.php';
72
  }
73
 
74
-
75
-
76
  public function w3tc_ajax_newrelic_apply_configuration() {
77
- $api_key = $_REQUEST['api_key'];
78
- $monitoring_type = Util_Request::get( 'monitoring_type', 'apm' );
79
- $apm_application_name = Util_Request::get( 'apm_application_name' );
80
- $browser_application_id = Util_Request::get( 'browser_application_id' );
81
-
82
- $c = Dispatcher::config();
83
  $c->set( array( 'newrelic', 'api_key' ), $api_key );
84
 
85
- if ( $monitoring_type == 'apm' ) {
86
  $c->set( array( 'newrelic', 'monitoring_type' ), 'apm' );
87
  $c->set( array( 'newrelic', 'apm.application_name' ), $apm_application_name );
88
  } else {
89
  $c->set( array( 'newrelic', 'monitoring_type' ), 'browser' );
90
- $c->set( array( 'newrelic', 'browser.application_id' ),
91
- $browser_application_id );
92
  }
93
 
94
  $c->save();
95
 
96
- // flush cached values on api key change to allow to reset it from ui
97
- // if something goes wrong
98
  update_option( 'w3tc_nr_account_id', '' );
99
  update_option( 'w3tc_nr_application_id', '' );
100
 
101
- $postfix = Util_Admin::custom_message_id( array(),
102
- array( 'newrelic_configuration_saved' =>
103
- 'NewRelic configuration is saved successfully' ) );
104
- echo 'Location admin.php?page=w3tc_general&' . $postfix;
 
 
 
 
105
  }
106
  }
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  class Extension_NewRelic_Popup {
5
+ public static function w3tc_ajax() {
6
  $o = new Extension_NewRelic_Popup();
7
 
8
+ add_action( 'w3tc_ajax_newrelic_popup', array( $o, 'w3tc_ajax_newrelic_popup' ) );
9
+ add_action( 'w3tc_ajax_newrelic_list_applications', array( $o, 'w3tc_ajax_newrelic_list_applications' ) );
10
+ add_action( 'w3tc_ajax_newrelic_apply_configuration', array( $o, 'w3tc_ajax_newrelic_apply_configuration' ) );
 
 
 
11
  }
12
 
 
 
13
  public function w3tc_ajax_newrelic_popup() {
14
  $c = Dispatcher::config();
15
 
16
+ $this->render_intro(
17
+ array(
18
+ 'api_key' => $c->get_string( array( 'newrelic', 'api_key' ) ),
19
+ )
20
+ );
21
  }
22
 
 
 
23
  private function render_intro( $details ) {
24
+ include W3TC_DIR . '/Extension_NewRelic_Popup_View_Intro.php';
25
  }
26
 
 
 
27
  public function w3tc_ajax_newrelic_list_applications() {
28
+ $api_key = Util_Request::get_string( 'api_key' );
29
+ $c = Dispatcher::config();
 
30
  $details = array(
31
+ 'api_key' => $api_key,
32
+ 'monitoring_type' => $c->get_string( array( 'newrelic', 'monitoring_type' ) ),
33
+ 'apm.application_name' => $c->get_string( array( 'newrelic', 'apm.application_name' ) ),
34
+ 'browser.application_id' => $c->get_string( array( 'newrelic', 'browser.application_id' ) ),
 
 
 
35
  );
36
+
37
+ if ( 'browser' !== $details['monitoring_type'] ) {
38
  $details['monitoring_type'] = 'apm';
39
+ }
40
 
41
  $service = new Extension_NewRelic_Service( $api_key );
42
 
43
  try {
44
+ $api = new Extension_NewRelic_Api( $api_key );
45
+ $details['apm_applications'] = $service->get_applications();
 
46
  $details['browser_applications'] = $api->get_browser_applications();
47
  } catch ( \Exception $ex ) {
48
  $details = array(
49
+ 'api_key' => $api_key,
50
+ 'error_message' => 'API key verification failed: ' . $ex->getMessage(),
 
51
  );
52
  $this->render_intro( $details );
53
  return;
54
  }
55
 
56
+ $details['browser_disabled'] = ! Util_Environment::is_w3tc_pro( $c );
57
 
58
+ include W3TC_DIR . '/Extension_NewRelic_Popup_View_ListApplications.php';
59
  }
60
 
 
 
61
  public function w3tc_ajax_newrelic_apply_configuration() {
62
+ $api_key = Util_Request::get_string( 'api_key' );
63
+ $monitoring_type = Util_Request::get_string( 'monitoring_type', 'apm' );
64
+ $apm_application_name = Util_Request::get_string( 'apm_application_name' );
65
+ $browser_application_id = Util_Request::get_string( 'browser_application_id' );
66
+ $c = Dispatcher::config();
67
+
68
  $c->set( array( 'newrelic', 'api_key' ), $api_key );
69
 
70
+ if ( 'apm' === $monitoring_type ) {
71
  $c->set( array( 'newrelic', 'monitoring_type' ), 'apm' );
72
  $c->set( array( 'newrelic', 'apm.application_name' ), $apm_application_name );
73
  } else {
74
  $c->set( array( 'newrelic', 'monitoring_type' ), 'browser' );
75
+ $c->set( array( 'newrelic', 'browser.application_id' ), $browser_application_id );
 
76
  }
77
 
78
  $c->save();
79
 
80
+ // flush cached values on api key change to allow to reset it from ui if something goes wrong.
 
81
  update_option( 'w3tc_nr_account_id', '' );
82
  update_option( 'w3tc_nr_application_id', '' );
83
 
84
+ $postfix = Util_Admin::custom_message_id(
85
+ array(),
86
+ array(
87
+ 'newrelic_configuration_saved' => 'NewRelic configuration is saved successfully',
88
+ )
89
+ );
90
+
91
+ echo esc_url( 'Location admin.php?page=w3tc_general&' . $postfix );
92
  }
93
  }
Extension_NewRelic_Popup_View_Intro.php CHANGED
@@ -1,37 +1,55 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form style="padding: 20px">
8
- <?php
9
- if ( isset( $details['error_message'] ) )
10
- echo '<div class="error">' . $details['error_message'] . '</div>';
11
- ?>
 
12
 
13
- <div class="metabox-holder">
14
- <?php Util_Ui::postbox_header(
15
- __( 'Specify API Key', 'w3-total-cache' ) ); ?>
16
- <table class="form-table">
17
- <tr>
18
- <th>
19
- <label for="newrelic_api_key"><?php
20
- _e( '<acronym title="Application Programming Interface">API</acronym> key:', 'w3-total-cache' )
21
- ?></label>
22
- </th>
23
- <td>
24
- <input name="api_key" class="w3tcnr_api_key" type="text"
25
- value="<?php echo esc_attr( $details['api_key'] ) ?>" size="45"/>
26
- </td>
27
- </tr>
28
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- <p class="submit">
31
- <input type="button"
32
- class="w3tcnr_list_applications w3tc-button-save button-primary"
33
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
34
- </p>
35
- <?php Util_Ui::postbox_footer(); ?>
36
- </div>
37
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form style="padding: 20px">
9
+ <?php
10
+ if ( isset( $details['error_message'] ) ) {
11
+ echo '<div class="error">' . esc_html( $details['error_message'] ) . '</div>';
12
+ }
13
+ ?>
14
 
15
+ <div class="metabox-holder">
16
+ <?php Util_Ui::postbox_header( esc_html__( 'Specify API Key', 'w3-total-cache' ) ); ?>
17
+ <table class="form-table">
18
+ <tr>
19
+ <th>
20
+ <label for="newrelic_api_key">
21
+ <?php
22
+ echo wp_kses(
23
+ sprintf(
24
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
25
+ __(
26
+ '%1$sAPI%2$s key:',
27
+ 'w3-total-cache'
28
+ ),
29
+ '<acronym title="' . esc_attr__( 'Application Programming Interface', 'w3-total-cache' ) . '">',
30
+ '</acronym>'
31
+ ),
32
+ array(
33
+ 'acronym' => array(
34
+ 'title' => array(),
35
+ ),
36
+ )
37
+ );
38
+ ?>
39
+ </label>
40
+ </th>
41
+ <td>
42
+ <input name="api_key" class="w3tcnr_api_key" type="text"
43
+ value="<?php echo esc_attr( $details['api_key'] ); ?>" size="45"/>
44
+ </td>
45
+ </tr>
46
+ </table>
47
 
48
+ <p class="submit">
49
+ <input type="button"
50
+ class="w3tcnr_list_applications w3tc-button-save button-primary"
51
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
52
+ </p>
53
+ <?php Util_Ui::postbox_footer(); ?>
54
+ </div>
55
  </form>
Extension_NewRelic_Popup_View_ListApplications.php CHANGED
@@ -1,62 +1,67 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <form style="padding: 20px" class="w3tcnr_form">
8
- <?php
9
- Util_Ui::hidden( '', 'api_key', $details['api_key'] );
10
- ?>
11
 
12
- <div class="metabox-holder">
13
- <?php Util_Ui::postbox_header(
14
- __( 'Select Application', 'w3-total-cache' ) ); ?>
15
- <table class="form-table">
16
- <tr><td>
17
- <label>
18
- <input name="monitoring_type" type="radio" value="apm"
19
- <?php checked( $details['monitoring_type'], 'apm' ) ?> />
20
- APM application (uses NewRelic PHP module)
21
- </label><br />
22
- <select name="apm_application_name" class="w3tcnr_apm">
23
- <?php
24
- foreach ( $details['apm_applications'] as $a ) {
25
- echo '<option ';
26
- selected( $a, $details['apm.application_name'] );
27
- echo '>' . htmlspecialchars( $a ) . '</option>';
28
- }
29
- ?>
30
- </select>
31
- </td></tr>
32
- <tr><td>
33
- <label>
34
- <input name="monitoring_type" type="radio" value="browser"
35
- <?php checked( $details['monitoring_type'], 'browser' ) ?>
36
- <?php disabled( $details['browser_disabled'] ) ?> />
37
- Standalone Browser
38
- <?php
39
- if ( $details['browser_disabled'] )
40
- echo ' (W3TC Pro Only)';
41
- ?>
42
- </label><br />
43
- <select name="browser_application_id" class="w3tcnr_browser">
44
- <?php
45
- foreach ( $details['browser_applications'] as $a ) {
46
- echo '<option value="' . esc_attr( $a['id'] ) . '" ';
47
- selected( $a['id'], $details['browser.application_id'] );
48
- echo '>' . htmlspecialchars( $a['name'] ) . '</option>';
49
- }
50
- ?>
51
- </select>
52
- </td></tr>
53
- </table>
 
 
 
 
54
 
55
- <p class="submit">
56
- <input type="button"
57
- class="w3tcnr_apply_configuration w3tc-button-save button-primary"
58
- value="<?php _e( 'Apply', 'w3-total-cache' ); ?>" />
59
- </p>
60
- <?php Util_Ui::postbox_footer(); ?>
61
- </div>
62
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form style="padding: 20px" class="w3tcnr_form">
9
+ <?php
10
+ Util_Ui::hidden( '', 'api_key', $details['api_key'] );
11
+ ?>
12
 
13
+ <div class="metabox-holder">
14
+ <?php Util_Ui::postbox_header( esc_html__( 'Select Application', 'w3-total-cache' ) ); ?>
15
+ <table class="form-table">
16
+ <tr>
17
+ <td>
18
+ <label>
19
+ <input name="monitoring_type" type="radio" value="apm"
20
+ <?php checked( $details['monitoring_type'], 'apm' ); ?> />
21
+ APM application (uses NewRelic PHP module)
22
+ </label><br />
23
+ <select name="apm_application_name" class="w3tcnr_apm">
24
+ <?php
25
+ foreach ( $details['apm_applications'] as $a ) {
26
+ echo '<option ';
27
+ selected( $a, $details['apm.application_name'] );
28
+ echo '>' . esc_html( $a ) . '</option>';
29
+ }
30
+ ?>
31
+ </select>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td>
36
+ <label>
37
+ <input name="monitoring_type" type="radio" value="browser"
38
+ <?php checked( $details['monitoring_type'], 'browser' ); ?>
39
+ <?php disabled( $details['browser_disabled'] ); ?> />
40
+ Standalone Browser
41
+ <?php
42
+ if ( $details['browser_disabled'] ) {
43
+ echo ' (W3TC Pro Only)';
44
+ }
45
+ ?>
46
+ </label><br />
47
+ <select name="browser_application_id" class="w3tcnr_browser">
48
+ <?php
49
+ foreach ( $details['browser_applications'] as $a ) {
50
+ echo '<option value="' . esc_attr( $a['id'] ) . '" ';
51
+ selected( $a['id'], $details['browser.application_id'] );
52
+ echo '>' . esc_html( $a['name'] ) . '</option>';
53
+ }
54
+ ?>
55
+ </select>
56
+ </td>
57
+ </tr>
58
+ </table>
59
 
60
+ <p class="submit">
61
+ <input type="button"
62
+ class="w3tcnr_apply_configuration w3tc-button-save button-primary"
63
+ value="<?php esc_attr_e( 'Apply', 'w3-total-cache' ); ?>" />
64
+ </p>
65
+ <?php Util_Ui::postbox_footer(); ?>
66
+ </div>
67
  </form>
Extension_NewRelic_Service.php CHANGED
@@ -104,9 +104,10 @@ class Extension_NewRelic_Service {
104
  * Apache 2.2 or 2.4 via mod_php
105
  * Or any web server that supports FastCGI using php-fpm
106
  */
107
- $server = explode( '/', $_SERVER['SERVER_SOFTWARE'] );
 
108
  $ws_check = false;
109
- $ws_name = $_SERVER['SERVER_SOFTWARE'];
110
  $ws_version = '';
111
 
112
  if ( sizeof( $server ) > 1 ) {
@@ -126,7 +127,7 @@ class Extension_NewRelic_Service {
126
  break;
127
  default:
128
  $ws_check = php_sapi_name() == 'fpm-fcgi';
129
- $ws_name = $_SERVER['SERVER_SOFTWARE'];
130
  $ws_version = '';
131
  }
132
  $verified[__( 'Web Server', 'w3-total-cache' )] = $ws_check ? $supported_string :
104
  * Apache 2.2 or 2.4 via mod_php
105
  * Or any web server that supports FastCGI using php-fpm
106
  */
107
+ $server_software = isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '';
108
+ $server = explode( '/', $server_software );
109
  $ws_check = false;
110
+ $ws_name = $server_software;
111
  $ws_version = '';
112
 
113
  if ( sizeof( $server ) > 1 ) {
127
  break;
128
  default:
129
  $ws_check = php_sapi_name() == 'fpm-fcgi';
130
+ $ws_name = $server_software;
131
  $ws_version = '';
132
  }
133
  $verified[__( 'Web Server', 'w3-total-cache' )] = $ws_check ? $supported_string :
Extension_NewRelic_Widget_View_Apm.php CHANGED
@@ -1,68 +1,68 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <div id="new-relic-widget">
9
- <div class="w3tcnr_loading w3tc_loading w3tc_hidden">Loading...</div>
10
- <div class="w3tcnr_error w3tc_none">An error occurred</div>
11
 
12
- <div class="w3tcnr_content w3tc_hidden">
13
- <div id="new-relic-summary">
14
- <h4><?php _e( 'Overview', 'w3-total-cache' )?></h4>
15
- <ul>
16
- <li><span>Apdex: </span><span class="w3tcnr_apdex">N/A</span></li>
17
- <li><span>Application Busy: </span><span class="w3tcnr_application_busy">N/A</span></li>
18
- <li><span>Error Rate: </span><span class="w3tcnr_error_rate">N/A</span></li>
19
- <li><span>Throughput: </span><span class="w3tcnr_throughput">N/A</span></li>
20
- <li><span>Errors: </span><span class="w3tcnr_errors">N/A</span></li>
21
- <li><span>Response Time: </span><span class="w3tcnr_response_time">N/A</span></li>
22
- <li><span>DB: </span><span class="w3tcnr_db">N/A</span></li>
23
- <li><span>CPU: </span><span class="w3tcnr_cpu">N/A</span></li>
24
- <li><span>Memory: </span><span class="w3tcnr_memory">N/A</span></li>
25
- </ul>
26
- </div>
27
- <div id="new-relic-extra-metrics">
28
- <h4><?php _e( 'Average times', 'w3-total-cache' )?></h4>
29
- <ul>
30
- <li><span>Page load time: </span><span class="w3tcnr_enduser">N/A</span></li>
31
- <li><span>Web Transaction: </span><span class="w3tcnr_webtransaction">N/A</span></li>
32
- <li><span>Database: </span><span class="w3tcnr_database">N/A</span></li>
33
- </ul>
34
- <div style="clear:both"></div>
35
- </div>
36
- <div id="new-relic-top-list">
37
- <h4><?php _e( 'Top 5 slowest times', 'w3-total-cache' )?></h4>
38
- <div class="wrapper">
39
- <h5 class="w3tcnr-header-pageloads"><?php _e( 'Page load times', 'w3-total-cache' )?><div class="handlediv open" title="Click to toggle"><br></div></h5>
40
- <div class="top-five w3tcnr_pageloads">
41
- <div class="w3tcnr_topfive_message">Loading...</div>
42
- </div>
43
- </div>
44
- <div class="wrapper">
45
- <h5 class="w3tcnr-header-webtransactions"><?php _e( 'Web Transaction times', 'w3-total-cache' )?><div class="handlediv open" title="Click to toggle"><br></div></h5>
46
- <div class="top-five w3tcnr_webtransactions">
47
- <div class="w3tcnr_topfive_message">Loading...</div>
48
- </div>
49
- </div>
50
- <div class="wrapper">
51
- <h5 class="w3tcnr-header-dbtimes"><?php _e( 'Database times', 'w3-total-cache' )?><div class="handlediv open" title="Click to toggle"><br></div></h5>
52
- <div id="w3tc-database-times" class="top-five w3tcnr_dbtimes">
53
- <div class="w3tcnr_topfive_message">Loading...</div>
54
- </div>
55
- </div>
56
- </div>
57
- <div style="clear:both"></div>
58
- <hr>
59
- <p>
60
- <?php _e( 'PHP agent:', 'w3-total-cache' )?>
61
- <span class="w3tcnr_php_agent">N/A</span>
62
- <br />
63
 
64
- <?php _e( 'Subscription level:', 'w3-total-cache' )?>
65
- <strong class="w3tcnr_subscription_level">N/A</strong>
66
- </p>
67
- </div>
68
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div id="new-relic-widget">
9
+ <div class="w3tcnr_loading w3tc_loading w3tc_hidden">Loading...</div>
10
+ <div class="w3tcnr_error w3tc_none">An error occurred</div>
11
 
12
+ <div class="w3tcnr_content w3tc_hidden">
13
+ <div id="new-relic-summary">
14
+ <h4><?php esc_html_e( 'Overview', 'w3-total-cache' ); ?></h4>
15
+ <ul>
16
+ <li><span>Apdex: </span><span class="w3tcnr_apdex">N/A</span></li>
17
+ <li><span>Application Busy: </span><span class="w3tcnr_application_busy">N/A</span></li>
18
+ <li><span>Error Rate: </span><span class="w3tcnr_error_rate">N/A</span></li>
19
+ <li><span>Throughput: </span><span class="w3tcnr_throughput">N/A</span></li>
20
+ <li><span>Errors: </span><span class="w3tcnr_errors">N/A</span></li>
21
+ <li><span>Response Time: </span><span class="w3tcnr_response_time">N/A</span></li>
22
+ <li><span>DB: </span><span class="w3tcnr_db">N/A</span></li>
23
+ <li><span>CPU: </span><span class="w3tcnr_cpu">N/A</span></li>
24
+ <li><span>Memory: </span><span class="w3tcnr_memory">N/A</span></li>
25
+ </ul>
26
+ </div>
27
+ <div id="new-relic-extra-metrics">
28
+ <h4><?php esc_html_e( 'Average times', 'w3-total-cache' ); ?></h4>
29
+ <ul>
30
+ <li><span>Page load time: </span><span class="w3tcnr_enduser">N/A</span></li>
31
+ <li><span>Web Transaction: </span><span class="w3tcnr_webtransaction">N/A</span></li>
32
+ <li><span>Database: </span><span class="w3tcnr_database">N/A</span></li>
33
+ </ul>
34
+ <div style="clear:both"></div>
35
+ </div>
36
+ <div id="new-relic-top-list">
37
+ <h4><?php esc_html_e( 'Top 5 slowest times', 'w3-total-cache' ); ?></h4>
38
+ <div class="wrapper">
39
+ <h5 class="w3tcnr-header-pageloads"><?php esc_html_e( 'Page load times', 'w3-total-cache' ); ?><div class="handlediv open" title="Click to toggle"><br></div></h5>
40
+ <div class="top-five w3tcnr_pageloads">
41
+ <div class="w3tcnr_topfive_message">Loading...</div>
42
+ </div>
43
+ </div>
44
+ <div class="wrapper">
45
+ <h5 class="w3tcnr-header-webtransactions"><?php esc_html_e( 'Web Transaction times', 'w3-total-cache' ); ?><div class="handlediv open" title="Click to toggle"><br></div></h5>
46
+ <div class="top-five w3tcnr_webtransactions">
47
+ <div class="w3tcnr_topfive_message">Loading...</div>
48
+ </div>
49
+ </div>
50
+ <div class="wrapper">
51
+ <h5 class="w3tcnr-header-dbtimes"><?php esc_html_e( 'Database times', 'w3-total-cache' ); ?><div class="handlediv open" title="Click to toggle"><br></div></h5>
52
+ <div id="w3tc-database-times" class="top-five w3tcnr_dbtimes">
53
+ <div class="w3tcnr_topfive_message">Loading...</div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ <div style="clear:both"></div>
58
+ <hr>
59
+ <p>
60
+ <?php esc_html_e( 'PHP agent:', 'w3-total-cache' ); ?>
61
+ <span class="w3tcnr_php_agent">N/A</span>
62
+ <br />
63
 
64
+ <?php esc_html_e( 'Subscription level:', 'w3-total-cache' ); ?>
65
+ <strong class="w3tcnr_subscription_level">N/A</strong>
66
+ </p>
67
+ </div>
68
  </div>
Extension_NewRelic_Widget_View_Browser.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
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>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <?php esc_html_e( 'Metrics are not available for browser applications', 'w3-total-cache' ); ?>
9
  <p>
10
+ <a href="<?php echo esc_url( W3TC_NEWRELIC_SIGNUP_URL ); ?>" target="_blank">
11
+ <?php esc_html_e( 'Upgrade your New Relic account to enable more metrics.', 'w3-total-cache' ); ?>
12
+ </a>
13
  </p>
Extension_NewRelic_Widget_View_NotConfigured.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- ?>
8
- <?php _e( 'You have not configured API key and Account Id.', 'w3-total-cache' )?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ esc_html_e( 'You have not configured API key and Account Id.', 'w3-total-cache' );
 
Extension_Swarmify_AdminActions.php CHANGED
@@ -5,9 +5,11 @@ namespace W3TC;
5
 
6
  class Extension_Swarmify_AdminActions {
7
  public function w3tc_swarmify_set_key() {
8
- if ( isset( $_REQUEST['status'] ) && isset( $_REQUEST['swarmcdnkey'] ) && $_REQUEST['status'] == '1' ) {
 
 
9
  $config = Dispatcher::config();
10
- $config->set( array( 'swarmify', 'api_key' ), $_REQUEST['swarmcdnkey'] );
11
  $config->save();
12
  }
13
 
5
 
6
  class Extension_Swarmify_AdminActions {
7
  public function w3tc_swarmify_set_key() {
8
+ $status_val = Util_Request::get_string( 'status' );
9
+ $swarmcdnkey_val = Util_Request::get_string( 'swarmcdnkey' );
10
+ if ( ! empty( $status_val ) && ! empty( $swarmcdnkey_val ) && '1' === $status_val ) {
11
  $config = Dispatcher::config();
12
+ $config->set( array( 'swarmify', 'api_key' ), $swarmcdnkey_val );
13
  $config->save();
14
  }
15
 
Extension_Swarmify_Page_View.php CHANGED
@@ -1,83 +1,81 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <p>
9
- Jump to:
10
- <a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
- <a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a>
12
  </p>
13
  <p>
14
- Swarmify extension is currently <?php
15
- if ( $config->is_extension_active_frontend( 'swarmify' ) )
16
- echo '<span class="w3tc-enabled">enabled</span>';
17
- else
18
- echo '<span class="w3tc-disabled">disabled</span>';
19
- ?>.
 
 
 
20
  <p>
21
 
22
  <form action="admin.php?page=w3tc_extensions&amp;extension=swarmify&amp;action=view" method="post">
23
- <div class="metabox-holder">
24
- <?php Util_Ui::postbox_header( __( 'Configuration', 'w3-total-cache' ),
25
- '', 'configuration' ); ?>
26
- <table class="form-table">
27
- <?php
28
- Util_Ui::config_item( array(
29
- 'key' => array( 'swarmify', 'api_key' ),
30
- 'label' => __( 'API Key:', 'w3-total-cache' ),
31
- 'control' => 'textbox',
32
- 'control_after' => Util_Ui::button_link( 'Obtain one', $swarmify_signup_url ),
33
- 'description' =>
34
- 'Swarmify API Key required in order to start optimizing your videos experience'
35
- )
36
- );
37
- ?>
38
- </table>
39
- <?php Util_Ui::button_config_save( 'extension_swarmify_configuration' ); ?>
40
- <?php Util_Ui::postbox_footer(); ?>
41
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
 
 
 
 
 
 
 
 
 
43
 
44
- <?php Util_Ui::postbox_header( __( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
45
- <table class="form-table">
46
- <?php
47
- Util_Ui::config_item( array(
48
- 'key' => array( 'swarmify', 'handle.htmlvideo' ),
49
- 'label' => __( '&lt;video&gt;:', 'w3-total-cache' ),
50
- 'control' => 'checkbox',
51
- 'checkbox_label' => "Optimize &lt;video&gt; HTML tags",
52
- 'description' =>
53
- 'Optimize videos delivered using &lt;video&gt; HTML tag.'
54
- )
55
- );
56
- ?>
57
- <?php
58
- Util_Ui::config_item( array(
59
- 'key' => array( 'swarmify', 'handle.jwplayer' ),
60
- 'label' => __( 'JWPlayer:', 'w3-total-cache' ),
61
- 'control' => 'checkbox',
62
- 'checkbox_label' => "Optimize JWPlayer",
63
- 'description' =>
64
- 'Optimize videos delivered using JWPlayer script.'
65
- )
66
- );
67
- ?>
68
- <?php
69
- Util_Ui::config_item( array(
70
- 'key' => array( 'swarmify', 'reject.logged' ),
71
- 'label' => __( 'Logged In:', 'w3-total-cache' ),
72
- 'control' => 'checkbox',
73
- 'checkbox_label' => "Don't optimize videos for logged in users",
74
- 'description' =>
75
- 'Only unauthenticated users will view optimized version of a given page.'
76
- )
77
- );
78
- ?>
79
- </table>
80
- <?php Util_Ui::button_config_save( 'extension_swarmify_behaviour' ); ?>
81
- <?php Util_Ui::postbox_footer(); ?>
82
- </form>
83
- </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <p>
9
+ Jump to:
10
+ <a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
11
+ <a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a>
12
  </p>
13
  <p>
14
+ Swarmify extension is currently
15
+ <?php
16
+ if ( $config->is_extension_active_frontend( 'swarmify' ) ) {
17
+ echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>';
18
+ } else {
19
+ echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>';
20
+ }
21
+ ?>
22
+ .
23
  <p>
24
 
25
  <form action="admin.php?page=w3tc_extensions&amp;extension=swarmify&amp;action=view" method="post">
26
+ <div class="metabox-holder">
27
+ <?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', 'configuration' ); ?>
28
+ <table class="form-table">
29
+ <?php
30
+ Util_Ui::config_item(
31
+ array(
32
+ 'key' => array( 'swarmify', 'api_key' ),
33
+ 'label' => esc_html__( 'API Key:', 'w3-total-cache' ),
34
+ 'control' => 'textbox',
35
+ 'control_after' => Util_Ui::button_link( 'Obtain one', $swarmify_signup_url ),
36
+ 'description' => esc_html__( 'Swarmify API Key required in order to start optimizing your videos experience', 'w3-total-cache' ),
37
+ )
38
+ );
39
+ ?>
40
+ </table>
41
+ <?php Util_Ui::button_config_save( 'extension_swarmify_configuration' ); ?>
42
+ <?php Util_Ui::postbox_footer(); ?>
 
43
 
44
+ <?php Util_Ui::postbox_header( esc_html__( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
45
+ <table class="form-table">
46
+ <?php
47
+ Util_Ui::config_item(
48
+ array(
49
+ 'key' => array( 'swarmify', 'handle.htmlvideo' ),
50
+ 'label' => esc_html__( '&lt;video&gt;:', 'w3-total-cache' ),
51
+ 'control' => 'checkbox',
52
+ 'checkbox_label' => esc_html__( 'Optimize &lt;video&gt; HTML tags', 'w3-total-cache' ),
53
+ 'description' => esc_html__( 'Optimize videos delivered using &lt;video&gt; HTML tag.', 'w3-total-cache' ),
54
+ )
55
+ );
56
 
57
+ Util_Ui::config_item(
58
+ array(
59
+ 'key' => array( 'swarmify', 'handle.jwplayer' ),
60
+ 'label' => esc_html__( 'JWPlayer:', 'w3-total-cache' ),
61
+ 'control' => 'checkbox',
62
+ 'checkbox_label' => esc_html__( 'Optimize JWPlayer', 'w3-total-cache' ),
63
+ 'description' => esc_html__( 'Optimize videos delivered using JWPlayer script.', 'w3-total-cache' ),
64
+ )
65
+ );
66
 
67
+ Util_Ui::config_item(
68
+ array(
69
+ 'key' => array( 'swarmify', 'reject.logged' ),
70
+ 'label' => esc_html__( 'Logged In:', 'w3-total-cache' ),
71
+ 'control' => 'checkbox',
72
+ 'checkbox_label' => esc_html__( 'Don\'t optimize videos for logged in users', 'w3-total-cache' ),
73
+ 'description' => esc_html__( 'Only unauthenticated users will view optimized version of a given page.', 'w3-total-cache' ),
74
+ )
75
+ );
76
+ ?>
77
+ </table>
78
+ <?php Util_Ui::button_config_save( 'extension_swarmify_behaviour' ); ?>
79
+ <?php Util_Ui::postbox_footer(); ?>
80
+ </div>
81
+ </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Extension_Swarmify_Widget_View_NotConfigured.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <div class="sign-up w3tc-widget-swarmify-base">
9
- <p><?php _e( 'Just as the load time and overall performance of your website impacts user satisfaction, so does the performance of your online videos. Optimize your video performance by enabling the Swarmify SmartVideo&#8482 solution.', 'w3-total-cache' )?></p>
10
- <h4><?php _e( 'New customers', 'w3-total-cache' )?></h4>
11
- <p><?php _e( 'Swarmify is a service that lets you speed up your site even more with W3 Total Cache.', 'w3-total-cache' )?></p>
12
- <a class="button-primary" href="<?php echo $swarmify_signup_url ?>" target="_blank"><?php _e( 'Sign Up Now and Save 25%', 'w3-total-cache' )?></a>
13
- <p><span class="desc"><?php _e( 'Free 14 day limited trial', 'w3-total-cache' )?></span></p>
14
- <h4><?php _e( 'Current customers', 'w3-total-cache' )?></h4>
15
- <p><?php _e( 'If you already have a Swarmify configuration key, or need to update your existing key, click here:', 'w3-total-cache' )?></p>
16
- <a class="button-primary" href="admin.php?page=w3tc_extensions&amp;extension=swarmify&amp;action=view"><?php _e( 'Configure', 'w3-total-cache' )?></a>
17
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div class="sign-up w3tc-widget-swarmify-base">
9
+ <p><?php esc_html_e( 'Just as the load time and overall performance of your website impacts user satisfaction, so does the performance of your online videos. Optimize your video performance by enabling the Swarmify SmartVideo&#8482 solution.', 'w3-total-cache' ); ?></p>
10
+ <h4><?php esc_html_e( 'New customers', 'w3-total-cache' ); ?></h4>
11
+ <p><?php esc_html_e( 'Swarmify is a service that lets you speed up your site even more with W3 Total Cache.', 'w3-total-cache' ); ?></p>
12
+ <a class="button-primary" href="<?php echo esc_url( $swarmify_signup_url ); ?>" target="_blank"><?php esc_html_e( 'Sign Up Now and Save 25%', 'w3-total-cache' ); ?></a>
13
+ <p><span class="desc"><?php esc_html_e( 'Free 14 day limited trial', 'w3-total-cache' ); ?></span></p>
14
+ <h4><?php esc_html_e( 'Current customers', 'w3-total-cache' ); ?></h4>
15
+ <p><?php esc_html_e( 'If you already have a Swarmify configuration key, or need to update your existing key, click here:', 'w3-total-cache' ); ?></p>
16
+ <a class="button-primary" href="admin.php?page=w3tc_extensions&amp;extension=swarmify&amp;action=view"><?php esc_html_e( 'Configure', 'w3-total-cache' ); ?></a>
17
  </div>
Extensions_Page.php CHANGED
@@ -30,19 +30,22 @@ class Extensions_Page extends Base_Page_Settings {
30
  * @return void
31
  */
32
  function render_content() {
33
- $extension = '';
34
- $extension_status = 'all';
35
-
36
- if ( isset( $_GET['extension_status'] ) ) {
37
- if ( in_array( $_GET['extension_status'], array( 'all', 'active', 'inactive', 'core' ) ) )
38
- $extension_status = $_GET['extension_status'];
39
  }
40
 
41
- if ( isset( $_GET['extension'] ) ) {
42
- $extension = esc_attr( $_GET['extension'] );
 
 
43
  }
44
 
45
- $view = ( isset( $_GET['action'] ) && $_GET['action'] == 'view' );
 
46
 
47
  $extensions_active = Extensions_Util::get_active_extensions( $this->_config );
48
 
30
  * @return void
31
  */
32
  function render_content() {
33
+ $extension_status = 'all';
34
+ $extension_status_val = Util_Request::get_string( 'extension_status' );
35
+ if ( ! empty( $extension_status_val ) ) {
36
+ if ( in_array( $extension_status_val, array( 'all', 'active', 'inactive', 'core' ), true ) ) {
37
+ $extension_status = $extension_status_val;
38
+ }
39
  }
40
 
41
+ $extension = '';
42
+ $extension_val = Util_Request::get_string( 'extension' );
43
+ if ( ! empty( $extension_val ) ) {
44
+ $extension = esc_attr( $extension_val );
45
  }
46
 
47
+ $action_val = Util_Request::get_string( 'action' );
48
+ $view = ( ! empty( $action_val ) && 'view' === $action_val );
49
 
50
  $extensions_active = Extensions_Util::get_active_extensions( $this->_config );
51
 
Extensions_Plugin_Admin.php CHANGED
@@ -54,11 +54,12 @@ class Extensions_Plugin_Admin {
54
  if ( Util_Admin::is_w3tc_admin_page() ) {
55
  add_action( 'admin_notices', array( $this, 'admin_notices' ) );
56
 
57
- if ( isset( $_GET['extension'] ) && isset( $_GET['action'] ) ) { // phpcs:ignore
58
- if ( in_array( $_GET['action'], array( 'activate', 'deactivate' ), true ) ) { // phpcs:ignore
 
59
  add_action( 'init', array( $this, 'change_extension_status' ) );
60
  }
61
- } elseif ( isset( $_POST['checked'] ) ) { // phpcs:ignore
62
  add_action( 'admin_init', array( $this, 'change_extensions_status' ) );
63
  }
64
  }
@@ -223,15 +224,29 @@ class Extensions_Plugin_Admin {
223
  foreach ( $extensions_active as $id => $info ) {
224
  $transient_name = 'w3tc_activation_' . $id;
225
  $action_name = 'w3tc_' . $id . '_action';
 
226
 
227
- if ( isset( $_GET[ $action_name ] ) && 'dismiss_activation_notice' === $_GET[ $action_name ] ) { // phpcs:ignore
228
  delete_transient( $transient_name );
229
  }
230
 
231
  if ( isset( $info['notice'] ) && get_transient( $transient_name ) ) {
232
  ?>
233
  <div class="notice notice-warning is-dismissible">
234
- <p><?php echo $info['notice']; //phpcs:ignore ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  </div>
236
  <?php
237
  }
54
  if ( Util_Admin::is_w3tc_admin_page() ) {
55
  add_action( 'admin_notices', array( $this, 'admin_notices' ) );
56
 
57
+ $action_val = Util_Request::get_string( 'action' );
58
+ if ( ! empty( Util_Request::get_string( 'extension' ) ) && ! empty( $action_val ) ) {
59
+ if ( in_array( $action_val, array( 'activate', 'deactivate' ), true ) ) {
60
  add_action( 'init', array( $this, 'change_extension_status' ) );
61
  }
62
+ } elseif ( ! empty( Util_Request::get_array( 'checked' ) ) ) {
63
  add_action( 'admin_init', array( $this, 'change_extensions_status' ) );
64
  }
65
  }
224
  foreach ( $extensions_active as $id => $info ) {
225
  $transient_name = 'w3tc_activation_' . $id;
226
  $action_name = 'w3tc_' . $id . '_action';
227
+ $action_val = Util_Request::get_string( $action_name );
228
 
229
+ if ( ! empty( $action_val ) && 'dismiss_activation_notice' === $action_val ) {
230
  delete_transient( $transient_name );
231
  }
232
 
233
  if ( isset( $info['notice'] ) && get_transient( $transient_name ) ) {
234
  ?>
235
  <div class="notice notice-warning is-dismissible">
236
+ <p>
237
+ <?php
238
+ echo wp_kses(
239
+ $info['notice'],
240
+ array(
241
+ 'a' => array(
242
+ 'class' => array(),
243
+ 'href' => array(),
244
+ 'target' => array(),
245
+ ),
246
+ )
247
+ );
248
+ ?>
249
+ </p>
250
  </div>
251
  <?php
252
  }
FeatureShowcase_Plugin_Admin.php CHANGED
@@ -205,9 +205,12 @@ class FeatureShowcase_Plugin_Admin {
205
  $c = Dispatcher::config();
206
  $extensions = $c->get_array( 'extensions.active' );
207
  $is_imageservice_active = isset( $extensions['imageservice'] );
208
- $imageservice_button_text = $is_imageservice_active ? __( 'Settings', 'w3-total-cache' ) : __( 'Activate', 'w3-total-cache' );
 
 
209
  $imageservice_button_link = $is_imageservice_active ?
210
- 'upload.php?page=w3tc_extension_page_imageservice' : 'admin.php?page=w3tc_extensions&action=activate&extension=imageservice';
 
211
 
212
  global $wp_version;
213
 
@@ -236,8 +239,10 @@ class FeatureShowcase_Plugin_Admin {
236
  'title' => esc_html__( 'Image Service', 'w3-total-cache' ),
237
  'icon' => 'dashicons-embed-photo',
238
  'text' => esc_html( $imageservice_description ),
239
- 'button' => '<button class="button" onclick="window.location=\'' .
240
- esc_url( Util_Ui::admin_url( $imageservice_button_link ) ) . '\'">' . esc_html( $imageservice_button_text ) . '</button>',
 
 
241
  'link' => '<a target="_blank" href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/image-service/?utm_source=w3tc&utm_medium=feature_showcase&utm_campaign=imageservice' ) .
242
  '">' . __( 'More info', 'w3-total-cache' ) . '<span class="dashicons dashicons-external"></span></a>',
243
  'is_premium' => false,
205
  $c = Dispatcher::config();
206
  $extensions = $c->get_array( 'extensions.active' );
207
  $is_imageservice_active = isset( $extensions['imageservice'] );
208
+ $imageservice_button_text = $is_imageservice_active ?
209
+ ( is_network_admin() ? __( 'Available in sites', 'w3-total-cache' ) : __( 'Settings', 'w3-total-cache' ) ) :
210
+ ( is_network_admin() ? __( 'Activate', 'w3-total-cache' ) : '' );
211
  $imageservice_button_link = $is_imageservice_active ?
212
+ ( is_network_admin() ? 'network/sites.php' : 'upload.php?page=w3tc_extension_page_imageservice' ) :
213
+ ( is_network_admin() ? 'admin.php?page=w3tc_extensions&action=activate&extension=imageservice' : '' );
214
 
215
  global $wp_version;
216
 
239
  'title' => esc_html__( 'Image Service', 'w3-total-cache' ),
240
  'icon' => 'dashicons-embed-photo',
241
  'text' => esc_html( $imageservice_description ),
242
+ 'button' => empty( $imageservice_button_text ) ? '' :
243
+ ( '<button class="button" onclick="window.location=\'' .
244
+ esc_url( Util_Ui::admin_url( $imageservice_button_link ) ) . '\'">' .
245
+ esc_html( $imageservice_button_text ) . '</button>' ),
246
  'link' => '<a target="_blank" href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/image-service/?utm_source=w3tc&utm_medium=feature_showcase&utm_campaign=imageservice' ) .
247
  '">' . __( 'More info', 'w3-total-cache' ) . '<span class="dashicons dashicons-external"></span></a>',
248
  'is_premium' => false,
Generic_AdminActions_Config.php CHANGED
@@ -16,35 +16,33 @@ class Generic_AdminActions_Config {
16
  *
17
  * @return void
18
  */
19
- function w3tc_config_import() {
20
  $error = '';
21
 
22
  $config = new Config();
23
 
24
- if ( !isset( $_FILES['config_file']['error'] ) ||
25
- $_FILES['config_file']['error'] == UPLOAD_ERR_NO_FILE ) {
26
  $error = 'config_import_no_file';
27
- } elseif ( $_FILES['config_file']['error'] != UPLOAD_ERR_OK ) {
28
  $error = 'config_import_upload';
29
  } else {
30
- $imported = $config->import( $_FILES['config_file']['tmp_name'] );
 
 
 
31
 
32
- if ( !$imported ) {
33
  $error = 'config_import_import';
34
  }
35
  }
36
 
37
  if ( $error ) {
38
- Util_Admin::redirect( array(
39
- 'w3tc_error' => $error
40
- ), true );
41
  return;
42
  }
43
 
44
  Util_Admin::config_save( $this->_config, $config );
45
- Util_Admin::redirect( array(
46
- 'w3tc_note' => 'config_import'
47
- ), true );
48
  }
49
 
50
  /**
@@ -55,7 +53,7 @@ class Generic_AdminActions_Config {
55
  function w3tc_config_export() {
56
  $filename = substr( get_home_url(), strpos( get_home_url(), '//' )+2 );
57
  @header( sprintf( __( 'Content-Disposition: attachment; filename=%s.json', 'w3-total-cache' ), $filename ) );
58
- echo $this->_config->export();
59
  die();
60
  }
61
 
@@ -137,7 +135,7 @@ class Generic_AdminActions_Config {
137
  $params = array( 'page' => 'w3tc_general' );
138
 
139
  if ( !file_put_contents( W3TC_FILE_DB_CLUSTER_CONFIG,
140
- stripslashes( $_REQUEST['newcontent'] ) ) ) {
141
  try {
142
  Util_Activation::throw_on_write_error( W3TC_FILE_DB_CLUSTER_CONFIG );
143
  } catch ( \Exception $e ) {
16
  *
17
  * @return void
18
  */
19
+ public function w3tc_config_import() {
20
  $error = '';
21
 
22
  $config = new Config();
23
 
24
+ if ( ! isset( $_FILES['config_file']['error'] ) || UPLOAD_ERR_NO_FILE === $_FILES['config_file']['error'] ) {
 
25
  $error = 'config_import_no_file';
26
+ } elseif ( UPLOAD_ERR_OK !== $_FILES['config_file']['error'] ) {
27
  $error = 'config_import_upload';
28
  } else {
29
+ $imported = $config->import(
30
+ isset( $_FILES['config_file']['tmp_name'] ) ?
31
+ esc_url_raw( wp_unslash( $_FILES['config_file']['tmp_name'] ) ) : ''
32
+ );
33
 
34
+ if ( ! $imported ) {
35
  $error = 'config_import_import';
36
  }
37
  }
38
 
39
  if ( $error ) {
40
+ Util_Admin::redirect( array( 'w3tc_error' => $error ), true );
 
 
41
  return;
42
  }
43
 
44
  Util_Admin::config_save( $this->_config, $config );
45
+ Util_Admin::redirect( array( 'w3tc_note' => 'config_import' ), true );
 
 
46
  }
47
 
48
  /**
53
  function w3tc_config_export() {
54
  $filename = substr( get_home_url(), strpos( get_home_url(), '//' )+2 );
55
  @header( sprintf( __( 'Content-Disposition: attachment; filename=%s.json', 'w3-total-cache' ), $filename ) );
56
+ echo $this->_config->export(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
57
  die();
58
  }
59
 
135
  $params = array( 'page' => 'w3tc_general' );
136
 
137
  if ( !file_put_contents( W3TC_FILE_DB_CLUSTER_CONFIG,
138
+ Util_Request::get_string( 'newcontent' ) ) ) {
139
  try {
140
  Util_Activation::throw_on_write_error( W3TC_FILE_DB_CLUSTER_CONFIG );
141
  } catch ( \Exception $e ) {
Generic_AdminActions_Default.php CHANGED
@@ -1,8 +1,6 @@
1
  <?php
2
  namespace W3TC;
3
 
4
-
5
-
6
  use RecursiveDirectoryIterator;
7
  use RecursiveIteratorIterator;
8
  use RecursiveRegexIterator;
@@ -12,7 +10,7 @@ define( 'W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN', '~define\s*\(\s*[\'"]COOKI
12
 
13
  class Generic_AdminActions_Default {
14
 
15
- private $_config = null;
16
  private $_config_master = null;
17
 
18
  /**
@@ -23,7 +21,7 @@ class Generic_AdminActions_Default {
23
  private $_page = null;
24
 
25
  function __construct() {
26
- $this->_config = Dispatcher::config();
27
  $this->_config_master = Dispatcher::config_master();
28
 
29
  $this->_page = Util_Admin::get_current_page();
@@ -59,12 +57,14 @@ class Generic_AdminActions_Default {
59
  $this->_config->save();
60
 
61
  Dispatcher::component( 'Licensing_Plugin_Admin' )->possible_state_change(
62
- $this->_config, $old_config );
 
 
63
  } catch ( \Exception $ex ) {
64
- echo json_encode( array( 'result' => 'failed' ) );
65
  exit();
66
  }
67
- echo json_encode( array( 'result' => 'success' ) );
68
  exit();
69
  }
70
 
@@ -74,8 +74,9 @@ class Generic_AdminActions_Default {
74
  * @return void
75
  */
76
  function w3tc_default_hide_note() {
77
- $note = Util_Request::get_string( 'note' );
78
  $setting = sprintf( 'notes.%s', $note );
 
79
  $this->_config->set( $setting, false );
80
  $this->_config->save();
81
 
@@ -84,7 +85,7 @@ class Generic_AdminActions_Default {
84
  }
85
 
86
  function w3tc_default_config_state() {
87
- $key = Util_Request::get_string( 'key' );
88
  $value = Util_Request::get_string( 'value' );
89
 
90
  $config_state = Dispatcher::config_state_master();
@@ -94,7 +95,7 @@ class Generic_AdminActions_Default {
94
  }
95
 
96
  function w3tc_default_config_state_master() {
97
- $key = Util_Request::get_string( 'key' );
98
  $value = Util_Request::get_string( 'value' );
99
 
100
  $config_state = Dispatcher::config_state_master();
@@ -105,7 +106,7 @@ class Generic_AdminActions_Default {
105
  }
106
 
107
  function w3tc_default_config_state_note() {
108
- $key = Util_Request::get_string( 'key' );
109
  $value = Util_Request::get_string( 'value' );
110
 
111
  $s = Dispatcher::config_state_note();
@@ -124,49 +125,55 @@ class Generic_AdminActions_Default {
124
  }
125
 
126
  public function w3tc_default_purgelog_clear() {
127
- $module = Util_Request::get_label( 'module' );
128
  $log_filename = Util_Debug::log_filename( $module . '-purge' );
 
129
  if ( file_exists( $log_filename ) ) {
130
  unlink( $log_filename );
131
  }
132
 
133
- Util_Admin::redirect( array(
134
- 'page' => 'w3tc_general',
135
- 'view' => 'purge_log',
136
- 'module' => $module
137
- ), true );
 
 
 
138
  }
139
 
140
- /**
141
- *
142
- */
143
  function w3tc_default_remove_add_in() {
144
 
145
  $module = Util_Request::get_string( 'w3tc_default_remove_add_in' );
146
 
147
  // in the case of missing permissions to delete
148
- // environment will use that to try to override addin via ftp
149
  set_transient( 'w3tc_remove_add_in_' . $module, 'yes', 600 );
150
 
151
  switch ( $module ) {
152
- case 'pgcache':
153
- Util_WpFile::delete_file( W3TC_ADDIN_FILE_ADVANCED_CACHE );
154
- $src = W3TC_INSTALL_FILE_ADVANCED_CACHE;
155
- $dst = W3TC_ADDIN_FILE_ADVANCED_CACHE;
156
- try {
157
- Util_WpFile::copy_file( $src, $dst );
158
- } catch ( Util_WpFile_FilesystemOperationException $ex ) {}
159
- break;
160
- case 'dbcache':
161
- Util_WpFile::delete_file( W3TC_ADDIN_FILE_DB );
162
- break;
163
- case 'objectcache':
164
- Util_WpFile::delete_file( W3TC_ADDIN_FILE_OBJECT_CACHE );
165
- break;
 
 
166
  }
167
- Util_Admin::redirect( array(
168
- 'w3tc_note' => 'add_in_removed'
169
- ), true );
 
 
 
170
  }
171
 
172
  /**
@@ -180,7 +187,7 @@ class Generic_AdminActions_Default {
180
  }
181
 
182
  /**
183
- * save&flush all action
184
  *
185
  * @return void
186
  */
@@ -202,29 +209,24 @@ class Generic_AdminActions_Default {
202
 
203
  private function _w3tc_save_options_process() {
204
  $data = array(
205
- 'old_config' => $this->_config,
206
  'response_query_string' => array(),
207
- 'response_actions' => array(),
208
- 'response_errors' => array(),
209
- 'response_notes' => array( 'config_save' )
210
  );
211
 
212
- // if we are on extension settings page - stay on the same page
213
- if ( Util_Request::get_string( 'page' ) == 'w3tc_extensions' ) {
214
- $data['response_query_string']['page'] =
215
- Util_Request::get_string( 'page' );
216
- $data['response_query_string']['extension'] =
217
- Util_Request::get_string( 'extension' );
218
- $data['response_query_string']['action'] =
219
- Util_Request::get_string( 'action' );
220
  }
221
 
222
-
223
- $capability = apply_filters( 'w3tc_capability_config_save',
224
- 'manage_options' );
225
- if ( !current_user_can( $capability ) )
226
- wp_die( __( 'You do not have the rights to perform this action.',
227
- 'w3-total-cache' ) );
228
 
229
  /**
230
  * Read config
@@ -233,7 +235,7 @@ class Generic_AdminActions_Default {
233
  $config = new Config();
234
  $this->read_request( $config );
235
 
236
- if ( $this->_page == 'w3tc_dashboard' ) {
237
  if ( Util_Request::get_boolean( 'maxcdn' ) ) {
238
  $config->set( 'cdn.enabled', true );
239
  $config->set( 'cdn.engine', 'maxcdn' );
@@ -243,8 +245,8 @@ class Generic_AdminActions_Default {
243
  /**
244
  * General tab
245
  */
246
- if ( $this->_page == 'w3tc_general' ) {
247
- $file_nfs = Util_Request::get_boolean( 'file_nfs' );
248
  $file_locking = Util_Request::get_boolean( 'file_locking' );
249
 
250
  $config->set( 'pgcache.file.nfs', $file_nfs );
@@ -256,22 +258,23 @@ class Generic_AdminActions_Default {
256
  $config->set( 'minify.file.locking', $file_locking );
257
 
258
  if ( is_network_admin() ) {
259
- if ( ( $this->_config->get_boolean( 'common.force_master' ) !==
260
- $config->get_boolean( 'common.force_master' ) ) ) {
261
- // blogmap is wrong so empty it
262
  @unlink( W3TC_CACHE_BLOGMAP_FILENAME );
263
- $blogmap_dir = dirname( W3TC_CACHE_BLOGMAP_FILENAME ) . '/' .
264
- basename( W3TC_CACHE_BLOGMAP_FILENAME, '.php' ) . '/';
265
- if ( @is_dir( $blogmap_dir ) )
266
  Util_File::rmdir( $blogmap_dir );
 
267
  }
268
  }
269
 
270
  /**
271
  * Check permalinks for page cache
272
  */
273
- if ( $config->get_boolean( 'pgcache.enabled' ) && $config->get_string( 'pgcache.engine' ) == 'file_generic'
274
- && !get_option( 'permalink_structure' ) ) {
 
 
275
  $config->set( 'pgcache.enabled', false );
276
  $data['response_errors'][] = 'fancy_permalinks_disabled_pgcache';
277
  }
@@ -280,20 +283,21 @@ class Generic_AdminActions_Default {
280
  /**
281
  * Minify tab
282
  */
283
- if ( $this->_page == 'w3tc_minify' ) {
284
  if ( ( $this->_config->get_boolean( 'minify.js.http2push' ) && ! $config->get_boolean( 'minify.js.http2push' ) ) ||
285
- ( $this->_config->get_boolean( 'minify.css.http2push' ) && ! $config->get_boolean( 'minify.css.http2push' ) ) ) {
286
- if ( $config->get_string( 'pgcache.engine' ) == 'file_generic' ) {
 
287
  $cache_dir = Util_Environment::cache_blog_dir( 'page_enhanced' );
288
- $this->_deleteAllHtaccessFiles( $cache_dir );
289
  }
290
  }
291
 
292
- if ( !$this->_config->get_boolean( 'minify.auto' ) ) {
293
- $js_groups = array();
294
  $css_groups = array();
295
 
296
- $js_files = Util_Request::get_array( 'js_files' );
297
  $css_files = Util_Request::get_array( 'css_files' );
298
 
299
  foreach ( $js_files as $theme => $templates ) {
@@ -301,8 +305,9 @@ class Generic_AdminActions_Default {
301
  foreach ( (array) $locations as $location => $types ) {
302
  foreach ( (array) $types as $files ) {
303
  foreach ( (array) $files as $file ) {
304
- if ( !empty( $file ) ) {
305
- $js_groups[$theme][$template][$location]['files'][] = Util_Environment::normalize_file_minify( $file );
 
306
  }
307
  }
308
  }
@@ -314,8 +319,9 @@ class Generic_AdminActions_Default {
314
  foreach ( $templates as $template => $locations ) {
315
  foreach ( (array) $locations as $location => $files ) {
316
  foreach ( (array) $files as $file ) {
317
- if ( !empty( $file ) ) {
318
- $css_groups[$theme][$template][$location]['files'][] = Util_Environment::normalize_file_minify( $file );
 
319
  }
320
  }
321
  }
@@ -325,10 +331,10 @@ class Generic_AdminActions_Default {
325
  $config->set( 'minify.js.groups', $js_groups );
326
  $config->set( 'minify.css.groups', $css_groups );
327
 
328
- $js_theme = Util_Request::get_string( 'js_theme' );
329
  $css_theme = Util_Request::get_string( 'css_theme' );
330
 
331
- $data['response_query_string']['js_theme'] = $js_theme;
332
  $data['response_query_string']['css_theme'] = $css_theme;
333
  }
334
  }
@@ -336,25 +342,33 @@ class Generic_AdminActions_Default {
336
  /**
337
  * Browser Cache tab
338
  */
339
- if ( $this->_page == 'w3tc_browsercache' ) {
340
- if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.no404wp' ) && !get_option( 'permalink_structure' ) ) {
 
 
 
341
  $config->set( 'browsercache.no404wp', false );
342
  $data['response_errors'][] = 'fancy_permalinks_disabled_browsercache';
343
  }
344
 
345
- // todo: move to cdn module
346
  $engine = $this->_config->get_string( 'cdn.engine' );
347
- if ( $engine == 'maxcdn' ) {
348
  require_once W3TC_LIB_NETDNA_DIR . '/NetDNA.php';
349
- $keys = explode( '+', $this->_config->get_string( 'cdn.'.$engine.'.authorization_key' ) );
350
- if ( sizeof( $keys ) == 3 ) {
351
- list( $alias, $consumerkey, $consumersecret ) = $keys;
352
  try {
353
- $api = new \NetDNA( $alias, $consumerkey, $consumersecret );
354
  $disable_cooker_header = $config->get_boolean( 'browsercache.other.nocookies' ) ||
355
  $config->get_boolean( 'browsercache.cssjs.nocookies' );
356
- $api->update_pull_zone( $this->_config->get_string( 'cdn.' . $engine .'.zone_id' ), array( 'ignore_setcookie_header' => $disable_cooker_header ) );
357
- } catch ( \Exception $ex ) {}
 
 
 
 
 
358
  }
359
  }
360
  }
@@ -362,8 +376,8 @@ class Generic_AdminActions_Default {
362
  /**
363
  * CDN tab
364
  */
365
- if ( $this->_page == 'w3tc_cdn' ) {
366
- $cdn_cnames = Util_Request::get_array( 'cdn_cnames' );
367
  $cdn_domains = array();
368
 
369
  foreach ( $cdn_cnames as $cdn_cname ) {
@@ -390,146 +404,156 @@ class Generic_AdminActions_Default {
390
  }
391
 
392
  switch ( $this->_config->get_string( 'cdn.engine' ) ) {
393
- case 'akamai':
394
- $config->set( 'cdn.akamai.domain', $cdn_domains );
395
- break;
396
-
397
- case 'att':
398
- $config->set( 'cdn.att.domain', $cdn_domains );
399
- break;
400
-
401
- case 'azure':
402
- $config->set( 'cdn.azure.cname', $cdn_domains );
403
- break;
404
 
405
- case 'cf':
406
- $config->set( 'cdn.cf.cname', $cdn_domains );
407
- break;
408
 
409
- case 'cf2':
410
- $config->set( 'cdn.cf2.cname', $cdn_domains );
411
- break;
412
 
413
- case 'cotendo':
414
- $config->set( 'cdn.cotendo.domain', $cdn_domains );
415
- break;
416
 
417
- case 'edgecast':
418
- $config->set( 'cdn.edgecast.domain', $cdn_domains );
419
- break;
420
 
421
- case 'ftp':
422
- $config->set( 'cdn.ftp.domain', $cdn_domains );
423
- break;
424
 
425
- case 'highwinds':
426
- $config->set( 'cdn.highwinds.host.domains', $cdn_domains );
427
- break;
428
 
429
- case 'limelight':
430
- $config->set( 'cdn.limelight.host.domains', $cdn_domains );
431
- break;
432
 
433
- case 'mirror':
434
- $config->set( 'cdn.mirror.domain', $cdn_domains );
435
- break;
436
 
437
- case 'maxcdn':
438
- $v = $config->get( 'cdn.maxcdn.domain' );
439
- if ( isset( $v['http_default'] ) )
440
- $cdn_domains['http_default'] = $v['http_default'];
441
- if ( isset( $v['https_default'] ) )
442
- $cdn_domains['https_default'] = $v['https_default'];
443
 
444
- $config->set( 'cdn.maxcdn.domain', $cdn_domains );
445
- break;
 
446
 
447
- case 'rackspace_cdn':
448
- $config->set( 'cdn.rackspace_cdn.domains', $cdn_domains );
449
- break;
 
 
 
 
 
 
 
450
 
451
- case 'rscf':
452
- $config->set( 'cdn.rscf.cname', $cdn_domains );
453
- break;
454
 
455
- case 's3':
456
- case 's3_compatible':
457
- $config->set( 'cdn.s3.cname', $cdn_domains );
458
- break;
459
 
460
- case 'stackpath':
461
- $v = $config->get( 'cdn.stackpath.domain' );
462
- if ( isset( $v['http_default'] ) )
463
- $cdn_domains['http_default'] = $v['http_default'];
464
- if ( isset( $v['https_default'] ) )
465
- $cdn_domains['https_default'] = $v['https_default'];
466
 
467
- $config->set( 'cdn.stackpath.domain', $cdn_domains );
468
- break;
469
- case 'stackpath2':
470
- $config->set( 'cdn.stackpath2.domain', $cdn_domains );
471
- break;
 
 
 
 
 
 
 
 
472
  }
473
  }
474
 
475
  $old_ext_settings = $this->_config->get_array( 'extensions.settings', array() );
476
  $new_ext_settings = $old_ext_settings;
477
- $modified = false;
478
 
479
  $extensions = Extensions_Util::get_extensions( $config );
480
  foreach ( $extensions as $extension => $descriptor ) {
481
- $request = Util_Request::get_as_array(
482
- 'extensions.settings.' . $extension . '.' );
483
  if ( count( $request ) > 0 ) {
484
- if ( !isset( $new_ext_settings[$extension] ) )
485
- $new_ext_settings[$extension] = array();
 
486
 
487
  foreach ( $request as $key => $value ) {
488
- if ( !isset( $old_ext_settings[$extension] ) ||
489
- !isset( $old_ext_settings[$extension][$key] ) ||
490
- $old_ext_settings[$extension][$key] != $value ) {
491
- $new_ext_settings[$extension][$key] = $value;
492
- $modified = true;
 
493
  }
494
  }
495
  }
496
  }
497
 
498
- if ( $modified )
499
- $config->set( "extensions.settings", $new_ext_settings );
 
500
 
501
  $data['new_config'] = $config;
502
- $data = apply_filters( 'w3tc_save_options', $data );
503
- $config = $data['new_config'];
504
 
505
  do_action( 'w3tc_config_ui_save', $config, $this->_config );
506
  do_action( "w3tc_config_ui_save-{$this->_page}", $config, $this->_config );
507
 
508
  Util_Admin::config_save( $this->_config, $config );
509
 
510
- if ( $this->_page == 'w3tc_cdn' ) {
511
  /**
512
  * Handle Set Cookie Domain
513
  */
514
  $set_cookie_domain_old = Util_Request::get_boolean( 'set_cookie_domain_old' );
515
  $set_cookie_domain_new = Util_Request::get_boolean( 'set_cookie_domain_new' );
516
 
517
- if ( $set_cookie_domain_old != $set_cookie_domain_new ) {
518
  if ( $set_cookie_domain_new ) {
519
- if ( !$this->enable_cookie_domain() ) {
520
- Util_Admin::redirect( array_merge(
521
- $data['response_query_string'], array(
522
- 'w3tc_error' => 'enable_cookie_domain'
 
 
523
  )
524
- ) );
 
525
  }
526
  } else {
527
- if ( !$this->disable_cookie_domain() ) {
528
- Util_Admin::redirect( array_merge(
529
- $data['response_query_string'], array(
530
- 'w3tc_error' => 'disable_cookie_domain'
 
 
531
  )
532
- ) );
 
533
  }
534
  }
535
  }
@@ -537,31 +561,32 @@ class Generic_AdminActions_Default {
537
 
538
  return array(
539
  'query_string' => $data['response_query_string'],
540
- 'actions' => $data['response_actions'],
541
- 'errors' => $data['response_errors'],
542
- 'notes' => $data['response_notes']
543
  );
544
  }
545
 
546
- private function _deleteAllHtaccessFiles($dir) {
547
  if ( ! is_dir( $dir ) ) {
548
  return;
549
  }
550
 
551
  $handle = opendir( $dir );
552
- if ( $handle === false ) {
553
  return;
554
  }
555
 
556
- while ( false !== ( $file = readdir( $handle ) ) ) {
557
- if ( $file == '.' || $file == '..' ) {
 
558
  continue;
559
  }
560
 
561
  if ( is_dir( $file ) ) {
562
- $this->_deleteAllHtaccessFiles( $file );
563
  continue;
564
- } else if ( $file === '.htaccess' ) {
565
  @unlink( $file );
566
  }
567
  }
@@ -575,23 +600,36 @@ class Generic_AdminActions_Default {
575
  * @return bool
576
  */
577
  function enable_cookie_domain() {
 
 
578
  $config_path = Util_Environment::wp_config_path();
579
- $config_data = @file_get_contents( $config_path );
580
 
581
- if ( $config_data === false ) {
582
  return false;
583
  }
584
 
585
  $cookie_domain = Util_Admin::get_cookie_domain();
586
 
587
  if ( $this->is_cookie_domain_define( $config_data ) ) {
588
- $new_config_data = preg_replace( W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN, "define('COOKIE_DOMAIN', '" . addslashes( $cookie_domain ) . "')", $config_data, 1 );
 
 
 
 
 
589
  } else {
590
- $new_config_data = preg_replace( '~<\?(php)?~', "\\0\r\ndefine('COOKIE_DOMAIN', '" . addslashes( $cookie_domain ) . "'); // " . __( 'Added by W3 Total Cache', 'w3-total-cache' ) . "\r\n", $config_data, 1 );
 
 
 
 
 
 
591
  }
592
 
593
- if ( $new_config_data != $config_data ) {
594
- if ( !@file_put_contents( $config_path, $new_config_data ) ) {
595
  return false;
596
  }
597
  }
@@ -605,18 +643,25 @@ class Generic_AdminActions_Default {
605
  * @return bool
606
  */
607
  function disable_cookie_domain() {
 
 
608
  $config_path = Util_Environment::wp_config_path();
609
- $config_data = @file_get_contents( $config_path );
610
 
611
- if ( $config_data === false ) {
612
  return false;
613
  }
614
 
615
  if ( $this->is_cookie_domain_define( $config_data ) ) {
616
- $new_config_data = preg_replace( W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN, "define('COOKIE_DOMAIN', false)", $config_data, 1 );
617
-
618
- if ( $new_config_data != $config_data ) {
619
- if ( !@file_put_contents( $config_path, $new_config_data ) ) {
 
 
 
 
 
620
  return false;
621
  }
622
  }
@@ -628,7 +673,7 @@ class Generic_AdminActions_Default {
628
  /**
629
  * Checks COOKIE_DOMAIN definition existence
630
  *
631
- * @param string $content
632
  * @return int
633
  */
634
  function is_cookie_domain_define( $content ) {
@@ -639,7 +684,7 @@ class Generic_AdminActions_Default {
639
  /**
640
  * Returns true if config section is sealed
641
  *
642
- * @param string $section
643
  * @return boolean
644
  */
645
  protected function is_sealed( $section ) {
@@ -649,15 +694,15 @@ class Generic_AdminActions_Default {
649
  /**
650
  * Reads config from request
651
  *
652
- * @param Config $config
653
  */
654
  function read_request( $config ) {
655
  $request = Util_Request::get_request();
656
 
657
- include W3TC_DIR . '/ConfigKeys.php'; // define $keys
658
 
659
  foreach ( $request as $request_key => $request_value ) {
660
- if ( is_array( $request_value ) ) {
661
  array_map( 'stripslashes_deep', $request_value );
662
  } else {
663
  $request_value = stripslashes( $request_value );
@@ -667,11 +712,10 @@ class Generic_AdminActions_Default {
667
  }
668
  }
669
 
670
- if ( substr( $request_key, 0, 11 ) == 'extension__' ) {
671
- $extension_id = Util_Ui::config_key_from_http_name(
672
- substr( $request_key, 11 ) );
673
 
674
- if ( $request_value == '1' ) {
675
  Extensions_Util::activate_extension( $extension_id, $config, true );
676
  } else {
677
  Extensions_Util::deactivate_extension( $extension_id, $config, true );
@@ -682,18 +726,17 @@ class Generic_AdminActions_Default {
682
  if ( is_array( $key ) ) {
683
  $config->set( $key, $request_value );
684
  } elseif ( array_key_exists( $key, $keys ) ) {
685
- $descriptor = $keys[$key];
686
  if ( isset( $descriptor['type'] ) ) {
687
- if ( $descriptor['type'] == 'array' ) {
688
  if ( is_array( $request_value ) ) {
689
  $request_value = implode( "\n", $request_value );
690
  }
691
- $request_value = explode( "\n",
692
- str_replace( "\r\n", "\n", $request_value ) );
693
- } elseif ( $descriptor['type'] == 'boolean' ) {
694
- $request_value = ( $request_value == '1' );
695
- } elseif ( $descriptor['type'] == 'integer' ) {
696
- $request_value = (int)$request_value;
697
  }
698
  }
699
 
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  use RecursiveDirectoryIterator;
5
  use RecursiveIteratorIterator;
6
  use RecursiveRegexIterator;
10
 
11
  class Generic_AdminActions_Default {
12
 
13
+ private $_config = null;
14
  private $_config_master = null;
15
 
16
  /**
21
  private $_page = null;
22
 
23
  function __construct() {
24
+ $this->_config = Dispatcher::config();
25
  $this->_config_master = Dispatcher::config_master();
26
 
27
  $this->_page = Util_Admin::get_current_page();
57
  $this->_config->save();
58
 
59
  Dispatcher::component( 'Licensing_Plugin_Admin' )->possible_state_change(
60
+ $this->_config,
61
+ $old_config
62
+ );
63
  } catch ( \Exception $ex ) {
64
+ echo wp_json_encode( array( 'result' => 'failed' ) );
65
  exit();
66
  }
67
+ echo wp_json_encode( array( 'result' => 'success' ) );
68
  exit();
69
  }
70
 
74
  * @return void
75
  */
76
  function w3tc_default_hide_note() {
77
+ $note = Util_Request::get_string( 'note' );
78
  $setting = sprintf( 'notes.%s', $note );
79
+
80
  $this->_config->set( $setting, false );
81
  $this->_config->save();
82
 
85
  }
86
 
87
  function w3tc_default_config_state() {
88
+ $key = Util_Request::get_string( 'key' );
89
  $value = Util_Request::get_string( 'value' );
90
 
91
  $config_state = Dispatcher::config_state_master();
95
  }
96
 
97
  function w3tc_default_config_state_master() {
98
+ $key = Util_Request::get_string( 'key' );
99
  $value = Util_Request::get_string( 'value' );
100
 
101
  $config_state = Dispatcher::config_state_master();
106
  }
107
 
108
  function w3tc_default_config_state_note() {
109
+ $key = Util_Request::get_string( 'key' );
110
  $value = Util_Request::get_string( 'value' );
111
 
112
  $s = Dispatcher::config_state_note();
125
  }
126
 
127
  public function w3tc_default_purgelog_clear() {
128
+ $module = Util_Request::get_label( 'module' );
129
  $log_filename = Util_Debug::log_filename( $module . '-purge' );
130
+
131
  if ( file_exists( $log_filename ) ) {
132
  unlink( $log_filename );
133
  }
134
 
135
+ Util_Admin::redirect(
136
+ array(
137
+ 'page' => 'w3tc_general',
138
+ 'view' => 'purge_log',
139
+ 'module' => $module,
140
+ ),
141
+ true
142
+ );
143
  }
144
 
 
 
 
145
  function w3tc_default_remove_add_in() {
146
 
147
  $module = Util_Request::get_string( 'w3tc_default_remove_add_in' );
148
 
149
  // in the case of missing permissions to delete
150
+ // environment will use that to try to override addin via ftp.
151
  set_transient( 'w3tc_remove_add_in_' . $module, 'yes', 600 );
152
 
153
  switch ( $module ) {
154
+ case 'pgcache':
155
+ Util_WpFile::delete_file( W3TC_ADDIN_FILE_ADVANCED_CACHE );
156
+ $src = W3TC_INSTALL_FILE_ADVANCED_CACHE;
157
+ $dst = W3TC_ADDIN_FILE_ADVANCED_CACHE;
158
+ try {
159
+ Util_WpFile::copy_file( $src, $dst );
160
+ } catch ( Util_WpFile_FilesystemOperationException $ex ) {
161
+ // missing exception handle?
162
+ }
163
+ break;
164
+ case 'dbcache':
165
+ Util_WpFile::delete_file( W3TC_ADDIN_FILE_DB );
166
+ break;
167
+ case 'objectcache':
168
+ Util_WpFile::delete_file( W3TC_ADDIN_FILE_OBJECT_CACHE );
169
+ break;
170
  }
171
+ Util_Admin::redirect(
172
+ array(
173
+ 'w3tc_note' => 'add_in_removed',
174
+ ),
175
+ true
176
+ );
177
  }
178
 
179
  /**
187
  }
188
 
189
  /**
190
+ * Save&flush all action
191
  *
192
  * @return void
193
  */
209
 
210
  private function _w3tc_save_options_process() {
211
  $data = array(
212
+ 'old_config' => $this->_config,
213
  'response_query_string' => array(),
214
+ 'response_actions' => array(),
215
+ 'response_errors' => array(),
216
+ 'response_notes' => array( 'config_save' ),
217
  );
218
 
219
+ // if we are on extension settings page - stay on the same page.
220
+ if ( 'w3tc_extensions' === Util_Request::get_string( 'page' ) ) {
221
+ $data['response_query_string']['page'] = Util_Request::get_string( 'page' );
222
+ $data['response_query_string']['extension'] = Util_Request::get_string( 'extension' );
223
+ $data['response_query_string']['action'] = Util_Request::get_string( 'action' );
 
 
 
224
  }
225
 
226
+ $capability = apply_filters( 'w3tc_capability_config_save', 'manage_options' );
227
+ if ( ! current_user_can( $capability ) ) {
228
+ wp_die( esc_html__( 'You do not have the rights to perform this action.', 'w3-total-cache' ) );
229
+ }
 
 
230
 
231
  /**
232
  * Read config
235
  $config = new Config();
236
  $this->read_request( $config );
237
 
238
+ if ( 'w3tc_dashboard' === $this->_page ) {
239
  if ( Util_Request::get_boolean( 'maxcdn' ) ) {
240
  $config->set( 'cdn.enabled', true );
241
  $config->set( 'cdn.engine', 'maxcdn' );
245
  /**
246
  * General tab
247
  */
248
+ if ( 'w3tc_general' === $this->_page ) {
249
+ $file_nfs = Util_Request::get_boolean( 'file_nfs' );
250
  $file_locking = Util_Request::get_boolean( 'file_locking' );
251
 
252
  $config->set( 'pgcache.file.nfs', $file_nfs );
258
  $config->set( 'minify.file.locking', $file_locking );
259
 
260
  if ( is_network_admin() ) {
261
+ if ( ( $this->_config->get_boolean( 'common.force_master' ) !== $config->get_boolean( 'common.force_master' ) ) ) {
262
+ // blogmap is wrong so empty it.
 
263
  @unlink( W3TC_CACHE_BLOGMAP_FILENAME );
264
+ $blogmap_dir = dirname( W3TC_CACHE_BLOGMAP_FILENAME ) . '/' . basename( W3TC_CACHE_BLOGMAP_FILENAME, '.php' ) . '/';
265
+ if ( @is_dir( $blogmap_dir ) ) {
 
266
  Util_File::rmdir( $blogmap_dir );
267
+ }
268
  }
269
  }
270
 
271
  /**
272
  * Check permalinks for page cache
273
  */
274
+ if ( $config->get_boolean( 'pgcache.enabled' ) &&
275
+ 'file_generic' === $config->get_string( 'pgcache.engine' ) &&
276
+ ! get_option( 'permalink_structure' ) ) {
277
+
278
  $config->set( 'pgcache.enabled', false );
279
  $data['response_errors'][] = 'fancy_permalinks_disabled_pgcache';
280
  }
283
  /**
284
  * Minify tab
285
  */
286
+ if ( 'w3tc_minify' === $this->_page ) {
287
  if ( ( $this->_config->get_boolean( 'minify.js.http2push' ) && ! $config->get_boolean( 'minify.js.http2push' ) ) ||
288
+ ( $this->_config->get_boolean( 'minify.css.http2push' ) && ! $config->get_boolean( 'minify.css.http2push' ) ) ) {
289
+
290
+ if ( 'file_generic' === $config->get_string( 'pgcache.engine' ) ) {
291
  $cache_dir = Util_Environment::cache_blog_dir( 'page_enhanced' );
292
+ $this->_delete_all_htaccess_files( $cache_dir );
293
  }
294
  }
295
 
296
+ if ( ! $this->_config->get_boolean( 'minify.auto' ) ) {
297
+ $js_groups = array();
298
  $css_groups = array();
299
 
300
+ $js_files = Util_Request::get_array( 'js_files' );
301
  $css_files = Util_Request::get_array( 'css_files' );
302
 
303
  foreach ( $js_files as $theme => $templates ) {
305
  foreach ( (array) $locations as $location => $types ) {
306
  foreach ( (array) $types as $files ) {
307
  foreach ( (array) $files as $file ) {
308
+ if ( ! empty( $file ) ) {
309
+ $js_groups[ $theme ][ $template ][ $location ]['files'][] =
310
+ Util_Environment::normalize_file_minify( $file );
311
  }
312
  }
313
  }
319
  foreach ( $templates as $template => $locations ) {
320
  foreach ( (array) $locations as $location => $files ) {
321
  foreach ( (array) $files as $file ) {
322
+ if ( ! empty( $file ) ) {
323
+ $css_groups[ $theme ][ $template ][ $location ]['files'][] =
324
+ Util_Environment::normalize_file_minify( $file );
325
  }
326
  }
327
  }
331
  $config->set( 'minify.js.groups', $js_groups );
332
  $config->set( 'minify.css.groups', $css_groups );
333
 
334
+ $js_theme = Util_Request::get_string( 'js_theme' );
335
  $css_theme = Util_Request::get_string( 'css_theme' );
336
 
337
+ $data['response_query_string']['js_theme'] = $js_theme;
338
  $data['response_query_string']['css_theme'] = $css_theme;
339
  }
340
  }
342
  /**
343
  * Browser Cache tab
344
  */
345
+ if ( 'w3tc_browsercache' === $this->_page ) {
346
+ if ( $config->get_boolean( 'browsercache.enabled' ) &&
347
+ $config->get_boolean( 'browsercache.no404wp' ) &&
348
+ ! get_option( 'permalink_structure' ) ) {
349
+
350
  $config->set( 'browsercache.no404wp', false );
351
  $data['response_errors'][] = 'fancy_permalinks_disabled_browsercache';
352
  }
353
 
354
+ // todo: move to cdn module.
355
  $engine = $this->_config->get_string( 'cdn.engine' );
356
+ if ( 'maxcdn' === $engine ) {
357
  require_once W3TC_LIB_NETDNA_DIR . '/NetDNA.php';
358
+ $keys = explode( '+', $this->_config->get_string( 'cdn.' . $engine . '.authorization_key' ) );
359
+ if ( count( $keys ) === 3 ) {
360
+ list( $alias, $consumerkey, $consumersecret ) = $keys;
361
  try {
362
+ $api = new \NetDNA( $alias, $consumerkey, $consumersecret );
363
  $disable_cooker_header = $config->get_boolean( 'browsercache.other.nocookies' ) ||
364
  $config->get_boolean( 'browsercache.cssjs.nocookies' );
365
+ $api->update_pull_zone(
366
+ $this->_config->get_string( 'cdn.' . $engine . '.zone_id' ),
367
+ array( 'ignore_setcookie_header' => $disable_cooker_header )
368
+ );
369
+ } catch ( \Exception $ex ) {
370
+ // missing exception handle?
371
+ }
372
  }
373
  }
374
  }
376
  /**
377
  * CDN tab
378
  */
379
+ if ( 'w3tc_cdn' === $this->_page ) {
380
+ $cdn_cnames = Util_Request::get_array( 'cdn_cnames' );
381
  $cdn_domains = array();
382
 
383
  foreach ( $cdn_cnames as $cdn_cname ) {
404
  }
405
 
406
  switch ( $this->_config->get_string( 'cdn.engine' ) ) {
407
+ case 'akamai':
408
+ $config->set( 'cdn.akamai.domain', $cdn_domains );
409
+ break;
 
 
 
 
 
 
 
 
410
 
411
+ case 'att':
412
+ $config->set( 'cdn.att.domain', $cdn_domains );
413
+ break;
414
 
415
+ case 'azure':
416
+ $config->set( 'cdn.azure.cname', $cdn_domains );
417
+ break;
418
 
419
+ case 'cf':
420
+ $config->set( 'cdn.cf.cname', $cdn_domains );
421
+ break;
422
 
423
+ case 'cf2':
424
+ $config->set( 'cdn.cf2.cname', $cdn_domains );
425
+ break;
426
 
427
+ case 'cotendo':
428
+ $config->set( 'cdn.cotendo.domain', $cdn_domains );
429
+ break;
430
 
431
+ case 'edgecast':
432
+ $config->set( 'cdn.edgecast.domain', $cdn_domains );
433
+ break;
434
 
435
+ case 'ftp':
436
+ $config->set( 'cdn.ftp.domain', $cdn_domains );
437
+ break;
438
 
439
+ case 'highwinds':
440
+ $config->set( 'cdn.highwinds.host.domains', $cdn_domains );
441
+ break;
442
 
443
+ case 'limelight':
444
+ $config->set( 'cdn.limelight.host.domains', $cdn_domains );
445
+ break;
 
 
 
446
 
447
+ case 'mirror':
448
+ $config->set( 'cdn.mirror.domain', $cdn_domains );
449
+ break;
450
 
451
+ case 'maxcdn':
452
+ $v = $config->get( 'cdn.maxcdn.domain' );
453
+ if ( isset( $v['http_default'] ) ) {
454
+ $cdn_domains['http_default'] = $v['http_default'];
455
+ }
456
+ if ( isset( $v['https_default'] ) ) {
457
+ $cdn_domains['https_default'] = $v['https_default'];
458
+ }
459
+ $config->set( 'cdn.maxcdn.domain', $cdn_domains );
460
+ break;
461
 
462
+ case 'rackspace_cdn':
463
+ $config->set( 'cdn.rackspace_cdn.domains', $cdn_domains );
464
+ break;
465
 
466
+ case 'rscf':
467
+ $config->set( 'cdn.rscf.cname', $cdn_domains );
468
+ break;
 
469
 
470
+ case 's3':
471
+ case 's3_compatible':
472
+ $config->set( 'cdn.s3.cname', $cdn_domains );
473
+ break;
 
 
474
 
475
+ case 'stackpath':
476
+ $v = $config->get( 'cdn.stackpath.domain' );
477
+ if ( isset( $v['http_default'] ) ) {
478
+ $cdn_domains['http_default'] = $v['http_default'];
479
+ }
480
+ if ( isset( $v['https_default'] ) ) {
481
+ $cdn_domains['https_default'] = $v['https_default'];
482
+ }
483
+ $config->set( 'cdn.stackpath.domain', $cdn_domains );
484
+ break;
485
+ case 'stackpath2':
486
+ $config->set( 'cdn.stackpath2.domain', $cdn_domains );
487
+ break;
488
  }
489
  }
490
 
491
  $old_ext_settings = $this->_config->get_array( 'extensions.settings', array() );
492
  $new_ext_settings = $old_ext_settings;
493
+ $modified = false;
494
 
495
  $extensions = Extensions_Util::get_extensions( $config );
496
  foreach ( $extensions as $extension => $descriptor ) {
497
+ $request = Util_Request::get_as_array( 'extensions.settings.' . $extension . '.' );
 
498
  if ( count( $request ) > 0 ) {
499
+ if ( ! isset( $new_ext_settings[ $extension ] ) ) {
500
+ $new_ext_settings[ $extension ] = array();
501
+ }
502
 
503
  foreach ( $request as $key => $value ) {
504
+ if ( ! isset( $old_ext_settings[ $extension ] ) ||
505
+ ! isset( $old_ext_settings[ $extension ][ $key ] ) ||
506
+ $old_ext_settings[ $extension ][ $key ] !== $value ) {
507
+
508
+ $new_ext_settings[ $extension ][ $key ] = $value;
509
+ $modified = true;
510
  }
511
  }
512
  }
513
  }
514
 
515
+ if ( $modified ) {
516
+ $config->set( 'extensions.settings', $new_ext_settings );
517
+ }
518
 
519
  $data['new_config'] = $config;
520
+ $data = apply_filters( 'w3tc_save_options', $data );
521
+ $config = $data['new_config'];
522
 
523
  do_action( 'w3tc_config_ui_save', $config, $this->_config );
524
  do_action( "w3tc_config_ui_save-{$this->_page}", $config, $this->_config );
525
 
526
  Util_Admin::config_save( $this->_config, $config );
527
 
528
+ if ( 'w3tc_cdn' === $this->_page ) {
529
  /**
530
  * Handle Set Cookie Domain
531
  */
532
  $set_cookie_domain_old = Util_Request::get_boolean( 'set_cookie_domain_old' );
533
  $set_cookie_domain_new = Util_Request::get_boolean( 'set_cookie_domain_new' );
534
 
535
+ if ( $set_cookie_domain_old !== $set_cookie_domain_new ) {
536
  if ( $set_cookie_domain_new ) {
537
+ if ( ! $this->enable_cookie_domain() ) {
538
+ Util_Admin::redirect(
539
+ array_merge(
540
+ $data['response_query_string'],
541
+ array(
542
+ 'w3tc_error' => 'enable_cookie_domain',
543
  )
544
+ )
545
+ );
546
  }
547
  } else {
548
+ if ( ! $this->disable_cookie_domain() ) {
549
+ Util_Admin::redirect(
550
+ array_merge(
551
+ $data['response_query_string'],
552
+ array(
553
+ 'w3tc_error' => 'disable_cookie_domain',
554
  )
555
+ )
556
+ );
557
  }
558
  }
559
  }
561
 
562
  return array(
563
  'query_string' => $data['response_query_string'],
564
+ 'actions' => $data['response_actions'],
565
+ 'errors' => $data['response_errors'],
566
+ 'notes' => $data['response_notes'],
567
  );
568
  }
569
 
570
+ private function _delete_all_htaccess_files( $dir ) {
571
  if ( ! is_dir( $dir ) ) {
572
  return;
573
  }
574
 
575
  $handle = opendir( $dir );
576
+ if ( false === $handle ) {
577
  return;
578
  }
579
 
580
+ $file = readdir( $handle );
581
+ while ( false !== $file ) {
582
+ if ( '.' === $file || '..' === $file ) {
583
  continue;
584
  }
585
 
586
  if ( is_dir( $file ) ) {
587
+ $this->_delete_all_htaccess_files( $file );
588
  continue;
589
+ } elseif ( '.htaccess' === $file ) {
590
  @unlink( $file );
591
  }
592
  }
600
  * @return bool
601
  */
602
  function enable_cookie_domain() {
603
+ global $wp_filesystem;
604
+
605
  $config_path = Util_Environment::wp_config_path();
606
+ $config_data = $wp_filesystem->get_contents( $config_path );
607
 
608
+ if ( false === $config_data ) {
609
  return false;
610
  }
611
 
612
  $cookie_domain = Util_Admin::get_cookie_domain();
613
 
614
  if ( $this->is_cookie_domain_define( $config_data ) ) {
615
+ $new_config_data = preg_replace(
616
+ W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN,
617
+ "define('COOKIE_DOMAIN', '" . addslashes( $cookie_domain ) . "')",
618
+ $config_data,
619
+ 1
620
+ );
621
  } else {
622
+ $new_config_data = preg_replace(
623
+ '~<\?(php)?~',
624
+ "\\0\r\ndefine('COOKIE_DOMAIN', '" . addslashes( $cookie_domain ) .
625
+ "'); // " . __( 'Added by W3 Total Cache', 'w3-total-cache' ) . "\r\n",
626
+ $config_data,
627
+ 1
628
+ );
629
  }
630
 
631
+ if ( $new_config_data !== $config_data ) {
632
+ if ( ! $wp_filesystem->put_contents( $config_path, $new_config_data ) ) {
633
  return false;
634
  }
635
  }
643
  * @return bool
644
  */
645
  function disable_cookie_domain() {
646
+ global $wp_filesystem;
647
+
648
  $config_path = Util_Environment::wp_config_path();
649
+ $config_data = $wp_filesystem->get_contents( $config_path );
650
 
651
+ if ( false === $config_data ) {
652
  return false;
653
  }
654
 
655
  if ( $this->is_cookie_domain_define( $config_data ) ) {
656
+ $new_config_data = preg_replace(
657
+ W3TC_PLUGIN_TOTALCACHE_REGEXP_COOKIEDOMAIN,
658
+ "define('COOKIE_DOMAIN', false)",
659
+ $config_data,
660
+ 1
661
+ );
662
+
663
+ if ( $new_config_data !== $config_data ) {
664
+ if ( ! $wp_filesystem->put_contents( $config_path, $new_config_data ) ) {
665
  return false;
666
  }
667
  }
673
  /**
674
  * Checks COOKIE_DOMAIN definition existence
675
  *
676
+ * @param string $content
677
  * @return int
678
  */
679
  function is_cookie_domain_define( $content ) {
684
  /**
685
  * Returns true if config section is sealed
686
  *
687
+ * @param string $section
688
  * @return boolean
689
  */
690
  protected function is_sealed( $section ) {
694
  /**
695
  * Reads config from request
696
  *
697
+ * @param Config $config
698
  */
699
  function read_request( $config ) {
700
  $request = Util_Request::get_request();
701
 
702
+ include W3TC_DIR . '/ConfigKeys.php'; // define $keys.
703
 
704
  foreach ( $request as $request_key => $request_value ) {
705
+ if ( is_array( $request_value ) ) {
706
  array_map( 'stripslashes_deep', $request_value );
707
  } else {
708
  $request_value = stripslashes( $request_value );
712
  }
713
  }
714
 
715
+ if ( 'extension__' === substr( $request_key, 0, 11 ) ) {
716
+ $extension_id = Util_Ui::config_key_from_http_name( substr( $request_key, 11 ) );
 
717
 
718
+ if ( '1' === $request_value ) {
719
  Extensions_Util::activate_extension( $extension_id, $config, true );
720
  } else {
721
  Extensions_Util::deactivate_extension( $extension_id, $config, true );
726
  if ( is_array( $key ) ) {
727
  $config->set( $key, $request_value );
728
  } elseif ( array_key_exists( $key, $keys ) ) {
729
+ $descriptor = $keys[ $key ];
730
  if ( isset( $descriptor['type'] ) ) {
731
+ if ( 'array' === $descriptor['type'] ) {
732
  if ( is_array( $request_value ) ) {
733
  $request_value = implode( "\n", $request_value );
734
  }
735
+ $request_value = explode( "\n", str_replace( "\r\n", "\n", $request_value ) );
736
+ } elseif ( 'boolean' === $descriptor['type'] ) {
737
+ $request_value = ( '1' === $request_value );
738
+ } elseif ( 'integer' === $descriptor['type'] ) {
739
+ $request_value = (int) $request_value;
 
740
  }
741
  }
742
 
Generic_AdminActions_Flush.php CHANGED
@@ -23,7 +23,7 @@ class Generic_AdminActions_Flush {
23
  function w3tc_flush_current_page() {
24
  $url = filter_input( INPUT_GET, 'url', FILTER_SANITIZE_URL );
25
  if ( empty( $url ) && isset( $_SERVER['HTTP_REFERER'] ) ) {
26
- $url = $_SERVER['HTTP_REFERER'];
27
  }
28
  w3tc_flush_url( $url );
29
 
23
  function w3tc_flush_current_page() {
24
  $url = filter_input( INPUT_GET, 'url', FILTER_SANITIZE_URL );
25
  if ( empty( $url ) && isset( $_SERVER['HTTP_REFERER'] ) ) {
26
+ $url = sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) );
27
  }
28
  w3tc_flush_url( $url );
29
 
Generic_AdminActions_Test.php CHANGED
@@ -33,36 +33,45 @@ class Generic_AdminActions_Test {
33
  }
34
 
35
  /**
36
- * Test memcached
37
- *
38
- * @return void
39
  */
40
- function w3tc_test_redis() {
41
- $servers = Util_Request::get_array( 'servers' );
42
- $password = Util_Request::get_string('password', '');
43
- $dbid = Util_Request::get_integer( 'dbid', 0 );
 
44
 
45
- if ( count( $servers ) <= 0 )
46
  $success = false;
47
- else {
48
  $success = true;
49
 
50
  foreach ( $servers as $server ) {
51
- @$cache = Cache::instance( 'redis', array(
52
- 'servers' => $server,
53
- 'persistent' => false,
54
- 'password' => $password,
55
- 'dbid' => $dbid
56
- ) );
57
- if ( is_null( $cache ) )
 
 
 
 
 
58
  $success = false;
 
59
 
60
  $test_string = sprintf( 'test_' . md5( time() ) );
61
- $test_value = array( 'content' => $test_string );
 
62
  $cache->set( $test_string, $test_value, 60 );
 
63
  $test_value = $cache->get( $test_string );
64
- if ( $test_value['content'] != $test_string )
 
65
  $success = false;
 
66
  }
67
  }
68
 
@@ -82,7 +91,7 @@ class Generic_AdminActions_Test {
82
  );
83
  }
84
 
85
- echo json_encode( $response );
86
  exit();
87
  }
88
 
33
  }
34
 
35
  /**
36
+ * Test memcached.
 
 
37
  */
38
+ public function w3tc_test_redis() {
39
+ $servers = Util_Request::get_array( 'servers' );
40
+ $verify_tls_certificates = Util_Request::get_boolean('verify_tls_certificates', true );
41
+ $password = Util_Request::get_string('password', '');
42
+ $dbid = Util_Request::get_integer( 'dbid', 0 );
43
 
44
+ if ( count( $servers ) <= 0 ) {
45
  $success = false;
46
+ } else {
47
  $success = true;
48
 
49
  foreach ( $servers as $server ) {
50
+ @$cache = Cache::instance( // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
51
+ 'redis',
52
+ array(
53
+ 'servers' => $server,
54
+ 'verify_tls_certificates' => $verify_tls_certificates,
55
+ 'persistent' => false,
56
+ 'password' => $password,
57
+ 'dbid' => $dbid,
58
+ )
59
+ );
60
+
61
+ if ( is_null( $cache ) ) {
62
  $success = false;
63
+ }
64
 
65
  $test_string = sprintf( 'test_' . md5( time() ) );
66
+ $test_value = array( 'content' => $test_string );
67
+
68
  $cache->set( $test_string, $test_value, 60 );
69
+
70
  $test_value = $cache->get( $test_string );
71
+
72
+ if ( isset( $test_value['content'] ) && $test_value['content'] !== $test_string ) {
73
  $success = false;
74
+ }
75
  }
76
  }
77
 
91
  );
92
  }
93
 
94
+ echo wp_json_encode( $response );
95
  exit();
96
  }
97
 
Generic_AdminNotes.php CHANGED
@@ -1,177 +1,357 @@
1
  <?php
 
 
 
 
 
 
2
  namespace W3TC;
3
 
 
 
 
4
  class Generic_AdminNotes {
5
  /**
 
6
  *
7
- *
8
- * @param Config $config
9
  * @return string
10
  */
11
- function w3tc_notes( $notes ) {
12
- $c = Dispatcher::config();
13
- $state = Dispatcher::config_state();
14
  $state_master = Dispatcher::config_state_master();
15
- $state_note = Dispatcher::config_state_note();
16
 
17
  /**
18
  * Check wp-content permissions
19
  */
20
- if ( !W3TC_WIN && !$state_master->get_boolean( 'common.hide_note_wp_content_permissions' ) ) {
21
  $wp_content_mode = Util_File::get_file_permissions( WP_CONTENT_DIR );
22
 
23
  if ( $wp_content_mode > 0755 ) {
24
- $notes['generic_wp_content_writeable'] = sprintf(
25
- __( '<strong>%s</strong> is write-able. When finished installing the plugin, change the permissions back to the default: <strong>chmod 755 %s</strong>. Permissions are currently %s. %s',
26
- 'w3-total-cache' ),
27
- WP_CONTENT_DIR,
28
- WP_CONTENT_DIR,
29
- base_convert( Util_File::get_file_permissions( WP_CONTENT_DIR ), 10, 8 ),
30
- Util_Ui::button_hide_note2( array(
31
- 'w3tc_default_config_state_master' => 'y',
32
- 'key' => 'common.hide_note_wp_content_permissions',
33
- 'value' => 'true' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
  }
36
 
37
  /**
38
- * Check Zlib extension
39
  */
40
- if ( !$state_master->get_boolean( 'common.hide_note_no_zlib' ) &&
41
- !function_exists( 'gzencode' ) ) {
42
- $notes['no_zlib'] = sprintf(
43
- __( 'Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Notify the server administrator. %s',
44
- 'w3-total-cache' ),
45
- Util_Ui::button_hide_note2( array(
46
- 'w3tc_default_config_state_master' => 'y',
47
- 'key' => 'common.hide_note_no_zlib',
48
- 'value' => 'true' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
 
51
  /**
52
  * Check if Zlib output compression is enabled
53
  */
54
- if ( !$state_master->get_boolean( 'common.hide_note_zlib_output_compression' ) &&
55
- Util_Environment::is_zlib_enabled() ) {
56
- $notes['zlib_output_compression'] = sprintf(
57
- __( 'Either the PHP configuration, web server configuration or a script in the WordPress installation has <strong>zlib.output_compression</strong> enabled.<br />Please locate and disable this setting to ensure proper HTTP compression behavior. %s',
58
- 'w3-total-cache' ),
59
- Util_Ui::button_hide_note2( array(
60
- 'w3tc_default_config_state_master' => 'y',
61
- 'key' => 'common.hide_note_zlib_output_compression',
62
- 'value' => 'true' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
  if ( $state_master->get_boolean( 'common.show_note.nginx_restart_required' ) ) {
66
  $cf = Dispatcher::component( 'CacheFlush' );
67
- $notes['nginx_restart_required'] = sprintf(
68
- __( 'nginx.conf rules have been updated. Please restart nginx server to provide a consistent user experience. %s',
69
- 'w3-total-cache' ),
70
- Util_Ui::button_hide_note2( array(
71
- 'w3tc_default_config_state_master' => 'y',
72
- 'key' => 'common.show_note.nginx_restart_required',
73
- 'value' => 'false' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  /**
77
  * Preview mode
78
  */
79
  if ( $c->is_preview() ) {
80
- $notes['preview_mode'] = sprintf(
81
- __( 'Preview mode is active: Changed settings will not take effect until preview mode is %s or %s.', 'w3-total-cache' ),
82
- Util_Ui::button_link( __( 'deploy', 'w3-total-cache' ),
83
- Util_Ui::url( array(
84
- 'w3tc_config_preview_deploy' => 'y' ) ) ),
85
- Util_Ui::button_link( __( 'disable', 'w3-total-cache' ),
86
- Util_Ui::url( array(
87
- 'w3tc_config_preview_disable' => 'y' ) ) ) ) .
88
- '<p class="description">'.
89
  sprintf(
90
- __( 'To preview any changed settings (without deploying): %s',
91
- 'w3-total-cache' ),
92
- Util_Ui::preview_link() ).
93
- '</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
  /**
97
- * Show notification after plugin activate/deactivate
98
  */
99
- if ( $state_note->get( 'common.show_note.plugins_updated' ) &&
100
- !is_network_admin() /* flushing under network admin do nothing */ ) {
101
  $texts = array();
102
 
103
  if ( $c->get_boolean( 'pgcache.enabled' ) ) {
104
  $texts[] = Util_Ui::button_link(
105
  __( 'empty the page cache', 'w3-total-cache' ),
106
- Util_Ui::url( array( 'w3tc_flush_posts' => 'y' ) ) );
 
107
  }
108
 
109
  if ( $c->get_boolean( 'minify.enabled' ) ) {
110
- $texts[] = sprintf(
111
- __( 'check the %s to maintain the desired user experience',
112
- 'w3-total-cache' ),
113
- Util_Ui::button_link(
114
- __( 'minify settings', 'w3-total-cache' ),
115
- Util_Ui::url(
116
- array(
117
- 'w3tc_default_config_state_note' => 'y',
118
- 'key' => 'common.show_note.plugins_updated',
119
- 'value' => 'false',
120
- 'page' => 'w3tc_minify',
121
- 'redirect' => esc_url( admin_url( 'admin.php?page=w3tc_minify' ) ),
 
 
 
 
 
122
  )
123
  )
 
 
 
 
 
 
 
 
 
124
  )
125
  );
126
  }
127
 
128
  if ( count( $texts ) ) {
129
- $notes['some_plugins_activated'] = sprintf(
130
- __( 'One or more plugins have been activated or deactivated, please %s. %s',
131
- 'w3-total-cache' ),
132
- implode( __( ' and ', 'w3-total-cache' ), $texts ),
133
- Util_Ui::button_hide_note2( array(
134
- 'w3tc_default_config_state_note' => 'y',
135
- 'key' => 'common.show_note.plugins_updated',
136
- 'value' => 'false' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
  }
139
 
140
-
141
  /**
142
- * Show notification when flush_statics needed
143
  */
144
- if ( $c->get_boolean( 'browsercache.enabled' ) &&
145
- $state_note->get( 'common.show_note.flush_statics_needed' ) &&
146
- !is_network_admin() /* flushing under network admin do nothing */ &&
147
- !$c->is_preview() ) {
148
- $notes['flush_statics_needed'] = sprintf(
149
- __( 'The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience. %s', 'w3-total-cache' ),
150
- Util_Ui::button_link( 'Empty the static files cache',
151
- Util_Ui::url( array( 'w3tc_flush_statics' => 'y' ) ) ),
152
- Util_Ui::button_hide_note2( array(
153
- 'w3tc_default_config_state_note' => 'y',
154
- 'key' => 'common.show_note.flush_statics_needed',
155
- 'value' => 'false' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
  /**
159
- * Show notification when flush_posts needed
160
  */
161
- if ( $state_note->get( 'common.show_note.flush_posts_needed' ) &&
162
- !is_network_admin() /* flushing under network admin do nothing */ &&
163
- !$c->is_preview() &&
164
- !isset( $notes['flush_statics_needed'] ) ) {
165
  $cf = Dispatcher::component( 'CacheFlush' );
166
  if ( $cf->flushable_posts() ) {
167
- $notes['flush_posts_needed'] = sprintf(
168
- __( 'The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience. %s', 'w3-total-cache' ),
169
- Util_Ui::button_link( 'Empty the page cache',
170
- Util_Ui::url( array( 'w3tc_flush_posts' => 'y' ) ) ),
171
- Util_Ui::button_hide_note2( array(
172
- 'w3tc_default_config_state_note' => 'y',
173
- 'key' => 'common.show_note.flush_posts_needed',
174
- 'value' => 'false' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
  }
177
 
@@ -184,56 +364,117 @@ class Generic_AdminNotes {
184
  $c->get_boolean( 'cdnfsd.debug' ) ||
185
  $c->get_boolean( 'varnish.debug' );
186
 
187
- if ( $is_debug && !$state_master->get_boolean( 'common.hide_note_debug_enabled' ) ) {
188
- $notes['debug_enabled'] = sprintf(
189
- __( 'You’re running debug mode, it’s using Resources and not recommend to run continuously. %s',
190
- 'w3-total-cache' ),
191
- Util_Ui::button_hide_note2( array(
192
- 'w3tc_default_config_state_master' => 'y',
193
- 'key' => 'common.hide_note_debug_enabled',
194
- 'value' => 'true' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  }
196
 
197
  return $notes;
198
  }
199
 
200
-
201
-
 
 
 
 
202
  public function w3tc_errors( $errors ) {
203
  $state = Dispatcher::config_state();
204
- $c = Dispatcher::config();
205
 
206
  /**
207
- * Check permalinks
208
  */
209
- if ( !$state->get_boolean( 'common.hide_note_no_permalink_rules' ) &&
210
- ( ( $c->get_boolean( 'pgcache.enabled' ) &&
211
- $c->get_string( 'pgcache.engine' ) == 'file_generic' ) ||
212
- ( $c->get_boolean( 'browsercache.enabled' ) &&
213
- $c->get_boolean( 'browsercache.no404wp' ) ) ) &&
214
- !Util_Rule::is_permalink_rules() ) {
215
- $errors['generic_no_permalinks'] = sprintf(
216
- __( 'The required directives for fancy permalinks could not be detected, please confirm they are available: <a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29">Creating and editing</a> %s',
217
- 'w3-total-cache' ),
218
- Util_Ui::button_hide_note2( array(
219
- 'w3tc_default_config_state_master' => 'y',
220
- 'key' => 'common.hide_note_no_permalink_rules',
221
- 'value' => 'true' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  }
223
 
224
  /**
225
- * Check memcached
226
  */
227
  if ( isset( $errors['memcache_not_responding.details'] ) ) {
228
- $memcache_error =
229
- __( 'The following memcached servers are not responding or not running:</p><ul>',
230
- 'w3-total-cache' );
231
-
232
  foreach ( $errors['memcache_not_responding.details'] as $memcaches_error ) {
233
- $memcache_error .= '<li>' . $memcaches_error . '</li>';
234
  }
235
 
236
- $memcache_error .= __( '</ul><p>This message will automatically disappear once the issue is resolved.', 'w3-total-cache' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  $errors['memcache_not_responding'] = $memcache_error;
239
  unset( $errors['memcache_not_responding.details'] );
1
  <?php
2
+ /**
3
+ * FIle: Generic_AdminNotes.php
4
+ *
5
+ * @package W3TC
6
+ */
7
+
8
  namespace W3TC;
9
 
10
+ /**
11
+ * Class: Generic_AdminNotes
12
+ */
13
  class Generic_AdminNotes {
14
  /**
15
+ * W3TC admin notices.
16
  *
17
+ * @param array $notes Notices.
 
18
  * @return string
19
  */
20
+ public function w3tc_notes( $notes ) {
21
+ $c = Dispatcher::config();
22
+ $state = Dispatcher::config_state();
23
  $state_master = Dispatcher::config_state_master();
24
+ $state_note = Dispatcher::config_state_note();
25
 
26
  /**
27
  * Check wp-content permissions
28
  */
29
+ if ( ! W3TC_WIN && ! $state_master->get_boolean( 'common.hide_note_wp_content_permissions' ) ) {
30
  $wp_content_mode = Util_File::get_file_permissions( WP_CONTENT_DIR );
31
 
32
  if ( $wp_content_mode > 0755 ) {
33
+ $notes['generic_wp_content_writeable'] = wp_kses(
34
+ sprintf(
35
+ // translators: 1: HTML strong tag for current WP directory, 2: HTML strong tag for CHMOD instruction for current WP directory,
36
+ // translators: 3: conversion of file permissions from base 10 to 8, 4: HTML input button for hiding message.
37
+ __(
38
+ '%1$s is write-able. When finished installing the plugin, change the permissions back to the default: %2$s. Permissions are currently %3$s. %4$s',
39
+ 'w3-total-cache'
40
+ ),
41
+ '<strong>' . WP_CONTENT_DIR . '</strong>',
42
+ '<strong>chmod 755 ' . WP_CONTENT_DIR . '</strong>',
43
+ base_convert( Util_File::get_file_permissions( WP_CONTENT_DIR ), 10, 8 ),
44
+ Util_Ui::button_hide_note2(
45
+ array(
46
+ 'w3tc_default_config_state_master' => 'y',
47
+ 'key' => 'common.hide_note_wp_content_permissions',
48
+ 'value' => 'true',
49
+ )
50
+ )
51
+ ),
52
+ array(
53
+ 'strong' => array(),
54
+ 'input' => array(
55
+ 'type' => array(),
56
+ 'name' => array(),
57
+ 'class' => array(),
58
+ 'value' => array(),
59
+ 'onclick' => array(),
60
+ ),
61
+ )
62
+ );
63
  }
64
  }
65
 
66
  /**
67
+ * Check Zlib extension.
68
  */
69
+ if ( ! $state_master->get_boolean( 'common.hide_note_no_zlib' ) && ! function_exists( 'gzencode' ) ) {
70
+ $notes['no_zlib'] = wp_kses(
71
+ sprintf(
72
+ // translators: 1: opening HTML strong tag, 2: closing HTML strong tag, 3: HTML input button for hiding message.
73
+ __(
74
+ 'Unfortunately the PHP installation is incomplete, the %1$szlib module is missing%2$s. This is a core PHP module. Notify the server administrator. %3$s',
75
+ 'w3-total-cache'
76
+ ),
77
+ '<strong>',
78
+ '</strong>',
79
+ Util_Ui::button_hide_note2(
80
+ array(
81
+ 'w3tc_default_config_state_master' => 'y',
82
+ 'key' => 'common.hide_note_no_zlib',
83
+ 'value' => 'true',
84
+ )
85
+ )
86
+ ),
87
+ array(
88
+ 'strong' => array(),
89
+ 'input' => array(
90
+ 'type' => array(),
91
+ 'name' => array(),
92
+ 'class' => array(),
93
+ 'value' => array(),
94
+ 'onclick' => array(),
95
+ ),
96
+ )
97
+ );
98
  }
99
 
100
  /**
101
  * Check if Zlib output compression is enabled
102
  */
103
+ if ( ! $state_master->get_boolean( 'common.hide_note_zlib_output_compression' ) && Util_Environment::is_zlib_enabled() ) {
104
+ $notes['zlib_output_compression'] = wp_kses(
105
+ sprintf(
106
+ // translators: 1: opening HTML strong tag, 2: clsoing HTML strong tag, 3: HTML line break, 4: HTML input button to hide message.
107
+ __(
108
+ 'Either the PHP configuration, web server configuration or a script in the WordPress installation has %1$szlib.output_compression%2$s enabled.%3$sPlease locate and disable this setting to ensure proper HTTP compression behavior. %4$s',
109
+ 'w3-total-cache'
110
+ ),
111
+ '<strong>',
112
+ '</strong>',
113
+ '<br />',
114
+ Util_Ui::button_hide_note2(
115
+ array(
116
+ 'w3tc_default_config_state_master' => 'y',
117
+ 'key' => 'common.hide_note_zlib_output_compression',
118
+ 'value' => 'true',
119
+ )
120
+ )
121
+ ),
122
+ array(
123
+ 'strong' => array(),
124
+ 'br' => array(),
125
+ 'input' => array(
126
+ 'type' => array(),
127
+ 'name' => array(),
128
+ 'class' => array(),
129
+ 'value' => array(),
130
+ 'onclick' => array(),
131
+ ),
132
+ )
133
+ );
134
  }
135
 
136
  if ( $state_master->get_boolean( 'common.show_note.nginx_restart_required' ) ) {
137
  $cf = Dispatcher::component( 'CacheFlush' );
138
+
139
+ $notes['nginx_restart_required'] = wp_kses(
140
+ sprintf(
141
+ // translators: 1: HTML input button to hide message.
142
+ __(
143
+ 'nginx.conf rules have been updated. Please restart nginx server to provide a consistent user experience. %1$s',
144
+ 'w3-total-cache'
145
+ ),
146
+ Util_Ui::button_hide_note2(
147
+ array(
148
+ 'w3tc_default_config_state_master' => 'y',
149
+ 'key' => 'common.show_note.nginx_restart_required',
150
+ 'value' => 'false',
151
+ )
152
+ )
153
+ ),
154
+ array(
155
+ 'input' => array(
156
+ 'type' => array(),
157
+ 'name' => array(),
158
+ 'class' => array(),
159
+ 'value' => array(),
160
+ 'onclick' => array(),
161
+ ),
162
+ )
163
+ );
164
  }
165
 
166
  /**
167
  * Preview mode
168
  */
169
  if ( $c->is_preview() ) {
170
+ $notes['preview_mode'] = wp_kses(
 
 
 
 
 
 
 
 
171
  sprintf(
172
+ // translators: 1: HTML input button to apply changes, 2: HTML input button to disable preview mode,
173
+ // translators: 3: opening HTML p tag, 4: HTML inptu button to preview changes, 5: closing HTML p tag.
174
+ __(
175
+ 'Preview mode is active: Changed settings will not take effect until preview mode is %1$s or %2$s. %3$sTo preview any changed settings (without deploying): %4$s',
176
+ 'w3-total-cache'
177
+ ),
178
+ Util_Ui::button_link(
179
+ __( 'deploy', 'w3-total-cache' ),
180
+ Util_Ui::url( array( 'w3tc_config_preview_deploy' => 'y' ) )
181
+ ),
182
+ Util_Ui::button_link(
183
+ __( 'disable', 'w3-total-cache' ),
184
+ Util_Ui::url( array( 'w3tc_config_preview_disable' => 'y' ) )
185
+ ),
186
+ '<p class="description">',
187
+ Util_Ui::preview_link(),
188
+ '</p>'
189
+ ),
190
+ array(
191
+ 'p' => array(
192
+ 'class' => array(),
193
+ ),
194
+ 'input' => array(
195
+ 'type' => array(),
196
+ 'name' => array(),
197
+ 'class' => array(),
198
+ 'value' => array(),
199
+ 'onclick' => array(),
200
+ ),
201
+ )
202
+ );
203
  }
204
 
205
  /**
206
+ * Show notification after plugin activate/deactivate.
207
  */
208
+ if ( $state_note->get( 'common.show_note.plugins_updated' ) && ! is_network_admin() /* flushing under network admin do nothing */ ) {
 
209
  $texts = array();
210
 
211
  if ( $c->get_boolean( 'pgcache.enabled' ) ) {
212
  $texts[] = Util_Ui::button_link(
213
  __( 'empty the page cache', 'w3-total-cache' ),
214
+ Util_Ui::url( array( 'w3tc_flush_posts' => 'y' ) )
215
+ );
216
  }
217
 
218
  if ( $c->get_boolean( 'minify.enabled' ) ) {
219
+ $texts[] = wp_kses(
220
+ sprintf(
221
+ // translators: 1: HTML input button to view minify settings.
222
+ __(
223
+ 'check the %1$s to maintain the desired user experience',
224
+ 'w3-total-cache'
225
+ ),
226
+ Util_Ui::button_link(
227
+ __( 'minify settings', 'w3-total-cache' ),
228
+ Util_Ui::url(
229
+ array(
230
+ 'w3tc_default_config_state_note' => 'y',
231
+ 'key' => 'common.show_note.plugins_updated',
232
+ 'value' => 'false',
233
+ 'page' => 'w3tc_minify',
234
+ 'redirect' => esc_url( admin_url( 'admin.php?page=w3tc_minify' ) ),
235
+ )
236
  )
237
  )
238
+ ),
239
+ array(
240
+ 'input' => array(
241
+ 'type' => array(),
242
+ 'name' => array(),
243
+ 'class' => array(),
244
+ 'value' => array(),
245
+ 'onclick' => array(),
246
+ ),
247
  )
248
  );
249
  }
250
 
251
  if ( count( $texts ) ) {
252
+ $notes['some_plugins_activated'] = wp_kses(
253
+ sprintf(
254
+ // translators: 1: HTML input button to clear the cache, 2: HTML input button to hide message.
255
+ __(
256
+ 'One or more plugins have been activated or deactivated, please %1$s. %2$s',
257
+ 'w3-total-cache'
258
+ ),
259
+ implode( __( ' and ', 'w3-total-cache' ), $texts ),
260
+ Util_Ui::button_hide_note2(
261
+ array(
262
+ 'w3tc_default_config_state_note' => 'y',
263
+ 'key' => 'common.show_note.plugins_updated',
264
+ 'value' => 'false',
265
+ )
266
+ )
267
+ ),
268
+ array(
269
+ 'input' => array(
270
+ 'type' => array(),
271
+ 'name' => array(),
272
+ 'class' => array(),
273
+ 'value' => array(),
274
+ 'onclick' => array(),
275
+ ),
276
+ 'a' => array(
277
+ 'href' => array(),
278
+ 'target' => array(),
279
+ ),
280
+ )
281
+ );
282
  }
283
  }
284
 
 
285
  /**
286
+ * Show notification when flush_statics needed.
287
  */
288
+ if ( $c->get_boolean( 'browsercache.enabled' ) && $state_note->get( 'common.show_note.flush_statics_needed' ) && ! is_network_admin() /* flushing under network admin do nothing */ && ! $c->is_preview() ) {
289
+ $notes['flush_statics_needed'] = wp_kses(
290
+ sprintf(
291
+ // translators: 1: HTML input button to empty static files cache, 2: HTML input button to hide message.
292
+ __(
293
+ 'The setting change(s) made either invalidate the cached data or modify the behavior of the site. %1$s now to provide a consistent user experience. %2$s',
294
+ 'w3-total-cache'
295
+ ),
296
+ Util_Ui::button_link(
297
+ 'Empty the static files cache',
298
+ Util_Ui::url( array( 'w3tc_flush_statics' => 'y' ) )
299
+ ),
300
+ Util_Ui::button_hide_note2(
301
+ array(
302
+ 'w3tc_default_config_state_note' => 'y',
303
+ 'key' => 'common.show_note.flush_statics_needed',
304
+ 'value' => 'false',
305
+ )
306
+ )
307
+ ),
308
+ array(
309
+ 'input' => array(
310
+ 'type' => array(),
311
+ 'name' => array(),
312
+ 'class' => array(),
313
+ 'value' => array(),
314
+ 'onclick' => array(),
315
+ ),
316
+ )
317
+ );
318
  }
319
 
320
  /**
321
+ * Show notification when flush_posts needed.
322
  */
323
+ if ( $state_note->get( 'common.show_note.flush_posts_needed' ) && ! is_network_admin() /* flushing under network admin do nothing */ && ! $c->is_preview() && ! isset( $notes['flush_statics_needed'] ) ) {
 
 
 
324
  $cf = Dispatcher::component( 'CacheFlush' );
325
  if ( $cf->flushable_posts() ) {
326
+ $notes['flush_posts_needed'] = wp_kses(
327
+ sprintf(
328
+ // translators: 1: HTML input button to empty page cache, 2: HTML input button to hide message.
329
+ __(
330
+ 'The setting change(s) made either invalidate the cached data or modify the behavior of the site. %1$s now to provide a consistent user experience. %2$s',
331
+ 'w3-total-cache'
332
+ ),
333
+ Util_Ui::button_link(
334
+ 'Empty the page cache',
335
+ Util_Ui::url( array( 'w3tc_flush_posts' => 'y' ) )
336
+ ),
337
+ Util_Ui::button_hide_note2(
338
+ array(
339
+ 'w3tc_default_config_state_note' => 'y',
340
+ 'key' => 'common.show_note.flush_posts_needed',
341
+ 'value' => 'false',
342
+ )
343
+ )
344
+ ),
345
+ array(
346
+ 'input' => array(
347
+ 'type' => array(),
348
+ 'name' => array(),
349
+ 'class' => array(),
350
+ 'value' => array(),
351
+ 'onclick' => array(),
352
+ ),
353
+ )
354
+ );
355
  }
356
  }
357
 
364
  $c->get_boolean( 'cdnfsd.debug' ) ||
365
  $c->get_boolean( 'varnish.debug' );
366
 
367
+ if ( $is_debug && ! $state_master->get_boolean( 'common.hide_note_debug_enabled' ) ) {
368
+ $notes['debug_enabled'] = wp_kses(
369
+ sprintf(
370
+ // translators: 1: HTML input button to hide message.
371
+ __(
372
+ 'You\'re running debug mode, it\'s using Resources and not recommend to run continuously. %1$s',
373
+ 'w3-total-cache'
374
+ ),
375
+ Util_Ui::button_hide_note2(
376
+ array(
377
+ 'w3tc_default_config_state_master' => 'y',
378
+ 'key' => 'common.hide_note_debug_enabled',
379
+ 'value' => 'true',
380
+ )
381
+ )
382
+ ),
383
+ array(
384
+ 'input' => array(
385
+ 'type' => array(),
386
+ 'name' => array(),
387
+ 'class' => array(),
388
+ 'value' => array(),
389
+ 'onclick' => array(),
390
+ ),
391
+ )
392
+ );
393
  }
394
 
395
  return $notes;
396
  }
397
 
398
+ /**
399
+ * W3TC error notices.
400
+ *
401
+ * @param array $errors Errors.
402
+ * @return array
403
+ */
404
  public function w3tc_errors( $errors ) {
405
  $state = Dispatcher::config_state();
406
+ $c = Dispatcher::config();
407
 
408
  /**
409
+ * Check permalinks.
410
  */
411
+ if (
412
+ ! $state->get_boolean( 'common.hide_note_no_permalink_rules' ) &&
413
+ (
414
+ ( $c->get_boolean( 'pgcache.enabled' ) && 'file_generic' === $c->get_string( 'pgcache.engine' ) ) ||
415
+ ( $c->get_boolean( 'browsercache.enabled' ) && $c->get_boolean( 'browsercache.no404wp' ) )
416
+ ) &&
417
+ ! Util_Rule::is_permalink_rules()
418
+ ) {
419
+ $errors['generic_no_permalinks'] = wp_kses(
420
+ sprintf(
421
+ // translators: 1: HTML a tag to WordPress codex for using htaccess for permalinks, 2: HTML input button to hide message.
422
+ __(
423
+ 'The required directives for fancy permalinks could not be detected, please confirm they are available: %1$s %2$s',
424
+ 'w3-total-cache'
425
+ ),
426
+ '<a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29">' .
427
+ __( 'Creating and editing', 'w3-total-cache' ) . '</a>',
428
+ Util_Ui::button_hide_note2(
429
+ array(
430
+ 'w3tc_default_config_state_master' => 'y',
431
+ 'key' => 'common.hide_note_no_permalink_rules',
432
+ 'value' => 'true',
433
+ )
434
+ )
435
+ ),
436
+ array(
437
+ 'a' => array(
438
+ 'href' => array(),
439
+ ),
440
+ 'input' => array(
441
+ 'type' => array(),
442
+ 'name' => array(),
443
+ 'class' => array(),
444
+ 'value' => array(),
445
+ 'onclick' => array(),
446
+ ),
447
+ )
448
+ );
449
  }
450
 
451
  /**
452
+ * Check memcached.
453
  */
454
  if ( isset( $errors['memcache_not_responding.details'] ) ) {
455
+ $memcache_errors = '';
 
 
 
456
  foreach ( $errors['memcache_not_responding.details'] as $memcaches_error ) {
457
+ $memcache_errors .= '<li>' . $memcaches_error . '</li>';
458
  }
459
 
460
+ $memcache_error = wp_kses(
461
+ sprintf(
462
+ // translators: 1: opening HTML p tag, 2: closing HTML p tag followed by opening HTML ul tag followed by memcache errors within HTML li tags,
463
+ // translators: 3: closing HTML p tag.
464
+ __(
465
+ '%1$sThe following memcached servers are not responding or not running:%2$sThis message will automatically disappear once the issue is resolved.%3$s',
466
+ 'w3-total-cache'
467
+ ),
468
+ '<p>',
469
+ '</p><ul>' . $memcache_errors . '</ul><p>',
470
+ '</p>'
471
+ ),
472
+ array(
473
+ 'p' => array(),
474
+ 'ul' => array(),
475
+ 'li' => array(),
476
+ )
477
+ );
478
 
479
  $errors['memcache_not_responding'] = $memcache_error;
480
  unset( $errors['memcache_not_responding.details'] );
Generic_Page_Dashboard.php CHANGED
@@ -42,7 +42,6 @@ class Generic_Page_Dashboard extends Base_Page_Settings {
42
  $cdn_enabled = $module_status->is_enabled( 'cdn' );
43
  $cdn_mirror_purge = Cdn_Util::can_purge_all( $module_status->get_module_engine( 'cdn' ) );
44
 
45
-
46
  // Required for Update Media Query String button
47
  $browsercache_update_media_qs = ( $this->_config->get_boolean( 'browsercache.cssjs.replace' ) || $this->_config->get_boolean( 'browsercache.other.replace' ) );
48
 
42
  $cdn_enabled = $module_status->is_enabled( 'cdn' );
43
  $cdn_mirror_purge = Cdn_Util::can_purge_all( $module_status->get_module_engine( 'cdn' ) );
44
 
 
45
  // Required for Update Media Query String button
46
  $browsercache_update_media_qs = ( $this->_config->get_boolean( 'browsercache.cssjs.replace' ) || $this->_config->get_boolean( 'browsercache.other.replace' ) );
47
 
Generic_Page_PurgeLog_View.php CHANGED
@@ -1,10 +1,11 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <style>
10
  .w3tc_purge_log_header {
@@ -47,7 +48,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
47
  }
48
 
49
  .w3tc_purge_log_backtrace tr:nth-child(odd){
50
- background-color: #f2f2f2;
51
  }
52
 
53
  </style>
@@ -55,11 +56,26 @@ include W3TC_INC_DIR . '/options/common/header.php';
55
  <h1>Purges Log</h1>
56
  <div class="w3tc_purge_log_clear">
57
  <?php
58
- echo Util_Ui::button_link( __( 'Clear Log', 'w3-total-cache' ),
59
- Util_Ui::url( array(
60
- 'w3tc_default_purgelog_clear' => 'y',
61
- 'module' => $module
62
- ) ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  ?>
64
  </div>
65
  </div>
@@ -67,42 +83,42 @@ include W3TC_INC_DIR . '/options/common/header.php';
67
 
68
  <p>
69
  Available logs:
70
- <?php foreach ( $purgelog_modules as $module ): ?>
71
- <a href="admin.php?page=w3tc_general&view=purge_log&module=<?php echo esc_attr( $module['label'] ) ?>"><?php echo esc_html( $module['name'] ) ?></a>
72
- <?php echo esc_html( $module['postfix'] ) ?>
73
  <?php endforeach ?>
74
  </p>
75
  <p>
76
- Filename: <?php echo esc_html( $log_filename ) ?> (<?php echo esc_html( $log_filefize ) ?>)
77
  </p>
78
 
79
- <?php foreach ( $lines as $line ): ?>
80
  <div class="w3tc_purge_log_table">
81
  <div class="w3tc_purge_log_label">Date</div>
82
- <div><?php echo esc_html( $line['date'] ) ?></div>
83
 
84
  <div class="w3tc_purge_log_label">Action</div>
85
- <div class="w3tc_purge_log_message"><?php echo esc_html( $line['message'] ) ?></div>
86
 
87
  <div class="w3tc_purge_log_label">User</div>
88
- <div class="w3tc_purge_log_message"><?php echo esc_html( $line['username'] ) ?></div>
89
 
90
- <?php if ( !empty( $line['urls'] ) ): ?>
91
  <div class="w3tc_purge_log_label">Pages Flushed</div>
92
  <div class="w3tc_purge_log_urls">
93
- <?php foreach ( $line['urls'] as $url ): ?>
94
- <div><?php echo esc_html( $url ) ?></div>
95
  <?php endforeach ?>
96
  </div>
97
  <?php endif ?>
98
 
99
  <div class="w3tc_purge_log_label">Stack Trace</div>
100
  <table class="w3tc_purge_log_backtrace">
101
- <?php foreach ( $line['backtrace'] as $backtrace_line ): ?>
102
  <tr>
103
- <td><?php echo esc_html( $backtrace_line['number'] ) ?></td>
104
- <td><?php echo $this->esc_filename( $backtrace_line['filename'] ) ?></td>
105
- <td><?php echo esc_html( $backtrace_line['function'] ) ?></td>
106
  </tr>
107
  <?php endforeach ?>
108
  </table>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <style>
11
  .w3tc_purge_log_header {
48
  }
49
 
50
  .w3tc_purge_log_backtrace tr:nth-child(odd){
51
+ background-color: #f2f2f2;
52
  }
53
 
54
  </style>
56
  <h1>Purges Log</h1>
57
  <div class="w3tc_purge_log_clear">
58
  <?php
59
+ echo wp_kses(
60
+ Util_Ui::button_link(
61
+ __( 'Clear Log', 'w3-total-cache' ),
62
+ Util_Ui::url(
63
+ array(
64
+ 'w3tc_default_purgelog_clear' => 'y',
65
+ 'module' => $module,
66
+ )
67
+ )
68
+ ),
69
+ array(
70
+ 'input' => array(
71
+ 'type' => array(),
72
+ 'name' => array(),
73
+ 'class' => array(),
74
+ 'value' => array(),
75
+ 'onclick' => array(),
76
+ ),
77
+ )
78
+ );
79
  ?>
80
  </div>
81
  </div>
83
 
84
  <p>
85
  Available logs:
86
+ <?php foreach ( $purgelog_modules as $module ) : ?>
87
+ <a href="admin.php?page=w3tc_general&view=purge_log&module=<?php echo esc_attr( $module['label'] ); ?>"><?php echo esc_html( $module['name'] ); ?></a>
88
+ <?php echo esc_html( $module['postfix'] ); ?>
89
  <?php endforeach ?>
90
  </p>
91
  <p>
92
+ Filename: <?php echo esc_html( $log_filename ); ?> (<?php echo esc_html( $log_filefize ); ?>)
93
  </p>
94
 
95
+ <?php foreach ( $lines as $line ) : ?>
96
  <div class="w3tc_purge_log_table">
97
  <div class="w3tc_purge_log_label">Date</div>
98
+ <div><?php echo esc_html( $line['date'] ); ?></div>
99
 
100
  <div class="w3tc_purge_log_label">Action</div>
101
+ <div class="w3tc_purge_log_message"><?php echo esc_html( $line['message'] ); ?></div>
102
 
103
  <div class="w3tc_purge_log_label">User</div>
104
+ <div class="w3tc_purge_log_message"><?php echo esc_html( $line['username'] ); ?></div>
105
 
106
+ <?php if ( ! empty( $line['urls'] ) ) : ?>
107
  <div class="w3tc_purge_log_label">Pages Flushed</div>
108
  <div class="w3tc_purge_log_urls">
109
+ <?php foreach ( $line['urls'] as $url ) : ?>
110
+ <div><?php echo esc_html( $url ); ?></div>
111
  <?php endforeach ?>
112
  </div>
113
  <?php endif ?>
114
 
115
  <div class="w3tc_purge_log_label">Stack Trace</div>
116
  <table class="w3tc_purge_log_backtrace">
117
+ <?php foreach ( $line['backtrace'] as $backtrace_line ) : ?>
118
  <tr>
119
+ <td><?php echo esc_html( $backtrace_line['number'] ); ?></td>
120
+ <td><?php echo $this->esc_filename( $backtrace_line['filename'] ); // phpcs:ignore ?></td>
121
+ <td><?php echo esc_html( $backtrace_line['function'] ); ?></td>
122
  </tr>
123
  <?php endforeach ?>
124
  </table>
Generic_Plugin.php CHANGED
@@ -5,9 +5,9 @@ namespace W3TC;
5
  * W3 Total Cache plugin
6
  */
7
  class Generic_Plugin {
8
- private $is_wp_die = false;
9
  private $_translations = array();
10
- private $_config = null;
11
 
12
  function __construct() {
13
  $this->_config = Dispatcher::config();
@@ -17,72 +17,40 @@ class Generic_Plugin {
17
  * Runs plugin
18
  */
19
  function run() {
20
- add_filter( 'cron_schedules', array(
21
- $this,
22
- 'cron_schedules'
23
- ), 5 );
24
-
25
- add_action( 'init', array(
26
- $this,
27
- 'init'
28
- ), 1 /* need that to run before wp-cron to issue w3tc redirect */ );
29
- if ( Util_Environment::is_w3tc_pro_dev() && Util_Environment::is_w3tc_pro( $this->_config ) )
30
  add_action( 'wp_footer', array( $this, 'pro_dev_mode' ) );
 
 
 
 
31
 
32
- add_action( 'admin_bar_menu', array(
33
- $this,
34
- 'admin_bar_menu'
35
- ), 150 );
36
- add_action( 'admin_bar_init', array(
37
- $this,
38
- 'admin_bar_init'
39
- ) );
40
-
41
- if ( isset( $_REQUEST['w3tc_theme'] ) && isset( $_SERVER['HTTP_USER_AGENT'] ) &&
42
- stristr( $_SERVER['HTTP_USER_AGENT'], W3TC_POWERED_BY ) !== false ) {
43
- add_filter( 'template', array(
44
- $this,
45
- 'template_preview'
46
- ) );
47
-
48
- add_filter( 'stylesheet', array(
49
- $this,
50
- 'stylesheet_preview'
51
- ) );
52
  } elseif ( $this->_config->get_boolean( 'mobile.enabled' ) || $this->_config->get_boolean( 'referrer.enabled' ) ) {
53
- add_filter( 'template', array(
54
- $this,
55
- 'template'
56
- ) );
57
-
58
- add_filter( 'stylesheet', array(
59
- $this,
60
- 'stylesheet'
61
- ) );
62
  }
63
 
64
  /**
65
  * Create cookies to flag if a pgcache role was loggedin
66
  */
67
- if ( !$this->_config->get_boolean( 'pgcache.reject.logged' ) && $this->_config->get_array( 'pgcache.reject.logged_roles' ) ) {
68
- add_action( 'set_logged_in_cookie', array(
69
- $this,
70
- 'check_login_action'
71
- ), 0, 5 );
72
- add_action( 'clear_auth_cookie', array(
73
- $this,
74
- 'check_login_action'
75
- ), 0, 5 );
76
  }
77
 
78
  if ( $this->can_ob() ) {
79
  add_filter( 'wp_die_xml_handler', array( $this, 'wp_die_handler' ) );
80
  add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
81
 
82
- ob_start( array(
83
- $this,
84
- 'ob_callback'
85
- ) );
86
  }
87
  }
88
 
@@ -105,41 +73,44 @@ class Generic_Plugin {
105
  // if they are enabled
106
  //
107
  // absense of keys (if e.g. pgcaching became disabled, but there is
108
- // cron event scheduled in db) causes PHP notices
109
- return array_merge( $schedules, array(
 
 
110
  'w3_cdn_cron_queue_process' => array(
111
  'interval' => 0,
112
- 'display' => '[W3TC] CDN queue process (disabled)'
113
  ),
114
- 'w3_cdn_cron_upload' => array(
115
  'interval' => 0,
116
- 'display' => '[W3TC] CDN auto upload (disabled)'
117
  ),
118
- 'w3_dbcache_cleanup' => array(
119
  'interval' => 0,
120
- 'display' => '[W3TC] Database Cache file GC (disabled)'
121
  ),
122
- 'w3_fragmentcache_cleanup' => array(
123
  'interval' => 0,
124
- 'display' => '[W3TC] Fragment Cache file GC (disabled)'
125
  ),
126
- 'w3_minify_cleanup' => array(
127
  'interval' => 0,
128
- 'display' => '[W3TC] Minify file GC (disabled)'
129
  ),
130
- 'w3_objectcache_cleanup' => array(
131
  'interval' => 0,
132
- 'display' => '[W3TC] Object Cache file GC (disabled)'
133
  ),
134
- 'w3_pgcache_cleanup' => array(
135
  'interval' => 0,
136
- 'display' => '[W3TC] Page Cache file GC (disabled)'
137
  ),
138
- 'w3_pgcache_prime' => array(
139
  'interval' => 0,
140
- 'display' => '[W3TC] Page Cache file GC (disabled)'
141
- )
142
- ) );
 
143
  }
144
 
145
  /**
@@ -148,16 +119,17 @@ class Generic_Plugin {
148
  * @return void
149
  */
150
  function init() {
151
- // Load plugin text domain
152
- load_plugin_textdomain( W3TC_TEXT_DOMAIN, null, plugin_basename( W3TC_DIR ) . '/languages/' );
153
 
154
- if ( is_multisite() && !is_network_admin() ) {
155
  global $w3_current_blog_id, $current_blog;
156
- if ( $w3_current_blog_id != $current_blog->blog_id && !isset( $GLOBALS['w3tc_blogmap_register_new_item'] ) ) {
157
- $url = Util_Environment::host_port() . $_SERVER['REQUEST_URI'];
158
  $pos = strpos( $url, '?' );
159
- if ( $pos !== false )
160
  $url = substr( $url, 0, $pos );
 
161
  $GLOBALS['w3tc_blogmap_register_new_item'] = $url;
162
  }
163
  }
@@ -165,32 +137,33 @@ class Generic_Plugin {
165
  if ( isset( $GLOBALS['w3tc_blogmap_register_new_item'] ) ) {
166
  $do_redirect = Util_WpmuBlogmap::register_new_item( $this->_config );
167
 
168
- // reset cache of blog_id
169
  Util_Environment::reset_microcache();
170
  Dispatcher::reset_config();
171
 
172
- // change config to actual blog, it was master before
173
  $this->_config = new Config();
174
 
175
- // fix environment, potentially it's first request to a specific blog
176
  $environment = Dispatcher::component( 'Root_Environment' );
177
- $environment->fix_on_event( $this->_config, 'first_frontend',
178
- $this->_config );
179
 
180
  // need to repeat request processing, since we was not able to realize
181
  // blog_id before so we are running with master config now.
182
  // redirect to the same url causes "redirect loop" error in browser,
183
- // so need to redirect to something a bit different
184
  if ( $do_redirect ) {
185
- if ( ( defined( 'WP_CLI' ) && WP_CLI ) || php_sapi_name() == 'cli' ) {
186
  // command-line mode, no real requests made,
187
- // try to switch context in-request
188
  } else {
189
- if ( strpos( $_SERVER['REQUEST_URI'], '?' ) === false )
190
- Util_Environment::safe_redirect_temp( $_SERVER['REQUEST_URI'] . '?repeat=w3tc' );
191
- else {
192
- if ( strpos( $_SERVER['REQUEST_URI'], 'repeat=w3tc' ) === false )
193
- Util_Environment::safe_redirect_temp( $_SERVER['REQUEST_URI'] . '&repeat=w3tc' );
 
 
194
  }
195
  }
196
  }
@@ -206,17 +179,17 @@ class Generic_Plugin {
206
  exit();
207
  }
208
  $admin_bar = false;
209
- if ( function_exists( 'is_admin_bar_showing' ) )
210
  $admin_bar = is_admin_bar_showing();
 
211
 
212
  if ( $admin_bar ) {
213
  add_action( 'wp_print_scripts', array( $this, 'popup_script' ) );
214
  }
215
 
216
-
217
- // dont add system stuff to search results
218
- if ( ( isset( $_GET['repeat'] ) && $_GET['repeat'] == 'w3tc' ) ||
219
- Util_Environment::is_preview_mode() ) {
220
  header( 'X-Robots-Tag: noindex' );
221
  }
222
  }
@@ -250,54 +223,59 @@ class Generic_Plugin {
250
  function admin_bar_menu() {
251
  global $wp_admin_bar;
252
 
253
- $base_capability = apply_filters( 'w3tc_capability_admin_bar',
254
- 'manage_options' );
255
 
256
  if ( current_user_can( $base_capability ) ) {
257
  $modules = Dispatcher::component( 'ModuleStatus' );
258
 
259
  $menu_postfix = '';
260
- if ( !is_admin() &&
261
- $this->_config->get_boolean( 'widget.pagespeed.show_in_admin_bar' ) ) {
262
  $menu_postfix = ' <span id="w3tc_monitoring_score">...</span>';
263
- add_action( 'wp_after_admin_bar_render',
264
- array( $this, 'wp_after_admin_bar_render' ) );
265
  }
266
 
267
  $menu_items = array();
268
 
269
  $menu_items['00010.generic'] = array(
270
- 'id' => 'w3tc',
271
  'title' => sprintf(
272
  '<span class="w3tc-icon ab-icon"></span><span class="ab-label">%s</span>' .
273
  $menu_postfix,
274
- __( 'Performance', 'w3-total-cache' ) ),
275
- 'href' => network_admin_url( 'admin.php?page=w3tc_dashboard' )
 
 
 
 
276
  );
277
 
278
  if ( $modules->plugin_is_enabled() ) {
279
  $menu_items['10010.generic'] = array(
280
- 'id' => 'w3tc_flush_all',
281
- 'parent' => 'w3tc',
282
- 'title' => __( 'Purge All Caches', 'w3-total-cache' ),
283
- 'href' => wp_nonce_url( network_admin_url(
284
- 'admin.php?page=w3tc_dashboard&amp;w3tc_flush_all' ),
285
- 'w3tc' )
286
- );
287
- if ( !is_admin() )
288
- $menu_items['10020.generic'] = array(
289
- 'id' => 'w3tc_flush_current_page',
290
  'parent' => 'w3tc',
291
- 'title' => __( 'Purge Current Page', 'w3-total-cache' ),
292
- 'href' => wp_nonce_url( admin_url(
293
- 'admin.php?page=w3tc_dashboard&amp;w3tc_flush_post&amp;post_id=' .
294
- Util_Environment::detect_post_id() ), 'w3tc' )
 
295
  );
296
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  $menu_items['20010.generic'] = array(
298
- 'id' => 'w3tc_flush',
299
  'parent' => 'w3tc',
300
- 'title' => __( 'Purge Modules', 'w3-total-cache' )
301
  );
302
  }
303
 
@@ -305,57 +283,65 @@ class Generic_Plugin {
305
  'id' => 'w3tc_feature_showcase',
306
  'parent' => 'w3tc',
307
  'title' => __( 'Feature Showcase', 'w3-total-cache' ),
308
- 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_feature_showcase' ), 'w3tc' ),
 
 
 
309
  );
310
 
311
  $menu_items['40010.generic'] = array(
312
- 'id' => 'w3tc_settings_general',
313
  'parent' => 'w3tc',
314
- 'title' => __( 'General Settings', 'w3-total-cache' ),
315
- 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_general' ), 'w3tc' )
 
 
 
316
  );
317
  $menu_items['40020.generic'] = array(
318
- 'id' => 'w3tc_settings_extensions',
319
  'parent' => 'w3tc',
320
- 'title' => __( 'Manage Extensions', 'w3-total-cache' ),
321
- 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_extensions' ), 'w3tc' )
 
 
 
322
  );
323
 
324
  $menu_items['40030.generic'] = array(
325
- 'id' => 'w3tc_settings_faq',
326
  'parent' => 'w3tc',
327
- 'title' => __( 'FAQ', 'w3-total-cache' ),
328
- 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_faq' ), 'w3tc' )
 
 
 
329
  );
330
 
331
  $menu_items['60010.generic'] = array(
332
- 'id' => 'w3tc_support',
333
  'parent' => 'w3tc',
334
- 'title' => __( 'Support', 'w3-total-cache' ),
335
- 'href' => network_admin_url( 'admin.php?page=w3tc_support' )
 
 
 
336
  );
337
 
338
  if ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) {
339
  $menu_items['90010.generic'] = array(
340
- 'id' => 'w3tc_debug_overlays',
341
  'parent' => 'w3tc',
342
- 'title' => __( 'Debug: Overlays', 'w3-total-cache' ),
343
  );
344
  $menu_items['90020.generic'] = array(
345
- 'id' => 'w3tc_overlay_support_us',
346
- 'parent' => 'w3tc_debug_overlays',
347
- 'title' => __( 'Support Us', 'w3-total-cache' ),
348
- 'href' => wp_nonce_url( network_admin_url(
349
- 'admin.php?page=w3tc_dashboard&amp;' .
350
- 'w3tc_message_action=generic_support_us' ), 'w3tc' )
351
- );
352
- $menu_items['60030.generic'] = array(
353
- 'id' => 'w3tc_overlay_edge',
354
  'parent' => 'w3tc_debug_overlays',
355
- 'title' => __( 'Edge', 'w3-total-cache' ),
356
- 'href' => wp_nonce_url( network_admin_url(
357
- 'admin.php?page=w3tc_dashboard&amp;' .
358
- 'w3tc_message_action=generic_edge' ), 'w3tc' )
 
359
  );
360
  }
361
 
@@ -366,25 +352,28 @@ class Generic_Plugin {
366
 
367
  foreach ( $keys as $key ) {
368
  $capability = apply_filters(
369
- 'w3tc_capability_admin_bar_' . $menu_items[$key]['id'],
370
- $base_capability );
 
371
 
372
- if ( current_user_can( $capability ) )
373
- $wp_admin_bar->add_menu( $menu_items[$key] );
 
374
  }
375
  }
376
  }
377
 
378
  public function wp_after_admin_bar_render() {
379
  $url = admin_url( 'admin-ajax.php', 'relative' ) .
380
- '?action=w3tc_monitoring_score&' . md5( $_SERVER['REQUEST_URI'] );
 
381
 
382
- ?>
383
  <script type= "text/javascript">
384
- var w3tc_monitoring_score = document.createElement('script');
385
- w3tc_monitoring_score.type = 'text/javascript';
386
- w3tc_monitoring_score.src = '<?php echo $url ?>';
387
- document.getElementsByTagName('HEAD')[0].appendChild(w3tc_monitoring_score);
388
  </script>
389
  <?php
390
  }
@@ -491,8 +480,7 @@ class Generic_Plugin {
491
  return $buffer;
492
  }
493
 
494
- if ( $this->is_wp_die &&
495
- !apply_filters( 'w3tc_process_wp_die', false, $buffer ) ) {
496
  // wp_die is dynamic output (usually fatal errors), dont process it
497
  } else {
498
  $buffer = apply_filters( 'w3tc_process_content', $buffer );
@@ -502,14 +490,15 @@ class Generic_Plugin {
502
  * Add footer comment
503
  */
504
  $date = date_i18n( 'Y-m-d H:i:s' );
505
- $host = ( !empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : 'localhost' );
506
 
507
- if ( Util_Environment::is_preview_mode() )
508
  $buffer .= "\r\n<!-- W3 Total Cache used in preview mode -->";
 
509
 
510
  $strings = array();
511
 
512
- if ( !$this->_config->get_boolean( 'common.tweeted' ) ) {
513
  $strings[] = 'Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/';
514
  $strings[] = '';
515
  }
@@ -518,8 +507,11 @@ class Generic_Plugin {
518
 
519
  if ( count( $strings ) ) {
520
  $strings[] = '';
521
- $strings[] = sprintf( "Served from: %s @ %s by W3 Total Cache",
522
- Util_Content::escape_comment( $host ), $date );
 
 
 
523
 
524
  $buffer .= "\r\n<!--\r\n" .
525
  Util_Content::escape_comment( implode( "\r\n", $strings ) ) .
@@ -535,8 +527,10 @@ class Generic_Plugin {
535
  'newrelic',
536
  'cdn',
537
  'browsercache',
538
- 'pagecache'
539
- ), $buffer );
 
 
540
 
541
  $buffer = apply_filters( 'w3tc_processed_content', $buffer );
542
  }
@@ -593,8 +587,8 @@ class Generic_Plugin {
593
  /**
594
  * Check User Agent
595
  */
596
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
597
- stristr( $_SERVER['HTTP_USER_AGENT'], W3TC_POWERED_BY ) !== false ) {
598
  return false;
599
  }
600
 
@@ -608,14 +602,15 @@ class Generic_Plugin {
608
  */
609
  function check_login_action( $logged_in_cookie = false, $expire = ' ', $expiration = 0, $user_id = 0, $action = 'logged_out' ) {
610
  $current_user = wp_get_current_user();
611
- if ( isset( $current_user->ID ) && !$current_user->ID )
612
  $user_id = new \WP_User( $user_id );
613
- else
614
  $user_id = $current_user;
 
615
 
616
  if ( is_string( $user_id->roles ) ) {
617
  $roles = array( $user_id->roles );
618
- } elseif ( !is_array( $user_id->roles ) || count( $user_id->roles ) <= 0 ) {
619
  return;
620
  } else {
621
  $roles = $user_id->roles;
@@ -623,24 +618,37 @@ class Generic_Plugin {
623
 
624
  $rejected_roles = $this->_config->get_array( 'pgcache.reject.roles' );
625
 
626
- if ( 'logged_out' == $action ) {
627
  foreach ( $rejected_roles as $role ) {
628
  $role_hash = md5( NONCE_KEY . $role );
629
- setcookie( 'w3tc_logged_' . $role_hash, $expire,
630
- time() - 31536000, COOKIEPATH, COOKIE_DOMAIN );
 
 
 
 
 
631
  }
632
 
633
  return;
634
  }
635
 
636
- if ( 'logged_in' != $action )
637
  return;
 
638
 
639
  foreach ( $roles as $role ) {
640
- if ( in_array( $role, $rejected_roles ) ) {
641
  $role_hash = md5( NONCE_KEY . $role );
642
- setcookie( 'w3tc_logged_' . $role_hash, true, $expire,
643
- COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
 
 
 
 
 
 
 
644
  }
645
  }
646
  }
5
  * W3 Total Cache plugin
6
  */
7
  class Generic_Plugin {
8
+ private $is_wp_die = false;
9
  private $_translations = array();
10
+ private $_config = null;
11
 
12
  function __construct() {
13
  $this->_config = Dispatcher::config();
17
  * Runs plugin
18
  */
19
  function run() {
20
+ add_filter( 'cron_schedules', array( $this, 'cron_schedules' ), 5 );
21
+
22
+ /* need this to run before wp-cron to issue w3tc redirect */
23
+ add_action( 'init', array( $this, 'init' ), 1 );
24
+
25
+ if ( Util_Environment::is_w3tc_pro_dev() && Util_Environment::is_w3tc_pro( $this->_config ) ) {
 
 
 
 
26
  add_action( 'wp_footer', array( $this, 'pro_dev_mode' ) );
27
+ }
28
+
29
+ add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 150 );
30
+ add_action( 'admin_bar_init', array( $this, 'admin_bar_init' ) );
31
 
32
+ $http_user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '';
33
+ if ( ! empty( Util_Request::get_string( 'w3tc_theme' ) ) && stristr( $http_user_agent, W3TC_POWERED_BY ) !== false ) {
34
+ add_filter( 'template', array( $this, 'template_preview' ) );
35
+ add_filter( 'stylesheet', array( $this, 'stylesheet_preview' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  } elseif ( $this->_config->get_boolean( 'mobile.enabled' ) || $this->_config->get_boolean( 'referrer.enabled' ) ) {
37
+ add_filter( 'template', array( $this, 'template' ) );
38
+ add_filter( 'stylesheet', array( $this, 'stylesheet' ) );
 
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
  * Create cookies to flag if a pgcache role was loggedin
43
  */
44
+ if ( ! $this->_config->get_boolean( 'pgcache.reject.logged' ) && $this->_config->get_array( 'pgcache.reject.logged_roles' ) ) {
45
+ add_action( 'set_logged_in_cookie', array( $this, 'check_login_action' ), 0, 5 );
46
+ add_action( 'clear_auth_cookie', array( $this, 'check_login_action' ), 0, 5 );
 
 
 
 
 
 
47
  }
48
 
49
  if ( $this->can_ob() ) {
50
  add_filter( 'wp_die_xml_handler', array( $this, 'wp_die_handler' ) );
51
  add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
52
 
53
+ ob_start( array( $this, 'ob_callback' ) );
 
 
 
54
  }
55
  }
56
 
73
  // if they are enabled
74
  //
75
  // absense of keys (if e.g. pgcaching became disabled, but there is
76
+ // cron event scheduled in db) causes PHP notices.
77
+ return array_merge(
78
+ $schedules,
79
+ array(
80
  'w3_cdn_cron_queue_process' => array(
81
  'interval' => 0,
82
+ 'display' => '[W3TC] CDN queue process (disabled)',
83
  ),
84
+ 'w3_cdn_cron_upload' => array(
85
  'interval' => 0,
86
+ 'display' => '[W3TC] CDN auto upload (disabled)',
87
  ),
88
+ 'w3_dbcache_cleanup' => array(
89
  'interval' => 0,
90
+ 'display' => '[W3TC] Database Cache file GC (disabled)',
91
  ),
92
+ 'w3_fragmentcache_cleanup' => array(
93
  'interval' => 0,
94
+ 'display' => '[W3TC] Fragment Cache file GC (disabled)',
95
  ),
96
+ 'w3_minify_cleanup' => array(
97
  'interval' => 0,
98
+ 'display' => '[W3TC] Minify file GC (disabled)',
99
  ),
100
+ 'w3_objectcache_cleanup' => array(
101
  'interval' => 0,
102
+ 'display' => '[W3TC] Object Cache file GC (disabled)',
103
  ),
104
+ 'w3_pgcache_cleanup' => array(
105
  'interval' => 0,
106
+ 'display' => '[W3TC] Page Cache file GC (disabled)',
107
  ),
108
+ 'w3_pgcache_prime' => array(
109
  'interval' => 0,
110
+ 'display' => '[W3TC] Page Cache file GC (disabled)',
111
+ ),
112
+ )
113
+ );
114
  }
115
 
116
  /**
119
  * @return void
120
  */
121
  function init() {
122
+ // Load plugin text domain.
123
+ load_plugin_textdomain( W3TC_TEXT_DOMAIN, false, plugin_basename( W3TC_DIR ) . '/languages/' );
124
 
125
+ if ( is_multisite() && ! is_network_admin() ) {
126
  global $w3_current_blog_id, $current_blog;
127
+ if ( $w3_current_blog_id !== $current_blog->blog_id && ! isset( $GLOBALS['w3tc_blogmap_register_new_item'] ) ) {
128
+ $url = Util_Environment::host_port() . ( isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' );
129
  $pos = strpos( $url, '?' );
130
+ if ( false !== $pos ) {
131
  $url = substr( $url, 0, $pos );
132
+ }
133
  $GLOBALS['w3tc_blogmap_register_new_item'] = $url;
134
  }
135
  }
137
  if ( isset( $GLOBALS['w3tc_blogmap_register_new_item'] ) ) {
138
  $do_redirect = Util_WpmuBlogmap::register_new_item( $this->_config );
139
 
140
+ // reset cache of blog_id.
141
  Util_Environment::reset_microcache();
142
  Dispatcher::reset_config();
143
 
144
+ // change config to actual blog, it was master before.
145
  $this->_config = new Config();
146
 
147
+ // fix environment, potentially it's first request to a specific blog.
148
  $environment = Dispatcher::component( 'Root_Environment' );
149
+ $environment->fix_on_event( $this->_config, 'first_frontend', $this->_config );
 
150
 
151
  // need to repeat request processing, since we was not able to realize
152
  // blog_id before so we are running with master config now.
153
  // redirect to the same url causes "redirect loop" error in browser,
154
+ // so need to redirect to something a bit different.
155
  if ( $do_redirect ) {
156
+ if ( ( defined( 'WP_CLI' ) && WP_CLI ) || php_sapi_name() === 'cli' ) {
157
  // command-line mode, no real requests made,
158
+ // try to switch context in-request.
159
  } else {
160
+ $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
161
+ if ( strpos( $request_uri, '?' ) === false ) {
162
+ Util_Environment::safe_redirect_temp( $request_uri . '?repeat=w3tc' );
163
+ } else {
164
+ if ( strpos( $request_uri, 'repeat=w3tc' ) === false ) {
165
+ Util_Environment::safe_redirect_temp( $request_uri . '&repeat=w3tc' );
166
+ }
167
  }
168
  }
169
  }
179
  exit();
180
  }
181
  $admin_bar = false;
182
+ if ( function_exists( 'is_admin_bar_showing' ) ) {
183
  $admin_bar = is_admin_bar_showing();
184
+ }
185
 
186
  if ( $admin_bar ) {
187
  add_action( 'wp_print_scripts', array( $this, 'popup_script' ) );
188
  }
189
 
190
+ // dont add system stuff to search results.
191
+ $repeat_val = Util_Request::get_string( 'repeat' );
192
+ if ( ( ! empty( $repeat_val ) && 'w3tc' === $repeat_val ) || Util_Environment::is_preview_mode() ) {
 
193
  header( 'X-Robots-Tag: noindex' );
194
  }
195
  }
223
  function admin_bar_menu() {
224
  global $wp_admin_bar;
225
 
226
+ $base_capability = apply_filters( 'w3tc_capability_admin_bar', 'manage_options' );
 
227
 
228
  if ( current_user_can( $base_capability ) ) {
229
  $modules = Dispatcher::component( 'ModuleStatus' );
230
 
231
  $menu_postfix = '';
232
+ if ( ! is_admin() && $this->_config->get_boolean( 'widget.pagespeed.show_in_admin_bar' ) ) {
 
233
  $menu_postfix = ' <span id="w3tc_monitoring_score">...</span>';
234
+ add_action( 'wp_after_admin_bar_render', array( $this, 'wp_after_admin_bar_render' ) );
 
235
  }
236
 
237
  $menu_items = array();
238
 
239
  $menu_items['00010.generic'] = array(
240
+ 'id' => 'w3tc',
241
  'title' => sprintf(
242
  '<span class="w3tc-icon ab-icon"></span><span class="ab-label">%s</span>' .
243
  $menu_postfix,
244
+ __( 'Performance', 'w3-total-cache' )
245
+ ),
246
+ 'href' => wp_nonce_url(
247
+ network_admin_url( 'admin.php?page=w3tc_dashboard' ),
248
+ 'w3tc'
249
+ ),
250
  );
251
 
252
  if ( $modules->plugin_is_enabled() ) {
253
  $menu_items['10010.generic'] = array(
254
+ 'id' => 'w3tc_flush_all',
 
 
 
 
 
 
 
 
 
255
  'parent' => 'w3tc',
256
+ 'title' => __( 'Purge All Caches', 'w3-total-cache' ),
257
+ 'href' => wp_nonce_url(
258
+ network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_flush_all' ),
259
+ 'w3tc'
260
+ ),
261
  );
262
 
263
+ if ( ! is_admin() ) {
264
+ $menu_items['10020.generic'] = array(
265
+ 'id' => 'w3tc_flush_current_page',
266
+ 'parent' => 'w3tc',
267
+ 'title' => __( 'Purge Current Page', 'w3-total-cache' ),
268
+ 'href' => wp_nonce_url(
269
+ admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_flush_post&amp;post_id=' . Util_Environment::detect_post_id() ),
270
+ 'w3tc'
271
+ ),
272
+ );
273
+ }
274
+
275
  $menu_items['20010.generic'] = array(
276
+ 'id' => 'w3tc_flush',
277
  'parent' => 'w3tc',
278
+ 'title' => __( 'Purge Modules', 'w3-total-cache' ),
279
  );
280
  }
281
 
283
  'id' => 'w3tc_feature_showcase',
284
  'parent' => 'w3tc',
285
  'title' => __( 'Feature Showcase', 'w3-total-cache' ),
286
+ 'href' => wp_nonce_url(
287
+ network_admin_url( 'admin.php?page=w3tc_feature_showcase' ),
288
+ 'w3tc'
289
+ ),
290
  );
291
 
292
  $menu_items['40010.generic'] = array(
293
+ 'id' => 'w3tc_settings_general',
294
  'parent' => 'w3tc',
295
+ 'title' => __( 'General Settings', 'w3-total-cache' ),
296
+ 'href' => wp_nonce_url(
297
+ network_admin_url( 'admin.php?page=w3tc_general' ),
298
+ 'w3tc'
299
+ ),
300
  );
301
  $menu_items['40020.generic'] = array(
302
+ 'id' => 'w3tc_settings_extensions',
303
  'parent' => 'w3tc',
304
+ 'title' => __( 'Manage Extensions', 'w3-total-cache' ),
305
+ 'href' => wp_nonce_url(
306
+ network_admin_url( 'admin.php?page=w3tc_extensions' ),
307
+ 'w3tc'
308
+ ),
309
  );
310
 
311
  $menu_items['40030.generic'] = array(
312
+ 'id' => 'w3tc_settings_faq',
313
  'parent' => 'w3tc',
314
+ 'title' => __( 'FAQ', 'w3-total-cache' ),
315
+ 'href' => wp_nonce_url(
316
+ network_admin_url( 'admin.php?page=w3tc_faq' ),
317
+ 'w3tc'
318
+ ),
319
  );
320
 
321
  $menu_items['60010.generic'] = array(
322
+ 'id' => 'w3tc_support',
323
  'parent' => 'w3tc',
324
+ 'title' => __( 'Support', 'w3-total-cache' ),
325
+ 'href' => wp_nonce_url(
326
+ network_admin_url( 'admin.php?page=w3tc_support' ),
327
+ 'w3tc'
328
+ ),
329
  );
330
 
331
  if ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) {
332
  $menu_items['90010.generic'] = array(
333
+ 'id' => 'w3tc_debug_overlays',
334
  'parent' => 'w3tc',
335
+ 'title' => __( 'Debug: Overlays', 'w3-total-cache' ),
336
  );
337
  $menu_items['90020.generic'] = array(
338
+ 'id' => 'w3tc_overlay_support_us',
 
 
 
 
 
 
 
 
339
  'parent' => 'w3tc_debug_overlays',
340
+ 'title' => __( 'Support Us', 'w3-total-cache' ),
341
+ 'href' => wp_nonce_url(
342
+ network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=generic_support_us' ),
343
+ 'w3tc'
344
+ ),
345
  );
346
  }
347
 
352
 
353
  foreach ( $keys as $key ) {
354
  $capability = apply_filters(
355
+ 'w3tc_capability_admin_bar_' . $menu_items[ $key ]['id'],
356
+ $base_capability
357
+ );
358
 
359
+ if ( current_user_can( $capability ) ) {
360
+ $wp_admin_bar->add_menu( $menu_items[ $key ] );
361
+ }
362
  }
363
  }
364
  }
365
 
366
  public function wp_after_admin_bar_render() {
367
  $url = admin_url( 'admin-ajax.php', 'relative' ) .
368
+ '?action=w3tc_monitoring_score&' .
369
+ md5( isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' );
370
 
371
+ ?>
372
  <script type= "text/javascript">
373
+ var w3tc_monitoring_score = document.createElement('script');
374
+ w3tc_monitoring_score.type = 'text/javascript';
375
+ w3tc_monitoring_score.src = '<?php echo esc_url( $url ); ?>';
376
+ document.getElementsByTagName('HEAD')[0].appendChild(w3tc_monitoring_score);
377
  </script>
378
  <?php
379
  }
480
  return $buffer;
481
  }
482
 
483
+ if ( $this->is_wp_die && ! apply_filters( 'w3tc_process_wp_die', false, $buffer ) ) {
 
484
  // wp_die is dynamic output (usually fatal errors), dont process it
485
  } else {
486
  $buffer = apply_filters( 'w3tc_process_content', $buffer );
490
  * Add footer comment
491
  */
492
  $date = date_i18n( 'Y-m-d H:i:s' );
493
+ $host = ( ! empty( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ) : 'localhost' );
494
 
495
+ if ( Util_Environment::is_preview_mode() ) {
496
  $buffer .= "\r\n<!-- W3 Total Cache used in preview mode -->";
497
+ }
498
 
499
  $strings = array();
500
 
501
+ if ( ! $this->_config->get_boolean( 'common.tweeted' ) ) {
502
  $strings[] = 'Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/';
503
  $strings[] = '';
504
  }
507
 
508
  if ( count( $strings ) ) {
509
  $strings[] = '';
510
+ $strings[] = sprintf(
511
+ 'Served from: %1$s @ %2$s by W3 Total Cache',
512
+ Util_Content::escape_comment( $host ),
513
+ $date
514
+ );
515
 
516
  $buffer .= "\r\n<!--\r\n" .
517
  Util_Content::escape_comment( implode( "\r\n", $strings ) ) .
527
  'newrelic',
528
  'cdn',
529
  'browsercache',
530
+ 'pagecache',
531
+ ),
532
+ $buffer
533
+ );
534
 
535
  $buffer = apply_filters( 'w3tc_processed_content', $buffer );
536
  }
587
  /**
588
  * Check User Agent
589
  */
590
+ $http_user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '';
591
+ if ( stristr( $http_user_agent, W3TC_POWERED_BY ) !== false ) {
592
  return false;
593
  }
594
 
602
  */
603
  function check_login_action( $logged_in_cookie = false, $expire = ' ', $expiration = 0, $user_id = 0, $action = 'logged_out' ) {
604
  $current_user = wp_get_current_user();
605
+ if ( isset( $current_user->ID ) && ! $current_user->ID ) {
606
  $user_id = new \WP_User( $user_id );
607
+ } else {
608
  $user_id = $current_user;
609
+ }
610
 
611
  if ( is_string( $user_id->roles ) ) {
612
  $roles = array( $user_id->roles );
613
+ } elseif ( ! is_array( $user_id->roles ) || count( $user_id->roles ) <= 0 ) {
614
  return;
615
  } else {
616
  $roles = $user_id->roles;
618
 
619
  $rejected_roles = $this->_config->get_array( 'pgcache.reject.roles' );
620
 
621
+ if ( 'logged_out' === $action ) {
622
  foreach ( $rejected_roles as $role ) {
623
  $role_hash = md5( NONCE_KEY . $role );
624
+ setcookie(
625
+ 'w3tc_logged_' . $role_hash,
626
+ $expire,
627
+ time() - 31536000,
628
+ COOKIEPATH,
629
+ COOKIE_DOMAIN
630
+ );
631
  }
632
 
633
  return;
634
  }
635
 
636
+ if ( 'logged_in' !== $action ) {
637
  return;
638
+ }
639
 
640
  foreach ( $roles as $role ) {
641
+ if ( in_array( $role, $rejected_roles, true ) ) {
642
  $role_hash = md5( NONCE_KEY . $role );
643
+ setcookie(
644
+ 'w3tc_logged_' . $role_hash,
645
+ true,
646
+ $expire,
647
+ COOKIEPATH,
648
+ COOKIE_DOMAIN,
649
+ is_ssl(),
650
+ true
651
+ );
652
  }
653
  }
654
  }
Generic_Plugin_Admin.php CHANGED
@@ -179,15 +179,15 @@ class Generic_Plugin_Admin {
179
 
180
  try {
181
  $base_capability = apply_filters( 'w3tc_ajax_base_capability_', 'manage_options' );
182
- $capability = apply_filters( 'w3tc_ajax_capability_' . $_REQUEST['w3tc_action'],
183
  $base_capability );
184
  if ( !empty( $capability ) && !current_user_can( $capability ) )
185
  throw new \Exception( 'no permissions' );
186
 
187
  do_action( 'w3tc_ajax' );
188
- do_action( 'w3tc_ajax_' . $_REQUEST['w3tc_action'] );
189
  } catch ( \Exception $e ) {
190
- echo $e->getMessage();
191
  }
192
 
193
  exit();
@@ -204,7 +204,7 @@ class Generic_Plugin_Admin {
204
 
205
  header( "Content-Type: application/x-javascript; charset=UTF-8" );
206
  echo 'document.getElementById("w3tc_monitoring_score") && ( document.getElementById("w3tc_monitoring_score").innerHTML = "' .
207
- strtr( $score, '"', '.' ) . '" );';
208
 
209
  exit();
210
  }
@@ -220,8 +220,10 @@ class Generic_Plugin_Admin {
220
  Util_Activation::deactivate_plugin();
221
  }
222
 
223
- if ( isset( $_REQUEST['page'] ) )
224
- do_action( 'admin_init_' . $_REQUEST['page'] );
 
 
225
  }
226
 
227
  /**
@@ -258,10 +260,11 @@ class Generic_Plugin_Admin {
258
  foreach ( $this->w3tc_message['actions'] as $action )
259
  do_action( 'w3tc_message_action_' . $action );
260
  }
261
- // for testing
262
- if ( isset( $_REQUEST['w3tc_message_action'] ) )
263
- do_action( 'w3tc_message_action_' . $_REQUEST['w3tc_message_action'] );
264
-
 
265
  }
266
 
267
  // Define icon styles for the custom post type
@@ -309,18 +312,19 @@ class Generic_Plugin_Admin {
309
  })(window,document,'script','https://api.w3-edge.com/v1/analytics','w3tc_ga');
310
 
311
  if (window.w3tc_ga) {
312
- w3tc_ga('create', '<?php echo $profile ?>', 'auto');
313
  w3tc_ga('set', {
314
  'dimension1': 'w3-total-cache',
315
- 'dimension2': '<?php echo W3TC_VERSION ?>',
316
- 'dimension3': '<?php global $wp_version; echo $wp_version; ?>',
317
- 'dimension4': 'php<?php echo phpversion() ?>',
318
- 'dimension5': '<?php echo esc_attr( $_SERVER["SERVER_SOFTWARE"] ) ?>',
319
- 'dimension6': 'mysql<?php global $wpdb; echo $wpdb->db_version() ?>',
320
- 'dimension7': '<?php echo Util_Environment::home_url_host() ?>',
321
- 'dimension9': '<?php echo esc_attr( $state->get_string( 'common.install_version' ) ) ?>',
322
- 'dimension10': '<?php echo esc_attr( Util_Environment::w3tc_edition( $this->_config ) ) ?>',
323
- 'dimension11': '<?php echo esc_attr( Util_Widget::list_widgets() ) ?>',
 
324
  'page': '<?php echo esc_attr( $page ); ?>'
325
  });
326
 
@@ -392,10 +396,10 @@ class Generic_Plugin_Admin {
392
  }
393
 
394
  global $pagenow;
395
- if ( $pagenow == 'plugins.php' || $this->is_w3tc_page ||
396
- isset( $_REQUEST['w3tc_note'] ) ||
397
- isset( $_REQUEST['w3tc_error'] ) ||
398
- isset( $_REQUEST['w3tc_message'] ) ) {
399
  /**
400
  * Only admin can see W3TC notices and errors
401
  */
@@ -518,7 +522,7 @@ class Generic_Plugin_Admin {
518
  }
519
 
520
  public function w3tc_ajax_faq() {
521
- $section = $_REQUEST['section'];
522
 
523
  $entries = Generic_Faq::parse( $section );
524
  $response = array();
@@ -609,7 +613,7 @@ class Generic_Plugin_Admin {
609
 
610
  $changelog = (array) preg_split( '~[\r\n]+~', trim( $matches[1] ) );
611
 
612
- echo '<div style="color: #f00;">' . __( 'Take a minute to update, here\'s why:', 'w3-total-cache' ) . '</div><div style="font-weight: normal;height:300px;overflow:auto">';
613
  $ul = false;
614
 
615
  foreach ( $changelog as $index => $line ) {
@@ -619,7 +623,7 @@ class Generic_Plugin_Admin {
619
  $ul = true;
620
  }
621
  $line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) );
622
- echo '<li style="width: 50%; margin: 0; float: left; ' . ( $index % 2 == 0 ? 'clear: left;' : '' ) . '">' . $line . '</li>';
623
  } else {
624
  if ( $ul ) {
625
  echo '</ul><div style="clear: left;"></div>';
@@ -741,9 +745,9 @@ class Generic_Plugin_Admin {
741
  $environment = Dispatcher::component( 'Root_Environment' );
742
  $environment->fix_in_wpadmin( $this->_config );
743
 
744
- if ( isset( $_REQUEST['upgrade'] ) )
745
- $notes[] = __( 'Required files and directories have been automatically created',
746
- 'w3-total-cache' );
747
  } catch ( Util_Environment_Exceptions $exs ) {
748
  $r = Util_Activation::parse_environment_exceptions( $exs );
749
  $n = 1;
@@ -800,27 +804,47 @@ class Generic_Plugin_Admin {
800
  }
801
 
802
  foreach ( $r['later_errors'] as $e ) {
803
- $errors['generic_env_' . $n] = $e;
804
  $n++;
805
  }
806
  }
807
 
808
  $errors = apply_filters( 'w3tc_errors', $errors );
809
- $notes = apply_filters( 'w3tc_notes', $notes );
810
 
811
  /**
812
- * Show messages
813
  */
814
  foreach ( $notes as $key => $note ) {
815
- echo sprintf(
816
- '<div class="updated w3tc_note" id="%s"><p>%s</p></div>',
817
- $key,
818
- $note );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
819
  }
820
 
821
  foreach ( $errors as $key => $error ) {
822
- echo sprintf( '<div class="error w3tc_error" id="%s"><p>%s</p></div>',
823
- $key, $error );
 
 
 
824
  }
825
  }
826
  }
179
 
180
  try {
181
  $base_capability = apply_filters( 'w3tc_ajax_base_capability_', 'manage_options' );
182
+ $capability = apply_filters( 'w3tc_ajax_capability_' . Util_Request::get_string( 'w3tc_action' ),
183
  $base_capability );
184
  if ( !empty( $capability ) && !current_user_can( $capability ) )
185
  throw new \Exception( 'no permissions' );
186
 
187
  do_action( 'w3tc_ajax' );
188
+ do_action( 'w3tc_ajax_' . Util_Request::get_string( 'w3tc_action' ) );
189
  } catch ( \Exception $e ) {
190
+ echo esc_html( $e->getMessage() );
191
  }
192
 
193
  exit();
204
 
205
  header( "Content-Type: application/x-javascript; charset=UTF-8" );
206
  echo 'document.getElementById("w3tc_monitoring_score") && ( document.getElementById("w3tc_monitoring_score").innerHTML = "' .
207
+ esc_html( strtr( $score, '"', '.' ) ) . '" );';
208
 
209
  exit();
210
  }
220
  Util_Activation::deactivate_plugin();
221
  }
222
 
223
+ $page_val = Util_Request::get_string( 'page' );
224
+ if ( ! empty( $page_val ) ) {
225
+ do_action( 'admin_init_' . $page_val );
226
+ }
227
  }
228
 
229
  /**
260
  foreach ( $this->w3tc_message['actions'] as $action )
261
  do_action( 'w3tc_message_action_' . $action );
262
  }
263
+ // for testing.
264
+ $w3tc_message_action_val = Util_Request::get_string( 'w3tc_message_action' );
265
+ if ( ! empty( $w3tc_message_action_val ) ) {
266
+ do_action( 'w3tc_message_action_' . $w3tc_message_action_val );
267
+ }
268
  }
269
 
270
  // Define icon styles for the custom post type
312
  })(window,document,'script','https://api.w3-edge.com/v1/analytics','w3tc_ga');
313
 
314
  if (window.w3tc_ga) {
315
+ w3tc_ga('create', '<?php echo esc_html( $profile ); ?>', 'auto');
316
  w3tc_ga('set', {
317
  'dimension1': 'w3-total-cache',
318
+ 'dimension2': '<?php echo esc_html( W3TC_VERSION ); ?>',
319
+ 'dimension3': '<?php global $wp_version; echo esc_html( $wp_version ); ?>',
320
+ 'dimension4': 'php<?php echo esc_html( phpversion() ); ?>',
321
+ 'dimension5': '<?php echo esc_attr( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '' ); ?>',
322
+ 'dimension6': 'mysql<?php global $wpdb; echo esc_attr( $wpdb->db_version() ); ?>',
323
+ 'dimension7': '<?php echo esc_url( Util_Environment::home_url_host() ); ?>',
324
+ 'dimension9': '<?php echo esc_attr( $state->get_string( 'common.install_version' ) ); ?>',
325
+ 'dimension10': '<?php echo esc_attr( Util_Environment::w3tc_edition( $this->_config ) ); ?>',
326
+ 'dimension11': '<?php echo esc_attr( Util_Widget::list_widgets() ); ?>',
327
+
328
  'page': '<?php echo esc_attr( $page ); ?>'
329
  });
330
 
396
  }
397
 
398
  global $pagenow;
399
+ if ( 'plugins.php' === $pagenow || $this->is_w3tc_page ||
400
+ ! empty( Util_Request::get_string( 'w3tc_note' ) ) ||
401
+ ! empty( Util_Request::get_string( 'w3tc_error' ) ) ||
402
+ ! empty( Util_Request::get_string( 'w3tc_message' ) ) ) {
403
  /**
404
  * Only admin can see W3TC notices and errors
405
  */
522
  }
523
 
524
  public function w3tc_ajax_faq() {
525
+ $section = Util_Request::get_string( 'section' );
526
 
527
  $entries = Generic_Faq::parse( $section );
528
  $response = array();
613
 
614
  $changelog = (array) preg_split( '~[\r\n]+~', trim( $matches[1] ) );
615
 
616
+ echo '<div style="color: #f00;">' . esc_html__( 'Take a minute to update, here\'s why:', 'w3-total-cache' ) . '</div><div style="font-weight: normal;height:300px;overflow:auto">';
617
  $ul = false;
618
 
619
  foreach ( $changelog as $index => $line ) {
623
  $ul = true;
624
  }
625
  $line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) );
626
+ echo '<li style="width: 50%; margin: 0; float: left; ' . ( $index % 2 == 0 ? 'clear: left;' : '' ) . '">' . esc_html( $line ) . '</li>';
627
  } else {
628
  if ( $ul ) {
629
  echo '</ul><div style="clear: left;"></div>';
745
  $environment = Dispatcher::component( 'Root_Environment' );
746
  $environment->fix_in_wpadmin( $this->_config );
747
 
748
+ if ( ! empty( Util_Request::get_string( 'upgrade' ) ) ) {
749
+ $notes[] = __( 'Required files and directories have been automatically created', 'w3-total-cache' );
750
+ }
751
  } catch ( Util_Environment_Exceptions $exs ) {
752
  $r = Util_Activation::parse_environment_exceptions( $exs );
753
  $n = 1;
804
  }
805
 
806
  foreach ( $r['later_errors'] as $e ) {
807
+ $errors[ 'generic_env_' . $n ] = $e;
808
  $n++;
809
  }
810
  }
811
 
812
  $errors = apply_filters( 'w3tc_errors', $errors );
813
+ $notes = apply_filters( 'w3tc_notes', $notes );
814
 
815
  /**
816
+ * Show messages.
817
  */
818
  foreach ( $notes as $key => $note ) {
819
+ echo wp_kses(
820
+ sprintf(
821
+ '<div class="updated w3tc_note" id="%1$s"><p>%2$s</p></div>',
822
+ esc_attr( $key ),
823
+ $note
824
+ ),
825
+ array(
826
+ 'div' => array(
827
+ 'class' => array(),
828
+ 'id' => array(),
829
+ ),
830
+ 'input' => array(
831
+ 'class' => array(),
832
+ 'name' => array(),
833
+ 'onclick' => array(),
834
+ 'type' => array(),
835
+ 'value' => array(),
836
+ ),
837
+ 'p' => array(),
838
+ )
839
+ );
840
  }
841
 
842
  foreach ( $errors as $key => $error ) {
843
+ printf(
844
+ '<div class="error w3tc_error" id="%1$s"><p>%2$s</p></div>',
845
+ esc_attr( $key ),
846
+ $error // phpcs:ignore
847
+ );
848
  }
849
  }
850
  }
Generic_Plugin_AdminNotifications.php CHANGED
@@ -39,10 +39,6 @@ class Generic_Plugin_AdminNotifications {
39
  $this,
40
  'w3tc_message_action_generic_edge'
41
  ) );
42
- add_action( 'w3tc_ajax_generic_edge', array(
43
- $this,
44
- 'w3tc_ajax_generic_edge'
45
- ) );
46
  }
47
  }
48
 
39
  $this,
40
  'w3tc_message_action_generic_edge'
41
  ) );
 
 
 
 
42
  }
43
  }
44
 
Generic_Plugin_AdminRowActions.php CHANGED
@@ -69,9 +69,11 @@ class Generic_Plugin_AdminRowActions {
69
  'w3tc_flush_post' => 'y',
70
  'post_id' => $post->ID ) );
71
 
72
- echo sprintf( '<div><a href="%s">%s</a></div>',
73
- $url,
74
- __( 'Purge from cache', 'w3-total-cache' ) );
 
 
75
  }
76
  }
77
  }
69
  'w3tc_flush_post' => 'y',
70
  'post_id' => $post->ID ) );
71
 
72
+ echo sprintf(
73
+ '<div><a href="%s">%s</a></div>',
74
+ esc_url( $url ),
75
+ esc_html__( 'Purge from cache', 'w3-total-cache' )
76
+ );
77
  }
78
  }
79
  }
Generic_Plugin_Admin_View_Faq.php CHANGED
@@ -1,22 +1,40 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <div id="w3tc-help">
9
- <p><?php _e( 'Request professional <a href="admin.php?page=w3tc_support" style="color: red;"><strong>support</strong></a> or troubleshoot issues using the common questions below:', 'w3-total-cache' ); ?></p>
10
-
11
- <ul>
12
- <?php foreach ( $entries as $entry ): ?>
13
- <li>
14
- <a href="<?php echo htmlspecialchars($entry['a']) ?>" target="_blank"><?php
15
- echo htmlspecialchars($entry['q'])
16
- ?></a>
17
- </li>
18
- <?php endforeach; ?>
19
- </ul>
20
-
21
- <div style="clear: left;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div id="w3tc-help">
9
+ <p>
10
+ <?php
11
+ echo wp_kses(
12
+ sprintf(
13
+ // translators: 1 opening HTML a tag to W3TC support plugin page followed by opening HTML strong tag,
14
+ // translators: 2 closing HTML strong tag followed by closing HTML a tag.
15
+ __(
16
+ 'Request professional %1$ssupport%2$s or troubleshoot issues using the common questions below:',
17
+ 'w3-total-cache'
18
+ ),
19
+ '<a href="admin.php?page=w3tc_support" style="color: red;"><strong>',
20
+ '</strong></a>'
21
+ ),
22
+ array(
23
+ 'a' => array(
24
+ 'href' => array(),
25
+ 'style' => array(),
26
+ ),
27
+ 'strong' => array(),
28
+ )
29
+ );
30
+ ?>
31
+ </p>
32
+ <ul>
33
+ <?php foreach ( $entries as $entry ) : ?>
34
+ <li>
35
+ <a href="<?php echo esc_url( $entry['a'] ); ?>" target="_blank"><?php echo esc_html( $entry['q'] ); ?></a>
36
+ </li>
37
+ <?php endforeach; ?>
38
+ </ul>
39
+ <div style="clear: left;"></div>
40
  </div>
Generic_Plugin_WidgetForum.php CHANGED
@@ -1,40 +1,47 @@
1
  <?php
2
- namespace W3TC;
3
-
4
  /**
5
- * W3 Forum Widget
 
 
6
  */
7
 
8
-
9
 
10
  /**
11
- * Class Generic_Plugin_WidgetForum
12
  */
13
  class Generic_Plugin_WidgetForum {
14
  /**
15
- * Config
 
 
16
  */
17
- private $_config = null;
18
 
19
- function __construct() {
 
 
 
20
  $this->_config = Dispatcher::config();
21
  }
22
 
23
  /**
24
- * Runs plugin
25
  */
26
- function run() {
27
- if ( Util_Admin::get_current_wp_page() == 'w3tc_dashboard' )
28
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
 
29
 
30
- add_action( 'w3tc_widget_setup', array(
31
- $this,
32
- 'wp_dashboard_setup'
33
- ) );
34
- add_action( 'w3tc_network_dashboard_setup', array(
35
- $this,
36
- 'wp_dashboard_setup'
37
- ) );
 
38
 
39
  if ( is_admin() ) {
40
  add_action( 'wp_ajax_w3tc_widget_latest_ajax', array( $this, 'action_widget_latest_ajax' ) );
@@ -42,63 +49,70 @@ class Generic_Plugin_WidgetForum {
42
  }
43
 
44
  /**
45
- * Dashboard setup action
46
- *
47
- * @return void
48
  */
49
- function wp_dashboard_setup() {
50
- Util_Widget::add( 'w3tc_latest', __( 'Discussions', 'w3-total-cache' ), array(
51
- $this,
52
- 'widget_latest'
53
- ), array(
54
- $this,
55
- 'widget_latest_control'
56
- ), 'side' );
57
  }
58
 
59
  /**
60
- * Returns key for transient cache of "widget latest"
61
- *
62
- * @return string
63
  */
64
- function _widget_latest_cache_key() {
65
  return 'dash_' . md5( 'w3tc_latest' );
66
  }
67
 
68
  /**
69
- * Prints latest widget contents
70
- *
71
- * @return void
72
  */
73
- function widget_latest() {
74
- if ( false !== ( $output = get_transient( $this->_widget_latest_cache_key() ) ) )
75
- echo $output;
76
- else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  include W3TC_INC_DIR . '/widget/latest.php';
 
78
  }
79
 
80
  /**
81
- * Prints latest widget contents
82
- *
83
- * @return void
84
  */
85
- function action_widget_latest_ajax() {
86
- // load content of feed
87
  global $wp_version;
88
 
89
- $items = array();
90
  $items_count = $this->_config->get_integer( 'widget.latest.items' );
91
 
92
  include_once ABSPATH . WPINC . '/feed.php';
93
  $feed = fetch_feed( W3TC_FEED_URL );
94
 
95
- if ( !is_wp_error( $feed ) ) {
96
  $feed_items = $feed->get_items( 0, $items_count );
97
 
98
  foreach ( $feed_items as $feed_item ) {
99
  $items[] = array(
100
- 'link' => $feed_item->get_link(),
101
- 'title' => htmlspecialchars_decode( $feed_item->get_title() )
102
  );
103
  }
104
  }
@@ -106,7 +120,7 @@ class Generic_Plugin_WidgetForum {
106
  ob_start();
107
  include W3TC_INC_DIR . '/widget/latest_ajax.php';
108
 
109
- // Default lifetime in cache of 12 hours (same as the feeds)
110
  set_transient( $this->_widget_latest_cache_key(), ob_get_flush(), 43200 );
111
  die();
112
  }
@@ -114,12 +128,11 @@ class Generic_Plugin_WidgetForum {
114
  /**
115
  * Latest widget control
116
  *
117
- * @param integer $widget_id
118
- * @param array $form_inputs
119
- * @return void
120
  */
121
- function widget_latest_control( $widget_id, $form_inputs = array() ) {
122
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
123
  $this->_config->set( 'widget.latest.items', Util_Request::get_integer( 'w3tc_widget_latest_items', 3 ) );
124
  $this->_config->save();
125
  delete_transient( $this->_widget_latest_cache_key() );
@@ -127,6 +140,9 @@ class Generic_Plugin_WidgetForum {
127
  include W3TC_INC_DIR . '/widget/latest_control.php';
128
  }
129
 
 
 
 
130
  public function enqueue() {
131
  wp_enqueue_style( 'w3tc-widget' );
132
  wp_enqueue_script( 'w3tc-metadata' );
1
  <?php
 
 
2
  /**
3
+ * File: Generic_Plugin_WidgetForumn.php
4
+ *
5
+ * @package W3TC
6
  */
7
 
8
+ namespace W3TC;
9
 
10
  /**
11
+ * Class: Generic_Plugin_WidgetForum
12
  */
13
  class Generic_Plugin_WidgetForum {
14
  /**
15
+ * Config.
16
+ *
17
+ * @var Config
18
  */
19
+ private $_config = null; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
20
 
21
+ /**
22
+ * Constructor.
23
+ */
24
+ public function __construct() {
25
  $this->_config = Dispatcher::config();
26
  }
27
 
28
  /**
29
+ * Runs plugin.
30
  */
31
+ public function run() {
32
+ if ( Util_Admin::get_current_wp_page() == 'w3tc_dashboard' ) {
33
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
34
+ }
35
 
36
+ add_action(
37
+ 'w3tc_widget_setup',
38
+ array( $this, 'wp_dashboard_setup' )
39
+ );
40
+
41
+ add_action(
42
+ 'w3tc_network_dashboard_setup',
43
+ array( $this, 'wp_dashboard_setup' )
44
+ );
45
 
46
  if ( is_admin() ) {
47
  add_action( 'wp_ajax_w3tc_widget_latest_ajax', array( $this, 'action_widget_latest_ajax' ) );
49
  }
50
 
51
  /**
52
+ * Dashboard setup action.
 
 
53
  */
54
+ public function wp_dashboard_setup() {
55
+ Util_Widget::add(
56
+ 'w3tc_latest',
57
+ __( 'Discussions', 'w3-total-cache' ),
58
+ array( $this, 'widget_latest' ),
59
+ array( $this, 'widget_latest_control' ),
60
+ 'side'
61
+ );
62
  }
63
 
64
  /**
65
+ * Returns key for transient cache of "widget latest".
 
 
66
  */
67
+ public function _widget_latest_cache_key() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
68
  return 'dash_' . md5( 'w3tc_latest' );
69
  }
70
 
71
  /**
72
+ * Prints latest widget contents.
 
 
73
  */
74
+ public function widget_latest() {
75
+ $output = get_transient( $this->_widget_latest_cache_key() );
76
+
77
+ if ( false !== $output ) {
78
+ echo wp_kses(
79
+ $output,
80
+ array(
81
+ 'a' => array(
82
+ 'href' => array(),
83
+ 'target' => array(),
84
+ ),
85
+ 'h4' => array(),
86
+ 'p' => array(
87
+ 'style' => array(),
88
+ ),
89
+ )
90
+ );
91
+ } else {
92
  include W3TC_INC_DIR . '/widget/latest.php';
93
+ }
94
  }
95
 
96
  /**
97
+ * Prints latest widget contents.
 
 
98
  */
99
+ public function action_widget_latest_ajax() {
100
+ // Load content of feed.
101
  global $wp_version;
102
 
103
+ $items = array();
104
  $items_count = $this->_config->get_integer( 'widget.latest.items' );
105
 
106
  include_once ABSPATH . WPINC . '/feed.php';
107
  $feed = fetch_feed( W3TC_FEED_URL );
108
 
109
+ if ( ! is_wp_error( $feed ) ) {
110
  $feed_items = $feed->get_items( 0, $items_count );
111
 
112
  foreach ( $feed_items as $feed_item ) {
113
  $items[] = array(
114
+ 'link' => $feed_item->get_link(),
115
+ 'title' => htmlspecialchars_decode( $feed_item->get_title() ),
116
  );
117
  }
118
  }
120
  ob_start();
121
  include W3TC_INC_DIR . '/widget/latest_ajax.php';
122
 
123
+ // Default lifetime in cache of 12 hours (same as the feeds).
124
  set_transient( $this->_widget_latest_cache_key(), ob_get_flush(), 43200 );
125
  die();
126
  }
128
  /**
129
  * Latest widget control
130
  *
131
+ * @param integer $widget_id Widget id.
132
+ * @param array $form_inputs Form inputs.
 
133
  */
134
+ public function widget_latest_control( $widget_id, $form_inputs = array() ) {
135
+ if ( 'POST' === ( isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : '' ) ) {
136
  $this->_config->set( 'widget.latest.items', Util_Request::get_integer( 'w3tc_widget_latest_items', 3 ) );
137
  $this->_config->save();
138
  delete_transient( $this->_widget_latest_cache_key() );
140
  include W3TC_INC_DIR . '/widget/latest_control.php';
141
  }
142
 
143
+ /**
144
+ * Enqueue scripts and styles.
145
+ */
146
  public function enqueue() {
147
  wp_enqueue_style( 'w3tc-widget' );
148
  wp_enqueue_script( 'w3tc-metadata' );
Generic_Plugin_WidgetNews.php CHANGED
@@ -1,33 +1,40 @@
1
  <?php
 
 
 
 
 
 
2
  namespace W3TC;
 
3
  /**
4
- * W3 Forum Widget
5
  */
6
  class Generic_Plugin_WidgetNews {
7
  /**
8
- * Config
 
 
9
  */
10
- private $_config = null;
11
 
12
- function __construct() {
 
 
 
13
  $this->_config = Dispatcher::config();
14
  }
15
 
16
  /**
17
- * Runs plugin
18
  */
19
- function run() {
20
- if ( Util_Admin::get_current_wp_page() == 'w3tc_dashboard' )
21
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
 
22
 
23
- add_action( 'w3tc_widget_setup', array(
24
- $this,
25
- 'wp_dashboard_setup'
26
- ) );
27
- add_action( 'w3tc_network_dashboard_setup', array(
28
- $this,
29
- 'wp_dashboard_setup'
30
- ) );
31
 
32
  if ( is_admin() ) {
33
  add_action( 'wp_ajax_w3tc_widget_latest_news_ajax', array( $this, 'action_widget_latest_news_ajax' ) );
@@ -35,18 +42,22 @@ class Generic_Plugin_WidgetNews {
35
  }
36
 
37
  /**
38
- * Dashboard setup action
39
- *
40
- * @return void
41
  */
42
- function wp_dashboard_setup() {
43
- Util_Widget::add( 'w3tc_latest_news', __( 'News', 'w3-total-cache' ), array(
 
 
 
44
  $this,
45
- 'widget_latest'
46
- ), array(
 
47
  $this,
48
- 'widget_latest_control'
49
- ), 'side' );
 
 
50
  }
51
 
52
  /**
@@ -54,7 +65,7 @@ class Generic_Plugin_WidgetNews {
54
  *
55
  * @return string
56
  */
57
- function _widget_latest_cache_key() {
58
  return 'dash_' . md5( 'w3tc_latest_news' );
59
  }
60
 
@@ -63,35 +74,49 @@ class Generic_Plugin_WidgetNews {
63
  *
64
  * @return void
65
  */
66
- function widget_latest() {
67
- if ( false !== ( $output = get_transient( $this->_widget_latest_cache_key() ) ) )
68
- echo $output;
69
- else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  include W3TC_INC_DIR . '/widget/latest_news.php';
 
71
  }
72
 
73
  /**
74
- * Prints latest widget contents
75
- *
76
- * @return void
77
  */
78
- function action_widget_latest_news_ajax() {
79
- // load content of feed
80
  global $wp_version;
81
 
82
- $items = array();
83
  $items_count = $this->_config->get_integer( 'widget.latest_news.items' );
84
 
85
  include_once ABSPATH . WPINC . '/feed.php';
 
86
  $feed = fetch_feed( W3TC_NEWS_FEED_URL );
87
 
88
- if ( !is_wp_error( $feed ) ) {
89
  $feed_items = $feed->get_items( 0, $items_count );
90
 
91
  foreach ( $feed_items as $feed_item ) {
92
  $items[] = array(
93
- 'link' => $feed_item->get_link(),
94
- 'title' => htmlspecialchars_decode( $feed_item->get_title() )
95
  );
96
  }
97
  }
@@ -99,22 +124,19 @@ class Generic_Plugin_WidgetNews {
99
  ob_start();
100
  include W3TC_INC_DIR . '/widget/latest_news_ajax.php';
101
 
102
- // Default lifetime in cache of 12 hours (same as the feeds)
103
  set_transient( $this->_widget_latest_cache_key(), ob_get_flush(), 43200 );
104
  die();
105
  }
106
 
107
  /**
108
- * Latest widget control
109
  *
110
- * @param integer $widget_id
111
- * @param array $form_inputs
112
- * @return void
113
  */
114
- function widget_latest_control( $widget_id, $form_inputs = array() ) {
115
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
116
-
117
-
118
  $this->_config->set( 'widget.latest_news.items', Util_Request::get_integer( 'w3tc_widget_latest_news_items', 3 ) );
119
  $this->_config->save();
120
  delete_transient( $this->_widget_latest_cache_key() );
@@ -122,6 +144,9 @@ class Generic_Plugin_WidgetNews {
122
  include W3TC_INC_DIR . '/widget/latest_news_control.php';
123
  }
124
 
 
 
 
125
  public function enqueue() {
126
  wp_enqueue_style( 'w3tc-widget' );
127
  wp_enqueue_script( 'w3tc-metadata' );
1
  <?php
2
+ /**
3
+ * File: Generic_Plugin_WidgetNews.php
4
+ *
5
+ * @package W3TC
6
+ */
7
+
8
  namespace W3TC;
9
+
10
  /**
11
+ * Class: Generic_Plugin_WidgetNews
12
  */
13
  class Generic_Plugin_WidgetNews {
14
  /**
15
+ * Config.
16
+ *
17
+ * @var Config
18
  */
19
+ private $_config = null; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
20
 
21
+ /**
22
+ * Constructor.
23
+ */
24
+ public function __construct() {
25
  $this->_config = Dispatcher::config();
26
  }
27
 
28
  /**
29
+ * Runs plugin.
30
  */
31
+ public function run() {
32
+ if ( Util_Admin::get_current_wp_page() === 'w3tc_dashboard' ) {
33
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
34
+ }
35
 
36
+ add_action( 'w3tc_widget_setup', array( $this, 'wp_dashboard_setup' ) );
37
+ add_action( 'w3tc_network_dashboard_setup', array( $this, 'wp_dashboard_setup' ) );
 
 
 
 
 
 
38
 
39
  if ( is_admin() ) {
40
  add_action( 'wp_ajax_w3tc_widget_latest_news_ajax', array( $this, 'action_widget_latest_news_ajax' ) );
42
  }
43
 
44
  /**
45
+ * Dashboard setup action.
 
 
46
  */
47
+ public function wp_dashboard_setup() {
48
+ Util_Widget::add(
49
+ 'w3tc_latest_news',
50
+ __( 'News', 'w3-total-cache' ),
51
+ array(
52
  $this,
53
+ 'widget_latest',
54
+ ),
55
+ array(
56
  $this,
57
+ 'widget_latest_control',
58
+ ),
59
+ 'side'
60
+ );
61
  }
62
 
63
  /**
65
  *
66
  * @return string
67
  */
68
+ public function _widget_latest_cache_key() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
69
  return 'dash_' . md5( 'w3tc_latest_news' );
70
  }
71
 
74
  *
75
  * @return void
76
  */
77
+ public function widget_latest() {
78
+ $output = get_transient( $this->_widget_latest_cache_key() );
79
+
80
+ if ( false !== $output ) {
81
+ echo wp_kses(
82
+ $output,
83
+ array(
84
+ 'a' => array(
85
+ 'href' => array(),
86
+ 'target' => array(),
87
+ ),
88
+ 'h4' => array(),
89
+ 'p' => array(
90
+ 'style' => array(),
91
+ ),
92
+ )
93
+ );
94
+ } else {
95
  include W3TC_INC_DIR . '/widget/latest_news.php';
96
+ }
97
  }
98
 
99
  /**
100
+ * Prints latest widget contents.
 
 
101
  */
102
+ public function action_widget_latest_news_ajax() {
103
+ // load content of feed.
104
  global $wp_version;
105
 
106
+ $items = array();
107
  $items_count = $this->_config->get_integer( 'widget.latest_news.items' );
108
 
109
  include_once ABSPATH . WPINC . '/feed.php';
110
+
111
  $feed = fetch_feed( W3TC_NEWS_FEED_URL );
112
 
113
+ if ( ! is_wp_error( $feed ) ) {
114
  $feed_items = $feed->get_items( 0, $items_count );
115
 
116
  foreach ( $feed_items as $feed_item ) {
117
  $items[] = array(
118
+ 'link' => $feed_item->get_link(),
119
+ 'title' => htmlspecialchars_decode( $feed_item->get_title() ),
120
  );
121
  }
122
  }
124
  ob_start();
125
  include W3TC_INC_DIR . '/widget/latest_news_ajax.php';
126
 
127
+ // Default lifetime in cache of 12 hours (same as the feeds).
128
  set_transient( $this->_widget_latest_cache_key(), ob_get_flush(), 43200 );
129
  die();
130
  }
131
 
132
  /**
133
+ * Latest widget control.
134
  *
135
+ * @param integer $widget_id Widget id.
136
+ * @param array $form_inputs Form inputs.
 
137
  */
138
+ public function widget_latest_control( $widget_id, $form_inputs = array() ) {
139
+ if ( 'POST' === ( isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : '' ) ) {
 
 
140
  $this->_config->set( 'widget.latest_news.items', Util_Request::get_integer( 'w3tc_widget_latest_news_items', 3 ) );
141
  $this->_config->save();
142
  delete_transient( $this->_widget_latest_cache_key() );
144
  include W3TC_INC_DIR . '/widget/latest_news_control.php';
145
  }
146
 
147
+ /**
148
+ * Enqueue scripts and styles.
149
+ */
150
  public function enqueue() {
151
  wp_enqueue_style( 'w3tc-widget' );
152
  wp_enqueue_script( 'w3tc-metadata' );
Generic_WidgetServices_View.php CHANGED
@@ -1,35 +1,37 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <form action="admin.php" xmlns="http://www.w3.org/1999/html" method="get">
9
- <input type="hidden" name="page" value="w3tc_support" />
10
-
11
- <ul>
12
- <?php
13
- for ( $n = 0; $n < ( is_array( $items ) ? count( $items ) : 0 ); $n++ ): ?>
14
- <li>
15
- <div class="w3tc_generic_widgetservice_radio_outer">
16
- <input id="service<?php echo $n ?>"
17
- type="radio"
18
- class="w3tc_generic_widgetservice_radio w3tc-ignore-change"
19
- name="service_item"
20
- value="<?php echo $n ?>"
21
- />
22
- </div>
23
- <label for="service<?php echo $n ?>" class="w3tc_generic_widgetservice_label">
24
- <?php echo htmlspecialchars( $items[$n]['name'] ) ?>
25
- </label>
26
- </li>
27
- <?php endfor ?>
28
- </ul>
29
- <div id="buy-w3-service-area"></div>
30
- <p>
31
- <input id="buy-w3-service" name="buy-w3-service" type="submit"
32
- class="button button-primary button-large"
33
- value="<?php _e( 'Buy now', 'w3-total-cache' ) ?>" />
34
- </p>
 
 
35
  </form>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <form action="admin.php" xmlns="http://www.w3.org/1999/html" method="get">
9
+ <input type="hidden" name="page" value="w3tc_support" />
10
+ <ul>
11
+ <?php
12
+ $cnt = is_array( $items ) ? count( $items ) : 0;
13
+ for ( $n = 0; $n < $cnt; $n++ ) :
14
+ ?>
15
+ <li>
16
+ <div class="w3tc_generic_widgetservice_radio_outer">
17
+ <input id="service<?php echo esc_attr( $n ); ?>"
18
+ type="radio"
19
+ class="w3tc_generic_widgetservice_radio w3tc-ignore-change"
20
+ name="service_item"
21
+ value="<?php echo esc_attr( $n ); ?>" />
22
+ </div>
23
+ <label for="service<?php echo esc_attr( $n ); ?>" class="w3tc_generic_widgetservice_label">
24
+ <?php echo esc_html( $items[ $n ]['name'] ); ?>
25
+ </label>
26
+ </li>
27
+ <?php
28
+ endfor;
29
+ ?>
30
+ </ul>
31
+ <div id="buy-w3-service-area"></div>
32
+ <p>
33
+ <input id="buy-w3-service" name="buy-w3-service" type="submit"
34
+ class="button button-primary button-large"
35
+ value="<?php esc_attr_e( 'Buy now', 'w3-total-cache' ); ?>" />
36
+ </p>
37
  </form>
Generic_WidgetSpreadTheWord_View.php CHANGED
@@ -1,20 +1,20 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
- <p><?php _e( "Enjoying W3TC? Please support us!", 'w3-total-cache' ) ?></p>
9
  <ul>
10
  <li>
11
- <label><?php _e( 'Vote:', 'w3-total-cache' ); ?></label>
12
  <input type="button" class="button button-vote" value="Give us a 5 stars!" />
13
  </li>
14
  </ul>
15
 
16
  <p>
17
- <?php _e( 'Or please share', 'w3-total-cache' ); ?>
18
  <a href="admin.php?page=w3tc_support&amp;request_type=new_feature">your feedback</a>
19
  so that we can improve!
20
  </p>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <p><?php esc_html_e( 'Enjoying W3TC? Please support us!', 'w3-total-cache' ); ?></p>
9
  <ul>
10
  <li>
11
+ <label><?php esc_html_e( 'Vote:', 'w3-total-cache' ); ?></label>
12
  <input type="button" class="button button-vote" value="Give us a 5 stars!" />
13
  </li>
14
  </ul>
15
 
16
  <p>
17
+ <?php esc_html_e( 'Or please share', 'w3-total-cache' ); ?>
18
  <a href="admin.php?page=w3tc_support&amp;request_type=new_feature">your feedback</a>
19
  so that we can improve!
20
  </p>
Licensing_AdminActions.php CHANGED
@@ -30,8 +30,8 @@ class Licensing_AdminActions {
30
 
31
 
32
  private function param( $name ) {
33
- return preg_replace( '/[^0-9a-zA-Z._\-]/', '',
34
- isset( $_REQUEST[$name] ) ? $_REQUEST[$name] : '' );
35
  }
36
 
37
  /**
30
 
31
 
32
  private function param( $name ) {
33
+ $param = Util_Request::get_string( $name );
34
+ return preg_replace( '/[^0-9a-zA-Z._\-]/', '', isset( $param ) ? $param : '' );
35
  }
36
 
37
  /**
Licensing_Core.php CHANGED
@@ -131,4 +131,32 @@ class Licensing_Core {
131
  ( empty( $renew_key ) ? '' : '&renew_key=' . urlencode( $renew_key ) ) .
132
  ( empty( $client_id ) ? '' : '&client_id=' . urlencode( $client_id ) );
133
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
131
  ( empty( $renew_key ) ? '' : '&renew_key=' . urlencode( $renew_key ) ) .
132
  ( empty( $client_id ) ? '' : '&client_id=' . urlencode( $client_id ) );
133
  }
134
+
135
+ /**
136
+ * Get the terms of service choice.
137
+ *
138
+ * @since X.X.X
139
+ *
140
+ * @static
141
+ *
142
+ * @see \W3TC\Util_Environment::is_w3tc_pro()
143
+ * @see \W3TC\Dispatcher::config_state()
144
+ * @see \W3TC\Dispatcher::config_state_master()
145
+ * @see \W3TC\ConfigState::get_string()
146
+ *
147
+ * @return string
148
+ */
149
+ public static function get_tos_choice() {
150
+ $config = Dispatcher::config();
151
+
152
+ if ( Util_Environment::is_w3tc_pro( $config ) ) {
153
+ $state = Dispatcher::config_state();
154
+ $terms = $state->get_string( 'license.terms' );
155
+ } else {
156
+ $state_master = Dispatcher::config_state_master();
157
+ $terms = $state_master->get_string( 'license.community_terms' );
158
+ }
159
+
160
+ return $terms;
161
+ }
162
  }
Licensing_Plugin_Admin.php CHANGED
@@ -3,7 +3,7 @@ namespace W3TC;
3
 
4
  class Licensing_Plugin_Admin {
5
  private $site_inactivated = false;
6
- private $site_activated = false;
7
  /**
8
  * Config
9
  */
@@ -19,39 +19,47 @@ class Licensing_Plugin_Admin {
19
  function run() {
20
  add_action( 'admin_init', array( $this, 'admin_init' ) );
21
  add_action( 'wp_ajax_w3tc_verify_plugin_license_key', array( $this, 'action_verify_plugin_license_key' ) );
22
- add_action( "w3tc_config_ui_save-w3tc_general", array( $this, 'possible_state_change' ), 2, 10 );
23
 
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(
49
- 'id' => 'w3tc_debug_overlay_upgrade',
50
  'parent' => 'w3tc_debug_overlays',
51
- 'title' => __( 'Upgrade', 'w3-total-cache' ),
52
- 'href' => wp_nonce_url( network_admin_url(
53
- 'admin.php?page=w3tc_dashboard&amp;' .
54
- 'w3tc_message_action=licensing_upgrade' ), 'w3tc' )
55
  );
56
  }
57
 
@@ -63,13 +71,13 @@ class Licensing_Plugin_Admin {
63
  }
64
 
65
  public function admin_head_licensing_upgrade() {
66
- ?>
67
  <script type="text/javascript">
68
- jQuery(function() {
69
- w3tc_lightbox_upgrade(w3tc_nonce, 'topbar_performance');
70
- jQuery('#w3tc-license-instruction').show();
71
- });
72
- </script>
73
  <?php
74
  }
75
 
@@ -82,20 +90,20 @@ class Licensing_Plugin_Admin {
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;
@@ -116,8 +124,7 @@ class Licensing_Plugin_Admin {
116
  * Setup notices actions
117
  */
118
  function admin_init() {
119
- $capability = apply_filters( 'w3tc_capability_admin_notices',
120
- 'manage_options' );
121
 
122
  $this->maybe_update_license_status();
123
 
@@ -126,16 +133,10 @@ class Licensing_Plugin_Admin {
126
  /**
127
  * Only admin can see W3TC notices and errors
128
  */
129
- if ( !Util_Environment::is_wpmu() ) {
130
- add_action( 'admin_notices', array(
131
- $this,
132
- 'admin_notices'
133
- ), 1, 1 );
134
  }
135
- add_action( 'network_admin_notices', array(
136
- $this,
137
- 'admin_notices'
138
- ), 1, 1 );
139
 
140
  if ( Util_Admin::is_w3tc_admin_page() ) {
141
  add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
@@ -145,41 +146,56 @@ class Licensing_Plugin_Admin {
145
  }
146
 
147
  private function _status_is( $s, $starts_with ) {
148
- $s .= '.';
149
  $starts_with .= '.';
150
- return substr( $s, 0, strlen( $starts_with ) ) == $starts_with;
151
  }
152
 
153
-
154
-
155
  /**
156
  * Run license status check and display messages
157
  */
158
  function admin_notices() {
159
  $message = '';
160
 
161
- $state = Dispatcher::config_state();
162
  $status = $state->get_string( 'license.status' );
163
 
164
  if ( defined( 'W3TC_PRO' ) ) {
165
- } elseif ( $status == 'no_key' ) {
166
  } elseif ( $this->_status_is( $status, 'inactive.expired' ) ) {
167
- $message = sprintf( __( 'It looks like your W3 Total Cache Pro License has expired. %s to continue using the Pro Features', 'w3-total-cache' ),
168
- '<input type="button" class="button-primary button-buy-plugin"' .
169
- ' data-nonce="'. wp_create_nonce( 'w3tc' ) . '"' .
170
- ' data-renew-key="' . esc_attr( $this->get_license_key() ) . '"' .
171
- ' data-src="licensing_expired" value="'.__( 'Renew Now', 'w3-total-cache' ) . '" />' );
 
 
 
 
 
 
 
172
  } elseif ( $this->_status_is( $status, 'invalid' ) ) {
173
  $message = __( 'The W3 Total Cache license key you entered is not valid.', 'w3-total-cache' ) .
174
- '<a href="' . ( is_network_admin() ? network_admin_url( 'admin.php?page=w3tc_general#licensing' ):
175
  admin_url( 'admin.php?page=w3tc_general#licensing' ) ) . '"> ' . __( 'Please enter it again.', 'w3-total-cache' ) . '</a>';
176
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi.activations_limit_not_reached' ) ) {
177
  $message = __( 'The W3 Total Cache license key is not active for this site.', 'w3-total-cache' );
178
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) ) {
179
- $message = __( 'The W3 Total Cache license key is not active for this site. ', 'w3-total-cache' ) .
180
  sprintf(
181
- __( 'You can switch your license to this website following <a class="w3tc_licensing_reset_rooturi" href="%s">this link</a>', 'w3-total-cache' ),
182
- Util_Ui::url( array( 'page' => 'w3tc_general', 'w3tc_licensing_reset_rooturi' => 'y' ) )
 
 
 
 
 
 
 
 
 
 
183
  );
184
  } elseif ( $this->_status_is( $status, 'inactive' ) ) {
185
  $message = __( 'The W3 Total Cache license key is not active.', 'w3-total-cache' );
@@ -189,50 +205,62 @@ class Licensing_Plugin_Admin {
189
  }
190
 
191
  if ( $message ) {
192
- if ( !Util_Admin::is_w3tc_admin_page() ) {
193
- echo '<script src="' . plugins_url( 'pub/js/lightbox.js', W3TC_FILE ) . '"></script>';
194
- echo '<link rel="stylesheet" id="w3tc-lightbox-css" href="' . plugins_url( 'pub/css/lightbox.css', W3TC_FILE ) . '" type="text/css" media="all" />';
195
  }
196
 
197
- Util_Ui::error_box( sprintf( "<p>$message. <a class='w3tc_licensing_check' href='%s'>" . __( 'check license status again' ) . '</a></p>',
198
- Util_Ui::url( array( 'page' => 'w3tc_general', 'w3tc_licensing_check_key' => 'y' ) ) )
 
 
 
 
 
 
 
 
 
 
 
 
199
  );
200
  }
201
 
202
-
203
  if ( $this->site_inactivated ) {
204
- Util_Ui::error_box( "<p>" . __( 'The W3 Total Cache license key is deactivated for this site.', 'w3-total-cache' ) ."</p>" );
205
  }
206
 
207
  if ( $this->site_activated ) {
208
- Util_Ui::error_box( "<p>" . __( 'The W3 Total Cache license key is activated for this site.', 'w3-total-cache' ) ."</p>" );
209
  }
210
  }
211
 
212
-
213
-
214
  function w3tc_notes( $notes ) {
215
- $terms = '';
216
  $state_master = Dispatcher::config_state_master();
217
 
218
  if ( defined( 'W3TC_PRO' ) ) {
219
  $terms = 'accept';
220
- } elseif ( !Util_Environment::is_w3tc_pro( $this->_config ) ) {
221
  $terms = $state_master->get_string( 'license.community_terms' );
222
 
223
- $buttons = sprintf( '<br /><br />%s&nbsp;%s',
224
- Util_Ui::button_link( __( 'Accept', 'w3-total-cache' ),
225
- Util_Ui::url( array(
226
- 'w3tc_licensing_terms_accept' => 'y' ) ) ),
227
- Util_Ui::button_link( __( 'Decline', 'w3-total-cache' ),
228
- Util_Ui::url( array(
229
- 'w3tc_licensing_terms_decline' => 'y' ) ) ) );
 
 
 
 
230
  } else {
231
  $state = Dispatcher::config_state();
232
  $terms = $state->get_string( 'license.terms' );
233
 
234
- $return_url = self_admin_url( Util_Ui::url( array(
235
- 'w3tc_licensing_terms_refresh' => 'y' ) ) );
236
 
237
  $buttons =
238
  sprintf( '<form method="post" action="%s">', W3TC_TERMS_ACCEPT_URL ) .
@@ -244,13 +272,20 @@ class Licensing_Plugin_Admin {
244
  '</form>';
245
  }
246
 
247
- if ( $terms != 'accept' && $terms != 'decline' && $terms != 'postpone' ) {
248
  if ( $state_master->get_integer( 'common.install' ) < 1542029724 ) {
249
  /* installed before 2018-11-12 */
250
- $notes['licensing_terms'] = sprintf(
251
- __( 'Our terms of use and privacy policies have been updated. Please <a href="%s" target="blank">review</a> and accept them.', 'w3-total-cache' ),
252
- W3TC_TERMS_URL ) .
253
- $buttons;
 
 
 
 
 
 
 
254
  } else {
255
  $notes['licensing_terms'] = sprintf(
256
  // translators: 1: HTML break tag, 2: Anchor/link open tag, 3: Anchor/link close tag.
@@ -269,8 +304,6 @@ class Licensing_Plugin_Admin {
269
  return $notes;
270
  }
271
 
272
-
273
-
274
  /**
275
  *
276
  *
@@ -283,24 +316,24 @@ class Licensing_Plugin_Admin {
283
  }
284
 
285
  $check_timeout = 3600 * 24 * 5;
286
- $status = '';
287
- $terms = '';
288
- $license_key = $this->get_license_key();
289
 
290
  $old_plugin_type = $this->_config->get_string( 'plugin.type' );
291
- $plugin_type = '';
292
 
293
- if ( !empty( $license_key ) || defined( 'W3TC_LICENSE_CHECK' ) ) {
294
  $license = Licensing_Core::check_license( $license_key, W3TC_VERSION );
295
 
296
  if ( $license ) {
297
  $status = $license->license_status;
298
- $terms = $license->license_terms;
299
  if ( $this->_status_is( $status, 'active' ) ) {
300
  $plugin_type = 'pro';
301
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) &&
302
  Util_Environment::is_w3tc_pro_dev() ) {
303
- $status = 'valid';
304
  $plugin_type = 'pro_dev';
305
  }
306
  }
@@ -310,7 +343,7 @@ class Licensing_Plugin_Admin {
310
  $status = 'no_key';
311
  }
312
 
313
- if ( $status == 'no_key' ) {
314
  } elseif ( $this->_status_is( $status, 'invalid' ) ) {
315
  } elseif ( $this->_status_is( $status, 'inactive' ) ) {
316
  } elseif ( $this->_status_is( $status, 'active' ) ) {
@@ -323,33 +356,31 @@ class Licensing_Plugin_Admin {
323
  $state->set( 'license.terms', $terms );
324
  $state->save();
325
 
326
- if ( $old_plugin_type != $plugin_type ) {
327
  try {
328
  $this->_config->set( 'plugin.type', $plugin_type );
329
  $this->_config->save();
330
  } catch ( \Exception $ex ) {
 
331
  }
332
  }
333
  return $status;
334
  }
335
 
336
-
337
-
338
  function get_license_key() {
339
  $license_key = $this->_config->get_string( 'plugin.license_key', '' );
340
- if ( $license_key == '' )
341
  $license_key = ini_get( 'w3tc.license_key' );
 
342
  return $license_key;
343
  }
344
 
345
-
346
-
347
  function action_verify_plugin_license_key() {
348
  $license = Util_Request::get_string( 'license_key', '' );
349
 
350
  if ( $license ) {
351
  $status = Licensing_Core::check_license( $license, W3TC_VERSION );
352
- echo $status->license_status;
353
  } else {
354
  echo 'invalid';
355
  }
3
 
4
  class Licensing_Plugin_Admin {
5
  private $site_inactivated = false;
6
+ private $site_activated = false;
7
  /**
8
  * Config
9
  */
19
  function run() {
20
  add_action( 'admin_init', array( $this, 'admin_init' ) );
21
  add_action( 'wp_ajax_w3tc_verify_plugin_license_key', array( $this, 'action_verify_plugin_license_key' ) );
22
+ add_action( 'w3tc_config_ui_save-w3tc_general', array( $this, 'possible_state_change' ), 2, 10 );
23
 
24
+ add_action( 'w3tc_message_action_licensing_upgrade', array( $this, 'w3tc_message_action_licensing_upgrade' ) );
 
25
 
26
  add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) );
27
  }
28
 
 
 
29
  public function w3tc_admin_bar_menu( $menu_items ) {
30
+ if ( ! Util_Environment::is_w3tc_pro( $this->_config ) ) {
31
  $menu_items['00020.licensing'] = array(
32
+ 'id' => 'w3tc_overlay_upgrade',
33
  'parent' => 'w3tc',
34
+ 'title' => wp_kses(
35
+ sprintf(
36
+ // translators: 1 opening HTML span tag, 2 closing HTML span tag.
37
+ __(
38
+ '%1$sUpgrade Performance%2$s',
39
+ 'w3-total-cache'
40
+ ),
41
+ '<span style="color: red; background: none;">',
42
+ '</span>'
43
+ ),
44
+ array(
45
+ 'span' => array(
46
+ 'style' => array(),
47
+ ),
48
+ )
49
+ ),
50
+ 'href' => wp_nonce_url(
51
+ network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=licensing_upgrade' ),
52
+ 'w3tc'
53
  ),
 
 
 
54
  );
55
  }
56
 
57
  if ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) {
58
  $menu_items['90040.licensing'] = array(
59
+ 'id' => 'w3tc_debug_overlay_upgrade',
60
  'parent' => 'w3tc_debug_overlays',
61
+ 'title' => esc_html__( 'Upgrade', 'w3-total-cache' ),
62
+ 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=licensing_upgrade' ), 'w3tc' )
 
 
63
  );
64
  }
65
 
71
  }
72
 
73
  public function admin_head_licensing_upgrade() {
74
+ ?>
75
  <script type="text/javascript">
76
+ jQuery(function() {
77
+ w3tc_lightbox_upgrade(w3tc_nonce, 'topbar_performance');
78
+ jQuery('#w3tc-license-instruction').show();
79
+ });
80
+ </script>
81
  <?php
82
  }
83
 
90
  function possible_state_change( $config, $old_config ) {
91
  $changed = false;
92
 
93
+ if ( $old_config->get_string( 'plugin.license_key' ) !== '' && $config->get_string( 'plugin.license_key' ) === '' ) {
94
  $result = Licensing_Core::deactivate_license( $old_config->get_string( 'plugin.license_key' ) );
95
  if ( $result ) {
96
  $this->site_inactivated = true;
97
  }
98
  $changed = true;
99
+ } elseif ( $old_config->get_string( 'plugin.license_key' ) === '' && $config->get_string( 'plugin.license_key' ) !== '' ) {
100
  $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION );
101
  if ( $result ) {
102
  $this->site_activated = true;
103
  $config->set( 'common.track_usage', true );
104
  }
105
  $changed = true;
106
+ } elseif ( $old_config->get_string( 'plugin.license_key' ) !== $config->get_string( 'plugin.license_key' ) ) {
107
  $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION );
108
  if ( $result ) {
109
  $this->site_activated = true;
124
  * Setup notices actions
125
  */
126
  function admin_init() {
127
+ $capability = apply_filters( 'w3tc_capability_admin_notices', 'manage_options' );
 
128
 
129
  $this->maybe_update_license_status();
130
 
133
  /**
134
  * Only admin can see W3TC notices and errors
135
  */
136
+ if ( ! Util_Environment::is_wpmu() ) {
137
+ add_action( 'admin_notices', array( $this, 'admin_notices' ), 1, 1 );
 
 
 
138
  }
139
+ add_action( 'network_admin_notices', array( $this, 'admin_notices' ), 1, 1 );
 
 
 
140
 
141
  if ( Util_Admin::is_w3tc_admin_page() ) {
142
  add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
146
  }
147
 
148
  private function _status_is( $s, $starts_with ) {
149
+ $s .= '.';
150
  $starts_with .= '.';
151
+ return substr( $s, 0, strlen( $starts_with ) ) === $starts_with;
152
  }
153
 
 
 
154
  /**
155
  * Run license status check and display messages
156
  */
157
  function admin_notices() {
158
  $message = '';
159
 
160
+ $state = Dispatcher::config_state();
161
  $status = $state->get_string( 'license.status' );
162
 
163
  if ( defined( 'W3TC_PRO' ) ) {
164
+ } elseif ( 'no_key' === $status ) {
165
  } elseif ( $this->_status_is( $status, 'inactive.expired' ) ) {
166
+ $message = wp_kses(
167
+ sprintf(
168
+ // translators: 1 HTML input button for renewing licence.
169
+ __(
170
+ 'It looks like your W3 Total Cache Pro License has expired. %1$s to continue using the Pro Features',
171
+ 'w3-total-cache'
172
+ ),
173
+ '<input type="button" class="button-primary button-buy-plugin" data-nonce="' .
174
+ esc_url( wp_create_nonce( 'w3tc' ) ) . '" data-renew-key="' . esc_attr( $this->get_license_key() ) .
175
+ '" data-src="licensing_expired" value="' . __( 'Renew Now', 'w3-total-cache' ) . '" />'
176
+ )
177
+ );
178
  } elseif ( $this->_status_is( $status, 'invalid' ) ) {
179
  $message = __( 'The W3 Total Cache license key you entered is not valid.', 'w3-total-cache' ) .
180
+ '<a href="' . ( is_network_admin() ? network_admin_url( 'admin.php?page=w3tc_general#licensing' ) :
181
  admin_url( 'admin.php?page=w3tc_general#licensing' ) ) . '"> ' . __( 'Please enter it again.', 'w3-total-cache' ) . '</a>';
182
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi.activations_limit_not_reached' ) ) {
183
  $message = __( 'The W3 Total Cache license key is not active for this site.', 'w3-total-cache' );
184
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) ) {
185
+ $message = wp_kses(
186
  sprintf(
187
+ // translators: HTML a tag to W3TC Licence Reset.
188
+ __(
189
+ 'The W3 Total Cache license key is not active for this site. You can switch your license to this website following %1$sthis link%2$s',
190
+ 'w3-total-cache'
191
+ ),
192
+ '<a class="w3tc_licensing_reset_rooturi" href="' . Util_Ui::url(
193
+ array(
194
+ 'page' => 'w3tc_general',
195
+ 'w3tc_licensing_reset_rooturi' => 'y',
196
+ )
197
+ ) . '"></a>'
198
+ )
199
  );
200
  } elseif ( $this->_status_is( $status, 'inactive' ) ) {
201
  $message = __( 'The W3 Total Cache license key is not active.', 'w3-total-cache' );
205
  }
206
 
207
  if ( $message ) {
208
+ if ( ! Util_Admin::is_w3tc_admin_page() ) {
209
+ echo '<script src="' . esc_url( plugins_url( 'pub/js/lightbox.js', W3TC_FILE ) ) . '"></script>';
210
+ echo '<link rel="stylesheet" id="w3tc-lightbox-css" href="' . esc_url( plugins_url( 'pub/css/lightbox.css', W3TC_FILE ) ) . '" type="text/css" media="all" />';
211
  }
212
 
213
+ Util_Ui::error_box(
214
+ sprintf(
215
+ '%1$s%2$s. %3$scheck license status again</a></p>',
216
+ '<p>',
217
+ $message,
218
+ '<a class="w3tc_licensing_check" href="' . Util_Ui::url(
219
+ array(
220
+ 'page' => 'w3tc_general',
221
+ 'w3tc_licensing_check_key' => 'y',
222
+ )
223
+ ) . '">',
224
+ '</a>',
225
+ '</p>'
226
+ )
227
  );
228
  }
229
 
 
230
  if ( $this->site_inactivated ) {
231
+ Util_Ui::error_box( '<p>' . __( 'The W3 Total Cache license key is deactivated for this site.', 'w3-total-cache' ) . '</p>' );
232
  }
233
 
234
  if ( $this->site_activated ) {
235
+ Util_Ui::error_box( '<p>' . __( 'The W3 Total Cache license key is activated for this site.', 'w3-total-cache' ) . '</p>' );
236
  }
237
  }
238
 
 
 
239
  function w3tc_notes( $notes ) {
240
+ $terms = '';
241
  $state_master = Dispatcher::config_state_master();
242
 
243
  if ( defined( 'W3TC_PRO' ) ) {
244
  $terms = 'accept';
245
+ } elseif ( ! Util_Environment::is_w3tc_pro( $this->_config ) ) {
246
  $terms = $state_master->get_string( 'license.community_terms' );
247
 
248
+ $buttons = sprintf(
249
+ '<br /><br />%s&nbsp;%s',
250
+ Util_Ui::button_link(
251
+ __( 'Accept', 'w3-total-cache' ),
252
+ Util_Ui::url( array( 'w3tc_licensing_terms_accept' => 'y' ) )
253
+ ),
254
+ Util_Ui::button_link(
255
+ __( 'Decline', 'w3-total-cache' ),
256
+ Util_Ui::url( array( 'w3tc_licensing_terms_decline' => 'y' ) )
257
+ )
258
+ );
259
  } else {
260
  $state = Dispatcher::config_state();
261
  $terms = $state->get_string( 'license.terms' );
262
 
263
+ $return_url = self_admin_url( Util_Ui::url( array( 'w3tc_licensing_terms_refresh' => 'y' ) ) );
 
264
 
265
  $buttons =
266
  sprintf( '<form method="post" action="%s">', W3TC_TERMS_ACCEPT_URL ) .
272
  '</form>';
273
  }
274
 
275
+ if ( 'accept' !== $terms && 'decline' !== $terms && 'postpone' !== $terms ) {
276
  if ( $state_master->get_integer( 'common.install' ) < 1542029724 ) {
277
  /* installed before 2018-11-12 */
278
+ $notes['licensing_terms'] = wp_kses(
279
+ sprintf(
280
+ // translators: 1 opening HTML a tag to W3TC Terms page, 2 closing HTML a tag.
281
+ __(
282
+ 'Our terms of use and privacy policies have been updated. Please %1$sreview%2$s and accept them.',
283
+ 'w3-total-cache'
284
+ ),
285
+ '<a href="' . esc_url( W3TC_TERMS_URL ) . '" target="blank">',
286
+ '</a>'
287
+ ) . $buttons
288
+ );
289
  } else {
290
  $notes['licensing_terms'] = sprintf(
291
  // translators: 1: HTML break tag, 2: Anchor/link open tag, 3: Anchor/link close tag.
304
  return $notes;
305
  }
306
 
 
 
307
  /**
308
  *
309
  *
316
  }
317
 
318
  $check_timeout = 3600 * 24 * 5;
319
+ $status = '';
320
+ $terms = '';
321
+ $license_key = $this->get_license_key();
322
 
323
  $old_plugin_type = $this->_config->get_string( 'plugin.type' );
324
+ $plugin_type = '';
325
 
326
+ if ( ! empty( $license_key ) || defined( 'W3TC_LICENSE_CHECK' ) ) {
327
  $license = Licensing_Core::check_license( $license_key, W3TC_VERSION );
328
 
329
  if ( $license ) {
330
  $status = $license->license_status;
331
+ $terms = $license->license_terms;
332
  if ( $this->_status_is( $status, 'active' ) ) {
333
  $plugin_type = 'pro';
334
  } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) &&
335
  Util_Environment::is_w3tc_pro_dev() ) {
336
+ $status = 'valid';
337
  $plugin_type = 'pro_dev';
338
  }
339
  }
343
  $status = 'no_key';
344
  }
345
 
346
+ if ( 'no_key' === $status ) {
347
  } elseif ( $this->_status_is( $status, 'invalid' ) ) {
348
  } elseif ( $this->_status_is( $status, 'inactive' ) ) {
349
  } elseif ( $this->_status_is( $status, 'active' ) ) {
356
  $state->set( 'license.terms', $terms );
357
  $state->save();
358
 
359
+ if ( $old_plugin_type !== $plugin_type ) {
360
  try {
361
  $this->_config->set( 'plugin.type', $plugin_type );
362
  $this->_config->save();
363
  } catch ( \Exception $ex ) {
364
+ // missing exception handle?
365
  }
366
  }
367
  return $status;
368
  }
369
 
 
 
370
  function get_license_key() {
371
  $license_key = $this->_config->get_string( 'plugin.license_key', '' );
372
+ if ( '' === $license_key ) {
373
  $license_key = ini_get( 'w3tc.license_key' );
374
+ }
375
  return $license_key;
376
  }
377
 
 
 
378
  function action_verify_plugin_license_key() {
379
  $license = Util_Request::get_string( 'license_key', '' );
380
 
381
  if ( $license ) {
382
  $status = Licensing_Core::check_license( $license, W3TC_VERSION );
383
+ echo esc_html( $status->license_status );
384
  } else {
385
  echo 'invalid';
386
  }
Minify_Core.php CHANGED
@@ -134,7 +134,7 @@ class Minify_Core {
134
 
135
  if ( $debug ) {
136
  Minify_Core::log( $error );
137
- echo "\r\n/* " . htmlspecialchars( $error ) . " */\r\n";
138
  }
139
  }
140
 
@@ -147,7 +147,14 @@ class Minify_Core {
147
  * @return bool
148
  */
149
  static public function log( $msg ) {
150
- $data = sprintf( "[%s] [%s] [%s] %s\n", date( 'r' ), $_SERVER['REQUEST_URI'], ( !empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '-' ), $msg );
 
 
 
 
 
 
 
151
  $data = strtr( $data, '<>', '..' );
152
 
153
  $filename = Util_Debug::log_filename( 'minify' );
@@ -175,7 +182,11 @@ class Minify_Core {
175
  case 'redis':
176
  $engineConfig = array(
177
  'servers' => $c->get_array( 'minify.redis.servers' ),
 
178
  'persistent' => $c->get_boolean( 'minify.redis.persistent' ),
 
 
 
179
  'dbid' => $c->get_integer( 'minify.redis.dbid' ),
180
  'password' => $c->get_string( 'minify.redis.password' )
181
  );
134
 
135
  if ( $debug ) {
136
  Minify_Core::log( $error );
137
+ echo "\r\n/* " . esc_html( $error ) . " */\r\n";
138
  }
139
  }
140
 
147
  * @return bool
148
  */
149
  static public function log( $msg ) {
150
+ $data = sprintf(
151
+ "[%s] [%s] [%s] %s\n",
152
+ date( 'r' ),
153
+ isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '',
154
+ ! empty( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '-',
155
+ $msg
156
+ );
157
+
158
  $data = strtr( $data, '<>', '..' );
159
 
160
  $filename = Util_Debug::log_filename( 'minify' );
182
  case 'redis':
183
  $engineConfig = array(
184
  'servers' => $c->get_array( 'minify.redis.servers' ),
185
+ 'verify_tls_certificates' => $c->get_boolean( 'minify.redis.verify_tls_certificates' ),
186
  'persistent' => $c->get_boolean( 'minify.redis.persistent' ),
187
+ 'timeout' => $c->get_integer( 'minify.redis.timeout' ),
188
+ 'retry_interval' => $c->get_integer( 'minify.redis.retry_interval' ),
189
+ 'read_timeout' => $c->get_integer( 'minify.redis.read_timeout' ),
190
  'dbid' => $c->get_integer( 'minify.redis.dbid' ),
191
  'password' => $c->get_string( 'minify.redis.password' )
192
  );
Minify_Environment.php CHANGED
@@ -146,7 +146,7 @@ class Minify_Environment {
146
 
147
  try{
148
  if ( file_exists( $dir ) && !is_writeable( $dir ) )
149
- Util_WpFile::delete_folder( $dir, '', $_SERVER['REQUEST_URI'] );
150
  } catch ( Util_WpFile_FilesystemRmdirException $ex ) {
151
  $exs->push( $ex );
152
  }
146
 
147
  try{
148
  if ( file_exists( $dir ) && !is_writeable( $dir ) )
149
+ Util_WpFile::delete_folder( $dir, '', isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' );
150
  } catch ( Util_WpFile_FilesystemRmdirException $ex ) {
151
  $exs->push( $ex );
152
  }
Minify_HelpPopup_View.php CHANGED
@@ -1,71 +1,150 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <div class="w3tc-overlay-logo"></div>
9
  <header>
10
  </header>
11
  <div class="w3tchelp_content">
12
- <h3>Hang on!</h3>
13
  <p>
14
- In the best case, the usage of minify optimization is a trial and
15
- error process, it's <em>not</em> an "instant on" or "set it and forget it"
16
- optimization technique.
17
  </p>
18
  <p>
19
- There are lots of reasons why minify cannot work for all sites under
20
- all circumstances and they have nothing to do with W3 Total Cache:
21
- Your site's content, your server(s), your plugins and your theme
22
- are all unique, that means that minify cannot automatically work for everyone.
 
 
 
 
23
  </p>
24
 
25
- <h3>What is minification exactly?</h3>
26
  <ul class="w3tchelp_content_list">
27
  <li>
28
- Minification is a process of reducing the file size to improve user experience
29
- and it requires testing in order to get it right &mdash; as such it doesn't work for everyone.
 
 
 
 
 
30
  </li>
31
  <li>
32
- The interactions and dependencies of <acronym title="Cascading Style Sheet">CSS</acronym> or <acronym>JS</acronym> on each
33
- other can be complex. Themes and plugins are typically created by various developers
34
- and can be combined in millions of combinations. As a result, W3 Total Cache cannot
35
- take all of those nuances into account, it just does the operation and
36
- let's you tune to what degree it does it, it doesn't "validate" the result
37
- or know if it's good or bad; a human must do that.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  </li>
39
  </ul>
40
 
41
- <h3>Still want to get started? Now for the Pro' tips:</h3>
42
  <ol class="w3tchelp_content_list">
43
  <li>
44
- Start with minify for your <acronym title="Cascading Style Sheet">CSS</acronym> using auto mode first.
45
- If you have any issues at that step, contact your developer(s) and report a bug. They should be able to
46
- point you in the right direction or correct the issue in a future update.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </li>
48
  <li>
49
- Once <acronym title="Cascading Style Sheet">CSS</acronym> is optimized, try <acronym>JS</acronym> minification. If auto
50
- mode doesn't work for you, be sure to check the web browsers
51
- error console to quickly confirm that the optimization isn't
52
- working. If the JavaScript is working, you can either make
53
- additional optimizations for user experience like experimenting
54
- with embed locations etc or further reducing file
55
- size etc. However, if you're having errors try
56
- the "combine only" option and if that still generates errors,
57
- there are bugs in the code of your theme or plugins or both that
58
- prevent minification of <acronym>JS</acronym> from working automatically.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  </li>
60
  </ol>
61
 
62
- <div>
63
- <input type="submit" class="btn w3tc-size image btn-primary outset save palette-turquoise "
64
- value="I Understand the Risks">
65
- <?php
66
- echo Util_Ui::button_link( 'Do It For Me',
67
- 'admin.php?page=w3tc_support', false,
68
- 'btn w3tc-size image btn-primary outset save palette-turquoise w3tc-button-ignore-change' );
69
- ?>
70
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <div class="w3tc-overlay-logo"></div>
9
  <header>
10
  </header>
11
  <div class="w3tchelp_content">
12
+ <h3><?php esc_html_e( 'Hang on!', 'w3-total-cache' ); ?></h3>
13
  <p>
14
+ <?php esc_html_e( 'In the best case, the usage of minify optimization is a trial and error process, it\'s', 'w3-total-cache' ); ?>
15
+ <em><?php esc_html_e( ' not ', 'w3-total-cache' ); ?></em>
16
+ <?php esc_html_e( 'an "instant on" or "set it and forget it" optimization technique.', 'w3-total-cache' ); ?>
17
  </p>
18
  <p>
19
+ <?php
20
+ esc_html_e(
21
+ 'There are lots of reasons why minify cannot work for all sites under all circumstances and they
22
+ have nothing to do with W3 Total Cache: Your site\'s content, your server(s), your plugins and
23
+ your theme are all unique, that means that minify cannot automatically work for everyone.',
24
+ 'w3-total-cache'
25
+ );
26
+ ?>
27
  </p>
28
 
29
+ <h3><?php esc_html_e( 'What is minification exactly?', 'w3-total-cache' ); ?></h3>
30
  <ul class="w3tchelp_content_list">
31
  <li>
32
+ <?php
33
+ esc_html_e(
34
+ 'Minification is a process of reducing the file size to improve user experience and it requires
35
+ testing in order to get it right &mdash; as such it doesn\'t work for everyone.',
36
+ 'w3-total-cache'
37
+ );
38
+ ?>
39
  </li>
40
  <li>
41
+ <?php
42
+ echo wp_kses(
43
+ sprintf(
44
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
45
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag.
46
+ __(
47
+ 'The interactions and dependencies of %1$sCSS%2$s or %3$sJS%4$s on each other can be complex.
48
+ Themes and plugins are typically created by various developers and can be combined in
49
+ millions of combinations. As a result, W3 Total Cache cannot take all of those nuances into
50
+ account, it just does the operation and let\'s you tune to what degree it does it, it
51
+ doesn\'t "validate" the result or know if it\'s good or bad; a human must do that.',
52
+ 'w3-total-cache'
53
+ ),
54
+ '<acronym title="' . esc_html__( 'Cascading Style Sheet', 'w3-total-cache' ) . '">',
55
+ '</acronym>',
56
+ '<acronym title="' . esc_html__( 'JavaScript', 'w3-total-cache' ) . '">',
57
+ '</acronym>'
58
+ ),
59
+ array(
60
+ 'acronym' => array(
61
+ 'title' => array(),
62
+ ),
63
+ )
64
+ );
65
+ ?>
66
  </li>
67
  </ul>
68
 
69
+ <h3><?php esc_html_e( 'Still want to get started? Now for the Pro\' tips:', 'w3-total-cache' ); ?></h3>
70
  <ol class="w3tchelp_content_list">
71
  <li>
72
+ <?php
73
+ echo wp_kses(
74
+ sprintf(
75
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
76
+ __(
77
+ 'Start with minify for your %1$sCSS%2$s using auto mode first. If you have any issues at that step,
78
+ contact your developer(s) and report a bug. They should be able to point you in the right
79
+ direction or correct the issue in a future update.',
80
+ 'w3-total-cache'
81
+ ),
82
+ '<acronym title="' . esc_html__( 'Cascading Style Sheet', 'w3-total-cache' ) . '">',
83
+ '</acronym>'
84
+ ),
85
+ array(
86
+ 'acronym' => array(
87
+ 'title' => array(),
88
+ ),
89
+ )
90
+ );
91
+ ?>
92
  </li>
93
  <li>
94
+ <?php
95
+ echo wp_kses(
96
+ sprintf(
97
+ // translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
98
+ // translators: 3 opening HTML acronym tag, 4 closing HTML acronym tag,
99
+ // translators: 5 opening HTML acronym tag, 6 closing HTML acronym tag.
100
+ __(
101
+ 'Once %1$sCSS%2$s is optimized, try %3$sJS%4$s minification. If auto mode doesn\'t work for
102
+ you, be sure to check the web browsers error console to quickly confirm that the optimization
103
+ isn\'t working. If the JavaScript is working, you can either make additional optimizations for
104
+ user experience like experimenting with embed locations etc or further reducing file size etc.
105
+ However, if you\'re having errors try the "combine only" option and if that still generates
106
+ errors, there are bugs in the code of your theme or plugins or both that prevent minification
107
+ of %5$sJS%6$s from working automatically.',
108
+ 'w3-total-cache'
109
+ ),
110
+ '<acronym title="' . esc_html__( 'Cascading Style Sheet', 'w3-total-cache' ) . '">',
111
+ '</acronym>',
112
+ '<acronym title="' . esc_html__( 'JavaScript', 'w3-total-cache' ) . '">',
113
+ '</acronym>',
114
+ '<acronym title="' . esc_html__( 'JavaScript', 'w3-total-cache' ) . '">',
115
+ '</acronym>'
116
+ ),
117
+ array(
118
+ 'acronym' => array(
119
+ 'title' => array(),
120
+ ),
121
+ )
122
+ );
123
+ ?>
124
  </li>
125
  </ol>
126
 
127
+ <div>
128
+ <input type="submit" class="btn w3tc-size image btn-primary outset save palette-turquoise "
129
+ value="<?php esc_attr_e( 'I Understand the Risks', 'w3-total-cache' ); ?>">
130
+ <?php
131
+ echo wp_kses(
132
+ Util_Ui::button_link(
133
+ 'Do It For Me',
134
+ 'admin.php?page=w3tc_support',
135
+ false,
136
+ 'btn w3tc-size image btn-primary outset save palette-turquoise w3tc-button-ignore-change'
137
+ ),
138
+ array(
139
+ 'input' => array(
140
+ 'type' => array(),
141
+ 'name' => array(),
142
+ 'class' => array(),
143
+ 'value' => array(),
144
+ 'onclick' => array(),
145
+ ),
146
+ )
147
+ );
148
+ ?>
149
+ </div>
150
  </div>
Minify_MinifiedFileRequestHandler.php CHANGED
@@ -222,7 +222,7 @@ class Minify_MinifiedFileRequestHandler {
222
  @header( 'X-Powered-By: ' . Util_Environment::w3tc_header() );
223
  }
224
 
225
- if ( empty( $_GET['f_array'] ) && empty( $_GET['g'] ) ) {
226
  return $this->finish_with_error( 'Nothing to minify', $quiet, false );
227
  }
228
 
@@ -579,7 +579,7 @@ class Minify_MinifiedFileRequestHandler {
579
 
580
  if ( defined( 'W3TC_IN_MINIFY' ) ) {
581
  status_header( 400 );
582
- echo $message;
583
  die();
584
  }
585
  }
@@ -671,7 +671,11 @@ class Minify_MinifiedFileRequestHandler {
671
  'host' => Util_Environment::host(),
672
  'module' => 'minify',
673
  'servers' => $this->_config->get_array( 'minify.redis.servers' ),
 
674
  'persistent' => $this->_config->get_boolean( 'minify.redis.persistent' ),
 
 
 
675
  'dbid' => $this->_config->get_integer( 'minify.redis.dbid' ),
676
  'password' => $this->_config->get_string( 'minify.redis.password' )
677
  );
222
  @header( 'X-Powered-By: ' . Util_Environment::w3tc_header() );
223
  }
224
 
225
+ if ( empty( Util_Request::get( 'f_array' ) ) && empty( Util_Request::get_string( 'g' ) ) ) {
226
  return $this->finish_with_error( 'Nothing to minify', $quiet, false );
227
  }
228
 
579
 
580
  if ( defined( 'W3TC_IN_MINIFY' ) ) {
581
  status_header( 400 );
582
+ echo esc_html( $message );
583
  die();
584
  }
585
  }
671
  'host' => Util_Environment::host(),
672
  'module' => 'minify',
673
  'servers' => $this->_config->get_array( 'minify.redis.servers' ),
674
+ 'verify_tls_certificates' => $this->_config->get_boolean( 'minify.redis.verify_tls_certificates' ),
675
  'persistent' => $this->_config->get_boolean( 'minify.redis.persistent' ),
676
+ 'timeout' => $this->_config->get_integer( 'minify.redis.timeout' ),
677
+ 'retry_interval' => $this->_config->get_integer( 'minify.redis.retry_interval' ),
678
+ 'read_timeout' => $this->_config->get_integer( 'minify.redis.read_timeout' ),
679
  'dbid' => $this->_config->get_integer( 'minify.redis.dbid' ),
680
  'password' => $this->_config->get_string( 'minify.redis.password' )
681
  );
Minify_Plugin.php CHANGED
@@ -90,17 +90,17 @@ class Minify_Plugin {
90
  $parsed = parse_url( $url );
91
  $prefix = '/' . trim( $parsed['path'], '/' ) . '/';
92
 
93
- if ( substr( $_SERVER['REQUEST_URI'], 0, strlen( $prefix ) ) == $prefix ) {
 
94
  $w3_minify = Dispatcher::component( 'Minify_MinifiedFileRequestHandler' );
95
- $filename = Util_Environment::remove_query_all(
96
- substr( $_SERVER['REQUEST_URI'], strlen( $prefix ) ) );
97
  $w3_minify->process( $filename );
98
  exit();
99
  }
100
 
101
- if ( !empty( $_REQUEST['w3tc_minify'] ) ) {
102
  $w3_minify = Dispatcher::component( 'Minify_MinifiedFileRequestHandler' );
103
- $w3_minify->process( $_REQUEST['w3tc_minify'] );
104
  exit();
105
  }
106
  }
@@ -927,7 +927,7 @@ class Minify_Plugin {
927
 
928
  foreach ( $uas as $ua ) {
929
  if ( !empty( $ua ) ) {
930
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && stristr( $_SERVER['HTTP_USER_AGENT'], $ua ) !== false ) {
931
  return false;
932
  }
933
  }
@@ -962,7 +962,7 @@ class Minify_Plugin {
962
  );
963
 
964
  foreach ( $auto_reject_uri as $uri ) {
965
- if ( strstr( $_SERVER['REQUEST_URI'], $uri ) !== false ) {
966
  return false;
967
  }
968
  }
@@ -974,12 +974,11 @@ class Minify_Plugin {
974
  $expr = trim( $expr );
975
  $expr = str_replace( '~', '\~', $expr );
976
 
977
- if ( $expr != '' && preg_match( '~' . $expr . '~i', $_SERVER['REQUEST_URI'] ) ) {
978
  return false;
979
  }
980
  }
981
 
982
-
983
  if ( Util_Request::get_string( 'wp_customize' ) )
984
  return false;
985
 
90
  $parsed = parse_url( $url );
91
  $prefix = '/' . trim( $parsed['path'], '/' ) . '/';
92
 
93
+ $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
94
+ if ( substr( $request_uri, 0, strlen( $prefix ) ) == $prefix ) {
95
  $w3_minify = Dispatcher::component( 'Minify_MinifiedFileRequestHandler' );
96
+ $filename = Util_Environment::remove_query_all( substr( $request_uri, strlen( $prefix ) ) );
 
97
  $w3_minify->process( $filename );
98
  exit();
99
  }
100
 
101
+ if ( !empty( Util_Request::get_string( 'w3tc_minify' ) ) ) {
102
  $w3_minify = Dispatcher::component( 'Minify_MinifiedFileRequestHandler' );
103
+ $w3_minify->process( Util_Request::get_string( 'w3tc_minify' ) );
104
  exit();
105
  }
106
  }
927
 
928
  foreach ( $uas as $ua ) {
929
  if ( !empty( $ua ) ) {
930
+ if ( stristr( isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '', $ua ) !== false ) {
931
  return false;
932
  }
933
  }
962
  );
963
 
964
  foreach ( $auto_reject_uri as $uri ) {
965
+ if ( strstr( isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '', $uri ) !== false ) {
966
  return false;
967
  }
968
  }
974
  $expr = trim( $expr );
975
  $expr = str_replace( '~', '\~', $expr );
976
 
977
+ if ( '' !== $expr && preg_match( '~' . $expr . '~i', isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' ) ) {
978
  return false;
979
  }
980
  }
981
 
 
982
  if ( Util_Request::get_string( 'wp_customize' ) )
983
  return false;
984
 
Mobile_Referrer.php CHANGED
@@ -7,34 +7,33 @@ namespace W3TC;
7
  define( 'W3TC_REFERRER_COOKIE_NAME', 'w3tc_referrer' );
8
 
9
  /**
10
- * class Referrer
11
  */
12
  class Mobile_Referrer extends Mobile_Base {
13
  /**
14
  * PHP5-style constructor
15
  */
16
- function __construct() {
17
  parent::__construct( 'referrer.rgroups', 'referrers' );
18
  }
19
 
20
  /**
21
- * Returns HTTP referrer value
22
  *
23
  * @return string
24
  */
25
- function get_http_referrer() {
26
  $http_referrer = '';
27
 
28
  if ( $this->has_enabled_groups() ) {
29
- if ( isset( $_COOKIE[W3TC_REFERRER_COOKIE_NAME] ) ) {
30
- $http_referrer = $_COOKIE[W3TC_REFERRER_COOKIE_NAME];
31
  } elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
32
- $http_referrer = $_SERVER['HTTP_REFERER'];
33
 
34
- setcookie( W3TC_REFERRER_COOKIE_NAME, $http_referrer, 0,
35
- '/' /* not defined yet Util_Environment::network_home_url_uri()*/ );
36
  }
37
- } elseif ( isset( $_COOKIE[W3TC_REFERRER_COOKIE_NAME] ) ) {
38
  setcookie( W3TC_REFERRER_COOKIE_NAME, '', 1 );
39
  }
40
 
7
  define( 'W3TC_REFERRER_COOKIE_NAME', 'w3tc_referrer' );
8
 
9
  /**
10
+ * Class: Mobile_Referrer
11
  */
12
  class Mobile_Referrer extends Mobile_Base {
13
  /**
14
  * PHP5-style constructor
15
  */
16
+ public function __construct() {
17
  parent::__construct( 'referrer.rgroups', 'referrers' );
18
  }
19
 
20
  /**
21
+ * Returns HTTP referrer value.
22
  *
23
  * @return string
24
  */
25
+ public function get_http_referrer() {
26
  $http_referrer = '';
27
 
28
  if ( $this->has_enabled_groups() ) {
29
+ if ( isset( $_COOKIE[ W3TC_REFERRER_COOKIE_NAME ] ) ) {
30
+ $http_referrer = htmlspecialchars( $_COOKIE[ W3TC_REFERRER_COOKIE_NAME ] ); // phpcs:ignore
31
  } elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
32
+ $http_referrer = filter_var( $_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL ); // phpcs:ignore
33
 
34
+ setcookie( W3TC_REFERRER_COOKIE_NAME, $http_referrer, 0, '/' /* not defined yet Util_Environment::network_home_url_uri()*/ );
 
35
  }
36
+ } elseif ( isset( $_COOKIE[ W3TC_REFERRER_COOKIE_NAME ] ) ) {
37
  setcookie( W3TC_REFERRER_COOKIE_NAME, '', 1 );
38
  }
39
 
Mobile_UserAgent.php CHANGED
@@ -1,22 +1,37 @@
1
  <?php
2
- namespace W3TC;
3
-
4
  /**
5
- * W3TC Mobile detection
 
 
 
 
 
6
  */
7
 
 
 
8
  /**
9
- * class Mobile
10
  */
11
  class Mobile_UserAgent extends Mobile_Base {
12
  /**
13
  * PHP5-style constructor
14
  */
15
- function __construct() {
16
  parent::__construct( 'mobile.rgroups', 'agents' );
17
  }
18
 
19
- function group_verifier( $group_compare_value ) {
20
- return isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '~' . $group_compare_value . '~i', $_SERVER['HTTP_USER_AGENT'] );
 
 
 
 
 
 
 
 
 
 
21
  }
22
  }
1
  <?php
 
 
2
  /**
3
+ * File: Mobile_UserAgent.php
4
+ *
5
+ * W3TC Mobile detection.
6
+ *
7
+ * @package W3TC
8
+ * @subpackage QA
9
  */
10
 
11
+ namespace W3TC;
12
+
13
  /**
14
+ * Class Mobile_UserAgent
15
  */
16
  class Mobile_UserAgent extends Mobile_Base {
17
  /**
18
  * PHP5-style constructor
19
  */
20
+ public function __construct() {
21
  parent::__construct( 'mobile.rgroups', 'agents' );
22
  }
23
 
24
+ /**
25
+ * Group verifier.
26
+ *
27
+ * @param string $group_compare_value Group comparison value.
28
+ * @return int|false
29
+ */
30
+ public function group_verifier( $group_compare_value ) {
31
+ return preg_match(
32
+ '~' . $group_compare_value . '~i',
33
+ isset( $_SERVER['HTTP_USER_AGENT'] ) ?
34
+ htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) : '' // phpcs:ignore
35
+ );
36
  }
37
  }
ObjectCache_Environment.php CHANGED
@@ -105,26 +105,44 @@ class ObjectCache_Environment {
105
  if ( $this->objectcache_installed() ) {
106
  if ( $this->is_objectcache_add_in() ) {
107
  $script_data = @file_get_contents( $dst );
108
- if ( $script_data == @file_get_contents( $src ) )
109
  return;
110
- } else if ( get_transient( 'w3tc_remove_add_in_objectcache' ) == 'yes' ) {
111
- // user already manually asked to remove another plugin's add in,
112
- // we should try to apply ours
113
- // (in case of missing permissions deletion could fail)
114
- } else if ( !$this->is_objectcache_old_add_in() ) {
115
- if ( isset( $_GET['page'] ) )
116
- $url = 'admin.php?page=' . $_GET['page'] . '&amp;';
117
- else
118
- $url = basename( Util_Environment::remove_query_all(
119
- $_SERVER['REQUEST_URI'] ) ) . '?page=w3tc_dashboard&amp;';
120
- $remove_url = Util_Ui::admin_url( $url .
121
- 'w3tc_default_remove_add_in=objectcache' );
122
-
123
- throw new Util_WpFile_FilesystemOperationException(
124
- sprintf( __( 'The Object Cache add-in file object-cache.php is not a W3 Total Cache drop-in.
125
- Remove it or disable Object Caching. %s', 'w3-total-cache' ),
126
- Util_Ui::button_link( __( 'Yes, remove it for me', 'w3-total-cache' ), wp_nonce_url( $remove_url, 'w3tc' ) ) ) );
127
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
 
130
  Util_WpFile::copy_file( $src, $dst );
105
  if ( $this->objectcache_installed() ) {
106
  if ( $this->is_objectcache_add_in() ) {
107
  $script_data = @file_get_contents( $dst );
108
+ if ( $script_data == @file_get_contents( $src ) ) {
109
  return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
+ } elseif ( 'yes' === get_transient( 'w3tc_remove_add_in_objectcache' ) ) {
112
+ // user already manually asked to remove another plugin's add in,
113
+ // we should try to apply ours
114
+ // (in case of missing permissions deletion could fail).
115
+ } elseif ( ! $this->is_objectcache_old_add_in() ) {
116
+ $page_val = Util_Request::get_string( 'page' );
117
+ if ( ! empty( $page_val ) ) {
118
+ $url = 'admin.php?page=' . $page_val . '&amp;';
119
+ } else {
120
+ $url = basename(
121
+ Util_Environment::remove_query_all(
122
+ isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''
123
+ )
124
+ ) . '?page=w3tc_dashboard&amp;';
125
+ }
126
+
127
+ $remove_url = Util_Ui::admin_url( $url . 'w3tc_default_remove_add_in=objectcache' );
128
+
129
+ throw new Util_WpFile_FilesystemOperationException(
130
+ sprintf(
131
+ // translators: 1 HTML button link to remove object-cache.php file.
132
+ __(
133
+ 'The Object Cache add-in file object-cache.php is not a W3 Total Cache drop-in. Remove it or disable Object Caching. %1$s',
134
+ 'w3-total-cache'
135
+ ),
136
+ Util_Ui::button_link(
137
+ __(
138
+ 'Yes, remove it for me',
139
+ 'w3-total-cache'
140
+ ),
141
+ wp_nonce_url( $remove_url, 'w3tc' )
142
+ )
143
+ )
144
+ );
145
+ }
146
  }
147
 
148
  Util_WpFile::copy_file( $src, $dst );
ObjectCache_Page_View_PurgeLog.php CHANGED
@@ -1,27 +1,28 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <style>
10
- <?php require_once(__DIR__ . '/shared/purge_log.css') ?>
11
  </style>
12
  <div class="metabox-holder">
13
- <?php Util_Ui::postbox_header( __( 'Object Cache Purges Log', 'w3-total-cache' ) ); ?>
14
 
15
- <h1>Purges Log</h1>
16
 
17
  <div class="w3tc_purge_log_table">
18
  <?php foreach ( $lines as $line ): ?>
19
- <div class="w3tc_purge_log_date"><?php echo esc_html( $line['date'] ) ?></div>
20
- <div class="w3tc_purge_log_message"><td><?php echo esc_html( $line['message'] ) ?></div>
21
  <div class="w3tc_purge_log_backtrace">
22
- <?php foreach ( $line['backtrace'] as $backtrace_line ): ?>
23
  <div class="w3tc_purge_log_traceline">
24
- <?php echo esc_html( $backtrace_line ) ?>
25
  </div>
26
  <?php endforeach ?>
27
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <style>
11
+ <?php require_once __DIR__ . '/shared/purge_log.css'; ?>
12
  </style>
13
  <div class="metabox-holder">
14
+ <?php Util_Ui::postbox_header( esc_html__( 'Object Cache Purges Log', 'w3-total-cache' ) ); ?>
15
 
16
+ <h1><?php esc_html_e( 'Purges Log', 'w3-total-cache' ); ?></h1>
17
 
18
  <div class="w3tc_purge_log_table">
19
  <?php foreach ( $lines as $line ): ?>
20
+ <div class="w3tc_purge_log_date"><?php echo esc_html( $line['date'] ); ?></div>
21
+ <div class="w3tc_purge_log_message"><td><?php echo esc_html( $line['message'] ); ?></div>
22
  <div class="w3tc_purge_log_backtrace">
23
+ <?php foreach ( $line['backtrace'] as $backtrace_line ) : ?>
24
  <div class="w3tc_purge_log_traceline">
25
+ <?php echo esc_html( $backtrace_line ); ?>
26
  </div>
27
  <?php endforeach ?>
28
  </div>
ObjectCache_WpObjectCache_Regular.php CHANGED
@@ -696,7 +696,11 @@ class ObjectCache_WpObjectCache_Regular {
696
  case 'redis':
697
  $engineConfig = array(
698
  'servers' => $this->_config->get_array( 'objectcache.redis.servers' ),
 
699
  'persistent' => $this->_config->get_boolean( 'objectcache.redis.persistent' ),
 
 
 
700
  'dbid' => $this->_config->get_integer( 'objectcache.redis.dbid' ),
701
  'password' => $this->_config->get_string( 'objectcache.redis.password' )
702
  );
@@ -744,8 +748,11 @@ class ObjectCache_WpObjectCache_Regular {
744
  case 'redis':
745
  $engineConfig = array(
746
  'servers' => $this->_config->get_array( 'objectcache.redis.servers' ),
747
- 'persistent' => $this->_config->get_boolean(
748
- 'objectcache.redis.persistent' ),
 
 
 
749
  'dbid' => $this->_config->get_integer( 'objectcache.redis.dbid' ),
750
  'password' => $this->_config->get_string( 'objectcache.redis.password' )
751
  );
696
  case 'redis':
697
  $engineConfig = array(
698
  'servers' => $this->_config->get_array( 'objectcache.redis.servers' ),
699
+ 'verify_tls_certificates' => $this->_config->get_boolean( 'objectcache.redis.verify_tls_certificates' ),
700
  'persistent' => $this->_config->get_boolean( 'objectcache.redis.persistent' ),
701
+ 'timeout' => $this->_config->get_integer( 'objectcache.redis.timeout' ),
702
+ 'retry_interval' => $this->_config->get_integer( 'objectcache.redis.retry_interval' ),
703
+ 'read_timeout' => $this->_config->get_integer( 'objectcache.redis.read_timeout' ),
704
  'dbid' => $this->_config->get_integer( 'objectcache.redis.dbid' ),
705
  'password' => $this->_config->get_string( 'objectcache.redis.password' )
706
  );
748
  case 'redis':
749
  $engineConfig = array(
750
  'servers' => $this->_config->get_array( 'objectcache.redis.servers' ),
751
+ 'verify_tls_certificates' => $this->_config->get_boolean( 'objectcache.redis.verify_tls_certificates' ),
752
+ 'persistent' => $this->_config->get_boolean( 'objectcache.redis.persistent' ),
753
+ 'timeout' => $this->_config->get_integer( 'objectcache.redis.timeout' ),
754
+ 'retry_interval' => $this->_config->get_integer( 'objectcache.redis.retry_interval' ),
755
+ 'read_timeout' => $this->_config->get_integer( 'objectcache.redis.read_timeout' ),
756
  'dbid' => $this->_config->get_integer( 'objectcache.redis.dbid' ),
757
  'password' => $this->_config->get_string( 'objectcache.redis.password' )
758
  );
PageSpeed_Plugin_Widget.php CHANGED
@@ -121,7 +121,7 @@ class PageSpeed_Plugin_Widget {
121
  return 'n/a';
122
  }
123
 
124
- $url = $_SERVER['HTTP_REFERER'];
125
 
126
  $config = Dispatcher::config();
127
  $key = $config->get_string( 'widget.pagespeed.key' );
121
  return 'n/a';
122
  }
123
 
124
+ $url = isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
125
 
126
  $config = Dispatcher::config();
127
  $key = $config->get_string( 'widget.pagespeed.key' );
PgCache_ContentGrabber.php CHANGED
@@ -125,7 +125,8 @@ class PgCache_ContentGrabber {
125
  'host' => Util_Environment::host_port()
126
  );
127
 
128
- $this->_request_uri = $_SERVER['REQUEST_URI'];
 
129
  $this->_lifetime = $this->_config->get_integer( 'pgcache.lifetime' );
130
  $this->_late_init = $this->_config->get_boolean( 'pgcache.late_init' );
131
  $this->_late_caching = $this->_config->get_boolean( 'pgcache.late_caching' );
@@ -394,7 +395,7 @@ class PgCache_ContentGrabber {
394
  $content = $this->_compress( $content, $compression );
395
  }
396
 
397
- echo $content;
398
 
399
  Dispatcher::usage_statistics_apply_before_init_and_exit( array( $this,
400
  'w3tc_usage_statistics_of_request' ) );
@@ -494,11 +495,13 @@ class PgCache_ContentGrabber {
494
  public function shutdown() {
495
  $compression = $this->_page_key_extension['compression'];
496
 
497
- // Parse dynamic content
498
  $buffer = $this->_parse_dynamic( $this->_shutdown_buffer );
499
 
500
- // Compress page according to headers already set
501
- echo $this->_compress( $buffer, $compression );
 
 
502
  }
503
 
504
  /**
@@ -535,16 +538,20 @@ class PgCache_ContentGrabber {
535
  /**
536
  * Skip if posting
537
  */
538
- if ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'DELETE', 'PUT', 'OPTIONS', 'TRACE', 'CONNECT', 'POST' ) ) ) {
539
- $this->cache_reject_reason = sprintf( 'Requested method is %s', $_SERVER['REQUEST_METHOD'] );
 
 
 
540
 
541
  return false;
542
  }
543
 
544
  /**
545
- * Skip if HEAD request
546
  */
547
- if ( isset( $_SERVER['REQUEST_METHOD'] ) && strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'HEAD' &&
 
548
  ( $this->_enhanced_mode || $this->_config->get_boolean( 'pgcache.reject.request_head' ) ) ) {
549
  $this->cache_reject_reason = 'Requested method is HEAD';
550
 
@@ -588,10 +595,10 @@ class PgCache_ContentGrabber {
588
  /**
589
  * Check User Agent
590
  */
591
- if ( !$this->_check_ua() ) {
592
  $this->cache_reject_reason = 'User agent is rejected';
593
- if ( isset( $_REQUEST['w3tc_rewrite_test'] ) ) {
594
- // special common case - w3tc_rewrite_test check request
595
  $this->process_status = 'miss_wp_admin';
596
  } else {
597
  $this->process_status = 'miss_configuration';
@@ -811,7 +818,11 @@ class PgCache_ContentGrabber {
811
  case 'redis':
812
  $engineConfig = array(
813
  'servers' => $this->_config->get_array( 'pgcache.redis.servers' ),
 
814
  'persistent' => $this->_config->get_boolean( 'pgcache.redis.persistent' ),
 
 
 
815
  'dbid' => $this->_config->get_integer( 'pgcache.redis.dbid' ),
816
  'password' => $this->_config->get_string( 'pgcache.redis.password' )
817
  );
@@ -860,7 +871,11 @@ class PgCache_ContentGrabber {
860
  case 'redis':
861
  $engineConfig = array(
862
  'servers' => $this->_config->get_array( 'pgcache.redis.servers' ),
 
863
  'persistent' => $this->_config->get_boolean( 'pgcache.redis.persistent' ),
 
 
 
864
  'dbid' => $this->_config->get_integer( 'pgcache.redis.dbid' ),
865
  'password' => $this->_config->get_string( 'pgcache.redis.password' )
866
  );
@@ -1064,7 +1079,7 @@ class PgCache_ContentGrabber {
1064
  foreach ( $uas as $ua ) {
1065
  if ( !empty( $ua ) ) {
1066
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
1067
- stristr( $_SERVER['HTTP_USER_AGENT'], $ua ) !== false )
1068
  return false;
1069
  }
1070
  }
@@ -1296,7 +1311,7 @@ class PgCache_ContentGrabber {
1296
  foreach ( $compressions as $compression ) {
1297
  if ( is_string( $compression ) &&
1298
  isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) &&
1299
- stristr( $_SERVER['HTTP_ACCEPT_ENCODING'], $compression ) !== false ) {
1300
  return $compression;
1301
  }
1302
  }
@@ -1377,7 +1392,7 @@ class PgCache_ContentGrabber {
1377
  */
1378
  function _is_buggy_ie() {
1379
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
1380
- $ua = $_SERVER['HTTP_USER_AGENT'];
1381
 
1382
  if ( strpos( $ua, 'Mozilla/4.0 (compatible; MSIE ' ) === 0 && strpos( $ua, 'Opera' ) === false ) {
1383
  $version = (float) substr( $ua, 30 );
@@ -1529,6 +1544,8 @@ class PgCache_ContentGrabber {
1529
 
1530
  if ( empty( $page_key_extension['group'] ) ) {
1531
  if ( $this->_enhanced_mode || $this->_nginx_memcached ) {
 
 
1532
  // URL decode
1533
  $key = urldecode( $key );
1534
 
@@ -1542,13 +1559,16 @@ class PgCache_ContentGrabber {
1542
  $key = preg_replace( '~\?.*$~', '', $key );
1543
 
1544
  // make sure one slash is at the end
 
 
 
1545
  $key = trim( $key, '/' ) . '/';
1546
 
1547
  if ( $this->_nginx_memcached ) {
1548
  return $key;
1549
  }
1550
 
1551
- return $key . '_index';
1552
  }
1553
  }
1554
 
@@ -1799,7 +1819,7 @@ class PgCache_ContentGrabber {
1799
  */
1800
  function _check_modified_since( $time ) {
1801
  if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
1802
- $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
1803
 
1804
  // IE has tacked on extra data to this header, strip it
1805
  if ( ( $semicolon = strrpos( $if_modified_since, ';' ) ) !== false ) {
@@ -1820,8 +1840,8 @@ class PgCache_ContentGrabber {
1820
  */
1821
  function _check_match( $etag ) {
1822
  if ( !empty( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
1823
- $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH'] ;
1824
- $client_etags = explode( ',', $if_none_match );
1825
 
1826
  foreach ( $client_etags as $client_etag ) {
1827
  $client_etag = trim( $client_etag );
@@ -2204,19 +2224,20 @@ class PgCache_ContentGrabber {
2204
  }
2205
  }
2206
 
2207
-
2208
-
2209
  /**
2210
- * Log
2211
  */
2212
  static protected function log( $msg ) {
2213
- $data = sprintf( "[%s] [%s] [%s] %s\n", date( 'r' ),
2214
- $_SERVER['REQUEST_URI'],
2215
- ( !empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '-' ),
2216
- $msg );
 
 
2217
  $data = strtr( $data, '<>', '..' );
2218
 
2219
  $filename = Util_Debug::log_filename( 'pagecache' );
 
2220
  return @file_put_contents( $filename, $data, FILE_APPEND );
2221
  }
2222
  }
125
  'host' => Util_Environment::host_port()
126
  );
127
 
128
+ $this->_request_uri = isset( $_SERVER['REQUEST_URI'] ) ?
129
+ filter_var( $_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL ) : ''; // phpcs:ignore
130
  $this->_lifetime = $this->_config->get_integer( 'pgcache.lifetime' );
131
  $this->_late_init = $this->_config->get_boolean( 'pgcache.late_init' );
132
  $this->_late_caching = $this->_config->get_boolean( 'pgcache.late_caching' );
395
  $content = $this->_compress( $content, $compression );
396
  }
397
 
398
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
399
 
400
  Dispatcher::usage_statistics_apply_before_init_and_exit( array( $this,
401
  'w3tc_usage_statistics_of_request' ) );
495
  public function shutdown() {
496
  $compression = $this->_page_key_extension['compression'];
497
 
498
+ // Parse dynamic content.
499
  $buffer = $this->_parse_dynamic( $this->_shutdown_buffer );
500
 
501
+ // Compress page according to headers already set.
502
+ $compressed_buffer = $this->_compress( $buffer, $compression );
503
+
504
+ echo $compressed_buffer; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
505
  }
506
 
507
  /**
538
  /**
539
  * Skip if posting
540
  */
541
+ $request_method = isset( $_SERVER['REQUEST_METHOD'] ) ?
542
+ htmlspecialchars( stripslashes( $_SERVER['REQUEST_METHOD'] ) ) : ''; // phpcs:ignore
543
+
544
+ if ( in_array( strtoupper( $request_method ), array( 'DELETE', 'PUT', 'OPTIONS', 'TRACE', 'CONNECT', 'POST' ), true ) ) {
545
+ $this->cache_reject_reason = sprintf( 'Requested method is %s', $request_method );
546
 
547
  return false;
548
  }
549
 
550
  /**
551
+ * Skip if HEAD request.
552
  */
553
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) &&
554
+ strtoupper( $_SERVER['REQUEST_METHOD'] ) === 'HEAD' && // phpcs:ignore
555
  ( $this->_enhanced_mode || $this->_config->get_boolean( 'pgcache.reject.request_head' ) ) ) {
556
  $this->cache_reject_reason = 'Requested method is HEAD';
557
 
595
  /**
596
  * Check User Agent
597
  */
598
+ if ( ! $this->_check_ua() ) {
599
  $this->cache_reject_reason = 'User agent is rejected';
600
+ if ( ! empty( Util_Request::get_string( 'w3tc_rewrite_test' ) ) ) {
601
+ // special common case - w3tc_rewrite_test check request.
602
  $this->process_status = 'miss_wp_admin';
603
  } else {
604
  $this->process_status = 'miss_configuration';
818
  case 'redis':
819
  $engineConfig = array(
820
  'servers' => $this->_config->get_array( 'pgcache.redis.servers' ),
821
+ 'verify_tls_certificates' => $this->_config->get_boolean( 'pgcache.redis.verify_tls_certificates' ),
822
  'persistent' => $this->_config->get_boolean( 'pgcache.redis.persistent' ),
823
+ 'timeout' => $this->_config->get_integer( 'pgcache.redis.timeout' ),
824
+ 'retry_interval' => $this->_config->get_integer( 'pgcache.redis.retry_interval' ),
825
+ 'read_timeout' => $this->_config->get_integer( 'pgcache.redis.read_timeout' ),
826
  'dbid' => $this->_config->get_integer( 'pgcache.redis.dbid' ),
827
  'password' => $this->_config->get_string( 'pgcache.redis.password' )
828
  );
871
  case 'redis':
872
  $engineConfig = array(
873
  'servers' => $this->_config->get_array( 'pgcache.redis.servers' ),
874
+ 'verify_tls_certificates' => $this->_config->get_boolean( 'pgcache.redis.verify_tls_certificates' ),
875
  'persistent' => $this->_config->get_boolean( 'pgcache.redis.persistent' ),
876
+ 'timeout' => $this->_config->get_integer( 'pgcache.redis.timeout' ),
877
+ 'retry_interval' => $this->_config->get_integer( 'pgcache.redis.retry_interval' ),
878
+ 'read_timeout' => $this->_config->get_integer( 'pgcache.redis.read_timeout' ),
879
  'dbid' => $this->_config->get_integer( 'pgcache.redis.dbid' ),
880
  'password' => $this->_config->get_string( 'pgcache.redis.password' )
881
  );
1079
  foreach ( $uas as $ua ) {
1080
  if ( !empty( $ua ) ) {
1081
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
1082
+ stristr( htmlspecialchars( stripslashes( $_SERVER['HTTP_USER_AGENT'] ) ), $ua ) !== false ) // phpcs:ignore
1083
  return false;
1084
  }
1085
  }
1311
  foreach ( $compressions as $compression ) {
1312
  if ( is_string( $compression ) &&
1313
  isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) &&
1314
+ stristr( htmlspecialchars( stripslashes( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ), $compression ) !== false ) { // phpcs:ignore
1315
  return $compression;
1316
  }
1317
  }
1392
  */
1393
  function _is_buggy_ie() {
1394
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
1395
+ $ua = htmlspecialchars( stripslashes( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore
1396
 
1397
  if ( strpos( $ua, 'Mozilla/4.0 (compatible; MSIE ' ) === 0 && strpos( $ua, 'Opera' ) === false ) {
1398
  $version = (float) substr( $ua, 30 );
1544
 
1545
  if ( empty( $page_key_extension['group'] ) ) {
1546
  if ( $this->_enhanced_mode || $this->_nginx_memcached ) {
1547
+ $extra = '';
1548
+
1549
  // URL decode
1550
  $key = urldecode( $key );
1551
 
1559
  $key = preg_replace( '~\?.*$~', '', $key );
1560
 
1561
  // make sure one slash is at the end
1562
+ if (substr($key, strlen($key) - 1, 1) == '/') {
1563
+ $extra = '_slash';
1564
+ }
1565
  $key = trim( $key, '/' ) . '/';
1566
 
1567
  if ( $this->_nginx_memcached ) {
1568
  return $key;
1569
  }
1570
 
1571
+ return $key . '_index' . $extra;
1572
  }
1573
  }
1574
 
1819
  */
1820
  function _check_modified_since( $time ) {
1821
  if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
1822
+ $if_modified_since = htmlspecialchars( stripslashes( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ); // phpcs:ignore
1823
 
1824
  // IE has tacked on extra data to this header, strip it
1825
  if ( ( $semicolon = strrpos( $if_modified_since, ';' ) ) !== false ) {
1840
  */
1841
  function _check_match( $etag ) {
1842
  if ( !empty( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
1843
+ $if_none_match = htmlspecialchars( stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ); // phpcs:ignore
1844
+ $client_etags = explode( ',', $if_none_match );
1845
 
1846
  foreach ( $client_etags as $client_etag ) {
1847
  $client_etag = trim( $client_etag );
2224
  }
2225
  }
2226
 
 
 
2227
  /**
2228
+ * Log.
2229
  */
2230
  static protected function log( $msg ) {
2231
+ $data = sprintf(
2232
+ "[%s] [%s] [%s] %s\n", date( 'r' ),
2233
+ isset( $_SERVER['REQUEST_URI'] ) ? filter_var( stripslashes( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : '',
2234
+ ! empty( $_SERVER['HTTP_REFERER'] ) ? htmlspecialchars( $_SERVER['HTTP_REFERER'] ) : '-',
2235
+ $msg
2236
+ );
2237
  $data = strtr( $data, '<>', '..' );
2238
 
2239
  $filename = Util_Debug::log_filename( 'pagecache' );
2240
+
2241
  return @file_put_contents( $filename, $data, FILE_APPEND );
2242
  }
2243
  }
PgCache_Environment.php CHANGED
@@ -189,7 +189,7 @@ class PgCache_Environment {
189
 
190
  try{
191
  if ( file_exists( $dir ) && !is_writeable( $dir ) )
192
- Util_WpFile::delete_folder( $dir, '', $_SERVER['REQUEST_URI'] );
193
  } catch ( Util_WpFile_FilesystemRmdirException $ex ) {
194
  $exs->push( $ex );
195
  }
@@ -703,6 +703,10 @@ class PgCache_Environment {
703
  $rules .= " RewriteRule .* - [E=W3TC_PREVIEW:_preview]\n";
704
  $env_W3TC_PREVIEW = '%{ENV:W3TC_PREVIEW}';
705
 
 
 
 
 
706
  $use_cache_rules = '';
707
  /**
708
  * Don't accept POSTs
@@ -735,7 +739,7 @@ class PgCache_Environment {
735
  * Make final rewrites for specific files
736
  */
737
  $uri_prefix = $cache_path . '/%{HTTP_HOST}/%{REQUEST_URI}/' .
738
- '_index' . $env_W3TC_UA . $env_W3TC_REF . $env_W3TC_COOKIE .
739
  $env_W3TC_SSL . $env_W3TC_PREVIEW;
740
  $uri_prefix = apply_filters( 'w3tc_pagecache_rules_apache_uri_prefix',
741
  $uri_prefix );
@@ -752,15 +756,6 @@ class PgCache_Environment {
752
  foreach ( $exts as $ext ) {
753
  $rules .= $use_cache_rules;
754
 
755
- if ( $ext == '.html' ) {
756
- /**
757
- * Check permalink structure trailing slash
758
- */
759
- if ( substr( $permalink_structure, -1 ) == '/' ) {
760
- $rules .= " RewriteCond %{REQUEST_URI} \\/$\n";
761
- }
762
- }
763
-
764
  $rules .= " RewriteCond \"" . $document_root . $uri_prefix . $ext .
765
  $env_W3TC_ENC . "\"" . $switch . "\n";
766
  $rules .= " RewriteRule .* \"" . $uri_prefix . $ext .
@@ -956,17 +951,11 @@ class PgCache_Environment {
956
  $rules .= " set \$w3tc_rewrite 0;\n";
957
  $rules .= "}\n";
958
 
959
- /**
960
- * Check permalink structure trailing slash
961
- * and allow WordPress to redirect for non-slash URIs
962
- */
963
- if ( $pgcache_engine == 'file_generic' ) {
964
- if ( substr( $permalink_structure, -1 ) == '/' ) {
965
- $rules .= "if ($env_request_uri !~ \\/$) {\n";
966
- $rules .= " set \$w3tc_rewrite 0;\n";
967
- $rules .= "}\n";
968
- }
969
- }
970
 
971
  /**
972
  * Check for rejected cookies
@@ -1129,7 +1118,7 @@ class PgCache_Environment {
1129
  $env_w3tc_enc = '$w3tc_enc';
1130
  }
1131
 
1132
- $key_postfix = $env_w3tc_ua . $env_w3tc_ref . $env_w3tc_cookie .
1133
  $env_w3tc_ssl . $env_w3tc_preview;
1134
 
1135
  if ( $pgcache_engine == 'file_generic' ) {
189
 
190
  try{
191
  if ( file_exists( $dir ) && !is_writeable( $dir ) )
192
+ Util_WpFile::delete_folder( $dir, '', isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' );
193
  } catch ( Util_WpFile_FilesystemRmdirException $ex ) {
194
  $exs->push( $ex );
195
  }
703
  $rules .= " RewriteRule .* - [E=W3TC_PREVIEW:_preview]\n";
704
  $env_W3TC_PREVIEW = '%{ENV:W3TC_PREVIEW}';
705
 
706
+ $rules .= " RewriteCond %{REQUEST_URI} \\/$\n";
707
+ $rules .= " RewriteRule .* - [E=W3TC_SLASH:_slash]\n";
708
+ $env_W3TC_SLASH = '%{ENV:W3TC_SLASH}';
709
+
710
  $use_cache_rules = '';
711
  /**
712
  * Don't accept POSTs
739
  * Make final rewrites for specific files
740
  */
741
  $uri_prefix = $cache_path . '/%{HTTP_HOST}/%{REQUEST_URI}/' .
742
+ '_index' . $env_W3TC_SLASH . $env_W3TC_UA . $env_W3TC_REF . $env_W3TC_COOKIE .
743
  $env_W3TC_SSL . $env_W3TC_PREVIEW;
744
  $uri_prefix = apply_filters( 'w3tc_pagecache_rules_apache_uri_prefix',
745
  $uri_prefix );
756
  foreach ( $exts as $ext ) {
757
  $rules .= $use_cache_rules;
758
 
 
 
 
 
 
 
 
 
 
759
  $rules .= " RewriteCond \"" . $document_root . $uri_prefix . $ext .
760
  $env_W3TC_ENC . "\"" . $switch . "\n";
761
  $rules .= " RewriteRule .* \"" . $uri_prefix . $ext .
951
  $rules .= " set \$w3tc_rewrite 0;\n";
952
  $rules .= "}\n";
953
 
954
+ $rules .= "set \$w3tc_slash \"\";\n";
955
+ $rules .= "if ($env_request_uri ~ \\/$) {\n";
956
+ $rules .= " set \$w3tc_slash _slash;\n";
957
+ $rules .= "}\n";
958
+ $env_w3tc_slash = "\$w3tc_slash";
 
 
 
 
 
 
959
 
960
  /**
961
  * Check for rejected cookies
1118
  $env_w3tc_enc = '$w3tc_enc';
1119
  }
1120
 
1121
+ $key_postfix = $env_w3tc_slash . $env_w3tc_ua . $env_w3tc_ref . $env_w3tc_cookie .
1122
  $env_w3tc_ssl . $env_w3tc_preview;
1123
 
1124
  if ( $pgcache_engine == 'file_generic' ) {
PgCache_Plugin.php CHANGED
@@ -212,9 +212,8 @@ class PgCache_Plugin {
212
  $redirect_url .= ':' . (int)$parsed_url['port'];
213
  }
214
 
215
- $redirect_url .= $_SERVER['REQUEST_URI'];
216
 
217
- //echo $redirect_url;
218
  wp_redirect( $redirect_url, 301 );
219
  exit();
220
  }
212
  $redirect_url .= ':' . (int)$parsed_url['port'];
213
  }
214
 
215
+ $redirect_url .= isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
216
 
 
217
  wp_redirect( $redirect_url, 301 );
218
  exit();
219
  }
Root_AdminActivation.php CHANGED
@@ -5,56 +5,69 @@ namespace W3TC;
5
  * W3 Total Cache plugin
6
  */
7
 
8
-
9
-
10
-
11
  /**
12
- * class Root_AdminActivation
13
  */
14
  class Root_AdminActivation {
15
  /**
16
  * Activate plugin action
17
  *
18
- * @param bool $network_wide
19
  * @return void
20
  */
21
- static public function activate( $network_wide ) {
22
- // decline non-network activation at WPMU
23
  if ( Util_Environment::is_wpmu() ) {
24
  if ( $network_wide ) {
25
- // we are in network activation
26
- } else if ( $_GET['action'] == 'error_scrape' &&
27
- strpos( $_SERVER['REQUEST_URI'], '/network/' ) !== false ) {
28
- // workaround for error_scrape page called after error
29
- // really we are in network activation and going to throw some error
30
- } else {
31
- echo 'Please <a href="' . network_admin_url( 'plugins.php' ) . '">network activate</a> W3 Total Cache when using WordPress Multisite.';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  die;
33
  }
34
  }
35
 
36
  try {
37
- $e = Dispatcher::component( 'Root_Environment' );
38
-
39
  $config = Dispatcher::config();
40
  $e->fix_in_wpadmin( $config, true );
41
  $e->fix_on_event( $config, 'activate' );
42
 
43
- // try to save config file if needed, optional thing so exceptions
44
- // hidden
45
- if ( !ConfigUtil::is_item_exists( 0, false ) ) {
46
  try {
47
- // create folders
48
  $e->fix_in_wpadmin( $config );
49
  } catch ( \Exception $ex ) {
 
50
  }
51
 
52
  try {
53
  Util_Admin::config_save( Dispatcher::config(), $config );
54
  } catch ( \Exception $ex ) {
 
55
  }
56
  }
57
  } catch ( Util_Environment_Exceptions $e ) {
 
58
  } catch ( \Exception $e ) {
59
  Util_Activation::error_on_exception( $e );
60
  }
@@ -65,10 +78,11 @@ class Root_AdminActivation {
65
  *
66
  * @return void
67
  */
68
- static public function deactivate() {
69
  try {
70
  Util_Activation::enable_maintenance_mode();
71
  } catch ( \Exception $ex ) {
 
72
  }
73
 
74
  try {
@@ -78,27 +92,45 @@ class Root_AdminActivation {
78
  $r = Util_Activation::parse_environment_exceptions( $exs );
79
 
80
  if ( strlen( $r['required_changes'] ) > 0 ) {
81
- $changes_style = 'border: 1px solid black; ' .
82
- 'background: white; ' .
83
- 'margin: 10px 30px 10px 30px; ' .
84
- 'padding: 10px;';
85
-
86
- $error = '<strong>W3 Total Cache Error:</strong> ' .
87
- 'Files and directories could not be automatically ' .
88
- 'removed to complete the deactivation. ' .
89
- '<br />Please execute commands manually:<br />' .
90
- '<div style="' . $changes_style . '">' .
91
- $r['required_changes'] . '</div>';
92
-
93
- // this is not shown since wp redirects from that page
94
- // not solved now
95
- echo '<div class="error"><p>' . $error . '</p></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
  }
98
 
99
  try {
100
  Util_Activation::disable_maintenance_mode();
101
  } catch ( \Exception $ex ) {
 
102
  }
103
 
104
  // Delete cron events.
5
  * W3 Total Cache plugin
6
  */
7
 
 
 
 
8
  /**
9
+ * Class Root_AdminActivation
10
  */
11
  class Root_AdminActivation {
12
  /**
13
  * Activate plugin action
14
  *
15
+ * @param bool $network_wide
16
  * @return void
17
  */
18
+ public static function activate( $network_wide ) {
19
+ // Decline non-network activation at WPMU.
20
  if ( Util_Environment::is_wpmu() ) {
21
  if ( $network_wide ) {
22
+ // We are in network activation.
23
+ } else if ( Util_Request::get_string( 'action' ) == 'error_scrape' &&
24
+ strpos( isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '', '/network/' ) !== false ) {
25
+ // Workaround for error_scrape page called after error really we are in network activation and going to throw some error.
26
+ } else {
27
+ echo wp_kses(
28
+ sprintf(
29
+ // translators: 1 opening HTML a tag to plugin admin page, 2 closing HTML a tag.
30
+ __(
31
+ 'Please %1$snetwork activate%2$s W3 Total Cache when using WordPress Multisite.',
32
+ 'w3-total-cache'
33
+ ),
34
+ '<a href="' . esc_url( network_admin_url( 'plugins.php' ) ) . '">',
35
+ '</a>'
36
+ ),
37
+ array(
38
+ 'a' => array(
39
+ 'href' => array(),
40
+ ),
41
+ )
42
+ );
43
+
44
  die;
45
  }
46
  }
47
 
48
  try {
49
+ $e = Dispatcher::component( 'Root_Environment' );
 
50
  $config = Dispatcher::config();
51
  $e->fix_in_wpadmin( $config, true );
52
  $e->fix_on_event( $config, 'activate' );
53
 
54
+ // try to save config file if needed, optional thing so exceptions hidden.
55
+ if ( ! ConfigUtil::is_item_exists( 0, false ) ) {
 
56
  try {
57
+ // create folders.
58
  $e->fix_in_wpadmin( $config );
59
  } catch ( \Exception $ex ) {
60
+ // missing exception handle?
61
  }
62
 
63
  try {
64
  Util_Admin::config_save( Dispatcher::config(), $config );
65
  } catch ( \Exception $ex ) {
66
+ // missing exception handle?
67
  }
68
  }
69
  } catch ( Util_Environment_Exceptions $e ) {
70
+ // missing exception handle?
71
  } catch ( \Exception $e ) {
72
  Util_Activation::error_on_exception( $e );
73
  }
78
  *
79
  * @return void
80
  */
81
+ public static function deactivate() {
82
  try {
83
  Util_Activation::enable_maintenance_mode();
84
  } catch ( \Exception $ex ) {
85
+ // missing exception handle?
86
  }
87
 
88
  try {
92
  $r = Util_Activation::parse_environment_exceptions( $exs );
93
 
94
  if ( strlen( $r['required_changes'] ) > 0 ) {
95
+ $changes_style = 'border: 1px solid black; background: white; margin: 10px 30px 10px 30px; padding: 10px;';
96
+
97
+ // this is not shown since wp redirects from that page not solved now.
98
+ echo wp_kses(
99
+ sprintf(
100
+ // translators: 1 opening HTML div tag followed by opening HTML p tag, 2 opening HTML strong tag,
101
+ // translators: 3 closing HTML strong tag, 4 html line break tags (x2), 5 opening HTML div tag,
102
+ // translators: 6 list of required changes, 7 closing HTML div tag,
103
+ // translators: 8 closing HTML p tag followed by closing HTML div tag.
104
+ __(
105
+ '%1$s%2$sW3 Total Cache Error:%3$s Files and directories could not be automatically removed to complete the deactivation. %4$sPlease execute commands manually:%5$s%6$s%7$s%8$s',
106
+ 'w3-total-cache'
107
+ ),
108
+ '<div class="' . esc_attr__( 'error', 'w3-total-cache' ) . '"><p>',
109
+ '<strong>',
110
+ '</strong>',
111
+ '<br /><br />',
112
+ '<div style="' . esc_attr( $changes_style ) . '">',
113
+ esc_html( $r['required_changes'] ),
114
+ '</div>',
115
+ '</p></div>'
116
+ ),
117
+ array(
118
+ 'div' => array(
119
+ 'class' => array(),
120
+ 'style' => array(),
121
+ ),
122
+ 'strong' => array(),
123
+ 'br' => array(),
124
+ 'p' => array(),
125
+ )
126
+ );
127
  }
128
  }
129
 
130
  try {
131
  Util_Activation::disable_maintenance_mode();
132
  } catch ( \Exception $ex ) {
133
+ // missing exception handle?
134
  }
135
 
136
  // Delete cron events.
Root_AdminMenu.php CHANGED
@@ -209,7 +209,7 @@ class Root_AdminMenu {
209
  /*
210
  * Hidden pages.
211
  */
212
- if ( isset( $_REQUEST['w3tc_dbcluster_config'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
213
  $options_dbcache = new DbCache_Page();
214
  $options_dbcache->dbcluster_config();
215
  }
209
  /*
210
  * Hidden pages.
211
  */
212
+ if ( ! empty( Util_Request::get_string( 'w3tc_dbcluster_config' ) ) ) {
213
  $options_dbcache = new DbCache_Page();
214
  $options_dbcache->dbcluster_config();
215
  }
Root_Loader.php CHANGED
@@ -163,52 +163,57 @@ class Root_Loader {
163
  do_action( 'w3tc_extension_load_admin' );
164
  }
165
 
166
- // Hide Image Service media.
167
- add_action(
168
- 'pre_get_posts',
169
- function( $query ) {
170
- if ( ! is_admin() || ! $query->is_main_query() ) {
171
- return;
172
- }
173
-
174
- $screen = get_current_screen();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
- if ( ! $screen || 'upload' !== $screen->id || 'attachment' !== $screen->post_type ) {
177
  return;
178
  }
 
 
 
 
 
 
 
 
179
 
180
- $query->set(
181
- 'meta_query',
182
- array(
183
  array(
184
  'key' => 'w3tc_imageservice_file',
185
  'compare' => 'NOT EXISTS',
186
  ),
187
- )
188
- );
189
-
190
- return;
191
- }
192
- );
193
 
194
- add_filter(
195
- 'ajax_query_attachments_args',
196
- function( $args ) {
197
- if ( ! is_admin() ) {
198
- return;
199
  }
200
-
201
- // Modify the query.
202
- $args['meta_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
203
- array(
204
- 'key' => 'w3tc_imageservice_file',
205
- 'compare' => 'NOT EXISTS',
206
- ),
207
- );
208
-
209
- return $args;
210
- }
211
- );
212
  }
213
  }
214
 
163
  do_action( 'w3tc_extension_load_admin' );
164
  }
165
 
166
+ // Hide Image Service converted images.
167
+ $settings = $c->get_array( 'imageservice' );
168
+ $visibility = isset( $settings['visibility'] ) ? $settings['visibility'] : 'never';
169
+
170
+ if ( 'never' === $visibility || ( 'extension' === $visibility && ! isset( $extensions['imageservice'] ) ) ) {
171
+ add_action(
172
+ 'pre_get_posts',
173
+ function( $query ) {
174
+ if ( ! is_admin() || ! $query->is_main_query() ) {
175
+ return;
176
+ }
177
+
178
+ $screen = get_current_screen();
179
+
180
+ if ( ! $screen || 'upload' !== $screen->id || 'attachment' !== $screen->post_type ) {
181
+ return;
182
+ }
183
+
184
+ $query->set(
185
+ 'meta_query',
186
+ array(
187
+ array(
188
+ 'key' => 'w3tc_imageservice_file',
189
+ 'compare' => 'NOT EXISTS',
190
+ ),
191
+ )
192
+ );
193
 
 
194
  return;
195
  }
196
+ );
197
+
198
+ add_filter(
199
+ 'ajax_query_attachments_args',
200
+ function( $args ) {
201
+ if ( ! is_admin() ) {
202
+ return;
203
+ }
204
 
205
+ // Modify the query.
206
+ $args['meta_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
 
207
  array(
208
  'key' => 'w3tc_imageservice_file',
209
  'compare' => 'NOT EXISTS',
210
  ),
211
+ );
 
 
 
 
 
212
 
213
+ return $args;
 
 
 
 
214
  }
215
+ );
216
+ }
 
 
 
 
 
 
 
 
 
 
217
  }
218
  }
219
 
SetupGuide_Plugin_Admin.php CHANGED
@@ -40,7 +40,8 @@ class SetupGuide_Plugin_Admin {
40
  public function __construct() {
41
  $page = Util_Request::get_string( 'page' );
42
  $is_w3tc_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX &&
43
- isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'w3tc_' ); // phpcs:ignore
 
44
 
45
  if ( 'w3tc_setup_guide' === $page || $is_w3tc_ajax ) {
46
  require_once W3TC_INC_DIR . '/wizard/template.php';
@@ -78,7 +79,7 @@ class SetupGuide_Plugin_Admin {
78
  * @since 2.0.0
79
  */
80
  public function skip() {
81
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
82
  update_site_option( 'w3tc_setupguide_completed', time() );
83
  wp_send_json_success();
84
  } else {
@@ -94,8 +95,8 @@ class SetupGuide_Plugin_Admin {
94
  * @uses $_POST['choice'] TOS choice: accept/decline.
95
  */
96
  public function set_tos_choice() {
97
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
98
- $choice = empty( $_POST['choice'] ) ? null : sanitize_key( $_POST['choice'] );
99
  $allowed_choices = array(
100
  'accept',
101
  'decline',
@@ -159,8 +160,8 @@ class SetupGuide_Plugin_Admin {
159
  * @see \W3TC\Util_Http::ttfb()
160
  */
161
  public function test_pgcache() {
162
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
163
- $nocache = ! empty( $_POST['nocache'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
164
  $url = site_url();
165
  $results = array(
166
  'nocache' => $nocache,
@@ -189,7 +190,7 @@ class SetupGuide_Plugin_Admin {
189
  * @see \W3TC\Config::get_string()
190
  */
191
  public function get_pgcache_settings() {
192
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
193
  $config = new Config();
194
 
195
  wp_send_json_success(
@@ -217,9 +218,9 @@ class SetupGuide_Plugin_Admin {
217
  * @see \W3TC\CacheFlush::flush_posts()
218
  */
219
  public function config_pgcache() {
220
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
221
- $enable = ! empty( $_POST['enable'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
222
- $engine = empty( $_POST['engine'] ) ? '' : esc_attr( trim( $_POST['engine'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
223
  $is_updating = false;
224
  $success = false;
225
  $config = new Config();
@@ -302,7 +303,7 @@ class SetupGuide_Plugin_Admin {
302
  * @global $wpdb WordPress database object.
303
  */
304
  public function test_dbcache() {
305
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
306
  $config = new Config();
307
  $results = array(
308
  'enabled' => $config->get_boolean( 'dbcache.enabled' ),
@@ -378,7 +379,7 @@ class SetupGuide_Plugin_Admin {
378
  * @see \W3TC\Config::get_string()
379
  */
380
  public function get_dbcache_settings() {
381
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
382
  $config = new Config();
383
 
384
  wp_send_json_success(
@@ -406,9 +407,9 @@ class SetupGuide_Plugin_Admin {
406
  * @see \W3TC\CacheFlush::dbcache_flush()
407
  */
408
  public function config_dbcache() {
409
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
410
- $enable = ! empty( $_POST['enable'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
411
- $engine = empty( $_POST['engine'] ) ? '' : esc_attr( trim( $_POST['engine'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
412
  $is_updating = false;
413
  $success = false;
414
  $config = new Config();
@@ -484,7 +485,7 @@ class SetupGuide_Plugin_Admin {
484
  * @see \W3TC\Config::get_string()
485
  */
486
  public function test_objcache() {
487
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
488
  $config = new Config();
489
  $results = array(
490
  'enabled' => $config->get_boolean( 'objectcache.enabled' ),
@@ -521,7 +522,7 @@ class SetupGuide_Plugin_Admin {
521
  * @see \W3TC\Config::get_string()
522
  */
523
  public function get_objcache_settings() {
524
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
525
  $config = new Config();
526
 
527
  wp_send_json_success(
@@ -549,9 +550,9 @@ class SetupGuide_Plugin_Admin {
549
  * @see \W3TC\CacheFlush::objcache_flush()
550
  */
551
  public function config_objcache() {
552
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
553
- $enable = ! empty( $_POST['enable'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
554
- $engine = empty( $_POST['engine'] ) ? '' : esc_attr( trim( $_POST['engine'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
555
  $is_updating = false;
556
  $success = false;
557
  $config = new Config();
@@ -627,7 +628,7 @@ class SetupGuide_Plugin_Admin {
627
  * @see \W3TC\Util_Http::get_headers()
628
  */
629
  public function test_browsercache() {
630
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
631
  $results = array();
632
  $urls = array(
633
  trailingslashit( site_url() ),
@@ -666,7 +667,7 @@ class SetupGuide_Plugin_Admin {
666
  * @see \W3TC\Config::get_string()
667
  */
668
  public function get_browsercache_settings() {
669
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
670
  $config = new Config();
671
 
672
  wp_send_json_success(
@@ -700,8 +701,8 @@ class SetupGuide_Plugin_Admin {
700
  * @uses $_POST['enable']
701
  */
702
  public function config_browsercache() {
703
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
704
- $enable = ! empty( $_POST['enable'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
705
  $config = new Config();
706
  $browsercache_enabled = $config->get_boolean( 'browsercache.enabled' );
707
 
@@ -747,7 +748,7 @@ class SetupGuide_Plugin_Admin {
747
  * @see \W3TC\Config::get_array()
748
  */
749
  public function get_lazyload_settings() {
750
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
751
  $config = new Config();
752
 
753
  wp_send_json_success(
@@ -779,8 +780,8 @@ class SetupGuide_Plugin_Admin {
779
  * @uses $_POST['enable']
780
  */
781
  public function config_lazyload() {
782
- if ( wp_verify_nonce( $_POST['_wpnonce'], 'w3tc_wizard' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
783
- $enable = ! empty( $_POST['enable'] );
784
  $config = new Config();
785
  $lazyload_enabled = $config->get_boolean( 'lazyload.enabled' );
786
 
@@ -813,39 +814,13 @@ class SetupGuide_Plugin_Admin {
813
  }
814
  }
815
 
816
- /**
817
- * Get the terms of service choice.
818
- *
819
- * @since 2.0.0
820
- *
821
- * @see \W3TC\Util_Environment::is_w3tc_pro()
822
- * @see \W3TC\Dispatcher::config_state()
823
- * @see \W3TC\Dispatcher::config_state_master()
824
- * @see \W3TC\ConfigState::get_string()
825
- *
826
- * @return string
827
- */
828
- private function get_tos_choice() {
829
- $config = new Config();
830
-
831
- if ( Util_Environment::is_w3tc_pro( $config ) ) {
832
- $state = Dispatcher::config_state();
833
- $terms = $state->get_string( 'license.terms' );
834
- } else {
835
- $state_master = Dispatcher::config_state_master();
836
- $terms = $state_master->get_string( 'license.community_terms' );
837
- }
838
-
839
- return $terms;
840
- }
841
-
842
  /**
843
  * Display the terms of service dialog if needed.
844
  *
845
  * @since 2.0.0
846
  * @access private
847
  *
848
- * @see self::get_tos_choice()
849
  *
850
  * @return bool
851
  */
@@ -854,7 +829,7 @@ class SetupGuide_Plugin_Admin {
854
  return false;
855
  }
856
 
857
- $terms = $this->get_tos_choice();
858
 
859
  return 'accept' !== $terms && 'decline' !== $terms && 'postpone' !== $terms;
860
  }
@@ -871,6 +846,7 @@ class SetupGuide_Plugin_Admin {
871
  * @see \W3TC\Config::get_boolean()
872
  * @see \W3TC\Util_Request::get_string()
873
  * @see \W3TC\Dispatcher::config_state()
 
874
  * @see \W3TC\Util_Environment::home_url_host()
875
  * @see \W3TC\Util_Environment::w3tc_edition()
876
  * @see \W3TC\Util_Widget::list_widgets()
@@ -914,7 +890,7 @@ class SetupGuide_Plugin_Admin {
914
  'w3tc_edition' => esc_attr( Util_Environment::w3tc_edition( $config ) ),
915
  'list_widgets' => esc_attr( Util_Widget::list_widgets() ),
916
  'ga_profile' => ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) ? 'UA-2264433-7' : 'UA-2264433-8',
917
- 'tos_choice' => $this->get_tos_choice(),
918
  'track_usage' => $config->get_boolean( 'common.track_usage' ),
919
  'test_complete_msg' => __(
920
  'Testing complete. Click Next to advance to the section and see the results.',
40
  public function __construct() {
41
  $page = Util_Request::get_string( 'page' );
42
  $is_w3tc_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX &&
43
+ ! empty( Util_Request::get_string( 'action' ) )
44
+ && 0 === strpos( Util_Request::get_string( 'action' ), 'w3tc_' );
45
 
46
  if ( 'w3tc_setup_guide' === $page || $is_w3tc_ajax ) {
47
  require_once W3TC_INC_DIR . '/wizard/template.php';
79
  * @since 2.0.0
80
  */
81
  public function skip() {
82
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
83
  update_site_option( 'w3tc_setupguide_completed', time() );
84
  wp_send_json_success();
85
  } else {
95
  * @uses $_POST['choice'] TOS choice: accept/decline.
96
  */
97
  public function set_tos_choice() {
98
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
99
+ $choice = Util_Request::get_string( 'choice' );
100
  $allowed_choices = array(
101
  'accept',
102
  'decline',
160
  * @see \W3TC\Util_Http::ttfb()
161
  */
162
  public function test_pgcache() {
163
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
164
+ $nocache = ! empty( Util_Request::get_string( 'nocache' ) );
165
  $url = site_url();
166
  $results = array(
167
  'nocache' => $nocache,
190
  * @see \W3TC\Config::get_string()
191
  */
192
  public function get_pgcache_settings() {
193
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
194
  $config = new Config();
195
 
196
  wp_send_json_success(
218
  * @see \W3TC\CacheFlush::flush_posts()
219
  */
220
  public function config_pgcache() {
221
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
222
+ $enable = ! empty( Util_Request::get_string( 'enable' ) );
223
+ $engine = empty( Util_Request::get_string( 'engine' ) ) ? '' : esc_attr( Util_Request::get_string( 'engine', '', true ) );
224
  $is_updating = false;
225
  $success = false;
226
  $config = new Config();
303
  * @global $wpdb WordPress database object.
304
  */
305
  public function test_dbcache() {
306
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
307
  $config = new Config();
308
  $results = array(
309
  'enabled' => $config->get_boolean( 'dbcache.enabled' ),
379
  * @see \W3TC\Config::get_string()
380
  */
381
  public function get_dbcache_settings() {
382
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
383
  $config = new Config();
384
 
385
  wp_send_json_success(
407
  * @see \W3TC\CacheFlush::dbcache_flush()
408
  */
409
  public function config_dbcache() {
410
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
411
+ $enable = ! empty( Util_Request::get_string( 'enable' ) );
412
+ $engine = empty( Util_Request::get_string( 'engine' ) ) ? '' : esc_attr( Util_Request::get_string( 'engine', '', true ) );
413
  $is_updating = false;
414
  $success = false;
415
  $config = new Config();
485
  * @see \W3TC\Config::get_string()
486
  */
487
  public function test_objcache() {
488
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
489
  $config = new Config();
490
  $results = array(
491
  'enabled' => $config->get_boolean( 'objectcache.enabled' ),
522
  * @see \W3TC\Config::get_string()
523
  */
524
  public function get_objcache_settings() {
525
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
526
  $config = new Config();
527
 
528
  wp_send_json_success(
550
  * @see \W3TC\CacheFlush::objcache_flush()
551
  */
552
  public function config_objcache() {
553
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
554
+ $enable = ! empty( Util_Request::get_string( 'enable' ) );
555
+ $engine = empty( Util_Request::get_string( 'engine' ) ) ? '' : esc_attr( Util_Request::get_string( 'engine', '', true ) );
556
  $is_updating = false;
557
  $success = false;
558
  $config = new Config();
628
  * @see \W3TC\Util_Http::get_headers()
629
  */
630
  public function test_browsercache() {
631
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
632
  $results = array();
633
  $urls = array(
634
  trailingslashit( site_url() ),
667
  * @see \W3TC\Config::get_string()
668
  */
669
  public function get_browsercache_settings() {
670
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
671
  $config = new Config();
672
 
673
  wp_send_json_success(
701
  * @uses $_POST['enable']
702
  */
703
  public function config_browsercache() {
704
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
705
+ $enable = ! empty( Util_Request::get_string( 'enable' ) );
706
  $config = new Config();
707
  $browsercache_enabled = $config->get_boolean( 'browsercache.enabled' );
708
 
748
  * @see \W3TC\Config::get_array()
749
  */
750
  public function get_lazyload_settings() {
751
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
752
  $config = new Config();
753
 
754
  wp_send_json_success(
780
  * @uses $_POST['enable']
781
  */
782
  public function config_lazyload() {
783
+ if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
784
+ $enable = ! empty( Util_Request::get_string( 'enable' ) );
785
  $config = new Config();
786
  $lazyload_enabled = $config->get_boolean( 'lazyload.enabled' );
787
 
814
  }
815
  }
816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
  /**
818
  * Display the terms of service dialog if needed.
819
  *
820
  * @since 2.0.0
821
  * @access private
822
  *
823
+ * @see Licensing_Core::get_tos_choice()
824
  *
825
  * @return bool
826
  */
829
  return false;
830
  }
831
 
832
+ $terms = Licensing_Core::get_tos_choice();
833
 
834
  return 'accept' !== $terms && 'decline' !== $terms && 'postpone' !== $terms;
835
  }
846
  * @see \W3TC\Config::get_boolean()
847
  * @see \W3TC\Util_Request::get_string()
848
  * @see \W3TC\Dispatcher::config_state()
849
+ * @see \W3TC\Licensing_Core::get_tos_choice()
850
  * @see \W3TC\Util_Environment::home_url_host()
851
  * @see \W3TC\Util_Environment::w3tc_edition()
852
  * @see \W3TC\Util_Widget::list_widgets()
890
  'w3tc_edition' => esc_attr( Util_Environment::w3tc_edition( $config ) ),
891
  'list_widgets' => esc_attr( Util_Widget::list_widgets() ),
892
  'ga_profile' => ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) ? 'UA-2264433-7' : 'UA-2264433-8',
893
+ 'tos_choice' => Licensing_Core::get_tos_choice(),
894
  'track_usage' => $config->get_boolean( 'common.track_usage' ),
895
  'test_complete_msg' => __(
896
  'Testing complete. Click Next to advance to the section and see the results.',
Support_AdminActions.php CHANGED
@@ -13,9 +13,9 @@ class Support_AdminActions {
13
  $post = array();
14
 
15
  foreach ( $_GET as $p => $v )
16
- $post[$p] = $v;
17
 
18
- $post['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
19
  $post['version'] = W3TC_VERSION;
20
 
21
  $license_level = 'community';
@@ -160,7 +160,7 @@ class Support_AdminActions {
160
  $server_info = array(
161
  'w3tc' => array(
162
  'version' => W3TC_VERSION,
163
- 'server' => ( !empty( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'Unknown' ),
164
  'dir' => W3TC_DIR,
165
  'cache_dir' => W3TC_CACHE_DIR,
166
  'blog_id' => Util_Environment::blog_id(),
13
  $post = array();
14
 
15
  foreach ( $_GET as $p => $v )
16
+ $post[$p] = Util_Request::get( $p );
17
 
18
+ $post['user_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '';
19
  $post['version'] = W3TC_VERSION;
20
 
21
  $license_level = 'community';
160
  $server_info = array(
161
  'w3tc' => array(
162
  'version' => W3TC_VERSION,
163
+ 'server' => ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : 'Unknown' ),
164
  'dir' => W3TC_DIR,
165
  'cache_dir' => W3TC_CACHE_DIR,
166
  'blog_id' => Util_Environment::blog_id(),
Support_Page.php CHANGED
@@ -17,8 +17,9 @@ class Support_Page {
17
  $w3tc_support_field_name = '';
18
  $w3tc_support_field_value = '';
19
 
20
- if ( isset( $_GET['service_item'] ) ) {
21
- $pos = (int) $_GET['service_item'];
 
22
 
23
  $v = get_site_option( 'w3tc_generic_widgetservices' );
24
  try {
@@ -59,13 +60,14 @@ class Support_Page {
59
  * @return void
60
  */
61
  function options() {
62
- if ( isset( $_GET['done'] ) ) {
63
  $postprocess_url =
64
  'admin.php?page=w3tc_support&w3tc_support_send_details' .
65
- '&_wpnonce=' . urlencode( $_GET['_wpnonce'] );
66
  foreach ( $_GET as $p => $v ) {
67
- if ( $p != 'page' && $p != '_wpnonce' && $p != 'done' )
68
- $postprocess_url .= '&' . urlencode( $p ) . '=' . urlencode( $v );
 
69
  }
70
 
71
  // terms accepted as a part of form
17
  $w3tc_support_field_name = '';
18
  $w3tc_support_field_value = '';
19
 
20
+ $service_item_val = Util_Request::get_integer( 'service_item' );
21
+ if ( ! empty( $service_item_val ) ) {
22
+ $pos = $service_item_val;
23
 
24
  $v = get_site_option( 'w3tc_generic_widgetservices' );
25
  try {
60
  * @return void
61
  */
62
  function options() {
63
+ if ( ! empty( Util_Request::get_string( 'done' ) ) ) {
64
  $postprocess_url =
65
  'admin.php?page=w3tc_support&w3tc_support_send_details' .
66
+ '&_wpnonce=' . rawurlencode( Util_Request::get_string( '_wpnonce' ) );
67
  foreach ( $_GET as $p => $v ) {
68
+ if ( 'page' !== $p && '_wpnonce' !== $p && 'done' !== $p ) {
69
+ $postprocess_url .= '&' . rawurlencode( $p ) . '=' . rawurlencode( Util_Request::get_string( $p ) );
70
+ }
71
  }
72
 
73
  // terms accepted as a part of form
SystemOpCache_GeneralPage_View.php CHANGED
@@ -1,52 +1,55 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
- <?php Util_Ui::postbox_header( __( 'Opcode Cache', 'w3-total-cache' ), '', 'system_opcache' ); ?>
9
 
10
  <table class="form-table">
11
- <?php
12
- Util_Ui::config_item( array(
13
- 'key' => 'opcache.engine',
14
- 'label' => 'Opcode Cache',
15
- 'control' => 'selectbox',
16
- 'value' => $opcode_engine,
17
- 'selectbox_values' => array(
18
- 'Not Available' => array(
19
- 'disabled' => ( $opcode_engine !== 'Not Available' ),
20
- 'label' => __( 'Not Available', 'w3-total-cache' ),
21
- ),
22
- 'OPcache' => array(
23
- 'disabled' => ( $opcode_engine !== 'OPcache' ),
24
- 'label' => __( 'Opcode: Zend Opcache', 'w3-total-cache' ),
25
- ),
26
- 'APC' => array(
27
- 'disabled' => ( $opcode_engine !== 'APC' ),
28
- 'label' => __( 'Opcode: Alternative PHP Cache (APC / APCu)', 'w3-total-cache' ),
 
 
29
  ),
30
- ),
31
- ) );
32
-
33
- Util_Ui::config_item( array(
34
- 'key' => 'opcache.validate_timestamps',
35
- 'label' => 'Validate timestamps:',
36
- 'control' => 'checkbox',
37
- 'disabled' => true,
38
- 'value' => $validate_timestamps,
39
- 'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
40
- 'description' => __( 'Once enabled, each file request will update the cache with the latest version. When this setting is off, the Opcode Cache will not check, instead PHP must be restarted in order for setting changes to be reflected.', 'w3-total-cache' )
41
- ) );
42
- ?>
43
-
44
  </table>
45
  <?php
46
- Util_Ui::button_config_save( 'general_opcache', '<input type="submit" name="w3tc_opcache_flush" value="' .
47
- __( 'Empty cache', 'w3-total-cache' ) . '"' .
48
- ( ( ( $opcode_engine !== 'Not Available' ) ) ? '' : ' disabled="disabled" ' ) .
49
- ' class="button" />' );
 
50
  ?>
51
 
52
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
+ <?php Util_Ui::postbox_header( esc_html__( 'Opcode Cache', 'w3-total-cache' ), '', 'system_opcache' ); ?>
9
 
10
  <table class="form-table">
11
+ <?php
12
+ Util_Ui::config_item(
13
+ array(
14
+ 'key' => 'opcache.engine',
15
+ 'label' => esc_html__( 'Opcode Cache', 'w3-total-cache' ),
16
+ 'control' => 'selectbox',
17
+ 'value' => $opcode_engine,
18
+ 'selectbox_values' => array(
19
+ 'Not Available' => array(
20
+ 'disabled' => ( 'Not Available' !== $opcode_engine ),
21
+ 'label' => esc_html__( 'Not Available', 'w3-total-cache' ),
22
+ ),
23
+ 'OPcache' => array(
24
+ 'disabled' => ( 'OPcache' !== $opcode_engine ),
25
+ 'label' => esc_html__( 'Opcode: Zend Opcache', 'w3-total-cache' ),
26
+ ),
27
+ 'APC' => array(
28
+ 'disabled' => ( 'APC' !== $opcode_engine ),
29
+ 'label' => esc_html__( 'Opcode: Alternative PHP Cache (APC / APCu)', 'w3-total-cache' ),
30
+ ),
31
  ),
32
+ )
33
+ );
34
+ Util_Ui::config_item(
35
+ array(
36
+ 'key' => 'opcache.validate_timestamps',
37
+ 'label' => 'Validate timestamps:',
38
+ 'control' => 'checkbox',
39
+ 'disabled' => true,
40
+ 'value' => $validate_timestamps,
41
+ 'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
42
+ 'description' => esc_html__( 'Once enabled, each file request will update the cache with the latest version. When this setting is off, the Opcode Cache will not check, instead PHP must be restarted in order for setting changes to be reflected.', 'w3-total-cache' )
43
+ )
44
+ );
45
+ ?>
46
  </table>
47
  <?php
48
+ Util_Ui::button_config_save(
49
+ 'general_opcache',
50
+ '<input type="submit" name="w3tc_opcache_flush" value="' . esc_attr__( 'Empty cache', 'w3-total-cache' ) . '"' .
51
+ ( ( 'Not Available' !== $opcode_engine ) ? '' : ' disabled="disabled" ' ) . ' class="button" />'
52
+ );
53
  ?>
54
 
55
  <?php Util_Ui::postbox_footer(); ?>
UsageStatistics_GeneralPage_View.php CHANGED
@@ -121,7 +121,7 @@ jQuery('#ustats_access_log_format_reset').click(function() {
121
 
122
  jQuery('#ustats_access_log_test').click(function() {
123
  var params = {
124
- action: 'w3tc_ajax',
125
  _wpnonce: w3tc_nonce,
126
  w3tc_action: 'ustats_access_log_test',
127
  filename: jQuery('#stats__access_log__filename').val()
121
 
122
  jQuery('#ustats_access_log_test').click(function() {
123
  var params = {
124
+ action: 'ustats_access_log_test',
125
  _wpnonce: w3tc_nonce,
126
  w3tc_action: 'ustats_access_log_test',
127
  filename: jQuery('#stats__access_log__filename').val()
UsageStatistics_Page.php CHANGED
@@ -31,12 +31,14 @@ class UsageStatistics_Page {
31
  return;
32
  }
33
 
34
- if ( isset( $_REQUEST['view'] ) && $_REQUEST['view'] == 'db_requests' ) {
 
35
  $storage = new UsageStatistics_StorageReader();
36
  $summary = $storage->get_history_summary();
37
  $timestamp_start = $summary['period']['timestamp_start'];
38
 
39
- $sort_column = isset( $_REQUEST['sort'] ) ? $_REQUEST['sort'] : '';
 
40
  if ( !in_array( $sort_column, array(
41
  'query', 'count_total', 'count_hit', 'avg_size',
42
  'avg_time_ms', 'sum_time_ms' ) ) ) {
@@ -61,12 +63,13 @@ class UsageStatistics_Page {
61
  );
62
 
63
  include W3TC_DIR . '/UsageStatistics_Page_DbRequests_View.php';
64
- } elseif ( isset( $_REQUEST['view'] ) && $_REQUEST['view'] == 'oc_requests' ) {
65
  $storage = new UsageStatistics_StorageReader();
66
  $summary = $storage->get_history_summary();
67
  $timestamp_start = $summary['period']['timestamp_start'];
68
 
69
- $sort_column = isset( $_REQUEST['sort'] ) ? $_REQUEST['sort'] : '';
 
70
  if ( !in_array( $sort_column, array(
71
  'group', 'count_total', 'count_get_total', 'count_get_hit',
72
  'count_set', 'avg_size', 'sum_size', 'sum_time_ms' ) ) ) {
@@ -91,12 +94,13 @@ class UsageStatistics_Page {
91
  );
92
 
93
  include W3TC_DIR . '/UsageStatistics_Page_ObjectCacheLog_View.php';
94
- } elseif ( isset( $_REQUEST['view'] ) && $_REQUEST['view'] == 'pagecache_requests' ) {
95
  $storage = new UsageStatistics_StorageReader();
96
  $summary = $storage->get_history_summary();
97
  $timestamp_start = $summary['period']['timestamp_start'];
98
 
99
- $sort_column = isset( $_REQUEST['sort'] ) ? $_REQUEST['sort'] : '';
 
100
  if ( !in_array( $sort_column, array(
101
  'uri', 'count', 'avg_size', 'avg_time_ms',
102
  'sum_time_ms' ) ) ) {
@@ -108,8 +112,11 @@ class UsageStatistics_Page {
108
  return;
109
  }
110
 
111
- $reader = new UsageStatistics_Source_PageCacheLog( $timestamp_start,
112
- $_REQUEST['status'], $sort_column );
 
 
 
113
  $items = $reader->list_entries();
114
 
115
  $result = array(
@@ -137,46 +144,36 @@ class UsageStatistics_Page {
137
 
138
 
139
  public function sort_link( $result, $name, $sort_column ) {
140
- $name_esc = esc_html( $name );
141
  if ( $result['sort_column'] == $sort_column ) {
142
- echo "<strong>$name_esc</strong>";
143
  return;
144
  }
145
 
146
  $new_query_string = $_GET;
147
- $new_query_string['sort'] = $sort_column;
148
-
149
- $url_esc = esc_url(
150
- 'admin.php?' . http_build_query( $new_query_string ) );
151
 
152
- echo "<a href='$url_esc'>$name_esc</a>";
153
  }
154
 
155
 
156
 
157
- public function summary_item( $id, $name, $checked = false,
158
- $extra_class = '', $column_background = '', $link_key = '' ) {
159
- echo "<div class='ustats_$id $extra_class'>\n";
160
  echo '<label>';
161
- echo '<input type="checkbox" name="';
162
- echo esc_attr( 'w3tcus_chart_check_' . $id ) . '" ';
163
- echo 'data-name="' . esc_attr( $name ) . '" ';
164
- echo 'data-column="' . esc_attr( $id ) . '" ';
165
 
166
- if ( !empty( $column_background ) ) {
167
  echo 'data-background="' . esc_attr( $column_background ) . '" ';
168
  }
169
 
170
  echo 'class="w3tc-ignore-change w3tcus_chart_check" ';
171
  checked( $checked );
172
  echo ' />';
173
- if ( !empty( $link_key ) ) {
174
- echo "<a href='" .
175
- esc_url( 'admin.php?page=w3tc_stats&view=pagecache_requests&status=' .
176
- urlencode( $link_key ) . '&status_name=' . urlencode( $name ) ) .
177
- "'>$name</a>";
178
  } else {
179
- echo $name;
180
  }
181
  echo ": <span></span>\n";
182
 
31
  return;
32
  }
33
 
34
+ $view_val = Util_Request::get_string( 'view' );
35
+ if ( ! empty( $view_val ) && 'db_requests' === $view_val ) {
36
  $storage = new UsageStatistics_StorageReader();
37
  $summary = $storage->get_history_summary();
38
  $timestamp_start = $summary['period']['timestamp_start'];
39
 
40
+ $sort_val = Util_Request::get_string( 'sort' );
41
+ $sort_column = ! empty( $sort_val ) ? $sort_val : '';
42
  if ( !in_array( $sort_column, array(
43
  'query', 'count_total', 'count_hit', 'avg_size',
44
  'avg_time_ms', 'sum_time_ms' ) ) ) {
63
  );
64
 
65
  include W3TC_DIR . '/UsageStatistics_Page_DbRequests_View.php';
66
+ } elseif ( ! empty( $view_val ) && 'oc_requests' === $view_val ) {
67
  $storage = new UsageStatistics_StorageReader();
68
  $summary = $storage->get_history_summary();
69
  $timestamp_start = $summary['period']['timestamp_start'];
70
 
71
+ $sort_val = Util_Request::get_string( 'sort' );
72
+ $sort_column = ! empty( $sort_val ) ? $sort_val : '';
73
  if ( !in_array( $sort_column, array(
74
  'group', 'count_total', 'count_get_total', 'count_get_hit',
75
  'count_set', 'avg_size', 'sum_size', 'sum_time_ms' ) ) ) {
94
  );
95
 
96
  include W3TC_DIR . '/UsageStatistics_Page_ObjectCacheLog_View.php';
97
+ } elseif ( ! empty( $view_val ) && 'pagecache_requests' === $view_val ) {
98
  $storage = new UsageStatistics_StorageReader();
99
  $summary = $storage->get_history_summary();
100
  $timestamp_start = $summary['period']['timestamp_start'];
101
 
102
+ $sort_val = Util_Request::get_string( 'sort' );
103
+ $sort_column = ! empty( $sort_val ) ? $sort_val : '';
104
  if ( !in_array( $sort_column, array(
105
  'uri', 'count', 'avg_size', 'avg_time_ms',
106
  'sum_time_ms' ) ) ) {
112
  return;
113
  }
114
 
115
+ $reader = new UsageStatistics_Source_PageCacheLog(
116
+ $timestamp_start,
117
+ Util_Request::get_string( 'status' ),
118
+ $sort_column
119
+ );
120
  $items = $reader->list_entries();
121
 
122
  $result = array(
144
 
145
 
146
  public function sort_link( $result, $name, $sort_column ) {
 
147
  if ( $result['sort_column'] == $sort_column ) {
148
+ echo '<strong>' . esc_html( $name ) . '</strong>';
149
  return;
150
  }
151
 
152
  $new_query_string = $_GET;
153
+ $new_query_string['sort'] = sanitize_text_field( $sort_column );
 
 
 
154
 
155
+ echo '<a href="' . esc_url( 'admin.php?' . http_build_query( $new_query_string ) ) . '">' . esc_html( $name ) . '</a>';
156
  }
157
 
158
 
159
 
160
+ public function summary_item( $id, $name, $checked = false, $extra_class = '', $column_background = '', $link_key = '' ) {
161
+ echo '<div class="ustats_' . esc_attr( $id ) . ' ' . esc_attr( $extra_class ) . '">\n';
 
162
  echo '<label>';
163
+ echo '<input type="checkbox" name="' . esc_attr( 'w3tcus_chart_check_' . $id ) . '" data-name="' .
164
+ esc_attr( $name ) . '" data-column="' . esc_attr( $id ) . '" ';
 
 
165
 
166
+ if ( ! empty( $column_background ) ) {
167
  echo 'data-background="' . esc_attr( $column_background ) . '" ';
168
  }
169
 
170
  echo 'class="w3tc-ignore-change w3tcus_chart_check" ';
171
  checked( $checked );
172
  echo ' />';
173
+ if ( ! empty( $link_key ) ) {
174
+ echo '<a href="' . esc_url( 'admin.php?page=w3tc_stats&view=pagecache_requests&status=' . rawurlencode( $link_key ) . '&status_name=' . rawurlencode( $name ) ) . '">$name</a>';
 
 
 
175
  } else {
176
+ echo esc_html( $name );
177
  }
178
  echo ": <span></span>\n";
179
 
UsageStatistics_Page_DbRequests_View.php CHANGED
@@ -1,42 +1,43 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <div class="metabox-holder">
10
- <?php Util_Ui::postbox_header( __( 'Usage Statistics', 'w3-total-cache' ) ); ?>
11
 
12
- <div style="float: right"><a href="admin.php?page=w3tc_stats">&lt; Back To Statistics</a></div>
13
- <h1>Database Queries</h1>
14
  <p>
15
- Period
16
- <?php echo $result['date_min'] ?>
17
  -
18
- <?php echo $result['date_max'] ?>
19
  </p>
20
 
21
  <table style="width: 100%">
22
  <tr>
23
- <td><?php $this->sort_link( $result, 'Query', 'query' ) ?></td>
24
- <td><?php $this->sort_link( $result, 'Count', 'count_total' ) ?></td>
25
- <td><?php $this->sort_link( $result, 'Cache Hits', 'count_hit' ) ?></td>
26
- <td><?php $this->sort_link( $result, 'Total processed time (ms)', 'sum_time_ms' ) ?></td>
27
- <td><?php $this->sort_link( $result, 'Avg Processed time (ms)', 'avg_time_ms' ) ?></td>
28
- <td><?php $this->sort_link( $result, 'Avg Size', 'avg_size' ) ?></td>
29
  </tr>
30
- <?php foreach ($result['items'] as $i): ?>
31
  <tr>
32
- <td title="Reject reasons: <?php echo esc_attr( implode( ',', $i['reasons'] ) ) ?>"><?php echo esc_html($i['query']) ?></td>
33
- <td><?php echo esc_html($i['count_total']) ?></td>
34
- <td><?php echo esc_html($i['count_hit']) ?></td>
35
- <td><?php echo esc_html($i['sum_time_ms']) ?></td>
36
- <td><?php echo esc_html($i['avg_time_ms']) ?></td>
37
- <td><?php echo $i['avg_size'] == 0 ? 'n/a' : esc_html($i['avg_size']) ?></td>
38
  </tr>
39
- <?php endforeach ?>
40
  </table>
41
 
42
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <div class="metabox-holder">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Usage Statistics', 'w3-total-cache' ) ); ?>
12
 
13
+ <div style="float: right"><a href="admin.php?page=w3tc_stats"><?php esc_html_e( '&lt; Back To Statistics', 'w3-total-cache' ); ?></a></div>
14
+ <h1><?php esc_html_e( 'Database Queries', 'w3-total-cache' ); ?></h1>
15
  <p>
16
+ <?php esc_html_e( 'Period', 'w3-total-cache' ); ?>
17
+ <?php echo esc_html( $result['date_min'] ); ?>
18
  -
19
+ <?php echo esc_html( $result['date_max'] ); ?>
20
  </p>
21
 
22
  <table style="width: 100%">
23
  <tr>
24
+ <td><?php $this->sort_link( $result, 'Query', 'query' ); ?></td>
25
+ <td><?php $this->sort_link( $result, 'Count', 'count_total' ); ?></td>
26
+ <td><?php $this->sort_link( $result, 'Cache Hits', 'count_hit' ); ?></td>
27
+ <td><?php $this->sort_link( $result, 'Total processed time (ms)', 'sum_time_ms' ); ?></td>
28
+ <td><?php $this->sort_link( $result, 'Avg Processed time (ms)', 'avg_time_ms' ); ?></td>
29
+ <td><?php $this->sort_link( $result, 'Avg Size', 'avg_size' ); ?></td>
30
  </tr>
31
+ <?php foreach ( $result['items'] as $i ) : ?>
32
  <tr>
33
+ <td title="<?php echo esc_attr__( 'Reject reasons: ', 'w3-total-cache' ) . esc_attr( implode( ',', $i['reasons'] ) ); ?>"><?php echo esc_html( $i['query'] ); ?></td>
34
+ <td><?php echo esc_html( $i['count_total'] ); ?></td>
35
+ <td><?php echo esc_html( $i['count_hit'] ); ?></td>
36
+ <td><?php echo esc_html( $i['sum_time_ms'] ); ?></td>
37
+ <td><?php echo esc_html( $i['avg_time_ms'] ); ?></td>
38
+ <td><?php echo esc_html( 0 === $i['avg_size'] ? 'n/a' : $i['avg_size'] ); ?></td>
39
  </tr>
40
+ <?php endforeach; ?>
41
  </table>
42
 
43
  <?php Util_Ui::postbox_footer(); ?>
UsageStatistics_Page_ObjectCacheLog_View.php CHANGED
@@ -1,44 +1,45 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <div class="metabox-holder">
10
- <?php Util_Ui::postbox_header( __( 'Usage Statistics', 'w3-total-cache' ) ); ?>
11
 
12
- <div style="float: right"><a href="admin.php?page=w3tc_stats">&lt; Back To Statistics</a></div>
13
- <h1>Object Cache Calls</h1>
14
  <p>
15
- Period
16
- <?php echo $result['date_min'] ?>
17
  -
18
- <?php echo $result['date_max'] ?>
19
  </p>
20
 
21
  <table style="width: 100%">
22
  <tr>
23
- <td><?php $this->sort_link( $result, 'Group', 'group' ) ?></td>
24
- <td><?php $this->sort_link( $result, 'Calls', 'count_total' ) ?></td>
25
- <td><?php $this->sort_link( $result, 'Get', 'count_get_total' ) ?></td>
26
- <td><?php $this->sort_link( $result, 'Cache Hits', 'count_get_hit' ) ?></td>
27
- <td><?php $this->sort_link( $result, 'Set', 'count_set' ) ?></td>
28
- <td><?php $this->sort_link( $result, 'Total processed time (ms)', 'sum_time_ms' ) ?></td>
29
- <td><?php $this->sort_link( $result, 'Total size transfeffed', 'sum_size' ) ?></td>
30
- <td><?php $this->sort_link( $result, 'Avg Size', 'avg_size' ) ?></td>
31
  </tr>
32
- <?php foreach ($result['items'] as $i): ?>
33
  <tr>
34
- <td><?php echo esc_html($i['group']) ?></td>
35
- <td><?php echo esc_html($i['count_total']) ?></td>
36
- <td><?php echo esc_html($i['count_get_total']) ?></td>
37
- <td><?php echo esc_html($i['count_get_hit']) ?></td>
38
- <td><?php echo esc_html($i['count_set']) ?></td>
39
- <td><?php echo esc_html($i['sum_time_ms']) ?></td>
40
- <td><?php echo $i['sum_size'] == 0 ? 'n/a' : esc_html($i['sum_size']) ?></td>
41
- <td><?php echo $i['avg_size'] == 0 ? 'n/a' : esc_html($i['avg_size']) ?></td>
42
  </tr>
43
  <?php endforeach ?>
44
  </table>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <div class="metabox-holder">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Usage Statistics', 'w3-total-cache' ) ); ?>
12
 
13
+ <div style="float: right"><a href="admin.php?page=w3tc_stats"><?php esc_html_e( '&lt; Back To Statistics', 'w3-total-cache' ); ?></a></div>
14
+ <h1><?php esc_html_e( 'Object Cache Calls', 'w3-total-cache' ); ?></h1>
15
  <p>
16
+ <?php esc_html_e( 'Period', 'w3-total-cache' ); ?>
17
+ <?php echo esc_html( $result['date_min'] ); ?>
18
  -
19
+ <?php echo esc_html( $result['date_max'] ); ?>
20
  </p>
21
 
22
  <table style="width: 100%">
23
  <tr>
24
+ <td><?php $this->sort_link( $result, 'Group', 'group' ); ?></td>
25
+ <td><?php $this->sort_link( $result, 'Calls', 'count_total' ); ?></td>
26
+ <td><?php $this->sort_link( $result, 'Get', 'count_get_total' ); ?></td>
27
+ <td><?php $this->sort_link( $result, 'Cache Hits', 'count_get_hit' ); ?></td>
28
+ <td><?php $this->sort_link( $result, 'Set', 'count_set' ); ?></td>
29
+ <td><?php $this->sort_link( $result, 'Total processed time (ms)', 'sum_time_ms' ); ?></td>
30
+ <td><?php $this->sort_link( $result, 'Total size transfeffed', 'sum_size' ); ?></td>
31
+ <td><?php $this->sort_link( $result, 'Avg Size', 'avg_size' ); ?></td>
32
  </tr>
33
+ <?php foreach ( $result['items'] as $i ) : ?>
34
  <tr>
35
+ <td><?php echo esc_html( $i['group'] ); ?></td>
36
+ <td><?php echo esc_html( $i['count_total'] ); ?></td>
37
+ <td><?php echo esc_html( $i['count_get_total'] ); ?></td>
38
+ <td><?php echo esc_html( $i['count_get_hit'] ); ?></td>
39
+ <td><?php echo esc_html( $i['count_set'] ); ?></td>
40
+ <td><?php echo esc_html( $i['sum_time_ms'] ); ?></td>
41
+ <td><?php echo 0 === $i['sum_size'] ? 'n/a' : esc_html( $i['sum_size'] ); ?></td>
42
+ <td><?php echo 0 === $i['avg_size'] ? 'n/a' : esc_html( $i['avg_size'] ); ?></td>
43
  </tr>
44
  <?php endforeach ?>
45
  </table>
UsageStatistics_Page_PageCacheRequests_View.php CHANGED
@@ -1,38 +1,39 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <div class="metabox-holder">
10
- <?php Util_Ui::postbox_header( __( 'Usage Statistics', 'w3-total-cache' ) ); ?>
11
 
12
- <div style="float: right"><a href="admin.php?page=w3tc_stats">&lt; Back To Statistics</a></div>
13
- <h1>Page Cache Reject Requests for <?php echo esc_html( $_REQUEST['status_name'] ) ?></h1>
14
  <p>
15
- Period
16
- <?php echo $result['date_min'] ?>
17
  -
18
- <?php echo $result['date_max'] ?>
19
  </p>
20
 
21
  <table style="width: 100%">
22
  <tr>
23
- <td><?php $this->sort_link( $result, 'URI', 'uri' ) ?></td>
24
- <td><?php $this->sort_link( $result, 'Count', 'count' ) ?></td>
25
- <td><?php $this->sort_link( $result, 'Total processed time (ms)', 'sum_time_ms' ) ?></td>
26
- <td><?php $this->sort_link( $result, 'Avg Processed time (ms)', 'avg_time_ms' ) ?></td>
27
- <td><?php $this->sort_link( $result, 'Avg Size', 'avg_size' ) ?></td>
28
  </tr>
29
- <?php foreach ($result['items'] as $i): ?>
30
  <tr>
31
- <td title="Reject reasons: <?php echo esc_attr( implode( ',', $i['reasons'] ) ) ?>"><?php echo esc_html($i['uri']) ?></td>
32
- <td><?php echo esc_html($i['count']) ?></td>
33
- <td><?php echo esc_html($i['sum_time_ms']) ?></td>
34
- <td><?php echo esc_html($i['avg_time_ms']) ?></td>
35
- <td><?php echo $i['avg_size'] == 0 ? 'n/a' : esc_html($i['avg_size']) ?></td>
36
  </tr>
37
  <?php endforeach ?>
38
  </table>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <div class="metabox-holder">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Usage Statistics', 'w3-total-cache' ) ); ?>
12
 
13
+ <div style="float: right"><a href="admin.php?page=w3tc_stats"><?php esc_html_e( '&lt; Back To Statistics', 'w3-total-cache' ); ?></a></div>
14
+ <h1><?php esc_html_e( 'Page Cache Reject Requests for ', 'w3-total-cache' ); ?><?php echo esc_html( isset( $_REQUEST['status_name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['status_name'] ) ) : '' ); ?></h1>
15
  <p>
16
+ <?php esc_html_e( 'Period', 'w3-total-cache' ); ?>
17
+ <?php echo esc_html( $result['date_min'] ); ?>
18
  -
19
+ <?php echo esc_html( $result['date_max'] ); ?>
20
  </p>
21
 
22
  <table style="width: 100%">
23
  <tr>
24
+ <td><?php $this->sort_link( $result, 'URI', 'uri' ); ?></td>
25
+ <td><?php $this->sort_link( $result, 'Count', 'count' ); ?></td>
26
+ <td><?php $this->sort_link( $result, 'Total processed time (ms)', 'sum_time_ms' ); ?></td>
27
+ <td><?php $this->sort_link( $result, 'Avg Processed time (ms)', 'avg_time_ms' ); ?></td>
28
+ <td><?php $this->sort_link( $result, 'Avg Size', 'avg_size' ); ?></td>
29
  </tr>
30
+ <?php foreach ( $result['items'] as $i ) : ?>
31
  <tr>
32
+ <td title="<?php echo esc_attr__( 'Reject reasons: ', 'w3-total-cache' ) . esc_attr( implode( ',', $i['reasons'] ) ); ?>"><?php echo esc_html( $i['uri'] ); ?></td>
33
+ <td><?php echo esc_html( $i['count'] ); ?></td>
34
+ <td><?php echo esc_html( $i['sum_time_ms'] ); ?></td>
35
+ <td><?php echo esc_html( $i['avg_time_ms'] ); ?></td>
36
+ <td><?php echo 0 === $i['avg_size'] ? 'n/a' : esc_html( $i['avg_size'] ); ?></td>
37
  </tr>
38
  <?php endforeach ?>
39
  </table>
UsageStatistics_Page_View.php CHANGED
@@ -1,17 +1,18 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
 
9
  ?>
10
- <div class="ustats_loading w3tc_loading">Loading...</div>
11
- <div class="ustats_error w3tc_none">An error occurred</div>
12
  <div class="ustats_nodata w3tc_none">
13
- <p>No data collected yet</p>
14
- <a href="#" class="ustats_reload">Refresh</a>
15
  </div>
16
 
17
  <div class="ustats_content w3tc_hidden">
@@ -19,58 +20,58 @@ include W3TC_INC_DIR . '/options/common/header.php';
19
  </div>
20
 
21
  <div class="metabox-holder" style="display: none">
22
- <?php Util_Ui::postbox_header( __( 'Web Requests', 'w3-total-cache' ) ); ?>
23
 
24
  <div class="ustats_block ustats_pagecache">
25
  <div class="ustats_block_data">
26
  <div class="ustats_header">
27
- Page Cache
28
  <span class="ustats_pagecache_engine_name w3tcus_inline">(<span></span>)</span>
29
  :
30
  </div>
31
  <div class="ustats_pagecache_size_used">
32
- Cache size: <span></span>
33
  </div>
34
  <div class="ustats_pagecache_items">
35
- Entries: <span></span>
36
  </div>
37
 
38
  <div class="ustats_pagecache_requests">
39
- Requests: <span></span>
40
  </div>
41
  <div class="ustats_pagecache_requests_per_second">
42
- Requests/sec: <span></span>
43
  </div>
44
  <div class="ustats_pagecache_requests_hit">
45
- Cache hits: <span></span>
46
  </div>
47
  <div class="ustats_pagecache_requests_hit_rate">
48
- Cache hit rate: <span></span>
49
  </div>
50
 
51
  <div class="ustats_pagecache_request_time_ms">
52
- Avg processing time: <span></span> ms
53
  </div>
54
  <div class="ustats_pagecache_size_percent">
55
- Size used: <span></span>
56
  </div>
57
  </div>
58
  <div class="ustats_block_chart">
59
- Request time
60
  <canvas id="w3tcus_pagecache_chart"></canvas>
61
  </div>
62
  </div>
63
 
64
  <div class="ustats_block ustats_php">
65
  <div class="ustats_block_data">
66
- <div class="ustats_header">PHP Requests:</div>
67
  <div class="ustats_php_php_requests_per_second">
68
- Requests/sec: <span></span>
69
  </div>
70
  <?php
71
  $this->summary_item(
72
  'php_php_requests',
73
- 'Requests/period',
74
  true,
75
  '',
76
  '#009900'
@@ -81,7 +82,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
81
  );
82
  $this->summary_item(
83
  'php_php_requests_pagecache_miss',
84
- 'Not cached',
85
  false,
86
  '',
87
  '#990000'
@@ -105,7 +106,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
105
  );
106
  $this->summary_item(
107
  'php_php_requests_pagecache_miss_api_call',
108
- 'API call',
109
  false,
110
  'ustats_php_php_requests_pagecache_miss_level2',
111
  '',
@@ -113,7 +114,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
113
  );
114
  $this->summary_item(
115
  'php_php_requests_pagecache_miss_configuration',
116
- 'W3TC Configuration',
117
  false,
118
  'ustats_php_php_requests_pagecache_miss_level2',
119
  '',
@@ -121,7 +122,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
121
  );
122
  $this->summary_item(
123
  'php_php_requests_pagecache_miss_fill',
124
- 'Cache Fill',
125
  false,
126
  'ustats_php_php_requests_pagecache_miss_level2',
127
  '',
@@ -129,7 +130,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
129
  );
130
  $this->summary_item(
131
  'php_php_requests_pagecache_miss_logged_in',
132
- 'Logged In',
133
  false,
134
  'ustats_php_php_requests_pagecache_miss_level2',
135
  '',
@@ -145,7 +146,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
145
  );
146
  $this->summary_item(
147
  'php_php_requests_pagecache_miss_query_string',
148
- 'Query String',
149
  false,
150
  'ustats_php_php_requests_pagecache_miss_level2',
151
  '',
@@ -153,7 +154,7 @@ include W3TC_INC_DIR . '/options/common/header.php';
153
  );
154
  $this->summary_item(
155
  'php_php_requests_pagecache_miss_third_party',
156
- 'Third Party',
157
  false,
158
  'ustats_php_php_requests_pagecache_miss_level2',
159
  '',
@@ -171,37 +172,37 @@ include W3TC_INC_DIR . '/options/common/header.php';
171
  ?>
172
  </div>
173
  <div class="ustats_block_chart">
174
- Requests handled by PHP
175
  <canvas id="w3tcus_php_requests_chart"></canvas>
176
  </div>
177
  </div>
178
 
179
  <div class="ustats_block ustats_access_log" style="height: 32vw">
180
  <div class="ustats_block_data">
181
- <div class="ustats_header">Access Log:</div>
182
  <div class="ustats_access_log_dynamic_requests_total">
183
- Dynamic Requests/period: <span></span>
184
  </div>
185
  <div class="ustats_access_log_dynamic_requests_per_second">
186
- Dynamic Requests/second: <span></span>
187
  </div>
188
  <div class="ustats_access_log_dynamic_requests_timing">
189
- Dynamic time to process (ms): <span></span>
190
  </div>
191
  <div class="ustats_access_log_static_requests_total">
192
- Static Requests/period: <span></span>
193
  </div>
194
  <div class="ustats_access_log_static_requests_per_second">
195
- Static Requests/second: <span></span>
196
  </div>
197
  <div class="ustats_access_log_static_requests_timing">
198
- Static time to process (ms): <span></span>
199
  </div>
200
  </div>
201
  <div class="ustats_block_chart">
202
- Requests
203
  <canvas id="w3tcus_access_log_chart_requests"></canvas>
204
- Time per request (ms)
205
  <canvas id="w3tcus_access_log_chart_timing"></canvas>
206
  </div>
207
  </div>
@@ -210,34 +211,34 @@ include W3TC_INC_DIR . '/options/common/header.php';
210
  </div>
211
 
212
  <div class="metabox-holder" style="display: none">
213
- <?php Util_Ui::postbox_header( __( 'Minify', 'w3-total-cache' ) ); ?>
214
 
215
  <div class="ustats_block ustats_minify">
216
  <div class="ustats_block_data">
217
- <div class="ustats_header">Minify:</div>
218
  <div class="ustats_minify_size_used">
219
- Used: <span></span>
220
  </div>
221
  <div class="ustats_minify_size_items">
222
- Files: <span></span>
223
  </div>
224
  <div class="ustats_minify_size_compression_css">
225
- CSS compression in cache: <span></span>
226
  </div>
227
  <div class="ustats_minify_size_compression_js">
228
- JS compression in cache: <span></span>
229
  </div>
230
  <div class="ustats_minify_requests_total">
231
- Requests/period: <span></span>
232
  </div>
233
  <div class="ustats_minify_requests_per_second">
234
- Requests/sec: <span></span>
235
  </div>
236
  <div class="ustats_minify_compression_css">
237
- Responded CSS compression: <span></span>
238
  </div>
239
  <div class="ustats_minify_compression_js">
240
- Responded JS compression: <span></span>
241
  </div>
242
  </div>
243
  </div>
@@ -246,58 +247,58 @@ include W3TC_INC_DIR . '/options/common/header.php';
246
  </div>
247
 
248
  <div class="metabox-holder" style="display: none">
249
- <?php Util_Ui::postbox_header( __( 'Object Cache', 'w3-total-cache' ) ); ?>
250
 
251
  <div class="ustats_block ustats_objectcache" style="height: 32vw">
252
  <div class="ustats_block_data">
253
  <div class="ustats_header">
254
- Object Cache
255
  <span class="ustats_objectcache_engine_name w3tcus_inline">(<span></span>)</span>
256
  </div>
257
  <div class="ustats_objectcache_get_total">
258
- Gets/period: <span></span>
259
  </div>
260
  <div class="ustats_objectcache_get_hits">
261
- Hits/period: <span></span>
262
  </div>
263
  <div class="ustats_objectcache_hit_rate">
264
- Hit rate: <span></span>
265
  </div>
266
  <div class="ustats_objectcache_sets">
267
- Sets/period: <span></span>
268
  </div>
269
  <div class="ustats_objectcache_flushes">
270
- Flushes/period: <span></span>
271
  </div>
272
  <div class="ustats_objectcache_time_ms">
273
- Time taken: <span></span> ms
274
  </div>
275
 
276
  <div class="ustats_objectcache_calls_per_second">
277
- Calls/sec: <span></span>
278
  </div>
279
 
280
- <a href="?page=w3tc_stats&view=oc_requests">Detailed view (in debug mode only)</a>
281
  </div>
282
  <div class="ustats_block_chart">
283
- Time taken for ObjectCache activity
284
  <canvas id="w3tcus_objectcache_time_chart"></canvas>
285
- Calls
286
  <canvas id="w3tcus_objectcache_chart"></canvas>
287
  </div>
288
  </div>
289
 
290
  <div class="ustats_block ustats_fragmentcache">
291
  <div class="ustats_block_data">
292
- <div class="ustats_header">Fragment Cache:</div>
293
  <div class="ustats_fragmentcache_calls_total">
294
- Calls/period: <span></span>
295
  </div>
296
  <div class="ustats_fragmentcache_calls_per_second">
297
- Calls/sec: <span></span>
298
  </div>
299
  <div class="ustats_fragmentcache_hit_rate">
300
- Hit rate: <span></span>
301
  </div>
302
  </div>
303
  </div>
@@ -312,48 +313,48 @@ include W3TC_INC_DIR . '/options/common/header.php';
312
  <div class="ustats_block ustats_dbcache" style="height: 32vw">
313
  <div class="ustats_block_data">
314
  <div class="ustats_header">
315
- Database Cache
316
  <span class="ustats_dbcache_engine_name w3tcus_inline">(<span></span>)</span>
317
  </div>
318
 
319
  <div class="ustats_dbcache_calls_total">
320
- Calls/period: <span></span>
321
  </div>
322
  <div class="ustats_dbcache_calls_per_second">
323
- Calls/sec: <span></span>
324
  </div>
325
  <div class="ustats_dbcache_hit_rate">
326
- Hit rate: <span></span>
327
  </div>
328
  <div class="ustats_dbcache_flushes">
329
- Cache flushes: <span></span>
330
  </div>
331
  <div class="ustats_dbcache_time_ms">
332
- Time taken: <span></span> ms
333
  </div>
334
 
335
- <a href="?page=w3tc_stats&view=db_requests">Slowest requests (in debug mode only)</a>
336
  </div>
337
  <div class="ustats_block_chart">
338
- Time taken for database activity
339
  <canvas id="w3tcus_dbcache_time_chart"></canvas>
340
- Requests
341
  <canvas id="w3tcus_dbcache_chart"></canvas>
342
  </div>
343
  </div>
344
 
345
  <div class="ustats_block ustats_wpdb">
346
  <div class="ustats_block_data">
347
- <div class="ustats_header">Database:</div>
348
  <div class="ustats_wpdb_calls_total">
349
- Calls/period: <span></span>
350
  </div>
351
  <div class="ustats_wpdb_calls_per_second">
352
- Calls/sec: <span></span>
353
  </div>
354
  </div>
355
  <div class="ustats_block_chart">
356
- Requests
357
  <canvas id="w3tcus_wpdb_chart"></canvas>
358
  </div>
359
  </div>
@@ -363,30 +364,30 @@ include W3TC_INC_DIR . '/options/common/header.php';
363
 
364
 
365
  <div class="metabox-holder" style="display: none">
366
- <?php Util_Ui::postbox_header( __( 'System Info', 'w3-total-cache' ) ); ?>
367
 
368
  <div class="ustats_block ustats_php">
369
  <div class="ustats_block_data">
370
- <div class="ustats_header">PHP Memory:</div>
371
  <div class="ustats_php_memory">
372
- Memory used: <span></span>
373
  </div>
374
  </div>
375
  <div class="ustats_block_chart">
376
- Memory per request (MB)
377
  <canvas id="w3tcus_php_memory_chart"></canvas>
378
  </div>
379
  </div>
380
 
381
  <div class="ustats_block ustats_cpu">
382
  <div class="ustats_block_data">
383
- <div class="ustats_header">CPU load:</div>
384
  <div class="ustats_cpu_avg">
385
- CPU load: <span></span>
386
  </div>
387
  </div>
388
  <div class="ustats_block_chart">
389
- CPU load
390
  <canvas id="w3tcus_cpu_chart"></canvas>
391
  </div>
392
  </div>
@@ -396,88 +397,91 @@ include W3TC_INC_DIR . '/options/common/header.php';
396
 
397
 
398
  <div class="metabox-holder" style="display: none">
399
- <?php Util_Ui::postbox_header( __( 'Cache Storage', 'w3-total-cache' ) ); ?>
400
 
401
  <div class="ustats_block ustats_memcached" style="height: 32vw">
402
  <div class="ustats_block_data">
403
- <div class="ustats_header">Memcached</div>
404
-
 
405
  <div class="ustats_memcached_used_by">
406
- Used by <span></span>
407
  </div>
408
  <div class="ustats_memcached_evictions_per_second">
409
- Evictions/sec: <span></span>
410
  </div>
411
  <div class="ustats_memcached_size_used">
412
- Used: <span></span>
413
  </div>
414
  <div class="ustats_memcached_size_percent">
415
- Used (%): <span></span>
416
  </div>
417
  <div class="ustats_memcached_get_hit_rate">
418
- Hit rate: <span></span>
419
  </div>
420
  </div>
421
  <div class="ustats_block_chart">
422
- Size used (MB)
423
  <canvas id="w3tcus_memcached_size_chart"></canvas>
424
- Hit rate
425
  <canvas id="w3tcus_memcached_hit_chart"></canvas>
426
  </div>
427
  </div>
428
 
429
  <div class="ustats_block ustats_redis" style="height: 32vw">
430
  <div class="ustats_block_data">
431
- <div class="ustats_header">Redis</div>
432
-
 
433
  <div class="ustats_redis_used_by">
434
- Used by <span></span>
435
  </div>
436
  <div class="ustats_redis_evictions_per_second">
437
- Evictions/sec: <span></span>
438
  </div>
439
  <div class="ustats_redis_size_used">
440
- Used: <span></span>
441
  </div>
442
  <div class="ustats_redis_get_hit_rate">
443
- Hit rate: <span></span>
444
  </div>
445
  </div>
446
  <div class="ustats_block_chart">
447
- Size used (MB)
448
  <canvas id="w3tcus_redis_size_chart"></canvas>
449
- Hit rate
450
  <canvas id="w3tcus_redis_hit_chart"></canvas>
451
  </div>
452
  </div>
453
 
454
  <div class="ustats_block ustats_apc" style="height: 32vw">
455
  <div class="ustats_block_data">
456
- <div class="ustats_header">APC</div>
457
-
 
458
  <div class="ustats_apc_used_by">
459
- Used by <span></span>
460
  </div>
461
  <div class="ustats_apc_evictions">
462
- Evictions: <span></span>
463
  </div>
464
  <div class="ustats_apc_size_used">
465
- Used: <span></span>
466
  </div>
467
  <div class="ustats_apc_size_percent">
468
- Used (%): <span></span>
469
  </div>
470
  <div class="ustats_apc_get_hit_rate">
471
- Hit rate: <span></span>
472
  </div>
473
  <div class="ustats_apc_items">
474
- Items: <span></span>
475
  </div>
476
  </div>
477
  <div class="ustats_block_chart">
478
- Size used (MB)
479
  <canvas id="w3tcus_apc_size_chart"></canvas>
480
- Hit rate
481
  <canvas id="w3tcus_apc_hit_chart"></canvas>
482
  </div>
483
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
 
10
  ?>
11
+ <div class="ustats_loading w3tc_loading"><?php esc_html_e( 'Loading...', 'w3-total-cache' ); ?></div>
12
+ <div class="ustats_error w3tc_none"><?php esc_html_e( 'An error occurred', 'w3-total-cache' ); ?></div>
13
  <div class="ustats_nodata w3tc_none">
14
+ <p><?php esc_html_e( 'No data collected yet', 'w3-total-cache' ); ?></p>
15
+ <a href="#" class="ustats_reload"><?php esc_html_e( 'Refresh', 'w3-total-cache' ); ?></a>
16
  </div>
17
 
18
  <div class="ustats_content w3tc_hidden">
20
  </div>
21
 
22
  <div class="metabox-holder" style="display: none">
23
+ <?php Util_Ui::postbox_header( esc_html__( 'Web Requests', 'w3-total-cache' ) ); ?>
24
 
25
  <div class="ustats_block ustats_pagecache">
26
  <div class="ustats_block_data">
27
  <div class="ustats_header">
28
+ <?php esc_html_e( 'Page Cache', 'w3-total-cache' ); ?>
29
  <span class="ustats_pagecache_engine_name w3tcus_inline">(<span></span>)</span>
30
  :
31
  </div>
32
  <div class="ustats_pagecache_size_used">
33
+ <?php esc_html_e( 'Cache size: ', 'w3-total-cache' ); ?><span></span>
34
  </div>
35
  <div class="ustats_pagecache_items">
36
+ <?php esc_html_e( 'Entries: ', 'w3-total-cache' ); ?><span></span>
37
  </div>
38
 
39
  <div class="ustats_pagecache_requests">
40
+ <?php esc_html_e( 'Requests: ', 'w3-total-cache' ); ?><span></span>
41
  </div>
42
  <div class="ustats_pagecache_requests_per_second">
43
+ <?php esc_html_e( 'Requests/sec: ', 'w3-total-cache' ); ?><span></span>
44
  </div>
45
  <div class="ustats_pagecache_requests_hit">
46
+ <?php esc_html_e( 'Cache hits: ', 'w3-total-cache' ); ?><span></span>
47
  </div>
48
  <div class="ustats_pagecache_requests_hit_rate">
49
+ <?php esc_html_e( 'Cache hit rate: ', 'w3-total-cache' ); ?><span></span>
50
  </div>
51
 
52
  <div class="ustats_pagecache_request_time_ms">
53
+ <?php esc_html_e( 'Avg processing time: ', 'w3-total-cache' ); ?><span></span><?php esc_html_e( ' ms', 'w3-total-cache' ); ?>
54
  </div>
55
  <div class="ustats_pagecache_size_percent">
56
+ <?php esc_html_e( 'Size used: ', 'w3-total-cache' ); ?><span></span>
57
  </div>
58
  </div>
59
  <div class="ustats_block_chart">
60
+ <?php esc_html_e( 'Request time', 'w3-total-cache' ); ?>
61
  <canvas id="w3tcus_pagecache_chart"></canvas>
62
  </div>
63
  </div>
64
 
65
  <div class="ustats_block ustats_php">
66
  <div class="ustats_block_data">
67
+ <div class="ustats_header"><?php esc_html_e( 'PHP Requests:', 'w3-total-cache' ); ?></div>
68
  <div class="ustats_php_php_requests_per_second">
69
+ <?php esc_html_e( 'Requests/sec: ', 'w3-total-cache' ); ?><span></span>
70
  </div>
71
  <?php
72
  $this->summary_item(
73
  'php_php_requests',
74
+ esc_html__( 'Requests/period', 'w3-total-cache' ),
75
  true,
76
  '',
77
  '#009900'
82
  );
83
  $this->summary_item(
84
  'php_php_requests_pagecache_miss',
85
+ esc_html__( 'Not cached', 'w3-total-cache' ),
86
  false,
87
  '',
88
  '#990000'
106
  );
107
  $this->summary_item(
108
  'php_php_requests_pagecache_miss_api_call',
109
+ esc_html__( 'API call', 'w3-total-cache' ),
110
  false,
111
  'ustats_php_php_requests_pagecache_miss_level2',
112
  '',
114
  );
115
  $this->summary_item(
116
  'php_php_requests_pagecache_miss_configuration',
117
+ esc_html__( 'W3TC Configuration', 'w3-total-cache' ),
118
  false,
119
  'ustats_php_php_requests_pagecache_miss_level2',
120
  '',
122
  );
123
  $this->summary_item(
124
  'php_php_requests_pagecache_miss_fill',
125
+ esc_html__( 'Cache Fill', 'w3-total-cache' ),
126
  false,
127
  'ustats_php_php_requests_pagecache_miss_level2',
128
  '',
130
  );
131
  $this->summary_item(
132
  'php_php_requests_pagecache_miss_logged_in',
133
+ esc_html__( 'Logged In', 'w3-total-cache' ),
134
  false,
135
  'ustats_php_php_requests_pagecache_miss_level2',
136
  '',
146
  );
147
  $this->summary_item(
148
  'php_php_requests_pagecache_miss_query_string',
149
+ esc_html__( 'Query String', 'w3-total-cache' ),
150
  false,
151
  'ustats_php_php_requests_pagecache_miss_level2',
152
  '',
154
  );
155
  $this->summary_item(
156
  'php_php_requests_pagecache_miss_third_party',
157
+ esc_html__( 'Third Party', 'w3-total-cache' ),
158
  false,
159
  'ustats_php_php_requests_pagecache_miss_level2',
160
  '',
172
  ?>
173
  </div>
174
  <div class="ustats_block_chart">
175
+ <?php esc_html_e( 'Requests handled by PHP', 'w3-total-cache' ); ?>
176
  <canvas id="w3tcus_php_requests_chart"></canvas>
177
  </div>
178
  </div>
179
 
180
  <div class="ustats_block ustats_access_log" style="height: 32vw">
181
  <div class="ustats_block_data">
182
+ <div class="ustats_header"><?php esc_html_e( 'Access Log:', 'w3-total-cache' ); ?></div>
183
  <div class="ustats_access_log_dynamic_requests_total">
184
+ <?php esc_html_e( 'Dynamic Requests/period: ', 'w3-total-cache' ); ?><span></span>
185
  </div>
186
  <div class="ustats_access_log_dynamic_requests_per_second">
187
+ <?php esc_html_e( 'Dynamic Requests/second: ', 'w3-total-cache' ); ?><span></span>
188
  </div>
189
  <div class="ustats_access_log_dynamic_requests_timing">
190
+ <?php esc_html_e( 'Dynamic time to process (ms): ', 'w3-total-cache' ); ?><span></span>
191
  </div>
192
  <div class="ustats_access_log_static_requests_total">
193
+ <?php esc_html_e( 'Static Requests/period: ', 'w3-total-cache' ); ?><span></span>
194
  </div>
195
  <div class="ustats_access_log_static_requests_per_second">
196
+ <?php esc_html_e( 'Static Requests/second: ', 'w3-total-cache' ); ?><span></span>
197
  </div>
198
  <div class="ustats_access_log_static_requests_timing">
199
+ <?php esc_html_e( 'Static time to process (ms): ', 'w3-total-cache' ); ?><span></span>
200
  </div>
201
  </div>
202
  <div class="ustats_block_chart">
203
+ <?php esc_html_e( 'Requests', 'w3-total-cache' ); ?>
204
  <canvas id="w3tcus_access_log_chart_requests"></canvas>
205
+ <?php esc_html_e( 'Time per request (ms)', 'w3-total-cache' ); ?>
206
  <canvas id="w3tcus_access_log_chart_timing"></canvas>
207
  </div>
208
  </div>
211
  </div>
212
 
213
  <div class="metabox-holder" style="display: none">
214
+ <?php Util_Ui::postbox_header( esc_html__( 'Minify', 'w3-total-cache' ) ); ?>
215
 
216
  <div class="ustats_block ustats_minify">
217
  <div class="ustats_block_data">
218
+ <div class="ustats_header"><?php esc_html_e( 'Minify:', 'w3-total-cache' ); ?></div>
219
  <div class="ustats_minify_size_used">
220
+ <?php esc_html_e( 'Used: ', 'w3-total-cache' ); ?><span></span>
221
  </div>
222
  <div class="ustats_minify_size_items">
223
+ <?php esc_html_e( 'Files: ', 'w3-total-cache' ); ?><span></span>
224
  </div>
225
  <div class="ustats_minify_size_compression_css">
226
+ <?php esc_html_e( 'CSS compression in cache: ', 'w3-total-cache' ); ?><span></span>
227
  </div>
228
  <div class="ustats_minify_size_compression_js">
229
+ <?php esc_html_e( 'JS compression in cache: ', 'w3-total-cache' ); ?><span></span>
230
  </div>
231
  <div class="ustats_minify_requests_total">
232
+ <?php esc_html_e( 'Requests/period: ', 'w3-total-cache' ); ?><span></span>
233
  </div>
234
  <div class="ustats_minify_requests_per_second">
235
+ <?php esc_html_e( 'Requests/sec: ', 'w3-total-cache' ); ?><span></span>
236
  </div>
237
  <div class="ustats_minify_compression_css">
238
+ <?php esc_html_e( 'Responded CSS compression: ', 'w3-total-cache' ); ?><span></span>
239
  </div>
240
  <div class="ustats_minify_compression_js">
241
+ <?php esc_html_e( 'Responded JS compression: ', 'w3-total-cache' ); ?><span></span>
242
  </div>
243
  </div>
244
  </div>
247
  </div>
248
 
249
  <div class="metabox-holder" style="display: none">
250
+ <?php Util_Ui::postbox_header( esc_html__( 'Object Cache', 'w3-total-cache' ) ); ?>
251
 
252
  <div class="ustats_block ustats_objectcache" style="height: 32vw">
253
  <div class="ustats_block_data">
254
  <div class="ustats_header">
255
+ <?php esc_html_e( 'Object Cache', 'w3-total-cache' ); ?>
256
  <span class="ustats_objectcache_engine_name w3tcus_inline">(<span></span>)</span>
257
  </div>
258
  <div class="ustats_objectcache_get_total">
259
+ <?php esc_html_e( 'Gets/period: ', 'w3-total-cache' ); ?><span></span>
260
  </div>
261
  <div class="ustats_objectcache_get_hits">
262
+ <?php esc_html_e( 'Hits/period: ', 'w3-total-cache' ); ?><span></span>
263
  </div>
264
  <div class="ustats_objectcache_hit_rate">
265
+ <?php esc_html_e( 'Hit rate: ', 'w3-total-cache' ); ?><span></span>
266
  </div>
267
  <div class="ustats_objectcache_sets">
268
+ <?php esc_html_e( 'Sets/period: ', 'w3-total-cache' ); ?><span></span>
269
  </div>
270
  <div class="ustats_objectcache_flushes">
271
+ <?php esc_html_e( 'Flushes/period: ', 'w3-total-cache' ); ?><span></span>
272
  </div>
273
  <div class="ustats_objectcache_time_ms">
274
+ <?php esc_html_e( 'Time taken: ', 'w3-total-cache' ); ?><span></span><?php esc_html_e( ' ms', 'w3-total-cache' ); ?>
275
  </div>
276
 
277
  <div class="ustats_objectcache_calls_per_second">
278
+ <?php esc_html_e( 'Calls/sec: ', 'w3-total-cache' ); ?><span></span>
279
  </div>
280
 
281
+ <a href="?page=w3tc_stats&view=oc_requests"><?php esc_html_e( 'Detailed view (in debug mode only)', 'w3-total-cache' ); ?></a>
282
  </div>
283
  <div class="ustats_block_chart">
284
+ <?php esc_html_e( 'Time taken for ObjectCache activity', 'w3-total-cache' ); ?>
285
  <canvas id="w3tcus_objectcache_time_chart"></canvas>
286
+ <?php esc_html_e( 'Calls', 'w3-total-cache' ); ?>
287
  <canvas id="w3tcus_objectcache_chart"></canvas>
288
  </div>
289
  </div>
290
 
291
  <div class="ustats_block ustats_fragmentcache">
292
  <div class="ustats_block_data">
293
+ <div class="ustats_header"><?php esc_html_e( 'Fragment Cache:', 'w3-total-cache' ); ?></div>
294
  <div class="ustats_fragmentcache_calls_total">
295
+ <?php esc_html_e( 'Calls/period: ', 'w3-total-cache' ); ?><span></span>
296
  </div>
297
  <div class="ustats_fragmentcache_calls_per_second">
298
+ <?php esc_html_e( 'Calls/sec: ', 'w3-total-cache' ); ?><span></span>
299
  </div>
300
  <div class="ustats_fragmentcache_hit_rate">
301
+ <?php esc_html_e( 'Hit rate: ', 'w3-total-cache' ); ?><span></span>
302
  </div>
303
  </div>
304
  </div>
313
  <div class="ustats_block ustats_dbcache" style="height: 32vw">
314
  <div class="ustats_block_data">
315
  <div class="ustats_header">
316
+ <?php esc_html_e( 'Database Cache', 'w3-total-cache' ); ?>
317
  <span class="ustats_dbcache_engine_name w3tcus_inline">(<span></span>)</span>
318
  </div>
319
 
320
  <div class="ustats_dbcache_calls_total">
321
+ <?php esc_html_e( 'Calls/period: ', 'w3-total-cache' ); ?><span></span>
322
  </div>
323
  <div class="ustats_dbcache_calls_per_second">
324
+ <?php esc_html_e( 'Calls/sec: ', 'w3-total-cache' ); ?><span></span>
325
  </div>
326
  <div class="ustats_dbcache_hit_rate">
327
+ <?php esc_html_e( 'Hit rate: ', 'w3-total-cache' ); ?><span></span>
328
  </div>
329
  <div class="ustats_dbcache_flushes">
330
+ <?php esc_html_e( 'Cache flushes: ', 'w3-total-cache' ); ?><span></span>
331
  </div>
332
  <div class="ustats_dbcache_time_ms">
333
+ <?php esc_html_e( 'Time taken: ', 'w3-total-cache' ); ?><span></span><?php esc_html_e( ' ms', 'w3-total-cache' ); ?>
334
  </div>
335
 
336
+ <a href="?page=w3tc_stats&view=db_requests"><?php esc_html_e( 'Slowest requests (in debug mode only)', 'w3-total-cache' ); ?></a>
337
  </div>
338
  <div class="ustats_block_chart">
339
+ <?php esc_html_e( 'Time taken for database activity', 'w3-total-cache' ); ?>
340
  <canvas id="w3tcus_dbcache_time_chart"></canvas>
341
+ <?php esc_html_e( 'Requests', 'w3-total-cache' ); ?>
342
  <canvas id="w3tcus_dbcache_chart"></canvas>
343
  </div>
344
  </div>
345
 
346
  <div class="ustats_block ustats_wpdb">
347
  <div class="ustats_block_data">
348
+ <div class="ustats_header"><?php esc_html_e( 'Database:', 'w3-total-cache' ); ?></div>
349
  <div class="ustats_wpdb_calls_total">
350
+ <?php esc_html_e( 'Calls/period: ', 'w3-total-cache' ); ?><span></span>
351
  </div>
352
  <div class="ustats_wpdb_calls_per_second">
353
+ <?php esc_html_e( 'Calls/sec: ', 'w3-total-cache' ); ?><span></span>
354
  </div>
355
  </div>
356
  <div class="ustats_block_chart">
357
+ <?php esc_html_e( 'Requests', 'w3-total-cache' ); ?>
358
  <canvas id="w3tcus_wpdb_chart"></canvas>
359
  </div>
360
  </div>
364
 
365
 
366
  <div class="metabox-holder" style="display: none">
367
+ <?php Util_Ui::postbox_header( esc_html__( 'System Info', 'w3-total-cache' ) ); ?>
368
 
369
  <div class="ustats_block ustats_php">
370
  <div class="ustats_block_data">
371
+ <div class="ustats_header"><?php esc_html_e( 'PHP Memory:', 'w3-total-cache' ); ?></div>
372
  <div class="ustats_php_memory">
373
+ <?php esc_html_e( 'Memory used: ', 'w3-total-cache' ); ?><span></span>
374
  </div>
375
  </div>
376
  <div class="ustats_block_chart">
377
+ <?php esc_html_e( 'Memory per request (MB)', 'w3-total-cache' ); ?>
378
  <canvas id="w3tcus_php_memory_chart"></canvas>
379
  </div>
380
  </div>
381
 
382
  <div class="ustats_block ustats_cpu">
383
  <div class="ustats_block_data">
384
+ <div class="ustats_header"><?php esc_html_e( 'CPU load:', 'w3-total-cache' ); ?></div>
385
  <div class="ustats_cpu_avg">
386
+ <?php esc_html_e( 'CPU load: ', 'w3-total-cache' ); ?><span></span>
387
  </div>
388
  </div>
389
  <div class="ustats_block_chart">
390
+ <?php esc_html_e( 'CPU load', 'w3-total-cache' ); ?>
391
  <canvas id="w3tcus_cpu_chart"></canvas>
392
  </div>
393
  </div>
397
 
398
 
399
  <div class="metabox-holder" style="display: none">
400
+ <?php Util_Ui::postbox_header( esc_html__( 'Cache Storage', 'w3-total-cache' ) ); ?>
401
 
402
  <div class="ustats_block ustats_memcached" style="height: 32vw">
403
  <div class="ustats_block_data">
404
+ <div class="ustats_header">
405
+ <?php esc_html_e( 'Memcached', 'w3-total-cache' ); ?>
406
+ </div>
407
  <div class="ustats_memcached_used_by">
408
+ <?php esc_html_e( 'Used by ', 'w3-total-cache' ); ?><span></span>
409
  </div>
410
  <div class="ustats_memcached_evictions_per_second">
411
+ <?php esc_html_e( 'Evictions/sec: ', 'w3-total-cache' ); ?><span></span>
412
  </div>
413
  <div class="ustats_memcached_size_used">
414
+ <?php esc_html_e( 'Used: ', 'w3-total-cache' ); ?><span></span>
415
  </div>
416
  <div class="ustats_memcached_size_percent">
417
+ <?php esc_html_e( 'Used (%): ', 'w3-total-cache' ); ?><span></span>
418
  </div>
419
  <div class="ustats_memcached_get_hit_rate">
420
+ <?php esc_html_e( 'Hit rate: ', 'w3-total-cache' ); ?><span></span>
421
  </div>
422
  </div>
423
  <div class="ustats_block_chart">
424
+ <?php esc_html_e( 'Size used (MB)', 'w3-total-cache' ); ?>
425
  <canvas id="w3tcus_memcached_size_chart"></canvas>
426
+ <?php esc_html_e( 'Hit rate', 'w3-total-cache' ); ?>
427
  <canvas id="w3tcus_memcached_hit_chart"></canvas>
428
  </div>
429
  </div>
430
 
431
  <div class="ustats_block ustats_redis" style="height: 32vw">
432
  <div class="ustats_block_data">
433
+ <div class="ustats_header">
434
+ <?php esc_html_e( 'Redis', 'w3-total-cache' ); ?>
435
+ </div>
436
  <div class="ustats_redis_used_by">
437
+ <?php esc_html_e( 'Used by ', 'w3-total-cache' ); ?><span></span>
438
  </div>
439
  <div class="ustats_redis_evictions_per_second">
440
+ <?php esc_html_e( 'Evictions/sec: ', 'w3-total-cache' ); ?><span></span>
441
  </div>
442
  <div class="ustats_redis_size_used">
443
+ <?php esc_html_e( 'Used: ', 'w3-total-cache' ); ?><span></span>
444
  </div>
445
  <div class="ustats_redis_get_hit_rate">
446
+ <?php esc_html_e( 'Hit rate: ', 'w3-total-cache' ); ?><span></span>
447
  </div>
448
  </div>
449
  <div class="ustats_block_chart">
450
+ <?php esc_html_e( 'Size used (MB)', 'w3-total-cache' ); ?>
451
  <canvas id="w3tcus_redis_size_chart"></canvas>
452
+ <?php esc_html_e( 'Hit rate', 'w3-total-cache' ); ?>
453
  <canvas id="w3tcus_redis_hit_chart"></canvas>
454
  </div>
455
  </div>
456
 
457
  <div class="ustats_block ustats_apc" style="height: 32vw">
458
  <div class="ustats_block_data">
459
+ <div class="ustats_header">
460
+ <?php esc_html_e( 'APC', 'w3-total-cache' ); ?>
461
+ </div>
462
  <div class="ustats_apc_used_by">
463
+ <?php esc_html_e( 'Used by ', 'w3-total-cache' ); ?><span></span>
464
  </div>
465
  <div class="ustats_apc_evictions">
466
+ <?php esc_html_e( 'Evictions: ', 'w3-total-cache' ); ?><span></span>
467
  </div>
468
  <div class="ustats_apc_size_used">
469
+ <?php esc_html_e( 'Used: ', 'w3-total-cache' ); ?><span></span>
470
  </div>
471
  <div class="ustats_apc_size_percent">
472
+ <?php esc_html_e( 'Used (%): ', 'w3-total-cache' ); ?><span></span>
473
  </div>
474
  <div class="ustats_apc_get_hit_rate">
475
+ <?php esc_html_e( 'Hit rate: ', 'w3-total-cache' ); ?><span></span>
476
  </div>
477
  <div class="ustats_apc_items">
478
+ <?php esc_html_e( 'Items: ', 'w3-total-cache' ); ?><span></span>
479
  </div>
480
  </div>
481
  <div class="ustats_block_chart">
482
+ <?php esc_html_e( 'Size used (MB)', 'w3-total-cache' ); ?>
483
  <canvas id="w3tcus_apc_size_chart"></canvas>
484
+ <?php esc_html_e( 'Hit rate', 'w3-total-cache' ); ?>
485
  <canvas id="w3tcus_apc_hit_chart"></canvas>
486
  </div>
487
  </div>
UsageStatistics_Page_View_Ad.php CHANGED
@@ -1,11 +1,9 @@
1
  <p>
2
- <?php _e( 'Users who upgrade to W3 Total Cache Pro will have access to the new
3
- Statistics page, which provides an in-depth view of the performance of your
4
- site.', 'w3-total-cache' ); ?>
5
  </p>
6
 
7
  <ul style="margin-left: 50px; margin-bottom: 20px">
8
- <li><?php _e( 'View detailed information about your site’s performance', 'w3-total-cache' ); ?></li>
9
- <li><?php _e( 'Visualize your performance over time with graphs', 'w3-total-cache' ); ?></li>
10
- <li><?php _e( 'Examine the overall performance of caching method backends', 'w3-total-cache' ); ?></li>
11
  </ul>
1
  <p>
2
+ <?php esc_html_e( 'Users who upgrade to W3 Total Cache Pro will have access to the new Statistics page, which provides an in-depth view of the performance of your site.', 'w3-total-cache' ); ?>
 
 
3
  </p>
4
 
5
  <ul style="margin-left: 50px; margin-bottom: 20px">
6
+ <li><?php esc_html_e( 'View detailed information about your site’s performance', 'w3-total-cache' ); ?></li>
7
+ <li><?php esc_html_e( 'Visualize your performance over time with graphs', 'w3-total-cache' ); ?></li>
8
+ <li><?php esc_html_e( 'Examine the overall performance of caching method backends', 'w3-total-cache' ); ?></li>
9
  </ul>
UsageStatistics_Page_View_Disabled.php CHANGED
@@ -1,19 +1,20 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <div class="metabox-holder ustats_ad_metabox">
10
- <?php Util_Ui::postbox_header( __( 'Usage Statistics', 'w3-total-cache' ) ); ?>
11
 
12
  <div class="ustats_ad">
13
- <?php include __DIR__ . '/UsageStatistics_Page_View_Ad.php' ?>
14
 
15
  <a class="button-primary"
16
- href="admin.php?page=w3tc_general#stats">Enable here</a>
17
  </div>
18
 
19
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <div class="metabox-holder ustats_ad_metabox">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Usage Statistics', 'w3-total-cache' ) ); ?>
12
 
13
  <div class="ustats_ad">
14
+ <?php require __DIR__ . '/UsageStatistics_Page_View_Ad.php' ?>
15
 
16
  <a class="button-primary"
17
+ href="admin.php?page=w3tc_general#stats"><?php esc_html_e( 'Enable here', 'w3-total-cache' ); ?></a>
18
  </div>
19
 
20
  <?php Util_Ui::postbox_footer(); ?>
UsageStatistics_Page_View_Free.php CHANGED
@@ -1,20 +1,21 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <div class="metabox-holder ustats_ad_metabox">
10
- <?php Util_Ui::postbox_header( __( 'Usage Statistics', 'w3-total-cache' ) ); ?>
11
 
12
  <div class="ustats_ad">
13
- <?php include __DIR__ . '/UsageStatistics_Page_View_Ad.php' ?>
14
 
15
  <input type="button" class="button-primary button-buy-plugin"
16
  data-src="page_stats_bottom"
17
- value="<?php _e( 'upgrade', 'w3-total-cache' ) ?>" />
18
  </div>
19
 
20
  <?php Util_Ui::postbox_footer(); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <div class="metabox-holder ustats_ad_metabox">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Usage Statistics', 'w3-total-cache' ) ); ?>
12
 
13
  <div class="ustats_ad">
14
+ <?php require __DIR__ . '/UsageStatistics_Page_View_Ad.php'; ?>
15
 
16
  <input type="button" class="button-primary button-buy-plugin"
17
  data-src="page_stats_bottom"
18
+ value="<?php esc_attr_e( 'upgrade', 'w3-total-cache' ); ?>" />
19
  </div>
20
 
21
  <?php Util_Ui::postbox_footer(); ?>
UsageStatistics_Page_View_NoDebugMode.php CHANGED
@@ -1,19 +1,20 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- include W3TC_INC_DIR . '/options/common/header.php';
8
  ?>
9
  <div class="metabox-holder">
10
- <?php Util_Ui::postbox_header( __( 'Usage Statistics', 'w3-total-cache' ) ); ?>
11
 
12
  <p>
13
- Usage Statistics is collected only when Debug Mode is enabled.
14
  </p>
15
 
16
- <a href="admin.php?page=w3tc_general#debug" class="button-primary">Enable it here</a>
17
 
18
  <?php Util_Ui::postbox_footer(); ?>
19
  </div>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ require W3TC_INC_DIR . '/options/common/header.php';
9
  ?>
10
  <div class="metabox-holder">
11
+ <?php Util_Ui::postbox_header( esc_html__( 'Usage Statistics', 'w3-total-cache' ) ); ?>
12
 
13
  <p>
14
+ <?php esc_html_e( 'Usage Statistics is collected only when Debug Mode is enabled.', 'w3-total-cache' ); ?>
15
  </p>
16
 
17
+ <a href="admin.php?page=w3tc_general#debug" class="button-primary"><?php esc_html_e( 'Enable it here', 'w3-total-cache' ); ?></a>
18
 
19
  <?php Util_Ui::postbox_footer(); ?>
20
  </div>
UsageStatistics_Plugin_Admin.php CHANGED
@@ -7,11 +7,9 @@ class UsageStatistics_Plugin_Admin {
7
  function run() {
8
  $c = Dispatcher::config();
9
 
 
10
  add_filter( 'w3tc_admin_menu', array( $this, 'w3tc_admin_menu' ) );
11
  add_action( 'w3tc_ajax_ustats_get', array( $this, 'w3tc_ajax_ustats_get' ) );
12
- add_action( 'w3tc_ajax_ustats_access_log_test',
13
- array( $this, 'w3tc_ajax_ustats_access_log_test' ) );
14
-
15
  add_filter( 'w3tc_usage_statistics_summary_from_history', array(
16
  'W3TC\UsageStatistics_Sources',
17
  'w3tc_usage_statistics_summary_from_history'
@@ -43,9 +41,6 @@ class UsageStatistics_Plugin_Admin {
43
  add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
44
  }
45
 
46
- #
47
-
48
-
49
  public function w3tc_config_ui_save( $config, $old_config ) {
50
  if ( $config->get( 'stats.slot_seconds' ) !=
51
  $old_config->get( 'stats.slot_seconds' ) ) {
@@ -55,8 +50,6 @@ class UsageStatistics_Plugin_Admin {
55
  }
56
  }
57
 
58
-
59
-
60
  public function w3tc_notes( $notes ) {
61
  $c = Dispatcher::config();
62
  $state_master = Dispatcher::config_state_master();
@@ -108,18 +101,31 @@ class UsageStatistics_Plugin_Admin {
108
  exit();
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
111
 
 
 
 
112
 
113
- public function w3tc_ajax_ustats_access_log_test() {
114
- $filename = $_REQUEST['filename'];
 
115
 
116
- $filename = str_replace( '://', '/', $filename );
117
- $h = @fopen( $filename, 'rb' );
118
- if ( !$h ) {
119
- echo 'Failed to open file ' . $filename;
120
  } else {
121
- echo 'Success';
122
  }
123
- exit();
 
124
  }
125
  }
7
  function run() {
8
  $c = Dispatcher::config();
9
 
10
+ add_action( 'wp_ajax_ustats_access_log_test', array( $this, 'w3tc_ajax_ustats_access_log_test' ) );
11
  add_filter( 'w3tc_admin_menu', array( $this, 'w3tc_admin_menu' ) );
12
  add_action( 'w3tc_ajax_ustats_get', array( $this, 'w3tc_ajax_ustats_get' ) );
 
 
 
13
  add_filter( 'w3tc_usage_statistics_summary_from_history', array(
14
  'W3TC\UsageStatistics_Sources',
15
  'w3tc_usage_statistics_summary_from_history'
41
  add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
42
  }
43
 
 
 
 
44
  public function w3tc_config_ui_save( $config, $old_config ) {
45
  if ( $config->get( 'stats.slot_seconds' ) !=
46
  $old_config->get( 'stats.slot_seconds' ) ) {
50
  }
51
  }
52
 
 
 
53
  public function w3tc_notes( $notes ) {
54
  $c = Dispatcher::config();
55
  $state_master = Dispatcher::config_state_master();
101
  exit();
102
  }
103
 
104
+ /**
105
+ * Ajax: Test access log path.
106
+ */
107
+ public function w3tc_ajax_ustats_access_log_test() {
108
+ $nonce_val = Util_Request::get_array( '_wpnonce' )[0];
109
+ $nonce = isset( $nonce_val ) ? $nonce_val : false;
110
+
111
+ if ( ! wp_verify_nonce( $nonce, 'w3tc' ) ) {
112
+ wp_die( esc_html__( 'Invalid WordPress nonce. Please reload the page and try again.', 'w3-total-cache' ) );
113
+ }
114
 
115
+ $handle = false;
116
+ $filename_val = Util_Request::get_string( 'filename' );
117
+ $filepath = ! empty( $filename_val ) ? str_replace( '://', '/', $filename_val ) : null;
118
 
119
+ if ( $filepath ) {
120
+ $handle = @fopen( $filepath, 'rb' ); // phpcs:ignore WordPress
121
+ }
122
 
123
+ if ( $handle ) {
124
+ esc_html_e( 'Success', 'w3-total-cache' );
 
 
125
  } else {
126
+ esc_html_e( 'Failed to open file', 'w3-total-cache' );
127
  }
128
+
129
+ wp_die();
130
  }
131
  }
UsageStatistics_Widget_View_Disabled.php CHANGED
@@ -1,14 +1,15 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
  ?>
7
  <style>
8
 
9
  .w3tcuw_inactive {
10
  height: 242px;
11
- background: url("<?php echo esc_url(plugins_url( 'pub/img/usage-statistics-widget.png', W3TC_FILE ) ) ?>");
12
  background-repeat: no-repeat;
13
  background-size: cover;
14
  }
@@ -27,10 +28,10 @@ if ( !defined( 'W3TC' ) )
27
 
28
  </style>
29
  <p class="w3tcuw_inactive">
30
- <?php if ( !Util_Environment::is_w3tc_pro( Dispatcher::config() ) ): ?>
31
  <input type="button"
32
- class="button-primary button-buy-plugin {nonce: '<?php echo wp_create_nonce( 'w3tc' ) ?>'}" data-src="usagestatistics_widget" value="<?php _e( 'Upgrade to Pro', 'w3-total-cache' ) ?>" />
33
- <?php else: ?>
34
  <a href="admin.php?page=w3tc_general#stats" class="button-primary">Enable</a>
35
  <?php endif ?>
36
  </p>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <style>
9
 
10
  .w3tcuw_inactive {
11
  height: 242px;
12
+ background: url("<?php echo esc_url( plugins_url( 'pub/img/usage-statistics-widget.png', W3TC_FILE ) ); ?>");
13
  background-repeat: no-repeat;
14
  background-size: cover;
15
  }
28
 
29
  </style>
30
  <p class="w3tcuw_inactive">
31
+ <?php if ( ! Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) : ?>
32
  <input type="button"
33
+ class="button-primary button-buy-plugin {nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}" data-src="usagestatistics_widget" value="<?php esc_html_e( 'Upgrade to Pro', 'w3-total-cache' ); ?>" />
34
+ <?php else : ?>
35
  <a href="admin.php?page=w3tc_general#stats" class="button-primary">Enable</a>
36
  <?php endif ?>
37
  </p>
UserExperience_GeneralPage_View.php CHANGED
@@ -1,71 +1,80 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
6
-
7
  ?>
8
  <?php
9
- Util_Ui::postbox_header( __( 'User Experience', 'w3-total-cache' ), '', 'userexperience' );
10
- Util_Ui::config_overloading_button( array(
11
- 'key' => 'lazyload.configuration_overloaded'
12
- ) );
13
  ?>
14
 
15
  <table class="form-table">
16
  <?php
17
- Util_Ui::config_item( array(
18
- 'key' => 'lazyload.enabled',
19
- 'control' => 'checkbox',
20
- 'checkbox_label' => __( 'Lazy Load Images', 'w3-total-cache' ),
21
- 'description' => __( 'Defer loading offscreen images.',
22
- 'w3-total-cache' )
23
- ) );
 
24
 
25
- Util_Ui::config_item_pro( array(
26
- 'key' => 'lazyload_googlemaps_general_settings',
27
- 'control' => 'none',
28
- 'none_label' => __( 'Lazy Load Google Maps', 'w3-total-cache' ),
29
- 'excerpt' => wp_kses(
30
- sprintf(
31
- // Translators: 1 an opening anchor to the user experience page, 2 its closing anchor tag, 3 an opening strong tag, 4 its closing tag.
32
- __( 'In addition to lazy loading images, with %3$sW3 Total Cache Pro%4$s you can lazy load %3$sGoogle Maps%4$s! More information and settings can be found on the %1$sUser Experience page%2$s.', 'w3-total-cache' ),
33
- '<a href="' . admin_url( 'admin.php?page=w3tc_userexperience' ) . '">',
34
- '</a>',
35
- '<strong>',
36
- '</strong>'
37
- ),
38
- array(
39
- 'a' => array(
40
- 'href' => array(),
 
 
 
41
  ),
42
- 'strong' => array(),
43
- )
44
- ),
45
- 'description' => array(),
46
- ) );
 
 
 
 
 
47
 
48
- Util_Ui::config_item_extension_enabled( array(
49
- 'extension_id' => 'user-experience-emoji',
50
- 'checkbox_label' => __( 'Disable Emoji', 'w3-total-cache' ),
51
- 'description' => __( 'Remove emojis support from your website.',
52
- 'w3-total-cache' )
53
- ) );
 
54
  ?>
55
  <?php
56
- Util_Ui::config_item_extension_enabled( array(
57
- 'extension_id' => 'user-experience-oembed',
58
- 'checkbox_label' => __( 'Disable wp-embed script', 'w3-total-cache' ),
59
- 'description' => __( 'Remove wp-embed.js script from your website. oEmbed functionality still works but you will not be able to embed other WordPress posts on your pages.',
60
- 'w3-total-cache' )
61
- ) );
 
62
 
63
  Util_Ui::config_item(
64
  array(
65
  'key' => 'jquerymigrate.disabled',
66
  'control' => 'checkbox',
67
- 'checkbox_label' => __( 'Disable jquery-migrate on the front-end', 'w3-total-cache' ),
68
- 'description' => __( 'Remove jquery-migrate support from your website front-end.', 'w3-total-cache' ),
69
  )
70
  );
71
  ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
  ?>
8
  <?php
9
+ Util_Ui::postbox_header( esc_html__( 'User Experience', 'w3-total-cache' ), '', 'userexperience' );
10
+ Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_overloaded' ) );
 
 
11
  ?>
12
 
13
  <table class="form-table">
14
  <?php
15
+ Util_Ui::config_item(
16
+ array(
17
+ 'key' => 'lazyload.enabled',
18
+ 'control' => 'checkbox',
19
+ 'checkbox_label' => esc_html__( 'Lazy Load Images', 'w3-total-cache' ),
20
+ 'description' => esc_html__( 'Defer loading offscreen images.', 'w3-total-cache' ),
21
+ )
22
+ );
23
 
24
+ Util_Ui::config_item_pro(
25
+ array(
26
+ 'key' => 'lazyload_googlemaps_general_settings',
27
+ 'control' => 'none',
28
+ 'none_label' => esc_html__( 'Lazy Load Google Maps', 'w3-total-cache' ),
29
+ 'excerpt' => wp_kses(
30
+ sprintf(
31
+ // translators: 1 opening HTML strong tag, 2 closing HTML strong tag, 3 opening HTML strong tag, 4 closing HTML strong tag,
32
+ // translators: 5 opening HTML a tag to W3TC User Experience page, 6 closing HTML a tag.
33
+ __(
34
+ 'In addition to lazy loading images, with %1$sW3 Total Cache Pro%2$s you can lazy load %3$sGoogle Maps%4$s! More information and settings can be found on the %5$sUser Experience page%6$s.',
35
+ 'w3-total-cache'
36
+ ),
37
+ '<strong>',
38
+ '</strong>',
39
+ '<strong>',
40
+ '</strong>',
41
+ '<a href="' . admin_url( 'admin.php?page=w3tc_userexperience' ) . '">',
42
+ '</a>'
43
  ),
44
+ array(
45
+ 'a' => array(
46
+ 'href' => array(),
47
+ ),
48
+ 'strong' => array(),
49
+ )
50
+ ),
51
+ 'description' => array(),
52
+ )
53
+ );
54
 
55
+ Util_Ui::config_item_extension_enabled(
56
+ array(
57
+ 'extension_id' => 'user-experience-emoji',
58
+ 'checkbox_label' => esc_html__( 'Disable Emoji', 'w3-total-cache' ),
59
+ 'description' => esc_html__( 'Remove emojis support from your website.', 'w3-total-cache' )
60
+ )
61
+ );
62
  ?>
63
  <?php
64
+ Util_Ui::config_item_extension_enabled(
65
+ array(
66
+ 'extension_id' => 'user-experience-oembed',
67
+ 'checkbox_label' => esc_html__( 'Disable wp-embed script', 'w3-total-cache' ),
68
+ 'description' => esc_html__( 'Remove wp-embed.js script from your website. oEmbed functionality still works but you will not be able to embed other WordPress posts on your pages.', 'w3-total-cache' )
69
+ )
70
+ );
71
 
72
  Util_Ui::config_item(
73
  array(
74
  'key' => 'jquerymigrate.disabled',
75
  'control' => 'checkbox',
76
+ 'checkbox_label' => esc_html__( 'Disable jquery-migrate on the front-end', 'w3-total-cache' ),
77
+ 'description' => esc_html__( 'Remove jquery-migrate support from your website front-end.', 'w3-total-cache' ),
78
  )
79
  );
80
  ?>
UserExperience_LazyLoad_Mutator.php CHANGED
@@ -103,6 +103,7 @@ class UserExperience_LazyLoad_Mutator {
103
  '$1data-$2=', $content );
104
 
105
  $content = $this->add_class_lazy( $content );
 
106
  $this->modified = true;
107
  }
108
 
@@ -222,6 +223,18 @@ class UserExperience_LazyLoad_Mutator {
222
 
223
 
224
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  public function class_process( $matches ) {
226
  list( $match, $v1, $v2, $quote, $v ) = $matches;
227
  if ( preg_match( '~(^|\\s)lazy(\\s|$)~is', $v ) ) {
103
  '$1data-$2=', $content );
104
 
105
  $content = $this->add_class_lazy( $content );
106
+ $content = $this->remove_native_lazy( $content );
107
  $this->modified = true;
108
  }
109
 
223
 
224
 
225
 
226
+ /**
227
+ * In safari javascript lazy-loaded image with loading="lazy"
228
+ * dont fire events, i.e. image not loaded
229
+ */
230
+ public function remove_native_lazy( $content ) {
231
+ return preg_replace(
232
+ '~(\s+)loading=[\'"]lazy[\'"]~is', '', $content
233
+ );
234
+ }
235
+
236
+
237
+
238
  public function class_process( $matches ) {
239
  list( $match, $v1, $v2, $quote, $v ) = $matches;
240
  if ( preg_match( '~(^|\\s)lazy(\\s|$)~is', $v ) ) {
UserExperience_LazyLoad_Mutator_Unmutable.php CHANGED
@@ -8,7 +8,7 @@ class UserExperience_LazyLoad_Mutator_Unmutable {
8
 
9
  public function __construct() {
10
  $this->placeholder_base = 'w3tc_lazyload_' .
11
- md5( $_SERVER['REQUEST_TIME'] ) . '_';
12
  }
13
 
14
 
8
 
9
  public function __construct() {
10
  $this->placeholder_base = 'w3tc_lazyload_' .
11
+ md5( isset( $_SERVER['REQUEST_TIME'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_TIME'] ) ) : '' ) . '_';
12
  }
13
 
14
 
UserExperience_LazyLoad_Page_View.php CHANGED
@@ -1,63 +1,108 @@
1
  <?php
2
  namespace W3TC;
3
 
4
- if ( !defined( 'W3TC' ) )
5
  die();
 
6
 
7
- $c = Dispatcher::config();
8
  $is_pro = Util_Environment::is_w3tc_pro( $c );
9
 
10
- $plugins = get_option( 'active_plugins' );
11
- $is_wp_google_maps = ( in_array( 'wp-google-maps/wpGoogleMaps.php', $plugins ) );
12
- $is_wp_google_map_plugin = ( in_array( 'wp-google-map-plugin/wp-google-map-plugin.php', $plugins ) );
13
- $is_google_maps_easy = ( in_array( 'google-maps-easy/gmp.php', $plugins ) );
14
 
15
  ?>
16
- <?php Util_Ui::postbox_header( __( 'Lazy Loading', 'w3-total-cache' ), '', 'application' ); ?>
17
  <table class="form-table">
18
  <?php
19
- Util_Ui::config_item( array(
20
- 'key' => 'lazyload.process_img',
21
- 'control' => 'checkbox',
22
- 'checkbox_label' => __( 'Process HTML image tags', 'w3-total-cache' ),
23
- 'description' => __( 'Process <code>img</code> tags',
24
- 'w3-total-cache' )
25
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- Util_Ui::config_item( array(
28
- 'key' => 'lazyload.process_background',
29
- 'control' => 'checkbox',
30
- 'checkbox_label' => __( 'Process background images', 'w3-total-cache' ),
31
- 'description' => __( 'Process <code>background</code> styles',
32
- 'w3-total-cache' )
33
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- Util_Ui::config_item( array(
36
- 'key' => 'lazyload.exclude',
37
- 'label' => 'Exclude words:',
38
- 'control' => 'textarea',
39
- 'description' => __( 'Exclude tags containing words',
40
- 'w3-total-cache' )
41
- ) );
 
42
 
43
- Util_Ui::config_item( array(
44
- 'key' => 'lazyload.threshold',
45
- 'control' => 'textbox',
46
- 'label' => __( 'Threshold', 'w3-total-cache' ),
47
- 'description' => __( 'The outer distance off the scrolling area from which to start loading the elements (example: 100px, 10%).',
48
- 'w3-total-cache' )
49
- ) );
 
50
 
51
- Util_Ui::config_item( array(
52
- 'key' => 'lazyload.embed_method',
53
- 'label' => __( 'Script Embed method:', 'w3-total-cache' ),
54
- 'control' => 'selectbox',
 
55
  'selectbox_values' => array(
56
- 'async_head' => 'async',
57
- 'sync_head' => 'sync (to head)',
58
- 'inline_footer' => 'inline'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ),
60
- 'description' => __( 'Use <code>inline</code> method only when your website has just a few pages', 'w3-total-cache' ),
61
  )
62
  );
63
 
@@ -65,41 +110,101 @@ $is_google_maps_easy = ( in_array( 'google-maps-easy/gmp.php', $plugins ) );
65
  </table>
66
  <table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
67
  <tr>
68
- <th>Google Maps</th>
69
  <td>
70
  <?php Util_Ui::pro_wrap_maybe_start(); ?>
71
- <p class="description w3tc-gopro-excerpt" style="padding-bottom: 10px"><?php _e( 'Lazy load google map', 'w3-total-cache' ); ?></p>
72
  <div>
73
  <?php
74
- Util_Ui::control2( Util_Ui::config_item_preprocess( array(
75
- 'key' => 'lazyload.googlemaps.wp_google_map_plugin',
76
- 'control' => 'checkbox',
77
- 'disabled' => ( $is_pro ? !$is_wp_google_map_plugin : true ),
78
- 'checkbox_label' => __( '<a href="https://wordpress.org/plugins/wp-google-map-plugin/" target="_blank">WP Google Map Plugin</a> plugin', 'w3-total-cache' ),
79
- 'label_class' => 'w3tc_no_trtd'
80
- ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  ?>
82
  </div>
83
  <div>
84
  <?php
85
- Util_Ui::control2( Util_Ui::config_item_preprocess( array(
86
- 'key' => 'lazyload.googlemaps.google_maps_easy',
87
- 'control' => 'checkbox',
88
- 'disabled' => ( $is_pro ? !$is_google_maps_easy : true ),
89
- 'checkbox_label' => __( '<a href="https://wordpress.org/plugins/google-maps-easy/" target="_blank">Google Maps Easy</a> plugin', 'w3-total-cache' ),
90
- 'label_class' => 'w3tc_no_trtd'
91
- ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  ?>
93
  </div>
94
  <div>
95
  <?php
96
- Util_Ui::control2( Util_Ui::config_item_preprocess( array(
97
- 'key' => 'lazyload.googlemaps.wp_google_maps',
98
- 'control' => 'checkbox',
99
- 'disabled' => ( $is_pro ? !$is_wp_google_maps : true ),
100
- 'checkbox_label' => __( '<a href="https://wordpress.org/plugins/wp-google-maps/" target="_blank">WP Google Maps</a> plugin', 'w3-total-cache' ),
101
- 'label_class' => 'w3tc_no_trtd'
102
- ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ?>
104
  </div>
105
  <?php Util_Ui::pro_wrap_maybe_end( 'lazyload_googlemaps' ); ?>
1
  <?php
2
  namespace W3TC;
3
 
4
+ if ( ! defined( 'W3TC' ) ) {
5
  die();
6
+ }
7
 
8
+ $c = Dispatcher::config();
9
  $is_pro = Util_Environment::is_w3tc_pro( $c );
10
 
11
+ $plugins = get_option( 'active_plugins' );
12
+ $is_wp_google_maps = ( in_array( 'wp-google-maps/wpGoogleMaps.php', $plugins, true ) );
13
+ $is_wp_google_map_plugin = ( in_array( 'wp-google-map-plugin/wp-google-map-plugin.php', $plugins, true ) );
14
+ $is_google_maps_easy = ( in_array( 'google-maps-easy/gmp.php', $plugins, true ) );
15
 
16
  ?>
17
+ <?php Util_Ui::postbox_header( esc_html__( 'Lazy Loading', 'w3-total-cache' ), '', 'application' ); ?>
18
  <table class="form-table">
19
  <?php
20
+ Util_Ui::config_item(
21
+ array(
22
+ 'key' => 'lazyload.process_img',
23
+ 'control' => 'checkbox',
24
+ 'checkbox_label' => esc_html__( 'Process HTML image tags', 'w3-total-cache' ),
25
+ 'description' => wp_kses(
26
+ sprintf(
27
+ // translators: 1 opening HTML code tag, 2 closing HTML code tag.
28
+ __(
29
+ 'Process %1$simg%2$s tags',
30
+ 'w3-total-cache'
31
+ ),
32
+ '<code>',
33
+ '</code>'
34
+ ),
35
+ array(
36
+ 'code' => array(),
37
+ )
38
+ ),
39
+ )
40
+ );
41
 
42
+ Util_Ui::config_item(
43
+ array(
44
+ 'key' => 'lazyload.process_background',
45
+ 'control' => 'checkbox',
46
+ 'checkbox_label' => esc_html__( 'Process background images', 'w3-total-cache' ),
47
+ 'description' => wp_kses(
48
+ sprintf(
49
+ // translators: 1 opening HTML code tag, 2 closing HTML code tag.
50
+ __(
51
+ 'Process %1$sbackground%2$s styles',
52
+ 'w3-total-cache'
53
+ ),
54
+ '<code>',
55
+ '</code>'
56
+ ),
57
+ array(
58
+ 'code' => array(),
59
+ )
60
+ ),
61
+ )
62
+ );
63
 
64
+ Util_Ui::config_item(
65
+ array(
66
+ 'key' => 'lazyload.exclude',
67
+ 'label' => esc_html__( 'Exclude words:', 'w3-total-cache' ),
68
+ 'control' => 'textarea',
69
+ 'description' => esc_html__( 'Exclude tags containing words', 'w3-total-cache' ),
70
+ )
71
+ );
72
 
73
+ Util_Ui::config_item(
74
+ array(
75
+ 'key' => 'lazyload.threshold',
76
+ 'control' => 'textbox',
77
+ 'label' => esc_html__( 'Threshold', 'w3-total-cache' ),
78
+ 'description' => esc_html__( 'The outer distance off the scrolling area from which to start loading the elements (example: 100px, 10%).', 'w3-total-cache' ),
79
+ )
80
+ );
81
 
82
+ Util_Ui::config_item(
83
+ array(
84
+ 'key' => 'lazyload.embed_method',
85
+ 'label' => esc_html__( 'Script Embed method:', 'w3-total-cache' ),
86
+ 'control' => 'selectbox',
87
  'selectbox_values' => array(
88
+ 'async_head' => esc_attr__( 'async', 'w3-total-cache' ),
89
+ 'sync_head' => esc_attr__( 'sync (to head)', 'w3-total-cache' ),
90
+ 'inline_footer' => esc_attr__( 'inline', 'w3-total-cache' ),
91
+ ),
92
+ 'description' => wp_kses(
93
+ sprintf(
94
+ // translators: 1 opening HTML code tag, 2 closing HTML code tag.
95
+ __(
96
+ 'Use %1$sinline%2$s method only when your website has just a few pages',
97
+ 'w3-total-cache'
98
+ ),
99
+ '<code>',
100
+ '</code>'
101
+ ),
102
+ array(
103
+ 'code' => array(),
104
+ )
105
  ),
 
106
  )
107
  );
108
 
110
  </table>
111
  <table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
112
  <tr>
113
+ <th><?php esc_html_e( 'Google Maps', 'w3-total-cache' ); ?></th>
114
  <td>
115
  <?php Util_Ui::pro_wrap_maybe_start(); ?>
116
+ <p class="description w3tc-gopro-excerpt" style="padding-bottom: 10px"><?php esc_html_e( 'Lazy load google map', 'w3-total-cache' ); ?></p>
117
  <div>
118
  <?php
119
+ Util_Ui::control2(
120
+ Util_Ui::config_item_preprocess(
121
+ array(
122
+ 'key' => 'lazyload.googlemaps.wp_google_map_plugin',
123
+ 'control' => 'checkbox',
124
+ 'disabled' => ( $is_pro ? ! $is_wp_google_map_plugin : true ),
125
+ 'checkbox_label' => wp_kses(
126
+ sprintf(
127
+ // translators: 1 opening HTML a tag to WordPress Google Map Plugin, 2 closing HTML a tag.
128
+ __(
129
+ '%1$sWP Google Map Plugin%2$s plugin',
130
+ 'w3-total-cache'
131
+ ),
132
+ '<a href="' . esc_url( 'https://wordpress.org/plugins/wp-google-map-plugin/' ) . '" target="_blank">',
133
+ '</a>'
134
+ ),
135
+ array(
136
+ 'a' => array(
137
+ 'href' => array(),
138
+ 'target' => array(),
139
+ ),
140
+ )
141
+ ),
142
+ 'label_class' => 'w3tc_no_trtd',
143
+ )
144
+ )
145
+ );
146
  ?>
147
  </div>
148
  <div>
149
  <?php
150
+ Util_Ui::control2(
151
+ Util_Ui::config_item_preprocess(
152
+ array(
153
+ 'key' => 'lazyload.googlemaps.google_maps_easy',
154
+ 'control' => 'checkbox',
155
+ 'disabled' => ( $is_pro ? ! $is_google_maps_easy : true ),
156
+ 'checkbox_label' => wp_kses(
157
+ sprintf(
158
+ // translators: 1 opening HTML a tag to Google Maps Easy plugin, 2 closing HTML a tag.
159
+ __(
160
+ '%1$sGoogle Maps Easy%2$s plugin',
161
+ 'w3-total-cache'
162
+ ),
163
+ '<a href="' . esc_url( 'https://wordpress.org/plugins/google-maps-easy/' ) . '" target="_blank">',
164
+ '</a>'
165
+ ),
166
+ array(
167
+ 'a' => array(
168
+ 'href' => array(),
169
+ 'target' => array(),
170
+ ),
171
+ )
172
+ ),
173
+ 'label_class' => 'w3tc_no_trtd',
174
+ )
175
+ )
176
+ );
177
  ?>
178
  </div>
179
  <div>
180
  <?php
181
+ Util_Ui::control2(
182
+ Util_Ui::config_item_preprocess(
183
+ array(
184
+ 'key' => 'lazyload.googlemaps.wp_google_maps',
185
+ 'control' => 'checkbox',
186
+ 'disabled' => ( $is_pro ? ! $is_wp_google_maps : true ),
187
+ 'checkbox_label' => wp_kses(
188
+ sprintf(
189
+ // translators: 1 opening HTML a tag to WordPress Google Maps, 2 closing HTML a tag.
190
+ __(
191
+ '%1$sWP Google Maps%2$s plugin',
192
+ 'w3-total-cache'
193
+ ),
194
+ '<a href="' . esc_url( 'https://wordpress.org/plugins/wp-google-maps/' ) . '" target="_blank">',
195
+ '</a>'
196
+ ),
197
+ array(
198
+ 'a' => array(
199
+ 'href' => array(),
200
+ 'target' => array(),
201
+ ),
202
+ )
203
+ ),
204
+ 'label_class' => 'w3tc_no_trtd',
205
+ )
206
+ )
207
+ );
208
  ?>
209
  </div>
210
  <?php Util_Ui::pro_wrap_maybe_end( 'lazyload_googlemaps' ); ?>
Util_Admin.php CHANGED
@@ -14,7 +14,7 @@ class Util_Admin {
14
  $page_url = Util_Request::get_string( 'page' );
15
  if ( $url == '' ) {
16
  if ( $check_referrer && !empty( $_SERVER['HTTP_REFERER'] ) ) {
17
- $url = $_SERVER['HTTP_REFERER'];
18
  } else {
19
  $url = 'admin.php';
20
  if ( empty( $page ) )
@@ -713,7 +713,7 @@ class Util_Admin {
713
  return $parse_url['host'];
714
  }
715
 
716
- return $_SERVER['HTTP_HOST'];
717
  }
718
 
719
  /*
@@ -734,10 +734,15 @@ class Util_Admin {
734
  * @return bool
735
  */
736
  static public function is_w3tc_admin_page() {
737
- if ( isset( $_GET['page'] ) && substr( $_GET['page'], 0, 5 ) == 'w3tc_' )
 
738
  return true;
739
- if ( isset( $_REQUEST['action'] ) && substr( $_REQUEST['action'], 0, 5 ) == 'w3tc_' )
 
 
 
740
  return true;
 
741
 
742
  return false;
743
  }
14
  $page_url = Util_Request::get_string( 'page' );
15
  if ( $url == '' ) {
16
  if ( $check_referrer && !empty( $_SERVER['HTTP_REFERER'] ) ) {
17
+ $url = isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
18
  } else {
19
  $url = 'admin.php';
20
  if ( empty( $page ) )
713
  return $parse_url['host'];
714
  }
715
 
716
+ return isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
717
  }
718
 
719
  /*
734
  * @return bool
735
  */
736
  static public function is_w3tc_admin_page() {
737
+ $page_val = Util_Request::get_string( 'page' );
738
+ if ( ! empty( $page_val ) && 'w3tc_' === substr( $page_val, 0, 5 ) ) {
739
  return true;
740
+ }
741
+
742
+ $action_val = Util_Request::get_string( 'action' );
743
+ if ( ! empty( $action_val ) && 'w3tc_' === substr( $action_val, 0, 5 ) ) {
744
  return true;
745
+ }
746
 
747
  return false;
748
  }
Util_ConfigLabel.php CHANGED
@@ -1,23 +1,41 @@
1
  <?php
 
 
 
 
 
 
2
  namespace W3TC;
3
 
 
 
 
4
  class Util_ConfigLabel {
5
- static public function get( $key ) {
 
 
 
 
 
6
  static $keys = null;
7
  if ( is_null( $keys ) ) {
8
  $keys = array(
9
- 'memcached.servers' => __( 'Memcached hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:', 'w3-total-cache' ),
10
- 'memcached.persistent' => __( 'Persistent connection', 'w3-total-cache' ),
11
- 'memcached.username' => __( 'Memcached username:', 'w3-total-cache' ),
12
- 'memcached.password' => __( 'Memcached password:', 'w3-total-cache' ),
13
- 'memcached.binary_protocol' => __( 'Binary protocol', 'w3-total-cache' ),
14
- 'redis.servers' => __( 'Redis hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:', 'w3-total-cache' ),
15
- 'redis.persistent' => __( 'Persistent connection', 'w3-total-cache' ),
16
- 'redis.dbid' => __( 'Redis Database ID:', 'w3-total-cache' ),
17
- 'redis.password' => __( 'Redis password:', 'w3-total-cache' ),
 
 
 
 
18
  );
19
  }
20
 
21
- return $keys[$key];
22
  }
23
  }
1
  <?php
2
+ /**
3
+ * File: Util_ConfigLabel.php
4
+ *
5
+ * @package W3TC
6
+ */
7
+
8
  namespace W3TC;
9
 
10
+ /**
11
+ * Class: Util_ConfigLabel
12
+ */
13
  class Util_ConfigLabel {
14
+ /**
15
+ * Undocumented function
16
+ *
17
+ * @param string $key Key name.
18
+ */
19
+ public static function get( $key ) {
20
  static $keys = null;
21
  if ( is_null( $keys ) ) {
22
  $keys = array(
23
+ 'memcached.servers' => __( 'Memcached hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:', 'w3-total-cache' ),
24
+ 'memcached.persistent' => __( 'Persistent connection', 'w3-total-cache' ),
25
+ 'memcached.username' => __( 'Memcached username:', 'w3-total-cache' ),
26
+ 'memcached.password' => __( 'Memcached password:', 'w3-total-cache' ),
27
+ 'memcached.binary_protocol' => __( 'Binary protocol', 'w3-total-cache' ),
28
+ 'redis.servers' => __( 'Redis hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:', 'w3-total-cache' ),
29
+ 'redis.verify_tls_certificates' => __( 'Verify TLS Certificates', 'w3-total-cache' ),
30
+ 'redis.persistent' => __( 'Persistent connection', 'w3-total-cache' ),
31
+ 'redis.timeout' => __( 'Connection timeout', 'w3-total-cache' ),
32
+ 'redis.retry_interval' => __( 'Connection retry interval', 'w3-total-cache' ),
33
+ 'redis.read_timeout' => __( 'Connection read timeout', 'w3-total-cache' ),
34
+ 'redis.dbid' => __( 'Redis Database ID:', 'w3-total-cache' ),
35
+ 'redis.password' => __( 'Redis password:', 'w3-total-cache' ),
36
  );
37
  }
38
 
39
+ return $keys[ $key ];
40
  }
41
  }
Util_Environment.php CHANGED
@@ -1,66 +1,84 @@
1
  <?php
 
 
 
 
 
 
2
  namespace W3TC;
3
 
 
 
 
4
  class Util_Environment {
5
  /**
6
- * Formats URL
7
  *
8
- * @param string $url
9
- * @param array $params
10
- * @param boolean $skip_empty
11
- * @param string $separator
 
 
 
 
 
 
 
 
 
 
12
  * @return string
13
  */
14
- static public function url_format( $url = '', $params = array(),
15
- $skip_empty = false, $separator = '&' ) {
16
- if ( $url != '' ) {
17
- $parse_url = @parse_url( $url );
18
- $url = '';
19
 
20
- if ( !empty( $parse_url['scheme'] ) ) {
21
  $url .= $parse_url['scheme'] . '://';
22
 
23
- if ( !empty( $parse_url['user'] ) ) {
24
  $url .= $parse_url['user'];
25
 
26
- if ( !empty( $parse_url['pass'] ) ) {
27
  $url .= ':' . $parse_url['pass'];
28
  }
29
  }
30
 
31
- if ( !empty( $parse_url['host'] ) ) {
32
  $url .= $parse_url['host'];
33
  }
34
 
35
- if ( !empty( $parse_url['port'] ) && $parse_url['port'] != 80 ) {
36
  $url .= ':' . (int) $parse_url['port'];
37
  }
38
  }
39
 
40
- if ( !empty( $parse_url['path'] ) ) {
41
  $url .= $parse_url['path'];
42
  }
43
 
44
- if ( !empty( $parse_url['query'] ) ) {
45
  $old_params = array();
46
  parse_str( $parse_url['query'], $old_params );
47
 
48
  $params = array_merge( $old_params, $params );
49
  }
50
 
51
- $query = Util_Environment::url_query( $params );
52
 
53
- if ( $query != '' ) {
54
  $url .= '?' . $query;
55
  }
56
 
57
- if ( !empty( $parse_url['fragment'] ) ) {
58
  $url .= '#' . $parse_url['fragment'];
59
  }
60
  } else {
61
- $query = Util_Environment::url_query( $params, $skip_empty, $separator );
62
 
63
- if ( $query != '' ) {
64
  $url = '?' . $query;
65
  }
66
  }
@@ -69,20 +87,21 @@ class Util_Environment {
69
  }
70
 
71
  /**
72
- * Formats query string
 
 
73
  *
74
- * @param array $params
75
- * @param boolean $skip_empty
76
- * @param string $separator
77
  * @return string
78
  */
79
- static public function url_query( $params = array(), $skip_empty = false,
80
- $separator = '&' ) {
81
- $str = '';
82
  static $stack = array();
83
 
84
  foreach ( (array) $params as $key => $value ) {
85
- if ( $skip_empty === true && empty( $value ) ) {
86
  continue;
87
  }
88
 
@@ -90,15 +109,16 @@ class Util_Environment {
90
 
91
  if ( is_array( $value ) ) {
92
  if ( count( $value ) ) {
93
- $str .= ( $str != '' ? '&' : '' ) .
94
- Util_Environment::url_query( $value, $skip_empty, $key );
95
  }
96
  } else {
97
  $name = '';
 
98
  foreach ( $stack as $key ) {
99
- $name .= ( $name != '' ? '[' . $key . ']' : $key );
100
  }
101
- $str .= ( $str != '' ? $separator : '' ) . $name . '=' . rawurlencode( $value );
102
  }
103
 
104
  array_pop( $stack );
@@ -107,21 +127,29 @@ class Util_Environment {
107
  return $str;
108
  }
109
 
110
- /*
111
- * Returns URL from filename/dirname
112
  *
 
 
 
 
113
  * @return string
114
  */
115
- static public function filename_to_url( $filename, $use_site_url = false ) {
116
- // using wp-content instead of document_root as known dir since dirbased
117
- // multisite wp adds blogname to the path inside site_url
118
- if ( substr( $filename, 0, strlen( WP_CONTENT_DIR ) ) != WP_CONTENT_DIR )
 
 
119
  return '';
 
 
120
  $uri_from_wp_content = substr( $filename, strlen( WP_CONTENT_DIR ) );
121
 
122
- if ( DIRECTORY_SEPARATOR != '/' )
123
- $uri_from_wp_content = str_replace( DIRECTORY_SEPARATOR, '/',
124
- $uri_from_wp_content );
125
 
126
  $url = content_url( $uri_from_wp_content );
127
  $url = apply_filters( 'w3tc_filename_to_url', $url );
@@ -130,54 +158,71 @@ class Util_Environment {
130
  }
131
 
132
  /**
133
- * Returns true if database cluster is used
134
  *
135
- * @return boolean
 
 
136
  */
137
- static public function is_dbcluster() {
138
- if ( !defined( 'W3TC_PRO' ) || !W3TC_PRO )
139
  return false;
 
140
 
141
- if ( isset( $GLOBALS['w3tc_dbcluster_config'] ) )
142
  return true;
 
143
 
144
  return defined( 'W3TC_FILE_DB_CLUSTER_CONFIG' ) &&
145
- @file_exists( W3TC_FILE_DB_CLUSTER_CONFIG );
146
  }
147
 
148
  /**
149
- * Returns true if WPMU uses vhosts
150
  *
151
- * @return boolean
 
 
152
  */
153
- static public function is_wpmu_subdomain() {
154
- return ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) ||
155
- ( defined( 'VHOST' ) && VHOST == 'yes' ) );
 
 
156
  }
157
 
158
  /**
159
- * Returns if there is multisite mode
160
  *
161
- * @return boolean
 
 
162
  */
163
- static public function is_wpmu() {
164
  static $wpmu = null;
165
 
166
- if ( $wpmu === null ) {
167
- $wpmu = ( file_exists( ABSPATH . 'wpmu-settings.php' ) ||
 
168
  ( defined( 'MULTISITE' ) && MULTISITE ) ||
169
  defined( 'SUNRISE' ) ||
170
- Util_Environment::is_wpmu_subdomain() );
 
171
  }
172
 
173
  return $wpmu;
174
  }
175
 
176
- static private $is_using_master_config = null;
177
-
178
- static public function is_using_master_config() {
 
 
 
 
 
179
  if ( is_null( self::$is_using_master_config ) ) {
180
- if ( !Util_Environment::is_wpmu() ) {
181
  self::$is_using_master_config = true;
182
  } elseif ( is_network_admin() ) {
183
  self::$is_using_master_config = true;
@@ -186,7 +231,7 @@ class Util_Environment {
186
  if ( is_null( $blog_data ) ) {
187
  self::$is_using_master_config = true;
188
  } else {
189
- self::$is_using_master_config = ( $blog_data[0] == 'm' );
190
  }
191
  }
192
  }
@@ -195,147 +240,186 @@ class Util_Environment {
195
  }
196
 
197
  /**
198
- * Returns header W3TC adds to responses powered by itself
 
 
 
 
199
  */
200
- static public function w3tc_header() {
201
  return W3TC_POWERED_BY .
202
  '/' . W3TC_VERSION;
203
  }
204
 
205
  /**
206
- * Check if URL is valid
 
 
207
  *
208
- * @param string $url
209
- * @return boolean
210
  */
211
- static public function is_url( $url ) {
212
  return preg_match( '~^(https?:)?//~', $url );
213
  }
214
 
215
  /**
216
- * Returns true if current connection is secure
217
  *
218
- * @return boolean
 
 
219
  */
220
- static public function is_https() {
 
 
 
 
 
 
 
221
  switch ( true ) {
222
- case ( isset( $_SERVER['HTTPS'] ) &&
223
- Util_Environment::to_boolean( $_SERVER['HTTPS'] ) ):
224
- case ( isset( $_SERVER['SERVER_PORT'] ) &&
225
- (int) $_SERVER['SERVER_PORT'] == 443 ):
226
- case ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
227
- $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ):
228
- return true;
229
  }
230
 
231
  return false;
232
  }
233
 
234
  /**
235
- * Moves user to preview-mode or opposite
 
 
236
  */
237
- static public function set_preview( $is_enabled ) {
238
- if ( $is_enabled )
239
  setcookie( 'w3tc_preview', '*', 0, '/' );
240
- else
241
- setcookie( "w3tc_preview", '', time()-3600, '/' );
 
242
  }
243
 
244
  /**
245
- * Retuns true if preview settings active
 
 
246
  *
247
- * @return boolean
248
  */
249
- static public function is_preview_mode() {
250
- return !empty( $_COOKIE['w3tc_preview'] );
251
  }
252
 
253
  /**
254
- * Returns true if server is Apache
 
 
255
  *
256
- * @return boolean
257
  */
258
- static public function is_apache() {
259
- // assume apache when unknown, since most common
260
- if ( empty( $_SERVER['SERVER_SOFTWARE'] ) )
261
  return true;
 
262
 
263
- return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false;
264
  }
265
 
 
266
  /**
267
- * Check whether server is LiteSpeed
 
 
268
  *
269
  * @return bool
270
  */
271
- static public function is_litespeed() {
272
- return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) !== false;
273
  }
274
 
275
  /**
276
- * Returns true if server is nginx
 
 
277
  *
278
- * @return boolean
279
  */
280
- static public function is_nginx() {
281
- return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) !== false;
282
  }
283
 
284
  /**
285
- * Returns true if server is nginx
286
  *
287
- * @return boolean
 
 
288
  */
289
- static public function is_iis() {
290
- return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'IIS' ) !== false;
291
  }
292
 
293
  /**
294
- * Returns domain from host
 
 
295
  *
296
- * @param string $host
297
  * @return string
298
  */
299
- static public function url_to_host( $url ) {
300
- $a = parse_url( $url );
301
- if ( isset( $a['host'] ) )
 
302
  return $a['host'];
 
303
 
304
  return '';
305
  }
306
 
307
  /**
308
- * Returns path from URL. Without trailing slash
 
 
 
 
309
  */
310
- static public function url_to_uri( $url ) {
311
  $uri = @parse_url( $url, PHP_URL_PATH );
312
 
313
- // convert FALSE and other return values to string
314
- if ( empty( $uri ) )
315
  return '';
 
316
 
317
  return rtrim( $uri, '/' );
318
  }
319
 
320
  /**
321
- * Returns current blog ID
 
 
322
  *
323
- * @return integer
324
  */
325
- static public function blog_id() {
326
  global $w3_current_blog_id;
327
 
328
- if ( !is_null( $w3_current_blog_id ) )
329
  return $w3_current_blog_id;
 
330
 
331
- if ( !Util_Environment::is_wpmu() || is_network_admin() ) {
332
  $w3_current_blog_id = 0;
333
  return $w3_current_blog_id;
334
  }
335
 
336
-
337
  $blog_data = Util_WpmuBlogmap::get_current_blog_data();
338
- if ( !is_null( $blog_data ) ) {
 
339
  $w3_current_blog_id = substr( $blog_data, 1 );
340
  } else {
341
  $w3_current_blog_id = 0;
@@ -346,94 +430,113 @@ class Util_Environment {
346
 
347
  /**
348
  * Memoized version of wp_upload_dir. That function is quite slow
349
- * for a number of times CDN calls it
 
 
 
 
350
  */
351
- static public function wp_upload_dir() {
352
  static $values_by_blog = array();
353
 
354
- $blog_id = Util_Environment::blog_id();
355
- if ( !isset( $values_by_blog[$blog_id] ) )
356
- $values_by_blog[$blog_id] = wp_upload_dir();
 
357
 
358
- return $values_by_blog[$blog_id];
359
  }
360
 
361
  /**
362
- * Returns path to section's cache dir
 
 
363
  *
364
- * @param string $section
365
  * @return string
366
  */
367
- static public function cache_dir( $section ) {
368
  return W3TC_CACHE_DIR . DIRECTORY_SEPARATOR . $section;
369
  }
370
 
371
  /**
372
- * Returns path to blog's cache dir
373
  *
374
- * @param string $section
375
- * @param null|int $blog_id
 
 
376
  * @return string
377
  */
378
- static public function cache_blog_dir( $section, $blog_id = null ) {
379
- if ( !Util_Environment::is_wpmu() )
380
  $postfix = '';
381
- else {
382
- if ( is_null( $blog_id ) )
383
- $blog_id = Util_Environment::blog_id();
 
384
 
385
  $postfix = DIRECTORY_SEPARATOR . sprintf( '%d', $blog_id );
386
 
387
  if ( defined( 'W3TC_BLOG_LEVELS' ) ) {
388
- for ( $n = 0; $n < W3TC_BLOG_LEVELS; $n++ )
389
  $postfix = DIRECTORY_SEPARATOR .
390
  substr( $postfix, strlen( $postfix ) - 1 - $n, 1 ) .
391
  $postfix;
 
392
  }
393
  }
394
 
395
- return Util_Environment::cache_dir( $section ) . $postfix;
396
  }
397
 
398
- static public function cache_blog_minify_dir() {
 
 
 
 
 
 
 
399
  // when minify manual used with a shared config - shared
400
  // minify urls has to be used too, since CDN upload is possible
401
  // only from network admin
402
- if ( Util_Environment::is_wpmu() &&
403
- Util_Environment::is_using_master_config() &&
404
- ! Dispatcher::config()->get_boolean( 'minify.auto' ) )
405
- $path = Util_Environment::cache_blog_dir( 'minify', 0 );
406
- else
407
- $path = Util_Environment::cache_blog_dir( 'minify' );
408
 
409
  return $path;
410
  }
411
 
412
-
413
-
414
  /**
415
- * Returns URL regexp from URL
416
  *
417
- * @param string $url
 
 
418
  * @return string
419
  */
420
- static public function get_url_regexp( $url ) {
421
  $url = preg_replace( '~(https?:)?//~i', '', $url );
422
  $url = preg_replace( '~^www\.~i', '', $url );
423
 
424
- $regexp = '(https?:)?//(www\.)?' . Util_Environment::preg_quote( $url );
425
 
426
  return $regexp;
427
  }
428
 
429
  /**
430
- * Returns SSL URL if current connection is https
 
 
431
  *
432
- * @param string $url
433
  * @return string
434
  */
435
- static public function url_to_maybe_https( $url ) {
436
- if ( Util_Environment::is_https() ) {
437
  $url = str_replace( 'http://', 'https://', $url );
438
  }
439
 
@@ -441,19 +544,21 @@ class Util_Environment {
441
  }
442
 
443
  /**
444
- * Get domain URL
 
 
445
  *
446
  * @return string
447
  */
448
 
449
- static public function home_domain_root_url() {
450
- $home_url = get_home_url();
451
- $parse_url = @parse_url( $home_url );
452
 
453
  if ( $parse_url && isset( $parse_url['scheme'] ) && isset( $parse_url['host'] ) ) {
454
- $scheme = $parse_url['scheme'];
455
- $host = $parse_url['host'];
456
- $port = ( isset( $parse_url['port'] ) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '' );
457
  $domain_url = sprintf( '%s://%s%s', $scheme, $host, $port );
458
 
459
  return $domain_url;
@@ -463,67 +568,82 @@ class Util_Environment {
463
  }
464
 
465
  /**
466
- * Returns domain url regexp
 
 
467
  *
468
  * @return string
469
  */
470
- static public function home_domain_root_url_regexp() {
471
- $domain_url = Util_Environment::home_domain_root_url();
472
- $regexp = Util_Environment::get_url_regexp( $domain_url );
473
 
474
  return $regexp;
475
  }
476
 
477
  /**
478
- * Returns SSL home url
 
 
479
  *
480
  * @return string
481
  */
482
- static public function home_url_maybe_https() {
483
  $home_url = get_home_url();
484
- $ssl = Util_Environment::url_to_maybe_https( $home_url );
485
 
486
  return $ssl;
487
  }
488
 
489
  /**
490
- * Returns home url regexp
 
 
491
  *
492
  * @return string
493
  */
494
- static public function home_url_regexp() {
495
  $home_url = get_home_url();
496
- $regexp = Util_Environment::get_url_regexp( $home_url );
497
 
498
  return $regexp;
499
  }
500
 
501
  /**
502
- * Copy of wordpress get_home_path, but accessible not only for wp-admin
503
  * Get the absolute filesystem path to the root of the WordPress installation
504
- * (i.e. filesystem path of siteurl)
505
  *
506
- * @return string Full filesystem path to the root of the WordPress installation
 
 
507
  */
508
- static public function site_path() {
509
  $home = set_url_scheme( get_option( 'home' ), 'http' );
510
  $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
511
 
512
  $home_path = ABSPATH;
513
  if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
514
- $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
515
- // fix of get_home_path, used when index.php is moved outside of
516
- // wp folder.
 
 
 
517
  $pos = strripos(
518
- str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ),
519
- trailingslashit( $wp_path_rel_to_home ) );
520
- if ( $pos !== false ) {
521
- $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
 
 
522
  $home_path = trailingslashit( $home_path );
523
  } else if ( defined( 'WP_CLI' ) ) {
524
  $pos = strripos(
525
  str_replace( '\\', '/', ABSPATH ),
526
- trailingslashit( $wp_path_rel_to_home ) );
 
 
527
  if ( $pos !== false ) {
528
  $home_path = substr( ABSPATH, 0, $pos );
529
  $home_path = trailingslashit( $home_path );
@@ -534,22 +654,22 @@ class Util_Environment {
534
  return str_replace( '\\', DIRECTORY_SEPARATOR, $home_path );
535
  }
536
 
537
-
538
-
539
  /**
540
- * Returns absolute path to document root
541
- *
542
  * No trailing slash!
543
  *
 
 
544
  * @return string
545
  */
546
- static public function document_root() {
547
  static $document_root = null;
548
 
549
- if ( !is_null( $document_root ) )
550
  return $document_root;
 
551
 
552
- $c = Dispatcher::config();
553
  $docroot_fix = $c->get_boolean( 'docroot_fix.enable' );
554
 
555
  if ( $docroot_fix ) {
@@ -557,12 +677,13 @@ class Util_Environment {
557
  return $document_root;
558
  }
559
 
560
- if ( !empty( $_SERVER['SCRIPT_FILENAME'] ) &&
561
- !empty( $_SERVER['PHP_SELF'] ) ) {
562
- $script_filename = Util_Environment::normalize_path(
563
- $_SERVER['SCRIPT_FILENAME'] );
564
- $php_self = Util_Environment::normalize_path(
565
- $_SERVER['PHP_SELF'] );
 
566
  if ( substr( $script_filename, -strlen( $php_self ) ) == $php_self ) {
567
  $document_root = substr( $script_filename, 0, -strlen( $php_self ) );
568
  $document_root = realpath( $document_root );
@@ -570,13 +691,14 @@ class Util_Environment {
570
  }
571
  }
572
 
573
- if ( !empty( $_SERVER['PATH_TRANSLATED'] ) ) {
574
  $document_root = substr(
575
- Util_Environment::normalize_path( $_SERVER['PATH_TRANSLATED'] ),
576
  0,
577
- -strlen( Util_Environment::normalize_path( $_SERVER['PHP_SELF'] ) ) );
578
- } elseif ( !empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
579
- $document_root = Util_Environment::normalize_path( $_SERVER['DOCUMENT_ROOT'] );
 
580
  } else {
581
  $document_root = ABSPATH;
582
  }
@@ -596,18 +718,20 @@ class Util_Environment {
596
  *
597
  * No trailing slash!
598
  *
 
 
599
  * @return string
600
  */
601
- static public function site_root() {
602
  $site_root = ABSPATH;
603
  $site_root = realpath( $site_root );
604
- $site_root = Util_Environment::normalize_path( $site_root );
605
 
606
  return $site_root;
607
  }
608
 
609
  /**
610
- * Returns blog path
611
  *
612
  * Example:
613
  *
@@ -616,30 +740,34 @@ class Util_Environment {
616
  *
617
  * With trailing slash!
618
  *
 
 
619
  * @return string
620
  */
621
- static public function site_url_uri() {
622
- return Util_Environment::url_to_uri( site_url() ) . '/';
623
  }
624
 
625
  /**
626
- * Returns home domain
 
 
627
  *
628
  * @return string
629
  */
630
- static public function home_url_host() {
631
- $home_url = get_home_url();
632
- $parse_url = @parse_url( $home_url );
633
 
634
  if ( $parse_url && isset( $parse_url['host'] ) ) {
635
  return $parse_url['host'];
636
  }
637
 
638
- return Util_Environment::host();
639
  }
640
 
641
  /**
642
- * Returns home path
643
  *
644
  * Example:
645
  *
@@ -649,39 +777,53 @@ class Util_Environment {
649
  *
650
  * With trailing slash!
651
  *
 
 
652
  * @return string
653
  */
654
- static public function home_url_uri() {
655
- return Util_Environment::url_to_uri( get_home_url() ) . '/';
656
  }
657
 
658
- static public function network_home_url_uri() {
 
 
 
 
 
 
 
659
  $uri = network_home_url( '', 'relative' );
660
 
661
- /* There is a bug in WP where network_home_url can return
 
662
  * a non-relative URI even though scheme is set to relative.
663
  */
664
- if ( Util_Environment::is_url( $uri ) )
665
  $uri = parse_url( $uri, PHP_URL_PATH );
 
666
 
667
- if ( empty( $uri ) )
668
  return '/';
 
669
 
670
  return $uri;
671
  }
672
 
673
  /**
674
- * Returns server hostname with port
 
 
675
  *
676
  * @return string
677
  */
678
- static public function host_port() {
679
  static $host = null;
680
 
681
- if ( $host === null ) {
682
- if ( !empty( $_SERVER['HTTP_HOST'] ) ) {
683
- // HTTP_HOST sometimes is not set causing warning
684
- $host = $_SERVER['HTTP_HOST'];
685
  } else {
686
  $host = '';
687
  }
@@ -689,26 +831,36 @@ class Util_Environment {
689
 
690
  return $host;
691
  }
692
-
693
- static public function host() {
694
- $host_port = Util_Environment::host_port();
 
 
 
 
 
 
695
 
696
  $pos = strpos( $host_port, ':' );
697
- if ( $pos === false )
 
698
  return $host_port;
 
699
 
700
  return substr( $host_port, 0, $pos );
701
  }
702
 
703
  /**
704
- * Returns WP config file path
 
 
705
  *
706
  * @return string
707
  */
708
- static public function wp_config_path() {
709
  $search = array(
710
  ABSPATH . 'wp-config.php',
711
- dirname( ABSPATH ) . DIRECTORY_SEPARATOR . 'wp-config.php'
712
  );
713
 
714
  foreach ( $search as $path ) {
@@ -720,49 +872,56 @@ class Util_Environment {
720
  return false;
721
  }
722
 
723
-
724
  /**
725
- * Parses path
 
 
726
  *
727
- * @param string $path
728
  * @return mixed
729
  */
730
- static public function parse_path( $path ) {
731
- $path = str_replace( array(
 
732
  '%BLOG_ID%',
733
  '%POST_ID%',
734
  '%BLOG_ID%',
735
- '%HOST%'
736
- ), array(
 
737
  ( isset( $GLOBALS['blog_id'] ) && is_numeric( $GLOBALS['blog_id'] ) ? (int) $GLOBALS['blog_id'] : 0 ),
738
  ( isset( $GLOBALS['post_id'] ) && is_numeric( $GLOBALS['post_id'] ) ?
739
  (int) $GLOBALS['post_id'] : 0 ),
740
- Util_Environment::blog_id(),
741
- Util_Environment::host()
742
- ), $path );
 
 
743
 
744
  return $path;
745
  }
746
 
747
  /**
748
- * Normalizes file name
749
  *
750
  * Relative to site root!
751
  *
752
- * @param string $file
 
 
753
  * @return string
754
  */
755
- static public function normalize_file( $file ) {
756
- if ( Util_Environment::is_url( $file ) ) {
757
  if ( strstr( $file, '?' ) === false ) {
758
- $home_url_regexp = '~' . Util_Environment::home_url_regexp() . '~i';
759
  $file = preg_replace( $home_url_regexp, '', $file );
760
  }
761
  }
762
 
763
- if ( !Util_Environment::is_url( $file ) ) {
764
- $file = Util_Environment::normalize_path( $file );
765
- $file = str_replace( Util_Environment::site_root(), '', $file );
766
  $file = ltrim( $file, '/' );
767
  }
768
 
@@ -770,24 +929,26 @@ class Util_Environment {
770
  }
771
 
772
  /**
773
- * Normalizes file name for minify
774
  *
775
  * Relative to document root!
776
  *
 
 
777
  * @param string $file
778
  * @return string
779
  */
780
- static public function normalize_file_minify( $file ) {
781
- if ( Util_Environment::is_url( $file ) ) {
782
  if ( strstr( $file, '?' ) === false ) {
783
- $domain_url_regexp = '~' . Util_Environment::home_domain_root_url_regexp() . '~i';
784
  $file = preg_replace( $domain_url_regexp, '', $file );
785
  }
786
  }
787
 
788
- if ( !Util_Environment::is_url( $file ) ) {
789
- $file = Util_Environment::normalize_path( $file );
790
- $file = str_replace( Util_Environment::document_root(), '', $file );
791
  $file = ltrim( $file, '/' );
792
  }
793
 
@@ -795,113 +956,125 @@ class Util_Environment {
795
  }
796
 
797
  /**
798
- * Normalizes file name for minify
799
  * Relative to document root!
800
  *
801
- * @param string $file
 
 
802
  * @return string
803
  */
804
- static public function url_to_docroot_filename( $url ) {
805
  $data = array(
806
  'home_url' => get_home_url(),
807
- 'url' => $url
808
  );
 
809
  $data = apply_filters( 'w3tc_url_to_docroot_filename', $data );
810
 
811
- $home_url = $data['home_url'];
812
  $normalized_url = $data['url'];
813
- $normalized_url = Util_Environment::remove_query_all( $normalized_url );
814
 
815
- // cut protocol
816
  $normalized_url = preg_replace( '~^http(s)?://~', '//', $normalized_url );
817
- $home_url = preg_replace( '~^http(s)?://~', '//', $home_url );
818
 
819
- if ( substr( $normalized_url, 0, strlen( $home_url ) ) != $home_url ) {
820
- // not a home url, return unchanged since cant be
821
- // converted to filename
822
  return null;
823
  }
824
 
825
  $path_relative_to_home = str_replace( $home_url, '', $normalized_url );
 
 
 
826
 
827
- $home = set_url_scheme( get_option( 'home' ), 'http' );
828
- $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
829
-
830
- $home_path = rtrim( Util_Environment::site_path(), '/' );
831
- // adjust home_path if site is not is home
832
  if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
833
- // $siteurl - $home
834
  $wp_path_rel_to_home = rtrim( str_ireplace( $home, '', $siteurl ), '/' );
 
835
  if ( substr( $home_path, -strlen( $wp_path_rel_to_home ) ) ==
836
  $wp_path_rel_to_home ) {
837
  $home_path = substr( $home_path, 0, -strlen( $wp_path_rel_to_home ) );
838
  }
839
  }
840
 
841
- // common encoded characters
842
  $path_relative_to_home = str_replace( '%20', ' ', $path_relative_to_home );
843
 
844
  $full_filename = $home_path . DIRECTORY_SEPARATOR .
845
  trim( $path_relative_to_home, DIRECTORY_SEPARATOR );
846
 
847
- $docroot = Util_Environment::document_root();
 
848
  if ( substr( $full_filename, 0, strlen( $docroot ) ) == $docroot ) {
849
  $docroot_filename = substr( $full_filename, strlen( $docroot ) );
850
  } else {
851
  $docroot_filename = $path_relative_to_home;
852
  }
853
 
854
- // sometimes urls (coming from other plugins/themes)
855
- // contain multiple "/" like "my-folder//myfile.js" which
856
- // fails to recognize by filesystem, while url is accessible
 
 
857
  $docroot_filename = str_replace( '//', DIRECTORY_SEPARATOR, $docroot_filename );
858
 
859
  return ltrim( $docroot_filename, DIRECTORY_SEPARATOR );
860
  }
861
 
862
- static public function docroot_to_full_filename( $docroot_filename ) {
863
- return rtrim( Util_Environment::document_root(), DIRECTORY_SEPARATOR ) .
864
- DIRECTORY_SEPARATOR . $docroot_filename;
865
- }
866
-
867
  /**
868
- * Translates remote file to local file
869
  *
870
- * @param string $file
871
- * @return string
 
 
872
  */
873
- static public function translate_file( $file ) {
874
- return $file;
 
875
  }
876
 
877
  /**
878
- * Removes WP query string from URL
 
 
879
  */
880
- static public function remove_query( $url ) {
881
  $url = preg_replace( '~(\?|&amp;|&#038;|&)+ver=[a-z0-9-_\.]+~i', '', $url );
882
 
883
  return $url;
884
  }
885
 
886
  /**
887
- * Removes all query strings from url
 
 
 
 
 
888
  */
889
- static public function remove_query_all( $url ) {
890
  $pos = strpos( $url, '?' );
891
- if ( $pos === false )
892
  return $url;
 
893
 
894
  return substr( $url, 0, $pos );
895
  }
896
 
897
-
898
  /**
899
- * Converts win path to unix
 
 
900
  *
901
- * @param string $path
902
  * @return string
903
  */
904
- static public function normalize_path( $path ) {
905
  $path = preg_replace( '~[/\\\]+~', '/', $path );
906
  $path = rtrim( $path, '/' );
907
 
@@ -909,20 +1082,23 @@ class Util_Environment {
909
  }
910
 
911
  /**
912
- * Returns real path of given path
913
  *
914
- * @param string $path
 
 
915
  * @return string
916
  */
917
- static public function realpath( $path ) {
918
- $path = Util_Environment::normalize_path( $path );
919
- $parts = explode( '/', $path );
920
  $absolutes = array();
921
 
922
  foreach ( $parts as $part ) {
923
  if ( '.' == $part ) {
924
  continue;
925
  }
 
926
  if ( '..' == $part ) {
927
  array_pop( $absolutes );
928
  } else {
@@ -934,12 +1110,14 @@ class Util_Environment {
934
  }
935
 
936
  /**
937
- * Returns real path of given path
 
 
938
  *
939
- * @param string $path
940
  * @return string
941
  */
942
- static public function path_remove_dots( $path ) {
943
  $parts = explode( '/', $path );
944
  $absolutes = array();
945
 
@@ -958,16 +1136,19 @@ class Util_Environment {
958
  }
959
 
960
  /**
961
- * Returns full URL from relative one
 
 
 
 
 
962
  */
963
- static public function url_relative_to_full( $relative_url ) {
964
- $relative_url = Util_Environment::path_remove_dots( $relative_url );
965
 
966
- if (version_compare(PHP_VERSION, '5.4.7') < 0) {
967
- if ( substr( $relative_url, 0, 2) == '//' ) {
968
- $relative_url =
969
- ( Util_Environment::is_https() ? 'https' : 'http' ) .
970
- ':' . $relative_url;
971
  }
972
  }
973
 
@@ -993,175 +1174,223 @@ class Util_Environment {
993
  }
994
 
995
  /**
996
- * Redirects to URL
997
  *
998
- * @param string $url
999
- * @param array $params
1000
- * @return string
 
1001
  */
1002
- static public function redirect( $url = '', $params = array() ) {
1003
- $url = Util_Environment::url_format( $url, $params );
1004
- if ( function_exists( 'do_action' ) )
1005
  do_action( 'w3tc_redirect' );
 
1006
 
1007
- @header( 'Location: ' . $url );
1008
  exit();
1009
  }
1010
 
1011
  /**
1012
- * Redirects to URL
1013
  *
1014
- * @param string $url
1015
- * @param array $params
1016
  *
1017
- * @return string
 
 
1018
  */
1019
- static public function safe_redirect_temp( $url = '', $params = array(),
1020
- $safe_redirect = false ) {
1021
- $url = Util_Environment::url_format( $url, $params );
1022
  if ( function_exists( 'do_action' ) ) {
1023
  do_action( 'w3tc_redirect' );
1024
  }
1025
 
1026
  $status_code = 302;
1027
 
1028
- $protocol = $_SERVER["SERVER_PROTOCOL"];
 
 
1029
  if ( 'HTTP/1.1' === $protocol ) {
1030
  $status_code = 307;
1031
  }
1032
 
1033
  $text = get_status_header_desc( $status_code );
1034
- if ( !empty( $text ) ) {
1035
  $status_header = "$protocol $status_code $text";
1036
  @header( $status_header, true, $status_code );
1037
  }
1038
 
1039
- add_action( 'wp_safe_redirect_fallback', array(
1040
- '\W3TC\Util_Environment', 'wp_safe_redirect_fallback' ) );
 
 
1041
 
1042
- @header( 'Cache-Control: no-cache' );
1043
  wp_safe_redirect( $url, $status_code );
1044
  exit();
1045
  }
1046
 
1047
- static public function wp_safe_redirect_fallback( $url ) {
 
 
 
 
 
 
 
 
1048
  return home_url( '?w3tc_repeat=invalid' );
1049
  }
1050
 
1051
  /**
1052
- * Detects post ID
1053
  *
1054
- * @return integer
 
 
1055
  */
1056
- static public function detect_post_id() {
1057
- global $posts, $comment_post_ID, $post_ID;
 
 
1058
 
1059
  if ( $post_ID ) {
1060
  return $post_ID;
1061
- } elseif ( $comment_post_ID ) {
1062
- return $comment_post_ID;
1063
  } elseif ( ( is_single() || is_page() ) && is_array( $posts ) && isset( $posts[0]->ID ) ) {
1064
  return $posts[0]->ID;
1065
  } elseif ( isset( $posts->ID ) ) {
1066
  return $posts->ID;
1067
- } elseif ( isset( $_REQUEST['p'] ) ) {
1068
- return (integer) $_REQUEST['p'];
1069
  }
1070
 
1071
  return 0;
1072
  }
1073
 
1074
- static public function instance_id() {
 
 
 
 
 
 
 
1075
  if ( defined( 'W3TC_INSTANCE_ID' ) ) {
1076
  return W3TC_INSTANCE_ID;
1077
  }
1078
 
1079
  static $instance_id;
1080
 
1081
- if ( !isset( $instance_id ) ) {
1082
- $config = Dispatcher::config();
1083
  $instance_id = $config->get_integer( 'common.instance_id', 0 );
1084
  }
 
1085
  return $instance_id;
1086
  }
1087
 
1088
  /**
 
1089
  *
 
1090
  *
1091
- * @var Config $config
1092
  * @return string
1093
  */
1094
- static public function w3tc_edition( $config = null ) {
1095
- if ( Util_Environment::is_w3tc_pro( $config ) && Util_Environment::is_w3tc_pro_dev() )
1096
  return 'pro development';
1097
- if ( Util_Environment::is_w3tc_pro( $config ) )
 
 
1098
  return 'pro';
 
 
1099
  return 'community';
1100
  }
1101
 
1102
  /**
 
1103
  *
 
1104
  *
1105
- * @param Config $config
1106
  * @return bool
1107
  */
1108
- static public function is_w3tc_pro( $config = null ) {
1109
- if ( defined( 'W3TC_PRO' ) && W3TC_PRO )
1110
  return true;
1111
- if ( defined( 'W3TC_ENTERPRISE' ) && W3TC_ENTERPRISE )
 
 
1112
  return true;
 
1113
 
1114
  if ( is_object( $config ) ) {
1115
  $plugin_type = $config->get_string( 'plugin.type' );
1116
 
1117
- if ( $plugin_type == 'pro' || $plugin_type == 'pro_dev' )
1118
  return true;
 
1119
  }
1120
 
1121
  return false;
1122
  }
1123
 
1124
  /**
1125
- * Enable Pro Dev mode support
 
 
1126
  *
1127
  * @return bool
1128
  */
1129
- static public function is_w3tc_pro_dev() {
1130
  return defined( 'W3TC_PRO_DEV_MODE' ) && W3TC_PRO_DEV_MODE;
1131
  }
1132
 
1133
  /**
1134
- * Quotes regular expression string
 
 
1135
  *
1136
- * @param string $string
1137
- * @param string $delimiter
1138
  * @return string
1139
  */
1140
- static public function preg_quote( $string, $delimiter = '~' ) {
1141
  $string = preg_quote( $string, $delimiter );
1142
- $string = strtr( $string, array(
1143
- ' ' => '\ '
1144
- ) );
 
1145
 
1146
  return $string;
1147
  }
1148
 
1149
  /**
1150
- * Returns true if zlib output compression is enabled otherwise false
1151
  *
1152
- * @return boolean
 
 
1153
  */
1154
- static public function is_zlib_enabled() {
1155
- return Util_Environment::to_boolean( ini_get( 'zlib.output_compression' ) );
1156
  }
1157
 
1158
  /**
1159
- * Recursive strips slahes from the var
1160
  *
1161
- * @param mixed $var
 
 
1162
  * @return mixed
1163
  */
1164
- static public function stripslashes( $var ) {
1165
  if ( is_string( $var ) ) {
1166
  return stripslashes( $var );
1167
  } elseif ( is_array( $var ) ) {
@@ -1172,74 +1401,81 @@ class Util_Environment {
1172
  }
1173
 
1174
  /**
1175
- * Checks if post should be flushed or not. Returns true if it should not be flushed
 
 
1176
  *
1177
- * @param unknown $post
1178
- * @param string $module which cache module to check against (pgcache, varnish, dbcache or objectcache)
1179
- * @param Config $config
1180
  * @return bool
1181
  */
1182
- static public function is_flushable_post( $post, $module, $config ) {
1183
- if ( is_numeric( $post ) )
1184
  $post = get_post( $post );
 
 
1185
  $post_status = array( 'publish' );
1186
- // dont flush when we have post "attachment"
1187
- // its child of the post and is flushed always when post is published, while not changed in fact
 
 
 
1188
  $post_type = array( 'revision', 'attachment' );
1189
  switch ( $module ) {
1190
- case 'pgcache':
1191
- case 'varnish':
1192
- case 'posts': // means html content of post pages
1193
- if ( !$config->get_boolean( 'pgcache.reject.logged' ) )
1194
- $post_status[] = 'private';
1195
- break;
1196
- case 'dbcache':
1197
- if ( !$config->get_boolean( 'dbcache.reject.logged' ) )
1198
- $post_status[] = 'private';
1199
- break;
 
 
1200
  }
1201
 
1202
- $flushable = is_object( $post ) &&
1203
- !in_array( $post->post_type, $post_type ) &&
1204
- in_array( $post->post_status, $post_status );
1205
 
1206
  return apply_filters( 'w3tc_flushable_post', $flushable, $post, $module );
1207
  }
1208
 
1209
-
1210
-
1211
  /**
1212
- * Checks if post belongs to a custom post type
1213
  *
1214
  * @since 2.1.7
1215
- *
1216
- * @param unknown $post
1217
  *
 
1218
  * @return bool
1219
  */
1220
- static public function is_custom_post_type( $post ) {
1221
  $post_type = get_post_type_object( $post->post_type );
1222
 
1223
- // post type not found belongs to default post type(s)
1224
- if ( empty ( $post_type ) )
1225
  return false;
1226
-
1227
- // check if custom
1228
- if ( $post_type->_builtin === false )
 
1229
  return true;
 
1230
 
1231
  return false;
1232
  }
1233
 
1234
-
1235
-
1236
  /**
1237
- * Converts value to boolean
1238
  *
1239
- * @param mixed $value
1240
- * @return boolean
 
 
1241
  */
1242
- static public function to_boolean( $value ) {
1243
  if ( is_string( $value ) ) {
1244
  switch ( strtolower( $value ) ) {
1245
  case '+':
@@ -1266,21 +1502,30 @@ class Util_Environment {
1266
  }
1267
 
1268
  /**
1269
- * Returns the apache, nginx version
 
 
1270
  *
1271
  * @return string
1272
  */
1273
- static public function get_server_version() {
1274
- $sig = explode( '/', $_SERVER['SERVER_SOFTWARE'] );
1275
- $temp = isset( $sig[1] ) ? explode( ' ', $sig[1] ) : array( '0' );
 
 
 
 
1276
  $version = $temp[0];
 
1277
  return $version;
1278
  }
1279
 
1280
  /**
1281
- * Checks if current request is REST REQUEST
 
 
1282
  */
1283
- static public function is_rest_request( $url ) {
1284
  if ( defined( 'REST_REQUEST' ) && REST_REQUEST )
1285
  return true;
1286
 
@@ -1289,7 +1534,12 @@ class Util_Environment {
1289
  return preg_match( '~' . W3TC_WP_JSON_URI . '~', $url );
1290
  }
1291
 
1292
- static public function reset_microcache() {
 
 
 
 
 
1293
  global $w3_current_blog_id;
1294
  $w3_current_blog_id = null;
1295
 
1
  <?php
2
+ /**
3
+ * File: Util_Environment.php
4
+ *
5
+ * @package W3TC
6
+ */
7
+
8
  namespace W3TC;
9
 
10
+ /**
11
+ * Class: Util_Environment
12
+ */
13
  class Util_Environment {
14
  /**
15
+ * Is using ,aster config.
16
  *
17
+ * @var bool
18
+ * @static
19
+ */
20
+ private static $is_using_master_config = null;
21
+
22
+ /**
23
+ * Formats URL.
24
+ *
25
+ * @static
26
+ *
27
+ * @param string $url URL.
28
+ * @param array $params Parameters.
29
+ * @param bool $skip_empty Skip empty.
30
+ * @param string $separator Separate.
31
  * @return string
32
  */
33
+ public static function url_format( $url = '', $params = array(), $skip_empty = false, $separator = '&' ) {
34
+ if ( ! empty( $url ) ) {
35
+ $parse_url = @parse_url( $url ); // phpcs:ignore
36
+ $url = '';
 
37
 
38
+ if ( ! empty( $parse_url['scheme'] ) ) {
39
  $url .= $parse_url['scheme'] . '://';
40
 
41
+ if ( ! empty( $parse_url['user'] ) ) {
42
  $url .= $parse_url['user'];
43
 
44
+ if ( ! empty( $parse_url['pass'] ) ) {
45
  $url .= ':' . $parse_url['pass'];
46
  }
47
  }
48
 
49
+ if ( ! empty( $parse_url['host'] ) ) {
50
  $url .= $parse_url['host'];
51
  }
52
 
53
+ if ( ! empty( $parse_url['port'] ) && $parse_url['port'] != 80 ) {
54
  $url .= ':' . (int) $parse_url['port'];
55
  }
56
  }
57
 
58
+ if ( ! empty( $parse_url['path'] ) ) {
59
  $url .= $parse_url['path'];
60
  }
61
 
62
+ if ( ! empty( $parse_url['query'] ) ) {
63
  $old_params = array();
64
  parse_str( $parse_url['query'], $old_params );
65
 
66
  $params = array_merge( $old_params, $params );
67
  }
68
 
69
+ $query = self::url_query( $params );
70
 
71
+ if ( ! empty( $query ) ) {
72
  $url .= '?' . $query;
73
  }
74
 
75
+ if ( ! empty( $parse_url['fragment'] ) ) {
76
  $url .= '#' . $parse_url['fragment'];
77
  }
78
  } else {
79
+ $query = self::url_query( $params, $skip_empty, $separator );
80
 
81
+ if ( ! empty( $query ) ) {
82
  $url = '?' . $query;
83
  }
84
  }
87
  }
88
 
89
  /**
90
+ * Formats query string.
91
+ *
92
+ * @static
93
  *
94
+ * @param array $params Parameters.
95
+ * @param bool $skip_empty Skip empty.
96
+ * @param string $separator Separator.
97
  * @return string
98
  */
99
+ public static function url_query( $params = array(), $skip_empty = false, $separator = '&' ) {
100
+ $str = '';
 
101
  static $stack = array();
102
 
103
  foreach ( (array) $params as $key => $value ) {
104
+ if ( $skip_empty && empty( $value ) ) {
105
  continue;
106
  }
107
 
109
 
110
  if ( is_array( $value ) ) {
111
  if ( count( $value ) ) {
112
+ $str .= ( ! empty( $str ) ? '&' : '' ) .
113
+ self::url_query( $value, $skip_empty, $key );
114
  }
115
  } else {
116
  $name = '';
117
+
118
  foreach ( $stack as $key ) {
119
+ $name .= ( ! empty( $name ) ? '[' . $key . ']' : $key );
120
  }
121
+ $str .= ( ! empty( $str ) ? $separator : '' ) . $name . '=' . rawurlencode( $value );
122
  }
123
 
124
  array_pop( $stack );
127
  return $str;
128
  }
129
 
130
+ /**
131
+ * Returns URL from filename/dirname.
132
  *
133
+ * @static
134
+ *
135
+ * @param string $filename Filename.
136
+ * @param bool $use_site_url Use siteurl.
137
  * @return string
138
  */
139
+ public static function filename_to_url( $filename, $use_site_url = false ) {
140
+ /**
141
+ * Using wp-content instead of document_root as known dir since dirbased
142
+ * multisite wp adds blogname to the path inside site_url.
143
+ */
144
+ if ( substr( $filename, 0, strlen( WP_CONTENT_DIR ) ) !== WP_CONTENT_DIR ) {
145
  return '';
146
+ }
147
+
148
  $uri_from_wp_content = substr( $filename, strlen( WP_CONTENT_DIR ) );
149
 
150
+ if ( DIRECTORY_SEPARATOR != '/' ) {
151
+ $uri_from_wp_content = str_replace( DIRECTORY_SEPARATOR, '/', $uri_from_wp_content );
152
+ }
153
 
154
  $url = content_url( $uri_from_wp_content );
155
  $url = apply_filters( 'w3tc_filename_to_url', $url );
158
  }
159
 
160
  /**
161
+ * Returns true if database cluster is used.
162
  *
163
+ * @static
164
+ *
165
+ * @return bool
166
  */
167
+ public static function is_dbcluster() {
168
+ if ( ! defined( 'W3TC_PRO' ) || ! W3TC_PRO ) {
169
  return false;
170
+ }
171
 
172
+ if ( isset( $GLOBALS['w3tc_dbcluster_config'] ) ) {
173
  return true;
174
+ }
175
 
176
  return defined( 'W3TC_FILE_DB_CLUSTER_CONFIG' ) &&
177
+ @file_exists( W3TC_FILE_DB_CLUSTER_CONFIG ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
178
  }
179
 
180
  /**
181
+ * Returns true if WPMU uses vhosts.
182
  *
183
+ * @static
184
+ *
185
+ * @return bool
186
  */
187
+ public static function is_wpmu_subdomain() {
188
+ return (
189
+ ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) ||
190
+ ( defined( 'VHOST' ) && 'yes' === VHOST )
191
+ );
192
  }
193
 
194
  /**
195
+ * Returns if there is multisite mode.
196
  *
197
+ * @static
198
+ *
199
+ * @return bool
200
  */
201
+ public static function is_wpmu() {
202
  static $wpmu = null;
203
 
204
+ if ( null === $wpmu ) {
205
+ $wpmu = (
206
+ file_exists( ABSPATH . 'wpmu-settings.php' ) ||
207
  ( defined( 'MULTISITE' ) && MULTISITE ) ||
208
  defined( 'SUNRISE' ) ||
209
+ self::is_wpmu_subdomain()
210
+ );
211
  }
212
 
213
  return $wpmu;
214
  }
215
 
216
+ /**
217
+ * Is using master config.
218
+ *
219
+ * @static
220
+ *
221
+ * @return bool
222
+ */
223
+ public static function is_using_master_config() {
224
  if ( is_null( self::$is_using_master_config ) ) {
225
+ if ( ! self::is_wpmu() ) {
226
  self::$is_using_master_config = true;
227
  } elseif ( is_network_admin() ) {
228
  self::$is_using_master_config = true;
231
  if ( is_null( $blog_data ) ) {
232
  self::$is_using_master_config = true;
233
  } else {
234
+ self::$is_using_master_config = ( 'm' === $blog_data[0] );
235
  }
236
  }
237
  }
240
  }
241
 
242
  /**
243
+ * Returns header W3TC adds to responses powered by itself.
244
+ *
245
+ * @static
246
+ *
247
+ * @return string
248
  */
249
+ public static function w3tc_header() {
250
  return W3TC_POWERED_BY .
251
  '/' . W3TC_VERSION;
252
  }
253
 
254
  /**
255
+ * Check if URL is valid.
256
+ *
257
+ * @static
258
  *
259
+ * @param string $url URL.
260
+ * @return bool
261
  */
262
+ public static function is_url( $url ) {
263
  return preg_match( '~^(https?:)?//~', $url );
264
  }
265
 
266
  /**
267
+ * Returns true if current connection is secure.
268
  *
269
+ * @static
270
+ *
271
+ * @return bool
272
  */
273
+ public static function is_https() {
274
+ $https = isset( $_SERVER['HTTPS'] ) ?
275
+ htmlspecialchars( stripslashes( $_SERVER['HTTPS'] ) ) : ''; // phpcs:ignore
276
+ $server_port = isset( $_SERVER['SERVER_PORT'] ) ?
277
+ htmlspecialchars( stripslashes( $_SERVER['SERVER_PORT'] ) ) : ''; // phpcs:ignore
278
+ $http_x_forwarded_proto = isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ?
279
+ htmlspecialchars( stripslashes( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : ''; // phpcs:ignore
280
+
281
  switch ( true ) {
282
+ case ( self::to_boolean( $https ) ):
283
+ case ( 433 === (int) $server_port ):
284
+ case ( 'https' === $http_x_forwarded_proto ):
285
+ return true;
 
 
 
286
  }
287
 
288
  return false;
289
  }
290
 
291
  /**
292
+ * Moves user to preview-mode or opposite.
293
+ *
294
+ * @static
295
  */
296
+ public static function set_preview( $is_enabled ) {
297
+ if ( $is_enabled ) {
298
  setcookie( 'w3tc_preview', '*', 0, '/' );
299
+ } else {
300
+ setcookie( 'w3tc_preview', '', time() - 3600, '/' );
301
+ }
302
  }
303
 
304
  /**
305
+ * Retuns true if preview settings active.
306
+ *
307
+ * @static
308
  *
309
+ * @return bool
310
  */
311
+ public static function is_preview_mode() {
312
+ return ! empty( $_COOKIE['w3tc_preview'] );
313
  }
314
 
315
  /**
316
+ * Returns true if server is Apache.
317
+ *
318
+ * @static
319
  *
320
+ * @return bool
321
  */
322
+ public static function is_apache() {
323
+ // Assume apache when unknown, since most common.
324
+ if ( empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
325
  return true;
326
+ }
327
 
328
+ return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( htmlspecialchars( stripslashes( $_SERVER['SERVER_SOFTWARE'] ) ), 'Apache' ) !== false; // phpcs:ignore
329
  }
330
 
331
+
332
  /**
333
+ * Check whether server is LiteSpeed.
334
+ *
335
+ * @static
336
  *
337
  * @return bool
338
  */
339
+ public static function is_litespeed() {
340
+ return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( htmlspecialchars( stripslashes( $_SERVER['SERVER_SOFTWARE'] ) ), 'LiteSpeed' ) !== false; // phpcs:ignore
341
  }
342
 
343
  /**
344
+ * Returns true if server is nginx.
345
+ *
346
+ * @static
347
  *
348
+ * @return bool
349
  */
350
+ public static function is_nginx() {
351
+ return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( htmlspecialchars( stripslashes( $_SERVER['SERVER_SOFTWARE'] ) ), 'nginx' ) !== false; // phpcs:ignore
352
  }
353
 
354
  /**
355
+ * Returns true if server is nginx.
356
  *
357
+ * @static
358
+ *
359
+ * @return bool
360
  */
361
+ public static function is_iis() {
362
+ return isset( $_SERVER['SERVER_SOFTWARE'] ) && stristr( htmlspecialchars( stripslashes( $_SERVER['SERVER_SOFTWARE'] ) ), 'IIS' ) !== false; // phpcs:ignore
363
  }
364
 
365
  /**
366
+ * Returns host/domain from URL.
367
+ *
368
+ * @static
369
  *
370
+ * @param string $url URL.
371
  * @return string
372
  */
373
+ public static function url_to_host( $url ) {
374
+ $a = parse_url( $url ); // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url
375
+
376
+ if ( isset( $a['host'] ) ) {
377
  return $a['host'];
378
+ }
379
 
380
  return '';
381
  }
382
 
383
  /**
384
+ * Returns path from URL. Without trailing slash.
385
+ *
386
+ * @static
387
+ *
388
+ * @param string $url URL.
389
  */
390
+ public static function url_to_uri( $url ) {
391
  $uri = @parse_url( $url, PHP_URL_PATH );
392
 
393
+ // Convert FALSE and other return values to string.
394
+ if ( empty( $uri ) ) {
395
  return '';
396
+ }
397
 
398
  return rtrim( $uri, '/' );
399
  }
400
 
401
  /**
402
+ * Returns current blog ID.
403
+ *
404
+ * @static
405
  *
406
+ * @return int
407
  */
408
+ public static function blog_id() {
409
  global $w3_current_blog_id;
410
 
411
+ if ( ! is_null( $w3_current_blog_id ) ) {
412
  return $w3_current_blog_id;
413
+ }
414
 
415
+ if ( ! self::is_wpmu() || is_network_admin() ) {
416
  $w3_current_blog_id = 0;
417
  return $w3_current_blog_id;
418
  }
419
 
 
420
  $blog_data = Util_WpmuBlogmap::get_current_blog_data();
421
+
422
+ if ( ! is_null( $blog_data ) ) {
423
  $w3_current_blog_id = substr( $blog_data, 1 );
424
  } else {
425
  $w3_current_blog_id = 0;
430
 
431
  /**
432
  * Memoized version of wp_upload_dir. That function is quite slow
433
+ * for a number of times CDN calls it.
434
+ *
435
+ * @static
436
+ *
437
+ * @return string
438
  */
439
+ public static function wp_upload_dir() {
440
  static $values_by_blog = array();
441
 
442
+ $blog_id = self::blog_id();
443
+
444
+ if ( ! isset( $values_by_blog[ $blog_id ] ) )
445
+ $values_by_blog[ $blog_id ] = wp_upload_dir();
446
 
447
+ return $values_by_blog[ $blog_id ];
448
  }
449
 
450
  /**
451
+ * Returns path to section's cache dir.
452
+ *
453
+ * @static
454
  *
455
+ * @param string $section Section.
456
  * @return string
457
  */
458
+ public static function cache_dir( $section ) {
459
  return W3TC_CACHE_DIR . DIRECTORY_SEPARATOR . $section;
460
  }
461
 
462
  /**
463
+ * Returns path to blog's cache dir.
464
  *
465
+ * @static
466
+ *
467
+ * @param string $section Section.
468
+ * @param int $blog_id Blog id.
469
  * @return string
470
  */
471
+ public static function cache_blog_dir( $section, $blog_id = null ) {
472
+ if ( ! self::is_wpmu() ) {
473
  $postfix = '';
474
+ } else {
475
+ if ( is_null( $blog_id ) ) {
476
+ $blog_id = self::blog_id();
477
+ }
478
 
479
  $postfix = DIRECTORY_SEPARATOR . sprintf( '%d', $blog_id );
480
 
481
  if ( defined( 'W3TC_BLOG_LEVELS' ) ) {
482
+ for ( $n = 0; $n < W3TC_BLOG_LEVELS; $n++ ) {
483
  $postfix = DIRECTORY_SEPARATOR .
484
  substr( $postfix, strlen( $postfix ) - 1 - $n, 1 ) .
485
  $postfix;
486
+ }
487
  }
488
  }
489
 
490
+ return self::cache_dir( $section ) . $postfix;
491
  }
492
 
493
+ /**
494
+ * Cache blog minify directory.
495
+ *
496
+ * @static
497
+ *
498
+ * @return string
499
+ */
500
+ public static function cache_blog_minify_dir() {
501
  // when minify manual used with a shared config - shared
502
  // minify urls has to be used too, since CDN upload is possible
503
  // only from network admin
504
+ if ( self::is_wpmu() && self::is_using_master_config() && ! Dispatcher::config()->get_boolean( 'minify.auto' ) ) {
505
+ $path = self::cache_blog_dir( 'minify', 0 );
506
+ } else {
507
+ $path = self::cache_blog_dir( 'minify' );
508
+ }
 
509
 
510
  return $path;
511
  }
512
 
 
 
513
  /**
514
+ * Returns URL regexp from URL.
515
  *
516
+ * @static
517
+ *
518
+ * @param string $url URL.
519
  * @return string
520
  */
521
+ public static function get_url_regexp( $url ) {
522
  $url = preg_replace( '~(https?:)?//~i', '', $url );
523
  $url = preg_replace( '~^www\.~i', '', $url );
524
 
525
+ $regexp = '(https?:)?//(www\.)?' . self::preg_quote( $url );
526
 
527
  return $regexp;
528
  }
529
 
530
  /**
531
+ * Returns SSL URL if current connection is https.
532
+ *
533
+ * @static
534
  *
535
+ * @param string $url URL.
536
  * @return string
537
  */
538
+ public static function url_to_maybe_https( $url ) {
539
+ if ( self::is_https() ) {
540
  $url = str_replace( 'http://', 'https://', $url );
541
  }
542
 
544
  }
545
 
546
  /**
547
+ * Get domain URL.
548
+ *
549
+ * @static
550
  *
551
  * @return string
552
  */
553
 
554
+ public static function home_domain_root_url() {
555
+ $home_url = get_home_url();
556
+ $parse_url = @parse_url( $home_url ); // phpcs:ignore
557
 
558
  if ( $parse_url && isset( $parse_url['scheme'] ) && isset( $parse_url['host'] ) ) {
559
+ $scheme = $parse_url['scheme'];
560
+ $host = $parse_url['host'];
561
+ $port = ( isset( $parse_url['port'] ) && 80 != $parse_url['port'] ? ':' . (int) $parse_url['port'] : '' ); // phpcs:ignore
562
  $domain_url = sprintf( '%s://%s%s', $scheme, $host, $port );
563
 
564
  return $domain_url;
568
  }
569
 
570
  /**
571
+ * Returns domain url regexp.
572
+ *
573
+ * @static
574
  *
575
  * @return string
576
  */
577
+ public static function home_domain_root_url_regexp() {
578
+ $domain_url = self::home_domain_root_url();
579
+ $regexp = self::get_url_regexp( $domain_url );
580
 
581
  return $regexp;
582
  }
583
 
584
  /**
585
+ * Returns SSL home url.
586
+ *
587
+ * @static
588
  *
589
  * @return string
590
  */
591
+ public static function home_url_maybe_https() {
592
  $home_url = get_home_url();
593
+ $ssl = self::url_to_maybe_https( $home_url );
594
 
595
  return $ssl;
596
  }
597
 
598
  /**
599
+ * Returns home url regexp.
600
+ *
601
+ * @static
602
  *
603
  * @return string
604
  */
605
+ public static function home_url_regexp() {
606
  $home_url = get_home_url();
607
+ $regexp = self::get_url_regexp( $home_url );
608
 
609
  return $regexp;
610
  }
611
 
612
  /**
613
+ * Copy of WordPress get_home_path, but accessible not only for wp-admin
614
  * Get the absolute filesystem path to the root of the WordPress installation
615
+ * (i.e. filesystem path of siteurl).
616
  *
617
+ * @static
618
+ *
619
+ * @return string Full filesystem path to the root of the WordPress installation.
620
  */
621
+ public static function site_path() {
622
  $home = set_url_scheme( get_option( 'home' ), 'http' );
623
  $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
624
 
625
  $home_path = ABSPATH;
626
  if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
627
+ $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); // $siteurl - $home.
628
+
629
+ // fix of get_home_path, used when index.php is moved outside of wp folder.
630
+ $script_filename = isset( $_SERVER['SCRIPT_FILENAME'] ) ?
631
+ htmlspecialchars( stripslashes( $_SERVER['SCRIPT_FILENAME'] ) ) : ''; // phpcs:ignore
632
+
633
  $pos = strripos(
634
+ str_replace( '\\', '/', $script_filename ),
635
+ trailingslashit( $wp_path_rel_to_home )
636
+ );
637
+
638
+ if ( false !== $pos ) {
639
+ $home_path = substr( $script_filename, 0, $pos );
640
  $home_path = trailingslashit( $home_path );
641
  } else if ( defined( 'WP_CLI' ) ) {
642
  $pos = strripos(
643
  str_replace( '\\', '/', ABSPATH ),
644
+ trailingslashit( $wp_path_rel_to_home )
645
+ );
646
+
647
  if ( $pos !== false ) {
648
  $home_path = substr( ABSPATH, 0, $pos );
649
  $home_path = trailingslashit( $home_path );
654
  return str_replace( '\\', DIRECTORY_SEPARATOR, $home_path );
655
  }
656
 
 
 
657
  /**
658
+ * Returns absolute path to document root.
 
659
  * No trailing slash!
660
  *
661
+ * @static
662
+ *
663
  * @return string
664
  */
665
+ public static function document_root() {
666
  static $document_root = null;
667
 
668
+ if ( ! is_null( $document_root ) ) {
669
  return $document_root;
670
+ }
671
 
672
+ $c = Dispatcher::config();
673
  $docroot_fix = $c->get_boolean( 'docroot_fix.enable' );
674
 
675
  if ( $docroot_fix ) {
677
  return $document_root;
678
  }
679
 
680
+ if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && ! empty( $_SERVER['PHP_SELF'] ) ) {
681
+ $script_filename = self::normalize_path(
682
+ htmlspecialchars( stripslashes( $_SERVER['SCRIPT_FILENAME'] ) ) // phpcs:ignore
683
+ );
684
+ $php_self = self::normalize_path(
685
+ htmlspecialchars( stripslashes( $_SERVER['PHP_SELF'] ) ) // phpcs:ignore
686
+ );
687
  if ( substr( $script_filename, -strlen( $php_self ) ) == $php_self ) {
688
  $document_root = substr( $script_filename, 0, -strlen( $php_self ) );
689
  $document_root = realpath( $document_root );
691
  }
692
  }
693
 
694
+ if ( ! empty( $_SERVER['PATH_TRANSLATED'] ) && ! empty( $_SERVER['PHP_SELF'] ) ) {
695
  $document_root = substr(
696
+ self::normalize_path( htmlspecialchars( stripslashes( $_SERVER['PATH_TRANSLATED'] ) ) ), // phpcs:ignore
697
  0,
698
+ -strlen( self::normalize_path( htmlspecialchars( stripslashes( $_SERVER['PHP_SELF'] ) ) ) ) // phpcs:ignore
699
+ );
700
+ } elseif ( ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
701
+ $document_root = self::normalize_path( htmlspecialchars( stripslashes( $_SERVER['DOCUMENT_ROOT'] ) ) ); // phpcs:ignore
702
  } else {
703
  $document_root = ABSPATH;
704
  }
718
  *
719
  * No trailing slash!
720
  *
721
+ * @static
722
+ *
723
  * @return string
724
  */
725
+ public static function site_root() {
726
  $site_root = ABSPATH;
727
  $site_root = realpath( $site_root );
728
+ $site_root = self::normalize_path( $site_root );
729
 
730
  return $site_root;
731
  }
732
 
733
  /**
734
+ * Returns blog path.
735
  *
736
  * Example:
737
  *
740
  *
741
  * With trailing slash!
742
  *
743
+ * @static
744
+ *
745
  * @return string
746
  */
747
+ public static function site_url_uri() {
748
+ return self::url_to_uri( site_url() ) . '/';
749
  }
750
 
751
  /**
752
+ * Returns home domain.
753
+ *
754
+ * @static
755
  *
756
  * @return string
757
  */
758
+ public static function home_url_host() {
759
+ $home_url = get_home_url();
760
+ $parse_url = @parse_url( $home_url ); // phpcs:ignore
761
 
762
  if ( $parse_url && isset( $parse_url['host'] ) ) {
763
  return $parse_url['host'];
764
  }
765
 
766
+ return self::host();
767
  }
768
 
769
  /**
770
+ * Returns home path.
771
  *
772
  * Example:
773
  *
777
  *
778
  * With trailing slash!
779
  *
780
+ * @static
781
+ *
782
  * @return string
783
  */
784
+ public static function home_url_uri() {
785
+ return self::url_to_uri( get_home_url() ) . '/';
786
  }
787
 
788
+ /**
789
+ * Network home URL.
790
+ *
791
+ * @static
792
+ *
793
+ * @return string
794
+ */
795
+ public static function network_home_url_uri() {
796
  $uri = network_home_url( '', 'relative' );
797
 
798
+ /*
799
+ * There is a bug in WP where network_home_url can return
800
  * a non-relative URI even though scheme is set to relative.
801
  */
802
+ if ( self::is_url( $uri ) ) {
803
  $uri = parse_url( $uri, PHP_URL_PATH );
804
+ }
805
 
806
+ if ( empty( $uri ) ) {
807
  return '/';
808
+ }
809
 
810
  return $uri;
811
  }
812
 
813
  /**
814
+ * Returns server hostname with port.
815
+ *
816
+ * @static
817
  *
818
  * @return string
819
  */
820
+ public static function host_port() {
821
  static $host = null;
822
 
823
+ if ( null === $host ) {
824
+ if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
825
+ // HTTP_HOST sometimes is not set causing warning.
826
+ $host = htmlspecialchars( stripslashes( $_SERVER['HTTP_HOST'] ) ); // phpcs:ignore
827
  } else {
828
  $host = '';
829
  }
831
 
832
  return $host;
833
  }
834
+ /**
835
+ * Host.
836
+ *
837
+ * @static
838
+ *
839
+ * @return string
840
+ */
841
+ public static function host() {
842
+ $host_port = self::host_port();
843
 
844
  $pos = strpos( $host_port, ':' );
845
+
846
+ if ( $pos === false ) {
847
  return $host_port;
848
+ }
849
 
850
  return substr( $host_port, 0, $pos );
851
  }
852
 
853
  /**
854
+ * Returns WP config file path.
855
+ *
856
+ * @static
857
  *
858
  * @return string
859
  */
860
+ public static function wp_config_path() {
861
  $search = array(
862
  ABSPATH . 'wp-config.php',
863
+ dirname( ABSPATH ) . DIRECTORY_SEPARATOR . 'wp-config.php',
864
  );
865
 
866
  foreach ( $search as $path ) {
872
  return false;
873
  }
874
 
 
875
  /**
876
+ * Parses path.
877
+ *
878
+ * @static
879
  *
880
+ * @param string $path Path.
881
  * @return mixed
882
  */
883
+ public static function parse_path( $path ) {
884
+ $path = str_replace(
885
+ array(
886
  '%BLOG_ID%',
887
  '%POST_ID%',
888
  '%BLOG_ID%',
889
+ '%HOST%',
890
+ ),
891
+ array(
892
  ( isset( $GLOBALS['blog_id'] ) && is_numeric( $GLOBALS['blog_id'] ) ? (int) $GLOBALS['blog_id'] : 0 ),
893
  ( isset( $GLOBALS['post_id'] ) && is_numeric( $GLOBALS['post_id'] ) ?
894
  (int) $GLOBALS['post_id'] : 0 ),
895
+ self::blog_id(),
896
+ self::host(),
897
+ ),
898
+ $path
899
+ );
900
 
901
  return $path;
902
  }
903
 
904
  /**
905
+ * Normalizes file name.
906
  *
907
  * Relative to site root!
908
  *
909
+ * @static
910
+ *
911
+ * @param string $file File path.
912
  * @return string
913
  */
914
+ public static function normalize_file( $file ) {
915
+ if ( self::is_url( $file ) ) {
916
  if ( strstr( $file, '?' ) === false ) {
917
+ $home_url_regexp = '~' . self::home_url_regexp() . '~i';
918
  $file = preg_replace( $home_url_regexp, '', $file );
919
  }
920
  }
921
 
922
+ if ( ! self::is_url( $file ) ) {
923
+ $file = self::normalize_path( $file );
924
+ $file = str_replace( self::site_root(), '', $file );
925
  $file = ltrim( $file, '/' );
926
  }
927
 
929
  }
930
 
931
  /**
932
+ * Normalizes file name for minify.
933
  *
934
  * Relative to document root!
935
  *
936
+ * @static
937
+ *
938
  * @param string $file
939
  * @return string
940
  */
941
+ public static function normalize_file_minify( $file ) {
942
+ if ( self::is_url( $file ) ) {
943
  if ( strstr( $file, '?' ) === false ) {
944
+ $domain_url_regexp = '~' . self::home_domain_root_url_regexp() . '~i';
945
  $file = preg_replace( $domain_url_regexp, '', $file );
946
  }
947
  }
948
 
949
+ if ( ! self::is_url( $file ) ) {
950
+ $file = self::normalize_path( $file );
951
+ $file = str_replace( self::document_root(), '', $file );
952
  $file = ltrim( $file, '/' );
953
  }
954
 
956
  }
957
 
958
  /**
959
+ * Normalizes file name for minify.
960
  * Relative to document root!
961
  *
962
+ * @static
963
+ *
964
+ * @param string $file File path.
965
  * @return string
966
  */
967
+ public static function url_to_docroot_filename( $url ) {
968
  $data = array(
969
  'home_url' => get_home_url(),
970
+ 'url' => $url,
971
  );
972
+
973
  $data = apply_filters( 'w3tc_url_to_docroot_filename', $data );
974
 
975
+ $home_url = $data['home_url'];
976
  $normalized_url = $data['url'];
977
+ $normalized_url = self::remove_query_all( $normalized_url );
978
 
979
+ // Cut protocol.
980
  $normalized_url = preg_replace( '~^http(s)?://~', '//', $normalized_url );
981
+ $home_url = preg_replace( '~^http(s)?://~', '//', $home_url );
982
 
983
+ if ( substr( $normalized_url, 0, strlen( $home_url ) ) !== $home_url ) {
984
+ // Not a home url, return unchanged since cant be converted to filename.
 
985
  return null;
986
  }
987
 
988
  $path_relative_to_home = str_replace( $home_url, '', $normalized_url );
989
+ $home = set_url_scheme( get_option( 'home' ), 'http' );
990
+ $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
991
+ $home_path = rtrim( Util_Environment::site_path(), '/' );
992
 
993
+ // Adjust home_path if site is not is home.
 
 
 
 
994
  if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
995
+ // $siteurl - $home/
996
  $wp_path_rel_to_home = rtrim( str_ireplace( $home, '', $siteurl ), '/' );
997
+
998
  if ( substr( $home_path, -strlen( $wp_path_rel_to_home ) ) ==
999
  $wp_path_rel_to_home ) {
1000
  $home_path = substr( $home_path, 0, -strlen( $wp_path_rel_to_home ) );
1001
  }
1002
  }
1003
 
1004
+ // Common encoded characters.
1005
  $path_relative_to_home = str_replace( '%20', ' ', $path_relative_to_home );
1006
 
1007
  $full_filename = $home_path . DIRECTORY_SEPARATOR .
1008
  trim( $path_relative_to_home, DIRECTORY_SEPARATOR );
1009
 
1010
+ $docroot = self::document_root();
1011
+
1012
  if ( substr( $full_filename, 0, strlen( $docroot ) ) == $docroot ) {
1013
  $docroot_filename = substr( $full_filename, strlen( $docroot ) );
1014
  } else {
1015
  $docroot_filename = $path_relative_to_home;
1016
  }
1017
 
1018
+ /*
1019
+ * Sometimes urls (coming from other plugins/themes)
1020
+ * contain multiple "/" like "my-folder//myfile.js" which
1021
+ * fails to recognize by filesystem, while url is accessible.
1022
+ */
1023
  $docroot_filename = str_replace( '//', DIRECTORY_SEPARATOR, $docroot_filename );
1024
 
1025
  return ltrim( $docroot_filename, DIRECTORY_SEPARATOR );
1026
  }
1027
 
 
 
 
 
 
1028
  /**
1029
+ * Document root to full filename.
1030
  *
1031
+ * @static
1032
+ *
1033
+ * @param string $docroot_filename Document filename.
1034
+ * @return strin
1035
  */
1036
+ public static function docroot_to_full_filename( $docroot_filename ) {
1037
+ return rtrim( Util_Environment::document_root(), DIRECTORY_SEPARATOR ) .
1038
+ DIRECTORY_SEPARATOR . $docroot_filename;
1039
  }
1040
 
1041
  /**
1042
+ * Removes WP query string from URL.
1043
+ *
1044
+ * @static
1045
  */
1046
+ public static function remove_query( $url ) {
1047
  $url = preg_replace( '~(\?|&amp;|&#038;|&)+ver=[a-z0-9-_\.]+~i', '', $url );
1048
 
1049
  return $url;
1050
  }
1051
 
1052
  /**
1053
+ * Removes all query strings from url.
1054
+ *
1055
+ * @static
1056
+ *
1057
+ * @param string $url URL.
1058
+ * @return string
1059
  */
1060
+ public static function remove_query_all( $url ) {
1061
  $pos = strpos( $url, '?' );
1062
+ if ( $pos === false ) {
1063
  return $url;
1064
+ }
1065
 
1066
  return substr( $url, 0, $pos );
1067
  }
1068
 
 
1069
  /**
1070
+ * Converts win path to unix.
1071
+ *
1072
+ * @static
1073
  *
1074
+ * @param string $path Path.
1075
  * @return string
1076
  */
1077
+ public static function normalize_path( $path ) {
1078
  $path = preg_replace( '~[/\\\]+~', '/', $path );
1079
  $path = rtrim( $path, '/' );
1080
 
1082
  }
1083
 
1084
  /**
1085
+ * Returns real path of given path.
1086
  *
1087
+ * @static
1088
+ *
1089
+ * @param string $path Path.
1090
  * @return string
1091
  */
1092
+ public static function realpath( $path ) {
1093
+ $path = self::normalize_path( $path );
1094
+ $parts = explode( '/', $path );
1095
  $absolutes = array();
1096
 
1097
  foreach ( $parts as $part ) {
1098
  if ( '.' == $part ) {
1099
  continue;
1100
  }
1101
+
1102
  if ( '..' == $part ) {
1103
  array_pop( $absolutes );
1104
  } else {
1110
  }
1111
 
1112
  /**
1113
+ * Returns real path of given path.
1114
+ *
1115
+ * @static
1116
  *
1117
+ * @param string $path Path.
1118
  * @return string
1119
  */
1120
+ public static function path_remove_dots( $path ) {
1121
  $parts = explode( '/', $path );
1122
  $absolutes = array();
1123
 
1136
  }
1137
 
1138
  /**
1139
+ * Returns full URL from relative one.
1140
+ *
1141
+ * @static
1142
+ *
1143
+ * @param string $relative_url Relative URL.
1144
+ * @return string
1145
  */
1146
+ public static function url_relative_to_full( $relative_url ) {
1147
+ $relative_url = self::path_remove_dots( $relative_url );
1148
 
1149
+ if ( version_compare( PHP_VERSION, '5.4.7' ) < 0 ) {
1150
+ if ( substr( $relative_url, 0, 2 ) === '//' ) {
1151
+ $relative_url = ( self::is_https() ? 'https' : 'http' ) . ':' . $relative_url;
 
 
1152
  }
1153
  }
1154
 
1174
  }
1175
 
1176
  /**
1177
+ * Redirects to URL.
1178
  *
1179
+ * @static
1180
+ *
1181
+ * @param string $url URL.
1182
+ * @param array $params Parameters.
1183
  */
1184
+ public static function redirect( $url = '', $params = array() ) {
1185
+ $url = self::url_format( $url, $params );
1186
+ if ( function_exists( 'do_action' ) ) {
1187
  do_action( 'w3tc_redirect' );
1188
+ }
1189
 
1190
+ @header( 'Location: ' . $url ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
1191
  exit();
1192
  }
1193
 
1194
  /**
1195
+ * Redirects to URL.
1196
  *
1197
+ * @static
 
1198
  *
1199
+ * @param string $url URL.
1200
+ * @param array $params Parameters.
1201
+ * @param bool $safe_redirect Safe redirect or not.
1202
  */
1203
+ public static function safe_redirect_temp( $url = '', $params = array(), $safe_redirect = false ) {
1204
+ $url = self::url_format( $url, $params );
1205
+
1206
  if ( function_exists( 'do_action' ) ) {
1207
  do_action( 'w3tc_redirect' );
1208
  }
1209
 
1210
  $status_code = 302;
1211
 
1212
+ $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ?
1213
+ htmlspecialchars( stripslashes( $_SERVER['SERVER_PROTOCOL'] ) ) : ''; // phpcs:ignore
1214
+
1215
  if ( 'HTTP/1.1' === $protocol ) {
1216
  $status_code = 307;
1217
  }
1218
 
1219
  $text = get_status_header_desc( $status_code );
1220
+ if ( ! empty( $text ) ) {
1221
  $status_header = "$protocol $status_code $text";
1222
  @header( $status_header, true, $status_code );
1223
  }
1224
 
1225
+ add_action(
1226
+ 'wp_safe_redirect_fallback',
1227
+ array( '\W3TC\Util_Environment', 'wp_safe_redirect_fallback' )
1228
+ );
1229
 
1230
+ @header( 'Cache-Control: no-cache' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
1231
  wp_safe_redirect( $url, $status_code );
1232
  exit();
1233
  }
1234
 
1235
+ /**
1236
+ * Fallback for wp_sfe_redirect().
1237
+ *
1238
+ * @static
1239
+ *
1240
+ * @param string $url URL.
1241
+ * @return string
1242
+ */
1243
+ public static function wp_safe_redirect_fallback( $url ) {
1244
  return home_url( '?w3tc_repeat=invalid' );
1245
  }
1246
 
1247
  /**
1248
+ * Detects post ID.
1249
  *
1250
+ * @static
1251
+ *
1252
+ * @return int
1253
  */
1254
+ public static function detect_post_id() {
1255
+ global $posts, $comment_post_ID, $post_ID; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
1256
+
1257
+ $p_val = Util_Request::get_integer( 'p' );
1258
 
1259
  if ( $post_ID ) {
1260
  return $post_ID;
1261
+ } elseif ( $comment_post_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
1262
+ return $comment_post_ID; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
1263
  } elseif ( ( is_single() || is_page() ) && is_array( $posts ) && isset( $posts[0]->ID ) ) {
1264
  return $posts[0]->ID;
1265
  } elseif ( isset( $posts->ID ) ) {
1266
  return $posts->ID;
1267
+ } elseif ( ! empty( $p_val ) ) {
1268
+ return $p_val;
1269
  }
1270
 
1271
  return 0;
1272
  }
1273
 
1274
+ /**
1275
+ * Get W3TC instance id.
1276
+ *
1277
+ * @static
1278
+ *
1279
+ * @return int
1280
+ */
1281
+ public static function instance_id() {
1282
  if ( defined( 'W3TC_INSTANCE_ID' ) ) {
1283
  return W3TC_INSTANCE_ID;
1284
  }
1285
 
1286
  static $instance_id;
1287
 
1288
+ if ( ! isset( $instance_id ) ) {
1289
+ $config = Dispatcher::config();
1290
  $instance_id = $config->get_integer( 'common.instance_id', 0 );
1291
  }
1292
+
1293
  return $instance_id;
1294
  }
1295
 
1296
  /**
1297
+ * Get W3TC edition.
1298
  *
1299
+ * @static
1300
  *
1301
+ * @param Config $config Config.
1302
  * @return string
1303
  */
1304
+ public static function w3tc_edition( $config = null ) {
1305
+ if ( self::is_w3tc_pro( $config ) && self::is_w3tc_pro_dev() ) {
1306
  return 'pro development';
1307
+ }
1308
+
1309
+ if ( self::is_w3tc_pro( $config ) ) {
1310
  return 'pro';
1311
+ }
1312
+
1313
  return 'community';
1314
  }
1315
 
1316
  /**
1317
+ * Is W3TC Pro.
1318
  *
1319
+ * @static
1320
  *
1321
+ * @param Config $config Config.
1322
  * @return bool
1323
  */
1324
+ public static function is_w3tc_pro( $config = null ) {
1325
+ if ( defined( 'W3TC_PRO' ) && W3TC_PRO ) {
1326
  return true;
1327
+ }
1328
+
1329
+ if ( defined( 'W3TC_ENTERPRISE' ) && W3TC_ENTERPRISE ) {
1330
  return true;
1331
+ }
1332
 
1333
  if ( is_object( $config ) ) {
1334
  $plugin_type = $config->get_string( 'plugin.type' );
1335
 
1336
+ if ( 'pro' === $plugin_type || 'pro_dev' === $plugin_type ) {
1337
  return true;
1338
+ }
1339
  }
1340
 
1341
  return false;
1342
  }
1343
 
1344
  /**
1345
+ * Enable Pro Dev mode support.
1346
+ *
1347
+ * @static
1348
  *
1349
  * @return bool
1350
  */
1351
+ public static function is_w3tc_pro_dev() {
1352
  return defined( 'W3TC_PRO_DEV_MODE' ) && W3TC_PRO_DEV_MODE;
1353
  }
1354
 
1355
  /**
1356
+ * Quotes regular expression string.
1357
+ *
1358
+ * @static
1359
  *
1360
+ * @param string $string String.
1361
+ * @param string $delimiter Delimeter.
1362
  * @return string
1363
  */
1364
+ public static function preg_quote( $string, $delimiter = '~' ) {
1365
  $string = preg_quote( $string, $delimiter );
1366
+ $string = strtr(
1367
+ $string,
1368
+ array( ' ' => '\ ' )
1369
+ );
1370
 
1371
  return $string;
1372
  }
1373
 
1374
  /**
1375
+ * Returns true if zlib output compression is enabled otherwise false.
1376
  *
1377
+ * @static
1378
+ *
1379
+ * @return bool
1380
  */
1381
+ public static function is_zlib_enabled() {
1382
+ return self::to_boolean( ini_get( 'zlib.output_compression' ) );
1383
  }
1384
 
1385
  /**
1386
+ * Recursive strips slahes from the var.
1387
  *
1388
+ * @static
1389
+ *
1390
+ * @param mixed $var Value.
1391
  * @return mixed
1392
  */
1393
+ public static function stripslashes( $var ) {
1394
  if ( is_string( $var ) ) {
1395
  return stripslashes( $var );
1396
  } elseif ( is_array( $var ) ) {
1401
  }
1402
 
1403
  /**
1404
+ * Checks if post should be flushed or not. Returns true if it should not be flushed.
1405
+ *
1406
+ * @static
1407
  *
1408
+ * @param object $post Post object.
1409
+ * @param string $module Which cache module to check against (pgcache, varnish, dbcache or objectcache).
1410
+ * @param Config $config Config.
1411
  * @return bool
1412
  */
1413
+ public static function is_flushable_post( $post, $module, $config ) {
1414
+ if ( is_numeric( $post ) ) {
1415
  $post = get_post( $post );
1416
+ }
1417
+
1418
  $post_status = array( 'publish' );
1419
+
1420
+ /**
1421
+ * Dont flush when we have post "attachment"
1422
+ * its child of the post and is flushed always when post is published, while not changed in fact.
1423
+ */
1424
  $post_type = array( 'revision', 'attachment' );
1425
  switch ( $module ) {
1426
+ case 'pgcache':
1427
+ case 'varnish':
1428
+ case 'posts': // Means html content of post pages.
1429
+ if ( ! $config->get_boolean( 'pgcache.reject.logged' ) ) {
1430
+ $post_status[] = 'private';
1431
+ }
1432
+ break;
1433
+ case 'dbcache':
1434
+ if ( ! $config->get_boolean( 'dbcache.reject.logged' ) ) {
1435
+ $post_status[] = 'private';
1436
+ }
1437
+ break;
1438
  }
1439
 
1440
+ $flushable = is_object( $post ) && ! in_array( $post->post_type, $post_type, true ) && in_array( $post->post_status, $post_status, true );
 
 
1441
 
1442
  return apply_filters( 'w3tc_flushable_post', $flushable, $post, $module );
1443
  }
1444
 
 
 
1445
  /**
1446
+ * Checks if post belongs to a custom post type.
1447
  *
1448
  * @since 2.1.7
1449
+ * @static
 
1450
  *
1451
+ * @param object $post Post object.
1452
  * @return bool
1453
  */
1454
+ public static function is_custom_post_type( $post ) {
1455
  $post_type = get_post_type_object( $post->post_type );
1456
 
1457
+ // post type not found belongs to default post type(s).
1458
+ if ( empty( $post_type ) ) {
1459
  return false;
1460
+ }
1461
+
1462
+ // check if custom.
1463
+ if ( false === $post_type->_builtin ) {
1464
  return true;
1465
+ }
1466
 
1467
  return false;
1468
  }
1469
 
 
 
1470
  /**
1471
+ * Converts value to boolean.
1472
  *
1473
+ * @static
1474
+ *
1475
+ * @param mixed $value Value.
1476
+ * @return bool
1477
  */
1478
+ public static function to_boolean( $value ) {
1479
  if ( is_string( $value ) ) {
1480
  switch ( strtolower( $value ) ) {
1481
  case '+':
1502
  }
1503
 
1504
  /**
1505
+ * Returns the apache, nginx version.
1506
+ *
1507
+ * @static
1508
  *
1509
  * @return string
1510
  */
1511
+ public static function get_server_version() {
1512
+ $sig = explode(
1513
+ '/',
1514
+ isset( $_SERVER['SERVER_SOFTWARE'] ) ?
1515
+ htmlspecialchars( stripslashes( $_SERVER['SERVER_SOFTWARE'] ) ) : '' // phpcs:ignore
1516
+ );
1517
+ $temp = isset( $sig[1] ) ? explode( ' ', $sig[1] ) : array( '0' );
1518
  $version = $temp[0];
1519
+
1520
  return $version;
1521
  }
1522
 
1523
  /**
1524
+ * Checks if current request is REST REQUEST.
1525
+ *
1526
+ * @static
1527
  */
1528
+ public static function is_rest_request( $url ) {
1529
  if ( defined( 'REST_REQUEST' ) && REST_REQUEST )
1530
  return true;
1531
 
1534
  return preg_match( '~' . W3TC_WP_JSON_URI . '~', $url );
1535
  }
1536
 
1537
+ /**
1538
+ * Reset microcache.
1539
+ *
1540
+ * @static
1541
+ */
1542
+ public static function reset_microcache() {
1543
  global $w3_current_blog_id;
1544
  $w3_current_blog_id = null;
1545
 
Util_PageUrls.php CHANGED
@@ -61,7 +61,7 @@ class Util_PageUrls {
61
  * Returns all urls related to a custom post type post
62
  *
63
  * @since 2.1.7
64
- *
65
  * @param unknown $post_id
66
  * @param int $limit_post_pages default is 10
67
  * @return array
@@ -74,8 +74,8 @@ class Util_PageUrls {
74
  $full_urls = array();
75
  $post_type = $post->post_type;
76
  $archive_link = get_post_type_archive_link($post_type);
77
- $posts_page_uri = str_replace( home_url(), '', $archive_link );
78
-
79
  if ( $posts_page_uri ) {
80
  $full_urls[] = $archive_link;
81
  $full_urls = array_merge( $full_urls, self::get_older_pages( $posts_page_uri, $limit_post_pages, $post_type ) );
@@ -83,9 +83,9 @@ class Util_PageUrls {
83
 
84
  $cpt_archive_urls[$limit_post_pages] = $full_urls;
85
  }
86
-
87
  return $cpt_archive_urls[$limit_post_pages];
88
- }
89
 
90
  /**
91
  * Return older pages listing posts
@@ -484,8 +484,8 @@ class Util_PageUrls {
484
  * @param int $pagenum
485
  * @return string
486
  */
487
- static public function get_pagenum_link( $url, $pagenum = 1 ) {
488
- $request_uri = $_SERVER['REQUEST_URI'];
489
  $_SERVER['REQUEST_URI'] = $url;
490
 
491
  if ( is_admin() ) {
61
  * Returns all urls related to a custom post type post
62
  *
63
  * @since 2.1.7
64
+ *
65
  * @param unknown $post_id
66
  * @param int $limit_post_pages default is 10
67
  * @return array
74
  $full_urls = array();
75
  $post_type = $post->post_type;
76
  $archive_link = get_post_type_archive_link($post_type);
77
+ $posts_page_uri = str_replace( home_url(), '', $archive_link );
78
+
79
  if ( $posts_page_uri ) {
80
  $full_urls[] = $archive_link;
81
  $full_urls = array_merge( $full_urls, self::get_older_pages( $posts_page_uri, $limit_post_pages, $post_type ) );
83
 
84
  $cpt_archive_urls[$limit_post_pages] = $full_urls;
85
  }
86
+
87
  return $cpt_archive_urls[$limit_post_pages];
88
+ }
89
 
90
  /**
91
  * Return older pages listing posts
484
  * @param int $pagenum
485
  * @return string
486
  */
487
+ public static function get_pagenum_link( $url, $pagenum = 1 ) {
488
+ $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
489
  $_SERVER['REQUEST_URI'] = $url;
490
 
491
  if ( is_admin() ) {
Util_Request.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  namespace W3TC;
3
 
4
  /**
@@ -6,21 +12,21 @@ namespace W3TC;
6
  */
7
 
8
  /**
9
- * class Request
10
  */
11
  class Util_Request {
12
  /**
13
  * Returns request value
14
  *
15
- * @param string $key
16
- * @param mixed $default
17
  * @return mixed
18
  */
19
- static function get( $key, $default = null ) {
20
- $request = Util_Request::get_request();
21
 
22
- if ( isset( $request[$key] ) ) {
23
- $value = $request[$key];
24
 
25
  if ( defined( 'TEMPLATEPATH' ) ) {
26
  $value = Util_Environment::stripslashes( $value );
@@ -35,68 +41,75 @@ class Util_Request {
35
  /**
36
  * Returns string value
37
  *
38
- * @param string $key
39
- * @param string $default
40
- * @param boolean $trim
41
  * @return string
42
  */
43
- static function get_string( $key, $default = '', $trim = true ) {
44
- $value = (string) Util_Request::get( $key, $default );
45
 
46
  return ( $trim ) ? trim( $value ) : $value;
47
  }
48
 
49
- static function get_label( $key, $default = '' ) {
50
- $v = self::get_string( $key, $default);
51
- return preg_replace('/[^A-Za-z0-9_\\-]/', '', $v);
 
 
 
 
 
 
 
52
  }
53
 
54
  /**
55
- * Returns integer value
56
  *
57
- * @param string $key
58
- * @param integer $default
59
- * @return integer
60
  */
61
- static function get_integer( $key, $default = 0 ) {
62
- return (integer) Util_Request::get( $key, $default );
63
  }
64
 
65
  /**
66
- * Returns double value
67
  *
68
- * @param string $key
69
- * @param double|float $default
70
  * @return double
71
  */
72
- static function get_double( $key, $default = 0. ) {
73
- return (double) Util_Request::get( $key, $default );
74
  }
75
 
76
  /**
77
- * Returns boolean value
78
  *
79
- * @param string $key
80
- * @param boolean $default
81
- * @return boolean
82
  */
83
- static function get_boolean( $key, $default = false ) {
84
- return Util_Environment::to_boolean( Util_Request::get( $key, $default ) );
85
  }
86
 
87
  /**
88
- * Returns array value
89
  *
90
- * @param string $key
91
- * @param array $default
92
  * @return array
93
  */
94
- static function get_array( $key, $default = array() ) {
95
- $value = Util_Request::get( $key );
96
 
97
  if ( is_array( $value ) ) {
98
  return $value;
99
- } elseif ( $value != '' ) {
100
  return preg_split( "/[\r\n,;]+/", trim( $value ) );
101
  }
102
 
@@ -104,37 +117,38 @@ class Util_Request {
104
  }
105
 
106
  /**
107
- * Returns array value
108
  *
109
- * @param string $prefix
110
- * @param array $default
111
  * @return array
112
  */
113
- static function get_as_array( $prefix, $default = array() ) {
114
- $request = Util_Request::get_request();
115
- $array = array();
 
116
  foreach ( $request as $key => $value ) {
117
  if ( strpos( $key, $prefix ) === 0 || strpos( $key, str_replace( '.', '_', $prefix ) ) === 0 ) {
118
- $array[substr( $key, strlen( $prefix ) )] = $value;
119
  }
120
  }
121
  return $array;
122
  }
123
 
124
  /**
125
- * Returns request array
126
  *
127
  * @return array
128
  */
129
- static function get_request() {
130
- if ( !isset( $_GET ) ) {
131
  $_GET = array();
132
  }
133
 
134
- if ( !isset( $_POST ) ) {
135
  $_POST = array();
136
  }
137
 
138
- return array_merge( $_GET, $_POST );
139
  }
140
  }
1
  <?php
2
+ /**
3
+ * File: Util_Request.php
4
+ *
5
+ * @package W3TC
6
+ */
7
+
8
  namespace W3TC;
9
 
10
  /**
12
  */
13
 
14
  /**
15
+ * Class: Util_Request
16
  */
17
  class Util_Request {
18
  /**
19
  * Returns request value
20
  *
21
+ * @param string $key Key.
22
+ * @param mixed $default Default value.
23
  * @return mixed
24
  */
25
+ public static function get( $key, $default = null ) {
26
+ $request = self::get_request();
27
 
28
+ if ( isset( $request[ $key ] ) ) {
29
+ $value = $request[ $key ];
30
 
31
  if ( defined( 'TEMPLATEPATH' ) ) {
32
  $value = Util_Environment::stripslashes( $value );
41
  /**
42
  * Returns string value
43
  *
44
+ * @param string $key Key.
45
+ * @param string $default Default value.
46
+ * @param bool $trim Trim.
47
  * @return string
48
  */
49
+ public static function get_string( $key, $default = '', $trim = true ) {
50
+ $value = (string) self::get( $key, $default );
51
 
52
  return ( $trim ) ? trim( $value ) : $value;
53
  }
54
 
55
+ /**
56
+ * Get label.
57
+ *
58
+ * @param string $key Key.
59
+ * @param string $default Default value.
60
+ * @return string
61
+ */
62
+ public static function get_label( $key, $default = '' ) {
63
+ $v = self::get_string( $key, $default );
64
+ return preg_replace( '/[^A-Za-z0-9_\\-]/', '', $v );
65
  }
66
 
67
  /**
68
+ * Returns integer value.
69
  *
70
+ * @param string $key Key.
71
+ * @param int $default Default value.
72
+ * @return int
73
  */
74
+ public static function get_integer( $key, $default = 0 ) {
75
+ return (int) self::get( $key, $default );
76
  }
77
 
78
  /**
79
+ * Returns double value.
80
  *
81
+ * @param string $key Key.
82
+ * @param double|float $default Default value.
83
  * @return double
84
  */
85
+ public static function get_double( $key, $default = 0. ) {
86
+ return (double) self::get( $key, $default ); // phpcs:ignore WordPress.PHP.TypeCasts.DoubleRealFound
87
  }
88
 
89
  /**
90
+ * Returns boolean value.
91
  *
92
+ * @param string $key Key.
93
+ * @param bool $default Default value.
94
+ * @return bool
95
  */
96
+ public static function get_boolean( $key, $default = false ) {
97
+ return Util_Environment::to_boolean( self::get( $key, $default ) );
98
  }
99
 
100
  /**
101
+ * Returns array value.
102
  *
103
+ * @param string $key Key.
104
+ * @param array $default Default value.
105
  * @return array
106
  */
107
+ public static function get_array( $key, $default = array() ) {
108
+ $value = self::get( $key );
109
 
110
  if ( is_array( $value ) ) {
111
  return $value;
112
+ } elseif ( ! empty( $value ) ) {
113
  return preg_split( "/[\r\n,;]+/", trim( $value ) );
114
  }
115
 
117
  }
118
 
119
  /**
120
+ * Returns array value.
121
  *
122
+ * @param string $prefix Prefix.
123
+ * @param array $default Default value.
124
  * @return array
125
  */
126
+ public static function get_as_array( $prefix, $default = array() ) {
127
+ $request = self::get_request();
128
+ $array = array();
129
+
130
  foreach ( $request as $key => $value ) {
131
  if ( strpos( $key, $prefix ) === 0 || strpos( $key, str_replace( '.', '_', $prefix ) ) === 0 ) {
132
+ $array[ substr( $key, strlen( $prefix ) ) ] = $value;
133
  }
134
  }
135
  return $array;
136
  }
137
 
138
  /**
139
+ * Returns request array.
140
  *
141
  * @return array
142
  */
143
+ public static function get_request() {
144
+ if ( ! isset( $_GET ) ) {
145
  $_GET = array();
146
  }
147
 
148
+ if ( ! isset( $_POST ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
149
  $_POST = array();
150
  }
151
 
152
+ return array_merge( $_GET, $_POST ); // phpcs:ignore
153
  }
154
  }
Util_Rule.php CHANGED
@@ -328,8 +328,11 @@ class Util_Rule {
328
 
329
  if ( !@file_put_contents( $path, $data ) ) {
330
  try {
331
- Util_WpFile::delete_folder( dirname( $path ), '',
332
- $_SERVER['REQUEST_URI'] );
 
 
 
333
  } catch ( Util_WpFile_FilesystemOperationException $ex ) {
334
  $exs->push( $ex );
335
  return;
@@ -424,18 +427,20 @@ class Util_Rule {
424
  }
425
 
426
  /**
427
- * Support for GoDaddy servers configuration which uses
428
- * SUBDOMAIN_DOCUMENT_ROOT variable
429
  */
430
- static public function apache_docroot_variable() {
431
- if ( isset( $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] ) &&
432
- $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] != $_SERVER['DOCUMENT_ROOT'] )
 
 
433
  return '%{ENV:SUBDOMAIN_DOCUMENT_ROOT}';
434
- elseif ( isset( $_SERVER['PHP_DOCUMENT_ROOT'] ) &&
435
- $_SERVER['PHP_DOCUMENT_ROOT'] != $_SERVER['DOCUMENT_ROOT'] )
436
  return '%{ENV:PHP_DOCUMENT_ROOT}';
437
- else
438
  return '%{DOCUMENT_ROOT}';
 
439
  }
440
 
441
 
328
 
329
  if ( !@file_put_contents( $path, $data ) ) {
330
  try {
331
+ Util_WpFile::delete_folder(
332
+ dirname( $path ),
333
+ '',
334
+ isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''
335
+ );
336
  } catch ( Util_WpFile_FilesystemOperationException $ex ) {
337
  $exs->push( $ex );
338
  return;
427
  }
428
 
429
  /**
430
+ * Support for GoDaddy servers configuration which uses.
431
+ * SUBDOMAIN_DOCUMENT_ROOT variable.
432
  */
433
+ public static function apache_docroot_variable() {
434
+ $document_root = isset( $_SERVER['DOCUMENT_ROOT'] ) ? esc_url_raw( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) : '';
435
+ $subdomain_document_root = isset( $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] ) ? esc_url_raw( wp_unslash( $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] ) ) : '';
436
+ $php_document_root = isset( $_SERVER['PHP_DOCUMENT_ROOT'] ) ? esc_url_raw( wp_unslash( $_SERVER['PHP_DOCUMENT_ROOT'] ) ) : '';
437
+ if ( ! empty( $subdomain_document_root ) && $subdomain_document_root !== $document_root ) {
438
  return '%{ENV:SUBDOMAIN_DOCUMENT_ROOT}';
439
+ } elseif ( ! empty( $php_document_root ) && $php_document_root !== $document_root ) {
 
440
  return '%{ENV:PHP_DOCUMENT_ROOT}';
441
+ } else {
442
  return '%{DOCUMENT_ROOT}';
443
+ }
444
  }
445
 
446
 
Util_Ui.php CHANGED
@@ -1,34 +1,36 @@
1
  <?php
2
  namespace W3TC;
3
 
 
 
4
  class Util_Ui {
5
  /**
6
  * Returns button html
7
  *
8
- * @param string $text
9
- * @param string $onclick
10
- * @param string $class
11
  * @return string
12
  */
13
- static public function button( $text, $onclick = '', $class = 'button',
14
  $name = '' ) {
15
- $maybe_name = ( empty( $name ) ? '' :
16
- ' name="' . htmlspecialchars( $name ) . '"' );
17
  return '<input type="button"' . $maybe_name . ' class="' .
18
- htmlspecialchars( $class ) . '" value="' . htmlspecialchars( $text ) .
19
- '" onclick="' . htmlspecialchars( $onclick ) . '" />';
20
  }
21
 
22
  /**
23
- * Returns button link html
24
  *
25
- * @param string $text
26
- * @param string $url
27
- * @param boolean $new_window
 
 
28
  * @return string
29
  */
30
- static public function button_link( $text, $url, $new_window = false,
31
- $class = 'button', $name = '' ) {
32
  $url = str_replace( '&amp;', '&', $url );
33
 
34
  if ( $new_window ) {
@@ -36,23 +38,25 @@ class Util_Ui {
36
  } else {
37
  $onclick = '';
38
 
39
- if ( strpos( $class, 'w3tc-button-ignore-change' ) >= 0 )
40
  $onclick .= 'w3tc_beforeupload_unbind(); ';
 
41
 
42
  $onclick .= sprintf( 'document.location.href=\'%s\';', addslashes( $url ) );
43
  }
44
 
45
- return Util_Ui::button( $text, $onclick, $class, $name );
46
  }
47
 
48
- static public function url( $addon ) {
49
- if ( !isset( $addon['page'] ) )
50
  $addon['page'] = Util_Request::get_string( 'page', 'w3tc_dashboard' );
 
51
 
52
  $url = 'admin.php';
53
  $amp = '?';
54
  foreach ( $addon as $key => $value ) {
55
- $url .= $amp . urlencode( $key ) . '=' . urlencode( $value );
56
  $amp = '&';
57
  }
58
 
@@ -67,44 +71,46 @@ class Util_Ui {
67
  * @param string $text
68
  * @param string $note
69
  * @param string $redirect
70
- * @param boolean $admin if to use config admin
71
  * @param string $page
72
  * @param string $custom_method
73
  * @return string
74
  */
75
- static public function button_hide_note( $text, $note, $redirect = '',
76
  $admin = false, $page = '',
77
  $custom_method = 'w3tc_default_hide_note' ) {
78
- if ( $page == '' ) {
79
  $page = Util_Request::get_string( 'page', 'w3tc_dashboard' );
80
  }
81
 
82
  $url = sprintf( 'admin.php?page=%s&%s&note=%s', $page, $custom_method, $note );
83
 
84
- if ( $admin )
85
  $url .= '&admin=1';
 
86
 
87
- if ( $redirect != '' ) {
88
- $url .= '&redirect=' . urlencode( $redirect );
89
  }
90
 
91
  $url = wp_nonce_url( $url, 'w3tc' );
92
 
93
- return Util_Ui::button_link( $text, $url, false, 'button',
94
- 'w3tc_hide_' . $custom_method );
95
  }
96
 
97
- static public function button_hide_note2( $parameters ) {
98
- return Util_Ui::button_link(
99
  __( 'Hide this message', 'w3-total-cache' ),
100
- Util_Ui::url( $parameters ),
101
- false, 'button',
102
- 'w3tc_hide_' . Util_Ui::config_key_to_http_name( $parameters['key'] ) );
 
 
103
  }
104
 
105
- static public function action_button( $action, $url, $class = '',
106
  $new_window = false ) {
107
- return Util_Ui::button_link( $action, $url, $new_window, $class );
108
  }
109
  /**
110
  * Returns popup button html
@@ -116,28 +122,30 @@ class Util_Ui {
116
  * @param integer $height
117
  * @return string
118
  */
119
- static public function button_popup( $text, $action, $params = '', $width = 800, $height = 600 ) {
120
- $url = wp_nonce_url( sprintf( 'admin.php?page=w3tc_dashboard&w3tc_%s%s', $action, ( $params != '' ? '&' . $params : '' ) ), 'w3tc' );
121
  $url = str_replace( '&amp;', '&', $url );
122
 
123
  $onclick = sprintf( 'window.open(\'%s\', \'%s\', \'width=%d,height=%d,status=no,toolbar=no,menubar=no,scrollbars=yes\');', $url, $action, $width, $height );
124
 
125
- return Util_Ui::button( $text, $onclick );
126
  }
127
 
128
  /**
129
  * Returns label string for a config key.
130
  *
131
- * @param string $config_key
132
- * @param string $area
133
  */
134
- static public function config_label( $config_key ) {
135
  static $config_labels = null;
136
- if ( is_null( $config_labels ) )
137
  $config_labels = apply_filters( 'w3tc_config_labels', array() );
 
138
 
139
- if ( isset( $config_labels[$config_key] ) )
140
- return $config_labels[$config_key];
 
141
 
142
  return '';
143
  }
@@ -145,11 +153,15 @@ class Util_Ui {
145
  /**
146
  * Prints the label string for a config key.
147
  *
148
- * @param string $config_key
149
- * @param string $area
150
  */
151
- static public function e_config_label( $config_key ) {
152
- echo Util_Ui::config_label( $config_key );
 
 
 
 
153
  }
154
 
155
  /**
@@ -162,70 +174,81 @@ class Util_Ui {
162
  * @todo Add .postbox-header to our postboxes and cleanup css.
163
  * @link https://github.com/W3EDGE/w3-total-cache/issues/237
164
  *
165
- * @param string $title
166
- * @param string $class
167
- * @param string $id
168
- * @return string
169
  */
170
- static public function postbox_header( $title, $class = '', $id = '' ) {
171
- if ( !empty( $id ) ) {
172
  $id = ' id="' . esc_attr( $id ) . '"';
173
  }
174
- echo '<div' . $id . ' class="postbox ' . $class . '"><div class="handlediv" title="' . __( 'Click to toggle', 'w3-total-cache' ) . '"><br /></div><h3 class="hndle"><span>' . $title . '</span></h3><div class="inside">';
 
 
 
175
  }
176
 
177
  /**
178
  * Returns postbox footer
179
  *
180
- * @return string
181
  */
182
- static public function postbox_footer() {
183
  echo '</div></div>';
184
  }
185
 
186
-
187
-
188
-
189
- static public function button_config_save( $id = '', $extra = '' ) {
190
  $b1_id = 'w3tc_save_options_' . $id;
191
  $b2_id = 'w3tc_default_save_and_flush_' . $id;
192
 
193
- ?>
194
  <p class="submit">
195
- <?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
196
- <input type="submit" id="<?php echo $b1_id ?>"
 
 
 
 
 
 
197
  name="w3tc_save_options"
198
  class="w3tc-button-save button-primary"
199
- value="<?php _e( 'Save all settings', 'w3-total-cache' ); ?>" />
200
- <?php echo $extra ?>
201
- <?php if ( !is_network_admin() ): ?>
202
- <input type="submit" id="<?php echo $b2_id ?>"
 
 
 
 
 
203
  name="w3tc_default_save_and_flush" style="float: right"
204
  class="w3tc-button-save button-primary"
205
- value="<?php _e( 'Save Settings & Purge Caches', 'w3-total-cache' ); ?>" />
206
  <?php endif ?>
207
  </p>
208
  <?php
209
  }
210
 
211
- static public function sealing_disabled( $key ) {
212
  $c = Dispatcher::config();
213
- if ( $c->is_sealed( $key ) )
214
  echo 'disabled="disabled" ';
 
215
  }
216
 
217
  /**
218
  * Returns nonce field HTML
219
  *
220
- * @param string $action
221
- * @param string $name
222
- * @param bool $referer
223
  * @internal param bool $echo
224
  * @return string
225
  */
226
- static public function nonce_field( $action = -1, $name = '_wpnonce', $referer = true ) {
227
- $name = esc_attr( $name );
228
- $return = '<input type="hidden" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
229
 
230
  if ( $referer ) {
231
  $return .= wp_referer_field( false );
@@ -237,42 +260,70 @@ class Util_Ui {
237
  /**
238
  * Returns an notification box
239
  *
240
- * @param string $message
241
- * @param string $id adds an id to the notification box
242
  * @return string
243
  */
244
- static public function get_notification_box( $message, $id = '' ) {
245
- if ( !isset( $_GET['page'] ) || ( isset( $_GET['page'] ) && substr( $_GET['page'], 0, 5 ) != 'w3tc_' ) )
246
- $logo = sprintf( '<img src="%s" alt="W3 Total Cache" style="height:30px" />"', plugins_url( '/pub/img/W3TC_dashboard_logo_title.png', W3TC_FILE ) . '' );
247
- else
 
 
 
 
 
248
  $logo = '';
249
- return sprintf( '<div %s class="updated">%s</div>', $id? "id=\"$id\"" : '' , $logo . $message );
 
 
 
 
 
250
  }
251
 
252
  /**
253
  * Echos an notification box
254
  *
255
- * @param string $message
256
- * @param string $id adds an id to the notification box
257
  */
258
- static public function e_notification_box( $message, $id = '' ) {
259
- echo Util_Ui::get_notification_box( $message, $id );
 
 
 
 
260
  }
261
 
262
  /**
263
- * Echos an error box
264
  *
265
- * @param unknown $message
266
- * @param string $id
267
  */
268
- static public function error_box( $message, $id = '' ) {
269
- if ( !isset( $_GET['page'] ) || ( isset( $_GET['page'] ) && substr( $_GET['page'], 0, 5 ) != 'w3tc_' ) )
270
- $logo = sprintf( '<img src="%s" alt="W3 Total Cache" style="height:30px" />', plugins_url( '/pub/img/W3TC_dashboard_logo_title.png', W3TC_FILE ) . '' );
271
- else
 
 
 
 
 
272
  $logo = '';
273
- $v = sprintf( '<div %s class="error">%s</div>', $id? "id=\"$id\"" : '' , $logo . $message );
 
 
 
 
 
 
274
 
275
- echo $v;
 
 
 
276
  }
277
 
278
  /**
@@ -282,44 +333,44 @@ class Util_Ui {
282
  * @param int $precision
283
  * @return string
284
  */
285
- static public function format_bytes( $bytes, $precision = 2 ) {
286
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
287
 
288
  $bytes = max( $bytes, 0 );
289
- $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
290
- $pow = min( $pow, count( $units ) - 1 );
291
 
292
- // Uncomment one of the following alternatives
293
  $bytes /= pow( 1024, $pow );
294
- // $bytes /= (1 << (10 * $pow));
295
 
296
- return round( $bytes, $precision ) . ' ' . $units[$pow];
297
  }
298
 
299
- static public function format_mbytes( $bytes, $precision = 2 ) {
300
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
301
 
302
  $bytes = max( $bytes, 0 );
303
- $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
304
- $pow = min( $pow, count( $units ) - 1 );
305
 
306
- // Uncomment one of the following alternatives
307
  $bytes /= pow( 1024, $pow );
308
- // $bytes /= (1 << (10 * $pow));
309
 
310
- return round( $bytes, $precision ) . ' ' . $units[$pow + 2];
311
  }
312
 
313
  /**
314
  * Returns an input text element
315
  *
316
- * @param string $id
317
- * @param string $name
318
- * @param string $value
319
- * @param bool $disabled
320
- * @param int $size
321
  */
322
- static public function r_hidden( $id, $name, $value ) {
323
  return '<input type="hidden" id="' . esc_attr( $id ) .
324
  '" name="' . esc_attr( $name ) .
325
  '" value="' . esc_attr( $value ) . '" />';
@@ -328,47 +379,53 @@ class Util_Ui {
328
  /**
329
  * Echos an input text element
330
  *
331
- * @param string $id
332
- * @param string $name
333
- * @param string $value
334
- * @param bool $disabled
335
- * @param int $size
336
  */
337
- static public function hidden( $id, $name, $value ) {
338
- echo self::r_hidden( $id, $name, $value );
 
 
 
 
339
  }
340
 
341
  /**
342
  * Echos an label element
343
  *
344
- * @param string $id
345
- * @param string $text
346
  */
347
- static public function label( $id, $text ) {
348
- echo '<label for="' . esc_attr( $id ) . '">';
349
- echo $text;
350
- echo '</label>';
 
 
351
  }
352
 
353
  /**
354
  * Echos an input text element
355
  *
356
- * @param string $id
357
- * @param string $name
358
- * @param string $value
359
- * @param bool $disabled
360
- * @param int $size
361
  */
362
- static public function textbox( $id, $name, $value, $disabled = false,
363
  $size = 40, $type = 'text', $placeholder = '' ) {
364
- echo '<input class="enabled" type="' . esc_attr( $type ) .
365
- '" id="' . esc_attr( $id ) .
366
- '" name="' . esc_attr( $name ) .
367
- '" value="' . esc_attr( $value ) . '"';
368
  disabled( $disabled );
369
  echo ' size="' . esc_attr( $size ) . '"';
370
 
371
- if ( !empty( $placeholder ) ) {
372
  echo ' placeholder="' . esc_attr( $placeholder ) . '"';
373
  }
374
 
@@ -378,129 +435,130 @@ class Util_Ui {
378
  /**
379
  * Echos an input password element
380
  *
381
- * @param string $id
382
- * @param string $name
383
- * @param string $value
384
- * @param bool $disabled
385
- * @param int $size
386
  */
387
- static public function passwordbox( $id, $name, $value, $disabled = false, $size = 40 ) {
388
- echo '<input class="enabled" type="password" id="' . esc_attr( $id );
389
- echo '" name="'. esc_attr( $name ) . '" value="' . esc_attr( $value ) . '" ';
 
 
390
  disabled( $disabled );
391
- echo ' size="';
392
- esc_attr_e( $size );
393
- echo '" />';
394
  }
395
 
396
  /**
397
  * Echos an select element
398
  *
399
- * @param string $id
400
- * @param string $name
401
- * @param bool $state whether checked or not
402
- * @param bool $disabled
403
- * @param array $optgroups
404
  */
405
- static public function selectbox( $id, $name, $value, $values,
406
- $disabled = false, $optgroups = null ) {
407
- echo '<select id="' . esc_attr( $id ) .
408
- '" name="' . esc_attr( $name ) .'" ';
409
  disabled( $disabled );
410
  echo ">\n";
411
 
412
- if ( !is_array( $optgroups ) ) {
413
- // simle control
414
- foreach ( $values as $key => $descriptor )
415
  self::option( $key, $value, $descriptor );
 
416
  } else {
417
- // with optgroups
418
  $current_optgroup = -1;
419
  foreach ( $values as $key => $descriptor ) {
420
  $optgroup = ( isset( $descriptor['optgroup'] ) ? $descriptor['optgroup'] : -1 );
421
- if ( $optgroup != $current_optgroup ) {
422
- if ( $current_optgroup != -1 )
423
  echo '</optgroup>';
424
- echo '<optgroup label="' . esc_attr( $optgroups[$optgroup] ) .
425
- '">' . "\n";
426
  $current_optgroup = $optgroup;
427
  }
428
 
429
  self::option( $key, $value, $descriptor );
430
  }
431
 
432
- if ( $current_optgroup != -1 )
433
  echo '</optgroup>';
 
434
  }
435
 
436
-
437
  echo '</select>';
438
  }
439
 
440
- static private function option( $key, $selected_value, $descriptor ) {
441
- if ( !is_array( $descriptor ) ) {
442
- $label = $descriptor;
443
  $disabled = false;
444
  } else {
445
- $label = $descriptor['label'];
446
- $disabled = !empty( $descriptor['disabled'] );
447
  }
448
 
449
  echo '<option value="' . esc_attr( $key ) . '" ';
450
  selected( $selected_value, $key );
451
  disabled( $disabled );
452
- echo '>';
453
- echo $label;
454
- echo '</option>' . "\n";
455
  }
456
 
457
  /**
458
  * Echos a group of radio elements
459
  * values: value => label pair or
460
- * value => array(label, disabled, postfix)
461
  */
462
- static public function radiogroup( $name, $value, $values,
463
- $disabled = false, $separator = '' ) {
464
  $first = true;
465
  foreach ( $values as $key => $label_or_array ) {
466
  if ( $first ) {
467
  $first = false;
468
  } else {
469
- echo $separator;
 
 
 
470
  }
471
 
472
- $label = '';
473
  $item_disabled = false;
474
- $postfix = '';
475
- $pro_feature = false;
476
 
477
- if ( !is_array( $label_or_array ) ) {
478
  $label = $label_or_array;
479
  } else {
480
- $label = $label_or_array['label'];
481
  $item_disabled = $label_or_array['disabled'];
482
- $postfix = isset( $label_or_array['postfix'] ) ?
483
- $label_or_array['postfix'] : '';
484
- $pro_feature = isset( $label_or_array['pro_feature'] ) ?
485
- $label_or_array['pro_feature'] : false;
486
  }
487
 
488
  if ( $pro_feature ) {
489
- Util_Ui::pro_wrap_maybe_start();
490
  }
491
- echo '<label><input type="radio" id="' . esc_attr( $name . '__' . $key ) .
492
- '" name="' . esc_attr( $name ) .
493
- '" value="' . esc_attr( $key ) . '"';
 
494
  checked( $value, $key );
495
  disabled( $disabled || $item_disabled );
496
- echo ' />';
497
- echo $label;
498
- echo '</label>' . $postfix . "\n";
499
  if ( $pro_feature ) {
500
- Util_Ui::pro_wrap_description( $label_or_array['pro_excerpt'],
501
- $label_or_array['pro_description'], $name . '__' . $key );
 
 
 
502
 
503
- Util_Ui::pro_wrap_maybe_end( $name . '__' . $key );
504
  }
505
  }
506
  }
@@ -508,149 +566,177 @@ class Util_Ui {
508
  /**
509
  * Echos an input text element
510
  *
511
- * @param string $id
512
- * @param string $name
513
- * @param string $value
514
- * @param bool $disabled
515
  */
516
- static public function textarea( $id, $name, $value, $disabled = false ) {?>
517
- <textarea class="enabled" id="<?php echo esc_attr( $id )?>"
518
- name="<?php echo esc_attr( $name )?>" rows="5" cols=25 style="width: 100%"
519
- <?php disabled( $disabled ) ?>><?php echo esc_textarea( $value )?></textarea>
520
- <?php
 
521
  }
522
 
523
  /**
524
  * Echos an input checkbox element
525
  *
526
- * @param string $id
527
- * @param string $name
528
- * @param bool $state whether checked or not
529
- * @param bool $disabled
530
  */
531
- static public function checkbox( $id, $name, $state, $disabled = false, $label = null ) {
532
- if ( !is_null( $label ) )
533
  echo '<label>';
 
534
 
535
- echo '<input type="hidden" name="' . esc_attr( $name ) . '" value="' .
536
- ( !$disabled ? '0' : ( $state ? '1' : '0' ) ). '">' .
537
- "\n";
538
- echo '<input class="enabled" type="checkbox" id="' . esc_attr( $id ) .
539
- '" name="' . esc_attr( $name ) . '" value="1" ';
540
  checked( $state );
541
  disabled( $disabled );
542
  echo ' /> ';
543
 
544
- if ( !is_null( $label ) )
545
- echo $label . '</label>';
 
546
  }
547
 
548
  /**
549
  * Echos an element
550
  *
551
- * @param string $type
552
- * @param string $id
553
- * @param string $name
554
- * @param mixed $value
555
- * @param bool $disabled
556
  */
557
- static public function element( $type, $id, $name, $value, $disabled = false ) {
558
  switch ( $type ) {
559
- case 'textbox':
560
- Util_Ui::textbox( $id, $name, $value, $disabled );
561
- break;
562
- case 'password':
563
- Util_Ui::passwordbox( $id, $name, $value, $disabled );
564
- break;
565
- case 'textarea':
566
- Util_Ui::textarea( $id, $name, $value, $disabled );
567
- break;
568
- case 'checkbox':
569
- default:
570
- Util_Ui::checkbox( $id, $name, $value, $disabled );
571
- break;
572
-
573
  }
574
  }
575
 
576
- static public function checkbox2( $e ) {
577
- Util_Ui::checkbox( $e['name'],
 
578
  $e['name'],
579
  $e['value'],
580
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
581
- ( isset( $e['label'] ) ? $e['label'] : null ) );
 
582
  }
583
 
584
- static public function radiogroup2( $e ) {
585
- Util_Ui::radiogroup( $e['name'], $e['value'], $e['values'],
586
- $e['disabled'], $e['separator'] );
 
 
 
 
 
587
  }
588
 
589
- static public function selectbox2( $e ) {
590
- Util_Ui::selectbox( $e['name'], $e['name'], $e['value'], $e['values'],
 
 
 
 
591
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
592
- ( isset( $e['optgroups'] ) ? $e['optgroups'] : null ) );
 
593
  }
594
 
595
- static public function textbox2( $e ) {
596
- Util_Ui::textbox( $e['name'], $e['name'], $e['value'],
 
 
 
597
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
598
- ( !empty( $e['size'] ) ? $e['size'] : 20 ),
599
- ( !empty( $e['type'] ) ? $e['type'] : 'text' ),
600
- ( !empty( $e['placeholder'] ) ? $e['placeholder'] : '' ) );
 
601
  }
602
 
603
- static public function textarea2( $e ) {
604
- Util_Ui::textarea( $e['name'], $e['name'], $e['value'],
605
- ( isset( $e['disabled'] ) ? $e['disabled'] : false ) );
 
 
 
 
606
  }
607
 
608
- static public function control2( $a ) {
609
- if ( $a['control'] == 'checkbox' ) {
610
- Util_Ui::checkbox2( array(
611
- 'name' => $a['control_name'],
612
- 'value' => $a['value'],
613
- 'disabled' => $a['disabled'],
614
- 'label' => $a['checkbox_label']
615
- ) );
616
- } elseif ( $a['control'] == 'radiogroup' ) {
617
- Util_Ui::radiogroup2( array(
618
- 'name' => $a['control_name'],
619
- 'value' => $a['value'],
620
- 'disabled' => $a['disabled'],
621
- 'values' => $a['radiogroup_values'],
622
- 'separator' => isset( $a['radiogroup_separator'] ) ?
623
- $a['radiogroup_separator'] : ''
624
- ) );
625
- } elseif ( $a['control'] == 'selectbox' ) {
626
- Util_Ui::selectbox2( array(
627
- 'name' => $a['control_name'],
628
- 'value' => $a['value'],
629
- 'disabled' => $a['disabled'],
630
- 'values' => $a['selectbox_values'],
631
- 'optgroups' => isset( $a['selectbox_optgroups'] ) ?
632
- $a['selectbox_optgroups'] : null
633
- ) );
634
- } elseif ( $a['control'] == 'textbox' ) {
635
- Util_Ui::textbox2( array(
636
- 'name' => $a['control_name'],
637
- 'value' => $a['value'],
638
- 'disabled' => $a['disabled'],
639
- 'type' => isset( $a['textbox_type'] ) ? $a['textbox_type'] : null,
640
- 'size' => isset( $a['textbox_size'] ) ? $a['textbox_size'] : null,
641
- 'placeholder' => isset( $a['textbox_placeholder'] ) ?
642
- $a['textbox_placeholder'] : null
643
- ) );
644
- } elseif ( $a['control'] == 'textarea' ) {
645
- Util_Ui::textarea2( array(
646
- 'name' => $a['control_name'],
647
- 'value' => $a['value'],
648
- 'disabled' => $a['disabled']
649
- ) );
 
 
 
 
 
 
 
650
  } elseif ( 'none' === $a['control'] ) {
651
- esc_html_e( $a['none_label'], 'w3-total-cache' );
652
  } elseif ( 'button' === $a['control'] ) {
653
- echo '<button type="button" class="button">' . __( $a['none_label'], 'w3-total-cache' ) . '</button>';
654
  }
655
  }
656
 
@@ -683,53 +769,75 @@ class Util_Ui {
683
  * style - default is label,controls view,
684
  * alternative is one-column view
685
  */
686
- static public function table_tr( $a ) {
687
  $id = isset( $a['id'] ) ? $a['id'] : '';
688
- $a = apply_filters( 'w3tc_ui_settings_item', $a );
689
 
690
  echo '<tr><th';
691
 
692
- if ( isset( $a['label_class'] ) )
693
- echo ' class="' . $a['label_class'] . '"';
 
694
  echo '>';
695
- if ( isset( $a['label'] ) )
696
- Util_Ui::label( $id, $a['label'] );
 
697
 
698
  echo "</th>\n<td>\n";
699
 
700
  foreach ( $a as $key => $e ) {
701
- if ( $key == 'checkbox' )
702
- Util_Ui::checkbox( $id,
 
703
  isset( $e['name'] ) ? $e['name'] : null,
704
  $e['value'],
705
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
706
- ( isset( $e['label'] ) ? $e['label'] : null ) );
707
- elseif ( $key == 'description' )
708
- echo '<p class="description">' . $e . '</p>';
709
- elseif ( $key == 'hidden' )
710
- Util_Ui::hidden( '', $e['name'], $e['value'] );
711
- elseif ( $key == 'html' )
712
- echo $e;
713
- elseif ( $key == 'radiogroup' )
714
- Util_Ui::radiogroup( $e['name'], $e['value'], $e['values'],
715
- $e['disabled'], $e['separator'] );
716
- elseif ( $key == 'selectbox' )
717
- Util_Ui::selectbox( $id, $e['name'], $e['value'], $e['values'],
 
 
 
 
 
 
 
 
 
 
718
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
719
- ( isset( $e['optgroups'] ) ? $e['optgroups'] : null ) );
720
- elseif ( $key == 'textbox' )
721
- Util_Ui::textbox( $id, $e['name'], $e['value'],
 
 
 
 
722
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
723
- ( !empty( $e['size'] ) ? $e['size'] : 20 ),
724
- ( !empty( $e['type'] ) ? $e['type'] : 'text' ),
725
- ( !empty( $e['placeholder'] ) ? $e['placeholder'] : '' ) );
726
- elseif ( $key == 'textarea' )
727
- Util_Ui::textarea( $id, $e['name'], $e['value'],
728
- ( isset( $e['disabled'] ) ? $e['disabled'] : false ) );
 
 
 
 
 
 
729
  }
730
 
731
- echo "</td>";
732
- echo "</tr>\n";
733
  }
734
 
735
  /**
@@ -749,7 +857,7 @@ class Util_Ui {
749
  * control_after => something after control to add
750
  * description => description shown to the user below
751
  */
752
- static public function config_item( $a ) {
753
  /*
754
  * Some items we do not want shown in the free edition.
755
  *
@@ -761,110 +869,123 @@ class Util_Ui {
761
  return;
762
  }
763
 
764
- $a = Util_Ui::config_item_preprocess( $a );
765
 
766
- if ( $a['label_class'] == 'w3tc_single_column' ) {
767
  echo '<tr><th colspan="2">';
768
  } else {
769
- echo '<tr><th class="' . $a['label_class'] . '">';
770
 
771
- if ( !empty( $a['label'] ) ) {
772
- Util_Ui::label( $a['control_name'], $a['label'] );
773
  }
774
 
775
  echo "</th>\n<td>\n";
776
  }
777
 
778
- Util_Ui::control2( $a );
779
 
780
  if ( isset( $a['control_after'] ) ) {
781
- echo $a['control_after'];
 
 
 
782
  }
783
  if ( isset( $a['description'] ) ) {
784
- echo '<p class="description">' . $a['description'] . '</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
785
  }
786
 
787
- echo ( isset( $a['style'] ) ? "</th>" : "</td>" );
788
  echo "</tr>\n";
789
  }
790
 
791
-
792
-
793
- static public function config_item_extension_enabled( $a ) {
794
  echo "<tr><th class=''></th>\n<td>\n";
795
 
796
  $c = Dispatcher::config();
797
- Util_Ui::checkbox2( array(
798
- 'name' => 'extension__' . Util_Ui::config_key_to_http_name( $a['extension_id'] ),
799
- 'value' => $c->is_extension_active_frontend( $a['extension_id'] ),
800
- 'label' => $a['checkbox_label']
801
- ) );
 
 
802
 
803
  if ( isset( $a['description'] ) ) {
804
- echo '<p class="description">' . $a['description'] . '</p>';
805
  }
806
 
807
- echo "</td>";
808
- echo "</tr>\n";
809
  }
810
 
 
 
811
 
 
 
812
 
813
- static public function config_item_pro( $a ) {
814
- $a = Util_Ui::config_item_preprocess( $a );
815
-
816
- if ( $a['label_class'] != 'w3tc_no_trtd' ) {
817
- echo '<tr><th class="' . $a['label_class'] . '">';
818
-
819
- if ( !empty( $a['label'] ) ) {
820
- Util_Ui::label( $a['control_name'], $a['label'] );
821
  }
822
 
823
  echo "</th>\n<td>\n";
824
  }
825
 
826
- Util_Ui::pro_wrap_maybe_start();
827
 
828
- Util_Ui::control2( $a );
829
 
830
  if ( isset( $a['control_after'] ) ) {
831
- echo $a['control_after'];
832
  }
833
 
834
  if ( isset( $a['description'] ) ) {
835
- Util_Ui::pro_wrap_description( $a['excerpt'], $a['description'], $a['control_name'] );
836
  }
837
 
838
- Util_Ui::pro_wrap_maybe_end( $a['control_name'] );
839
 
840
- if ( $a['label_class'] != 'w3tc_no_trtd' ) {
841
- echo "</th>";
842
- echo "</tr>\n";
843
  }
844
  }
845
 
846
-
847
-
848
- static public function config_item_preprocess( $a ) {
849
  $c = Dispatcher::config();
850
 
851
- if ( !isset( $a['value'] ) || is_null( $a['value'] ) ) {
852
  $a['value'] = $c->get( $a['key'] );
853
- if ( is_array( $a['value'] ) )
854
  $a['value'] = implode( "\n", $a['value'] );
 
855
  }
856
 
857
- if ( !isset( $a['disabled'] ) || is_null( $a['disabled'] ) ) {
858
  $a['disabled'] = $c->is_sealed( $a['key'] );
859
  }
860
 
861
  if ( empty( $a['label'] ) ) {
862
- $a['label'] = Util_Ui::config_label( $a['key'] );
863
  }
864
 
865
- $a['control_name'] = Util_Ui::config_key_to_http_name( $a['key'] );
866
- $a['label_class'] = empty( $a['label_class'] ) ? '' : $a['label_class'];
867
- if ( empty( $a['label_class'] ) && $a['control'] == 'checkbox' ) {
868
  $a['label_class'] = 'w3tc_config_checkbox';
869
  }
870
 
@@ -876,71 +997,69 @@ class Util_Ui {
876
  return apply_filters( 'w3tc_ui_config_item_' . $action_key, $a );
877
  }
878
 
879
-
880
-
881
  /**
882
  * Displays config item - caching engine selectbox
883
  */
884
- static public function config_item_engine( $a ) {
885
  if ( isset( $a['empty_value'] ) && $a['empty_value'] ) {
886
  $values[''] = array(
887
- 'label' => 'Please select a method'
888
  );
889
  }
890
 
891
- $values['file'] = array(
892
- 'label' => __( 'Disk', 'w3-total-cache' ),
893
- 'optgroup' => 0
894
  );
895
- $values['apc'] = array(
896
- 'disabled' => !Util_Installed::apc(),
897
- 'label' => __( 'Opcode: Alternative PHP Cache (APC / APCu)', 'w3-total-cache' ),
898
- 'optgroup' => 1
899
  );
900
  $values['eaccelerator'] = array(
901
- 'disabled' => !Util_Installed::eaccelerator(),
902
- 'label' => __( 'Opcode: eAccelerator', 'w3-total-cache' ),
903
- 'optgroup' => 1
904
  );
905
- $values['xcache'] = array(
906
- 'disabled' => !Util_Installed::xcache(),
907
- 'label' => __( 'Opcode: XCache', 'w3-total-cache' ),
908
- 'optgroup' => 1
909
  );
910
- $values['wincache'] = array(
911
- 'disabled' => !Util_Installed::wincache(),
912
- 'label' => __( 'Opcode: WinCache', 'w3-total-cache' ),
913
- 'optgroup' => 1
914
  );
915
- $values['memcached'] = array(
916
- 'disabled' => !Util_Installed::memcached(),
917
- 'label' => __( 'Memcached', 'w3-total-cache' ),
918
- 'optgroup' => 2
919
  );
920
- $values['redis'] = array(
921
- 'disabled' => !Util_Installed::redis(),
922
- 'label' => __( 'Redis', 'w3-total-cache' ),
923
- 'optgroup' => 2
924
  );
925
 
926
- Util_Ui::config_item( array(
927
- 'key' => $a['key'],
928
- 'label' => ( isset( $a['label'] ) ? $a['label'] : null ),
929
- 'disabled' => ( isset( $a['disabled'] ) ? $a['disabled'] : null ),
930
- 'control' => 'selectbox',
931
- 'selectbox_values' => $values,
 
932
  'selectbox_optgroups' => array(
933
  __( 'Shared Server:', 'w3-total-cache' ),
934
  __( 'Dedicated / Virtual Server:', 'w3-total-cache' ),
935
- __( 'Multiple Servers:', 'w3-total-cache' )
936
  ),
937
- 'control_after' => isset( $a['control_after'] ) ? $a['control_after'] : null,
938
- ) );
 
939
  }
940
 
941
-
942
-
943
- static public function pro_wrap_maybe_start() {
944
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
945
  return;
946
  }
@@ -951,27 +1070,25 @@ class Util_Ui {
951
  <?php
952
  }
953
 
 
 
954
 
955
-
956
- static public function pro_wrap_description( $excerpt, $description, $data_href ) {
957
- echo '<p class="description w3tc-gopro-excerpt">' . $excerpt . '</p>';
958
-
959
- if ( !empty( $description ) ) {
960
  $d = array_map(
961
- function($e) {
962
- return "<p class='description'>$e</p>";
963
  },
964
- $description
965
  );
966
 
967
- echo '<div class="w3tc-gopro-description">' . implode( "\n", $d ) . '</div>';
968
- echo '<a href="#" class="w3tc-gopro-more" data-href="w3tc-gopro-more-' . $data_href . '">Show More <span class="dashicons dashicons-arrow-down-alt2"></span></a>';
 
 
969
  }
970
  }
971
 
972
-
973
-
974
- static public function pro_wrap_maybe_end( $button_data_src ) {
975
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
976
  return;
977
  }
@@ -979,7 +1096,7 @@ class Util_Ui {
979
  ?>
980
  </div>
981
  <div class="w3tc-gopro-action">
982
- <button class="button w3tc-gopro-button button-buy-plugin" data-src="<?php echo esc_attr( $button_data_src ) ?>">
983
  Learn more about Pro
984
  </button>
985
  </div>
@@ -987,9 +1104,7 @@ class Util_Ui {
987
  <?php
988
  }
989
 
990
-
991
-
992
- static public function pro_wrap_maybe_start2() {
993
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
994
  return;
995
  }
@@ -1000,9 +1115,7 @@ class Util_Ui {
1000
  <?php
1001
  }
1002
 
1003
-
1004
-
1005
- static public function pro_wrap_maybe_end2( $button_data_src ) {
1006
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
1007
  return;
1008
  }
@@ -1010,7 +1123,7 @@ class Util_Ui {
1010
  ?>
1011
  </p>
1012
  <div style="text-align: right">
1013
- <button class="button w3tc-gopro-button button-buy-plugin" data-src="<?php echo esc_attr( $button_data_src ) ?>">
1014
  Unlock Feature
1015
  </button>
1016
  </div>
@@ -1024,24 +1137,24 @@ class Util_Ui {
1024
  * On subblogs - shows button to enable/disable custom configuration
1025
  * $a['key'] - config key *_overloaded which are managed
1026
  */
1027
- static public function config_overloading_button( $a ) {
1028
  $c = Dispatcher::config();
1029
- if ( $c->is_master() )
1030
  return;
 
1031
 
1032
  if ( $c->get_boolean( $a['key'] ) ) {
1033
- $name = 'w3tc_config_overloaded_disable~' .
1034
- Util_Ui::config_key_to_http_name( $a['key'] );
1035
  $value = __( 'Use common settings', 'w3-total-cache' );
1036
  } else {
1037
- $name = 'w3tc_config_overloaded_enable~' .
1038
- Util_Ui::config_key_to_http_name( $a['key'] );
1039
  $value = __( 'Use specific settings', 'w3-total-cache' );
1040
  }
1041
 
1042
  echo '<div style="float: right">';
1043
- echo '<input type="submit" class="button" name="' .
1044
- esc_attr( $name ) . '" value="' . esc_attr( $value ) . '" />';
 
1045
  echo '</div>';
1046
  }
1047
 
@@ -1060,9 +1173,12 @@ class Util_Ui {
1060
  *
1061
  * @return string
1062
  */
1063
- static public function preview_link() {
1064
- return Util_Ui::button_link( __( 'Preview', 'w3-total-cache' ),
1065
- Util_Ui::url( array( 'w3tc_default_previewing' => 'y' ) ), true );
 
 
 
1066
  }
1067
 
1068
  /**
@@ -1072,58 +1188,80 @@ class Util_Ui {
1072
  * @param bool $string
1073
  * @return array|string
1074
  */
1075
- static public function secs_to_time( $input, $string = true ) {
1076
- $input = (double)$input;
1077
- $time = array();
1078
- $msecs = floor( $input*1000 % 1000 );
1079
  $seconds = $input % 60;
1080
- $input = floor( $input / 60 );
1081
- $minutes = $input % 60;
1082
- $input = floor( $input / 60 );
1083
- $hours = $input % 60;
1084
- if ( $hours )
1085
- $time[] = sprintf( __( '%dh', 'w3-total-cache' ), $hours );
1086
- if ( $minutes )
1087
- $time[] = sprintf( __( '%dm', 'w3-total-cache' ), $minutes );
1088
- if ( $seconds )
1089
- $time[] = sprintf( __( '%ds', 'w3-total-cache' ), $seconds );
1090
- if ( $msecs )
1091
- $time[] = sprintf( __( '%dms', 'w3-total-cache' ), $msecs );
1092
-
1093
- if ( empty( $time ) )
1094
- $time[] = sprintf( __( '%dms', 'w3-total-cache' ), 0 );
1095
- if ( $string )
 
 
 
 
 
1096
  return implode( ' ', $time );
 
1097
  return $time;
1098
  }
1099
 
1100
-
1101
-
1102
  /**
1103
  * Returns option name accepted by W3TC as http paramter
1104
  * from it's id (full name from config file)
1105
  */
1106
- static public function config_key_to_http_name( $id ) {
1107
- if ( is_array( $id ) )
1108
  $id = $id[0] . '___' . $id[1];
 
1109
 
1110
  return str_replace( '.', '__', $id );
1111
  }
1112
 
1113
-
1114
-
1115
  /*
1116
  * Converts configuration key returned in http _GET/_POST
1117
  * to configuration key
1118
  */
1119
- static public function config_key_from_http_name( $http_key ) {
1120
  $a = explode( '___', $http_key );
1121
- if ( count( $a ) == 2 ) {
1122
- $a[0] = Util_Ui::config_key_from_http_name( $a[0] );
1123
- $a[1] = Util_Ui::config_key_from_http_name( $a[1] );
1124
  return $a;
1125
  }
1126
 
1127
  return str_replace( '__', '.', $http_key );
1128
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1129
  }
1
  <?php
2
  namespace W3TC;
3
 
4
+ use DOMDocument;
5
+
6
  class Util_Ui {
7
  /**
8
  * Returns button html
9
  *
10
+ * @param string $text
11
+ * @param string $onclick
12
+ * @param string $class
13
  * @return string
14
  */
15
+ public static function button( $text, $onclick = '', $class = 'button',
16
  $name = '' ) {
17
+ $maybe_name = ( empty( $name ) ? '' : ' name="' . esc_attr( $name ) . '"' );
 
18
  return '<input type="button"' . $maybe_name . ' class="' .
19
+ esc_attr( $class ) . '" value="' . esc_attr( $text ) .
20
+ '" onclick="' . esc_attr( $onclick ) . '" />';
21
  }
22
 
23
  /**
24
+ * Returns button link html.
25
  *
26
+ * @param string $text Text.
27
+ * @param string $url URL.
28
+ * @param bool $new_window Open link in a new window.
29
+ * @param string $class Class.
30
+ * @param string $name Name.
31
  * @return string
32
  */
33
+ public static function button_link( $text, $url, $new_window = false, $class = 'button', $name = '' ) {
 
34
  $url = str_replace( '&amp;', '&', $url );
35
 
36
  if ( $new_window ) {
38
  } else {
39
  $onclick = '';
40
 
41
+ if ( strpos( $class, 'w3tc-button-ignore-change' ) >= 0 ) {
42
  $onclick .= 'w3tc_beforeupload_unbind(); ';
43
+ }
44
 
45
  $onclick .= sprintf( 'document.location.href=\'%s\';', addslashes( $url ) );
46
  }
47
 
48
+ return self::button( $text, $onclick, $class, $name );
49
  }
50
 
51
+ public static function url( $addon ) {
52
+ if ( ! isset( $addon['page'] ) ) {
53
  $addon['page'] = Util_Request::get_string( 'page', 'w3tc_dashboard' );
54
+ }
55
 
56
  $url = 'admin.php';
57
  $amp = '?';
58
  foreach ( $addon as $key => $value ) {
59
+ $url .= $amp . rawurlencode( $key ) . '=' . rawurlencode( $value );
60
  $amp = '&';
61
  }
62
 
71
  * @param string $text
72
  * @param string $note
73
  * @param string $redirect
74
+ * @param boolean $admin if to use config admin.
75
  * @param string $page
76
  * @param string $custom_method
77
  * @return string
78
  */
79
+ public static function button_hide_note( $text, $note, $redirect = '',
80
  $admin = false, $page = '',
81
  $custom_method = 'w3tc_default_hide_note' ) {
82
+ if ( '' === $page ) {
83
  $page = Util_Request::get_string( 'page', 'w3tc_dashboard' );
84
  }
85
 
86
  $url = sprintf( 'admin.php?page=%s&%s&note=%s', $page, $custom_method, $note );
87
 
88
+ if ( $admin ) {
89
  $url .= '&admin=1';
90
+ }
91
 
92
+ if ( '' !== $redirect ) {
93
+ $url .= '&redirect=' . rawurlencode( $redirect );
94
  }
95
 
96
  $url = wp_nonce_url( $url, 'w3tc' );
97
 
98
+ return self::button_link( $text, $url, false, 'button', 'w3tc_hide_' . $custom_method );
 
99
  }
100
 
101
+ public static function button_hide_note2( $parameters ) {
102
+ return self::button_link(
103
  __( 'Hide this message', 'w3-total-cache' ),
104
+ self::url( $parameters ),
105
+ false,
106
+ 'button',
107
+ 'w3tc_hide_' . self::config_key_to_http_name( $parameters['key'] )
108
+ );
109
  }
110
 
111
+ public static function action_button( $action, $url, $class = '',
112
  $new_window = false ) {
113
+ return self::button_link( $action, $url, $new_window, $class );
114
  }
115
  /**
116
  * Returns popup button html
122
  * @param integer $height
123
  * @return string
124
  */
125
+ public static function button_popup( $text, $action, $params = '', $width = 800, $height = 600 ) {
126
+ $url = wp_nonce_url( sprintf( 'admin.php?page=w3tc_dashboard&w3tc_%s%s', $action, ( '' !== $params ? '&' . $params : '' ) ), 'w3tc' );
127
  $url = str_replace( '&amp;', '&', $url );
128
 
129
  $onclick = sprintf( 'window.open(\'%s\', \'%s\', \'width=%d,height=%d,status=no,toolbar=no,menubar=no,scrollbars=yes\');', $url, $action, $width, $height );
130
 
131
+ return self::button( $text, $onclick );
132
  }
133
 
134
  /**
135
  * Returns label string for a config key.
136
  *
137
+ * @param string $config_key
138
+ * @param string $area
139
  */
140
+ public static function config_label( $config_key ) {
141
  static $config_labels = null;
142
+ if ( is_null( $config_labels ) ) {
143
  $config_labels = apply_filters( 'w3tc_config_labels', array() );
144
+ }
145
 
146
+ if ( isset( $config_labels[ $config_key ] ) ) {
147
+ return $config_labels[ $config_key ];
148
+ }
149
 
150
  return '';
151
  }
153
  /**
154
  * Prints the label string for a config key.
155
  *
156
+ * @param string $config_key
157
+ * @param string $area
158
  */
159
+ public static function e_config_label( $config_key ) {
160
+ $config_label = self::config_label( $config_key );
161
+ echo wp_kses(
162
+ $config_label,
163
+ self::get_allowed_html_for_wp_kses_from_content( $config_label )
164
+ );
165
  }
166
 
167
  /**
174
  * @todo Add .postbox-header to our postboxes and cleanup css.
175
  * @link https://github.com/W3EDGE/w3-total-cache/issues/237
176
  *
177
+ * @param string $title
178
+ * @param string $class
179
+ * @param string $id
180
+ * @return void
181
  */
182
+ public static function postbox_header( $title, $class = '', $id = '' ) {
183
+ if ( ! empty( $id ) ) {
184
  $id = ' id="' . esc_attr( $id ) . '"';
185
  }
186
+ echo '<div' . $id . ' class="postbox ' . esc_attr( $class ) . '">
187
+ <div class="handlediv" title="' . esc_attr__( 'Click to toggle', 'w3-total-cache' ) . '"><br /></div>
188
+ <h3 class="hndle"><span>' . wp_kses( $title, self::get_allowed_html_for_wp_kses_from_content( $title ) ) . '</span></h3>
189
+ <div class="inside">';
190
  }
191
 
192
  /**
193
  * Returns postbox footer
194
  *
195
+ * @return void
196
  */
197
+ public static function postbox_footer() {
198
  echo '</div></div>';
199
  }
200
 
201
+ public static function button_config_save( $id = '', $extra = '' ) {
 
 
 
202
  $b1_id = 'w3tc_save_options_' . $id;
203
  $b2_id = 'w3tc_default_save_and_flush_' . $id;
204
 
205
+ ?>
206
  <p class="submit">
207
+ <?php
208
+ $nonce_field = self::nonce_field( 'w3tc' );
209
+ echo wp_kses(
210
+ $nonce_field,
211
+ self::get_allowed_html_for_wp_kses_from_content( $nonce_field )
212
+ );
213
+ ?>
214
+ <input type="submit" id="<?php echo esc_attr( $b1_id ); ?>"
215
  name="w3tc_save_options"
216
  class="w3tc-button-save button-primary"
217
+ value="<?php esc_attr_e( 'Save all settings', 'w3-total-cache' ); ?>" />
218
+ <?php
219
+ echo wp_kses(
220
+ $extra,
221
+ self::get_allowed_html_for_wp_kses_from_content( $extra )
222
+ );
223
+ ?>
224
+ <?php if ( ! is_network_admin() ) : ?>
225
+ <input type="submit" id="<?php echo esc_attr( $b2_id ); ?>"
226
  name="w3tc_default_save_and_flush" style="float: right"
227
  class="w3tc-button-save button-primary"
228
+ value="<?php esc_attr_e( 'Save Settings & Purge Caches', 'w3-total-cache' ); ?>" />
229
  <?php endif ?>
230
  </p>
231
  <?php
232
  }
233
 
234
+ public static function sealing_disabled( $key ) {
235
  $c = Dispatcher::config();
236
+ if ( $c->is_sealed( $key ) ) {
237
  echo 'disabled="disabled" ';
238
+ }
239
  }
240
 
241
  /**
242
  * Returns nonce field HTML
243
  *
244
+ * @param string $action
245
+ * @param string $name
246
+ * @param bool $referer
247
  * @internal param bool $echo
248
  * @return string
249
  */
250
+ public static function nonce_field( $action = -1, $name = '_wpnonce', $referer = true ) {
251
+ $return = '<input type="hidden" name="' . esc_attr( $name ) . '" value="' . esc_attr( wp_create_nonce( $action ) ) . '" />';
 
252
 
253
  if ( $referer ) {
254
  $return .= wp_referer_field( false );
260
  /**
261
  * Returns an notification box
262
  *
263
+ * @param string $message
264
+ * @param string $id adds an id to the notification box.
265
  * @return string
266
  */
267
+ public static function get_notification_box( $message, $id = '' ) {
268
+ $page_val = Util_Request::get_string( 'page' );
269
+
270
+ if ( empty( $page_val ) || ( ! empty( $page_val ) && 'w3tc_' !== substr( $page_val, 0, 5 ) ) ) {
271
+ $logo = sprintf(
272
+ '<img src="%s" alt="W3 Total Cache" style="height:30px" />"',
273
+ esc_url( plugins_url( '/pub/img/W3TC_dashboard_logo_title.png', W3TC_FILE ) ) . ''
274
+ );
275
+ } else {
276
  $logo = '';
277
+ }
278
+ return sprintf(
279
+ '<div %s class="updated">%s</div>',
280
+ $id ? 'id="' . esc_attr( $id ) . '"' : '',
281
+ $logo . wp_kses( $message, self::get_allowed_html_for_wp_kses_from_content( $message ) )
282
+ );
283
  }
284
 
285
  /**
286
  * Echos an notification box
287
  *
288
+ * @param string $message
289
+ * @param string $id adds an id to the notification box.
290
  */
291
+ public static function e_notification_box( $message, $id = '' ) {
292
+ $notification_box = self::get_notification_box( $message, $id );
293
+ echo wp_kses(
294
+ $notification_box,
295
+ self::get_allowed_html_for_wp_kses_from_content( $notification_box )
296
+ );
297
  }
298
 
299
  /**
300
+ * Echos an error box.
301
  *
302
+ * @param string $message Message.
303
+ * @param string $id Id.
304
  */
305
+ public static function error_box( $message, $id = '' ) {
306
+ $page_val = Util_Request::get_string( 'page' );
307
+
308
+ if ( empty( $page_val ) || ( ! empty( $page_val ) && 'w3tc_' !== substr( $page_val, 0, 5 ) ) ) {
309
+ $logo = sprintf(
310
+ '<img src="%s" alt="W3 Total Cache" style="height:30px" />',
311
+ esc_url( plugins_url( '/pub/img/W3TC_dashboard_logo_title.png', W3TC_FILE ) . '' )
312
+ );
313
+ } else {
314
  $logo = '';
315
+ }
316
+
317
+ $v = sprintf(
318
+ '<div %s class="error">%s</div>',
319
+ $id ? 'id="' . esc_attr( $id ) . '"' : '',
320
+ $logo . wp_kses( $message, self::get_allowed_html_for_wp_kses_from_content( $message ) )
321
+ );
322
 
323
+ echo wp_kses(
324
+ $v,
325
+ self::get_allowed_html_for_wp_kses_from_content( $v )
326
+ );
327
  }
328
 
329
  /**
333
  * @param int $precision
334
  * @return string
335
  */
336
+ public static function format_bytes( $bytes, $precision = 2 ) {
337
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
338
 
339
  $bytes = max( $bytes, 0 );
340
+ $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
341
+ $pow = min( $pow, count( $units ) - 1 );
342
 
343
+ // Uncomment one of the following alternatives.
344
  $bytes /= pow( 1024, $pow );
345
+ // $bytes /= ( 1 << ( 10 * $pow ) );
346
 
347
+ return round( $bytes, $precision ) . ' ' . $units[ $pow ];
348
  }
349
 
350
+ public static function format_mbytes( $bytes, $precision = 2 ) {
351
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
352
 
353
  $bytes = max( $bytes, 0 );
354
+ $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
355
+ $pow = min( $pow, count( $units ) - 1 );
356
 
357
+ // Uncomment one of the following alternatives.
358
  $bytes /= pow( 1024, $pow );
359
+ // $bytes /= ( 1 << ( 10 * $pow ) );
360
 
361
+ return round( $bytes, $precision ) . ' ' . $units[ $pow + 2 ];
362
  }
363
 
364
  /**
365
  * Returns an input text element
366
  *
367
+ * @param string $id
368
+ * @param string $name
369
+ * @param string $value
370
+ * @param bool $disabled
371
+ * @param int $size
372
  */
373
+ public static function r_hidden( $id, $name, $value ) {
374
  return '<input type="hidden" id="' . esc_attr( $id ) .
375
  '" name="' . esc_attr( $name ) .
376
  '" value="' . esc_attr( $value ) . '" />';
379
  /**
380
  * Echos an input text element
381
  *
382
+ * @param string $id
383
+ * @param string $name
384
+ * @param string $value
385
+ * @param bool $disabled
386
+ * @param int $size
387
  */
388
+ public static function hidden( $id, $name, $value ) {
389
+ $hidden = self::r_hidden( $id, $name, $value );
390
+ echo wp_kses(
391
+ $hidden,
392
+ self::get_allowed_html_for_wp_kses_from_content( $hidden )
393
+ );
394
  }
395
 
396
  /**
397
  * Echos an label element
398
  *
399
+ * @param string $id
400
+ * @param string $text
401
  */
402
+ public static function label( $id, $text ) {
403
+ $label = '<label for="' . esc_attr( $id ) . '">' . $text . '</label>';
404
+ echo wp_kses(
405
+ $label,
406
+ self::get_allowed_html_for_wp_kses_from_content( $label )
407
+ );
408
  }
409
 
410
  /**
411
  * Echos an input text element
412
  *
413
+ * @param string $id
414
+ * @param string $name
415
+ * @param string $value
416
+ * @param bool $disabled
417
+ * @param int $size
418
  */
419
+ public static function textbox( $id, $name, $value, $disabled = false,
420
  $size = 40, $type = 'text', $placeholder = '' ) {
421
+ echo '<input class="enabled" type="' . esc_attr( $type ) . '"
422
+ id="' . esc_attr( $id ) . '"
423
+ name="' . esc_attr( $name ) . '"
424
+ value="' . esc_attr( $value ) . '" ';
425
  disabled( $disabled );
426
  echo ' size="' . esc_attr( $size ) . '"';
427
 
428
+ if ( ! empty( $placeholder ) ) {
429
  echo ' placeholder="' . esc_attr( $placeholder ) . '"';
430
  }
431
 
435
  /**
436
  * Echos an input password element
437
  *
438
+ * @param string $id
439
+ * @param string $name
440
+ * @param string $value
441
+ * @param bool $disabled
442
+ * @param int $size
443
  */
444
+ public static function passwordbox( $id, $name, $value, $disabled = false, $size = 40 ) {
445
+ echo '<input class="enabled" type="password"
446
+ id="' . esc_attr( $id ) . '"
447
+ name="' . esc_attr( $name ) . '"
448
+ value="' . esc_attr( $value ) . '" ';
449
  disabled( $disabled );
450
+ echo ' size="' . esc_attr( $size ) . '" />';
 
 
451
  }
452
 
453
  /**
454
  * Echos an select element
455
  *
456
+ * @param string $id
457
+ * @param string $name
458
+ * @param bool $state whether checked or not.
459
+ * @param bool $disabled
460
+ * @param array $optgroups
461
  */
462
+ public static function selectbox( $id, $name, $value, $values,
463
+ $disabled = false, $optgroups = null ) {
464
+ echo '<select id="' . esc_attr( $id ) . '" name="' . esc_attr( $name ) . '" ';
 
465
  disabled( $disabled );
466
  echo ">\n";
467
 
468
+ if ( ! is_array( $optgroups ) ) {
469
+ // simle control.
470
+ foreach ( $values as $key => $descriptor ) {
471
  self::option( $key, $value, $descriptor );
472
+ }
473
  } else {
474
+ // with optgroups.
475
  $current_optgroup = -1;
476
  foreach ( $values as $key => $descriptor ) {
477
  $optgroup = ( isset( $descriptor['optgroup'] ) ? $descriptor['optgroup'] : -1 );
478
+ if ( $optgroup !== $current_optgroup ) {
479
+ if ( -1 !== $current_optgroup ) {
480
  echo '</optgroup>';
481
+ }
482
+ echo '<optgroup label="' . esc_attr( $optgroups[ $optgroup ] ) . '">' . "\n";
483
  $current_optgroup = $optgroup;
484
  }
485
 
486
  self::option( $key, $value, $descriptor );
487
  }
488
 
489
+ if ( -1 !== $current_optgroup ) {
490
  echo '</optgroup>';
491
+ }
492
  }
493
 
 
494
  echo '</select>';
495
  }
496
 
497
+ private static function option( $key, $selected_value, $descriptor ) {
498
+ if ( ! is_array( $descriptor ) ) {
499
+ $label = $descriptor;
500
  $disabled = false;
501
  } else {
502
+ $label = $descriptor['label'];
503
+ $disabled = ! empty( $descriptor['disabled'] );
504
  }
505
 
506
  echo '<option value="' . esc_attr( $key ) . '" ';
507
  selected( $selected_value, $key );
508
  disabled( $disabled );
509
+ echo '>' . wp_kses( $label, self::get_allowed_html_for_wp_kses_from_content( $label ) ) . '</option>' . "\n";
 
 
510
  }
511
 
512
  /**
513
  * Echos a group of radio elements
514
  * values: value => label pair or
515
+ * value => array(label, disabled, postfix).
516
  */
517
+ public static function radiogroup( $name, $value, $values,
518
+ $disabled = false, $separator = '' ) {
519
  $first = true;
520
  foreach ( $values as $key => $label_or_array ) {
521
  if ( $first ) {
522
  $first = false;
523
  } else {
524
+ echo wp_kses(
525
+ $separator,
526
+ self::get_allowed_html_for_wp_kses_from_content( $separator )
527
+ );
528
  }
529
 
530
+ $label = '';
531
  $item_disabled = false;
532
+ $postfix = '';
533
+ $pro_feature = false;
534
 
535
+ if ( ! is_array( $label_or_array ) ) {
536
  $label = $label_or_array;
537
  } else {
538
+ $label = $label_or_array['label'];
539
  $item_disabled = $label_or_array['disabled'];
540
+ $postfix = isset( $label_or_array['postfix'] ) ? $label_or_array['postfix'] : '';
541
+ $pro_feature = isset( $label_or_array['pro_feature'] ) ? $label_or_array['pro_feature'] : false;
 
 
542
  }
543
 
544
  if ( $pro_feature ) {
545
+ self::pro_wrap_maybe_start();
546
  }
547
+ echo '<label><input type="radio"
548
+ id="' . esc_attr( $name . '__' . $key ) . '"
549
+ name="' . esc_attr( $name ) . '"
550
+ value="' . esc_attr( $key ) . '"';
551
  checked( $value, $key );
552
  disabled( $disabled || $item_disabled );
553
+ echo ' />' . wp_kses( $label, self::get_allowed_html_for_wp_kses_from_content( $label ) ) . '</label>' . wp_kses( $postfix, self::get_allowed_html_for_wp_kses_from_content( $postfix ) ) . "\n";
 
 
554
  if ( $pro_feature ) {
555
+ self::pro_wrap_description(
556
+ $label_or_array['pro_excerpt'],
557
+ $label_or_array['pro_description'],
558
+ $name . '__' . $key
559
+ );
560
 
561
+ self::pro_wrap_maybe_end( $name . '__' . $key );
562
  }
563
  }
564
  }
566
  /**
567
  * Echos an input text element
568
  *
569
+ * @param string $id
570
+ * @param string $name
571
+ * @param string $value
572
+ * @param bool $disabled
573
  */
574
+ public static function textarea( $id, $name, $value, $disabled = false ) {
575
+ ?>
576
+ <textarea class="enabled" id="<?php echo esc_attr( $id ); ?>"
577
+ name="<?php echo esc_attr( $name ); ?>" rows="5" cols=25 style="width: 100%"
578
+ <?php disabled( $disabled ); ?>><?php echo esc_textarea( $value ); ?></textarea>
579
+ <?php
580
  }
581
 
582
  /**
583
  * Echos an input checkbox element
584
  *
585
+ * @param string $id
586
+ * @param string $name
587
+ * @param bool $state whether checked or not.
588
+ * @param bool $disabled
589
  */
590
+ public static function checkbox( $id, $name, $state, $disabled = false, $label = null ) {
591
+ if ( ! is_null( $label ) ) {
592
  echo '<label>';
593
+ }
594
 
595
+ echo '<input type="hidden" name="' . esc_attr( $name ) . '"
596
+ value="' . esc_attr( ( ! $disabled ? '0' : ( $state ? '1' : '0' ) ) ) . '">' . "\n";
597
+ echo '<input class="enabled" type="checkbox" id="' . esc_attr( $id ) . '"
598
+ name="' . esc_attr( $name ) . '" value="1" ';
 
599
  checked( $state );
600
  disabled( $disabled );
601
  echo ' /> ';
602
 
603
+ if ( ! is_null( $label ) ) {
604
+ echo wp_kses( $label, self::get_allowed_html_for_wp_kses_from_content( $label ) ) . '</label>';
605
+ }
606
  }
607
 
608
  /**
609
  * Echos an element
610
  *
611
+ * @param string $type
612
+ * @param string $id
613
+ * @param string $name
614
+ * @param mixed $value
615
+ * @param bool $disabled
616
  */
617
+ public static function element( $type, $id, $name, $value, $disabled = false ) {
618
  switch ( $type ) {
619
+ case 'textbox':
620
+ self::textbox( $id, $name, $value, $disabled );
621
+ break;
622
+ case 'password':
623
+ self::passwordbox( $id, $name, $value, $disabled );
624
+ break;
625
+ case 'textarea':
626
+ self::textarea( $id, $name, $value, $disabled );
627
+ break;
628
+ case 'checkbox':
629
+ default:
630
+ self::checkbox( $id, $name, $value, $disabled );
631
+ break;
 
632
  }
633
  }
634
 
635
+ public static function checkbox2( $e ) {
636
+ self::checkbox(
637
+ $e['name'],
638
  $e['name'],
639
  $e['value'],
640
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
641
+ ( isset( $e['label'] ) ? $e['label'] : null )
642
+ );
643
  }
644
 
645
+ public static function radiogroup2( $e ) {
646
+ self::radiogroup(
647
+ $e['name'],
648
+ $e['value'],
649
+ $e['values'],
650
+ $e['disabled'],
651
+ $e['separator']
652
+ );
653
  }
654
 
655
+ public static function selectbox2( $e ) {
656
+ self::selectbox(
657
+ $e['name'],
658
+ $e['name'],
659
+ $e['value'],
660
+ $e['values'],
661
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
662
+ ( isset( $e['optgroups'] ) ? $e['optgroups'] : null )
663
+ );
664
  }
665
 
666
+ public static function textbox2( $e ) {
667
+ self::textbox(
668
+ $e['name'],
669
+ $e['name'],
670
+ $e['value'],
671
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
672
+ ( ! empty( $e['size'] ) ? $e['size'] : 20 ),
673
+ ( ! empty( $e['type'] ) ? $e['type'] : 'text' ),
674
+ ( ! empty( $e['placeholder'] ) ? $e['placeholder'] : '' )
675
+ );
676
  }
677
 
678
+ public static function textarea2( $e ) {
679
+ self::textarea(
680
+ $e['name'],
681
+ $e['name'],
682
+ $e['value'],
683
+ ( isset( $e['disabled'] ) ? $e['disabled'] : false )
684
+ );
685
  }
686
 
687
+ public static function control2( $a ) {
688
+ if ( 'checkbox' === $a['control'] ) {
689
+ self::checkbox2(
690
+ array(
691
+ 'name' => $a['control_name'],
692
+ 'value' => $a['value'],
693
+ 'disabled' => $a['disabled'],
694
+ 'label' => $a['checkbox_label'],
695
+ )
696
+ );
697
+ } elseif ( 'radiogroup' === $a['control'] ) {
698
+ self::radiogroup2(
699
+ array(
700
+ 'name' => $a['control_name'],
701
+ 'value' => $a['value'],
702
+ 'disabled' => $a['disabled'],
703
+ 'values' => $a['radiogroup_values'],
704
+ 'separator' => isset( $a['radiogroup_separator'] ) ? $a['radiogroup_separator'] : '',
705
+ )
706
+ );
707
+ } elseif ( 'selectbox' === $a['control'] ) {
708
+ self::selectbox2(
709
+ array(
710
+ 'name' => $a['control_name'],
711
+ 'value' => $a['value'],
712
+ 'disabled' => $a['disabled'],
713
+ 'values' => $a['selectbox_values'],
714
+ 'optgroups' => isset( $a['selectbox_optgroups'] ) ? $a['selectbox_optgroups'] : null,
715
+ )
716
+ );
717
+ } elseif ( 'textbox' === $a['control'] ) {
718
+ self::textbox2(
719
+ array(
720
+ 'name' => $a['control_name'],
721
+ 'value' => $a['value'],
722
+ 'disabled' => $a['disabled'],
723
+ 'type' => isset( $a['textbox_type'] ) ? $a['textbox_type'] : null,
724
+ 'size' => isset( $a['textbox_size'] ) ? $a['textbox_size'] : null,
725
+ 'placeholder' => isset( $a['textbox_placeholder'] ) ? $a['textbox_placeholder'] : null,
726
+ )
727
+ );
728
+ } elseif ( 'textarea' === $a['control'] ) {
729
+ self::textarea2(
730
+ array(
731
+ 'name' => $a['control_name'],
732
+ 'value' => $a['value'],
733
+ 'disabled' => $a['disabled'],
734
+ )
735
+ );
736
  } elseif ( 'none' === $a['control'] ) {
737
+ echo wp_kses( $a['none_label'], self::get_allowed_html_for_wp_kses_from_content( $a['none_label'] ) );
738
  } elseif ( 'button' === $a['control'] ) {
739
+ echo '<button type="button" class="button">' . wp_kses( $a['none_label'], self::get_allowed_html_for_wp_kses_from_content( $a['none_label'] ) ) . '</button>';
740
  }
741
  }
742
 
769
  * style - default is label,controls view,
770
  * alternative is one-column view
771
  */
772
+ public static function table_tr( $a ) {
773
  $id = isset( $a['id'] ) ? $a['id'] : '';
774
+ $a = apply_filters( 'w3tc_ui_settings_item', $a );
775
 
776
  echo '<tr><th';
777
 
778
+ if ( isset( $a['label_class'] ) ) {
779
+ echo ' class="' . esc_attr( $a['label_class'] ) . '"';
780
+ }
781
  echo '>';
782
+ if ( isset( $a['label'] ) ) {
783
+ self::label( $id, $a['label'] );
784
+ }
785
 
786
  echo "</th>\n<td>\n";
787
 
788
  foreach ( $a as $key => $e ) {
789
+ if ( 'checkbox' === $key ) {
790
+ self::checkbox(
791
+ $id,
792
  isset( $e['name'] ) ? $e['name'] : null,
793
  $e['value'],
794
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
795
+ ( isset( $e['label'] ) ? $e['label'] : null )
796
+ );
797
+ } elseif ( 'description' === $key ) {
798
+ echo '<p class="description">' . wp_kses( $e, self::get_allowed_html_for_wp_kses_from_content( $e ) ) . '</p>';
799
+ } elseif ( 'hidden' === $key ) {
800
+ self::hidden( '', $e['name'], $e['value'] );
801
+ } elseif ( 'html' === $key ) {
802
+ echo wp_kses( $e, self::get_allowed_html_for_wp_kses_from_content( $e ) );
803
+ } elseif ( 'radiogroup' === $key ) {
804
+ self::radiogroup(
805
+ $e['name'],
806
+ $e['value'],
807
+ $e['values'],
808
+ $e['disabled'],
809
+ $e['separator']
810
+ );
811
+ } elseif ( 'selectbox' === $key ) {
812
+ self::selectbox(
813
+ $id,
814
+ $e['name'],
815
+ $e['value'],
816
+ $e['values'],
817
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
818
+ ( isset( $e['optgroups'] ) ? $e['optgroups'] : null )
819
+ );
820
+ } elseif ( 'textbox' === $key ) {
821
+ self::textbox(
822
+ $id,
823
+ $e['name'],
824
+ $e['value'],
825
  ( isset( $e['disabled'] ) ? $e['disabled'] : false ),
826
+ ( ! empty( $e['size'] ) ? $e['size'] : 20 ),
827
+ ( ! empty( $e['type'] ) ? $e['type'] : 'text' ),
828
+ ( ! empty( $e['placeholder'] ) ? $e['placeholder'] : '' )
829
+ );
830
+ } elseif ( 'textarea' === $key ) {
831
+ self::textarea(
832
+ $id,
833
+ $e['name'],
834
+ $e['value'],
835
+ ( isset( $e['disabled'] ) ? $e['disabled'] : false )
836
+ );
837
+ }
838
  }
839
 
840
+ echo "</td></tr>\n";
 
841
  }
842
 
843
  /**
857
  * control_after => something after control to add
858
  * description => description shown to the user below
859
  */
860
+ public static function config_item( $a ) {
861
  /*
862
  * Some items we do not want shown in the free edition.
863
  *
869
  return;
870
  }
871
 
872
+ $a = self::config_item_preprocess( $a );
873
 
874
+ if ( 'w3tc_single_column' === $a['label_class'] ) {
875
  echo '<tr><th colspan="2">';
876
  } else {
877
+ echo '<tr><th class="' . esc_attr( $a['label_class'] ) . '">';
878
 
879
+ if ( ! empty( $a['label'] ) ) {
880
+ self::label( $a['control_name'], $a['label'] );
881
  }
882
 
883
  echo "</th>\n<td>\n";
884
  }
885
 
886
+ self::control2( $a );
887
 
888
  if ( isset( $a['control_after'] ) ) {
889
+ echo wp_kses(
890
+ $a['control_after'],
891
+ self::get_allowed_html_for_wp_kses_from_content( $a['control_after'] )
892
+ );
893
  }
894
  if ( isset( $a['description'] ) ) {
895
+ echo wp_kses(
896
+ sprintf(
897
+ '%1$s%2$s%3$s',
898
+ '<p class="description">',
899
+ $a['description'],
900
+ '</p>'
901
+ ),
902
+ array(
903
+ 'p' => array(
904
+ 'class' => array(),
905
+ ),
906
+ 'acronym' => array(
907
+ 'title' => array(),
908
+ ),
909
+ )
910
+ );
911
  }
912
 
913
+ echo ( isset( $a['style'] ) ? '</th>' : '</td>' );
914
  echo "</tr>\n";
915
  }
916
 
917
+ public static function config_item_extension_enabled( $a ) {
 
 
918
  echo "<tr><th class=''></th>\n<td>\n";
919
 
920
  $c = Dispatcher::config();
921
+ self::checkbox2(
922
+ array(
923
+ 'name' => 'extension__' . self::config_key_to_http_name( $a['extension_id'] ),
924
+ 'value' => $c->is_extension_active_frontend( $a['extension_id'] ),
925
+ 'label' => $a['checkbox_label'],
926
+ )
927
+ );
928
 
929
  if ( isset( $a['description'] ) ) {
930
+ echo '<p class="description">' . wp_kses( $a['description'], self::get_allowed_html_for_wp_kses_from_content( $a['description'] ) ) . '</p>';
931
  }
932
 
933
+ echo "</td></tr>\n";
 
934
  }
935
 
936
+ public static function config_item_pro( $a ) {
937
+ $a = self::config_item_preprocess( $a );
938
 
939
+ if ( 'w3tc_no_trtd' !== $a['label_class'] ) {
940
+ echo '<tr><th class="' . esc_attr( $a['label_class'] ) . '">';
941
 
942
+ if ( ! empty( $a['label'] ) ) {
943
+ self::label( $a['control_name'], $a['label'] );
 
 
 
 
 
 
944
  }
945
 
946
  echo "</th>\n<td>\n";
947
  }
948
 
949
+ self::pro_wrap_maybe_start();
950
 
951
+ self::control2( $a );
952
 
953
  if ( isset( $a['control_after'] ) ) {
954
+ echo wp_kses( $a['control_after'], self::get_allowed_html_for_wp_kses_from_content( $a['control_after'] ) );
955
  }
956
 
957
  if ( isset( $a['description'] ) ) {
958
+ self::pro_wrap_description( $a['excerpt'], $a['description'], $a['control_name'] );
959
  }
960
 
961
+ self::pro_wrap_maybe_end( $a['control_name'] );
962
 
963
+ if ( 'w3tc_no_trtd' !== $a['label_class'] ) {
964
+ echo "</th></tr>\n";
 
965
  }
966
  }
967
 
968
+ public static function config_item_preprocess( $a ) {
 
 
969
  $c = Dispatcher::config();
970
 
971
+ if ( ! isset( $a['value'] ) || is_null( $a['value'] ) ) {
972
  $a['value'] = $c->get( $a['key'] );
973
+ if ( is_array( $a['value'] ) ) {
974
  $a['value'] = implode( "\n", $a['value'] );
975
+ }
976
  }
977
 
978
+ if ( ! isset( $a['disabled'] ) || is_null( $a['disabled'] ) ) {
979
  $a['disabled'] = $c->is_sealed( $a['key'] );
980
  }
981
 
982
  if ( empty( $a['label'] ) ) {
983
+ $a['label'] = self::config_label( $a['key'] );
984
  }
985
 
986
+ $a['control_name'] = self::config_key_to_http_name( $a['key'] );
987
+ $a['label_class'] = empty( $a['label_class'] ) ? '' : $a['label_class'];
988
+ if ( empty( $a['label_class'] ) && 'checkbox' === $a['control'] ) {
989
  $a['label_class'] = 'w3tc_config_checkbox';
990
  }
991
 
997
  return apply_filters( 'w3tc_ui_config_item_' . $action_key, $a );
998
  }
999
 
 
 
1000
  /**
1001
  * Displays config item - caching engine selectbox
1002
  */
1003
+ public static function config_item_engine( $a ) {
1004
  if ( isset( $a['empty_value'] ) && $a['empty_value'] ) {
1005
  $values[''] = array(
1006
+ 'label' => 'Please select a method',
1007
  );
1008
  }
1009
 
1010
+ $values['file'] = array(
1011
+ 'label' => __( 'Disk', 'w3-total-cache' ),
1012
+ 'optgroup' => 0,
1013
  );
1014
+ $values['apc'] = array(
1015
+ 'disabled' => ! Util_Installed::apc(),
1016
+ 'label' => __( 'Opcode: Alternative PHP Cache (APC / APCu)', 'w3-total-cache' ),
1017
+ 'optgroup' => 1,
1018
  );
1019
  $values['eaccelerator'] = array(
1020
+ 'disabled' => ! Util_Installed::eaccelerator(),
1021
+ 'label' => __( 'Opcode: eAccelerator', 'w3-total-cache' ),
1022
+ 'optgroup' => 1,
1023
  );
1024
+ $values['xcache'] = array(
1025
+ 'disabled' => ! Util_Installed::xcache(),
1026
+ 'label' => __( 'Opcode: XCache', 'w3-total-cache' ),
1027
+ 'optgroup' => 1,
1028
  );
1029
+ $values['wincache'] = array(
1030
+ 'disabled' => ! Util_Installed::wincache(),
1031
+ 'label' => __( 'Opcode: WinCache', 'w3-total-cache' ),
1032
+ 'optgroup' => 1,
1033
  );
1034
+ $values['memcached'] = array(
1035
+ 'disabled' => ! Util_Installed::memcached(),
1036
+ 'label' => __( 'Memcached', 'w3-total-cache' ),
1037
+ 'optgroup' => 2,
1038
  );
1039
+ $values['redis'] = array(
1040
+ 'disabled' => ! Util_Installed::redis(),
1041
+ 'label' => __( 'Redis', 'w3-total-cache' ),
1042
+ 'optgroup' => 2,
1043
  );
1044
 
1045
+ self::config_item(
1046
+ array(
1047
+ 'key' => $a['key'],
1048
+ 'label' => ( isset( $a['label'] ) ? $a['label'] : null ),
1049
+ 'disabled' => ( isset( $a['disabled'] ) ? $a['disabled'] : null ),
1050
+ 'control' => 'selectbox',
1051
+ 'selectbox_values' => $values,
1052
  'selectbox_optgroups' => array(
1053
  __( 'Shared Server:', 'w3-total-cache' ),
1054
  __( 'Dedicated / Virtual Server:', 'w3-total-cache' ),
1055
+ __( 'Multiple Servers:', 'w3-total-cache' ),
1056
  ),
1057
+ 'control_after' => isset( $a['control_after'] ) ? $a['control_after'] : null,
1058
+ )
1059
+ );
1060
  }
1061
 
1062
+ public static function pro_wrap_maybe_start() {
 
 
1063
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
1064
  return;
1065
  }
1070
  <?php
1071
  }
1072
 
1073
+ public static function pro_wrap_description( $excerpt_clean, $description, $data_href ) {
1074
+ echo '<p class="description w3tc-gopro-excerpt">' . wp_kses( $excerpt_clean, self::get_allowed_html_for_wp_kses_from_content( $excerpt_clean ) ) . '</p>';
1075
 
1076
+ if ( ! empty( $description ) ) {
 
 
 
 
1077
  $d = array_map(
1078
+ function( $e ) {
1079
+ return '<p class="description">' . wp_kses( $e, self::get_allowed_html_for_wp_kses_from_content( $e ) ) . '</p>';
1080
  },
1081
+ $description
1082
  );
1083
 
1084
+ $descriptions = implode( "\n", $d );
1085
+
1086
+ echo '<div class="w3tc-gopro-description">' . wp_kses( $descriptions, self::get_allowed_html_for_wp_kses_from_content( $descriptions ) ) . '</div>';
1087
+ echo '<a href="#" class="w3tc-gopro-more" data-href="w3tc-gopro-more-' . esc_url( $data_href ) . '">' . esc_html( __( 'Show More', 'w3-total-cache' ) ) . '<span class="dashicons dashicons-arrow-down-alt2"></span></a>';
1088
  }
1089
  }
1090
 
1091
+ public static function pro_wrap_maybe_end( $button_data_src ) {
 
 
1092
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
1093
  return;
1094
  }
1096
  ?>
1097
  </div>
1098
  <div class="w3tc-gopro-action">
1099
+ <button class="button w3tc-gopro-button button-buy-plugin" data-src="<?php echo esc_attr( $button_data_src ); ?>">
1100
  Learn more about Pro
1101
  </button>
1102
  </div>
1104
  <?php
1105
  }
1106
 
1107
+ public static function pro_wrap_maybe_start2() {
 
 
1108
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
1109
  return;
1110
  }
1115
  <?php
1116
  }
1117
 
1118
+ public static function pro_wrap_maybe_end2( $button_data_src ) {
 
 
1119
  if ( Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) {
1120
  return;
1121
  }
1123
  ?>
1124
  </p>
1125
  <div style="text-align: right">
1126
+ <button class="button w3tc-gopro-button button-buy-plugin" data-src="<?php echo esc_attr( $button_data_src ); ?>">
1127
  Unlock Feature
1128
  </button>
1129
  </div>
1137
  * On subblogs - shows button to enable/disable custom configuration
1138
  * $a['key'] - config key *_overloaded which are managed
1139
  */
1140
+ public static function config_overloading_button( $a ) {
1141
  $c = Dispatcher::config();
1142
+ if ( $c->is_master() ) {
1143
  return;
1144
+ }
1145
 
1146
  if ( $c->get_boolean( $a['key'] ) ) {
1147
+ $name = 'w3tc_config_overloaded_disable~' . self::config_key_to_http_name( $a['key'] );
 
1148
  $value = __( 'Use common settings', 'w3-total-cache' );
1149
  } else {
1150
+ $name = 'w3tc_config_overloaded_enable~' . self::config_key_to_http_name( $a['key'] );
 
1151
  $value = __( 'Use specific settings', 'w3-total-cache' );
1152
  }
1153
 
1154
  echo '<div style="float: right">';
1155
+ echo '<input type="submit" class="button"
1156
+ name="' . esc_attr( $name ) . '"
1157
+ value="' . esc_attr( $value ) . '" />';
1158
  echo '</div>';
1159
  }
1160
 
1173
  *
1174
  * @return string
1175
  */
1176
+ public static function preview_link() {
1177
+ return self::button_link(
1178
+ __( 'Preview', 'w3-total-cache' ),
1179
+ self::url( array( 'w3tc_default_previewing' => 'y' ) ),
1180
+ true
1181
+ );
1182
  }
1183
 
1184
  /**
1188
  * @param bool $string
1189
  * @return array|string
1190
  */
1191
+ public static function secs_to_time( $input, $string = true ) {
1192
+ $input = (float) $input;
1193
+ $time = array();
1194
+ $msecs = floor( $input * 1000 % 1000 );
1195
  $seconds = $input % 60;
1196
+
1197
+ $minutes = floor( $input / 60 ) % 60;
1198
+ $hours = floor( $input / 60 / 60 ) % 60;
1199
+
1200
+ if ( $hours ) {
1201
+ $time[] = $hours;
1202
+ }
1203
+ if ( $minutes ) {
1204
+ $time[] = sprintf( '%dm', $minutes );
1205
+ }
1206
+ if ( $seconds ) {
1207
+ $time[] = sprintf( '%ds', $seconds );
1208
+ }
1209
+ if ( $msecs ) {
1210
+ $time[] = sprintf( '%dms', $msecs );
1211
+ }
1212
+
1213
+ if ( empty( $time ) ) {
1214
+ $time[] = sprintf( '%dms', 0 );
1215
+ }
1216
+ if ( $string ) {
1217
  return implode( ' ', $time );
1218
+ }
1219
  return $time;
1220
  }
1221
 
 
 
1222
  /**
1223
  * Returns option name accepted by W3TC as http paramter
1224
  * from it's id (full name from config file)
1225
  */
1226
+ public static function config_key_to_http_name( $id ) {
1227
+ if ( is_array( $id ) ) {
1228
  $id = $id[0] . '___' . $id[1];
1229
+ }
1230
 
1231
  return str_replace( '.', '__', $id );
1232
  }
1233
 
 
 
1234
  /*
1235
  * Converts configuration key returned in http _GET/_POST
1236
  * to configuration key
1237
  */
1238
+ public static function config_key_from_http_name( $http_key ) {
1239
  $a = explode( '___', $http_key );
1240
+ if ( count( $a ) === 2 ) {
1241
+ $a[0] = self::config_key_from_http_name( $a[0] );
1242
+ $a[1] = self::config_key_from_http_name( $a[1] );
1243
  return $a;
1244
  }
1245
 
1246
  return str_replace( '__', '.', $http_key );
1247
  }
1248
+
1249
+ public static function get_allowed_html_for_wp_kses_from_content( $content ) {
1250
+ $allowed_html = array();
1251
+
1252
+ if( empty( $content ) ) {
1253
+ return $allowed_html;
1254
+ }
1255
+
1256
+ $dom = new DOMDocument();
1257
+ @$dom->loadHTML( $content );
1258
+ foreach ( $dom->getElementsByTagName( '*' ) as $tag ) {
1259
+ $tagname = $tag->tagName;
1260
+ foreach ( $tag->attributes as $attribute_name => $attribute_val ) {
1261
+ $allowed_html[ $tagname ][ $attribute_name ] = array();
1262
+ }
1263
+ $allowed_html[ $tagname ] = empty( $allowed_html[ $tagname ] ) ? array() : $allowed_html[ $tagname ];
1264
+ }
1265
+ return $allowed_html;
1266
+ }
1267
  }
Util_Widget.php CHANGED
@@ -1,8 +1,25 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  namespace W3TC;
3
 
 
 
 
4
  class Util_Widget {
5
- static $w3tc_dashboard_widgets = array();
 
 
 
 
 
 
6
 
7
  /**
8
  * Registers dashboard widgets.
@@ -10,19 +27,21 @@ class Util_Widget {
10
  * Handles POST data, sets up filters.
11
  *
12
  * @since 0.9.2.6
 
13
  */
14
- static public function setup() {
15
  global $w3tc_registered_widgets, $w3tc_registered_widget_controls, $w3tc_dashboard_control_callbacks;
 
16
  $w3tc_dashboard_control_callbacks = array();
17
- $screen = get_current_screen();
 
 
18
 
19
- $update = false;
20
- $widget_options = get_option( 'w3tc_dashboard_widget_options' );
21
- if ( !$widget_options || !is_array( $widget_options ) )
22
  $widget_options = array();
 
23
 
24
- // Hook to register new widgets
25
- // Filter widget order
26
  if ( is_network_admin() ) {
27
  do_action( 'w3tc_network_dashboard_setup' );
28
  $dashboard_widgets = apply_filters( 'w3tc_network_dashboard_widgets', array() );
@@ -32,90 +51,122 @@ class Util_Widget {
32
  }
33
 
34
  foreach ( $dashboard_widgets as $widget_id ) {
35
- $name = empty( $w3tc_registered_widgets[$widget_id]['all_link'] ) ? $w3tc_registered_widgets[$widget_id]['name'] : $w3tc_registered_widgets[$widget_id]['name'] . " <a href='{$w3tc_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all' ) . '</a>';
36
- Util_Widget::add( $widget_id, $name, $w3tc_registered_widgets[$widget_id]['callback'], $w3tc_registered_widget_controls[$widget_id]['callback'] );
37
  }
38
 
39
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) {
40
- check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
41
- ob_start(); // hack - but the same hack wp-admin/widgets.php uses
42
- Util_Widget::trigger_widget_control( $_POST['widget_id'] );
43
  ob_end_clean();
44
  }
45
 
46
- if ( $update )
47
  update_option( 'w3tc_dashboard_widget_options', $widget_options );
 
48
 
49
  do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
50
  do_action( 'do_meta_boxes', $screen->id, 'side', '' );
51
  }
52
 
53
- static public function add2( $widget_id, $priority, $widget_name, $callback,
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /**
3
+ * File: Util_Widget.php
4
+ *
5
+ * @package W3TC
6
+ *
7
+ * phpcs:disable Generic.Files.OneObjectStructurePerFile
8
+ */
9
+
10
  namespace W3TC;
11
 
12
+ /**
13
+ * Class: Util_Widget
14
+ */
15
  class Util_Widget {
16
+ /**
17
+ * Dashboard widgets.
18
+ *
19
+ * @var array
20
+ * @static
21
+ */
22
+ public static $w3tc_dashboard_widgets = array();
23
 
24
  /**
25
  * Registers dashboard widgets.
27
  * Handles POST data, sets up filters.
28
  *
29
  * @since 0.9.2.6
30
+ * @static
31
  */
32
+ public static function setup() {
33
  global $w3tc_registered_widgets, $w3tc_registered_widget_controls, $w3tc_dashboard_control_callbacks;
34
+
35
  $w3tc_dashboard_control_callbacks = array();
36
+ $screen = get_current_screen();
37
+ $update = false;
38
+ $widget_options = get_option( 'w3tc_dashboard_widget_options' );
39
 
40
+ if ( ! $widget_options || ! is_array( $widget_options ) ) {
 
 
41
  $widget_options = array();
42
+ }
43
 
44
+ // Hook to register new widgets. Filter widget order.
 
45
  if ( is_network_admin() ) {
46
  do_action( 'w3tc_network_dashboard_setup' );
47
  $dashboard_widgets = apply_filters( 'w3tc_network_dashboard_widgets', array() );
51
  }
52
 
53
  foreach ( $dashboard_widgets as $widget_id ) {
54
+ $name = empty( $w3tc_registered_widgets[ $widget_id ]['all_link'] ) ? $w3tc_registered_widgets[ $widget_id ]['name'] : $w3tc_registered_widgets[ $widget_id ]['name'] . " <a href='{$w3tc_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all', 'w3-total-cache' ) . '</a>';
55
+ self::add( $widget_id, $name, $w3tc_registered_widgets[ $widget_id ]['callback'], $w3tc_registered_widget_controls[ $widget_id ]['callback'] );
56
  }
57
 
58
+ if ( 'POST' === isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : '' && ! empty( Util_Request::get_string( 'widget_id' ) ) ) {
59
+ check_admin_referer( 'edit-dashboard-widget_' . Util_Request::get_string( 'widget_id' ), 'dashboard-widget-nonce' );
60
+ ob_start(); // The same hack "wp-admin/widgets.php" uses.
61
+ self::trigger_widget_control( Util_Request::get_string( 'widget_id' ) );
62
  ob_end_clean();
63
  }
64
 
65
+ if ( $update ) {
66
  update_option( 'w3tc_dashboard_widget_options', $widget_options );
67
+ }
68
 
69
  do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
70
  do_action( 'do_meta_boxes', $screen->id, 'side', '' );
71
  }
72
 
73
+ /**
74
+ * Add 2.
75
+ *
76
+ * @static
77
+ *
78
+ * @param string $widget_id Widget id.
79
+ * @param int $priority Prioroty.
80
+ * @param string $widget_name Widget name.
81
+ * @param callable $callback Callback.
82
+ * @param callable $control_callback Control callback.
83
+ * @param string $location Location.
84
+ * @param string $header_text Header t