<?php
/**
 * The template for displaying all pages
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site may use a
 * different template.
 *
 * @link    https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package wpstream-theme
 */

get_header();
$wpstream_page_sidebar = wpstream_theme_is_show_sidebar();

$show_title_page = wpstream_theme_show_page_title();


$content_class = ' col-12 col-lg-9 ';
if ( !$wpstream_page_sidebar ) {
	$content_class = ' col-md-12 col-lg-12" ';
}
?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content py-5 mt-5 <?php echo esc_attr( wpstream_theme_container_class() ); ?>">

			<!-- Hook to add something nice -->
			<?php wpstream_bs_after_primary(); ?>

			<div class="row">
				<?php 
				if ( ( function_exists('is_checkout') && is_checkout() ) || ( function_exists('is_cart') && is_cart() ) ): ?>
					<main id="main" class="site-main">
						<header class="entry-header">
							<?php the_post(); ?>

                        <?php if ( $show_title_page ): ?>
							<h1><?php the_title(); ?></h1>
                        <?php endif; ?>

							<?php wpstream_theme_post_thumbnail(); ?>
						</header>

						<div  id="content" class="entry-content">
							<?php the_content(); ?>
						</div>

						<footer class="entry-footer">
							<?php comments_template(); ?>
						</footer>
					</main>
				<?php elseif ( is_active_sidebar( 'sidebar-1' ) ) : ?>
					<div class="<?php echo esc_attr( $content_class ); ?>">

						<main id="main" class="site-main">
							<header class="entry-header">
								<?php the_post(); ?>

								<?php if ( $show_title_page ): ?>
                                    <h1><?php the_title(); ?></h1>
								<?php endif; ?>

								<?php wpstream_theme_post_thumbnail(); ?>
							</header>

							<div class="entry-content">
								<?php the_content(); ?>
							</div>

					
							<?php comments_template(); ?>
							
				
						</main>
					</div>

					<?php
					if ( $wpstream_page_sidebar ) {
						get_sidebar();
					}
					?>

				<?php else : ?>
					<main id="main" class="site-main">
						<header class="entry-header">
							<?php the_post(); ?>

							<?php if ( $show_title_page ): ?>
                                <h1><?php the_title(); ?></h1>
							<?php endif; ?>

							<?php wpstream_theme_post_thumbnail(); ?>
						</header>

						<div class="entry-content">
							<?php the_content(); ?>
						</div>

					<!--	<footer class="entry-footer">
							<?php //comments_template(); ?>
						</footer> -->
					</main>
				<?php endif; ?>
			</div>

		</div>
	</div>

<?php
get_footer();
