| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
?> |
| 6 |
<tr> |
| 7 |
<th scope="row">Cache-Control |
| 8 |
<p class="description"><?php esc_html_e('The Cache-Control general-header field is used to specify directives for caching mechanisms in both, requests and responses. Caching directives are unidirectional, meaning that a given directive in a request is not implying that the same directive is to be given in the response.', 'http-headers'); ?></p> |
| 9 |
<hr> |
| 10 |
<p class="description"><?php esc_html_e('Read more at', 'http-headers'); ?> |
| 11 |
<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control"><?php esc_html_e('MDN Web Docs', 'http-headers'); ?></a> |
| 12 |
</p> |
| 13 |
</th> |
| 14 |
<td> |
| 15 |
<fieldset> |
| 16 |
<legend class="screen-reader-text">Cache-Control</legend> |
| 17 |
<?php |
| 18 |
$http_headers_cache_control = get_option('hh_cache_control', 0); |
| 19 |
foreach ($http_headers_bools as $http_headers_k => $http_headers_v) |
| 20 |
{ |
| 21 |
?><p><label><input type="radio" class="http-header" name="hh_cache_control" value="<?php echo esc_attr($http_headers_k); ?>"<?php checked($http_headers_cache_control, $http_headers_k); ?> /> <?php echo esc_html($http_headers_v); ?></label></p><?php |
| 22 |
} |
| 23 |
?> |
| 24 |
</fieldset> |
| 25 |
</td> |
| 26 |
<td> |
| 27 |
<?php settings_fields( 'http-headers-cc' ); ?> |
| 28 |
<?php do_settings_sections( 'http-headers-cc' ); ?> |
| 29 |
<?php |
| 30 |
$http_headers_items = array( |
| 31 |
'must-revalidate' => 'bool', |
| 32 |
'no-cache' => 'bool', |
| 33 |
'no-store' => 'bool', |
| 34 |
'no-transform' => 'bool', |
| 35 |
'public' => 'bool', |
| 36 |
'private' => 'bool', |
| 37 |
'proxy-revalidate' => 'bool', |
| 38 |
'max-age' => 'int', |
| 39 |
's-maxage' => 'int', |
| 40 |
'immutable' => 'bool', |
| 41 |
'stale-while-revalidate' => 'int', |
| 42 |
'stale-if-error' => 'int', |
| 43 |
); |
| 44 |
?> |
| 45 |
<table> |
| 46 |
<?php |
| 47 |
$http_headers_cache_control_value = get_option('hh_cache_control_value'); |
| 48 |
if (!$http_headers_cache_control_value) |
| 49 |
{ |
| 50 |
$http_headers_cache_control_value = array(); |
| 51 |
} |
| 52 |
foreach ($http_headers_items as $http_headers_item => $http_headers_type) |
| 53 |
{ |
| 54 |
?> |
| 55 |
<tr> |
| 56 |
<td><label for="hh_cache_control_value_<?php echo esc_attr($http_headers_item); ?>"><?php echo esc_html($http_headers_item); ?></label></td> |
| 57 |
<td><?php |
| 58 |
switch ($http_headers_type) { |
| 59 |
case 'bool': |
| 60 |
?><input type="checkbox" class="http-header-value" name="hh_cache_control_value[<?php echo esc_attr($http_headers_item); ?>]" id="hh_cache_control_value_<?php echo esc_attr($http_headers_item); ?>" value="1"<?php checked(array_key_exists($http_headers_item, $http_headers_cache_control_value), 1, true); ?>><?php |
| 61 |
break; |
| 62 |
case 'int': |
| 63 |
?><input type="text" class="http-header-value" name="hh_cache_control_value[<?php echo esc_attr($http_headers_item); ?>]" id="hh_cache_control_value_<?php echo esc_attr($http_headers_item); ?>" size="6" value="<?php echo array_key_exists($http_headers_item, $http_headers_cache_control_value) && strlen($http_headers_cache_control_value[$http_headers_item]) > 0 ? (int) $http_headers_cache_control_value[$http_headers_item] : NULL; ?>"> <?php esc_html_e('seconds', 'http-headers'); |
| 64 |
break; |
| 65 |
} |
| 66 |
?> |
| 67 |
</td> |
| 68 |
</tr> |
| 69 |
<?php |
| 70 |
} |
| 71 |
?> |
| 72 |
</table> |
| 73 |
</td> |
| 74 |
</tr> |