woocommerce_should_register_blocks │ filter-hook │ WC 11.1.0

Filters whether WooCommerce should register its block types and patterns for the current request.

Registration is skipped on known non-rendering contexts (the Store API and other WooCommerce REST namespaces, cron, AJAX, XML-RPC, favicon, robots.txt and XML sitemaps) as a performance optimisation. Product and variation descriptions rendered through do_blocks and emails rendered by the email editor are already handled on demand (see the woocommerce_short_description and woocommerce_email_editor_render_start hooks in Bootstrap), so this filter is only needed to opt back in when an extension renders WooCommerce blocks some other way in one of those contexts.

Usage

add_filter( 'woocommerce_should_register_blocks', 'wp_kama_woocommerce_should_register_blocks_filter' );

/**
 * Function for `woocommerce_should_register_blocks` filter-hook.
 * 
 * @param bool $should_register Whether block types and patterns should be registered for this
 *                              request.
 *
 * @return bool
 */
function wp_kama_woocommerce_should_register_blocks_filter( $should_register ){
	// filter...
	return $should_register;
}
$should_register(true|false)
Whether block types and patterns should be registered for this request.

Changelog

Since 11.1.0 Introduced.

Where the hook is called

BlockRegistrationContext::should_register()
woocommerce_should_register_blocks
woocommerce/src/Blocks/Domain/BlockRegistrationContext.php 42
return (bool) apply_filters( 'woocommerce_should_register_blocks', $this->is_rendering_request() );

Where the hook is used in WooCommerce

Usage not found.