[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwenty/template-parts/ -> pagination.php (source)

   1  <?php
   2  /**
   3   * A template partial to output pagination for the Twenty Twenty default theme.
   4   *
   5   * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
   6   *
   7   * @package WordPress
   8   * @subpackage Twenty_Twenty
   9   * @since Twenty Twenty 1.0
  10   */
  11  
  12  $prev_text = sprintf(
  13      '%s <span class="nav-prev-text">%s</span>',
  14      '<span aria-hidden="true">&larr;</span>',
  15      /*
  16       * Translators: This text contains HTML to allow the text to be shorter on small screens.
  17       * The text inside the span with the class nav-short will be hidden on small screens.
  18       */
  19      __( 'Newer <span class="nav-short">Posts</span>', 'twentytwenty' )
  20  );
  21  $next_text = sprintf(
  22      '<span class="nav-next-text">%s</span> %s',
  23      /*
  24       * Translators: This text contains HTML to allow the text to be shorter on small screens.
  25       * The text inside the span with the class nav-short will be hidden on small screens.
  26       */
  27      __( 'Older <span class="nav-short">Posts</span>', 'twentytwenty' ),
  28      '<span aria-hidden="true">&rarr;</span>'
  29  );
  30  
  31  $posts_pagination = get_the_posts_pagination(
  32      array(
  33          'mid_size'  => 1,
  34          'prev_text' => $prev_text,
  35          'next_text' => $next_text,
  36      )
  37  );
  38  
  39  // If we're not outputting the previous page link, prepend a placeholder with `visibility: hidden` to take its place.
  40  if ( false === strpos( $posts_pagination, 'prev page-numbers' ) ) {
  41      $posts_pagination = str_replace( '<div class="nav-links">', '<div class="nav-links"><span class="prev page-numbers placeholder" aria-hidden="true">' . $prev_text . '</span>', $posts_pagination );
  42  }
  43  
  44  // If we're not outputting the next page link, append a placeholder with `visibility: hidden` to take its place.
  45  if ( false === strpos( $posts_pagination, 'next page-numbers' ) ) {
  46      $posts_pagination = str_replace( '</div>', '<span class="next page-numbers placeholder" aria-hidden="true">' . $next_text . '</span></div>', $posts_pagination );
  47  }
  48  
  49  if ( $posts_pagination ) { ?>
  50  
  51      <div class="pagination-wrapper section-inner">
  52  
  53          <hr class="styled-separator pagination-separator is-style-wide" aria-hidden="true" />
  54  
  55          <?php echo $posts_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?>
  56  
  57      </div><!-- .pagination-wrapper -->
  58  
  59      <?php
  60  }


Generated : Wed Dec 18 08:20:01 2024 Cross-referenced by PHPXref