Automattic\WooCommerce\Blocks\Patterns
PTKPatternsStore::flush_cached_patterns
Reset the cached patterns to fetch them again from the PTK.
Method of the class: PTKPatternsStore{}
No Hooks.
Returns
null. Nothing (null).
Usage
$PTKPatternsStore = new PTKPatternsStore(); $PTKPatternsStore->flush_cached_patterns();
Changelog
| Since 10.4.1 | Introduced. |
| Since 10.4.1 | Unscheduling is deferred if Action Scheduler hasn't initialized yet. |
PTKPatternsStore::flush_cached_patterns() PTKPatternsStore::flush cached patterns code WC 10.7.0
public function flush_cached_patterns() {
delete_option( self::OPTION_NAME );
if ( ! function_exists( 'as_unschedule_all_actions' ) ) {
return;
}
// Unschedule any existing fetch_patterns actions.
// Defer unscheduling until Action Scheduler is ready to avoid errors during early initialization.
if ( did_action( 'action_scheduler_init' ) ) {
as_unschedule_all_actions( self::FETCH_PATTERNS_ACTION, array(), 'woocommerce' );
} else {
add_action(
'action_scheduler_init',
function () {
as_unschedule_all_actions( self::FETCH_PATTERNS_ACTION, array(), 'woocommerce' );
}
);
}
}