<?php

/* @var Tangibledesign\MyHome\Widgets\BlogPost\BlogPostAuthorWidget $mhCurrentWidget */
global $mhCurrentWidget;

$mhBlogPost = $mhCurrentWidget->getBlogPost();
if (!$mhBlogPost) {
    return;
}

$mhUser = $mhCurrentWidget->getUser();
if (!$mhUser) {
    return;
}

$mhShowAvatar = $mhCurrentWidget->showAvatar();
$mhShowName = $mhCurrentWidget->showName();
$mhShowJobTitle = $mhCurrentWidget->showJobTitle();
$mhShowDescription = $mhCurrentWidget->showDescription();
?>
<div class="myhome-blog-author-widget">
    <?php if ($mhShowAvatar) : ?>
        <div class="myhome-blog-author-widget__avatar">
            <?php echo esc_html($mhCurrentWidget->getUserInitials()); ?>
        </div>
    <?php endif; ?>
    
    <div class="myhome-blog-author-widget__content">
        <?php if ($mhShowName) : ?>
            <div class="myhome-blog-author-widget__name">
                <?php echo esc_html($mhUser->getDisplayName()); ?>
            </div>
        <?php endif; ?>
        
        <?php if ($mhShowJobTitle) : 
            $mhJobTitle = $mhCurrentWidget->getJobTitleText();
            if (!empty($mhJobTitle)) : ?>
                <div class="myhome-blog-author-widget__job-title">
                    <?php echo esc_html($mhJobTitle); ?>
                </div>
            <?php endif; ?>
        <?php endif; ?>
        
        <?php if ($mhShowDescription) : 
            $mhDescription = $mhUser->getDescription();
            if (!empty($mhDescription)) : ?>
                <div class="myhome-blog-author-widget__description">
                    <?php echo wp_kses_post($mhDescription); ?>
                </div>
            <?php endif; ?>
        <?php endif; ?>
    </div>
</div>