<?php
/*
Theme Designed By: Meysam Hosseinkhani
Email: Meysam98@Gmail.com
Author Website: Hosseinkhani.ir
*/
   // Exit if accessed directly
   if (!defined('ABSPATH')) {
    exit; 
       global $az_data;
} ?>

<?php $store_page_setting = (is_front_page() && is_page_template('front-page.php') ? 'page' : 'paged' );
   $current_page = get_query_var($store_page_setting);
         $per_page = get_option('posts_per_page');
         $offset = $current_page > 0 ? $per_page * ($current_page-1) : 0;
        if($az_data['main_type_post'] || get_option( 'show_on_front' ) == 'page'){
         $product_args = array(
            'post_type' => 'post',
            'posts_per_page' => $per_page,
            'offset' => $offset
         );
        } else {
            if (az_woo()) {
                $product_args = array(
                    'post_type' => 'product',
                    'posts_per_page' => $per_page,
                    'offset' => $offset
                );
            }
            else{
                $product_args = array(
                    'post_type' => 'download',
                    'posts_per_page' => $per_page,
                    'offset' => $offset
                );
            }
        }
   $products = new WP_Query( $product_args );
   get_header();?>

<div class="container-fluid main-con">
    <main class="container">

    <?php azin_bread() ?>

    <?php if (is_front_page() && $wp_query->get('paged') < 2) {
        if ($az_data['show_head_banner']) { ?>
                <div class="head-con hovers<?php if (!$az_data['show_head_mobile']) { echo ' hidden-xs'; }?>">
                    <a href="<?php echo $az_data['head_banner_link']; ?>" aria-label="<?php echo $az_data['head_banner_title']; ?>">
                        <figure>
                        <img src="<?php echo $az_data['head_banner']['url']; ?>" alt="<?php echo $az_data['head_banner_title']; ?>" class="head-banner" /></figure>
                    </a>
                </div>
    <?php } } ?>
        
<div class="row main<?php side_type(); ?>" id="main" <?php if ($az_data['site_schema']) { ?>itemscope itemtype="https://schema.org/Blog" <?php } ?>>

<div class="col-lg-9 col-12<?php if ($az_data['side_type'] == 2) { echo ' right-side'; } if ($az_data['sticky_side']) { echo ' pcol'; }?>">
    
    <?php if( is_front_page() && $wp_query->get( 'paged' ) < 2 ) { if ($az_data['show_slider']) { ?>
        <!-- start slider --> 
        <?php require_once AZ_DIR .'/includes/slider.php'; ?>
        <!-- end slider -->
    <?php } } ?>

    <?php if( is_front_page() && $wp_query->get( 'paged' ) < 2 ) { if ($az_data['show_services'] && $az_data['show_services_main']) { ?>
        <!-- start services -->
        <?php require_once AZ_DIR .'/includes/services.php'; ?>
        <!-- end services -->
    <?php  }  } ?>

    <?php if( is_front_page() && $wp_query->get( 'paged' ) < 2 ) { if ($az_data['show_special']) { ?>
    <!-- start special-box -->
    <?php if (az_woo()) {
	    require_once AZ_DIR .'/includes/woo/special-box.php';
    } else {
        require_once AZ_DIR .'/includes/special-box.php';
    } ?>
    <!-- end special-box -->
    <?php  }  } ?>

    <?php if ( is_front_page() && $az_data['show_most_viewed'] && $wp_query->get( 'paged' ) < 2) { ?>
    <!-- start most viewed -->
    <?php if (az_woo()) {
	    require_once AZ_DIR .'/includes/woo/most-viewed.php';
    } else {
        require_once AZ_DIR .'/includes/most-viewed.php';
    } ?>
    <!-- end most viewed -->
    <?php } ?>

    <?php if( is_front_page() && $wp_query->get( 'paged' ) < 2 ) { if ($az_data['show_ads_banner1']) { ?>
        <!-- start ads banner #1 -->
        <?php require_once AZ_DIR .'/includes/ads-banner.php'; ?>
        <!-- end ads banner #1 -->
    <?php } } ?>

    <?php if (!$az_data['show_blocks']) { ?>
    <!-- start products -->
    <div class="row">
        <?php if($az_data['main_type_post'] || get_option( 'show_on_front' ) == 'page') { ?>
        <?php require_once AZ_DIR .'/includes/posts.php'; ?>
        <?php } else { ?>
        <?php if (az_woo()) { ?>
        <?php require_once AZ_DIR .'/includes/woo/products.php'; ?>
        <?php } else { ?>
        <?php require_once AZ_DIR .'/includes/products.php'; ?>
        <?php } } ?>
    </div>
    <!-- end products -->

    <?php } else {
        if (az_woo()) {
            require_once AZ_DIR .'/includes/woo/blocks.php';             
        } else {
            require_once AZ_DIR .'/includes/blocks.php';             
        }
    } ?>

    <?php if( is_front_page() && $wp_query->get( 'paged' ) < 2 ) { if ($az_data['show_ads_banner2']) { ?>
        <!-- start ads banner #2 -->
        <?php require_once AZ_DIR .'/includes/ads-banner-t.php'; ?>
        <!-- end ads banner #2 -->
    <?php }  } ?>

    <?php if ($az_data['show_main_blog'] && !$az_data['main_type_post'] && is_front_page() && $wp_query->get( 'paged' ) < 2) { ?>
        <!-- start main blog -->
        <?php require_once AZ_DIR .'/includes/main-blog.php'; ?>
        <!-- end main blog -->
    <?php } ?>
    
    <?php if (is_front_page() && $az_data['show_prod_block'] && $az_data['main_type_post'] && $wp_query->get( 'paged' ) < 2) { ?>
    <!-- start prod block -->
    <?php if (az_woo()) { ?>
        <?php require_once AZ_DIR .'/includes/woo/prod-block.php'; ?>
    <?php } else { ?>
        <?php require_once AZ_DIR .'/includes/prod-block.php'; ?>
    <?php } ?>
    <!-- end prod block -->
    <?php } ?>
    
    <!-- start foot banner -->
    <?php if( is_front_page() && $wp_query->get( 'paged' ) < 2 ) {
         if ($az_data['show_foot_banner']) { ?>
    <div class="row">
        <div class="col-12 foot-con hovers">
            <a href="<?php echo $az_data['foot_banner_link']; ?>" aria-label="<?php echo $az_data['foot_banner_title']; ?>">
                <figure><img src="<?php echo $az_data['foot_banner']['url']; ?>" alt="<?php echo $az_data['foot_banner_title']; ?>" class="foot-banner" /></figure>
            </a>
        </div>
    </div>
    <?php } } ?>
    <!-- end foot banner -->
</div>

<aside class="col-lg-3 side-bar<?php if (!$az_data['show_side_mobile']) {echo ' hidden-sm hidden-xs';} if ($az_data['sticky_side']) { echo ' side-sticky'; }?>">
    <?php get_template_part('right-sidebar'); ?>
</aside>

</div>
</main>
</div>

<?php get_footer();