PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.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
← All changes | templates/cache/browser-cache.php +78 -35 3.2.5 → 4.7.0 View file →
@@ -1,24 +1,34 @@
1 -<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?>
1 +<?php if (!defined('ABSPATH')) die('No direct access allowed'); ?>
2 2
3 3 <div class="wpo_section wpo_group">
4 4
5 - <h3 class="wpo-first-child"><?php _e('Browser static file caching settings (via headers)', 'wp-optimize');?></h3>
5 + <h3 class="wpo-first-child"><?php esc_html_e('Browser static file caching settings (via headers)', 'wp-optimize');?></h3>
6 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')); ?>
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 8 </p>
9 9
10 10 <div class="wpo-fieldgroup">
11 - <?php if ($is_cloudflare_site) : ?>
11 + <?php if ($is_cloudflare_handling_browser_cache) : ?>
12 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>
13 + <em><?php esc_html_e('Your website seems to use Cloudflare, which handles the browser caching rules.', 'wp-optimize'); ?></em>
14 14 </p>
15 15
16 16 <?php else : ?>
17 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>
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>
20 + <?php
21 + // translators: %s is the word "enabled" in bold
22 + echo wp_kses_post(sprintf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.esc_html__('enabled', 'wp-optimize').'</strong>'));
23 + ?>
24 + </span>
25 + <span class="wpo-disabled">
26 + <?php
27 + // translators: %s is the word "disabled" in bold
28 + echo wp_kses_post(sprintf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.esc_html__('disabled', 'wp-optimize').'</strong>'));
29 + ?>
30 + </span>
21 31 </div>
22 32
23 33 <br>
24 34
@@ -24,41 +34,74 @@
24 34
25 35 <?php
26 36
27 37 // 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 - ?>
38 + if (false === $wpo_browser_cache_enabled || $wpo_browser_cache_settings_added || is_wp_error($wpo_browser_cache_enabled)) {
39 + if (is_wp_error($wpo_browser_cache_enabled)) {
40 + ?>
41 + <div id="wpo_browser_cache_error_message" class="notice error below-h2">
42 + <p>
43 + <b><?php esc_html_e('Error: Unable to Check browser cache.', 'wp-optimize'); ?></b>
44 + <?php esc_html_e('We encountered a problem while checking if browser cache is enabled.', 'wp-optimize'); ?>
45 + </p>
46 + <p><?php echo wp_kses_post($wpo_browser_cache_enabled->get_error_message()); ?></p>
47 + </div>
48 + <?php
49 + } else {
50 + if ($wp_optimize->is_apache_server()) {
51 + $button_text = $wpo_browser_cache_enabled ? __('Update', 'wp-optimize') : __('Enable', 'wp-optimize');
52 + ?>
53 + <form>
54 + <input type="hidden" id="wpo_enable_browser_cache" class="cache-settings" name="enable_browser_cache" value="<?php echo $wpo_browser_cache_enabled ? 'true' : 'false'; ?>" />
55 + <label><?php esc_html_e('Expiration time:', 'wp-optimize'); ?></label>
56 + <input id="wpo_browser_cache_expire_days" class="cache-settings wpo_browser_cache_input" type="number" min="0" step="1" name="browser_cache_expire_days" value="<?php echo esc_attr($wpo_browser_cache_expire_days); ?>">
57 + <label for="wpo_browser_cache_expire_days"><?php esc_html_e('day(s)', 'wp-optimize'); ?></label>
58 + <input id="wpo_browser_cache_expire_hours" class="cache-settings wpo_browser_cache_input" type="number" min="0" step="1" name="browser_cache_expire_hours" value="<?php echo esc_attr($wpo_browser_cache_expire_hours); ?>">
59 + <label for="wpo_browser_cache_expire_hours"><?php esc_html_e('hour(s)', 'wp-optimize'); ?></label>
60 + <button class="button-primary" type="button" id="wp_optimize_browser_cache_enable"><?php echo esc_html($button_text); ?></button>
61 + <img class="wpo_spinner display-none" src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- N/A ?>"
62 + width="20" height="20" alt="...">
63 + <p><?php esc_html_e('Empty or 0 values disable the headers.', 'wp-optimize'); ?></p>
64 + </form>
65 + <?php
66 + } else {
67 + 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'));
68 + }
69 +
70 + ?>
30 71
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());
72 + <div id="wpo_browser_cache_message"><?php
73 + if (false === $wpo_browser_cache_enabled && $wpo_browser_cache_settings_added) {
74 + ?>
75 + <div class="notice notice-error">
76 + <p>
77 + <?php
78 + $message = esc_html__('The .htaccess file already contains browser static caching settings, but browser caching is not functioning as expected.', 'wp-optimize');
79 + $message .= ' ';
80 + $message .= esc_html__('This indicates that your webserver does not support .htaccess browser caching rules.', 'wp-optimize');
81 + $message .= ' ';
82 + $message .= esc_html__('To further investigate this, you must contact your web hosting provider.', 'wp-optimize');
83 + echo $message; // phpcs:ignore WordPress.Security.EscapeOutput -- Output is already escaped
84 + ?>
85 + </p>
86 + </div>
87 + <?php
34 88 }
35 89 ?></div>
36 90
91 + <?php if ('' !== $wpo_browser_cache_error_message) { ?>
92 + <div id="wpo_browser_cache_error_message" class="notice notice-error"><?php echo esc_html($wpo_browser_cache_error_message); ?></div>
93 + <?php } else { ?>
94 + <div id="wpo_browser_cache_error_message" class="notice notice-error" style="display: none;"></div>
95 + <?php } ?>
96 +
97 + <?php if ('' !== $wpo_browser_cache_output) { ?>
98 + <pre id="wpo_browser_cache_output"><?php echo esc_html($wpo_browser_cache_output); ?></pre>
99 + <?php } else { ?>
100 + <pre id="wpo_browser_cache_output" style="display: none;"></pre>
101 + <?php } ?>
37 102 <?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 - <label><?php _e('Expiration time:', 'wp-optimize'); ?></label>
43 - <input id="wpo_browser_cache_expire_days" type="number" min="0" step="1" name="browser_cache_expire_days" value="<?php echo esc_attr($wpo_browser_cache_expire_days); ?>">
44 - <label for="wpo_browser_cache_expire"><?php _e('day(s)', 'wp-optimize'); ?></label>
45 - <input id="wpo_browser_cache_expire_hours" type="number" min="0" step="1" name="browser_cache_expire_hours" value="<?php echo esc_attr($wpo_browser_cache_expire_hours); ?>">
46 - <label for="wpo_browser_cache_expire_hours"><?php _e('hour(s)', 'wp-optimize'); ?></label>
47 - <button class="button-primary" type="button" id="wp_optimize_browser_cache_enable"><?php echo $button_text; ?></button>
48 - <img class="wpo_spinner display-none" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>"
49 - width="20" height="20" alt="...">
50 - <p><?php _e('Empty or 0 values disable the headers.', 'wp-optimize'); ?></p>
51 - </form>
52 - <?php
53 - } else {
54 - 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'));
55 103 }
56 - ?>
57 -
58 - <div id="wpo_browser_cache_message"></div>
59 - <pre id="wpo_browser_cache_output" style="display: none;"></pre>
60 - <?php
61 104 }
62 105
63 106 endif;
64 107 ?>