| 1 |
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?> |
| 2 |
|
| 3 |
<div class="wpo_section wpo_group"> |
| 4 |
|
| 5 |
<h3 class="wpo-first-child"><?php _e('Browser static file caching settings (via headers)', 'wp-optimize');?></h3> |
| 6 |
<p> |
| 7 |
<?php echo __("Browser static file caching uses HTTP response headers to advise a visitor's browser to cache non-changing files for a while, so that it doesn't attempt to retrieve them upon every visit.", 'wp-optimize').' '.sprintf('<a href="%s" target="_blank">%s</a>', $info_link, __('Follow this link to get more information.', 'wp-optimize')); ?> |
| 8 |
</p> |
| 9 |
|
| 10 |
<div class="wpo-fieldgroup"> |
| 11 |
<?php if ($is_cloudflare_site) : ?> |
| 12 |
<p class="wpo-enabled"><span class="dashicons dashicons-yes"></span> |
| 13 |
<em><?php _e('Your website seems to use Cloudflare, which handles the browser caching rules.', 'wp-optimize'); ?></em> |
| 14 |
</p> |
| 15 |
|
| 16 |
<?php else : ?> |
| 17 |
|
| 18 |
<div id="wpo_browser_cache_status" class="<?php echo $class_name; ?>"> |
| 19 |
<span class="wpo-enabled"><span class="dashicons dashicons-yes"></span> <?php printf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.__('enabled', 'wp-optimize').'</strong>'); ?></span> |
| 20 |
<span class="wpo-disabled"><?php printf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.__('disabled', 'wp-optimize').'</strong>'); ?></span> |
| 21 |
</div> |
| 22 |
|
| 23 |
<br> |
| 24 |
|
| 25 |
<?php |
| 26 |
|
| 27 |
// add browser cache control section only if browser cache disabled or we added cache settings to .htaccess. |
| 28 |
if (false == $wpo_browser_cache_enabled || $wpo_browser_cache_settings_added) { |
| 29 |
?> |
| 30 |
|
| 31 |
<div id="wpo_browser_cache_error_message" class="notice error below-h2"><?php |
| 32 |
if (is_wp_error($wpo_browser_cache_enabled) && $wp_optimize->is_apache_server()) { |
| 33 |
echo htmlspecialchars($wpo_browser_cache_enabled->get_error_message()); |
| 34 |
} |
| 35 |
?></div> |
| 36 |
|
| 37 |
<?php |
| 38 |
if ($wp_optimize->is_apache_server()) { |
| 39 |
$button_text = $wpo_browser_cache_enabled ? __('Update', 'wp-optimize') : __('Enable', 'wp-optimize'); |
| 40 |
?> |
| 41 |
<form> |
| 42 |
<input type="hidden" id="wpo_enable_browser_cache" class="cache-settings" name="enable_browser_cache" value="<?php echo $wpo_browser_cache_enabled ? 'true' : 'false'; ?>" /> |
| 43 |
<label><?php _e('Expiration time:', 'wp-optimize'); ?></label> |
| 44 |
<input id="wpo_browser_cache_expire_days" class="cache-settings" type="number" min="0" step="1" name="browser_cache_expire_days" value="<?php echo esc_attr($wpo_browser_cache_expire_days); ?>"> |
| 45 |
<label for="wpo_browser_cache_expire"><?php _e('day(s)', 'wp-optimize'); ?></label> |
| 46 |
<input id="wpo_browser_cache_expire_hours" class="cache-settings" type="number" min="0" step="1" name="browser_cache_expire_hours" value="<?php echo esc_attr($wpo_browser_cache_expire_hours); ?>"> |
| 47 |
<label for="wpo_browser_cache_expire_hours"><?php _e('hour(s)', 'wp-optimize'); ?></label> |
| 48 |
<button class="button-primary" type="button" id="wp_optimize_browser_cache_enable"><?php echo $button_text; ?></button> |
| 49 |
<img class="wpo_spinner display-none" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>" |
| 50 |
width="20" height="20" alt="..."> |
| 51 |
<p><?php _e('Empty or 0 values disable the headers.', 'wp-optimize'); ?></p> |
| 52 |
</form> |
| 53 |
<?php |
| 54 |
} else { |
| 55 |
printf('<a href="%s" target="_blank">%s</a>', $faq_link, __('Follow this link to read the article about how to enable browser cache with your server software.', 'wp-optimize')); |
| 56 |
} |
| 57 |
?> |
| 58 |
|
| 59 |
<div id="wpo_browser_cache_message"></div> |
| 60 |
<pre id="wpo_browser_cache_output" style="display: none;"></pre> |
| 61 |
<?php |
| 62 |
} |
| 63 |
|
| 64 |
endif; |
| 65 |
?> |
| 66 |
</div><!-- END .wpo-fieldgroup --> |
| 67 |
</div><!-- END .wpo_section --> |
| 68 |
|