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

$post_sidebar_layout   = Draly_Dropshipping_Starter_Helper::get_option( 'post_sidebar_layout', 'left' );
$enable_post_shares    = Draly_Dropshipping_Starter_Helper::get_option( 'enable_post_shares' );
$enable_product_shares = Draly_Dropshipping_Starter_Helper::get_option( 'enable_product_shares' );

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

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

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

if ( $post_sidebar_layout != 'full' ) {
	$main_container_classes [] = $post_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 ) ); ?>">
        <article <?php post_class( 'post-item post-single' ); ?>>
            <div class="container">
				<?php while ( have_posts() ): the_post(); ?>
                    <div class="row">
                        <div class="<?php echo esc_attr( implode( ' ', $main_content_classes ) ); ?>">
							<?php
							Draly_Dropshipping_Starter_Helper::post_format();
							Draly_Dropshipping_Starter_Helper::post_title();
							?>
                            <div class="post-meta">
								<?php
								Draly_Dropshipping_Starter_Helper::post_author();
								Draly_Dropshipping_Starter_Helper::post_date();
								Draly_Dropshipping_Starter_Helper::post_comment();
								?>
                            </div>
							<?php Draly_Dropshipping_Starter_Helper::post_category(); ?>
							<?php Draly_Dropshipping_Starter_Helper::post_full_content(); ?>
                            <div class="post-footer">
								<?php
								if ( ! empty( $enable_post_shares ) ) {
									get_template_part( 'template-parts/share', 'button' );
								}
								Draly_Dropshipping_Starter_Helper::post_tags();
								?>
                            </div>
							<?php
							if ( comments_open() || get_comments_number() ) :
								comments_template();
							endif;
							?>
                        </div>
						<?php if ( $post_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>
					<?php get_template_part( 'template-parts/blog', 'related' ); ?>
				<?php
				endwhile;
				wp_reset_postdata();
				?>
            </div>
        </article>
    </div>
<?php get_footer();
