WC_REST_System_Status_V2_Controller::register_cache_clean()public staticWC 1.0

Register cache cleaner

Handles all the cache cleaning for this endpoint. We need to register these functions before the routes are registered, so this function gets called from Server.php

Метод класса: WC_REST_System_Status_V2_Controller{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WC_REST_System_Status_V2_Controller::register_cache_clean();

Код WC_REST_System_Status_V2_Controller::register_cache_clean() WC 8.7.0

public static function register_cache_clean() {
	// Clear the theme cache if we switch themes or our theme is upgraded.
	add_action( 'switch_theme', array( __CLASS__, 'clean_theme_cache' ) );
	add_action( 'activate_plugin', array( __CLASS__, 'clean_plugin_cache' ) );
	add_action( 'deactivate_plugin', array( __CLASS__, 'clean_plugin_cache' ) );
	add_action(
		'upgrader_process_complete',
		function( $upgrader, $extra ) {
			if ( ! $extra || ! $extra['type'] ) {
				return;
			}

			// Clear the cache if woocommerce is updated.
			if ( 'plugin' === $extra['type'] ) {
				\WC_REST_System_Status_V2_Controller::clean_theme_cache();
				\WC_REST_System_Status_V2_Controller::clean_plugin_cache();
				return;
			}

			if ( 'theme' === $extra['type'] ) {
				\WC_REST_System_Status_V2_Controller::clean_theme_cache();
				return;
			}
		},
		10,
		2
	);
}