<?php
/**
 * Post list pagination
 *
 * @package Multi
 */

?>
<?php
$multimagazine_args = wp_parse_args( $args );

if ( get_theme_mod( 'multi_load_postlist', MULTIMAGAZINE_LOAD_POSTLIST ) === 'button' ) {
	$multimagazine_load_button = true;
	if ( $multimagazine_args['postlist']->max_num_pages > get_query_var( 'paged' ) ) :
		?>
		<p class="load-button"><a href="#" class="button load-more-posts"><?php esc_html_e( 'Load more posts', 'multimagazine' ); ?></a></p>
		<?php
	endif;
}

$multimagazine_nav_classes = 'navigation pagination';
if ( get_theme_mod( 'multi_pagination_style', MULTIMAGAZINE_PAGINATION_STYLE ) === 'modern' ) {
	$multimagazine_nav_classes .= ' pagination-modern';
}
if ( get_theme_mod( 'pagination_dot_border_position', MULTIMAGAZINE_PAGINATION_DOT_BORDER_POSITION ) === 'outside' ) {
	$multimagazine_nav_classes .= ' pagination-outside';
}
if ( isset( $multimagazine_load_button ) ) {
	$multimagazine_nav_classes .= ' hide';
}
?>
<nav class="<?php echo esc_attr( $multimagazine_nav_classes ); ?>" aria-label="<?php esc_attr_e( 'Post list pagination', 'multimagazine' ); ?>">
	<?php
	global $wp_query;
	echo wp_kses_post(
		paginate_links(
			array(
				'base'      => get_pagenum_link( 1 ) . '%_%',
				'format'    => get_option( 'permalink_structure' ) ? '/page/%#%/' : '&paged=%#%',
				'current'   => $multimagazine_args['page-number'],
				'total'     => $multimagazine_args['postlist']->max_num_pages,
				'prev_text' => '<i class="pagination-icon m-icon m-icon-long-arrow-left"></i>' . __( 'Previous', 'multimagazine' ),
				'next_text' => __( 'Next', 'multimagazine' ) . '<i class="pagination-icon m-icon m-icon-long-arrow-right"></i>',
			)
		)
	);
	?>
</nav>
