Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
NoResults::render
Render the block.
Метод класса: NoResults{}
Хуков нет.
Возвращает
Строку. | void Rendered block output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Block attributes.
- $content(строка) (обязательный)
- Block content.
- $block(WP_Block) (обязательный)
- Block instance.
Код NoResults::render() NoResults::render WC 10.5.2
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
);
}