mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-30 23:39:42 +01:00
93a75784b7
The theme supports WordPress 4.7 or later, while the polyfill for `str_contains()` only exists in WordPress 5.9 or later. Follow-up to [55988], [57275]. Props poena. See #60241. Built from https://develop.svn.wordpress.org/trunk@57276 git-svn-id: http://core.svn.wordpress.org/trunk@56782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
61 lines
2.2 KiB
PHP
61 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* A template partial to output pagination for the Twenty Twenty default theme.
|
|
*
|
|
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Twenty_Twenty
|
|
* @since Twenty Twenty 1.0
|
|
*/
|
|
|
|
$prev_text = sprintf(
|
|
'%s <span class="nav-prev-text">%s</span>',
|
|
'<span aria-hidden="true">←</span>',
|
|
/*
|
|
* Translators: This text contains HTML to allow the text to be shorter on small screens.
|
|
* The text inside the span with the class nav-short will be hidden on small screens.
|
|
*/
|
|
__( 'Newer <span class="nav-short">Posts</span>', 'twentytwenty' )
|
|
);
|
|
$next_text = sprintf(
|
|
'<span class="nav-next-text">%s</span> %s',
|
|
/*
|
|
* Translators: This text contains HTML to allow the text to be shorter on small screens.
|
|
* The text inside the span with the class nav-short will be hidden on small screens.
|
|
*/
|
|
__( 'Older <span class="nav-short">Posts</span>', 'twentytwenty' ),
|
|
'<span aria-hidden="true">→</span>'
|
|
);
|
|
|
|
$posts_pagination = get_the_posts_pagination(
|
|
array(
|
|
'mid_size' => 1,
|
|
'prev_text' => $prev_text,
|
|
'next_text' => $next_text,
|
|
)
|
|
);
|
|
|
|
// If we're not outputting the previous page link, prepend a placeholder with `visibility: hidden` to take its place.
|
|
if ( false === strpos( $posts_pagination, 'prev page-numbers' ) ) {
|
|
$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 );
|
|
}
|
|
|
|
// If we're not outputting the next page link, append a placeholder with `visibility: hidden` to take its place.
|
|
if ( false === strpos( $posts_pagination, 'next page-numbers' ) ) {
|
|
$posts_pagination = str_replace( '</div>', '<span class="next page-numbers placeholder" aria-hidden="true">' . $next_text . '</span></div>', $posts_pagination );
|
|
}
|
|
|
|
if ( $posts_pagination ) { ?>
|
|
|
|
<div class="pagination-wrapper section-inner">
|
|
|
|
<hr class="styled-separator pagination-separator is-style-wide" aria-hidden="true" />
|
|
|
|
<?php echo $posts_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?>
|
|
|
|
</div><!-- .pagination-wrapper -->
|
|
|
|
<?php
|
|
}
|