WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Blocks_Utils::has_block_in_page() public WC 1.0

Check if a given page contains a particular block.

{} Это метод класса: WC_Blocks_Utils{}

Хуков нет.


true|false. Boolean value if the page contains the block or not. Null in case the page does not exist.


$result = WC_Blocks_Utils::has_block_in_page( $page, $block_name );
$page(int|WP_Post) (обязательный)
Page post ID or post object.
$block_name(строка) (обязательный)
The name (id) of a block, e.g. woocommerce/cart.

Код WC_Blocks_Utils::has_block_in_page() WC 5.6.0

public static function has_block_in_page( $page, $block_name ) {
	$page_to_check = get_post( $page );
	if ( null === $page_to_check ) {
		return false;

	$blocks = parse_blocks( $page_to_check->post_content );
	foreach ( $blocks as $block ) {
		if ( $block_name === $block['blockName'] ) {
			return true;

	return false;