-
Notifications
You must be signed in to change notification settings - Fork 85
/
CacheGroups_Plugin_Admin_View.php
341 lines (318 loc) · 15.2 KB
/
CacheGroups_Plugin_Admin_View.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<?php
/**
* File: CacheGroups_Plugin_Admin_View.php
*
* @since 2.1.0
*
* @package W3TC
*
* @uses $useragent_groups
* @uses $useragent_themes
* @uses $referrer_groups
* @uses $referrer_themes
* @uses $cookie_groups
*/
namespace W3TC;
if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<form id="cachegroups_form" action="admin.php?page=<?php echo esc_attr( $this->_page ); ?>" method="post">
<?php Util_UI::print_control_bar( 'cachegroups_form_control' ); ?>
<!-- User Agenet Groups -->
<script type="text/javascript">/*<![CDATA[*/
var mobile_themes = {};
<?php foreach ( $useragent_themes as $theme_key => $theme_name ) : ?>
mobile_themes['<?php echo esc_attr( addslashes( $theme_key ) ); ?>'] = '<?php echo esc_html( addslashes( $theme_name ) ); ?>';
<?php endforeach; ?>
/*]]>*/</script>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Manage User Agent Groups', 'w3-total-cache' ), '', 'manage-uag' ); ?>
<p>
<input id="mobile_add" type="button" class="button"
<?php disabled( $useragent_groups['disabled'] ); ?>
value="<?php esc_html_e( 'Create a group', 'w3-total-cache' ); ?>" />
<?php esc_html_e( 'of user agents by specifying names in the user agents field. Assign a set of user agents to use a specific theme, redirect them to another domain or if an existing mobile plugin is active, create user agent groups to ensure that a unique cache is created for each user agent group. Drag and drop groups into order (if needed) to determine their priority (top -> down).', 'w3-total-cache' ); ?>
</p>
<ul id="mobile_groups">
<?php
$index = 0;
foreach ( $useragent_groups['value'] as $group => $group_config ) :
$index++;
?>
<li id="mobile_group_<?php echo esc_attr( $group ); ?>">
<table class="form-table">
<tr>
<th>
<?php esc_html_e( 'Group name:', 'w3-total-cache' ); ?>
</th>
<td>
<span class="mobile_group_number"><?php echo esc_attr( $index ); ?>.</span> <span class="mobile_group"><?php echo esc_html( $group ); // phpcs:ignore ?></span>
<input type="button" class="button mobile_delete"
value="<?php esc_html_e( 'Delete group', 'w3-total-cache' ); ?>"
<?php disabled( $useragent_groups['disabled'] ); ?> />
</td>
</tr>
<tr>
<th>
<label for="mobile_groups_<?php echo esc_attr( $group ); ?>_enabled"><?php esc_html_e( 'Enabled:', 'w3-total-cache' ); ?></label>
</th>
<td>
<input type="hidden" name="mobile_groups[<?php echo esc_attr( $group ); ?>][enabled]" value="0" />
<input id="mobile_groups_<?php echo esc_attr( $group ); ?>_enabled"
class="mobile_group_enabled" type="checkbox"
name="mobile_groups[<?php echo esc_attr( $group ); ?>][enabled]"
<?php disabled( $useragent_groups['disabled'] ); ?> value="1"
<?php checked( $group_config['enabled'], true ); ?> />
</td>
</tr>
<tr>
<th>
<label for="mobile_groups_<?php echo esc_attr( $group ); ?>_theme"><?php esc_html_e( 'Theme:', 'w3-total-cache' ); ?></label>
</th>
<td>
<select id="mobile_groups_<?php echo esc_attr( $group ); ?>_theme"
name="mobile_groups[<?php echo esc_attr( $group ); ?>][theme]"
<?php disabled( $useragent_groups['disabled'] ); ?> >
<option value=""><?php esc_html_e( '-- Pass-through --', 'w3-total-cache' ); ?></option>
<?php foreach ( $useragent_themes as $theme_key => $theme_name ) : ?>
<option value="<?php echo esc_attr( $theme_key ); ?>"<?php selected( $theme_key, $group_config['theme'] ); ?>><?php echo esc_html( $theme_name ); ?></option>
<?php endforeach; ?>
</select>
<p class="description">
<?php esc_html_e( 'Assign this group of user agents to a specific theme. Selecting "Pass-through" allows any plugin(s) (e.g. mobile plugins) to properly handle requests for these user agents. If the "redirect users to" field is not empty, this setting is ignored.', 'w3-total-cache' ); ?>
</p>
</td>
</tr>
<tr>
<th>
<label for="mobile_groups_<?php echo esc_attr( $group ); ?>_redirect"><?php esc_html_e( 'Redirect users to:', 'w3-total-cache' ); ?></label>
</th>
<td>
<input id="mobile_groups_<?php echo esc_attr( $group ); ?>_redirect"
type="text" name="mobile_groups[<?php echo esc_attr( $group ); ?>][redirect]"
value="<?php echo esc_attr( $group_config['redirect'] ); ?>"
<?php disabled( $useragent_groups['disabled'] ); ?>
size="60" />
<p class="description"><?php esc_html_e( 'A 302 redirect is used to send this group of users to another hostname (domain); recommended if a 3rd party service provides a mobile version of your site.', 'w3-total-cache' ); ?></p>
</td>
</tr>
<tr>
<th>
<label for="mobile_groups_<?php echo esc_attr( $group ); ?>_agents"><?php esc_html_e( 'User agents:', 'w3-total-cache' ); ?></label>
</th>
<td>
<textarea id="mobile_groups_<?php echo esc_attr( $group ); ?>_agents"
name="mobile_groups[<?php echo esc_attr( $group ); ?>][agents]"
rows="10" cols="50" <?php disabled( $useragent_groups['disabled'] ); ?>><?php echo esc_textarea( implode( "\r\n", (array) $group_config['agents'] ) ); ?></textarea>
<p class="description">
<?php esc_html_e( 'Specify the user agents for this group. Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported.', 'w3-total-cache' ); ?>
</p>
</td>
</tr>
</table>
</li>
<?php endforeach; ?>
</ul>
<div id="mobile_groups_empty" style="display: none;"><?php esc_html_e( 'No groups added. All user agents receive the same page and minify cache results.', 'w3-total-cache' ); ?></div>
<?php
Util_Ui::postbox_footer();
Util_Ui::postbox_header(
__( 'Note(s):', 'w3-total-cache' ),
'',
'notes'
);
?>
<table class="form-table">
<tr>
<th colspan="2">
<ul>
<?php echo $useragent_groups['description']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</ul>
</th>
</tr>
</table>
<?php Util_Ui::postbox_footer(); ?>
</div>
<!-- Referrer Groups -->
<script type="text/javascript">/*<![CDATA[*/
var referrer_themes = {};
<?php foreach ( $referrer_themes as $theme_key => $theme_name ) : ?>
referrer_themes['<?php echo esc_attr( $theme_key ); ?>'] = '<?php echo esc_html( $theme_name ); ?>';
<?php endforeach; ?>
/*]]>*/</script>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Manage Referrer Groups', 'w3-total-cache' ), '', 'manage-rg' ); ?>
<p>
<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 -> down).', 'w3-total-cache' ); ?>
</p>
<ul id="referrer_groups">
<?php
$index = 0;
foreach ( $referrer_groups as $group => $group_config ) :
$index++;
?>
<li id="referrer_group_<?php echo esc_attr( $group ); ?>">
<table class="form-table">
<tr>
<th>
<?php esc_html_e( 'Group name:', 'w3-total-cache' ); ?>
</th>
<td>
<span class="referrer_group_number"><?php echo esc_attr( $index ); ?>.</span> <span class="referrer_group"><?php echo esc_html( $group ); ?></span> <input type="button" class="button referrer_delete" value="<?php esc_html_e( 'Delete group', 'w3-total-cache' ); ?>" />
</td>
</tr>
<tr>
<th>
<label for="referrer_groups_<?php echo esc_attr( $group ); ?>_enabled"><?php esc_html_e( 'Enabled:', 'w3-total-cache' ); ?></label>
</th>
<td>
<input type="hidden" name="referrer_groups[<?php echo esc_attr( $group ); ?>][enabled]" value="0" />
<input id="referrer_groups_<?php echo esc_attr( $group ); ?>_enabled"
class="referrer_group_enabled" type="checkbox"
name="referrer_groups[<?php echo esc_attr( $group ); ?>][enabled]"
value="1"<?php checked( $group_config['enabled'], true ); ?> />
</td>
</tr>
<tr>
<th>
<label for="referrer_groups_<?php echo esc_attr( $group ); ?>_theme"><?php esc_html_e( 'Theme:', 'w3-total-cache' ); ?></label>
</th>
<td>
<select id="referrer_groups_<?php echo esc_attr( $group ); ?>_theme" name="referrer_groups[<?php echo esc_attr( $group ); ?>][theme]">
<option value=""><?php esc_html_e( '-- Pass-through --', 'w3-total-cache' ); ?></option>
<?php foreach ( $referrer_themes as $theme_key => $theme_name ) : ?>
<option value="<?php echo esc_attr( $theme_key ); ?>"<?php selected( $theme_key, $group_config['theme'] ); ?>><?php echo esc_html( $theme_name ); ?></option>
<?php endforeach; ?>
</select>
<p class="description"><?php esc_html_e( 'Assign this group of referrers to a specific theme. Selecting "Pass-through" allows any plugin(s) (e.g. referrer plugins) to properly handle requests for these referrers. If the "redirect users to" field is not empty, this setting is ignored.', 'w3-total-cache' ); ?></p>
</td>
</tr>
<tr>
<th>
<label for="referrer_groups_<?php echo esc_attr( $group ); ?>_redirect"><?php esc_html_e( 'Redirect users to:', 'w3-total-cache' ); ?></label>
</th>
<td>
<input id="referrer_groups_<?php echo esc_attr( $group ); ?>_redirect" type="text" name="referrer_groups[<?php echo esc_attr( $group ); ?>][redirect]" value="<?php echo esc_attr( $group_config['redirect'] ); ?>" size="60" />
<p class="description"><?php esc_html_e( 'A 302 redirect is used to send this group of referrers to another hostname (domain).', 'w3-total-cache' ); ?></p>
</td>
</tr>
<tr>
<th>
<label for="referrer_groups_<?php echo esc_attr( $group ); ?>_referrers"><?php esc_html_e( 'Referrers:', 'w3-total-cache' ); ?></label>
</th>
<td>
<textarea id="referrer_groups_<?php echo esc_attr( $group ); ?>_referrers" name="referrer_groups[<?php echo esc_attr( $group ); ?>][referrers]" rows="10" cols="50"><?php echo esc_textarea( implode( "\r\n", (array) $group_config['referrers'] ) ); ?></textarea>
<p class="description"><?php esc_html_e( 'Specify the referrers for this group. Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported.', 'w3-total-cache' ); ?></p>
</td>
</tr>
</table>
</li>
<?php endforeach; ?>
</ul>
<div id="referrer_groups_empty" style="display: none;"><?php esc_html_e( 'No groups added. All referrers receive the same page and minify cache results.', 'w3-total-cache' ); ?></div>
<?php Util_Ui::postbox_footer(); ?>
</div>
<!-- Cookie Groups -->
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Manage Cookie Groups', 'w3-total-cache' ), '', 'manage-cg' ); ?>
<p>
<input id="w3tc_cookiegroup_add" type="button" class="button"
<?php disabled( $cookie_groups['disabled'] ); ?>
value="<?php esc_html_e( 'Create a group', 'w3-total-cache' ); ?>" />
<?php esc_html_e( 'of Cookies by specifying names in the Cookies field. Assign a set of Cookies to ensure that a unique cache is created for each Cookie group. Drag and drop groups into order (if needed) to determine their priority (top -> down).', 'w3-total-cache' ); ?>
</p>
<ul id="cookiegroups" class="w3tc_cachegroups">
<?php
$index = 0;
foreach ( $cookie_groups['value'] as $group => $group_config ) :
$index++;
?>
<li id="cookiegroup_<?php echo esc_attr( $group ); ?>">
<table class="form-table">
<tr>
<th>
<?php esc_html_e( 'Group name:', 'w3-total-cache' ); ?>
</th>
<td>
<span class="cookiegroup_number"><?php echo esc_attr( $index ); ?>.</span>
<span class="cookiegroup_name"><?php echo htmlspecialchars( $group ); // phpcs:ignore ?></span>
<input type="button" class="button w3tc_cookiegroup_delete"
value="<?php esc_html_e( 'Delete group', 'w3-total-cache' ); ?>"
<?php disabled( $cookie_groups['disabled'] ); ?> />
</td>
</tr>
<tr>
<th>
<label for="cookiegroup_<?php echo esc_attr( $group ); ?>_enabled">
<?php esc_html_e( 'Enabled:', 'w3-total-cache' ); ?>
</label>
</th>
<td>
<input id="cookiegroup_<?php echo esc_attr( $group ); ?>_enabled"
class="cookiegroup_enabled" type="checkbox"
name="cookiegroups[<?php echo esc_attr( $group ); ?>][enabled]"
<?php disabled( $cookie_groups['disabled'] ); ?> value="1"
<?php checked( $group_config['enabled'], true ); ?> />
</td>
</tr>
<tr>
<th>
<label for="cookiegroup_<?php echo esc_attr( $group ); ?>_cache">
<?php esc_html_e( 'Cache:', 'w3-total-cache' ); ?>
</label>
</th>
<td>
<input id="cookiegroup_<?php echo esc_attr( $group ); ?>_cache"
type="checkbox"
name="cookiegroups[<?php echo esc_attr( $group ); ?>][cache]"
<?php disabled( $cookie_groups['disabled'] ); ?> value="1"
<?php checked( $group_config['cache'], true ); ?> /> <?php esc_html_e( 'Enable', 'w3-total-cache' ); ?>
<p class="description"><?php esc_html_e( 'Controls whether web pages can be cached or not when cookies from this group are detected.', 'w3-total-cache' ); ?></p>
</td>
</tr>
<tr>
<th>
<label for="cookiegroup_<?php echo esc_attr( $group ); ?>_cookies">
<?php esc_html_e( 'Cookies:', 'w3-total-cache' ); ?>
</label>
</th>
<td>
<textarea id="cookiegroup_<?php echo esc_attr( $group ); ?>_cookies"
name="cookiegroups[<?php echo esc_attr( $group ); ?>][cookies]"
rows="10" cols="50" <?php disabled( $cookie_groups['disabled'] ); ?>><?php echo esc_textarea( implode( "\r\n", (array) $group_config['cookies'] ) ); ?></textarea>
<p class="description">
<?php esc_html_e( 'Specify the cookies for this group. Values like \'cookie\', \'cookie=value\', and cookie[a-z]+=value[a-z]+ are supported. Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported.', 'w3-total-cache' ); ?>
</p>
</td>
</tr>
</table>
</li>
<?php endforeach; ?>
</ul>
<div id="cookiegroups_empty" style="display: none;"><?php esc_html_e( 'No groups added. All Cookies receive the same page and minify cache results.', 'w3-total-cache' ); ?></div>
<?php
Util_Ui::postbox_footer();
Util_Ui::postbox_header(
__( 'Note(s):', 'w3-total-cache' ),
'',
'notes'
);
?>
<table class="form-table">
<tr>
<th colspan="2">
<ul>
<li>
<?php esc_html_e( 'Content is cached for each group separately.', 'w3-total-cache' ); ?>
</li>
<li>
<?php esc_html_e( 'Per the above, make sure that visitors are notified about the cookie as per any regulations in your market.', 'w3-total-cache' ); ?>
</li>
</ul>
</th>
</tr>
</table>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>