initial commit

This commit is contained in:
2024-04-29 13:12:44 +05:45
commit 34887303c5
19300 changed files with 5268802 additions and 0 deletions

View File

@ -0,0 +1,66 @@
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?>
<div class="wpo_section wpo_group">
<h3 class="wpo-first-child"><?php _e('Browser static file caching settings (via headers)', 'wp-optimize');?></h3>
<p>
<?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')); ?>
</p>
<div class="wpo-fieldgroup">
<?php if ($is_cloudflare_site) : ?>
<p class="wpo-enabled"><span class="dashicons dashicons-yes"></span>
<em><?php _e('Your website seems to use Cloudflare, which handles the browser caching rules.', 'wp-optimize'); ?></em>
</p>
<?php else : ?>
<div id="wpo_browser_cache_status" class="<?php echo $class_name; ?>">
<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>
<span class="wpo-disabled"><?php printf(__('Browser static file caching headers are currently %s.', 'wp-optimize'), '<strong>'.__('disabled', 'wp-optimize').'</strong>'); ?></span>
</div>
<br>
<?php
// add browser cache control section only if browser cache disabled or we added cache settings to .htaccess.
if (false == $wpo_browser_cache_enabled || $wpo_browser_cache_settings_added) {
?>
<div id="wpo_browser_cache_error_message" class="notice error below-h2"><?php
if (is_wp_error($wpo_browser_cache_enabled) && $wp_optimize->is_apache_server()) {
echo htmlspecialchars($wpo_browser_cache_enabled->get_error_message());
}
?></div>
<?php
if ($wp_optimize->is_apache_server()) {
$button_text = $wpo_browser_cache_enabled ? __('Update', 'wp-optimize') : __('Enable', 'wp-optimize');
?>
<form>
<label><?php _e('Expiration time:', 'wp-optimize'); ?></label>
<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); ?>">
<label for="wpo_browser_cache_expire"><?php _e('day(s)', 'wp-optimize'); ?></label>
<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); ?>">
<label for="wpo_browser_cache_expire_hours"><?php _e('hour(s)', 'wp-optimize'); ?></label>
<button class="button-primary" type="button" id="wp_optimize_browser_cache_enable"><?php echo $button_text; ?></button>
<img class="wpo_spinner display-none" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>"
width="20" height="20" alt="...">
<p><?php _e('Empty or 0 values disable the headers.', 'wp-optimize'); ?></p>
</form>
<?php
} else {
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'));
}
?>
<div id="wpo_browser_cache_message"></div>
<pre id="wpo_browser_cache_output" style="display: none;"></pre>
<?php
}
endif;
?>
</div><!-- END .wpo-fieldgroup -->
</div><!-- END .wpo_section -->

View File

