<?php
/**
 * Pagination - Show numbered pagination for catalog pages
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/loop/pagination.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://woocommerce.com/document/template-structure/
 * @package WooCommerce\Templates
 * @version 9.3.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$multimagazine_total   = isset( $multimagazine_total ) ? $multimagazine_total : wc_get_loop_prop( 'total_pages' );
$multimagazine_current = isset( $multimagazine_current ) ? $multimagazine_current : wc_get_loop_prop( 'current_page' );
$multimagazine_base    = isset( $multimagazine_base ) ? $multimagazine_base : esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) );
$multimagazine_format  = isset( $multimagazine_format ) ? $multimagazine_format : '';

if ( $multimagazine_total <= 1 ) {
	return;
}

$pagination_classes = 'navigation pagination';
if ( get_theme_mod( 'multi_pagination_style', MULTIMAGAZINE_PAGINATION_STYLE ) === 'modern' ) {
	$pagination_classes .= ' pagination-modern';
}
if ( get_theme_mod( 'pagination_dot_border_position', MULTIMAGAZINE_PAGINATION_DOT_BORDER_POSITION ) === 'outside' ) {
	$pagination_classes .= ' pagination-outside';
}
?>
<div class="<?php echo esc_attr( $pagination_classes ); ?>">
	<?php
	echo wp_kses_post(
		paginate_links(
			apply_filters(
				'woocommerce_pagination_args',
				array( // phpcs:ignore Standard.Category.SniffName.ErrorCode
					'base'      => $multimagazine_base,
					'format'    => $multimagazine_format,
					'add_args'  => false,
					'current'   => max( 1, $multimagazine_current ),
					'total'     => $multimagazine_total,
					'prev_text' => '<i class="pagination-icon m-icon m-icon-long-arrow-left" aria-hidden="true"></i>' . __( 'Previous', 'multimagazine' ),
					'next_text' => __( 'Next', 'multimagazine' ) . '<i class="pagination-icon m-icon m-icon-long-arrow-right" aria-hidden="true"></i>',
					'end_size'  => 3,
					'mid_size'  => 3,
				)
			)
		)
	);
	?>
</div>
