[ Index ]

PHP Cross Reference of WordPress

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  /**
  13   * Translators:
  14   * This text contains HTML to allow the text to be shorter on small screens.
  15   * The text inside the span with the class nav-short will be hidden on small screens.
  16   */
  17  
  18  $prev_text = sprintf(
  19      '%s <span class="nav-prev-text">%s</span>',
  20      '<span aria-hidden="true">&larr;</span>',
  21      __( 'Newer <span class="nav-short">Posts</span>', 'twentytwenty' )
  22  );
  23  $next_text = sprintf(
  24      '<span class="nav-next-text">%s</span> %s',
  25      __( 'Older <span class="nav-short">Posts</span>', 'twentytwenty' ),
  26      '<span aria-hidden="true">&rarr;</span>'
  27  );
  28  
  29  $posts_pagination = get_the_posts_pagination(
  30      array(
  31          'mid_size'  => 1,
  32          'prev_text' => $prev_text,
  33          'next_text' => $next_text,
  34      )
  35  );
  36  
  37  // If we're not outputting the previous page link, prepend a placeholder with `visibility: hidden` to take its place.
  38  if ( strpos( $posts_pagination, 'prev page-numbers' ) === false ) {
  39      $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 );
  40  }
  41  
  42  // If we're not outputting the next page link, append a placeholder with `visibility: hidden` to take its place.
  43  if ( strpos( $posts_pagination, 'next page-numbers' ) === false ) {
  44      $posts_pagination = str_replace( '</div>', '<span class="next page-numbers placeholder" aria-hidden="true">' . $next_text . '</span></div>', $posts_pagination );
  45  }
  46  
  47  if ( $posts_pagination ) { ?>
  48  
  49      <div class="pagination-wrapper section-inner">
  50  
  51          <hr class="styled-separator pagination-separator is-style-wide" aria-hidden="true" />
  52  
  53          <?php echo $posts_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?>
  54  
  55      </div><!-- .pagination-wrapper -->
  56  
  57      <?php
  58  }


Generated: Sat Aug 8 01:00:03 2020 Cross-referenced by PHPXref 0.7.1