@ -0,0 +1,75 @@
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?>
<div class="wpo_section wpo_group">
<h3 class="wpo-first-child"><?php _e('Gzip compression settings', 'wp-optimize');?></h3>
<p>
<span class="dashicons dashicons-info"></span> <span><?php _e("This option improves the performance of your website and decreases its loading time. When a visitor makes a request, the server compresses the requested resource before sending it leading to smaller file sizes and faster loading.", 'wp-optimize'); ?>
<?php printf('<a href="%s" target="_blank">%s</a>', $info_link, __('Follow this link to get more information about Gzip compression.', 'wp-optimize')); ?>
</span>
</p>
<?php if (is_wp_error($wpo_gzip_headers_information)) {
$class = 'notice notice-error';
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $wpo_gzip_headers_information->get_error_message()));
} else {
?>
<?php if ($wpo_gzip_compression_enabled && !is_wp_error($wpo_gzip_compression_enabled) && !$wpo_gzip_compression_enabled_by_wpo) : ?>
<div class="wpo-fieldgroup wpo-gzip-already-enabled">
<p><span class="dashicons dashicons-yes"></span>
<?php if (is_array($wpo_gzip_headers_information) && 'brotli' == $wpo_gzip_headers_information['compression']) { ?>
<?php _e('Your server uses Brotli compression instead of Gzip, which is good.', 'wp-optimize'); ?>
<?php } else { ?>
<?php _e('Gzip compression is already enabled.', 'wp-optimize'); ?>
<?php } ?>
<?php if ($is_cloudflare_site) { ?>
<em><?php _e('It seems to be handled by Cloudflare.', 'wp-optimize'); ?></em>
<?php } ?>
</p>
</div>
<?php else : ?>
<div class="wpo-fieldgroup">
<p id="wpo_gzip_compression_status" class="<?php echo $class_name; ?>">
<strong class="wpo-enabled"><?php _e('Gzip compression is currently ENABLED.', 'wp-optimize'); ?></strong>
<strong class="wpo-disabled"><?php _e('Gzip compression is currently DISABLED.', 'wp-optimize'); ?></strong>
<?php if (!$wp_optimize->is_apache_server() || ($wpo_gzip_compression_enabled && false == $wpo_gzip_compression_settings_added)) : ?>
<a href="#" class="wpo-refresh-gzip-status" title="<?php esc_attr_e('Press this to see if any changes were made to your Gzip configuration', 'wp-optimize'); ?>"><?php _e('Check status again', 'wp-optimize'); ?> <img class="wpo_spinner display-none" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>"></a>
<?php endif; ?>
</p>
<br>
<?php
// add gzip compression section only if gzip compression disabled or we added cache settings to .htaccess.
if (is_wp_error($wpo_gzip_compression_enabled) || false == $wpo_gzip_compression_enabled || $wpo_gzip_compression_settings_added) {
if ($wp_optimize->is_apache_server()) {
$button_text = (!is_wp_error($wpo_gzip_compression_enabled) && $wpo_gzip_compression_enabled) ? __('Disable', 'wp-optimize') : __('Enable', 'wp-optimize');
?>
<form>
<button class="button-primary" type="button"
id="wp_optimize_gzip_compression_enable" data-enable="<?php echo $wpo_gzip_compression_enabled ? '0' : '1'; ?>"><?php echo $button_text; ?></button>
<img class="wpo_spinner display-none" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>"
width="20" height="20" alt="...">
<br>
</form>
<?php
} else {
printf('<a href="%s" target="_blank">%s</a>', $faq_link, __('Follow this link to read the article about how to enable Gzip compression with your server software.', 'wp-optimize'));
}
}
?>
</div>
<div id="wpo_gzip_compression_error_message">
<?php
if (is_wp_error($wpo_gzip_compression_enabled)) {
echo htmlspecialchars($wpo_gzip_compression_enabled->get_error_message());
}
?>
</div>
<pre id="wpo_gzip_compression_output" style="display: none;"></pre>
<?php endif; ?>
<?php } ?>
</div>

View File

