<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package benqu
 */

benqu_get_breadcrumb();
$benquPostClass = '';
if(is_active_sidebar('sidebar-1')){
	$benquPostClass = 'col-xl-8 benqu-sticky-item';
}else{
	$benquPostClass = 'col-lg-10 offset-lg-1 no-active-sidebar';
}
$authore_info_show = cs_get_option('authore_info_show');
$single_post_comment_disable = cs_get_option('single_post_comment_disable');
$related_post_disable = cs_get_option('related_post_disable');
$blog_tags = cs_get_option('blog_tags');
$blog_top_share = cs_get_option('blog_top_share');
$blog_top_share = is_null($blog_top_share) ? true : $blog_top_share;
$blog_inner_share = cs_get_option('blog_inner_share');
$blog_inner_share = is_null($blog_inner_share) ? true : $blog_inner_share;
$blog_share = cs_get_option('blog_share');
$blog_nav = cs_get_option('blog_nav');
$authore_show = cs_get_option('authore_show');
$featured_image_caption_show = cs_get_option('featured_image_caption_show');
$ajax_scroll_stop = cs_get_option('ajax_scroll_stop');

$view_count_disable = cs_get_option('view_count_disable');
$post_comment_disable = cs_get_option('post_comment_disable');
$post_date_disable = cs_get_option('post_date_disable');
?>
<div class="pfy_single_post_wrapper pfy-inter-wraap">
    <div class="container">
        <div class="row benqu-sticky-wrap">
            <div class="<?php echo esc_attr($benquPostClass);?>">
            <?php if($ajax_scroll_stop == true):?>
                <div class="ajax-scroll-post">
                    <?php endif;?>
                    <?php
                    while ( have_posts() ) :
                        the_post();
                        if(get_post_meta(get_the_ID(), 'benqu_post_format_meta', true)) {
                            $post_video_meta = get_post_meta(get_the_ID(), 'benqu_post_format_meta', true);
                        } else {
                            $post_video_meta = array();
                        }
                        
                        if( array_key_exists( 'video_id', $post_video_meta )) {
                            $video_id = $post_video_meta['video_id'];
                        } else {
                            $video_id = '';
                        }
                        ?>
                        <div class="bnq__post_wap_loop">
                            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                                <header class="entry-header">
                                    <?php benqu_category_badge();?>
                                    <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
                                    <div class="pfy-single-post-meta d-flex align-items-center">
                                        <ul>
                                            <?php if($authore_show != false): ?>
																							<li><span class="auth_by"><?php esc_html_e( 'BY', 'benqu' ); ?></span> <?php the_author()?></li>
                                            <?php endif;?>
                                            
																						<?php if($post_date_disable == true): ?>
																							<li><i class="fal fa-calendar-alt"></i> <?php echo esc_html(get_the_time( get_option('date_format')));?></li>
                                            <?php endif;?>
                                            
																						<?php if($post_comment_disable == true): ?>
																							<li>
																									<i class="far fa-comments"></i>
																									<?php echo esc_attr(get_comments_number());?> 
																									<?php
																											if(get_comments_number() == 1){
																													esc_html_e( 'Comment', 'benqu' );
																											}else{
																													esc_html_e( 'Comments', 'benqu' );
																											}						 
																									?>
																							</li>
                                            <?php endif;?>
                                            
																						<?php if(function_exists('benqu_get_views') && $view_count_disable == true): ?>
                                                <li><i class="fal fa-eye"></i> <?php echo esc_attr(benqu_get_views());?> <?php esc_html_e( 'Views', 'benqu' );?></li>
                                            <?php endif;?>
                                        </ul>
                                        <div class="bnq__social-top">
																						<?php if(function_exists('benqu_post_share_two') && $blog_top_share == true){ benqu_post_share_two(); } ?>
                                        </div>
                                    </div>
                                </header><!-- .entry-header -->
                                <div class="pfy-single-post-thumb">
                                    <?php the_post_thumbnail( 'benqu-img-size4', ['class' => 'img-fluid'] ); ?>
																		<?php if($featured_image_caption_show == true && get_the_post_thumbnail_caption()) { ?>
																			<div class="pfy-single-post-caption"><em><?php the_post_thumbnail_caption(); ?></em></div>
																		<?php } ?>
																</div>
                                <div class="bnq-single-con <?php if( !function_exists('benqu_post_share_two') || $blog_inner_share == false){echo esc_attr("no-social");} ?>">
																		<?php if(function_exists('benqu_post_share_two') && $blog_inner_share == true): ?>
																			<div class="bnq-inner-social">
																				<?php benqu_post_share_two(); ?>
																			</div>
																		<?php endif; ?>
																		<div class="entry-content">
                                        <?php
                                        the_content(
                                            sprintf(
                                                wp_kses(
                                                    /* translators: %s: Name of current post. Only visible to screen readers */
                                                    __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'benqu' ),
                                                    array(
                                                        'span' => array(
                                                            'class' => array(),
                                                        ),
                                                    )
                                                ),
                                                wp_kses_post( get_the_title() )
                                            )
                                        );

                                        wp_link_pages(
                                            array(
                                                'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'benqu' ),
                                                'after'  => '</div>',
                                            )
                                        );
                                        ?>
                                    </div><!-- .entry-content -->
                                </div>                    
                                
                                <?php if(true == $blog_tags || function_exists('benqu_post_share')): ?>
                                <footer class="entry-footer">
                                    <div class="row align-items-center">
                                        <div class="col-lg-6 col-6">                                
                                            <?php if(true == $blog_tags){ benqu_entry_footer(); }?>
                                        </div>
                                        <div class="col-lg-6 col-6 text-end">
                                            <?php 
                                                if(function_exists('benqu_post_share') && $blog_share != false){
                                                    benqu_post_share();
                                                }
                                            ?>
                                        </div>
                                    </div>                        
                                </footer><!-- .entry-footer -->
                                <?php endif;?>
                            </article><!-- #post-<?php the_ID(); ?> -->
                            
                            <?php
																if(function_exists('benqu_single_post_pagination') && true == $blog_nav){
																		benqu_single_post_pagination();
																}
																
																if(function_exists('benqu_theme_author_box') && true == $authore_info_show){
																		benqu_theme_author_box();
																}

																// If comments are open or we have at least one comment, load up the comment template.
																if($single_post_comment_disable == true ){
																		if ( comments_open() || get_comments_number()) :
																				comments_template();
																		endif;
																}
														?>
                        </div>
                        

                   <?php endwhile; // End of the loop. ?>
									 <?php if($ajax_scroll_stop == true): ?>
            </div>
            <?php endif;?>
            <?php 
                if($related_post_disable == true){
                    get_template_part('template-parts/related-posts');
                }
            ?>
            </div>
            <?php get_sidebar();?>
        </div>
    </div>
</div>


