Açıklama Yok

pagination.php 2.2KB

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