| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; |
| 3 |
|
| 4 |
// Page exclusions |
| 5 |
$exclude_urls = get_option('berq_exclude_urls', []); |
| 6 |
$url_lines = implode("\n", $exclude_urls); |
| 7 |
|
| 8 |
// Ignore URL params |
| 9 |
$ignore_params = get_option('berq_ignore_urls_params', []); |
| 10 |
$param_lines = implode("\n", $ignore_params); |
| 11 |
|
| 12 |
$post_type_names = get_post_types(array( |
| 13 |
'public' => true, |
| 14 |
// 'exclude_from_search' => false, |
| 15 |
), 'names'); |
| 16 |
unset($post_type_names['attachment']); |
| 17 |
|
| 18 |
$taxonomy_names = get_taxonomies([ |
| 19 |
'public' => true, |
| 20 |
'publicly_queryable' => true, |
| 21 |
'rewrite' => true, |
| 22 |
'show_ui' => true, // optional but useful |
| 23 |
], 'names'); |
| 24 |
|
| 25 |
$excluded_cookies = implode("\n", $configs['exclude_cookies']); |
| 26 |
$cache_lifespan = $configs['cache_lifespan']; |
| 27 |
|
| 28 |
|
| 29 |
?> |
| 30 |
<div id="cache-management" <?php bwp_is_tab('cache-management'); ?>> |
| 31 |
<h2 class="berq-tab-title"><?php esc_html_e('Cache Management', 'searchpro'); ?></h2> |
| 32 |
<div class="berq-info-box"> |
| 33 |
<h3 class="berq-box-title"><?php esc_html_e('Max. Cache Lifespan', 'searchpro'); ?></h3> |
| 34 |
<div class="berq-box-content"> |
| 35 |
<p><?php esc_html_e("Set the maximum cache lifespan to control how long cached pages are stored before being refreshed. Note that {$plugin_name} automatically flushes the page cache when content is updated, so keeping the cache lifespan high is recommended.", 'searchpro'); ?></p> |
| 36 |
|
| 37 |
<div class="berqwp-lifespan-options"> |
| 38 |
<label> |
| 39 |
<input type="radio" name="berqwp_cache_lifespan" value="<?php echo MONTH_IN_SECONDS; ?>" <?php echo $cache_lifespan == MONTH_IN_SECONDS ? 'checked' : ''; ?>> |
| 40 |
<?php esc_html_e('30 Days (Default)', 'searchpro'); ?> |
| 41 |
</label> |
| 42 |
<label> |
| 43 |
<input type="radio" name="berqwp_cache_lifespan" value="<?php echo WEEK_IN_SECONDS; ?>" <?php echo $cache_lifespan == WEEK_IN_SECONDS ? 'checked' : ''; ?>> |
| 44 |
<?php esc_html_e('7 Days', 'searchpro'); ?> |
| 45 |
</label> |
| 46 |
<label> |
| 47 |
<input type="radio" name="berqwp_cache_lifespan" value="<?php echo DAY_IN_SECONDS; ?>" <?php echo $cache_lifespan == DAY_IN_SECONDS ? 'checked' : ''; ?>> |
| 48 |
<?php esc_html_e('24 Hours', 'searchpro'); ?> |
| 49 |
</label> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
</div> |
| 53 |
<!-- <div class="berq-info-box"> |
| 54 |
<h3 class="berq-box-title"><?php esc_html_e('Page Compression', 'searchpro'); ?></h3> |
| 55 |
<div class="berq-box-content"> |
| 56 |
<p><?php esc_html_e('Deliver GZIP-compressed page cache files, reducing page size by up to 70%.', 'searchpro'); ?></p> |
| 57 |
|
| 58 |
<div class="berqwp-pagecompress-options"> |
| 59 |
|
| 60 |
<?php if ($configs['page_compression'] === true) { ?> |
| 61 |
|
| 62 |
<label class="bwp-disable-pagecompression"> |
| 63 |
<input type="submit" name="bwp_disable_page_compression" value="Disable page compression" style="display:none"> |
| 64 |
<?php esc_html_e('Disable page compression', 'searchpro'); ?> |
| 65 |
</label> |
| 66 |
|
| 67 |
<?php } else { ?> |
| 68 |
|
| 69 |
<a href="#" class="berq-btn berqwp-enable-page-compression"> |
| 70 |
<div class="berqwp-loader"></div><?php esc_html_e('Enable page compression', 'searchpro'); ?> |
| 71 |
</a> |
| 72 |
|
| 73 |
<?php } ?> |
| 74 |
|
| 75 |
</div> |
| 76 |
</div> |
| 77 |
</div> --> |
| 78 |
<div class="berq-info-box"> |
| 79 |
<h3 class="berq-box-title"><?php esc_html_e('Page Exclusions', 'searchpro'); ?></h3> |
| 80 |
<div class="berq-box-content"> |
| 81 |
<p><?php esc_html_e('Exclude pages from caching. Enter one page URL per line. You can use a wildcard by adding *. For example: https://yoursite.com/campaign/*', 'searchpro'); ?> |
| 82 |
|
| 83 |
<?php if (bwp_show_docs()) { ?> |
| 84 |
<a href="https://berqwp.com/help-center/exclude-pages-from-being-cached/" target="_blank"><?php esc_html_e('Learn more', 'searchpro'); ?></a> |
| 85 |
<?php } ?> |
| 86 |
|
| 87 |
</p> |
| 88 |
<textarea name="berq_exclude_urls" cols="30" rows="10"><?php echo esc_textarea($url_lines); ?></textarea> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
<div class="berq-info-box"> |
| 92 |
<h3 class="berq-box-title"><?php esc_html_e('Content Types', 'searchpro'); ?></h3> |
| 93 |
<div class="berq-box-content"> |
| 94 |
<p><?php esc_html_e('Choose which post types and archive pages should be cached.', 'searchpro'); ?></p> |
| 95 |
<div class="optimize-post-types"> |
| 96 |
<?php |
| 97 |
foreach ($post_type_names as $key => $value) { |
| 98 |
?> |
| 99 |
<div> |
| 100 |
<input type="checkbox" name="berqwp_optimize_post_types[]" value="<?php echo esc_attr($key); ?>" <?php checked(1, in_array($value, get_option('berqwp_optimize_post_types')), true); ?>> |
| 101 |
|
| 102 |
<?php |
| 103 |
$post_counts = wp_count_posts($value); |
| 104 |
$published_count = isset($post_counts->publish) ? $post_counts->publish : 0; |
| 105 |
echo esc_html(ucfirst($key) . " ($published_count)"); |
| 106 |
|
| 107 |
?> |
| 108 |
</div> |
| 109 |
<?php |
| 110 |
} |
| 111 |
foreach ($taxonomy_names as $key => $value) { |
| 112 |
?> |
| 113 |
<div> |
| 114 |
<input type="checkbox" name="berqwp_optimize_taxonomies[]" value="<?php echo esc_attr($key); ?>" <?php checked(1, in_array($value, get_option('berqwp_optimize_taxonomies')), true); ?>> |
| 115 |
|
| 116 |
<?php |
| 117 |
echo esc_html(ucfirst($key)); |
| 118 |
?> |
| 119 |
</div> |
| 120 |
<?php |
| 121 |
} |
| 122 |
?> |
| 123 |
|
| 124 |
</div> |
| 125 |
</div> |
| 126 |
</div> |
| 127 |
<div class="berq-info-box"> |
| 128 |
<h3 class="berq-box-title"><?php esc_html_e('Exclude Cookies', 'searchpro'); ?></h3> |
| 129 |
<div class="berq-box-content"> |
| 130 |
<p><?php esc_html_e("Prevent cached pages from being served when the following cookies are present. Enter a partial match or keyword from the cookie name to exclude it. Add one cookie ID per line. Example: woocommerce_cart_hash"); ?> |
| 131 |
|
| 132 |
</p> |
| 133 |
<textarea name="berq_exclude_cookies" cols="30" rows="10"><?php echo esc_textarea($excluded_cookies); ?></textarea> |
| 134 |
</div> |
| 135 |
</div> |
| 136 |
<div class="berq-info-box"> |
| 137 |
<h3 class="berq-box-title"><?php esc_html_e('Ignore URL Parameters', 'searchpro'); ?></h3> |
| 138 |
<div class="berq-box-content"> |
| 139 |
<p><?php esc_html_e("Ignore page URL parameters, these parameters will be disregarded and won't be cached separately. Enter one parameter per line."); ?> |
| 140 |
|
| 141 |
<?php if (bwp_show_docs()) { ?> |
| 142 |
<a href="https://berqwp.com/help-center/ignore-url-parameters/" target="_blank"><?php esc_html_e('Learn more', 'searchpro'); ?></a> |
| 143 |
<?php } ?> |
| 144 |
|
| 145 |
</p> |
| 146 |
<textarea name="berq_ignore_urls_params" cols="30" rows="10"><?php echo esc_textarea($param_lines); ?></textarea> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
<button type="submit" class="berqwp-save"><svg width="20" height="20" viewBox="0 0 20 20" fill="none" |
| 150 |
xmlns="http://www.w3.org/2000/svg"> |
| 151 |
<path d="M4.16663 10.8333L7.49996 14.1667L15.8333 5.83334" stroke="white" stroke-width="2" |
| 152 |
stroke-linecap="round" stroke-linejoin="round" /> |
| 153 |
</svg> |
| 154 |
<?php esc_html_e("Save changes", "searchpro"); ?></button> |
| 155 |
</div> |
| 156 |
|