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

global $post;
global $campoal_options;

$updates_per_page       = isset($campoal_options['conikal_updates_per_page_field']) ? $campoal_options['conikal_updates_per_page_field'] : 5;

$give_prefix 		    = '_give_';

$form_id 			    = $post->ID;
$time 				    = human_time_diff(get_the_time('U', $form_id), current_time('timestamp'));
$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) );

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

<div class="give-updates-section">
    <div id="updates<?php echo esc_attr($form_id) ?>" class="update-list" data-id="<?php echo esc_attr($form_id) ?>" data-load="0">
        <h2 class="ui dividing header"><?php esc_html_e('Updates', 'campoal') ?></h2>
        <div id="update-list<?php echo esc_attr($form_id) ?>"></div>
        <div class="ui hidden divider"></div>
        <div class="ui basic fluid button updates-more" id="updates-more<?php echo esc_attr($form_id) ?>" data-offset="<?php echo esc_attr($updates_per_page) ?>"><i class="long arrow down icon"></i><?php esc_html_e('More updates...', 'campoal') ?></div>
    </div>

    <!-- AUTHOR -->
    <div class="ui secondary segment give-author-content">
        <div class="ui small header">
            <img class="ui circular image lazy" data-src="<?php echo esc_url($author_avatar); ?>" data-retina="<?php echo esc_url($author_avatar); ?>" src="<?php echo esc_url($lazy_placeholder_avatar); ?>" alt="<?php echo esc_attr($author_name) ?>">
            <div class="content">
                <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' )); ?>" class="header truncate" data-bjax>
                    <?php echo esc_html($author_name) ?>
                </a>
                <div class="sub header truncate">
                    <strong><?php esc_html_e('Started this project', 'campoal') ?></strong>
                    <span class="text grey"><?php echo sprintf(esc_html__('%s ago', 'campoal'), esc_html($time)) ?></span>
                </div>
            </div>
        </div>
    </div>
</div>
