<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
global $post;
global $current_user;

$decisionmakers_display = isset($campoal_options['conikal_decisionmakers_display_field']) ? $campoal_options['conikal_decisionmakers_display_field'] : 1;

$receiver       = conikal_get_decistion_makers($id, true, $decisionmakers_display);

$user_country   = get_user_meta(get_the_author_meta( 'ID' ), 'user_country', true);
$user_city      = get_user_meta(get_the_author_meta( 'ID' ), 'user_city', true);
$user_state     = get_user_meta(get_the_author_meta( 'ID' ), 'user_state', true);

// get author
$avatar         = conikal_get_avatar_url( get_the_author_meta('ID'), array('size' => 64) );
$avatar_retina  = conikal_get_avatar_url( get_the_author_meta('ID'), array('size' => 128) );
$author_name    = conikal_get_author_name(get_the_author_meta('ID'));

// lazy placeholder
$lazy_placeholder_avatar = conikal_lazy_load_placeholder('avatar');
?>

<div class="ui basic padded vertical segment petition-title-block">
    <div class="ui center aligned huge header petition-title">
        <div class="content">
            <div class="sub header petition-to"><?php echo conikal_custom_icon('send') ?><?php echo sprintf(esc_html__('Petition to %s', 'campoal'), esc_html($receiver)) ?></div>
            <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
        </div>
    </div>
    <div class="ui center aligned small header">
        <div class="sub header">
            <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' )); ?>" data-bjax>
                <img class="ui avatar image lazy" data-src="<?php echo esc_url($avatar); ?>" data-retina="<?php echo esc_url($avatar_retina); ?>" src="<?php echo esc_url($lazy_placeholder_avatar); ?>" alt="<?php echo esc_attr($author_name) ?>">
                <strong><?php echo esc_html($author_name) ?></strong>
            </a>
            <?php if ($user_country || $user_state || $user_city) { ?>
                <span class="text grey"> · 
                    <?php echo esc_html($user_city ? $user_city . ', ' : '') . esc_html($user_state ? $user_state . ', ' : '') . esc_html($user_country ? $user_country : '') ?>
                 </span>
            <?php } ?>
        </div>
    </div>
</div>