Automattic\WooCommerce\Blocks\BlockTypes\Reviews

ProductReviewsTitle::render │ protected │ WC 1.0

Render the block.

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

Хуков нет.

Возвращает

string. Rendered block content.

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

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

Код ProductReviewsTitle::render() WC 11.3.0

protected function render( $attributes, $content, $block ) {
	if ( post_password_required() ) {
		return;
	}
	$post_id = $block->context['postId'];
	$product = wc_get_product( $post_id );

	if ( ! $product ) {
		return '';
	}

	$align_class_name   = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
	$reviews_count      = $product->get_review_count();
	$tag_name           = 'h2';
	if ( isset( $attributes['level'] ) ) {
		$tag_name = 'h' . $attributes['level'];
	}

	$reviews_title = $this->get_reviews_title( $attributes, $product );

	return sprintf(
		'<%1$s id="reviews" %2$s>%3$s</%1$s>',
		$tag_name,
		$wrapper_attributes,
		$reviews_title
	);
}