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

?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <div id="content" class="post-excerpt single-post">
            <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>

            <?php if( !post_password_required() ) : ?>
            <div class="post-details">
                <?php if ( ! has_post_thumbnail() ) : ?>
                    <div class="post-date">
                        <span><?php echo esc_html( get_the_date() ); ?></span>
                    </div><!-- /.post-date -->
                <?php endif; ?>
                <div class="excerpt-author">
                    <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?></a>
                    <div class="author-name">
                        <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php the_author(); ?></a>
                    </div><!-- /.author-name -->
                </div><!-- /.excerpt-author -->

                <?php
                    $prime_business_categories_list = get_the_category_list( esc_html__( ' / ', 'prime-business' ) );
                    if ( $prime_business_categories_list ) {
                        printf(
                            /* translators: 1: SVG icon. 2: posted in label, only visible to screen readers. 3: list of categories. */
                            '<div class="excerpt-category">%1$s</div><!-- /.excerpt-category -->',
                            $prime_business_categories_list
                        ); // WPCS: XSS OK.
                    }
                ?>

                <?php
                    edit_post_link(
                        sprintf(
                            /* translators: %s: Name of current post */
                            esc_html__( 'Edit %s', 'prime-business' ),
                            the_title( '<div class="post-edit"><span class="screen-reader-text">"', '"</span></div><!-- /.post-edit -->', false )
                        ),
                        '<span class="edit-link">',
                        '</span>'
                    );
                ?>
            </div><!-- /.post-details -->
            <?php endif; ?>

        <div class="post-content clearfix">
            <?php
                the_content(
                    sprintf(
                        /* translators: %s: Name of current post */
                        __( '<span class="screen-reader-text"> "%s"</span>', 'prime-business' ),
                        get_the_title()
                    )
                );
            ?>
        </div><!-- /.post-content -->

        <?php
            wp_link_pages(
                array(
                    'before'      => '<div class="link-pages-wrap clearfix"><div class="link-pages">' . esc_html__( 'Continue Reading:', 'prime-business' ),
                    'after'       => '</div></div>',
                    'link_before' => '<span class="page-numbers button">',
                    'link_after'  => '</span>',
                )
            );
        ?>
        <?php if( !post_password_required() ) : ?>
        <?php
            if( $prime_business_tags = get_the_tags() ) {
                echo '<span class="meta-sep"></span>';
                foreach( $prime_business_tags as $prime_business_tag ) {
                    $prime_business_sep = ( $prime_business_tag === end( $prime_business_tags ) ) ? '' : ', ';
                    echo '<a href="' . esc_url( get_term_link( $prime_business_tag, $prime_business_tag->taxonomy ) ) . '">#' . esc_html( $prime_business_tag->name ) . '</a>' . esc_html( $prime_business_sep );
                }
            }
        ?>
        <?php endif; ?>

        <div class="pagination-single">
            <div class="pagination-nav clearfix">
                <?php $prime_business_prev_post = get_adjacent_post( false, '', false ); ?>
                <?php if ( is_a( $prime_business_prev_post, 'WP_Post' ) ) { ?>
                <div class="previous-post-wrap">
                    <div class="previous-post">
                        <a href="<?php echo esc_url( get_permalink( get_adjacent_post( false, '', false)->ID ) ); ?>"><?php esc_html_e( 'Previous Post', 'prime-business' ); ?></a>
                    </div><!-- /.previous-post -->
                    <a href="<?php echo esc_url( get_permalink( get_adjacent_post( false, '', false)->ID ) ); ?>" class="prev"><?php echo esc_html( get_the_title( $prime_business_prev_post->ID ) ); ?></a>
                </div><!-- /.previous-post-wrap -->
                <?php } ?>

                <?php $prime_business_next_post = get_adjacent_post( false, '', true ); ?>
                <?php if ( is_a( $prime_business_next_post, 'WP_Post' ) ) { ?>
                <div class="next-post-wrap">
                    <div class="next-post">
                        <a href="<?php echo esc_url( get_permalink( get_adjacent_post( false, '', true)->ID ) ); ?>"><?php esc_html_e( 'Next Post', 'prime-business' ); ?></a>
                    </div><!-- /.next-post -->
                    <a href="<?php echo esc_url( get_permalink( get_adjacent_post( false, '', true)->ID ) ); ?>" class="next"><?php echo esc_html( get_the_title( $prime_business_next_post->ID ) ); ?></a>
                </div><!-- /.next-post-wrap -->
                <?php } ?>
            </div><!-- /.pagination-nav -->
        </div><!-- /.pagination-single-->
    </div><!-- /.post-excerpt -->
</div>
