Automattic\WooCommerce\Blocks\BlockTypes\Reviews
ProductReviewsTitle::render
Render the block.
Method of the class: ProductReviewsTitle{}
No Hooks.
Returns
String. Rendered block content.
Usage
// protected - for code of main (parent) or child class $result = $this->render( $attributes, $content, $block );
- $attributes(array) (required)
- Block attributes.
- $content(string) (required)
- Block content.
- $block(WP_Block) (required)
- Block instance.
ProductReviewsTitle::render() ProductReviewsTitle::render code WC 10.6.2
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
);
}