get_comments_pagination_arrow() – Helper function that returns the proper pagination arrow HTML for `CommentsPaginationNext` and `CommentsPaginationPrevious` blocks based on the provided `paginationArrow` from `CommentsPagination` context.

You appear to be a bot. Output may be restricted

Description

Helper function that returns the proper pagination arrow HTML for CommentsPaginationNext and CommentsPaginationPrevious blocks based on the provided paginationArrow from CommentsPagination context.

It's used in CommentsPaginationNext and CommentsPaginationPrevious blocks.

Usage

$string|null = get_comments_pagination_arrow( $block, $pagination_type );

Parameters

$block
( WP_Block ) required – Block instance.
$pagination_type
( string ) optional default: next – Type of the arrow we will be rendering. Default 'next'. Accepts 'next' or 'previous'.

Returns

string|null The pagination arrow HTML or null if there is none.

Source

File name: wordpress/wp-includes/blocks.php


Lines:

1 to 21 of 21
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'>$arrow</span>";
  }
  return null;
}
 

 View on GitHub View on Trac