<?php
// Retrieve options once and store in variables
$post_author          = glamer_options('glamer_single_post_author', true);
$post_date            = glamer_options('glamer_single_post_date', true);
$post_comment_number  = glamer_options('glamer_single_post_cmnt', true);
$post_cat_name        = glamer_options('glamer_single_post_cat', true);
$post_tag             = glamer_options('glamer_single_post_tag', true);
$post_share           = glamer_options('glamer_post_share', true);
$post_nav             = glamer_options('glamer_post_nav', true);
$author_profile       = glamer_options('glamer_author_profile', false);
$sidebar_content      = glamer_options('post_single_lsidebar_content', 'one');

// Allow layout override through the 'bs' URL parameter if it exists
$sidebar_content = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : $sidebar_content;
// Post format template part selection
$post_format = get_post_format();
$template_part = $post_format ? "template-parts/post/post-format/post-format-$post_format" : 'template-parts/post/post-format/post-format-others';
?>

<article id="post-<?php the_ID(); ?>" <?php post_class('post-single ' . ($sidebar_content !== 'two' && get_post_type() === 'post' ? 'single-with-sidebar-style-one' : 'single-with-sidebar-style-two')); ?>>
    <?php if ($sidebar_content === 'two') : ?>
        <div class="post-meta-with-title <?php echo esc_attr('post-meta-top-style'); ?>">
            <?php if (get_post_type() === 'post') : ?>
                <div class="post-meta post-details-meta">
                    <ul>
                        <?php if ($post_author) : ?>
                            <li><?php glamer_posted_by(); ?></li>
                        <?php endif; ?>
                        <?php if ($post_date) : ?>
                            <li><?php glamer_posted_on(); ?></li>
                        <?php endif; ?>
                        <?php if (get_comments_number() && $post_comment_number) : ?>
                            <li class="comment-number"><?php glamer_comment_count(); ?></li>
                        <?php endif; ?>
                        <?php if ($post_cat_name) : ?>
                            <li><?php glamer_post_categories(); ?></li>
                        <?php endif; ?>
                    </ul>
                </div>
            <?php endif; ?>
            <?php the_title('<h3 class="post-title single-blog-post-title underline-anim-wrap">', '</h3>'); ?>
        </div>
        <?php get_template_part($template_part); ?>
    <?php endif; ?>

    <?php if ($sidebar_content === 'one') : ?>
        <?php get_template_part($template_part); ?>
    <?php endif; ?>

    <div class="post-content-wrapper">
        <?php if ($sidebar_content === 'one' && get_post_type() === 'post') : ?>
            <div class="post-meta post-details-meta">
                <ul>
                    <?php if ($post_author) : ?>
                        <li><?php glamer_posted_by(); ?></li>
                    <?php endif; ?>
                    <?php if ($post_date) : ?>
                        <li><?php glamer_posted_on(); ?></li>
                    <?php endif; ?>
                    <?php if (get_comments_number() && $post_comment_number) : ?>
                        <li class="comment-number"><?php glamer_comment_count(); ?></li>
                    <?php endif; ?>
                    <?php if ($post_cat_name) : ?>
                        <li><?php glamer_post_categories(); ?></li>
                    <?php endif; ?>
                </ul>
            </div>
            <?php the_title('<h3 class="post-title single-blog-post-title underline-anim-wrap">', '</h3>'); ?>

        <?php endif; ?>

        <div class="entry-content">
            <?php
            the_content(sprintf(
                wp_kses(
                    __('Continue reading<span class="screen-reader-text"> "%s"</span>', 'glamer'),
                    array('span' => array('class' => array()))
                ),
                get_the_title()
            ));

            wp_link_pages(array(
                'before' => '<div class="page-links">' . esc_html__('Pages:', 'glamer'),
                'after'  => '</div>',
            ));
            ?>
        </div><!-- .entry-content -->

        <?php if (has_tag() && $post_tag) : ?>
            <div class="post-share-wrapper pt-10">
                <?php glamer_post_tags(); ?>
            </div>
        <?php endif; ?>
    </div>

    <?php if (function_exists('glamercore_post_share') && $post_share) {
        glamercore_post_share();
    } ?>
</article><!-- #post-<?php the_ID(); ?> -->

<?php
$total_post = wp_count_posts('post')->publish;
if ($total_post > 1 && $post_nav) {
    glamer_next_prev_post_link();
}

if ($author_profile) {
    /**
	* Hook - glamer_action_author_info_hook.
	*
	* @hooked glamer_author_info_hook -  10
	*/
	do_action( 'glamer_action_author_info_hook' );
}