/** * Disables Other Caching Plugins if SG SuperCacher is enabled */ function disable_other_caching_plugins() { $sg_cachepress_options = new SG_CachePress_Options(); if ($sg_cachepress_options->is_enabled('enable_cache')) { add_filter('do_rocket_generate_caching_files', '__return_false'); } }
/** * Updates a param from ajax request * * @since 1.1.0 */ public function update_parameter() { $paramTranslator = array('dynamic-cache' => 'enable_cache', 'memcached' => 'enable_memcached', 'autoflush-cache' => 'autoflush_cache'); $paramName = $paramTranslator[$_POST['parameterName']]; $currentValue = (int) $this->options_handler->get_option($paramName); $toggledValue = (int) (!$currentValue); //if cache is turned on or off it's a good idea to flush it on right away if ($paramName == 'enable_cache') { SG_CachePress_Supercacher::purge_cache(); } if ($paramName == 'enable_memcached') { global $sg_cachepress_memcache; //check if we can actually enable memcached and display error if not if ($toggledValue == 1) { if (!$sg_cachepress_memcache->check_and_create_memcached_dropin()) { die("Please, first enable Memcached from your cPanel!"); } } else { if (!$sg_cachepress_memcache->remove_memcached_dropin()) { die("Could not disable memcache!"); } } } if ($this->options_handler->update_option($paramName, $toggledValue)) { if ($paramName == 'enable_cache' && $toggledValue == 1) { SG_CachePress::check_if_plugin_caches(); } else { if ($paramName == 'enable_cache' && $toggledValue == 0) { $sg_cachepress_options = new SG_CachePress_Options(); $sg_cachepress_options->disable_option('show_notice'); } } die((string) $toggledValue); } else { die((string) $currentValue); } }
/** * Fired for each blog when the plugin is deactivated. * * @since 1.1.0 */ private static function single_deactivate() { // TODO: Define deactivation functionality here? $sg_cachepress_options = new SG_CachePress_Options(); $sg_cachepress_options->disable_option('show_notice'); }
/** * Fired for each blog when the plugin is activated. * * @since 1.1.0 */ private static function single_activate() { $sg_cachepress_options = new SG_CachePress_Options(); $sg_cachepress = new SG_CachePress($sg_cachepress_options); if (!$sg_cachepress_options->get_option()) { $sg_cachepress_options->init_options(); } }