PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.5.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.5.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / templates / cache / browser-cache.php

browser-cache.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.5.0, at templates/cache/browser-cache.php

85 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 esc_html_e('Browser static file caching settings (via headers)', 'wp-optimize');?></h3>
6 <p>
7 <?php echo esc_html__("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>', esc_url($info_link), esc_html__('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 esc_html_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 esc_attr($class_name); ?>">
19 <span class="wpo-enabled"><span class="dashicons dashicons-yes"></span> <?php echo strip_tags(sprintf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.esc_html__('enabled', 'wp-optimize').'</strong>'), '<strong>'); ?></span>
20 <span class="wpo-disabled"><?php echo strip_tags(sprintf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.esc_html__('disabled', 'wp-optimize').'</strong>'), '<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 esc_html($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 esc_html_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 esc_html_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 esc_html_e('hour(s)', 'wp-optimize'); ?></label>
48 <button class="button-primary" type="button" id="wp_optimize_browser_cache_enable"><?php echo esc_html($button_text); ?></button>
49 <img class="wpo_spinner display-none" src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>"
50 width="20" height="20" alt="...">
51 <p><?php esc_html_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>', esc_url($faq_link), esc_html__('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"><?php
60 if (false == $wpo_browser_cache_enabled && $wpo_browser_cache_settings_added) {
61 ?>
62 <div class="notice notice-error">
63 <p>
64 <?php
65 $message = esc_html__('The .htaccess file already contains browser static caching settings, but browser caching is not functioning as expected.', 'wp-optimize');
66 $message .= ' ';
67 $message .= esc_html__('This indicates that your webserver does not support .htaccess browser caching rules.', 'wp-optimize');
68 $message .= ' ';
69 $message .= esc_html__('To further investigate this, you must contact your web hosting provider.', 'wp-optimize');
70 echo $message; // phpcs:ignore WordPress.Security.EscapeOutput -- Output is already escaped
71 ?>
72 </p>
73 </div>
74 <?php
75 }
76 ?></div>
77 <pre id="wpo_browser_cache_output" style="display: none;"></pre>
78 <?php
79 }
80
81 endif;
82 ?>
83 </div><!-- END .wpo-fieldgroup -->
84 </div><!-- END .wpo_section -->
85