Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wp-smush.../core
File: class-cache-controller.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Smush\Core;
[2] Fix | Delete
[3] Fix | Delete
class Cache_Controller extends Controller {
[4] Fix | Delete
const SHOW_CACHE_NOTICE_TRANSIENT = 'wp_smush_show_cache_notice';
[5] Fix | Delete
const CLEAR_CACHE_ACTION = 'wp_smush_clear_page_cache';
[6] Fix | Delete
[7] Fix | Delete
public function __construct() {
[8] Fix | Delete
$this->register_action( 'wp_smush_webp_status_changed', array( $this, 'webp_status_changed' ) );
[9] Fix | Delete
$this->register_action( 'wp_smush_webp_method_changed', array( $this, 'webp_method_changed' ) );
[10] Fix | Delete
$this->register_action( 'wp_smush_cdn_status_changed', array( $this, 'cdn_status_changed' ) );
[11] Fix | Delete
// TODO: identify other cases where cache should be cleared and call the clear_third_party_cache method
[12] Fix | Delete
[13] Fix | Delete
$this->register_action( 'wp_ajax_smush_dismiss_cache_notice', array( $this, 'dismiss_cache_notice' ) );
[14] Fix | Delete
$this->register_action( 'wp_smush_header_notices', array( $this, 'maybe_show_cache_notice' ) );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
public function cdn_status_changed() {
[18] Fix | Delete
$this->clear_third_party_cache( 'cdn' );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function webp_method_changed() {
[22] Fix | Delete
$this->clear_third_party_cache( 'webp_method' );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
public function webp_status_changed() {
[26] Fix | Delete
$this->clear_third_party_cache( 'webp' );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
private function clear_third_party_cache( $notice_key = '' ) {
[30] Fix | Delete
do_action( self::CLEAR_CACHE_ACTION );
[31] Fix | Delete
if ( ! has_action( self::CLEAR_CACHE_ACTION ) && $notice_key ) {
[32] Fix | Delete
// If no one is handling the cache clearing then show a notice
[33] Fix | Delete
set_transient( self::SHOW_CACHE_NOTICE_TRANSIENT, $notice_key );
[34] Fix | Delete
}
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
public function dismiss_cache_notice() {
[38] Fix | Delete
check_ajax_referer( 'wp-smush-ajax' );
[39] Fix | Delete
// Check for permission.
[40] Fix | Delete
if ( ! Helper::is_user_allowed( 'manage_options' ) ) {
[41] Fix | Delete
wp_die( esc_html__( 'Unauthorized', 'wp-smushit' ), 403 );
[42] Fix | Delete
}
[43] Fix | Delete
delete_transient( self::SHOW_CACHE_NOTICE_TRANSIENT );
[44] Fix | Delete
wp_send_json_success();
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
public function maybe_show_cache_notice() {
[48] Fix | Delete
$notice = $this->get_cache_notice();
[49] Fix | Delete
if ( empty( $notice ) ) {
[50] Fix | Delete
return;
[51] Fix | Delete
}
[52] Fix | Delete
?>
[53] Fix | Delete
<div class="sui-notice sui-notice-info" id="wp-smush-cache-notice">
[54] Fix | Delete
<div class="sui-notice-content">
[55] Fix | Delete
<div class="sui-notice-message">
[56] Fix | Delete
<i class="sui-notice-icon sui-icon-info" aria-hidden="true"></i>
[57] Fix | Delete
<p><?php echo wp_kses_post( $notice ); ?></p>
[58] Fix | Delete
</div>
[59] Fix | Delete
<div class="sui-notice-actions">
[60] Fix | Delete
<button class="sui-button-icon smush-dismiss-notice-button">
[61] Fix | Delete
<i class="sui-icon-check" aria-hidden="true"></i>
[62] Fix | Delete
<span class="sui-screen-reader-text"><?php esc_html_e( 'Dismiss', 'wp-smushit' ); ?></span>
[63] Fix | Delete
</button>
[64] Fix | Delete
</div>
[65] Fix | Delete
</div>
[66] Fix | Delete
</div>
[67] Fix | Delete
<?php
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
private function get_cache_notice() {
[71] Fix | Delete
$notice_key = get_transient( self::SHOW_CACHE_NOTICE_TRANSIENT );
[72] Fix | Delete
if ( empty( $notice_key ) ) {
[73] Fix | Delete
return;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
$settings = Settings::get_instance();
[77] Fix | Delete
if ( 'cdn' === $notice_key ) {
[78] Fix | Delete
return $settings->has_cdn_page() ? __( 'CDN status has changed.<br/>If you have a page caching plugin or server caching, please clear it to ensure everything works as expected.', 'wp-smushit' ) : '';
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
if ( 'webp' === $notice_key || 'webp_method' === $notice_key ) {
[82] Fix | Delete
$notice = 'webp' === $notice_key ? __( 'Local WebP status has changed.<br/>If you have a page caching plugin or server caching, please clear it to ensure everything works as expected.', 'wp-smushit' ) :
[83] Fix | Delete
__( 'Local WebP method has been updated.<br/>If you have a page caching plugin or server caching, please clear it to ensure everything works as expected.', 'wp-smushit' );
[84] Fix | Delete
return $settings->has_webp_page() ? $notice : '';
[85] Fix | Delete
}
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function