<?php
/**
 * Displays Author bio in single post
 *
 * @package Purenote
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$purenote_single_posts_author_enable = purenote_get_customizer_option_value( 'purenote_single_posts_author_enable' );

if ( ! is_single() || false === $purenote_single_posts_author_enable ) {
    return;
}

/**
 * hook - purenote_before_author_box
 * 
 * @since 1.0.0
 */
do_action( 'purenote_before_author_box' );

$author_id         = get_the_author_meta( 'ID' );
$author_avatar     = get_avatar( $author_id, 'thumbnail' );
$author_post_link  = get_the_author_posts_link();
$author_bio        = get_the_author_meta( 'description' );
$author_url        = get_the_author_meta( 'user_url' );

?>

<div class="post-author-box-wrapper">

        <?php if ( $author_avatar ) { ?>
            <div class="purenote-author__avatar">
                <?php echo wp_kses_post( $author_avatar ); ?>
            </div><!-- .purenote-author-avatar -->
        <?php } ?>

        <div class="purenote-author-info">
            <?php if ( $author_post_link ) { ?>
                    <h5 class="purenote-author-name"><?php echo wp_kses_post( $author_post_link ); ?></h5>
            <?php } ?>

            <?php if ( $author_bio ) { ?>
                <div class="purenote-author-bio">
                    <?php echo wp_kses_post( $author_bio ); ?>
                </div><!-- .purenote-author-bio -->
            <?php } ?>

            <div class="purenote-author-meta">
                <?php if ( $author_url ) { ?>
                    <div class="purenote-author-website">
                        <span><?php esc_html_e( 'Website', 'purenote' ); ?></span>
                        <a href="<?php echo esc_url( $author_url ); ?>" target="_blank"><?php echo esc_url( $author_url ); ?></a>
                    </div><!-- .purenote-author-website -->
                <?php } ?>
            </div><!-- .purenote-author-meta -->
        </div><!-- .purenote-author-info -->
</div><!-- .post-author-box-wrapper -->

<?php
/**
 * hook - purenote_after_author_box
 * 
 * @since 1.0.0
 */
do_action( 'purenote_after_author_box' );