<?php

/**
 * The template for displaying all single posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package hostiko
 */

$akd_theme_admin_page = get_option( 'akd-framework-admin-page' );
// Check if Elementor exists and a template ID is selected
if ( ! empty( $akd_theme_admin_page['opt-select-single-post-elementor-template'] ) && did_action( 'elementor/loaded' ) && is_singular() && get_post_type() === 'post' ) :
	// Use Elementor's API to render the selected template
    get_header();
	echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $akd_theme_admin_page['opt-select-single-post-elementor-template'] );
    get_footer();
    exit;
endif;
if(isset($akd_theme_admin_page['opt-image-select-single-page-layout']) && $akd_theme_admin_page['opt-image-select-single-page-layout'] == 'right-sidebar' && is_singular() && get_post_type() === 'post'){
$blog_column = is_active_sidebar( 'right-sidebar' ) ? 8 : 12 ;
$blog_column_shop = is_active_sidebar( 'right-sidebar-shop' ) ? 8 : 12 ;
$single_template = $akd_theme_admin_page['opt-select-single-post-elementor-template'];

get_header();

?>
<div id="primary" class="content-area hostiko-page-containerr hostiko-blog-details">
    <main id="main" class="site-main">
        <div class="blog-details-area">
            <div class="container">
                <div class="row custom-gutter">
                    <?php
						if(is_active_sidebar( 'right-sidebar' )){
							?>
                    <div class="col-lg-<?php print esc_attr($blog_column); ?>">
                        <?php
						}else if(is_active_sidebar( 'right-sidebar-shop' )){
							?>
                        <div class="col-lg-<?php print esc_attr($blog_column_shop); ?>">
                            <?php
						}
							while ( have_posts() ) :
								the_post();
									if ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() )  ) {
										the_content();
									} 
									else{
										get_template_part( 'template-parts/content', get_post_format() );
									}
								?>

                            <?php 
								if( get_previous_post_link() AND get_next_post_link() ) : ?>

                            <?php 
								endif; ?>


                            <?php get_template_part( 'template-parts/biography'); ?>


                            <div class="blog-details-comment">
                                <?php
									// If comments are open or we have at least one comment, load up the comment template.
									if ( comments_open() || get_comments_number() ) :
										comments_template(); 
									endif;
									?>
                            </div>
                            <?php 	
							endwhile; ?>
                        </div>
                        <?php
						if ( is_active_sidebar( 'right-sidebar' ) && ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() ) || ( is_single() && is_singular('post') ) ) ) {
						?>
                        <div class="col-lg-4 sidebar-blog right-side">
                            <?php get_sidebar(); ?>
                        </div>
                        <?php
						} else if ( is_active_sidebar( 'right-sidebar-shop' ) && function_exists('is_product') && is_product() ) {
						?>
                        <div class="col-lg-4 sidebar-blog right-side">
                            <?php get_sidebar('shop'); ?>
                        </div>
                        <?php
						}
						?>
                    </div>
                </div>
            </div>
    </main><!-- #main -->
</div><!-- #primary -->
<?php 
get_footer();
}
else if(isset($akd_theme_admin_page['opt-image-select-single-page-layout']) && $akd_theme_admin_page['opt-image-select-single-page-layout'] == 'left-sidebar'  && is_singular() && get_post_type() === 'post'){
$blog_column = is_active_sidebar( 'right-sidebar' ) ? 8 : 12 ;
$blog_column_shop = is_active_sidebar( 'right-sidebar-shop' ) ? 8 : 12 ;
get_header();
?>
<div id="primary" class="content-area hostiko-page-containerr hostiko-blog-details">
    <main id="main" class="site-main">
        <div class="blog-details-area">
            <div class="container">
                <div class="row custom-gutter">

                    <?php
						if ( is_active_sidebar( 'right-sidebar' ) && ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() ) || ( is_single() && is_singular('post') ) ) ) {
						?>
                    <div class="col-lg-4 sidebar-blog right-side">
                        <?php get_sidebar(); ?>
                    </div>
                    <?php
						} else if ( is_active_sidebar( 'right-sidebar-shop' ) && function_exists('is_product') && is_product() ) {
						?>
                    <div class="col-lg-4 sidebar-blog right-side">
                        <?php get_sidebar('shop'); ?>
                    </div>
                    <?php
						}
						?>

                    <?php
						if(is_active_sidebar( 'right-sidebar' )){
							?>
                    <div class="col-lg-<?php print esc_attr($blog_column); ?>">
                        <?php
						}else if(is_active_sidebar( 'right-sidebar-shop' )){
							?>
                        <div class="col-lg-<?php print esc_attr($blog_column_shop); ?>">
                            <?php
						}
							while ( have_posts() ) :
								the_post();
									if ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() )  ) {
										the_content();
									} 
									else{
										get_template_part( 'template-parts/content', get_post_format() );
									}
								?>

                            <?php 
								if( get_previous_post_link() AND get_next_post_link() ) : ?>

                            <?php 
								endif; ?>
                            <?php get_template_part( 'template-parts/biography'); ?>
                            <div class="blog-details-comment">
                                <?php
									// If comments are open or we have at least one comment, load up the comment template.
									if ( comments_open() || get_comments_number() ) :
										comments_template(); 
									endif;
									?>
                            </div>
                            <?php 	
							endwhile; ?>
                        </div>

                    </div>
                </div>
            </div>
    </main><!-- #main -->
