= 0) { require_once dirname(__FILE__) . '/php-5.3-functions.php'; } wpo_cache_load_extensions(); if (!class_exists('WPO_Page_Cache')) : class WPO_Page_Cache { /** * Cache config object * * @var mixed */ public $config; /** * Logger for this class * * @var mixed */ public $logger; /** * Instance of this class * * @var mixed */ public static $instance; /** * Store last advanced cache file writing status * If true then last writing finished with error * * @var bool */ public $advanced_cache_file_writing_error; /** * Store errors * * @var array */ private $_errors = array(); /** * Last advanced cache file content * * @var string */ public $advanced_cache_file_content; /** * Store the latest advanced-cache.php version required * * @var string */ private $_minimum_advanced_cache_file_version = '3.0.17'; /** * Set everything up here */ public function __construct() { $this->config = WPO_Cache_Config::instance(); $this->rules = WPO_Cache_Rules::instance(); $this->logger = new Updraft_PHP_Logger(); add_action('activate_plugin', array($this, 'activate_deactivate_plugin')); add_action('deactivate_plugin', array($this, 'activate_deactivate_plugin')); /** * Regenerate config file on cache flush. */ add_action('wpo_cache_flush', array($this, 'update_cache_config')); add_action('wpo_cache_flush', array($this, 'delete_cache_size_information')); // Add purge cache link to admin bar. add_filter('wpo_cache_admin_bar_menu_items', array($this, 'admin_bar_purge_cache'), 20, 1); // Handle single page purge. add_action('wp_loaded', array($this, 'handle_purge_single_page_cache')); add_action('admin_init', array($this, 'admin_init')); $this->check_compatibility_issues(); } /** * Do required actions on activate/deactivate any plugin. */ public function activate_deactivate_plugin() { $this->update_cache_config(); /** * Filters whether activating / deactivating a plugin will purge the cache. */ if (apply_filters('wpo_purge_page_cache_on_activate_deactivate_plugin', true)) { $this->purge(); } } /** * Check if current user can purge cache. * * @return bool */ public function can_purge_cache() { if (is_multisite()) return $this->is_enabled() && (current_user_can('manage_network_options') || WP_Optimize()->can_purge_the_cache()); return $this->is_enabled() && (current_user_can('manage_options') || WP_Optimize()->can_purge_the_cache()); } /** * Add Purge from cache in admin bar. * * @param array $menu_items * @return array */ public function admin_bar_purge_cache($menu_items) { global $pagenow; if (!$this->can_purge_cache()) return $menu_items; $act_url = remove_query_arg(array('wpo_single_page_cache_purged', 'wpo_all_pages_cache_purged')); $cache_size = $this->get_cache_size(); $cache_size_info = '
'.__('WP-Optimize:', 'wp-optimize').' '.__('Please disable the feature "Gzip compression" in PageSpeed Ninja to prevent conflicts.', 'wp-optimize').'
'.__('WP-Optimize:', 'wp-optimize').' '.__('Please disable the feature "Gzip compression" in Far Future Expiration to prevent conflicts.', 'wp-optimize').'