<?php
/**
 * WeCodeArt Framework.
 *
 * WARNING: This file is part of the core WeCodeArt Framework. DO NOT edit this file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package 	WeCodeArt Framework
 * @subpackage 	Entry\Meta\Author
 * @since 		3.9.5
 * @version		6.1.3
 */

defined( 'ABSPATH' ) || exit;

use function WeCodeArt\Functions\get_prop;

/**
 * @param   object  $author Author
 * @param   array   $attributes Contains the Block attributes
 */

$attributes = isset( $attributes ) ? $attributes : [];
$classnames = [];

if( $value = get_prop( $attributes, 'textAlign' ) ) {
    $classnames[] = 'has-text-align-' . $value;
}

wecodeart( 'styles' )->Utilities->load( [ 'me-2', 'flex-fill' ] );

?>
<div <?php echo get_block_wrapper_attributes( [ 'class' => implode( ' ', $classnames ) ] ); ?>>
    <?php if( get_prop( $attributes, 'showAvatar' ) ) : ?>
    <div class="wp-block-post-author__avatar me-2"><?php

    echo get_avatar(
        $author->id,
        get_prop( $attributes, 'avatarSize', 48 ), 
        '',
        sprintf( esc_html__( '%s`s avatar', 'wecodeart' ), $author->name )
    );

    ?></div><?php
    
    else : 
    
    wecodeart( 'dom' )->SVG::render( 'user', [
        'class' => 'wp-block-post-author__icon fa-fw'
    ] );

    endif; ?>
    <div class="wp-block-post-author__content flex-fill">
    <?php if( $byline = get_prop( $attributes, 'byline' ) ) : ?>
    <div class="wp-block-post-author__byline has-small-font-size"><?php
    
    echo esc_html( $byline );

    ?></div>
    <?php endif; ?>
    <?php if( get_prop( $attributes, 'isLink', true ) ) : ?>
    <a class="wp-block-post-author__link" href="<?php echo esc_url( $author->url ); ?>" rel="author">
    <?php endif; ?>
        <span class="wp-block-post-author__name"><?php
        
        echo esc_html( $author->name ); 

        ?></span>
    <?php if( get_prop( $attributes, 'isLink', true ) ) : ?>
    </a>
    <?php endif; ?>
    <?php if( get_prop( $attributes, 'showBio' ) && $author->bio ) : ?>
    <div class="wp-block-post-author__bio"><?php echo wp_kses_post( $author->bio ); ?></div>
    <?php endif; ?>
    </div>
</div>