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

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

    <?php azin_bread(); ?>
        
      <div class="row main<?php side_type(); ?>" id="main" <?php if ($az_data['site_schema']) { ?>itemscope itemtype="https://schema.org/Blog" <?php } ?>>

<?php $type   = edd_single_price_option_mode( get_the_ID() ) ? 'checkbox' : 'radio';
	if ($type == 'radio') {
        remove_action( 'edd_purchase_link_top', 'edd_purchase_variable_pricing', 10, 1 );
        add_action( 'edd_purchase_link_top', 'shoestrap_edd_purchase_variable_pricing', 10, 1 );
    }
?>

<?php if($az_data['single_type'] == 1) { ?>

<div class="col-lg-9 col-12<?php if ($az_data['side_type'] == 2) { echo ' right-side'; } if ($az_data['sticky_side']) { echo ' pcol'; }?>">
    
    <!-- start head banner -->
    <?php if ($az_data['show_down_head_banner']) { ?>
    <div class="foot-con hovers">
        <a href="<?php echo $az_data['down_head_banner_link']; ?>" aria-label="<?php echo $az_data['down_head_banner_title']; ?>">
            <figure><img src="<?php echo $az_data['down_head_banner']['url']; ?>" alt="<?php echo $az_data['down_head_banner_title']; ?>" class="foot-banner" /></figure>
        </a>
    </div>
    <?php }?>
    <!-- end head banner -->

    <!-- start services -->
    <?php if ($az_data['show_services'] && $az_data['show_services_prod']) { require_once AZ_DIR .'/includes/services.php'; } ?>
    <!-- end services -->

    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post();?>
    <article <?php if($az_data['site_schema']) {?>itemscope itemtype="http://schema.org/Product"
        <?php } ?>>
        <?php if($az_data['site_schema']) {?>
        <link itemprop="mainEntityOfPage" href="<?php the_permalink(); ?>" />
        <meta itemprop="image" content="<?php the_post_thumbnail_url(); ?>">
        <?php } ?>
        <div role="main" class="scon" id="post-<?php the_ID(); ?>">
            <div class="s-product">
                <header class="post-row">
                    <div class="post-title">
                        <h1 <?php if($az_data['site_schema']) {?>itemprop="name"
                            <?php } ?>><i aria-hidden="true" class="fas fa-<?php $posticon = (rwmb_meta('file_p_type') != '' ? rwmb_meta('file_p_type') : 'download'); echo $posticon; ?>"></i>
                            <?php the_title(); ?>
                        </h1>
                        <div class="post-extra">
                            <?php if( function_exists("df_star_ratings") && ($az_data['star_rating']) ) { ?>
                            <div class="rating">
                                <?php echo df_star_ratings(get_the_ID()); ?>
                            </div>
                            <?php } ?>
                            <?php if ($az_data['social_share']) { ?>
                            <span tabindex="0" class="share-btn" data-toggle="modal" data-target="#shareModal"><i class="fas fa-share-alt"></i></span>
                            <?php } ?>
                            <?php if (rwmb_meta( 'file_pre' ) != '') { ?>
                            <a href="<?php echo rwmb_meta( 'file_pre' ); ?>" data-title="<?php echo $az_data['text_pre']; ?>" target="_blank">
                                <span class="pre-btn" data-toggle="tooltip" data-placement="top" title="<?php echo $az_data['text_pre']; ?>"><i class="fas fa-desktop"></i>
                                    <span class="pre-text hidden-sm hidden-xs">
                                        <?php echo $az_data['text_pre']; ?></span>
                                </span>
                            </a>
                            <?php } ?>
                            <?php 
                    //Wishlist BTN
                    /*
                    if ( function_exists( 'edd_wl_load_wish_list_link' ) ) {
                        echo '<span data-toggle="tooltip" data-placement="top" title="افزودن به علاقه مندیها">';
                        edd_wl_load_wish_list_link( get_the_ID() );
                        echo '</span>';
                    }*/
                    ?>
                        </div>
                    </div>
                </header>

                <?php if($az_data['square_thumb']) {
                    $prodimg = 'col-lg-5 col-md-6 col-12';
                    $proddet = 'col-lg-7 col-md-6 col-12 square_thumb';
                } else {
                    $prodimg = 'col-lg-7 col-md-8 col-12';
                    $proddet = 'col-lg-5 col-md-4 col-12 square_thumb';
                } ?>
                <div class="row product-details">
                    <div class="<?php echo $prodimg; ?> prod-img si-img">
                        <?php if(rwmb_meta( 'file_special' )) { ?>
                            <span class="special" aria-hidden="true">
                                <?php echo $az_data['text_special']; ?>
                            </span>
                        <?php } ?>
                        <?php
                        //File Preview
                        $file_pre = rwmb_meta( 'file_pre_type' );
                        $images = rwmb_meta( 'file_images', array( 'size' => 'single-download' ) );
                        $videos = rwmb_meta( 'file_video' );
                        $aparat = rwmb_meta( 'file_aparat' );
                        
                        if($file_pre == 'pre_aparat' && !empty($aparat))
                        {
                        echo '<div id="15305363563383534"><script type="text/JavaScript" src="https://www.aparat.com/embed/'.$aparat.'?data[rnddiv]=15305363563383534&data[responsive]=yes"></script></div>';
                        }
                        elseif($file_pre == 'pre_slides' && !empty($images))
                        {
                        ?>
                        <div id="sp-slider" class="slider-pro">
                            <div class="sp-slides">
                                <?php foreach ( $images as $image ) { ?>
                                <div class="sp-slide">
                                    <a href="<?php echo $image['full_url']; ?>" class="imgg" title="<?php the_title_attribute(); ?>">
                                        <img <?php if($az_data['site_schema']) {?> itemprop="image"<?php } ?> class="sp-image" src="<?php echo get_template_directory_uri(); ?>/images/blank.gif" data-src="<?php echo $image['full_url']; ?>" data-small="<?php echo $image['full_url']; ?>" data-medium="<?php echo $image['full_url']; ?>" data-large="<?php echo $image['full_url']; ?>" data-retina="<?php echo $image['full_url']; ?>" />
                                    </a>
                                </div>
                                <?php } ?>
                            </div>
                            <div class="sp-thumbnails">
                                <?php $images = rwmb_meta( 'file_images', array( 'size' => 'single-download-m' ) ); 
                                foreach ( $images as $image ) { ?>
                                <div class="sp-thumbnail">
                                    <div class="sp-thumbnail-image-container">
                                        <img class="sp-thumbnail-image" src="<?php echo $image['url']; ?>"/>
                                    </div>
                                </div>
                                <?php } ?>
                            </div>
                        </div>
                        <?php } else if ($file_pre == 'pre_video' && !empty($videos)) { 
                            echo do_shortcode('[video src="'.$videos.'"]');
                        } else { ?>
                        <?php if ( has_post_thumbnail()) {  ?>
                            <a href="<?php the_post_thumbnail_url( 'full' ); ?>" class="imgg" title="<?php the_title_attribute(); ?>">
                                <img <?php if($az_data['site_schema']) {?>itemprop="image"<?php } ?> src="<?php the_post_thumbnail_url( 'single-download' ); ?>" class="post-tumb" alt="<?php the_title_attribute(); ?>"/>
                            </a>
                        <?php } else { ?>
                            <img <?php if($az_data['site_schema']) {?>itemprop="image"<?php } ?> src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/tumb.png" class="post-tumb" alt="<?php the_title_attribute(); ?>"/>
                        <?php }
                            $audio = rwmb_meta ('file_audio');
                            if($file_pre == 'pre_music' && !empty($audio)) {
                            echo do_shortcode('[audio src="'.$audio.'"]');
                        } } ?>
                    </div>

                    <div class="<?php echo $proddet; ?> prod-det" <?php if($az_data['site_schema']) {?>itemprop="offers" itemscope itemtype="http://schema.org/Offer"
                        <?php } ?>>

                        <?php if($az_data['site_schema']) { ?>
                        <meta itemprop="priceCurrency" content="IRR">
                        <meta itemprop="price" content="<?php echo (int)str_replace(',', '', edd_get_download_price(get_the_ID())); ?>">
                        <link itemprop="availability" href="http://schema.org/InStock" />
                        <meta itemprop="url" content="<?php the_permalink(); ?>">
                        <?php } ?>

                        <?php if ($az_data['show_fone']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['fone_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['fone']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php echo rwmb_meta( 'file_fone' ); ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_ftwo']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['ftwo_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['ftwo']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php echo rwmb_meta( 'file_ftwo' ); ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>
                        
                        <?php if ($az_data['show_fthree']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['fthree_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['fthree']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php
                                    if($az_data['edit_fthree']) { 
                                        echo rwmb_meta( 'file_fthree' );
                                    } else { ?>
                                        <a class="author-link" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>">
                                            <?php the_author(); ?>
                                        </a>
                                    <?php }  ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_ffour']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['ffour_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['ffour']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php 
                                    if($az_data['edit_ffour']) {
                                        echo rwmb_meta( 'file_ffour' );
                                    } else { ?>
                                        <?php echo get_the_date('j F Y'); ?>
                                    <?php } ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_ffive']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['ffive_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['ffive']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php
                                    if($az_data['edit_ffive']) { 
                                        echo rwmb_meta( 'file_ffive' );
                                    } else {
                                    the_terms( $post->ID, 'download_category', '', '، ', '' );
                                    } ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_fsix']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['fsix_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['fsix']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php
                                    setPostViews(get_the_ID());
                                    if($az_data['edit_fsix']) {
                                        echo rwmb_meta( 'file_fsix' );
                                    } else {
                                        if($az_data['show_dcount']) {
                                        $download = new EDD_Download( get_the_ID() ); echo $download->get_sales().' فروش';
                                        } else {
                                            echo getPostViews(get_the_ID());
                                        }
                                    } ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php 
                        if(!rwmb_meta( 'file_coming' )) {
                        $variable_prices = edd_has_variable_prices(get_the_ID());
                            if(!$variable_prices) { ?>
                                <div class="prod-row col-12">
                                    <span class="sprice">
                                        <?php p_price(get_the_ID()); ?>
                                    </span>
                                </div>
                        <?php } } ?>
                        <div class="prod-add col-12">
                            <div class="col-lg-8 col-12 add-col">
                                <?php 
                                if(!rwmb_meta( 'file_coming' )) {
                                    function edd_texts_args( $args ) {
                                        $args['class'] = 'btn btn-success';
                                        return $args;
                                    }
                                    add_filter( 'edd_purchase_link_args', 'edd_texts_args' );
                                    if(function_exists('edd_price')) { 
                                        if(edd_is_free_download(get_the_ID()) && $az_data['free_logged'] && !is_user_logged_in()) { 
                                            
                                            if(!empty($az_data['free_logged_link'])) {
                                                echo '<a href="'.$az_data['free_logged_link'].'" title="ورود">';
                                            }
                                            echo '<span class="free-logged">'. $az_data['text_free_logged'].'</span>';
                                            if(!empty($az_data['free_logged_link'])) {
                                                echo '</a>';
                                            }
                                        } else {
                                            echo edd_get_purchase_link(get_the_ID(), 'Add', 'button'); 
                                        }
                                    } 
                                } else {
                                    echo '<span class="coming">'. $az_data['text_coming'].'</span>';
                                } ?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php if ($az_data['show_buy_fixed']) { ?>
                    <div class="btn btn-success buy-fixed">
                        <?php if(edd_is_free_download(get_the_ID())) { ?>
                            <i class="fas fa-download"></i>&nbsp;
                            <?php echo $az_data['text_down_this']; ?>
                        <?php } else { ?>
                            <i class="fas fa-shopping-cart"></i>&nbsp;
                            <?php echo $az_data['text_buy_this']; ?>
                        <?php } ?>
                    </div>
                <?php } ?>
                <div class="down-con"<?php if($az_data['site_schema']) {?> itemprop="description"<?php } ?>>
                    <?php if ($az_data['text_summ']) { ?>
                        <div class="single-text">
                    <?php } ?>
                    <?php the_content();?>
                    <?php
                    $defaults = array(
                        'before'           => '<div class="text-center apage-break">',
                        'after'            => '</div>',
                        'link_before'      => '',
                        'link_after'       => '',
                        'next_or_number'   => 'text',
                        'separator'        => ' ',
                        'nextpagelink'     => '<span class="btn btn-primary">صفحه بعد <i aria-hidden="true" class="fas fa-angle-left"></i></span>',
                        'previouspagelink' => '<span class="btn btn-primary"><i aria-hidden="true" class="fas fa-angle-right"></i> صفحه قبل</span>',
                        'pagelink'         => '%',
                        'echo'             => 1
                    );
                    wp_link_pages($defaults); ?>
                        <?php if ($az_data['text_summ']) { ?>
                            <p class="read-more">
                                <a href="#" class="sbutton">
                                    <?php echo $az_data['text_read_more']; ?>
                                </a>
                            </p>
                        </div>
                    <?php } ?>

                    <?php if(rwmb_meta( 'file_dbox' )) { ?>
                    <!--DL Box-->
                        <div class="dlbox">
                            <div class="dltitle">
                                <i class="fas fa-download"></i>
                                <?php echo $az_data['text_dl']; ?>
                                <?php echo rwmb_meta( 'file_fname', $args, $post->ID ); ?>
                            </div>
                            <?php if( $az_data['show_dl_logged'] && !is_user_logged_in()) {?>
                                <div class="dl-login-msg">
                                    برای مشاهده لینک های دانلود
                                   <a <?php if (!$az_data['ch_login_link']) { echo 'href="#" data-toggle="modal" data-target="#login"';
                                    } else {
                                        echo 'href="' .$az_data['login_link'].'"';
                                    } ?>>
                                        وارد شوید
                                    </a>
                                    یا
                                    <a <?php if (!$az_data['ch_register_link']) {
                                    if (az_woo()) {
                                        echo 'href="' .esc_url(home_url()).'/my-account"';
                                    } else {
                                        echo 'href="' .esc_url(home_url()).'/register"';
                                    }
                                    } else {
                                        echo 'href="' .$az_data['register_link'].'"';
                                    } ?> title="<?php echo $az_data['text_reg_hint']; ?>">
                                        ثبت نام
                                    </a>
                                    نمایید.
                                </div>
                            <?php } else { ?>
                            <div class="links">
                                <?php 
                                $urls = rwmb_meta( 'file_furl', $args, $post->ID );
                                $box_type = rwmb_meta( 'file_box_type', $args, $post->ID );
                                if ( !empty( $urls ) ) {
                                    if ($box_type=='box_part' || $box_type == '') {
                                    foreach ( $urls as $urls ) {
                                        if (filter_var($urls, FILTER_VALIDATE_URL) === FALSE) {
                                            echo '<div class="plain"><i class="fas fa-chain"></i>'.$urls.'</div>';
                                        } else {
                                        $url_name = str_replace('%20', ' ', basename($urls));
                                        $url_name = str_replace('-', ' ', $url_name); 
                                        echo '<a href="'.$urls.'" title="'.$url_name.'" class="flink"><i class="fas fa-caret-left"></i>'.$url_name.'</a>';
                                        }
                                    }
                                    } elseif ($box_type=='box_single') {
                                    foreach ( $urls as $url ) {
                                        if (filter_var($url, FILTER_VALIDATE_URL)) {
                                            echo '<a href="'.$url.'"';
                                        } else {
                                        echo 'title="'.$url.'" class="flink"><i class="fas fa-caret-left"></i>'.$url.'</a>';
                                        }
                                    }
                                    }
                                } ?>
                            </div>
                            <?php } ?>

                            <div class="row fdet">
                                <div class="col-md-4 sdet">
                                    <i class="fas fa-save"></i>
                                    <span aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?php echo $az_data['text_size']; ?>"><?php echo rwmb_meta( 'file_fsize', $args, $post->ID ); ?></span>
                                </div>
                                <div class="col-md-4 sdet">
                                    <i class="fas fa-lock"></i>
                                    <span aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?php echo $az_data['text_pass']; ?>">
                                        <?php echo rwmb_meta( 'file_fpass', $args, $post->ID ); ?>
                                    </span>
                                </div>
                                <div class="col-md-4 sdet">
                                    <span class="dhelp" data-toggle="modal" data-target="#dhelp">
                                        <i class="fas fa-question-circle"></i>
                                        <span aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?php echo $az_data['text_hdl']; ?>"><?php echo $az_data['text_hdl']; ?></span>
                                    </span>
                                </div>
                            </div>
                            <!-- Modal -->
                            <div class="modal fade" id="dhelp">
                            <div class="modal-dialog modal-dialog-centered">
                                <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title">
                                        <?php echo $az_data['dl_help_title']; ?>
                                    </h4>
                                    <button type="button" class="close" data-dismiss="modal">
                                        <i class="fas fa-times" aria-hidden="true"></i>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <?php echo $az_data['dl_help_text']; ?>
                                </div>
                                </div>
                            </div>
                            </div>
                            <!-- Modal -->
                        </div>
                        <!--DL Box-->
                    <?php } ?>

                    <?php if ($az_data['show_msg_help']) { ?>
                    <div class="alert alert-info msg-help col-12">
                        <strong><span class="fas fa-info-circle"></span>&nbsp;&nbsp;
                            <?php echo $az_data['msg_title']; ?></strong>
                        <?php echo $az_data['msg_help']; ?>
                    </div>
                    <?php } ?>

                </div>

                <footer>
                    <?php if ($az_data['show_post_tags']) { ?>
                    <?php the_terms( $post->ID, 'download_tag', '<div class="col-12 p-tags">
                        <p><span class="fas fa-tags"></span>&nbsp;'.$az_data['text_tags'].'&nbsp;', '&nbsp;', '</p>
                    </div>' ); ?>
                    <?php } ?>
                </footer>
            </div>
        </div>
    </article>

    <?php if ($az_data['show_related_p']) { ?>
    <!-- begin custom related loop, isa -->
    <?php
              $custom_taxterms = wp_get_object_terms( $post->ID, $az_data['related_p_by'], array('fields' => 'ids') );
            $args = array(
            'post_type' => 'download',
            'post_status' => 'publish',
            'posts_per_page' => $az_data['related_p_count'],
            'orderby' => 'rand',
            'tax_query' => array(
                array(
                    'taxonomy' => $az_data['related_p_by'],
                    'field' => 'id',
                    'terms' => $custom_taxterms
                )
            ),
            'post__not_in' => array ($post->ID),
            );
            $related_items = new WP_Query( $args );
             if ($related_items->have_posts()) { ?>
    <div class="rcon">
        <div class="m-product">
                    <div class="post-title">
                        <h3><i aria-hidden="true" class="fas fa-shopping-bag"></i>
                            <?php echo $az_data['related_p_title']; ?>
                        </h3>
                    </div>
            <div class="owl-carousel nauto-play">
                <?php
                while ( $related_items->have_posts() ) : $related_items->the_post();
            ?>
                <div class="item">
                    <div class="rcol">
                        <div class="r-box r-box-view">
                            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                                <div class="figure">
                                    <div class="fig">
                                        <span class="fig-price">
                                            <?php p_price(get_the_ID()); ?></span>
                                        <?php p_mimg() ?>
                                    </div>
                                    <div class="figcaption">
                                        <?php the_title(); ?>
                                    </div>
                                </div>
                            </a>
                        </div>
                    </div>
                </div>
                <?php endwhile;
                     wp_reset_postdata();
                     ?>
            </div>
        </div>
    </div>
    <!-- end custom related loop -->
    <?php }} ?>
    <?php endwhile; ?>
    <!-- start foot banner -->
    <?php if ($az_data['show_down_foot_banner']) { ?>
    <div class="row">
        <div class="col-12 foot-con hovers">
            <a href="<?php echo $az_data['down_foot_banner_link']; ?>" aria-label="<?php echo $az_data['down_foot_banner_title']; ?>">
                <figure><img src="<?php echo $az_data['down_foot_banner']['url']; ?>" alt="<?php echo $az_data['down_foot_banner_title']; ?>" class="foot-banner" /></figure>
            </a>
        </div>
    </div>
    <?php }?>
    <!-- end foot banner -->
    <?php if ($az_data['show_ads_banner1'] && $az_data['show_ads_banner1_down']) { ?>
        <!-- start ads banner #1 -->
        <?php require_once AZ_DIR .'/includes/ads-banner.php'; ?>
        <!-- end ads banner #1 -->
    <?php  } ?>

    <?php if ($az_data['show_ads_banner2'] && $az_data['show_ads_banner2_down']) { ?>
        <!-- start ads banner #2 -->
        <?php require_once AZ_DIR .'/includes/ads-banner-t.php'; ?>
        <!-- end ads banner #2 -->
    <?php } ?>
    <?php
	if ( comments_open() ) : ?>
        <div class="comments-con">
            <div class="comments-list col-12">
                <?php comments_template(); ?>
            </div>
        </div>
    <?php endif; ?>
    <?php endif; ?>
</div>

<?php
} else {
?>

<div class="col-lg-9 col-12<?php if ($az_data['side_type'] == 2) { echo ' right-side'; } if ($az_data['sticky_side']) { echo ' pcol'; }?>">
    
    <!-- start head banner -->
    <?php if ($az_data['show_down_head_banner']) { ?>
    <div class="foot-con hovers">
        <a href="<?php echo $az_data['down_head_banner_link']; ?>" aria-label="<?php echo $az_data['down_head_banner_title']; ?>">
            <figure><img src="<?php echo $az_data['down_head_banner']['url']; ?>" alt="<?php echo $az_data['down_head_banner_title']; ?>" class="foot-banner" /></figure>
        </a>
    </div>
    <?php }?>
    <!-- end head banner -->

    <!-- start services -->
    <?php if ($az_data['show_services'] && $az_data['show_services_prod']) { require_once AZ_DIR .'/includes/services.php'; } ?>
    <!-- end services -->

    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <article <?php if($az_data['site_schema']) {?>itemscope itemtype="http://schema.org/Product"
        <?php } ?>>
        <?php if($az_data['site_schema']) {?>
        <link itemprop="mainEntityOfPage" href="<?php the_permalink(); ?>" />
        <meta itemprop="image" content="<?php the_post_thumbnail_url(); ?>">
        <?php } ?>
        <div role="main" class="scon" id="post-<?php the_ID(); ?>">
            <div class="s-product">
                <header class="post-row">
                    <div class="post-title">
                        <h1 <?php if($az_data['site_schema']) {?>itemprop="name"
                            <?php } ?>><i aria-hidden="true" class="fas fa-<?php $posticon = (rwmb_meta('file_p_type') != '' ? rwmb_meta('file_p_type') : 'download'); echo $posticon; ?>"></i>
                            <?php the_title(); ?>
                        </h1>
                        <div class="post-extra">
                            <?php if( function_exists("df_star_ratings") && ($az_data['star_rating']) ) { ?>
                            <div class="rating">
                                <?php echo df_star_ratings(get_the_ID()); ?>
                            </div>
                            <?php } ?>
                            <?php if ($az_data['social_share']) { ?>
                            <span tabindex="0" class="share-btn" data-toggle="modal" data-target="#shareModal"><i class="fas fa-share-alt"></i></span>
                            <?php } ?>
                            <?php if (rwmb_meta( 'file_pre' ) != '') { ?>
                            <a href="<?php echo rwmb_meta( 'file_pre' ); ?>" data-title="<?php echo $az_data['text_pre']; ?>" target="_blank">
                                <span class="pre-btn" data-toggle="tooltip" data-placement="top" title="<?php echo $az_data['text_pre']; ?>"><i class="fas fa-desktop"></i>
                                    <span class="pre-text hidden-sm hidden-xs">
                                        <?php echo $az_data['text_pre']; ?></span>
                                </span>
                            </a>
                            <?php } ?>
                        </div>
                    </div>
                </header>
                <?php if($az_data['square_thumb']) {
                    $prodimg = 'col-lg-5 col-md-6 col-12';
                    $proddet = 'col-lg-7 col-md-6 col-12 square_thumb';
                } else {
                    $prodimg = 'col-lg-7 col-md-8 col-12';
                    $proddet = 'col-lg-5 col-md-4 col-12 square_thumb';
                }
                     ?>
                <div class="row product-details">
                    <div class="<?php echo $prodimg; ?> prod-img si-img">
                        <?php if(rwmb_meta( 'file_special' )) { ?>
                            <span class="special" aria-hidden="true">
                                <?php echo $az_data['text_special']; ?>
                            </span>
                        <?php } ?>
                        <?php
                        //File Preview
                        $file_pre = rwmb_meta( 'file_pre_type' );
                        $images = rwmb_meta( 'file_images', array( 'size' => 'single-download' ) );
                        $videos = rwmb_meta( 'file_video' );
                        $aparat = rwmb_meta( 'file_aparat' );
                        
                        if($file_pre == 'pre_aparat' && !empty($aparat))
                        {
                        echo '<div id="15305363563383534"><script type="text/JavaScript" src="https://www.aparat.com/embed/'.$aparat.'?data[rnddiv]=15305363563383534&data[responsive]=yes"></script></div>';
                        }
                        elseif($file_pre == 'pre_slides' && !empty($images))
                        {
                        ?>
                        <div id="sp-slider" class="slider-pro">
                            <div class="sp-slides">
                                <?php foreach ( $images as $image ) { ?>
                                <div class="sp-slide">
                                    <a href="<?php echo $image['full_url']; ?>" class="imgg" title="<?php the_title_attribute(); ?>">
                                        <img <?php if($az_data['site_schema']) {?> itemprop="image"<?php } ?> class="sp-image" src="<?php echo get_template_directory_uri(); ?>/images/blank.gif" data-src="<?php echo $image['full_url']; ?>" data-small="<?php echo $image['full_url']; ?>" data-medium="<?php echo $image['full_url']; ?>" data-large="<?php echo $image['full_url']; ?>" data-retina="<?php echo $image['full_url']; ?>" />
                                    </a>
                                </div>
                                <?php } ?>
                            </div>
                            <div class="sp-thumbnails">
                                <?php $images = rwmb_meta( 'file_images', array( 'size' => 'single-download-m' ) ); 
                                foreach ( $images as $image ) { ?>
                                <div class="sp-thumbnail">
                                    <div class="sp-thumbnail-image-container">
                                        <img class="sp-thumbnail-image" src="<?php echo $image['url']; ?>"/>
                                    </div>
                                </div>
                                <?php } ?>
                            </div>
                        </div>
                        <?php } else if ($file_pre == 'pre_video' && !empty($videos)) { 
                            echo do_shortcode('[video src="'.$videos.'"]');
                        } else { ?>
                        <?php if ( has_post_thumbnail()) {  ?>
                            <a href="<?php the_post_thumbnail_url( 'full' ); ?>" class="imgg" title="<?php the_title_attribute(); ?>">
                                <img <?php if($az_data['site_schema']) {?>itemprop="image"<?php } ?> src="<?php the_post_thumbnail_url( 'single-download' ); ?>" class="post-tumb" alt="<?php the_title_attribute(); ?>"/>
                            </a>
                        <?php } else { ?>
                            <img <?php if($az_data['site_schema']) {?>itemprop="image"<?php } ?> src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/tumb.png" class="post-tumb" alt="<?php the_title_attribute(); ?>"/>
                        <?php }
                            $audio = rwmb_meta ('file_audio');
                            if($file_pre == 'pre_music' && !empty($audio)) {
                            echo do_shortcode('[audio src="'.$audio.'"]');
                        } } ?>
                    </div>

                    <div class="<?php echo $proddet; ?> prod-det" <?php if($az_data['site_schema']) {?>itemprop="offers" itemscope itemtype="http://schema.org/Offer"
                        <?php } ?>>

                        <?php if($az_data['site_schema']) { ?>
                        <meta itemprop="priceCurrency" content="IRR">
                        <meta itemprop="price" content="<?php echo (int)str_replace(',', '', edd_get_download_price(get_the_ID())); ?>">
                        <link itemprop="availability" href="http://schema.org/InStock" />
                        <meta itemprop="url" content="<?php the_permalink(); ?>">
                        <?php } ?>

                        <?php if ($az_data['show_fone']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['fone_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['fone']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php echo rwmb_meta( 'file_fone' ); ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_ftwo']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['ftwo_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['ftwo']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php echo rwmb_meta( 'file_ftwo' ); ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>
                        
                        <?php if ($az_data['show_fthree']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['fthree_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['fthree']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php
                                    if($az_data['edit_fthree']) { 
                                        echo rwmb_meta( 'file_fthree' );
                                    } else { ?>
                                        <a class="author-link" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>">
                                            <?php the_author(); ?>
                                        </a>
                                    <?php }  ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_ffour']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['ffour_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['ffour']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php 
                                    if($az_data['edit_ffour']) {
                                        echo rwmb_meta( 'file_ffour' );
                                    } else { ?>
                                        <?php echo get_the_date('j F Y'); ?>
                                    <?php } ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_ffive']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['ffive_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['ffive']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php
                                    if($az_data['edit_ffive']) { 
                                        echo rwmb_meta( 'file_ffive' );
                                    } else {
                                    the_terms( $post->ID, 'download_category', '', '، ', '' );
                                    } ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php if ($az_data['show_fsix']) { ?>
                        <div class="prod-row col-12">
                            <div class="attr">
                                <span class="fas <?php echo $az_data['fsix_icon']; ?> picon"></span>
                                <span class="attr-text">
                                    <?php echo $az_data['fsix']; ?>
                                </span>
                            </div>
                            <div class="attr-value">
                                <span>
                                    <?php
                                    setPostViews(get_the_ID());
                                    if($az_data['edit_fsix']) {
                                        echo rwmb_meta( 'file_fsix' );
                                    } else {
                                        if($az_data['show_dcount']) {
                                        $download = new EDD_Download( get_the_ID() ); echo $download->get_sales().' فروش';
                                        } else {
                                            echo getPostViews(get_the_ID());
                                        }
                                    } ?>
                                </span>
                            </div>
                        </div>
                        <?php } ?>

                        <?php 
                        if(!rwmb_meta( 'file_coming' )) {
                        $variable_prices = edd_has_variable_prices(get_the_ID());
                            if(!$variable_prices) { ?>
                                <div class="prod-row col-12">
                                    <span class="sprice">
                                        <?php p_price(get_the_ID()); ?>
                                    </span>
                                </div>
                        <?php } } ?>
                        <div class="prod-add col-12">
                            <div class="col-lg-8 col-12 add-col">
                                <?php 
                                if(!rwmb_meta( 'file_coming' )) {
                                    function edd_texts_args( $args ) {
                                        $args['class'] = 'btn btn-success';
                                        return $args;
                                    }
                                    add_filter( 'edd_purchase_link_args', 'edd_texts_args' );
                                    if(function_exists('edd_price')) { 
                                        if(edd_is_free_download(get_the_ID()) && $az_data['free_logged'] && !is_user_logged_in()) { 
                                            
                                            if(!empty($az_data['free_logged_link'])) {
                                                echo '<a href="'.$az_data['free_logged_link'].'" title="ورود">';
                                            }
                                            echo '<span class="free-logged">'. $az_data['text_free_logged'].'</span>';
                                            if(!empty($az_data['free_logged_link'])) {
                                                echo '</a>';
                                            }
                                        } else {
                                            echo edd_get_purchase_link(get_the_ID(), 'Add', 'button'); 
                                        }
                                    } 
                                } else {
                                    echo '<span class="coming">'. $az_data['text_coming'].'</span>';
                                } ?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php if ($az_data['show_buy_fixed']) { ?>
                <div class="btn btn-success buy-fixed">
                    <?php 
            if(edd_is_free_download(get_the_ID())) { 
            ?>
                    <i class="fas fa-download"></i>&nbsp;
                    <?php echo $az_data['text_down_this']; ?>
                    <?php } else { ?>
                    <i class="fas fa-shopping-cart"></i>&nbsp;
                    <?php echo $az_data['text_buy_this']; ?>
                    <?php } ?>
                </div>
                <?php } ?>
            </div>
            <ul class="nav nav-tabs">
                <li class="nav-item description_tab"><a data-toggle="tab" href="#pdesc" class="active">توضیحات</a></li>
                <li class="nav-item reviews_tab"><a data-toggle="tab" href="#comments">نظرات</a></li>
            </ul>
            <div class="tab-content ptabs">
                <div id="pdesc" class="tab-pane container active">
                    <div class="down-con" <?php if($az_data['site_schema']) {?>itemprop="description"
                        <?php } ?>>
                        <?php if ($az_data['text_summ']) { ?>
                        <div class="single-text">
                            <?php } ?>
                            <?php the_content();?>
                            <?php
                                $defaults = array(
                                    'before'           => '<div class="text-center apage-break">',
                                    'after'            => '</div>',
                                    'link_before'      => '',
                                    'link_after'       => '',
                                    'next_or_number'   => 'text',
                                    'separator'        => ' ',
                                    'nextpagelink'     => '<span class="btn btn-primary">صفحه بعد <i aria-hidden="true" class="fas fa-angle-left"></i></span>',
                                    'previouspagelink' => '<span class="btn btn-primary"><i aria-hidden="true" class="fas fa-angle-right"></i> صفحه قبل</span>',
                                    'pagelink'         => '%',
                                    'echo'             => 1
                                );
                            wp_link_pages($defaults); ?>
                            <?php if ($az_data['text_summ']) { ?>
                            <p class="read-more"><a href="#" class="sbutton">
                                    <?php echo $az_data['text_read_more']; ?></a></p>
                        </div>
                        <?php } ?>
                        <?php if(rwmb_meta( 'file_dbox' )) { ?>
                        <!--DL Box-->
                        <div class="dlbox">
                            <div class="dltitle">
                                <i class="fas fa-download"></i>
                                <?php echo $az_data['text_dl']; ?>
                                <?php echo rwmb_meta( 'file_fname', $args, $post->ID ); ?>
                            </div>
                            <?php if( $az_data['show_dl_logged'] && !is_user_logged_in()) {?>
                                <div class="dl-login-msg">
                                    برای مشاهده لینک های دانلود
                                   <a <?php if (!$az_data['ch_login_link']) { echo 'href="#" data-toggle="modal" data-target="#login"';
                                    } else {
                                        echo 'href="' .$az_data['login_link'].'"';
                                    } ?>>
                                        وارد شوید
                                    </a>
                                    یا
                                    <a <?php if (!$az_data['ch_register_link']) {
                                    if (az_woo()) {
                                        echo 'href="' .esc_url(home_url()).'/my-account"';
                                    } else {
                                        echo 'href="' .esc_url(home_url()).'/register"';
                                    }
                                    } else {
                                        echo 'href="' .$az_data['register_link'].'"';
                                    } ?> title="<?php echo $az_data['text_reg_hint']; ?>">
                                        ثبت نام
                                    </a>
                                    نمایید.
                                </div>
                            <?php } else { ?>
                            <div class="links">
                                <?php 
                                $urls = rwmb_meta( 'file_furl', $args, $post->ID );
                                $box_type = rwmb_meta( 'file_box_type', $args, $post->ID );
                                if ( !empty( $urls ) ) {
                                    if ($box_type=='box_part' || $box_type == '') {
                                    foreach ( $urls as $urls ) {
                                        if (filter_var($urls, FILTER_VALIDATE_URL) === FALSE) {
                                            echo '<div class="plain"><i class="fas fa-chain"></i>'.$urls.'</div>';
                                        } else {
                                        $url_name = str_replace('%20', ' ', basename($urls));
                                        $url_name = str_replace('-', ' ', $url_name); 
                                        echo '<a href="'.$urls.'" title="'.$url_name.'" class="flink"><i class="fas fa-caret-left"></i>'.$url_name.'</a>';
                                        }
                                    }
                                    } elseif ($box_type=='box_single') {
                                    foreach ( $urls as $url ) {
                                        if (filter_var($url, FILTER_VALIDATE_URL)) {
                                            echo '<a href="'.$url.'"';
                                        } else {
                                        echo 'title="'.$url.'" class="flink"><i class="fas fa-caret-left"></i>'.$url.'</a>';
                                        }
                                    }
                                    }
                                } ?>
                            </div>
                            <?php } ?>

                            <div class="row fdet">
                                <div class="col-md-4 sdet">
                                    <i class="fas fa-save"></i>
                                    <span aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?php echo $az_data['text_size']; ?>"><?php echo rwmb_meta( 'file_fsize', $args, $post->ID ); ?></span>
                                </div>
                                <div class="col-md-4 sdet">
                                    <i class="fas fa-lock"></i>
                                    <span aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?php echo $az_data['text_pass']; ?>">
                                        <?php echo rwmb_meta( 'file_fpass', $args, $post->ID ); ?>
                                    </span>
                                </div>
                                <div class="col-md-4 sdet">
                                    <span class="dhelp" data-toggle="modal" data-target="#dhelp">
                                        <i class="fas fa-question-circle"></i>
                                        <span aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?php echo $az_data['text_hdl']; ?>"><?php echo $az_data['text_hdl']; ?></span>
                                    </span>
                                </div>
                            </div>
                            <!-- Modal -->
                            <div class="modal fade" id="dhelp">
                            <div class="modal-dialog modal-dialog-centered">
                                <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title">
                                        <?php echo $az_data['dl_help_title']; ?>
                                    </h4>
                                    <button type="button" class="close" data-dismiss="modal">
                                        <i class="fas fa-times" aria-hidden="true"></i>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <?php echo $az_data['dl_help_text']; ?>
                                </div>
                                </div>
                            </div>
                            </div>
                            <!-- Modal -->
                        </div>
                        <!--DL Box-->
                        <?php } ?>
                        <?php if ($az_data['show_msg_help']) { ?>
                        <div class="alert alert-info msg-help">
                            <strong><span class="fas fa-info-circle"></span>&nbsp;&nbsp;
                                <?php echo $az_data['msg_title']; ?></strong>
                            <?php echo $az_data['msg_help']; ?>
                        </div>
                        <?php } ?>
                    </div>
                    <footer>
                        <?php if ($az_data['show_post_tags']) { ?>
                        <?php the_terms( $post->ID, 'download_tag', '<div class="col-12 p-tags">
            <p><span class="fas fa-tags"></span>&nbsp;'.$az_data['text_tags'].'&nbsp;', '&nbsp;', '</p>
         </div>' ); ?>
                        <?php } ?>
                    </footer>
                </div>
                <div id="comments" class="tab-pane container fade">
                    <?php comments_template(); ?>
                </div>
            </div>
        </div>
    </article>
    <?php if ($az_data['show_related_p']) { ?>
    <!-- begin custom related loop, isa -->
    <?php
              $custom_taxterms = wp_get_object_terms( $post->ID, $az_data['related_p_by'], array('fields' => 'ids') );
            $args = array(
            'post_type' => 'download',
            'post_status' => 'publish',
            'posts_per_page' => $az_data['related_p_count'],
            'orderby' => 'rand',
            'tax_query' => array(
                array(
                    'taxonomy' => $az_data['related_p_by'],
                    'field' => 'id',
                    'terms' => $custom_taxterms
                )
            ),
            'post__not_in' => array ($post->ID),
            );
            $related_items = new WP_Query( $args );
             if ($related_items->have_posts()) { ?>
    <div class="rcon">
        <div class="m-product">
                    <div class="post-title">
                        <h3><i aria-hidden="true" class="fas fa-shopping-bag"></i>
                            <?php echo $az_data['related_p_title']; ?>
                        </h3>
                    </div>
            <div class="owl-carousel nauto-play">
                <?php
                while ( $related_items->have_posts() ) : $related_items->the_post();
            ?>
                <div class="item">
                    <div class="rcol">
                        <div class="r-box r-box-view">
                            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                                <div class="figure">
                                    <div class="fig">
                                        <span class="fig-price">
                                            <?php p_price(get_the_ID()); ?></span>
                                        <?php p_mimg() ?>
                                    </div>
                                    <div class="figcaption">
                                        <?php the_title(); ?>
                                    </div>
                                </div>
                            </a>
                        </div>
                    </div>
                </div>
                <?php endwhile;
                     wp_reset_postdata();
                     ?>
            </div>
        </div>
    </div>
    <!-- end custom related loop -->
    <?php }} ?>
    <?php endwhile; ?>
    <!-- start foot banner -->
    <?php if ($az_data['show_down_foot_banner']) { ?>
    <div class="foot-con hovers">
        <a href="<?php echo $az_data['down_foot_banner_link']; ?>" aria-label="<?php echo $az_data['down_foot_banner_title']; ?>">
            <figure><img src="<?php echo $az_data['down_foot_banner']['url']; ?>" alt="<?php echo $az_data['down_foot_banner_title']; ?>" class="foot-banner" /></figure>
        </a>
    </div>
    <?php }?>
    <!-- end foot banner -->
    <?php if ($az_data['show_ads_banner1'] && $az_data['show_ads_banner1_down']) { ?>
    <!-- start ads banner #1 -->
    <?php require_once AZ_DIR .'/includes/ads-banner.php'; ?>
    <!-- end ads banner #1 -->
    <?php  } ?>

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


<?php } ?>
<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 if ($az_data['edd_side']) { ?>
    <?php if ( is_active_sidebar( 'shop-sidebar' ) ) {
      dynamic_sidebar('shop-sidebar'); 
    } ?>
    <?php } else { ?>
    <?php get_template_part('right-sidebar'); ?>
    <?php } ?>
</aside>

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

<?php get_footer();