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

global $post;

$give_prefix 		= '_give_';

$form_id 			= $post->ID;
$petition_id        = get_post_meta($form_id, $give_prefix . 'petition_id', true);

$author_name            = conikal_get_author_name($post->post_author);
$author_link            = get_author_posts_url($post->post_author, get_the_author_meta('user_nicename'));
$author_avatar          = conikal_get_avatar_url($post->post_author, array('size' => 64));
$author_avatar_retina   = conikal_get_avatar_url($post->post_author, array('size' => 128));

$user_country   = get_user_meta($post->post_author, 'user_country', true);
$user_city      = get_user_meta($post->post_author, 'user_city', true);
$user_state     = get_user_meta($post->post_author, 'user_state', true);

$content      		= get_post_meta($form_id, $give_prefix . 'form_content', true);
$excerpt 			= conikal_get_excerpt_by_id($form_id, 30, $content);

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

<div class="give-feature-content">
    <h1 class="ui header give-campaign-title" id="give-campaign-title">
        <?php the_title() ?>
    </h1>
    <div class="ui grid">
        <div class="sixteen wide column">
            <a class="truncate" href="<?php echo esc_url($author_link) ?>" data-bjax>
                <img class="ui avatar image lazy" data-src="<?php echo esc_url($author_avatar); ?>" data-retina="<?php echo esc_url($author_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>
                <?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 } ?>
            </a>
        </div>
    </div>
    <div class="ui vertical segment"><?php echo esc_html($excerpt) ?></div>
</div>