Exemplo n.º 1
0
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', @$instance['title']);
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $ans_count = ap_question_get_the_answer_count();
     $last_active = ap_question_get_the_active_ago();
     $total_subs = ap_question_get_the_subscriber_count();
     $view_count = ap_question_get_the_view_count();
     echo '<div class="ap-widget-inner">';
     if (is_question()) {
         echo '<ul class="ap-stats-widget">';
         echo '<li><span class="stat-label apicon-pulse">' . __('Active', 'ap') . '</span><span class="stat-value"><time class="published updated" itemprop="dateModified" datetime="' . mysql2date('c', $last_active) . '">' . ap_human_time(mysql2date('U', $last_active)) . '</time></span></li>';
         echo '<li><span class="stat-label apicon-eye">' . __('Views', 'ap') . '</span><span class="stat-value">' . sprintf(_n('One time', '%d times', $view_count, 'ap'), $view_count) . '</span></li>';
         echo '<li><span class="stat-label apicon-answer">' . __('Answers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('%2$s1%3$s answer', '%2$s%1$d%3$s answers', $ans_count, 'ap'), $ans_count, '<span data-view="answer_count">', '</span>') . '</span></li>';
         echo '<li><span class="stat-label apicon-mail">' . __('Followers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('1 follower', '%d followers', $total_subs, 'ap'), $total_subs) . '</span></li>';
         echo '</ul>';
     } else {
         _e('This widget can only be used in single question page', 'ap');
     }
     echo '</div>';
     echo $args['after_widget'];
 }
Exemplo n.º 2
0
/**
 * Echo view count for current question
 * @since 2.1
 */
function ap_question_the_view_count()
{
    echo ap_question_get_the_view_count();
}