<?php
/**
 * Partial template to display author box
 *
 * @package Blogbuster
 */

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

$blogbuster_single_posts_author_enable = blogbuster_get_customizer_option_value( 'blogbuster_single_posts_author_enable' );

if ( false === $blogbuster_single_posts_author_enable ) {
    return;
}

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


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

?>
    <div class="blogbuster-author-container" <?php blogbuster_schema_markup( 'avatar' ); ?>>

        <div class="blogbuster-author-image">
            <?php echo wp_kses_post( $author_avatar ); ?>
        </div> <!-- blogbuster-author-image -->

        <div class="blogbuster-author-info">

            <h3 class="author-nicename" <?php blogbuster_schema_markup( 'author_name' ); ?>>
                <a href="<?php echo esc_url( $author_link ); ?>"><?php echo esc_html( get_the_author_meta( 'user_nicename', $author_id ) ); ?></a>
            </h3>

            <span class="author-website" <?php blogbuster_schema_markup( 'author_link' ); ?>><?php esc_html_e( 'Website: ' , 'blogbuster' );?> <a href="<?php echo esc_url( $author_url ); ?>" target="_blank"><?php echo esc_url( $author_url ); ?></a></span>
            <span class="author-description" <?php blogbuster_schema_markup( 'description' ); ?>><?php wp_kses_post ( $author_bio ); ?></span>
            
        </div><!-- blogbuster-author-info -->

    </div><!-- blogbuster-author-container -->

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