Automattic\WooCommerce\Blocks\BlockTypes

ProductCollectionNoResults::render()protectedWC 1.0

Render the block.

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

Хуков нет.

Возвращает

Строку. | void Rendered block output.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render( $attributes, $content, $block );
$attributes(массив) (обязательный)
Block attributes.
$content(строка) (обязательный)
Block content.
$block(WP_Block) (обязательный)
Block instance.

Код ProductCollectionNoResults::render() WC 9.5.1

protected function render( $attributes, $content, $block ) {
	$content = trim( $content );
	if ( empty( $content ) ) {
		return '';
	}

	$query = ProductCollectionUtils::prepare_and_execute_query( $block );

	// If the query has products, don't render the block.
	if ( $query->post_count > 0 ) {
		return '';
	}

	// Update the anchor tag URLs.
	$updated_html_content = $this->modify_anchor_tag_urls( trim( $content ) );

	$wrapper_attributes = get_block_wrapper_attributes();
	return sprintf(
		'<div %1$s>%2$s</div>',
		$wrapper_attributes,
		$updated_html_content
	);
}