<?php
/**
 * Tag Main File.
 *
 * @package INVENTIVE
 * @author  Themekalia
 * @version 1.0
 */

get_header();
global $wp_query;
$data  = \INVENTIVE\Includes\Classes\Common::instance()->data( 'tag' )->get();
$layout = $data->get( 'layout' );
$sidebar = $data->get( 'sidebar' );
$layout = ( $layout ) ? $layout : 'right';
$sidebar = ( $sidebar ) ? $sidebar : 'default-sidebar';
if (is_active_sidebar( $sidebar )) {$layout = 'right';} else{$layout = 'full';}
$class = ( !$layout || $layout == 'full' ) ? 'col-xs-12 col-sm-12 col-md-12' : 'col-lg-8 col-md-12 col-sm-12';
if ( class_exists( '\Elementor\Plugin' ) AND $data->get( 'tpl-type' ) == 'e' AND $data->get( 'tpl-elementor' ) ) {
	echo Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $data->get( 'tpl-elementor' ) );
} else {
?>

<?php if ( $data->get( 'enable_banner' ) ) : ?>
	<?php do_action( 'inventive_banner', $data );?>
<?php else:?>
<!-- Page Title -->
<section class="page-title">
    <?php if( $data->get( 'banner' ) ){?><div class="bg-layer" style="background-image: url('<?php echo esc_url( $data->get( 'banner' ) ); ?>');"></div><?php };?>
    <div class="auto-container">
        <div class="content-box">
            <h1><?php if ($data->get('title')) { echo wp_kses($data->get('title'), true); } else { single_tag_title(); } ?></h1>
            <ul class="bread-crumb clearfix">
                <?php echo inventive_the_breadcrumb(); ?>
            </ul>
        </div>
    </div>
</section>
<!-- End Page Title -->

<?php endif;?>

<!-- sidebar-page-container -->
<section class="sidebar-page-container inner_page">
    <div class="auto-container">
        <div class="row">
        	
			<?php if( $data->get( 'layout' ) == 'left' ): ?>
			<div class="col-lg-4 col-md-12 col-sm-12 sidebar-side">
                <div class="blog-sidebar default-sidebar pt_60 pb_50">
                    <?php dynamic_sidebar( $sidebar ); ?>
                </div>
            </div>
			<?php endif; ?>
            
            <div class="content-side <?php echo esc_attr( $class ); ?> <?php if ( $data->get( 'layout' ) == 'left' ) echo 'left-sidebar'; elseif ( $data->get( 'layout' ) == 'right' ) echo 'right-sidebar'; ?>">
                <div class="shape_right_border"></div>
                <div class="blog-classic-content pt_100 pb_100">
                    <div class="thm-unit-test">                        
                        <?php
                            while ( have_posts() ) :
                                the_post();
                                inventive_template_load( 'templates/blog/blog.php', compact( 'data' ) );
                            endwhile;
                            wp_reset_postdata();
                        ?>                            
                    </div>
                    
                    <!--Pagination-->
                    <div class="pagination-wrapper">
                    	<?php inventive_the_pagination( $wp_query->max_num_pages );?>
                    </div>
                </div>
            </div>
        	
			<?php if( $data->get( 'layout' ) == 'right' ): ?>
			<div class="col-lg-4 col-md-12 col-sm-12 sidebar-side">
                <div class="blog-sidebar default-sidebar pt_60 pb_50">
                    <?php dynamic_sidebar( $sidebar ); ?>
                </div>
            </div>
			<?php endif; ?>
            
        </div>
    </div>
</section> 
<!--End blog area-->

<?php }
get_footer();
