/** * Render Meta Box content. */ public function answers_meta_box_content() { $ans_args = array('post_type' => 'answer', 'post_status' => 'publish', 'post_parent' => get_the_ID(), 'showposts' => 10, 'orderby' => 'date', 'order' => 'DESC'); $ans_args = apply_filters('ap_meta_box_answers_query_args', $ans_args); $answers = get_posts($ans_args); if (!empty($answers)) { foreach ($answers as $ans) { ?> <div class="answer clearfix"> <div class="author"> <span><?php echo get_avatar($ans->post_author, 30); ?> </span> <strong><?php echo ap_user_display_name($ans->post_author); ?> </strong> </div> <div class="answer-content"> <div class="submitted-on"> <?php printf(__('%sAnswered about %s ago%s', 'ap'), '<span class="when">', '</span>', ap_human_time(get_the_time('U', $ans))); ?> </div> <p><?php echo $ans->post_content; ?> </p> <div class="row-actions"> <span><a href="<?php echo get_edit_post_link($ans->ID); ?> "><?php _e('Edit', 'ap'); ?> </a></span> <span> | <a href="#"><?php _e('Hide', 'ap'); ?> </a></span> <span class="delete vim-d vim-destructive"> | <a href="<?php echo get_delete_post_link($ans->ID); ?> "><?php _e('Trash', 'ap'); ?> </a></span> </div> </div> </div> <?php } } else { _e('No answers yet', 'ap'); } wp_reset_postdata(); }
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']; }
function ap_comment($comment) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?> "> <!-- comment #<?php comment_ID(); ?> --> <article id="comment-<?php comment_ID(); ?> " class="comment"> <div class="ap-avatar"> <a href="<?php echo ap_user_link($comment->user_id); ?> "> <?php echo get_avatar($comment, ap_opt('avatar_size_qcomment')); ?> </a> </div> <div class="comment-content"> <?php if ('0' == $comment->comment_approved) { ?> <p class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'ap'); ?> </p> <?php } ?> <p class="ap-comment-texts"> <?php echo get_comment_text(); ?> <?php printf(' - <time datetime="%1$s">%2$s %3$s</time>', get_comment_time('c'), ap_human_time(get_comment_time('U')), __('ago', 'ap')); ?> </p> <div class="comment-meta"> <?php if (ap_user_can_edit_comment(get_comment_ID())) { echo '<a class="comment-edit-btn" href="#" data-button="ap-edit-comment" data-args="' . get_comment_ID() . '-' . wp_create_nonce('comment-' . get_comment_ID()) . '"><i class="aicon-pencil"></i> ' . __('Edit', 'ap') . '</a>'; } if (ap_user_can_delete_comment(get_comment_ID())) { echo '<a class="comment-delete-btn" href="#" data-button="ap-delete-comment" data-confirm="' . __('Are you sure? It cannot be undone!', 'ap') . '" data-args="' . get_comment_ID() . '-' . wp_create_nonce('delete-comment-' . get_comment_ID()) . '"><i class="aicon-close"></i> ' . __('Delete', 'ap') . '</a>'; } ?> </div> </div> </article> <?php }
function ap_get_latest_history_html($post_id, $avatar = false, $icon = false) { $history = ap_get_latest_history($post_id); $html = ''; if ($history) { if ($avatar) { $html .= '<a class="ap-savatar" href="' . ap_user_link($history['user_id']) . '">' . get_avatar($history['user_id'], 20) . '</a>'; } if ($icon) { $html .= '<span class="' . ap_history_icon($history['type']) . ' ap-tlicon"></span>'; } $html .= '<span class="ap-post-history">' . sprintf(__('%s %s about %s ago', 'ap'), ap_user_display_name($history['user_id']), ap_history_name($history['type']), ap_human_time(mysql2date('U', $history['date']))) . '</span>'; } elseif (!$icon) { $html = '<span class="ap-post-history">' . sprintf(__('Asked by %s', 'ap'), ap_user_display_name()) . '</span>'; } if ($html) { return apply_filters('ap_latest_history_html', $html); } return false; }
<li class="ap-tip ap-ansslable" title="<?php _e('Answer is accepted', 'ap'); ?> "> <i class="ap-icon-answer"></i> </li> <?php } ?> <li class="list-meta ap-tip" title="<?php _e('Last activity', 'ap'); ?> "> <i class="ap-icon-clock ap-meta-icon"></i> <?php printf('<span class="when">%s %s ago</span>', ap_get_latest_history_html(get_the_ID()), ap_human_time(mysql2date('U', ap_last_active(get_question_id())))); ap_user_display_name(); ?> </li> <li class="ap-tip" title="<?php _e('Question category', 'ap'); ?> "><?php ap_question_categories_html(false, false); ?> </li> <li class="ap-tip" title="<?php _e('Question tagged', 'ap'); ?> "><?php ap_question_tags_html(false, false);
function ap_reputation_get_the_date() { printf(__('%s ago', 'ap'), ap_human_time(ap_reputation_get_date(), false)); }
</div><!-- close .ap-avatar --> <div class="ap-comment-content no-overflow"> <div class="ap-comment-header"> <a href="<?php echo ap_user_link($comment->user_id); ?> " class="ap-comment-author"><?php echo ap_user_display_name($comment->user_id); ?> </a> <?php $a = ' e '; $b = ' '; $time = get_option('date_format') . $b . get_option('time_format') . $a . get_option('gmt_offset'); printf(' - <a title="%3$s" href="#li-comment-%4$s" class="ap-comment-time"><time datetime="%1$s">%2$s</time></a>', get_comment_time('c'), ap_human_time(get_comment_time('U')), get_comment_time($time), get_comment_ID()); // Comment actions ap_comment_actions_buttons(); ?> </div><!-- close .ap-comment-header --> <div class="ap-comment-texts"> <?php comment_text(); ?> </div> <?php /** * ACTION: ap_after_comment_content * Action called after comment content. * * @since 2.0.1
public function flag_meta_box_content($post) { // get all flag message $flag_note = ap_opt('flag_note'); $results = ap_get_all_meta(array('apmeta_type' => 'flag', 'apmeta_actionid' => $post->ID), 10); if (!empty($results)) { foreach ($results as $r) { ?> <div class="flag-item clearfix"> <div class="flagger"> <?php echo get_avatar($r->apmeta_userid, 30); ?> <strong><?php echo ap_user_display_name($r->apmeta_userid); ?> </strong> </div> <div class="flag-message"> <div class="submitted-on"> <?php printf(__('<span class="when">Flagged about %s ago</span>', 'ap'), ap_human_time($r->unix_date)); ?> </div> <strong><?php echo $r->apmeta_value !== NULL ? $flag_note[$r->apmeta_value]['title'] : __('Flagged with custom message', 'ap'); ?> </strong> <span><?php echo $r->apmeta_value !== NULL ? $flag_note[$r->apmeta_value]['description'] : $r->apmeta_param; ?> </span> </div> </div> <?php } } else { _e('No flag yet', 'ap'); } }
</div> </li> <li> <div class="ap-about-stats-item"> <?php echo ap_icon('eye', true); printf(__('%d profile views', 'ap'), ap_user_get_the_meta('__profile_views')); ?> </div> </li> <li> <div class="ap-about-stats-item"> <?php echo ap_icon('clock', true); if (ap_user_get_the_meta('__last_active') != 0) { printf(__('Last seen %s ago', 'ap'), ap_human_time(ap_user_get_the_meta('__last_active'), false)); } else { _e('Never logged in', 'ap'); } ?> </div> </li> </ul><!-- close .ap-about-stats --> </div><!-- close .ap-about-block-c --> </div><!-- close .ap-about-block.user-stats --> <div class="ap-about-block"> <h3><?php echo ap_icon('reputation', true);
function ap_get_message_html($message, $return = true) { $link = ap_user_link($message->message_sender); $o = '<li class="ap-message clearfix"> <div class="ap-avatar">' . ap_user_avatar($message->message_sender, true) . '</div> <div class="no-overflow"> <div class="ap-message-head clearfix"> <strong><a href="' . $link . '">' . ap_user_display_name($message->message_sender, true) . '</a></strong> '; if ($message->message_sender == get_current_user_id()) { $o .= '<div class="ap-message-btns ap-dropdown"> <a href="#" class="btn ap-btn ap-dropdown-toggle ap-icon-arrow-down"></a> <ul class="ap-dropdown-menu"> ' . ap_message_actions_buttons($message) . ' </ul> </div>'; } $o .= '<time>' . sprintf(__('%s ago', 'ap'), ap_human_time($message->message_date, false)) . '</time> </div> <div class="ap-message no-overflow" data-view="ap-message-content"> ' . apply_filters('the_content', stripslashes_deep($message->message_content)) . ' </div> </div> </li>'; $o = apply_filters('ap_get_message_html', $o); if ($return) { return $o; } echo $o; }
function ap_get_latest_history_html($post_id, $initial = false, $avatar = false, $icon = false) { $post = get_post($post_id); $history = get_post_meta($post_id, '__ap_history', true); if (!$history && $initial) { $history['date'] = get_the_time('c', $post_id); $history['user_id'] = $post->post_author; $history['type'] = 'new_' . $post->post_type; } $html = ''; if ($history) { if ($icon) { $html .= '<span class="' . ap_icon($history['type']) . ' ap-tlicon"></span>'; } if ($avatar) { $html .= '<a class="ap-avatar" href="' . ap_user_link($history['user_id']) . '">' . get_avatar($history['user_id'], 22) . '</a>'; } $title = ap_history_title($history['type']); $html .= '<span class="ap-post-history">' . ap_icon('history', true) . sprintf(__(' %s %s %s ago', 'ap'), ap_user_display_name($history['user_id']), $title, '<time datetime="' . mysql2date('c', $history['date']) . '">' . ap_human_time($history['date'], false) . '</time>') . '</span>'; } if ($html) { return apply_filters('ap_latest_history_html', $html); } return false; }
echo get_avatar($comment->user_id, 30); ?> </a> </div><!-- close .ap-avatar --> <div class="ap-comment-content no-overflow"> <div class="ap-comment-header"> <a href="<?php echo ap_user_link($comment->user_id); ?> " class="ap-comment-author"><?php echo ap_user_display_name($comment->user_id); ?> </a> <?php printf(' - <a href="#li-comment-%3$s" class="ap-comment-time"><time datetime="%1$s">%2$s</time></a>', get_comment_time('c', true), ap_human_time(get_comment_time('U', true)), get_comment_ID()); // Comment actions. ap_comment_actions_buttons(); ?> </div><!-- close .ap-comment-header --> <div class="ap-comment-texts"> <?php comment_text(); ?> </div> <?php /** * ACTION: ap_after_comment_content * Action called after comment content. * * @since 2.0.1
?> " data-id="<?php echo get_the_ID(); ?> "> <div class="ap-content clearfix"> <div class="ap-content-inner"> <div class="ap-user-meta"> <div class="ap-avatar"> <?php echo get_avatar(get_the_author_meta('user_email'), ap_opt('avatar_size_question')); ?> </div> <div class="ap-meta"> <?php printf(__('<span class="when">answered about %s ago</span>', 'ap'), ap_human_time(get_the_time('U'))); ?> </div> </div> <div class="answer-content"> <strong class="ap-answer-title"><?php echo get_the_title($answer->post->post_parent); ?> </strong> <?php echo ap_truncate_chars(strip_tags(get_the_content()), 100); ?> <div class="ap-ans-action"> <a href="<?php echo ap_answer_edit_link();
/** * Activity date */ function ap_activity_the_date() { echo ap_human_time(ap_activity_date(), false); }
function ap_comment($comment) { $GLOBALS['comment'] = $comment; $class = '0' == $comment->comment_approved ? ' pending' : ''; ?> <li <?php comment_class('clearfix' . $class); ?> id="li-comment-<?php comment_ID(); ?> "> <!-- comment #<?php comment_ID(); ?> --> <div id="comment-<?php comment_ID(); ?> " class="clearfix"> <div class="ap-avatar ap-pull-left"> <a href="<?php echo ap_user_link($comment->user_id); ?> "> <!-- TODO: OPTION - Avatar size --> <?php echo get_avatar($comment->user_id, 30); ?> </a> </div> <div class="ap-comment-content no-overflow"> <div class="ap-comment-header"> <a href="<?php echo ap_user_link($comment->user_id); ?> " class="ap-comment-author"><?php echo ap_user_display_name($comment->user_id); ?> </a> <?php $a = " e "; $b = " "; $time = get_option('date_format') . $b . get_option('time_format') . $a . get_option('gmt_offset'); printf(' - <a title="%4$s" href="#li-comment-%5$s" class="ap-comment-time"><time datetime="%1$s">%2$s %3$s</time></a>', get_comment_time('c'), ap_human_time(get_comment_time('U')), __('ago', 'ap'), get_comment_time($time), $comment_id = get_comment_ID()); // Comment actions ap_comment_actions_buttons(); ?> </div> <div class="ap-comment-texts"> <?php comment_text(); ?> </div> <?php /** * ACTION: ap_after_comment_content * Action called after comment content * @since 2.0.1 */ do_action('ap_after_comment_content', $comment); ?> <?php if ('0' == $comment->comment_approved) { ?> <p class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'ap'); ?> </p> <?php } ?> </div> </div> <?php }
function ap_question_get_the_time_relative($question_id = false) { $question_id = ap_parameter_empty($question_id, @ap_question_get_the_ID()); return ap_human_time(ap_question_get_the_time($question_id, 'U')) . __(' ago', 'ap'); }
/** * Get latest activity of question or answer. * @param integer $post_id Question or answer ID. * @return string */ function ap_latest_post_activity_html($post_id = false) { if (false === $post_id) { $post_id = get_the_ID(); } $post = get_post($post_id); $activity = ap_post_activity_meta($post_id); if (!$activity) { $activity['date'] = get_the_time('c', $post_id); $activity['user_id'] = $post->post_author; $activity['type'] = 'new_' . $post->post_type; } $html = ''; if ($activity) { $title = ap_activity_short_title($activity['type']); $html .= '<span class="ap-post-history">'; $html .= sprintf(__(' %s %s %s ago', 'ap'), '<a href="' . ap_user_link($activity['user_id']) . '">' . ap_user_display_name($activity['user_id']) . '</a>', $title, '<a href="' . get_permalink($post) . '"><time datetime="' . mysql2date('c', $activity['date']) . '">' . ap_human_time($activity['date'], false) . '</time></a>'); $html .= '</span>'; } if ($html) { return apply_filters('ap_latest_post_activity_html', $html); } return false; }
function ap_answer_the_time($answer_id = false, $format = 'U') { $answer_id = ap_parameter_empty($answer_id, @ap_answer_get_the_answer_id()); printf(__('<time itemprop="datePublished" datetime="%s">%s Ago</time>', 'ap'), ap_answer_get_the_time(false, 'c'), ap_human_time(ap_answer_get_the_time($answer_id, $format))); }
</li> <li> <?php $count = ap_count_ans(get_the_ID()); printf(_n('<span>Answer</span><strong data-view="ap-answer-count-label">1 Answer</strong>', '<span>Answers</span><strong data-view="ap-answer-count-label">%d Answers</strong>', $count, 'ap'), $count); ?> </li> <li> <?php $view_count = ap_get_qa_views(); printf(_n('<span>Viewed</span><strong>1 Times</strong>', '<span>Viewed</span><strong>%d Times</strong>', $view_count, 'ap'), $view_count); ?> </li> <li> <?php printf(__('<span>Active</span><strong><time class="updated" itemprop="dateUpdated" datetime="%s">%s Ago</time></strong>', 'ap'), mysql2date('c', ap_last_active(get_question_id())), ap_human_time(mysql2date('U', ap_last_active(get_question_id())))); ?> </li> </ul> </div> </div> <?php comments_template(); ?> </div> </div> </div> <?php if (ap_have_ans(get_the_ID())) { ap_answers_list(get_the_ID(), 'voted');
</div> </li> <li> <div class="ap-about-stats-item"> <?php echo ap_icon('eye', true); printf(__('%d profile views', 'anspress-question-answer'), ap_user_get_the_meta('__profile_views')); ?> </div> </li> <li> <div class="ap-about-stats-item"> <?php echo ap_icon('clock', true); if (ap_user_get_the_meta('__last_active') != 0) { printf(__('Last seen %s', 'anspress-question-answer'), ap_human_time(ap_user_get_the_meta('__last_active'), false)); } else { _e('Never logged in', 'anspress-question-answer'); } ?> </div> </li> </ul><!-- close .ap-about-stats --> </div><!-- close .ap-about-block-c --> </div><!-- close .ap-about-block.user-stats --> <?php do_action('ap_user_about_block_after_status'); ?>
/** * Activity date */ function ap_activity_the_date() { printf(__('%s ago', 'ap'), ap_human_time(ap_activity_date(), false)); }
<div id="ap-user-badges"> <ul class="ap-list-badges"> <?php if ($user_badges) { foreach ($user_badges as $b) { echo '<li><ul class="ap-badge-item clearfix">'; $badge = ap_badge_by_id($b->badge_id); echo '<li class="ap-badge-type"><i class="ap-icon-badge badge-' . $badge['type'] . '"></i><span>' . $badge['type'] . '</span></li>'; echo '<li class="ap-badge-info"><strong>' . $badge['title'] . '</strong><span>' . sprintf($badge['description'], $badge['value']) . '</span></li>'; echo '<li class="ap-total-badge">' . sprintf(_n('<span>1</span> Badge', '<span>%d</span> Badges', $count_badges[$b->badge_id], 'ap'), $count_badges[$b->badge_id]) . '</li>'; echo '<li class="ap-badge-date ap-icon-clock">' . ap_human_time($b->date, false) . '</li>'; echo '</ul></li>'; } } else { echo '<li class="ap-nobadges">' . __('No badges earned yet!', 'ap') . '</li>'; } ?> </ul> </div>
/** * Process ajax trash posts callback */ public function delete_post() { $post_id = (int) $_POST['post_id']; $action = 'delete_post_' . $post_id; if (!wp_verify_nonce($_POST['__nonce'], $action) || !ap_user_can_delete($post_id)) { $this->something_wrong(); } $post = get_post($post_id); if (time() > get_the_time('U', $post->ID) + (int) ap_opt('disable_delete_after') && !is_super_admin()) { $this->send(array('message_type' => 'warning', 'message' => sprintf(__('This post was created %s, its locked hence you cannot delete it.', 'anspress-question-answer'), ap_human_time(get_the_time('U', $post->ID))))); } wp_trash_post($post_id); if ($post->post_type == 'question') { do_action('ap_wp_trash_question', $post_id); $this->send(array('action' => 'delete_question', 'do' => array('redirect' => ap_base_page_link()), 'message' => 'question_moved_to_trash')); } else { do_action('ap_wp_trash_answer', $post_id); $current_ans = ap_count_published_answers($post->post_parent); $count_label = sprintf(_n('1 Answer', '%d Answers', $current_ans, 'anspress-question-answer'), $current_ans); $remove = !$current_ans ? true : false; $this->send(array('action' => 'delete_answer', 'div_id' => '#answer_' . $post_id, 'count' => $current_ans, 'count_label' => $count_label, 'remove' => $remove, 'message' => 'answer_moved_to_trash', 'view' => array('answer_count' => $current_ans, 'answer_count_label' => $count_label))); } }
/** * Output answer time in human readable format * @param boolean|integer $answer_id If outside of loop, post ID can be passed. * @param integer $format WP time format. * @return void */ function ap_answer_the_time($answer_id = false, $format = 'U') { $answer_id = ap_parameter_empty($answer_id, @ap_answer_get_the_answer_id()); printf(esc_attr__('%s Ago', 'ap'), '<a href="' . get_permalink($answer_id) . '"><time itemprop="datePublished" datetime="%s">' . ap_human_time(ap_answer_get_the_time($answer_id, $format)) . '</time></a>'); }
/** * Output answer time in human readable format * @param boolean|integer $answer_id If outside of loop, post ID can be passed. * @param integer $format WP time format. * @return void */ function ap_answer_the_time($answer_id = false, $format = 'U') { $answer_id = ap_parameter_empty($answer_id, @ap_answer_get_the_answer_id()); echo '<a href="' . get_permalink($answer_id) . '"><time itemprop="datePublished" datetime="' . ap_answer_get_the_time($answer_id, 'c') . '">' . ap_human_time(ap_answer_get_the_time($answer_id, $format)) . '</time></a>'; }
?> "><?php _e('Trash post', 'ap'); ?> </a></span> </div> <div class="post-content"> <?php the_content(); ?> </div> </div> <?php if (!empty($flags) && is_array($flags)) { echo '<table class="ap-flagger-table"><tbody>'; foreach ($flags as $flag) { echo '<tr class="flag-item">'; echo '<td class="ap-user-avatar">' . get_avatar($flag->apmeta_userid, 30) . '</td>'; echo '<td class="ap-when-flagged">' . sprintf(__('%s flagged this post %s ago', 'ap'), '<a href="' . get_edit_user_link($flag->apmeta_userid) . '">' . ap_user_display_name($flag->apmeta_userid) . '</a>', ap_human_time($flag->unix_date)) . '</td>'; echo '<td class="ap-remove-flag"><a href="__nonce=' . wp_create_nonce('flag_delete' . $flag->apmeta_id) . '&action=ap_delete_flag&id=' . $flag->apmeta_id . '" data-action="ap-delete-flag">' . __('Remove', 'ap') . '</a></td>'; echo '</tr>'; } echo '</tbody></table>'; } else { _e('No one flagged this post yet', 'ap'); } ?> </div> </div>
function ap_reputation_get_the_date() { echo ap_human_time(ap_reputation_get_date(), false); }
function ap_question_the_time($question_id = false, $format = 'U') { $question_id = ap_parameter_empty($question_id, @ap_question_get_the_ID()); printf(__('%s %s', 'ap'), '<a href="' . get_permalink($question_id) . '"><time itemprop="datePublished" datetime="' . ap_question_get_the_time(false, 'c') . '">' . ap_human_time(ap_question_get_the_time($question_id, $format)), '</time></a>'); }
function ap_notification_the_date() { printf(__('%s ago', 'ap'), ap_human_time(ap_notification_date(), false)); }
</a> <?php echo ap_select_answer_btn_html(get_the_ID()); ?> </div> <div class="ap-content-inner no-overflow"> <div class="ap-amainc"> <div class="ap-user-meta"> <div class="ap-single-vote"> <?php ap_vote_html(); ?> </div> <div class="ap-meta"> <?php printf(__('<a href="' . ap_user_link(get_the_author_meta('ID')) . '" class="author"><span>%s</span></a> <span class="when">answered about %s ago</span>', 'ap'), ap_user_display_name(false, true), ap_human_time(get_the_time('U'))); ?> </div> </div> <div class="answer-content" itemprop="text"> <?php the_content(); ?> </div> <ul class="ap-user-actions clearfix"> <li><?php ap_edit_a_btn_html(); ?> </li> <li><?php