PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.5.3
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.5.3
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 4.5.3, at templates/cache/browser-cache.php

100 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (!defined('ABSPATH')) 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_handling_browser_cache) : ?>
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>
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>
31 </div>
32
33 <br>
34
35 <?php
36
37 // add browser cache control section only if browser cache disabled or we added cache settings to .htaccess.
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" 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" 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 ?>
71
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
88 }
89 ?></div>
90 <div id="wpo_browser_cache_error_message" class="notice notice-error" style="display: none;"></div>
91 <pre id="wpo_browser_cache_output" style="display: none;"></pre>
92 <?php
93 }
94 }
95
96 endif;
97 ?>
98 </div><!-- END .wpo-fieldgroup -->
99 </div><!-- END .wpo_section -->
100