<?php
defined( 'ABSPATH' ) || exit;
get_header(); ?>

<script src=""></script>

<div class="shop-breadcrumbs">
  <?php woocommerce_breadcrumb(); ?>
</div>

<div class="shop-layout">
  <aside class="shop-sidebar">
    <?php
        dynamic_sidebar( 'shop-filters' );
    ?>
  </aside>

  <main class="shop-products">
    <header class="shop-products__header">
        <div class="shop-products__header-title">Wszystkie produkty</div> 
        <div class="shop-products__sort">
            <?php woocommerce_catalog_ordering(); ?>
        </div>
    </header>

    <?php if ( woocommerce_product_loop() ) : ?>
      <?php woocommerce_product_loop_start(); ?>

        <?php while ( have_posts() ) : the_post(); ?>
          <?php wc_get_template_part( 'content', 'product' ); ?>
        <?php endwhile; ?>

      <?php woocommerce_product_loop_end(); ?>


      <?php
        global $wp_query;

        $big = 999999999;
        $pagination = paginate_links( array(
          'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
          'format'    => '?paged=%#%',
          'current'   => max( 1, get_query_var('paged') ),
          'total'     => $wp_query->max_num_pages,
          'prev_text' => '&lt; Poprzednia strona',
          'next_text' => 'Następna strona &gt;',
          'type'      => 'array',    
          'end_size'  => 2,
          'mid_size'  => 1,
        ) );

        if ( is_array( $pagination ) ) : ?>
          <nav class="shop-pagination">
            <ul class="custom-pagination">
              <?php foreach ( $pagination as $page ) : ?>
                <li class="<?php echo ( strpos( $page, 'current' ) !== false ) ? 'active' : ''; ?>">
                  <?php echo $page; ?>
                </li>
              <?php endforeach; ?>
            </ul>
          </nav>
      <?php endif; ?>

    <?php else : ?>
      <?php wc_no_products_found(); ?>
    <?php endif; ?>
  </main>
</div>

<?php get_footer(); ?>
