Automattic\WooCommerce\Blocks\BlockTypes\Reviews

ProductReviewsPaginationNext::renderprotectedWC 1.0

Render the block.

Method of the class: ProductReviewsPaginationNext{}

No Hooks.

Returns

String. Rendered block type output.

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.

ProductReviewsPaginationNext::render() code WC 10.7.0

protected function render( $attributes, $content, $block ) {
	// Bail out early if the post ID is not set for some reason.
	if ( empty( $block->context['postId'] ) ) {
		return '';
	}

	$comment_vars     = build_comment_query_vars_from_block( $block );
	$max_page         = ( new \WP_Comment_Query( $comment_vars ) )->max_num_pages;
	$default_label    = __( 'Newer Reviews', 'woocommerce' );
	$label            = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
	$pagination_arrow = $this->get_pagination_arrow( $block );

	$filter_link_attributes = static function () {
		return get_block_wrapper_attributes();
	};
	add_filter( 'next_comments_link_attributes', $filter_link_attributes );

	if ( $pagination_arrow ) {
		$label .= $pagination_arrow;
	}

	$next_comments_link = get_next_comments_link( $label, $max_page, $comment_vars['paged'] ?? null );

	remove_filter( 'next_posts_link_attributes', $filter_link_attributes );

	if ( ! isset( $next_comments_link ) ) {
		return '';
	}
	return $next_comments_link;
}