@ -0,0 +1,50 @@
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?>
<h3 class="wpo-first-child"><?php _e('URLs to exclude from caching', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup">
<p>
<label for="cache_exception_urls"><?php printf(__('List paths (e.g. %s) that should not be cached (one per line)', 'wp-optimize'), '<code>'._x('/product/green-beans', 'an example path', 'wp-optimize').'</code>'); ?> </label>
<textarea name="cache_exception_urls" id="cache_exception_urls" class="cache-settings" placeholder="/members/*"><?php echo htmlspecialchars($cache_exception_urls); ?></textarea>
</p>
<span>
<?php _e('Use the wildcard * to exclude child URLs.', 'wp-optimize'); ?> <?php printf(_x('e.g. %s or %s', '%s are examples of path using the wildcard *', 'wp-optimize'), '<code>'._x('/shop/*', 'an example path with the wildcard (*)', 'wp-optimize').'</code>', '<code>'._x('*sample-path*', 'a second example path using the wildcard (*) twice', 'wp-optimize').'</code>'); ?>
</span>
<?php do_action('wpo_after_cache_exception_urls'); ?>
</div>
<?php do_action('wpo_after_cache_exception_urls_fieldgroup'); ?>
<h3 class="wpo-first-child"><?php _e('Cookies which, if present, will prevent caching (one per line)', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup">
<p>
<label for="cache_exception_cookies"><?php _e('List of cookies that will prevent caching when set.', 'wp-optimize'); ?></label>
<textarea name="cache_exception_cookies" id="cache_exception_cookies" class="cache-settings" placeholder="wordpress_*"><?php echo htmlspecialchars($cache_exception_cookies); ?></textarea>
</p>
</div>
<h3 class="wpo-first-child"><?php _e('List of browser agent strings which, if detected, will prevent caching', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup">
<p>
<label for="cache_exception_browser_agents"><?php _e('List of browser agents strings or substrings that should not be served cached files (one per line)', 'wp-optimize'); ?></label>
<textarea name="cache_exception_browser_agents" id="cache_exception_browser_agents" class="cache-settings" placeholder="AppleWebKit/*"><?php echo htmlspecialchars($cache_exception_browser_agents); ?></textarea>
</p>
<span><?php _e('If any of the above strings is found in the User-Agent HTTP header, then the requested page will not be cached.', 'wp-optimize'); ?> </span>
</div>
<?php do_action('wpo_page_cache_advanced_settings', $wpo_cache_options); ?>
<input id="wp-optimize-save-cache-advanced-rules" class="button button-primary" type="submit" name="wp-optimize-save-cache-advanced-rules" value="Save changes">
<img class="wpo_spinner" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>" alt="...">
<span class="save-done dashicons dashicons-yes display-none"></span>

View File

@ -0,0 +1,9 @@
<?php if (!defined('ABSPATH')) die('No direct access.'); ?>
<h3 class="wpo-cloudflare-cache-options purge-cache"> <?php _e('Cloudflare settings', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup cache-options wpo-cloudflare-cache-options purge-cache">
<p>
<input id="purge_cloudflare_cache" disabled type="checkbox" name="purge_cloudflare_cache" class="cache-settings">
<label for="purge_cloudflare_cache"><?php _e('Purge Cloudflare cached pages when the WP-Optimize cache is purged', 'wp-optimize'); ?> <em><?php printf(__('(This feature requires %s)', 'wp-optimize'), '<a target="_blank" href="'.WP_Optimize()->maybe_add_affiliate_params('https://getwpo.com/buy/').'">WP Optimize Premium</a>'); ?></em></label>
</p>
</div>

View File

@ -0,0 +1,53 @@
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?>
<h3 class="wpo-first-child"><?php _e('Preload now', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup">
<p>
<input id="wp_optimize_run_cache_preload" class="button button-primary" type="submit" name="wp_optimize_run_cache_preload" value="<?php echo $is_running ? esc_attr__('Cancel', 'wp-optimize') : esc_attr__('Run now', 'wp-optimize'); ?>" <?php echo $is_running ? 'data-running="1"' : ''; ?>>
<span id="wp_optimize_preload_cache_status"><?php
echo htmlspecialchars($status_message);
?></span>
</p>
<span>
<?php _e('This action will trigger WP-Optimize to cache the site by visiting pages to preload them (so that they are ready the first time a human visitor wants them).', 'wp-optimize'); ?>
<?php _e('If a sitemap is available, then it will be used to determine which content gets cached.', 'wp-optimize'); ?>
</span>
</div>
<h3 class="wpo-first-child"><?php _e('Schedule preloader', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup">
<p>
<label>
<input name="enable_schedule_preload" id="enable_schedule_preload" class="cache-settings" type="checkbox" value="true" <?php checked($wpo_cache_options['enable_schedule_preload']); ?>>
<?php _e('Activate scheduled cache preloading', 'wp-optimize'); ?>
</label>
<p>
<?php _e('The scheduled preloading will run automatically in your chosen time period.', 'wp-optimize'); ?>
</p>
</p>
<label for="preload_schedule_type"><?php _e('Select schedule type', 'wp-optimize'); ?></label><br>
<select id="preload_schedule_type" class="cache-settings" name="preload_schedule_type" disabled>
<?php
foreach ($schedule_options as $opt_id => $opt_description) {
?>
<option value="<?php echo esc_attr($opt_id); ?>" <?php selected($wpo_cache_options['preload_schedule_type'], $opt_id); ?> <?php if ('wpo_use_cache_lifespan' == $opt_id && $wpo_cache_options['page_cache_length_value'] <= 0) disabled(true); ?>><?php echo htmlspecialchars($opt_description); ?></option>
<?php
}
?>
</select>
</div>
<input id="wp-optimize-save-cache-preload-settings" class="button button-primary" type="submit" name="wp-optimize-save-cache-preload-settings" value="<?php esc_attr_e('Save changes', 'wp-optimize');?>">
<img class="wpo_spinner" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>" alt="...">
<span class="save-done dashicons dashicons-yes display-none"></span>

View File

@ -0,0 +1,111 @@
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?>
<?php if ($does_server_handles_cache) : ?>
<div class="wpo-info highlight-dashicons">
<h3><?php _e('Your web hosting company/server handles: ', 'wp-optimize'); ?></h3>
<p><?php _e('Page caching', 'wp-optimize'); ?><span class="dashicons dashicons-saved"></span></p>
<p><?php _e('Gzip compression', 'wp-optimize'); ?><span class="dashicons dashicons-saved"></span></p>
<p><?php _e('Browser static file caching (via headers)', 'wp-optimize'); ?><span class="dashicons dashicons-saved"></span></p>
</div>
<?php else : ?>
<div class="wpo-info">
<a class="wpo-info__trigger" href="#"><span class="dashicons dashicons-sos"></span> <?php _e('How to use the cache feature', 'wp-optimize'); ?> <span class="wpo-info__close"><?php _e('Close', 'wp-optimize'); ?></span></a>
<div class="wpo-info__content">
<p><strong><?php _e('Not sure how to use the cache feature?', 'wp-optimize'); ?></strong> <br><?php _e('Watch our how-to video below.', 'wp-optimize'); ?></p>
<div class="wpo-video-preview">
<a href="https://vimeo.com/337247770" data-embed="https://player.vimeo.com/video/337247770?color=df6926&title=0&byline=0&portrait=0" target="_blank"><img src="<?php echo trailingslashit(WPO_PLUGIN_URL); ?>images/notices/cache-video-preview.png" alt="<?php _e('Cache video preview', 'wp-optimize');?>" /></a>
</div>
<small>(<?php _e('Loads a video hosted on vimeo.com', 'wp-optimize'); ?>) - <a href="https://vimeo.com/337247770" target="_blank"><?php _e('Open the video in a new window', 'wp-optimize'); ?></a></small>
</div>
</div>
<div class="wpo-fieldgroup wpo-first-child cache-options">
<div class="notice notice-warning below-h2 wpo-warnings__enabling-cache wpo_hidden"><p></p><ul></ul></div>
<div class="notice error below-h2 wpo-error wpo-error__enabling-cache wpo_hidden"><p></p></div>
<pre id="wpo_advanced_cache_output" style="display: none;"></pre>
<div class="switch-container">
<label class="switch">
<input name="enable_page_caching" id="enable_page_caching" class="cache-settings" type="checkbox" value="true" <?php checked($wpo_cache_options['enable_page_caching'] || $wpo_cache->is_enabled()); ?>>
<span class="slider round"></span>
</label>
<label for="enable_page_caching">
<?php _e('Enable page caching', 'wp-optimize'); ?>
</label>
</div>
<p>
<?php echo __("This is all that's needed for caching to work.", 'wp-optimize').' '.__('WP-Optimize will automatically detect and configure itself optimally for your site.', 'wp-optimize').' '.__('You can tweak the the settings below and in the advanced settings tab, if needed.', 'wp-optimize'); ?>
</p>
<?php if (!empty($active_cache_plugins)) { ?>
<p class="wpo-error">
<?php
printf(__('It looks like you already have an active caching plugin (%s) installed. Having more than one active page cache might cause unexpected results.', 'wp-optimize'), implode(', ', $active_cache_plugins));
?>
</p>
<?php } ?>
</div>
<h3 class="purge-cache" <?php echo $display; ?>> <?php _e('Purge the cache', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup cache-options purge-cache" <?php echo $display; ?> >
<p class="wpo-button-wrap">
<input id="wp-optimize-purge-cache" class="button button-primary <?php echo $can_purge_the_cache ? '' : 'disabled'; ?>" type="submit" value="<?php esc_attr_e('Purge cache', 'wp-optimize'); ?>" <?php echo $can_purge_the_cache ? '' : 'disabled'; ?>>
<img class="wpo_spinner" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>" alt="...">
<span class="save-done dashicons dashicons-yes display-none"></span>
</p>
<p>
<?php _e('Deletes the entire cache contents but keeps the page cache enabled.', 'wp-optimize'); ?>
</p>
<p>
<span id="wpo_current_cache_size_information"><?php _e('Current cache size:', 'wp-optimize'); ?> <?php echo WP_Optimize()->format_size($cache_size['size']); ?></span>
<br><span id="wpo_current_cache_file_count"><?php _e('Number of files:', 'wp-optimize'); ?> <?php echo $cache_size['file_count']; ?></span>
</p>
</div>
<h3><?php _e('Cache settings', 'wp-optimize'); ?></h3>
<div class="wpo-fieldgroup cache-options">
<div class="wpo-fieldgroup__subgroup">
<label for="enable_mobile_caching">
<input name="enable_mobile_caching" id="enable_mobile_caching" class="cache-settings" type="checkbox" value="true" <?php checked($wpo_cache_options['enable_mobile_caching'], 1); ?>>
<?php _e('Generate separate files for mobile devices', 'wp-optimize'); ?>
</label>
<span tabindex="0" data-tooltip="<?php _e('Useful if your website has mobile-specific content.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span> </span>
</div>
<div class="wpo-fieldgroup__subgroup">
<label for="enable_user_caching">
<input name="enable_user_caching" id="enable_user_caching" class="cache-settings wpo-select-group" type="checkbox" value="true" <?php checked($wpo_cache_options['enable_user_caching']); ?>>
<?php _e('Serve cached pages to logged in users', 'wp-optimize'); ?>
</label>
<span tabindex="0" data-tooltip="<?php _e('Enable this option if you do not have user-specific or restricted content on your website.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span> </span>
</div>
<?php do_action('wpo_after_cache_settings'); ?>
<div class="wpo-fieldgroup__subgroup">
<label for="page_cache_length_value"><?php _e('Cache lifespan', 'wp-optimize'); ?></label>
<p>
<input name="page_cache_length_value" id="page_cache_length_value" class="cache-settings" type="number" value="<?php echo esc_attr($wpo_cache_options['page_cache_length_value']); ?>">
<select name="page_cache_length_unit" id="page_cache_length_unit" class="cache-settings">
<option value="hours" <?php selected('hours', $wpo_cache_options['page_cache_length_unit']); ?>><?php _e('Hours', 'wp-optimize'); ?></option>
<option value="days" <?php selected('days', $wpo_cache_options['page_cache_length_unit']); ?>><?php _e('Days', 'wp-optimize'); ?></option>
<option value="months" <?php selected('months', $wpo_cache_options['page_cache_length_unit']); ?>><?php _e('Months', 'wp-optimize'); ?></option>
</select>
</p>
<span>
<?php _e('Time after which a new cached version will be generated (0 = only when the cache is emptied)', 'wp-optimize'); ?>
</span>
</div>
<?php do_action('wpo_page_cache_settings_after', $wpo_cache_options); ?>
</div>
<input id="wp-optimize-save-cache-settings" class="button button-primary" type="submit" name="wp-optimize-save-cache-settings" value="<?php esc_attr_e('Save changes', 'wp-optimize'); ?>">
<img class="wpo_spinner" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>" alt="....">
<span class="save-done dashicons dashicons-yes display-none"></span>
<?php endif;