settings['disabled_tabs'] = apply_filters('speedycache_disabled_tabs', []); $hooknames[] = add_menu_page('SpeedyCache Settings', 'SpeedyCache', $capability, 'speedycache', '\SpeedyCache\Settings::base', SPEEDYCACHE_URL.'/assets/images/icon.svg'); foreach($hooknames as $hookname){ add_action('load-'.$hookname, '\SpeedyCache\Admin::load_assets'); } } static function load_assets(){ add_action('admin_enqueue_scripts', '\SpeedyCache\Admin::enqueue_scripts'); } // Enqueues Admin CSS on load of the page static function enqueue_scripts(){ wp_enqueue_style('speedycache-admin', SPEEDYCACHE_URL.'/assets/css/admin.css', [], SPEEDYCACHE_VERSION); wp_enqueue_script('speedycache-admin', SPEEDYCACHE_URL . '/assets/js/admin.js', [], SPEEDYCACHE_VERSION); wp_localize_script('speedycache-admin', 'speedycache_ajax', [ 'url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('speedycache_ajax_nonce'), 'premium' => defined('SPEEDYCACHE_PRO'), ]); } // Post action to delete cache through Manage cache options. static function delete_cache(){ check_admin_referer('speedycache_post_nonce'); if(!current_user_can('manage_options')){ wp_die(esc_html__('You do not have a required privilege', 'speedycache')); } $delete['minified'] = isset($_REQUEST['minified']); $delete['font'] = isset($_REQUEST['font']); $delete['gravatars'] = isset($_REQUEST['gravatars']); $delete['domain'] = isset($_REQUEST['domain']); $delete['preload'] = isset($_REQUEST['preload_cache']); \SpeedyCache\Delete::run($delete); $redirect_to = esc_url_raw(wp_unslash($_REQUEST['_wp_http_referer'])); wp_safe_redirect($redirect_to); die(); } static function delete_single(){ check_admin_referer('speedycache_post_nonce', 'security'); if(!current_user_can('manage_options')){ wp_die(esc_html__('You do not have a required privilege', 'speedycache')); } $post_id = Util::sanitize_get('post_id'); \SpeedyCache\Delete::cache($post_id); $redirect_to = esc_url_raw(wp_unslash($_REQUEST['referer'])); wp_safe_redirect($redirect_to); die(); } static function delete_single_url(){ check_admin_referer('speedycache_post_nonce', 'security'); if(!current_user_can('manage_options')){ wp_die(esc_html__('You do not have a required privilege', 'speedycache')); } $url = esc_url_raw(wp_unslash($_REQUEST['referer'])); \SpeedyCache\Delete::url($url); wp_safe_redirect($url); die(); } static function combitibility_notice(){ $incompatible_plugins = [ 'wp-rocket/wp-rocket.php' => 'WP Rocket', 'wp-super-cache/wp-cache.php' => 'WP Super Cache', 'litespeed-cache/litespeed-cache.php' => 'LiteSpeed Cache', 'swift-performance-lite/performance.php' => 'Swift Performance Lite', 'swift-performance/performance.php' => 'Swift Performance', 'wp-fastest-cache/wpFastestCache.php' => 'WP Fastest Cache', 'wp-optimize/wp-optimize.php' => 'WP Optimize', 'w3-total-cache/w3-total-cache.php' => 'W3 Total Cache', ]; $conflicting_plugins = []; foreach($incompatible_plugins as $plugin_path => $plugin_name){ if(is_plugin_active($plugin_path)){ $conflicting_plugins[] = $plugin_name; } } if(empty($conflicting_plugins)){ return; } echo '
'.esc_html__('You have activated plugins that conflict with SpeedyCache. We recommend deactivating these plugins to ensure SpeedyCache functions properly.', 'speedycache').'