WP_Super_Cache_Rest_Update_Settings::toggle_easy_caching()protectedWPSCache 1.0

Easy caching is a mode that allows the user to press one button and enable a sensible default of settings.

Method of the class: WP_Super_Cache_Rest_Update_Settings{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->toggle_easy_caching( $enabled );
$enabled(true|false)
-
Default: true

WP_Super_Cache_Rest_Update_Settings::toggle_easy_caching() code WPSCache 1.12.0

protected function toggle_easy_caching( $enabled = true ) {
	global $cache_path, $wp_cache_shutdown_gc, $cache_schedule_type;
	if ( $enabled ) {
		$settings = array(
			'wp_cache_mobile_enabled' => 1,
			'is_cache_enabled'        => 1,
			'cache_rebuild_files'     => 1,
			'cache_compression'       => 0,
			'wp_cache_not_logged_in'  => 2,
		);
		wp_cache_enable();
		if ( ! defined( 'DISABLE_SUPERCACHE' ) ) {
			wp_cache_debug( 'DISABLE_SUPERCACHE is not set, super_cache enabled.' );
			wp_super_cache_enable();
		}
		wpsc_set_default_gc();

	} else {
		wp_cache_disable();
		$settings = array( 'is_cache_enabled' => 0 );
		wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
		wp_clear_scheduled_hook( 'wp_cache_gc' );
		wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
	}

	foreach ( $settings as $key => $value ) {
		$this->set_value_by_key( $value, $key );
	}

	if ( $cache_path != WP_CONTENT_DIR . '/cache/' ) {
		$this->set_value_by_key( $cache_path, 'wp_cache_location' );
	}

	$advanced_settings = array(
		'wp_super_cache_late_init',
		'wp_cache_disable_utf8',
		'wp_cache_no_cache_for_get',
		'wp_supercache_304',
		'wp_cache_mfunc_enabled',
		'wp_cache_mobile_enabled',
		'wp_cache_front_page_checks',
		'wp_supercache_cache_list',
		'wp_cache_hello_world',
		'wp_cache_clear_on_post_edit',
		'wp_cache_make_known_anon',
		'wp_cache_object_cache',
		'wp_cache_refresh_single_only',
		'cache_compression',
		'wp_cache_mutex_disabled'
	);

	foreach ( $advanced_settings as $setting ) {
		$value = ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) ? 1 : 0;
		$this->set_value_by_key( $value, $setting );
	}
}