<?php
/*
Theme Designed By: Meysam Hosseinkhani
Email: Meysam98@Gmail.com
Author Website: Hosseinkhani.ir
*/
   // Exit if accessed directly
   if (!defined('ABSPATH')) {
    exit;
}
edd_az();
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 global $az_data;
$author = get_user_by( 'slug', get_query_var( 'vendor' ) );

if ( !$author ) {
   $url = $_SERVER['REQUEST_URI'];
   $page_id = EDD_FES()->helper->get_option( 'fes-vendor-page', false );
   $page = get_page( $page_id );
   $page_name = ! empty( $page->post_name ) ? $page->post_name : EDD_FES()->vendors->get_vendor_constant_name( false, false );
   $permalink = '/'. trailingslashit( $page_name ) ;
   
   if ( !empty ( $_SERVER['REQUEST_URI'] ) && !empty( $url ) ){
      $string = str_replace( $permalink, '', $url );
      $author = get_user_by( 'slug', untrailingslashit ( $string ) );
   }
}
?>
<div class="col-lg-9 col-12<?php if ($az_data['side_type'] == 2) { echo ' right-side'; } if ($az_data['sticky_side']) { echo ' pcol'; }?>">
    <div class="rcon">
        <div class="author-page">
            <div class="row">
                <div class="col-md-2 col-12 uavatar">
                    <?php echo get_avatar($author->ID , 128, '',$author->display_name ); ?>
                </div>
                <div class="col-md-10 col-12">
                    <div class="row author-name">
                        <?php echo $author->display_name; ?>
                        <?php if ($az_data['show_author_user']) { ?>
                        <span class="author-uname">
                            <?php echo get_the_author_meta('user_login', $author); ?>
                        </span>
                        <?php } ?>
                    </div>
                    <div class="row author-bio">
                        <?php echo $author->description; ?>
                    </div>
                    <div class="row author-det">
                        <div class="col-md-3 col-12 author-attr">
                            <i class="fas fa-shopping-bag"></i>
                            <?php if (az_woo()) { ?>
                                <?php echo count_user_posts( $author->ID , "product"  ) ?>
                            <?php } else { ?>
                                <?php echo count_user_posts( $author->ID , "download"  ) ?>
                            <?php } ?>
                            محصول
                        </div>
                        <div class="col-md-3 col-12 author-attr">
                            <i class="fas fa-file-alt"></i>
                            <?php echo count_user_posts( $author->ID , "post"  ) ?> نوشته
                        </div>
                        <div class="col-md-3 col-12 author-attr">
                            <i class="fas fa-user-plus"></i> عضویت
                            <?php echo parsidate('y/m/d',$author->user_registered,$lang='per'); ?>
                        </div>
                        <div class="col-md-3 col-12">
                            <span class="mail-btn">
                                <a class="btn btn-primary float-left" href="mailto:<?php echo $author->user_email; ?>"><i class="fas fa-envelope"></i> ارسال ایمیل</a></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--- Block-Products --->
    <?php 
    $block_prods = new WP_Query( array(
        'posts_per_page' => 8,
        'post_type' => 'download',
        'post_status' => 'publish',
        'author_name' => $author->user_nicename,
        'order' => 'DESC'  ) );
    if ( $block_prods->have_posts() ) {
    ?>
    <div class="rcon">
        <div class="m-product">
                    <div class="post-title">
                            <h3>
                                <a href="<?php echo get_author_posts_url( $author->ID , $author->user_nicename ).'?post_type=download'; ?>">
                                    <i class="fas fa-shopping-bag"></i>محصولات
                                </a>
                            </h3>
                            <a class="float-left morebtn" href="<?php echo get_author_posts_url( $author->ID , $author->user_nicename ).'?post_type=download'; ?>">
                                <?php echo $az_data['text_more']; ?> <i class="fas fa-chevron-left"></i>
                            </a>
                    </div>
            <div class="owl-carousel nauto-play">
                <?php
               while ( $block_prods->have_posts() ) : $block_prods->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(); ?>">
                                <figure class="figure">
                                    <div class="fig">
                                        <span class="fig-price">
                                            <?php p_price(get_the_ID()); ?></span>
                                        <?php p_mimg() ?>
                                        <?php 
                   if(rwmb_meta( 'file_special' )){ ?>
                                        <span class="special" aria-hidden="true">
                                            <?php echo $az_data['text_special']; ?></span>
                                        <?php } ?>
                                    </div>
                                    <figcaption class="figcaption">
                                        <?php the_title(); ?>
                                    </figcaption>
                                </figure>
                            </a>
                        </div>
                    </div>
                </div>
                <?php endwhile;
                     wp_reset_postdata();
                     ?>
            </div>
        </div>
    </div>
    <?php } ?>
    <!--- Block-Products --->

 <!--- Block-Posts --->
    <?php $block_posts = new WP_Query( array(
        'posts_per_page' => 8,
        'post_type' => 'post',
        'post_status' => 'publish',
        'author_name' => $author->user_nicename,
        'order' => 'DESC'  ) );
    if ( $block_posts->have_posts() ) {
    ?>
    <div class="rcon">
        <div class="m-product">
                    <div class="post-title">
                        <h3><a href="<?php echo get_author_posts_url( $author->ID , $author->user_nicename ).'?post_type=post'; ?>">
                                <i class="fas fa-file-alt"></i>نوشته ها</a></h3>
                        <a class="float-left morebtn" href="<?php echo get_author_posts_url( $author->ID , $author->user_nicename ).'?post_type=post'; ?>">
                            <?php echo $az_data['text_more']; ?> <i class="fas fa-chevron-left"></i></a>
                    </div>
            <div class="owl-carousel nauto-play">
                <?php
               while ( $block_posts->have_posts() ) : $block_posts->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"><span>
                                                <?php echo $az_data['text_more_text']; ?></span></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>
    <?php } ?>
    <!--- Block-post --->

</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();