Automattic\WooCommerce\Blocks
BlockPatterns::register_ptk_patterns()
Register patterns from the Patterns Toolkit.
Method of the class: BlockPatterns{}
No Hooks.
Return
null
. Nothing (null).
Usage
$BlockPatterns = new BlockPatterns(); $BlockPatterns->register_ptk_patterns();
BlockPatterns::register_ptk_patterns() BlockPatterns::register ptk patterns code WC 9.4.2
public function register_ptk_patterns() { // Only if the user has allowed tracking, we register the patterns from the PTK. $allow_tracking = 'yes' === get_option( 'woocommerce_allow_tracking' ); if ( ! $allow_tracking ) { return; } // The most efficient way to check for an existing action is to use `as_has_scheduled_action`, but in unusual // cases where another plugin has loaded a very old version of Action Scheduler, it may not be available to us. $has_scheduled_action = function_exists( 'as_has_scheduled_action' ) ? 'as_has_scheduled_action' : 'as_next_scheduled_action'; $patterns = $this->ptk_patterns_store->get_patterns(); if ( empty( $patterns ) ) { // By only logging when patterns are empty and no fetch is scheduled, // we ensure that warnings are only generated in genuinely problematic situations, // such as when the pattern fetching mechanism has failed entirely. if ( ! call_user_func( $has_scheduled_action, 'fetch_patterns' ) ) { wc_get_logger()->warning( __( 'Empty patterns received from the PTK Pattern Store', 'woocommerce' ), ); } return; } $patterns = $this->parse_categories( $patterns ); foreach ( $patterns as $pattern ) { $pattern['slug'] = $pattern['name']; $pattern['content'] = $pattern['html']; $this->pattern_registry->register_block_pattern( $pattern['ID'], $pattern, $this->get_patterns_dictionary() ); } }