| 1 |
<?php |
| 2 |
|
| 3 |
namespace Upress\EzCache; |
| 4 |
|
| 5 |
use WP_Admin_Bar; |
| 6 |
use wpdb; |
| 7 |
|
| 8 |
class Admin { |
| 9 |
/** @var Plugin */ |
| 10 |
private $plugin; |
| 11 |
protected static $svg = '<svg viewBox="0 0 480 480" version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" xmlns:serif="http://www.serif.com/" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"> |
| 12 |
<g id="Camada-1" serif:id="Camada 1" fill-rule="nonzero"> |
| 13 |
<path d="M206.088 138.266l-90.584 127.353h115.3l-67.078 160.647 201.096-213.077H254.006l53.292-74.923h-101.21z" fill="#fc0"/> |
| 14 |
<path d="M205.088 138.266l-90.585 127.352h115.3l-67.078 160.647L285.68 239.266H180.327l75.364-101h-50.603z" fill="url(#_Linear1)"/> |
| 15 |
</g> |
| 16 |
<defs> |
| 17 |
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(171.176 0 0 -171.176 114.504 282.266)"> |
| 18 |
<stop offset="0" stop-color="#deb203" stop-opacity="1"/> |
| 19 |
<stop offset="1" stop-color="#fc0" stop-opacity="1"/> |
| 20 |
</linearGradient> |
| 21 |
</defs> |
| 22 |
</svg> '; |
| 23 |
|
| 24 |
function __construct( $plugin ) { |
| 25 |
$this->plugin = $plugin; |
| 26 |
|
| 27 |
add_filter( 'show_admin_bar', [ $this, 'maybe_show_admin_bar' ], 100 ); |
| 28 |
add_action( 'admin_init', [ $this, 'register_settings' ] ); |
| 29 |
add_action( 'admin_menu', [ $this, 'register_menu' ] ); |
| 30 |
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); |
| 31 |
// Premium UI gates removed — Pro is unlocked for everyone. |
| 32 |
// inject_branding_css removed — branding is now built into Vue 2.0 |
| 33 |
add_action( 'plugin_action_links_' . plugin_basename( $this->plugin->plugin_file ), [ |
| 34 |
$this, |
| 35 |
'plugin_action_links', |
| 36 |
] ); |
| 37 |
add_action( 'admin_notices', [ $this, 'maybe_show_advanced_cache_notice' ] ); |
| 38 |
// Trial banner removed — licensing system disabled. |
| 39 |
|
| 40 |
add_action( 'admin_bar_menu', [ $this, 'add_admin_bar_button' ], 999 ); |
| 41 |
add_action( 'admin_post_wpb_clear_cache', [ $this, 'admin_clear_cache' ] ); |
| 42 |
add_action( 'delete_attachment', [ $this, 'delete_webp_image' ] ); |
| 43 |
|
| 44 |
add_action( 'init', [ $this, 'register_post_meta' ] ); |
| 45 |
add_action( 'add_meta_boxes', [ $this, 'post_cache_metabox' ] ); |
| 46 |
add_action( 'save_post', [ $this, 'save_post_cache_metabox' ] ); |
| 47 |
add_action( 'pre_post_update', [ $this, 'maybe_clear_cache_on_post_update' ], 10, 2 ); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Delete the webp versions when the image is deleted |
| 52 |
* |
| 53 |
* @param int $attachment_id |
| 54 |
*/ |
| 55 |
function delete_webp_image( $attachment_id ) { |
| 56 |
global $wpdb; |
| 57 |
|
| 58 |
$upload_dir = wp_upload_dir()['basedir']; |
| 59 |
|
| 60 |
$meta = wp_get_attachment_metadata( $attachment_id ); |
| 61 |
if ( ! $meta || ! isset( $meta['file'] ) ) { |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
if ( ! isset( $meta['sizes'] ) ) { |
| 66 |
$meta['sizes'] = []; |
| 67 |
} |
| 68 |
|
| 69 |
$meta['sizes'][] = [ 'file' => $meta['file'] ]; |
| 70 |
|
| 71 |
$hashes = []; |
| 72 |
foreach ( $meta['sizes'] as $size ) { |
| 73 |
$image_path = trailingslashit( $upload_dir ) . $meta['file']; |
| 74 |
$ext = pathinfo( $image_path, PATHINFO_EXTENSION ); |
| 75 |
$image_webp_path = preg_replace( '/^(.+)\.' . preg_quote( $ext, '/' ) . '$/u', '$1.webp', $image_path ); |
| 76 |
|
| 77 |
$hashes[] = sha1( $image_path ); |
| 78 |
|
| 79 |
if ( file_exists( $image_webp_path ) ) { |
| 80 |
unlink( $image_webp_path ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
$wpdb->query( |
| 85 |
$wpdb->prepare( |
| 86 |
"DELETE FROM `{$wpdb->prefix}ezcache_webp_images` WHERE `uid` IN (" . substr( str_repeat( "%d, ", count( $hashes ) ), 0, - 2 ) . ")", |
| 87 |
$hashes |
| 88 |
) |
| 89 |
); |
| 90 |
|
| 91 |
$wpdb->query( "OPTIMIZE TABLE `{$wpdb->prefix}ezcache_webp_images`" ); |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Register the post meta fields |
| 96 |
*/ |
| 97 |
function register_post_meta() { |
| 98 |
if ( function_exists( 'register_post_meta' ) ) { |
| 99 |
register_post_meta( 'post', '_ezcache_do_not_cache_post', [ |
| 100 |
'show_in_rest' => true, |
| 101 |
'single' => true, |
| 102 |
'type' => 'bool', |
| 103 |
'auth_callback' => function () { |
| 104 |
return current_user_can( 'edit_posts' ); |
| 105 |
}, |
| 106 |
] ); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Register the meta box |
| 112 |
*/ |
| 113 |
function post_cache_metabox() { |
| 114 |
global $post_type; |
| 115 |
|
| 116 |
if ( 'attachement' == $post_type ) { |
| 117 |
return; |
| 118 |
} |
| 119 |
|
| 120 |
add_meta_box( |
| 121 |
'ezcache_metabox', |
| 122 |
__( 'Caching', 'ezcache' ), |
| 123 |
[ $this, 'post_cache_metabox_output' ], |
| 124 |
null, |
| 125 |
'side' |
| 126 |
); |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* Render the post meta box |
| 131 |
* |
| 132 |
* @param $post |
| 133 |
*/ |
| 134 |
function post_cache_metabox_output( $post ) { |
| 135 |
global $post_type_object; |
| 136 |
|
| 137 |
$value = get_post_meta( $post->ID, '_ezcache_do_not_cache_post', true ); |
| 138 |
wp_nonce_field( 'ezcache_metabox', '_eznonce' ); |
| 139 |
?> |
| 140 |
<div style="padding:8px 0"> |
| 141 |
<div style="display:flex;align-items:center"> |
| 142 |
<input type="checkbox" |
| 143 |
id="ezcache_no_cache" |
| 144 |
name="ezcache_no_cache" |
| 145 |
class="checkbox" style="width:16px;height:16px;margin-right:8px;vertical-align:middle" |
| 146 |
<?php checked( $value ); ?> |
| 147 |
> |
| 148 |
<label style="vertical-align:middle;cursor:pointer" for="ezcache_no_cache"> |
| 149 |
<?php echo 'page' == $post_type_object->capability_type ? esc_html__( 'Do not cache this page', 'ezcache' ) : esc_html__( 'Do not cache this post', 'ezcache' ); ?> |
| 150 |
</label> |
| 151 |
</div> |
| 152 |
</div> |
| 153 |
<?php |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* Save the meta box settings |
| 158 |
* |
| 159 |
* @param $post_id |
| 160 |
*/ |
| 161 |
function save_post_cache_metabox( $post_id ) { |
| 162 |
if ( ! isset( $_POST['_eznonce'] ) || ! wp_verify_nonce( $_POST['_eznonce'], 'ezcache_metabox' ) ) { |
| 163 |
return; |
| 164 |
} |
| 165 |
|
| 166 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
| 167 |
return; |
| 168 |
} |
| 169 |
|
| 170 |
if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 171 |
return; |
| 172 |
} |
| 173 |
|
| 174 |
if ( isset( $_POST['ezcache_no_cache'] ) ) { |
| 175 |
update_post_meta( $post_id, '_ezcache_do_not_cache_post', true ); |
| 176 |
Cache::instance()->clear_cache_single( $post_id ); |
| 177 |
} else { |
| 178 |
delete_post_meta( $post_id, '_ezcache_do_not_cache_post' ); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
/** |
| 183 |
* Runs when a post is created, updated, or a comment is left on it |
| 184 |
* |
| 185 |
* @param int $post_id Post ID |
| 186 |
* @param array $data Array of unslashed post data |
| 187 |
*/ |
| 188 |
function maybe_clear_cache_on_post_update( $post_id, $data ) { |
| 189 |
$settings = Settings::get_settings(); |
| 190 |
|
| 191 |
if ( $settings->cache_clear_on_post_edit ) { |
| 192 |
$this->plugin->ezcache->clear_cache_single( $post_id ); |
| 193 |
|
| 194 |
return; |
| 195 |
} |
| 196 |
|
| 197 |
if ( $settings->cache_clear_home_on_post_edit ) { |
| 198 |
$this->plugin->ezcache->clear_cache_url( '/' ); |
| 199 |
|
| 200 |
$blog_page_url = $this->plugin->ezcache->get_relative_url( get_post_type_archive_link( 'post' ) ); |
| 201 |
$this->plugin->ezcache->clear_cache_url( $blog_page_url ); |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* Add settings link to the plugin action links |
| 207 |
* |
| 208 |
* @param array $links |
| 209 |
* |
| 210 |
* @return array |
| 211 |
*/ |
| 212 |
function plugin_action_links( $links ) { |
| 213 |
$links[] = sprintf( |
| 214 |
'<a href="%s">%s</a>', |
| 215 |
admin_url( 'admin.php?page=ezcache' ), |
| 216 |
__( 'Settings' ) |
| 217 |
); |
| 218 |
|
| 219 |
return $links; |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* Add the menu to the admin bar |
| 224 |
* |
| 225 |
* @param WP_Admin_Bar $wp_admin_bar |
| 226 |
*/ |
| 227 |
function add_admin_bar_button( $wp_admin_bar ) { |
| 228 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 229 |
return; |
| 230 |
} |
| 231 |
|
| 232 |
$referer = rawurlencode( wp_unslash( remove_query_arg( 'fl_builder', $_SERVER['REQUEST_URI'] ) ) ); |
| 233 |
$svg = preg_replace( '/<svg(\s+?)(?:(?:style=[\'"]([\s\S]+?);?[\'"]([\s\S]*?))|([\s\S]*?))>/i', '<svg class="ab-icon" style="height:1em;width:auto;color:#a0a5aa;color:rgba(240,245,250,.6);$2" $3$4>', self::$svg ); |
| 234 |
|
| 235 |
$wp_admin_bar->add_menu( [ |
| 236 |
'id' => 'ezcache', |
| 237 |
'title' => $svg . __( 'ezCache', 'ezcache' ), |
| 238 |
'href' => admin_url( 'admin.php?page=ezcache' ), |
| 239 |
] ); |
| 240 |
|
| 241 |
$wp_admin_bar->add_menu( [ |
| 242 |
'id' => 'ezcache-settings', |
| 243 |
'parent' => 'ezcache', |
| 244 |
'title' => __( 'Settings', 'ezcache' ), |
| 245 |
'href' => admin_url( 'admin.php?page=ezcache' ), |
| 246 |
] ); |
| 247 |
|
| 248 |
$wp_admin_bar->add_menu( [ |
| 249 |
'id' => 'ezcache-clear-cache', |
| 250 |
'parent' => 'ezcache', |
| 251 |
'title' => __( 'Clear Cache', 'ezcache' ), |
| 252 |
'href' => wp_nonce_url( admin_url( 'admin-post.php?action=wpb_clear_cache&_wp_http_referer=' . $referer ), 'wpb-clear-cache' ), |
| 253 |
] ); |
| 254 |
} |
| 255 |
|
| 256 |
function register_settings() { |
| 257 |
register_setting( $this->plugin->plugin_settings_key . '_group', $this->plugin->plugin_settings_key ); |
| 258 |
} |
| 259 |
|
| 260 |
/** |
| 261 |
* Add the menu under the 'Settings' sidebar item |
| 262 |
*/ |
| 263 |
function register_menu() { |
| 264 |
global $submenu; |
| 265 |
|
| 266 |
add_menu_page( |
| 267 |
__( 'ezCache' ), |
| 268 |
__( 'ezCache' ), |
| 269 |
'manage_options', |
| 270 |
'ezcache', |
| 271 |
[ $this, 'settings_page' ], |
| 272 |
'data:image/svg+xml;base64,' . base64_encode( self::$svg ) |
| 273 |
); |
| 274 |
|
| 275 |
$urls = [ |
| 276 |
__( 'Statistics', 'ezcache' ) => '/', |
| 277 |
__( 'Settings', 'ezcache' ) => '/settings', |
| 278 |
__( 'Advanced Settings', 'ezcache' ) => '/advanced', |
| 279 |
__( 'License', 'ezcache' ) => '/license', |
| 280 |
]; |
| 281 |
|
| 282 |
if ( ! isset( $submenu['ezcache'] ) ) { |
| 283 |
$submenu['ezcache'] = []; |
| 284 |
} |
| 285 |
|
| 286 |
foreach ( $urls as $title => $url ) { |
| 287 |
$submenu['ezcache'][] = [ $title, 'manage_options', admin_url( 'admin.php?page=ezcache' ) . '#' . $url ]; |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
/** |
| 292 |
* Render the settings page |
| 293 |
*/ |
| 294 |
function settings_page() { |
| 295 |
$trans = $this->getJsTraslations(); |
| 296 |
?> |
| 297 |
<div class="wrap"><h1 aria-hidden="true"><!-- WordPress notices trap --></h1></div> |
| 298 |
<div id="ezcache-options" class="wrap ezcache-options"> |
| 299 |
<!--suppress HtmlUnknownTag --> |
| 300 |
<ezc-options> |
| 301 |
<div class="ezcache-options--preload" aria-hidden="true" style="display:none"> |
| 302 |
<header class="ezcache-header"> |
| 303 |
<h1> |
| 304 |
<svg viewBox="0 0 360 68" version="1.1" xmlns="http://www.w3.org/2000/svg" |
| 305 |
xml:space="preserve" fill-rule="evenodd" |
| 306 |
clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" class="logo"> |
| 307 |
<g id="Camada-1" fill-rule="nonzero"> |
| 308 |
<path d="M51.154 53.752H13.691V37.239h22.056l9.144-12.855h-31.2V13.378H52.72L62.235 0H0v67.338h45.91l5.244-13.586z" |
| 309 |
fill="#1e1e1e"></path> |
| 310 |
<path d="M72.596 24.521h21.219L53.38 67.338h58.228V54.797H80.976l39.09-41.42H80.389l-7.794 11.144z" |
| 311 |
fill="#1e1e1e"></path> |
| 312 |
<path d="M57.073 13.378L40.101 37.239h21.603l-12.568 30.1 37.678-39.923H66.051l9.985-14.038H57.073z" |
| 313 |
fill="#fc0"></path> |
| 314 |
<path d="M57.074 13.378L40.102 37.239h21.602L49.136 67.338l23.038-35.036H52.435l14.12-18.924h-9.481z" |
| 315 |
fill="url(#_Linear1)"></path> |
| 316 |
<path d="M200.202 47.707h-19.221l9.611-22.993 9.61 22.993zm8.279 19.631h10.645l-23.212-53.965h-10.645l-23.213 53.965h10.572l4.435-10.163h27.056l4.362 10.163z" |
| 317 |
fill="gray"></path> |
| 318 |
<path d="M313.541 67.338V13.373h-9.684V36.29h-25.43V13.373h-9.758v53.965h9.758v-22.03h25.43v22.03h9.684z" |
| 319 |
fill="gray"></path> |
| 320 |
<path d="M360 57.728h-29.053V44.865h16.255l3.911-9.092h-20.166V22.835h24.983l4.07-9.461h-38.736v53.964H360v-9.61z" |
| 321 |
fill="gray"></path> |
| 322 |
<path d="M143.812 13.373h15.746v9.314h-15.746c-12.493 0-17.89 9.315-17.815 17.964.073 8.575 5.026 17.52 17.815 17.52h15.659l-3.943 9.167H143.812c-19.22 0-27.352-13.233-27.426-26.687-.073-13.528 8.723-27.278 27.426-27.278z" |
| 323 |
fill="gray"></path> |
| 324 |
<path d="M245.201 13.373h15.746v9.314H245.201c-12.493 0-17.89 9.315-17.816 17.964.074 8.575 5.027 17.52 17.816 17.52h15.746v9.167H245.201c-19.221 0-27.352-13.233-27.426-26.687-.074-13.528 8.723-27.278 27.426-27.278" |
| 325 |
fill="gray"></path> |
| 326 |
</g> |
| 327 |
<defs> |
| 328 |
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" |
| 329 |
gradientUnits="userSpaceOnUse" |
| 330 |
gradientTransform="matrix(32.072 0 0 -32.072 40.101 40.358)"> |
| 331 |
<stop offset="0" stop-color="#deb203" stop-opacity="1"></stop> |
| 332 |
<stop offset="1" stop-color="#fc0" stop-opacity="1"></stop> |
| 333 |
</linearGradient> |
| 334 |
</defs> |
| 335 |
</svg> |
| 336 |
</h1> |
| 337 |
</header> |
| 338 |
<div class="row"> |
| 339 |
<div class="col-12 order-first col-sm-4 col-md-3 col-xl-2"> |
| 340 |
<nav class="ezcache-nav"> |
| 341 |
<a href="#" class="nav-item"> |
| 342 |
<?php echo str_repeat( '■', mb_strlen( $trans['stats'] ) ); ?> |
| 343 |
</a> |
| 344 |
<a href="#" class="nav-item"> |
| 345 |
<?php echo str_repeat( '■', mb_strlen( $trans['settings'] ) ); ?> |
| 346 |
</a> |
| 347 |
<a href="#" class="nav-item"> |
| 348 |
<?php echo str_repeat( '■', mb_strlen( $trans['advanced_settings'] ) ); ?> |
| 349 |
</a> |
| 350 |
<a href="#" class="nav-item"> |
| 351 |
<?php echo str_repeat( '■', mb_strlen( $trans['license'] ) ); ?> |
| 352 |
</a> |
| 353 |
</nav> |
| 354 |
</div> |
| 355 |
<div class="col-12 col-sm-4 order-sm-last col-md-3 col-xl-2 mb-4"> |
| 356 |
<div class="ezcache-nav mt-1"> |
| 357 |
<button type="button" class="wpb-button" disabled> |
| 358 |
<svg viewBox="0 0 24 24"> |
| 359 |
<path d="M19,8L15,12H18A6,6 0 0,1 12,18C11,18 10.03,17.75 9.2,17.3L7.74,18.76C8.97,19.54 10.43,20 12,20A8,8 0 0,0 20,12H23M6,12A6,6 0 0,1 12,6C13,6 13.97,6.25 14.8,6.7L16.26,5.24C15.03,4.46 13.57,4 12,4A8,8 0 0,0 4,12H1L5,16L9,12"></path> |
| 360 |
</svg> |
| 361 |
<?php echo str_repeat( '■', mb_strlen( $trans['clear_cache'] ) ); ?> |
| 362 |
</button> |
| 363 |
<a href="#" target="_blank" class="mt-2 wpb-button wpb-button-outlined disabled"> |
| 364 |
<svg viewBox="0 0 24 24"> |
| 365 |
<path d="M12,16A3,3 0 0,1 9,13C9,11.88 9.61,10.9 10.5,10.39L20.21,4.77L14.68,14.35C14.18,15.33 13.17,16 12,16M12,3C13.81,3 15.5,3.5 16.97,4.32L14.87,5.53C14,5.19 13,5 12,5A8,8 0 0,0 4,13C4,15.21 4.89,17.21 6.34,18.65H6.35C6.74,19.04 6.74,19.67 6.35,20.06C5.96,20.45 5.32,20.45 4.93,20.07V20.07C3.12,18.26 2,15.76 2,13A10,10 0 0,1 12,3M22,13C22,15.76 20.88,18.26 19.07,20.07V20.07C18.68,20.45 18.05,20.45 17.66,20.06C17.27,19.67 17.27,19.04 17.66,18.65V18.65C19.11,17.2 20,15.21 20,13C20,12 19.81,11 19.46,10.1L20.67,8C21.5,9.5 22,11.18 22,13Z"></path> |
| 366 |
</svg> |
| 367 |
<?php echo str_repeat( '■', mb_strlen( $trans['run_speed_test'] ) ); ?> |
| 368 |
</a> |
| 369 |
</div> |
| 370 |
<div class="side-links"> |
| 371 |
<a href="#" target="_blank" class="side-links-item disabled"> |
| 372 |
<?php echo str_repeat( '■', mb_strlen( $trans['documentation'] ) ); ?> |
| 373 |
</a> |
| 374 |
<a href="#" target="_blank" class="side-links-item disabled"> |
| 375 |
<?php echo str_repeat( '■', mb_strlen( $trans['knowledgebase'] ) ); ?> |
| 376 |
</a> |
| 377 |
</div> |
| 378 |
</div> |
| 379 |
<div class="col-12 col-sm-4 order-sm-first col-md-6 col-xl-8"> |
| 380 |
<section class="ezcache-main"> |
| 381 |
<div> |
| 382 |
<header class="ezcache-screen-header"> |
| 383 |
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> |
| 384 |
</svg> |
| 385 |
<?php echo str_repeat( '■', mb_strlen( $trans['stats'] ) ); ?> |
| 386 |
</header> |
| 387 |
<div class="row"> |
| 388 |
</div> |
| 389 |
</div> |
| 390 |
</section> |
| 391 |
</div> |
| 392 |
</div> |
| 393 |
</div> |
| 394 |
<noscript> |
| 395 |
<p class="text-center"> |
| 396 |
<strong><?php esc_html_e( 'This application requires JavaScript to run', 'ezcache' ); ?></strong> |
| 397 |
</p> |
| 398 |
</noscript> |
| 399 |
</ezc-options> |
| 400 |
</div> |
| 401 |
<?php |
| 402 |
} |
| 403 |
|
| 404 |
/** |
| 405 |
* Queue up the options page scripts |
| 406 |
*/ |
| 407 |
public function enqueue_scripts() { |
| 408 |
$screen = get_current_screen(); |
| 409 |
|
| 410 |
if ( 'toplevel_page_ezcache' != $screen->id ) { |
| 411 |
return; |
| 412 |
} |
| 413 |
|
| 414 |
$ver = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : $this->plugin->plugin_version; |
| 415 |
|
| 416 |
wp_enqueue_script( 'ezcache-options', $this->plugin->plugin_url . '/assets/dist/js/options.js', [], $ver, true ); |
| 417 |
wp_enqueue_style( 'ezcache-options', $this->plugin->plugin_url . '/assets/dist/css/options.css', [], $ver ); |
| 418 |
// branding.css removed — branding is embedded in Vue 2.0 options.css |
| 419 |
|
| 420 |
// Freemius removed — Pro is unlocked for everyone. |
| 421 |
wp_localize_script( 'ezcache-options', 'ezcache', [ |
| 422 |
'assets_url' => esc_url_raw( EZCACHE_URL . '/assets' ), |
| 423 |
'ajax_url' => esc_url_raw( admin_url( 'admin-ajax.php' ) ), |
| 424 |
'rest_url' => esc_url_raw( rest_url() ), |
| 425 |
'ajax_nonce' => wp_create_nonce( 'ezcache-options' ), |
| 426 |
'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
| 427 |
'is_premium' => true, |
| 428 |
'is_trial' => false, |
| 429 |
'trial_days_remaining' => 0, |
| 430 |
'premium_features' => \Upress\EzCache\PremiumFeatures::get_premium_features(), |
| 431 |
'upgrade_url' => '', |
| 432 |
'is_freemius_registered' => false, |
| 433 |
'is_freemius_trial' => false, |
| 434 |
'is_freemius_paying' => true, |
| 435 |
'trial_start_url' => '', |
| 436 |
'opt_in_url' => '', |
| 437 |
'is_rtl' => is_rtl(), |
| 438 |
'site_url' => esc_url_raw( untrailingslashit( site_url() ) ), |
| 439 |
'performance_url' => admin_url( 'admin.php?page=ezcache-performance' ), |
| 440 |
'trans' => $this->getJsTraslations(), |
| 441 |
'is_https_2' => $this->check_https_2_support(), |
| 442 |
'is_elementor_installed' => is_plugin_active( 'elementor/elementor.php' ), |
| 443 |
] ); |
| 444 |
} |
| 445 |
|
| 446 |
/** |
| 447 |
* Check if current website supports HTTPS/2 |
| 448 |
* |
| 449 |
* @return bool |
| 450 |
*/ |
| 451 |
protected function check_https_2_support() { |
| 452 |
if ( ! is_ssl() ) { |
| 453 |
return false; |
| 454 |
} |
| 455 |
|
| 456 |
$supports = get_transient( 'ezcache_https_2_support' ); |
| 457 |
|
| 458 |
if ( ! $supports ) { |
| 459 |
$response = wp_safe_remote_head( home_url(), [ |
| 460 |
'httpversion' => '2.0', |
| 461 |
] ); |
| 462 |
|
| 463 |
$supports = false; |
| 464 |
if ( ! is_wp_error( $response ) ) { |
| 465 |
$response = $response['http_response']->get_response_object(); |
| 466 |
$supports = $response->protocol_version == 2; |
| 467 |
} |
| 468 |
|
| 469 |
set_transient( 'ezcache_https_2_support', [ 'has_support' => $supports ], DAY_IN_SECONDS ); |
| 470 |
} |
| 471 |
|
| 472 |
return isset( $supports['has_support'] ) ? $supports['has_support'] : false; |
| 473 |
} |
| 474 |
|
| 475 |
/** |
| 476 |
* Get the trnaslations required for the javascript frontend |
| 477 |
* |
| 478 |
* @return array |
| 479 |
*/ |
| 480 |
protected function getJsTraslations() { |
| 481 |
return [ |
| 482 |
'is_rtl' => is_rtl(), |
| 483 |
|
| 484 |
'select_all' => __( 'Select All', 'ezcache' ), |
| 485 |
'select_none' => __( 'Select None', 'ezcache' ), |
| 486 |
'ezcache' => __( 'ezCache', 'ezcache' ), |
| 487 |
'enabled' => __( 'Enabled', 'ezcache' ), |
| 488 |
'disabled' => __( 'Disabled', 'ezcache' ), |
| 489 |
'run_speed_test' => __( 'Run a Speed Test', 'ezcache' ), |
| 490 |
'save_settings' => __( 'Save Settings', 'ezcache' ), |
| 491 |
'reset' => __( 'Reset', 'ezcache' ), |
| 492 |
'reset_settings' => __( 'Reset Settings', 'ezcache' ), |
| 493 |
'confirm_reset_settings' => __( 'Are you sure you want to reset the settings to their default values?', 'ezcache' ), |
| 494 |
'settings_saved' => __( 'Settings updated.', 'ezcache' ), |
| 495 |
'error_saving_settings' => __( 'Could not save settings.', 'ezcache' ), |
| 496 |
'clear_cache' => __( 'Clear Cache', 'ezcache' ), |
| 497 |
'cache_cleared' => __( 'Cache has been cleared.', 'ezcache' ), |
| 498 |
'documentation' => __( 'Documentation', 'ezcache' ), |
| 499 |
'knowledgebase' => __( 'Knowledgebase', 'ezcache' ), |
| 500 |
'settings' => __( 'Settings', 'ezcache' ), |
| 501 |
'advanced_settings' => __( 'Advanced Settings', 'ezcache' ), |
| 502 |
'stats' => __( 'Statistics', 'ezcache' ), |
| 503 |
'license' => __( 'License', 'ezcache' ), |
| 504 |
'performance' => __( 'Performance', 'ezcache' ), |
| 505 |
|
| 506 |
// Performance page translations |
| 507 |
'cache_preload' => __( 'Cache Preload', 'ezcache' ), |
| 508 |
'status' => __( 'Status', 'ezcache' ), |
| 509 |
'processed' => __( 'Processed', 'ezcache' ), |
| 510 |
'remaining' => __( 'remaining', 'ezcache' ), |
| 511 |
'run_preload_now' => __( 'Run Preload Now', 'ezcache' ), |
| 512 |
'stop_preload' => __( 'Stop Preload', 'ezcache' ), |
| 513 |
'preload_settings' => __( 'Preload Settings', 'ezcache' ), |
| 514 |
'enable_preload' => __( 'Enable Preload', 'ezcache' ), |
| 515 |
'enable_preload_desc' => __( 'Activate the cache preloader. Pages will be crawled in the background to keep the cache warm.', 'ezcache' ), |
| 516 |
'preload_after_clear' => __( 'Preload after cache clear', 'ezcache' ), |
| 517 |
'crawl_homepage' => __( 'Crawl homepage links', 'ezcache' ), |
| 518 |
'sitemap_url' => __( 'Sitemap URL (optional)', 'ezcache' ), |
| 519 |
'sitemap_url_desc' => __( 'Leave blank to auto-detect /wp-sitemap.xml, /sitemap_index.xml or /sitemap.xml.', 'ezcache' ), |
| 520 |
'urls_per_batch' => __( 'URLs per batch', 'ezcache' ), |
| 521 |
'frontend_optimizations' => __( 'Front-end Optimizations', 'ezcache' ), |
| 522 |
'lazy_load_images' => __( 'Lazy load images', 'ezcache' ), |
| 523 |
'lazy_load_iframes' => __( 'Lazy load iframes', 'ezcache' ), |
| 524 |
'defer_js' => __( 'Defer JavaScript', 'ezcache' ), |
| 525 |
'defer_js_desc' => __( 'Adds defer to local script tags to reduce render-blocking JS.', 'ezcache' ), |
| 526 |
'defer_js_exclusions' => __( 'Defer JS exclusions', 'ezcache' ), |
| 527 |
'defer_js_exclusions_desc' => __( 'One match per line. URLs containing any of these strings will not be deferred.', 'ezcache' ), |
| 528 |
'remove_query_strings' => __( 'Remove query strings from static assets', 'ezcache' ), |
| 529 |
'dns_prefetch' => __( 'DNS prefetch hosts', 'ezcache' ), |
| 530 |
'preconnect' => __( 'Preconnect hosts', 'ezcache' ), |
| 531 |
'heartbeat_control' => __( 'Heartbeat Control', 'ezcache' ), |
| 532 |
'enable_heartbeat' => __( 'Enable heartbeat control', 'ezcache' ), |
| 533 |
'mode' => __( 'Mode', 'ezcache' ), |
| 534 |
'reduce_activity' => __( 'Reduce activity (60s ticks)', 'ezcache' ), |
| 535 |
'disable_completely' => __( 'Disable completely', 'ezcache' ), |
| 536 |
'cdn' => __( 'CDN', 'ezcache' ), |
| 537 |
'enable_cdn' => __( 'Enable CDN rewriting', 'ezcache' ), |
| 538 |
'cdn_url' => __( 'CDN URL', 'ezcache' ), |
| 539 |
'cdn_url_desc' => __( 'Static assets under /wp-content/uploads, /themes and /plugins will be rewritten to this host.', 'ezcache' ), |
| 540 |
'database_cleanup' => __( 'Database Cleanup', 'ezcache' ), |
| 541 |
'delete_revisions' => __( 'Delete post revisions', 'ezcache' ), |
| 542 |
'delete_auto_drafts' => __( 'Delete auto drafts', 'ezcache' ), |
| 543 |
'delete_trashed_posts' => __( 'Delete trashed posts', 'ezcache' ), |
| 544 |
'delete_spam_comments' => __( 'Delete spam comments', 'ezcache' ), |
| 545 |
'delete_trashed_comments' => __( 'Delete trashed comments', 'ezcache' ), |
| 546 |
'delete_transients' => __( 'Delete expired transients', 'ezcache' ), |
| 547 |
'delete_orphan_meta' => __( 'Delete orphan post meta', 'ezcache' ), |
| 548 |
'optimize_tables' => __( 'Run OPTIMIZE TABLE on all tables', 'ezcache' ), |
| 549 |
'cleanup_schedule' => __( 'Automatic cleanup schedule', 'ezcache' ), |
| 550 |
'never' => __( 'Never (manual only)', 'ezcache' ), |
| 551 |
'run_cleanup_now' => __( 'Run Cleanup Now', 'ezcache' ), |
| 552 |
'preload_started' => __( 'Preload started in the background.', 'ezcache' ), |
| 553 |
'preload_stopped' => __( 'Preload cancelled.', 'ezcache' ), |
| 554 |
'db_cleaned' => __( 'Database cleanup completed.', 'ezcache' ), |
| 555 |
'saving' => __( 'Saving', 'ezcache' ), |
| 556 |
'error' => __( 'An error occurred', 'ezcache' ), |
| 557 |
|
| 558 |
'recommended' => __( 'Recommended', 'ezcache' ), |
| 559 |
'basic_settings' => __( 'Basic Settings', 'ezcache' ), |
| 560 |
'confirm' => __( 'OK', 'ezcache' ), |
| 561 |
'cancel' => __( 'Cancel', 'ezcache' ), |
| 562 |
'delete' => __( 'Delete', 'ezcache' ), |
| 563 |
|
| 564 |
'no_cache_known_users' => __( 'Don\'t cache pages for known users', 'ezcache' ), |
| 565 |
'no_cache_known_users_description' => __( 'This disables cache for logged in users.', 'ezcache' ), |
| 566 |
'no_cache_known_users_admin_bar_notice' => __( 'The admin bar will be hidden for all users to prevent it being saved into the cache.', 'ezcache' ), |
| 567 |
'no_cache_comment_authors' => __( 'Don\'t cache pages for comment authors', 'ezcache' ), |
| 568 |
'no_cache_comment_authors_description' => __( 'Do not save cache for users who saved their name and email for the next time they comment.', 'ezcache' ), |
| 569 |
'cache_expiry' => __( 'Cache Expiry', 'ezcache' ), |
| 570 |
'cache_lifetime' => __( 'Cache Timeout', 'ezcache' ), |
| 571 |
'cache_lifetime_description' => __( 'How long to keep the cached data, the recommended and effective starting point is one day.', 'ezcache' ), |
| 572 |
'cache_expiry_interval' => __( 'Check for stale cache every', 'ezcache' ), |
| 573 |
'cache_expiry_interval_description' => __( 'Automatically check for stale cache files and delete them at a set interval.', 'ezcache' ), |
| 574 |
'interval' => __( 'Interval', 'ezcache' ), |
| 575 |
'every' => __( 'Every', 'ezcache' ), |
| 576 |
'seconds' => __( 'Seconds', 'ezcache' ), |
| 577 |
'cache_schedule_type_time' => __( 'At Time', 'ezcache' ), |
| 578 |
'cache_schedule_interval' => __( 'Interval', 'ezcache' ), |
| 579 |
'weekly' => __( 'Weekly', 'ezcache' ), |
| 580 |
'daily' => __( 'Daily', 'ezcache' ), |
| 581 |
'twicedaily' => __( 'Twice Daily', 'ezcache' ), |
| 582 |
'hourly' => __( 'Hourly', 'ezcache' ), |
| 583 |
'at' => __( 'At', 'ezcache' ), |
| 584 |
'cache_bypass' => __( 'Cache Bypass', 'ezcache' ), |
| 585 |
'no_cache_query_params' => __( 'Don\'t cache pages where the URLs contain parameters in the query string', 'ezcache' ), |
| 586 |
'no_cache_query_params_description' => __( 'Don\'t save cache when the URL contains query string parameters, such as ?page_id=15 at the end of the URL.', 'ezcache' ), |
| 587 |
'separate_mobile_cache' => __( 'Separate cache for mobile devices', 'ezcache' ), |
| 588 |
'separate_mobile_cache_description' => __( 'Save separate cache files for mobile browsers and a separate file for desktop browsers, you should only enable this option if your theme is not responsive and you use a theme or a plugin that produces a separate mobile version of the website.', 'ezcache' ), |
| 589 |
'cache_clear_on_post_edit' => __( 'Clear cache when a post or page is published or updated', 'ezcache' ), |
| 590 |
'cache_clear_on_post_edit_description' => __( 'Keep your posts up to date even when they are updated by clearing their cache.', 'ezcache' ), |
| 591 |
'cache_clear_home_on_post_edit' => __( 'Clear homepage cache when a post or page is published or updated', 'ezcache' ), |
| 592 |
'cache_clear_home_on_post_edit_description' => __( 'Make sure your visitors read the latest posts by clearing the cache when you update or publish a post.', 'ezcache' ), |
| 593 |
'bypass_cache_title' => __( 'Disable caching for the following pages', 'ezcache' ), |
| 594 |
'bypass_cache_single' => __( 'Single Posts', 'ezcache' ), |
| 595 |
'bypass_cache_pages' => __( 'Pages', 'ezcache' ), |
| 596 |
'bypass_cache_frontpage' => __( 'Front Page', 'ezcache' ), |
| 597 |
'bypass_cache_home' => __( 'Home', 'ezcache' ), |
| 598 |
'bypass_cache_archives' => __( 'Archives', 'ezcache' ), |
| 599 |
'bypass_cache_tag' => __( 'Tags', 'ezcache' ), |
| 600 |
'bypass_cache_category' => __( 'Categories', 'ezcache' ), |
| 601 |
'bypass_cache_feed' => __( 'Feeds', 'ezcache' ), |
| 602 |
'bypass_cache_search' => __( 'Search Results', 'ezcache' ), |
| 603 |
'bypass_cache_author' => __( 'Author Pages', 'ezcache' ), |
| 604 |
'rejected_uri' => __( 'Links (URLs) which will never get cached', 'ezcache' ), |
| 605 |
'rejected_uri_description' => __( 'Do not serve cached content if the URL matches any link in the following list', 'ezcache' ), |
| 606 |
'rejected_uri_wildcard' => __( 'The domain part of the URL will be stripped automatically. Use * wildcard character to match multiple characters at this position (eg. /product/*).', 'ezcache' ), |
| 607 |
'rejected_user_agent' => __( 'User Agents which will never receive cached data', 'ezcache' ), |
| 608 |
'rejected_user_agent_description' => __( 'Do not serve cached content to the following useragents', 'ezcache' ), |
| 609 |
'rejected_cookies' => __( 'Cookies which will prevent pages from getting cached', 'ezcache' ), |
| 610 |
'rejected_cookies_description' => __( 'Specify the cookies that when set in the visitor\'s browser, should prevent a page from getting cached (one per line)', 'ezcache' ), |
| 611 |
'rejected_cookies_placeholder' => _x( 'wordpress_logged_in_', 'rejected cookies example', 'ezcache' ), |
| 612 |
'n_minutes' => __( '%s Minutes', 'ezcache' ), |
| 613 |
'n_hours' => __( '%s Hours', 'ezcache' ), |
| 614 |
'n_days' => __( '%s Days', 'ezcache' ), |
| 615 |
'never_expire' => __( 'Never Expire', 'ezcache' ), |
| 616 |
'cache_disabled' => __( 'WP_CACHE is disabled in your wp-config.php, caching will not work.', 'ezcache' ), |
| 617 |
'adv_cache_not_exists' => __( 'advanced-cache.php is missing from your wp-content folder, caching will not work.', 'ezcache' ), |
| 618 |
'plugin_badly_installed' => __( 'Plugin is not installed properly, please reinstall, caching will not work.', 'ezcache' ), |
| 619 |
'desktop' => _x( 'Desktop', 'statistics block title', 'ezcache' ), |
| 620 |
'mobile' => _x( 'Mobile', 'statistics block title', 'ezcache' ), |
| 621 |
'expired' => _x( 'Expire Cache', 'statistics block title', 'ezcache' ), |
| 622 |
'javascript' => _x( 'JavaScript Files', 'statistics block title', 'ezcache' ), |
| 623 |
'css' => _x( 'CSS Files', 'statistics block title', 'ezcache' ), |
| 624 |
'webp_images' => _x( 'WebP Images', 'statistics block title', 'ezcache' ), |
| 625 |
'cache_usage' => __( 'ezCache Cache Usage', 'ezcache' ), |
| 626 |
'webp_stats_description' => __( 'Images optimized with WebP.', 'ezcache' ), |
| 627 |
'cache_bypass_settings' => _x( 'Cache Bypass', 'settings block title', 'ezcache' ), |
| 628 |
'cache_settings' => _x( 'Caching', 'settings block title', 'ezcache' ), |
| 629 |
'performance_settings' => _x( 'Performance', 'settings block title', 'ezcache' ), |
| 630 |
'cache_expiry_settings' => _x( 'Cache Expiration', 'settings block title', 'ezcache' ), |
| 631 |
'optimize_google_fonts' => __( 'Optimize Google fonts', 'ezcache' ), |
| 632 |
'optimize_google_fonts_description' => __( 'Combine multiple Google Fonts declerations into one.', 'ezcache' ), |
| 633 |
'minify_html' => __( 'Minify HTML', 'ezcache' ), |
| 634 |
'minify_html_description' => __( 'Minify the cached HTML to make cached files smaller.', 'ezcache' ), |
| 635 |
'minify_inline_js' => __( 'Minify Inline JavaScript', 'ezcache' ), |
| 636 |
'minify_inline_js_description' => __( 'Include JavaScript embedded in the HTML in the minification process.', 'ezcache' ), |
| 637 |
'minify_inline_css' => __( 'Minify Inline CSS', 'ezcache' ), |
| 638 |
'minify_inline_css_description' => __( 'Include CSS embedded in the HTML in the minification process.', 'ezcache' ), |
| 639 |
'minify_js' => __( 'Minify JavaScript', 'ezcache' ), |
| 640 |
'minify_js_description' => __( 'Minify JavaScript files to reduce their size.', 'ezcache' ), |
| 641 |
'minify_html_comments' => __( 'Remove HTML comments', 'ezcache' ), |
| 642 |
'minify_html_comments_description' => __( 'Remove embeded comments from minified HTML.', 'ezcache' ), |
| 643 |
'combine_head_js' => __( 'Combine JavaScript in Head', 'ezcache' ), |
| 644 |
'combine_head_js_description' => __( 'Combine multiple JavaScript files found in the head section of the HTML into one file.', 'ezcache' ), |
| 645 |
'combine_body_js' => __( 'Combine JavaScript in Body', 'ezcache' ), |
| 646 |
'combine_body_js_description' => __( 'Combine multiple JavaScript files found in the body section of the HTML into one file.', 'ezcache' ), |
| 647 |
'combine_head_inline_js' => __( 'Combine Inline JavaScript in Head', 'ezcache' ), |
| 648 |
'combine_head_inline_js_description' => __( 'Combine JavaScript scripts found in the head section of the HTML into the combined JS file.', 'ezcache' ), |
| 649 |
'combine_body_inline_js' => __( 'Combine Inline JavaScript in Body', 'ezcache' ), |
| 650 |
'combine_body_inline_js_description' => __( 'Combine JavaScript scripts found in the body section of the HTML into the combined JS file.', 'ezcache' ), |
| 651 |
'combine_js_elementor_notice' => __( 'Elementor generates a unique JS file for each post/page which can cause the cache to use large amounts of disk space, to fix this make sure to exclude Elementor JS files (`elementor/js/post-*`) from optimizations.', 'ezcache' ), |
| 652 |
'minify_css' => __( 'Minify CSS', 'ezcache' ), |
| 653 |
'minify_css_description' => __( 'Minify CSS files to reduce their size.', 'ezcache' ), |
| 654 |
'combine_css' => __( 'Combine CSS', 'ezcache' ), |
| 655 |
'combine_css_description' => __( 'Combine multiple CSS files into one to reduce HTTP requests.', 'ezcache' ), |
| 656 |
'combine_css_elementor_notice' => __( 'Elementor generates a unique CSS file for each post/page which can cause the cache to use large amounts of disk space, to fix this make sure to exclude Elementor CSS files (`elementor/css/post-*`) from optimizations.', 'ezcache' ), |
| 657 |
'disable_wp_emoji' => __( 'Disable WordPress Emoji', 'ezcache' ), |
| 658 |
'disable_wp_emoji_description' => __( 'Remove extra code related to Emoji from WordPress which was added recently to support Emoji in an older browsers.', 'ezcache' ), |
| 659 |
'not_recommended_https2' => __( 'Your server supports HTTP/2 which benefits from having this option kept disabled', 'ezcache' ), |
| 660 |
'enable_webp_support' => __( 'Optimize Images With WebP', 'ezcache' ), |
| 661 |
/* xgettext:no-php-format */ |
| 662 |
'enable_webp_support_description' => __( 'WebP is a modern image format that provides superior lossless and lossy compression for images on the web. WebP lossless images are 26% smaller in size compared to PNGs, and 25-34% smaller than comparable JPEG images.', 'ezcache' ), |
| 663 |
'requries_premium_license' => __( 'Requires a premium license', 'ezcache' ), |
| 664 |
'rejected_user_agent_placeholder' => _x( 'Googlebot', 'user agent example', 'ezcache' ), |
| 665 |
'rejected_uri_placeholder' => _x( '/products/*', 'rejected uri example', 'ezcache' ), |
| 666 |
'css_stats_description' => __( 'Optimized and cached CSS files.', 'ezcache' ), |
| 667 |
'javascript_stats_description' => __( 'Optimized and cached JavaScript files.', 'ezcache' ), |
| 668 |
'expired_stats_description' => __( 'Cache data that has expired and waiting to be cleaned up.', 'ezcache' ), |
| 669 |
'mobile_stats_description' => __( 'Cache data for pages viewed from mobile devices.', 'ezcache' ), |
| 670 |
'desktop_stats_description' => __( 'Cache data for pages viewed from desktop computers.', 'ezcache' ), |
| 671 |
'general_advanced_settings' => __( 'General', 'ezcache' ), |
| 672 |
|
| 673 |
'combine_css_footer' => __( 'Move combined CSS to footer', 'ezcache' ), |
| 674 |
'combine_css_footer_description' => __( 'Eliminate render blocking CSS by moving the combined CSS file to the footer section.', 'ezcache' ), |
| 675 |
'critical_css' => __( 'Critical CSS', 'ezcache' ), |
| 676 |
'critical_css_description' => __( "Critical CSS is the minimum set of blocking CSS required to render the first screen's worth of content to the user in order to render content to the user as fast as possible.\nThe Critical CSS can (and should) be manually created to fit the website perfectly, however there are tools that can automatically generate the Critical CSS for you.", 'ezcache' ), |
| 677 |
'critical_css_more_information' => __( 'More information about Critical CSS', 'ezcache' ), |
| 678 |
'critical_css_online_tool' => __( 'Online Critical CSS Generator', 'ezcache' ), |
| 679 |
'combine_css_footer_requires_combine_css_notice' => __( 'Moving combined CSS to footer requires the Combine CSS option enabled.', 'ezcache' ), |
| 680 |
'excluded_minify_files' => __( 'Exclude JS/CSS files from optimization', 'ezcache' ), |
| 681 |
'excluded_minify_files_description' => __( 'List filenames or paths to files which should be excluded from minification or combining.', 'ezcache' ), |
| 682 |
'excluded_minify_files_placeholder' => __( "jquery.js\nrecaptcha/api.js\ngoogleadservices.com", 'ezcache' ), |
| 683 |
|
| 684 |
'advanced_tools' => __( 'Advanced Tools', 'ezcache' ), |
| 685 |
'delete_webp_images' => __( 'Clear WebP Images Cache', 'ezcache' ), |
| 686 |
'confirm_delete_webp_images' => __( "Are you sure that you want to delete all of the cached WebP images?\nTheses images will have to be converted again which may take some time.", 'ezcache' ), |
| 687 |
'error_delete_webp_images' => __( "Error clearing WebP image cache", 'ezcache' ), |
| 688 |
'schedule_webp_images_process_started' => __( "Scheduled task queued", 'ezcache' ), |
| 689 |
'error_schedule_webp_images_process' => __( "Error scheduling WebP process", 'ezcache' ), |
| 690 |
'schedule_webp_images_process' => __( "Re-Schedule WebP Process Scheduled Task", 'ezcache' ), |
| 691 |
|
| 692 |
'license_key' => __( 'License Key', 'ezcache' ), |
| 693 |
'license_key_description' => __( 'Pro features are unlocked.', 'ezcache' ), |
| 694 |
'deactivate_license' => __( 'Account Settings', 'ezcache' ), |
| 695 |
'activate_license' => __( 'Manage License', 'ezcache' ), |
| 696 |
'license_valid' => __( 'License is valid', 'ezcache' ), |
| 697 |
'license_invalid' => __( 'License is invalid', 'ezcache' ), |
| 698 |
'license_expires_at' => __( 'License expires at %s', 'ezcache' ), |
| 699 |
'unknown' => __( 'Unknown', 'ezcache' ), |
| 700 |
'license_status' => __( 'Status', 'ezcache' ), |
| 701 |
'license_details' => __( 'License Details', 'ezcache' ), |
| 702 |
'license_type' => __( 'License Type', 'ezcache' ), |
| 703 |
'trial_license' => _x( 'Trial', 'license type', 'ezcache' ), |
| 704 |
'regular_license' => _x( 'Pro', 'license type', 'ezcache' ), |
| 705 |
'expires_in' => __( 'Expires In', 'ezcache' ), |
| 706 |
'expires_at' => __( 'Expires At', 'ezcache' ), |
| 707 |
'uses_left' => __( 'Convertions Left', 'ezcache' ), |
| 708 |
'trial_not_started' => __( '%s days after first usage', 'ezcache' ), |
| 709 |
'purchase_license' => __( 'Get a Pro License', 'ezcache' ), |
| 710 |
'license_expired' => __( 'Expired', 'ezcache' ), |
| 711 |
'no_expiry_while_upress_client' => __( 'Will not expire while hosted on uPress', 'ezcache' ), |
| 712 |
|
| 713 |
'upress_ad' => __( 'uPress Premium WordPress Hosting', 'ezcache' ), |
| 714 |
'upress_domain' => __( 'www.upress.io', 'ezcache' ), |
| 715 |
'upress_ad_link' => __( 'https://www.upress.io/?utm_source=wordpress&utm_medium=cpc&utm_campaign=ezcache', 'ezcache' ), |
| 716 |
'speed_test_url' => __( 'https://speedom.net/?url=%s&location=US-NY&utm_source=wordpress&utm_medium=cpc&utm_campaign=ezcache', 'ezcache' ), |
| 717 |
'ezcache_docs_link' => __( 'https://ezcache-wp.com/documentation?utm_source=wordpress&utm_medium=cpc&utm_campaign=ezcache', 'ezcache' ), |
| 718 |
'ezcache_knowledgebase_link' => __( 'https://ezcache-wp.com/knowledgebase?utm_source=wordpress&utm_medium=cpc&utm_campaign=ezcache', 'ezcache' ), |
| 719 |
'ezcache_pricing_link' => __( 'https://ezcache-wp.com/pricing?utm_source=wordpress&utm_medium=cpc&utm_campaign=ezcache', 'ezcache' ), |
| 720 |
]; |
| 721 |
} |
| 722 |
|
| 723 |
/** |
| 724 |
* Show cache status admin notices when needed |
| 725 |
*/ |
| 726 |
|
| 727 |
/** |
| 728 |
* Show trial banner in admin |
| 729 |
*/ |
| 730 |
function show_trial_banner() { |
| 731 |
// No-op — licensing/trial system removed. Pro is unlocked for everyone. |
| 732 |
return; |
| 733 |
} |
| 734 |
|
| 735 |
function maybe_show_advanced_cache_notice() { |
| 736 |
$webp_queue = get_site_option( 'ezcache_convert_images_to_webp_reprocess_queue' ); |
| 737 |
if ( ! $webp_queue ) { |
| 738 |
$webp_queue = []; |
| 739 |
} |
| 740 |
$count_pending = array_reduce( $webp_queue, function ( $count, $images ) { |
| 741 |
return $count + count( $images ); |
| 742 |
}, 0 ); |
| 743 |
|
| 744 |
if ( $count_pending > 0 ) { |
| 745 |
echo '<div class="notice notice-info"><p><strong>' . esc_html__( 'ezCache', 'ezcache' ) . ':</strong> ' . sprintf( esc_html__( 'WebP Processing is currently running, %d images remaining.', 'ezcache' ), $count_pending ) . '</p></div>'; |
| 746 |
} |
| 747 |
|
| 748 |
if ( ! get_site_option( 'ezcache_first_run', false ) ) { |
| 749 |
update_site_option( 'ezcache_first_run', 1 ); |
| 750 |
} |
| 751 |
} |
| 752 |
|
| 753 |
function admin_clear_cache() { |
| 754 |
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'wpb-clear-cache' ) ) { |
| 755 |
wp_nonce_ays( 'wpb-clear-cache' ); |
| 756 |
} |
| 757 |
|
| 758 |
$this->plugin->ezcache->clear_cache(); |
| 759 |
|
| 760 |
wp_redirect( wp_get_referer() ); |
| 761 |
exit; |
| 762 |
} |
| 763 |
|
| 764 |
function maybe_show_admin_bar( $show_admin_bar ) { |
| 765 |
$settings = Settings::get_settings(); |
| 766 |
|
| 767 |
if ( ! $settings->no_cache_known_users ) { |
| 768 |
return false; |
| 769 |
} |
| 770 |
|
| 771 |
return $show_admin_bar; |
| 772 |
} |
| 773 |
|
| 774 |
/** |
| 775 |
* Inject premium feature gates into the UI |
| 776 |
*/ |
| 777 |
|
| 778 |
/** |
| 779 |
* @deprecated Branding is now handled by the Vue 2.0 frontend (options.css/options.js). |
| 780 |
* This method is no longer hooked. Kept for reference only. |
| 781 |
*/ |
| 782 |
function inject_branding_css() { |
| 783 |
$screen = get_current_screen(); |
| 784 |
if ( ! $screen || strpos( $screen->id, 'ezcache' ) === false ) { |
| 785 |
return; |
| 786 |
} |
| 787 |
?> |
| 788 |
<style> |
| 789 |
/* ezCache 2026 Branding */ |
| 790 |
.ezcache-screen-header { |
| 791 |
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%) !important; |
| 792 |
color: #fff !important; |
| 793 |
padding: 24px 28px !important; |
| 794 |
border-radius: 12px !important; |
| 795 |
margin: 20px 0 24px !important; |
| 796 |
display: flex !important; |
| 797 |
align-items: center !important; |
| 798 |
gap: 12px !important; |
| 799 |
font-size: 22px !important; |
| 800 |
font-weight: 700 !important; |
| 801 |
position: relative; |
| 802 |
overflow: hidden; |
| 803 |
border: 1px solid rgba(255,204,0,0.2); |
| 804 |
box-shadow: 0 4px 20px rgba(0,0,0,0.15); |
| 805 |
} |
| 806 |
.ezcache-screen-header::before { |
| 807 |
content: none; |
| 808 |
font-size: 0; |
| 809 |
margin-right: 4px; |
| 810 |
} |
| 811 |
.ezcache-screen-header::after { |
| 812 |
content: none; |
| 813 |
position: absolute; |
| 814 |
right: 20px; |
| 815 |
top: 50%; |
| 816 |
transform: translateY(-50%); |
| 817 |
background: #ffcc00; |
| 818 |
color: #0a0a0a; |
| 819 |
font-size: 11px; |
| 820 |
font-weight: 800; |
| 821 |
padding: 4px 12px; |
| 822 |
border-radius: 20px; |
| 823 |
letter-spacing: 0.5px; |
| 824 |
} |
| 825 |
.ezcache-screen-header svg { |
| 826 |
fill: #ffcc00 !important; |
| 827 |
width: 28px !important; |
| 828 |
height: 28px !important; |
| 829 |
} |
| 830 |
|
| 831 |
/* Modernize toggle panels */ |
| 832 |
.ezcache-toggle-panel, |
| 833 |
.ezcache-options .postbox, |
| 834 |
.ezcache-options .card { |
| 835 |
border-radius: 10px !important; |
| 836 |
border: 1px solid #e0e0e0 !important; |
| 837 |
box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important; |
| 838 |
overflow: hidden; |
| 839 |
} |
| 840 |
|
| 841 |
/* Save button styling */ |
| 842 |
.wpb-button-primary { |
| 843 |
background: linear-gradient(135deg, #ffcc00, #e6b800) !important; |
| 844 |
color: #0a0a0a !important; |
| 845 |
border: none !important; |
| 846 |
border-radius: 8px !important; |
| 847 |
font-weight: 700 !important; |
| 848 |
text-transform: none !important; |
| 849 |
box-shadow: 0 2px 10px rgba(255,204,0,0.25) !important; |
| 850 |
transition: all 0.2s !important; |
| 851 |
} |
| 852 |
.wpb-button-primary:hover { |
| 853 |
transform: translateY(-1px) !important; |
| 854 |
box-shadow: 0 4px 16px rgba(255,204,0,0.35) !important; |
| 855 |
} |
| 856 |
|
| 857 |
/* Sidebar menu icon */ |
| 858 |
#toplevel_page_ezcache .wp-menu-image::before { |
| 859 |
content: '⚡' !important; |
| 860 |
font-size: 18px !important; |
| 861 |
} |
| 862 |
</style> |
| 863 |
<?php |
| 864 |
} |
| 865 |
function inject_premium_ui_gates() { |
| 866 |
$screen = get_current_screen(); |
| 867 |
if ( 'toplevel_page_ezcache' != $screen->id ) { |
| 868 |
return; |
| 869 |
} |
| 870 |
|
| 871 |
if ( \Upress\EzCache\PremiumFeatures::is_premium() ) { |
| 872 |
return; // Premium user, no gates needed |
| 873 |
} |
| 874 |
|
| 875 |
$premium_features = \Upress\EzCache\PremiumFeatures::get_premium_features(); |
| 876 |
$features_json = json_encode( $premium_features ); |
| 877 |
$upgrade_url = '#pricing'; |
| 878 |
|
| 879 |
?> |
| 880 |
<style> |
| 881 |
.ezcache-premium-overlay { |
| 882 |
position: relative; |
| 883 |
} |
| 884 |
.ezcache-premium-overlay::after { |
| 885 |
content: '🔒 PRO'; |
| 886 |
position: absolute; |
| 887 |
top: 50%; |
| 888 |
right: 12px; |
| 889 |
transform: translateY(-50%); |
| 890 |
background: #ffcc00; |
| 891 |
color: #1a1a1a; |
| 892 |
font-size: 11px; |
| 893 |
font-weight: 800; |
| 894 |
padding: 2px 10px; |
| 895 |
border-radius: 12px; |
| 896 |
pointer-events: none; |
| 897 |
} |
| 898 |
.ezcache-premium-disabled { |
| 899 |
opacity: 0.45; |
| 900 |
pointer-events: none; |
| 901 |
user-select: none; |
| 902 |
} |
| 903 |
.ezcache-upgrade-banner { |
| 904 |
background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%); |
| 905 |
border: 1px solid #ffcc00; |
| 906 |
border-radius: 12px; |
| 907 |
padding: 20px 24px; |
| 908 |
margin: 16px 0; |
| 909 |
display: flex; |
| 910 |
align-items: center; |
| 911 |
justify-content: space-between; |
| 912 |
flex-wrap: wrap; |
| 913 |
gap: 16px; |
| 914 |
} |
| 915 |
.ezcache-upgrade-banner .upgrade-text { |
| 916 |
color: #e0e0e0; |
| 917 |
font-size: 14px; |
| 918 |
line-height: 1.5; |
| 919 |
} |
| 920 |
.ezcache-upgrade-banner .upgrade-text strong { |
| 921 |
color: #ffcc00; |
| 922 |
} |
| 923 |
.ezcache-upgrade-btn { |
| 924 |
background: #ffcc00; |
| 925 |
color: #1a1a1a; |
| 926 |
border: none; |
| 927 |
padding: 10px 24px; |
| 928 |
border-radius: 50px; |
| 929 |
font-size: 14px; |
| 930 |
font-weight: 700; |
| 931 |
text-decoration: none; |
| 932 |
cursor: pointer; |
| 933 |
white-space: nowrap; |
| 934 |
transition: all 0.2s; |
| 935 |
} |
| 936 |
.ezcache-upgrade-btn:hover { |
| 937 |
background: #e6b800; |
| 938 |
transform: translateY(-1px); |
| 939 |
box-shadow: 0 4px 15px rgba(255,204,0,0.3); |
| 940 |
color: #1a1a1a; |
| 941 |
} |
| 942 |
</style> |
| 943 |
<script> |
| 944 |
document.addEventListener('DOMContentLoaded', function() { |
| 945 |
var premiumFeatures = <?php echo $features_json; ?>; |
| 946 |
var upgradeUrl = '<?php echo esc_url( $upgrade_url ); ?>'; |
| 947 |
|
| 948 |
function applyPremiumGates() { |
| 949 |
// Find all checkboxes and select elements |
| 950 |
var inputs = document.querySelectorAll('input[type="checkbox"], select, textarea'); |
| 951 |
|
| 952 |
inputs.forEach(function(input) { |
| 953 |
var id = input.id || ''; |
| 954 |
var name = input.name || ''; |
| 955 |
|
| 956 |
// Check if this input's ID matches a premium feature |
| 957 |
premiumFeatures.forEach(function(feature) { |
| 958 |
if (id.indexOf(feature) !== -1 || name.indexOf(feature) !== -1) { |
| 959 |
// Disable the input |
| 960 |
input.disabled = true; |
| 961 |
input.checked = false; |
| 962 |
|
| 963 |
// Find parent container and add overlay |
| 964 |
var parent = input.closest('.form-group, div, tr'); |
| 965 |
if (parent && !parent.classList.contains('ezcache-premium-disabled')) { |
| 966 |
parent.classList.add('ezcache-premium-disabled'); |
| 967 |
parent.classList.add('ezcache-premium-overlay'); |
| 968 |
} |
| 969 |
} |
| 970 |
}); |
| 971 |
}); |
| 972 |
|
| 973 |
// Add upgrade banner at the top of the main content |
| 974 |
var mainContent = document.querySelector('.ezcache-main, .ezcache-options, .wrap'); |
| 975 |
if (mainContent && !document.querySelector('.ezcache-upgrade-banner')) { |
| 976 |
var banner = document.createElement('div'); |
| 977 |
banner.className = 'ezcache-upgrade-banner'; |
| 978 |
banner.innerHTML = '<div class="upgrade-text">⚡ <strong>Upgrade to Pro</strong> to unlock CSS/JS optimization, WebP images, cache preloading, CDN, database cleanup and more — just <strong>$29/year</strong></div><a href="' + upgradeUrl + '" class="ezcache-upgrade-btn">🔓 Upgrade to Pro</a>'; |
| 979 |
|
| 980 |
var firstChild = mainContent.firstChild; |
| 981 |
if (firstChild) { |
| 982 |
mainContent.insertBefore(banner, firstChild); |
| 983 |
} else { |
| 984 |
mainContent.appendChild(banner); |
| 985 |
} |
| 986 |
} |
| 987 |
} |
| 988 |
|
| 989 |
// Apply immediately and also watch for Vue rendering |
| 990 |
setTimeout(applyPremiumGates, 500); |
| 991 |
setTimeout(applyPremiumGates, 1500); |
| 992 |
setTimeout(applyPremiumGates, 3000); |
| 993 |
|
| 994 |
// Also watch for DOM changes (Vue renders async) |
| 995 |
var observer = new MutationObserver(function() { |
| 996 |
setTimeout(applyPremiumGates, 100); |
| 997 |
}); |
| 998 |
var target = document.querySelector('#ezcache-options, .ezcache-options, .wrap'); |
| 999 |
if (target) { |
| 1000 |
observer.observe(target, { childList: true, subtree: true }); |
| 1001 |
// Stop observing after 10 seconds to avoid performance issues |
| 1002 |
setTimeout(function() { observer.disconnect(); }, 10000); |
| 1003 |
} |
| 1004 |
}); |
| 1005 |
</script> |
| 1006 |
<?php |
| 1007 |
} |
| 1008 |
} |
| 1009 |
|