</div><!-- #primary -->
<?php 
get_footer();
}
else if(isset($akd_theme_admin_page['opt-image-select-single-page-layout']) && $akd_theme_admin_page['opt-image-select-single-page-layout'] == 'full-width'  && is_singular() && get_post_type() === 'post'){
$blog_column = 12 ;
$blog_column_shop = 12 ;

get_header();
?>
<div id="primary" class="content-area hostiko-page-containerr hostiko-blog-details">
    <main id="main" class="site-main">
        <div class="blog-details-area">
            <div class="container">
                <div class="row custom-gutter">

                    <?php
                            if(is_active_sidebar( 'right-sidebar' )){
                                ?>
                    <div class="col-lg-<?php print esc_attr($blog_column); ?>">
                        <?php
                            }else if(is_active_sidebar( 'right-sidebar-shop' )){
                                ?>
                        <div class="col-lg-<?php print esc_attr($blog_column_shop); ?>">
                            <?php
                            }
                                while ( have_posts() ) :
                                    the_post();
                                        if ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() )  ) {
                                            the_content();
                                        } 
                                        else{
                                            get_template_part( 'template-parts/content', get_post_format() );
                                        }
                                    ?>
                            <?php 
                                    if( get_previous_post_link() AND get_next_post_link() ) : ?>

                            <?php 
                                    endif; ?>
                            <?php get_template_part( 'template-parts/biography'); ?>

                            <div class="blog-details-comment">
                                <?php
                                        // If comments are open or we have at least one comment, load up the comment template.
                                        if ( comments_open() || get_comments_number() ) :
                                            comments_template(); 
                                        endif;
                                        ?>
                            </div>
                            <?php 	
                                endwhile; ?>
                        </div>

                    </div>
                </div>
            </div>
    </main><!-- #main -->
</div><!-- #primary -->
<?php 
get_footer();
}
else{
$blog_column = is_active_sidebar( 'right-sidebar' ) ? 8 : 12 ;
$blog_column_shop = is_active_sidebar( 'right-sidebar-shop' ) ? 8 : 12 ;

get_header();
?>
<div id="primary" class="content-area hostiko-page-containerr hostiko-blog-details">
    <main id="main" class="site-main">
        <div class="blog-details-area">
            <div class="container">
                <div class="row custom-gutter">
                    <?php
						if(is_active_sidebar( 'right-sidebar' )){
							?>
                    <div class="col-lg-<?php print esc_attr($blog_column); ?>">
                        <?php
						}else if(is_active_sidebar( 'right-sidebar-shop' )){
							?>
                        <div class="col-lg-<?php print esc_attr($blog_column_shop); ?>">
                            <?php
						}
							while ( have_posts() ) :
								the_post();
									if ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() )  ) {
										the_content();
									} 
									else{
										get_template_part( 'template-parts/content', get_post_format() );
									}
									
								?>
                            <?php 
								if( get_previous_post_link() AND get_next_post_link() ) : ?>

                            <?php 
								endif; ?>
                            <?php get_template_part( 'template-parts/biography'); ?>
                            <div class="blog-details-comment">
                                <?php
									// If comments are open or we have at least one comment, load up the comment template.
									if ( comments_open() || get_comments_number() ) :
										comments_template(); 
									endif;
									?>
                            </div>
                            <?php 	
							endwhile; ?>
                        </div>
                        <?php
						if ( is_active_sidebar( 'right-sidebar' ) && ( ( function_exists('is_shop') && is_shop() ) || ( function_exists('is_product') && is_product() ) || ( is_single() && is_singular('post') ) ) ) {
						?>
                        <div class="col-lg-4 sidebar-blog right-side">
                            <?php get_sidebar(); ?>
                        </div>
                        <?php
						} else if ( is_active_sidebar( 'right-sidebar-shop' ) && function_exists('is_product') && is_product() ) {
						?>
                        <div class="col-lg-4 sidebar-blog right-side">
                            <?php get_sidebar('shop'); ?>
                        </div>
                        <?php
						}
						?>
                    </div>
                </div>
            </div>
    </main><!-- #main -->
</div><!-- #primary -->
<?php 
get_footer();
}