Automattic\WooCommerce\Blocks\BlockTypes

ProductResultsCount::render │ protected │ WC 1.0

Render the block.

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

Хуков нет.

Возвращает

string. Rendered block output.

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

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

Код ProductResultsCount::render() WC 11.3.0

protected function render( $attributes, $content, $block ) {
	// Buffer the result count and use it as the block's frontend content.
	ob_start();
	woocommerce_result_count();
	$product_results_count = ob_get_clean();

	$classes = 'woocommerce wc-block-product-results-count';
	if ( ! empty( $attributes['fontSize'] ) ) {
		// Preserve the legacy class for backward compatibility.
		$classes .= ' has-font-size';
	}

	$wrapper_attributes = get_block_wrapper_attributes(
		array(
			'class'                 => $classes,
			'data-wp-interactive'   => $this->get_full_block_name(),
			'data-wp-router-region' => 'wc-product-results-count-' . ( $block->context['queryId'] ?? 0 ),
		)
	);

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