<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Draly
 */

get_header();

$blog_sidebar_layout = Draly_Dropshipping_Starter_Helper::get_option( 'blog_sidebar_layout', 'left' );
$blog_style          = Draly_Dropshipping_Starter_Helper::get_option( 'blog_style', 'standard' );

$sidebar_isset = wp_get_sidebars_widgets();
$sidebar_id    = 'widget-area';

if ( empty( $sidebar_isset[ $sidebar_id ] ) ) {
	$blog_sidebar_layout = 'full';
}

$main_container_classes = array( 'main-container' );
$main_content_classes   = array( 'main-content', 'col-12' );

if ( $blog_sidebar_layout != 'full' ) {
	$main_container_classes[] = $blog_sidebar_layout . '-sidebar has-sidebar';
	$main_content_classes[]   = 'col-xl-9 col-lg-8';
} else {
	$main_container_classes[] = 'no-sidebar';
}
?>

    <div id="content" class="<?php echo esc_attr( implode( ' ', $main_container_classes ) ); ?>">
        <div class="container">
            <div class="row">
                <div class="<?php echo esc_attr( implode( ' ', $main_content_classes ) ); ?>">
					<?php get_template_part( 'templates/blog/blog', $blog_style ); ?>
                </div>
				<?php if ( $blog_sidebar_layout != 'full' ) {
					if ( is_active_sidebar( $sidebar_id ) ) : ?>
                        <div class="sidebar col-xl-3 col-lg-4 col-12">
                            <div id="widget-area" class="widget-area sidebar-blog">
								<?php dynamic_sidebar( $sidebar_id ); ?>
                            </div>
                        </div>
					<?php endif;
				} ?>
            </div>
        </div>
    </div>
<?php get_footer();
