get_comments_pagination_arrow

函数
get_comments_pagination_arrow ( $block, $pagination_type = 'next' )
参数
  • (WP_Block) $block Block instance.
    Required:
  • (string) $pagination_type Optional. Type of the arrow we will be rendering. Accepts 'next' or 'previous'. Default 'next'.
    Required:
    Default: 'next'
返回值
  • (string|null) The pagination arrow HTML or null if there is none.
定义位置
相关方法
get_the_comments_paginationthe_comments_paginationget_query_pagination_arrowget_the_comments_navigationget_the_posts_pagination
引入
6.0.0
弃用
-

get_comments_pagination_arrow: 这个函数用来生成特定页面的评论分页箭头的HTML。

帮助函数,根据`CommentsPagination`上下文提供的`paginationArrow`,为`CommentsPaginationNext`和`CommentsPaginationPrevious`区块返回适当的分页箭头HTML。

它被用于CommentsPaginationNext和CommentsPaginationPrevious区块中。

function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) {
	$arrow_map = array(
		'none'    => '',
		'arrow'   => array(
			'next'     => '→',
			'previous' => '←',
		),
		'chevron' => array(
			'next'     => '»',
			'previous' => '«',
		),
	);
	if ( ! empty( $block->context['comments/paginationArrow'] ) && ! empty( $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ] ) ) {
		$arrow_attribute = $block->context['comments/paginationArrow'];
		$arrow           = $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ];
		$arrow_classes   = "wp-block-comments-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
		return "<span class='$arrow_classes' aria-hidden='true'>$arrow</span>";
	}
	return null;
}

常见问题

FAQs
查看更多 >