<?php
/**
 * A template partial to output pagination markup.
 */

/**
 * Translators:
 * This text contains HTML to allow the text to be shorter on small screens.
 * The text inside the span with the class uk-visible@m will be hidden on small screens.
 */

$prev_text = sprintf(
	'%s <span class="nav-prev-text">%s <span class="uk-visible@m">%s</span></span>',
	'<span aria-hidden="true">&larr;</span>', __( 'Newer', 'eisai' ), __( 'posts', 'eisai' )
);
$next_text = sprintf(
	'<span class="nav-next-text">%s <span class="uk-visible@m">%s</span></span> %s',
	__( 'Older', 'eisai' ),
	__( 'posts', 'eisai' ),
	'<span aria-hidden="true">&rarr;</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 uk-link-text" data-uk-scrollspy="cls: uk-animation-fade" style="visibility: hidden;">
		<div class="uk-container">
			<?php echo $posts_pagination; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?>
		</div>
	</div> <!-- .pagination-wrapper -->

	<?php
}
