function ap_get_all_parti($avatar_size = 40, $post_id = false) { if (!$post_id) { $post_id = get_the_ID(); } $parti = ap_get_parti($post_id); echo '<h3 class="ap-question-side-title">' . sprintf(_n('<span>1</span> Participant', '<span>%d</span> Participants', count($parti), 'ap'), count($parti)) . '</h3>'; echo '<ul class="ap-participants-list ap-inline-list clearfix">'; foreach ($parti as $p) { ?> <li> <?php echo '<a title="' . ap_user_display_name($p->apmeta_userid, true) . '" href="' . ap_user_link($p->apmeta_userid) . '">'; ?> <?php echo get_avatar($p->apmeta_userid, $avatar_size); ?> <?php echo '</a>'; ?> </li> <?php } echo '</ul>'; }
/** * 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(); }
/** * Print all particpants of a question * @param integer $avatar_size * @param boolean $post_id * @return void * @since 0.4 */ function ap_get_all_parti($avatar_size = 40, $post_id = false) { if (!$post_id) { $post_id = get_question_id(); } $parti = ap_get_parti($post_id); echo '<span class="ap-widget-title">' . sprintf(_n('<span>1</span> Participant', '<span>%d</span> Participants', count($parti), 'ap'), count($parti)) . '</span>'; echo '<div class="ap-participants-list clearfix">'; foreach ($parti as $p) { echo '<a title="' . ap_user_display_name($p->apmeta_userid, true) . '" href="' . ap_user_link($p->apmeta_userid) . '" class="ap-avatar">'; echo get_avatar($p->apmeta_userid, $avatar_size); echo '</a>'; } echo '</div>'; }
/** * Override get_avatar * @param string $avatar Avatar image. * @param integar|string $id_or_email User id or email. * @param string $size Avatar size. * @param string $default Default avatar. * @param string $alt Avatar image alternate text. * @return string */ public function get_avatar($avatar, $id_or_email, $size, $default, $alt) { if (!empty($id_or_email)) { if (is_object($id_or_email)) { $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); if (!empty($id_or_email->comment_type) && !in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { return $avatar; } if (!empty($id_or_email->user_id)) { $id = (int) $id_or_email->user_id; $user = get_userdata($id); if ($user) { $id_or_email = $user->ID; } } else { $id_or_email = 0; } } elseif (is_email($id_or_email)) { $u = get_user_by('email', $id_or_email); $id_or_email = $u->ID; } $ap_avatar = ap_get_avatar_src($id_or_email, $size > 50 ? false : true); if ($ap_avatar !== false) { return "<img data-view='user_avatar_{$id_or_email}' alt='{$alt}' src='{$ap_avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; } } if (strpos($avatar, 'ANSPRESS_AVATAR_SRC') !== false) { $display_name = ap_user_display_name(array('user_id' => $id_or_email)); return '<img data-view="user_avatar_' . $id_or_email . '" alt="' . $alt . '" data-name="' . $display_name . '" data-height="' . $size . '" data-width="' . $size . '" class="avatar avatar-' . $size . ' photo ap-dynamic-avatar" />'; } return $avatar; }
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; }
/** * Add user dropdown and notification menu * @param string $o Menu html. * @param object $item Menu item object. * @param integer $depth Menu depth. * @param object $args Menu args. * @return string */ public function walker_nav_menu_start_el($o, $item, $depth, $args) { if (!is_user_logged_in() && (in_array('anspress-page-profile', $item->classes) || in_array('anspress-page-notification', $item->classes))) { $o = ''; } if (in_array('anspress-page-profile', $item->classes) && is_user_logged_in()) { $menus = ap_get_user_menu(get_current_user_id()); $active_user_page = get_query_var('user_page') ? esc_attr(get_query_var('user_page')) : 'about'; $o = '<a id="ap-user-menu-anchor" class="ap-dropdown-toggle" href="#">'; $o .= get_avatar(get_current_user_id(), 80); $o .= '<span class="name">' . ap_user_display_name(get_current_user_id()) . '</span>'; $o .= ap_icon('chevron-down', true); $o .= '</a>'; $o .= '<ul id="ap-user-menu-link" class="ap-dropdown-menu ap-user-dropdown-menu">'; foreach ($menus as $m) { $class = !empty($m['class']) ? ' ' . $m['class'] : ''; $o .= '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '>'; $o .= '<a href="' . $m['link'] . '" class="ap-user-link-' . $m['slug'] . $class . '">'; $o .= esc_attr($m['title']) . '</a>'; $o .= '</li>'; } $o .= '</ul>'; } elseif (in_array('anspress-page-notification', $item->classes) && is_user_logged_in()) { $o = '<a id="ap-user-notification-anchor" class="ap-dropdown-toggle ' . ap_icon('globe') . '" href="#">' . ap_get_the_total_unread_notification(false, false) . '</a>'; global $ap_notifications; ob_start(); $ap_notifications = ap_get_user_notifications(array('per_page' => 10)); ap_get_template_part('user/notification-dropdown'); $o .= ob_get_clean(); } return $o; }
/** * 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; }
"> <?php echo get_avatar(get_the_author_meta('user_email'), ap_opt('avatar_size_qquestion')); ?> </a> </div> <div class="ap-content-inner no-overflow"> <div class="ap-qmainc"> <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')) . '?rel=author" class="author"><span itemprop="author">%s</span></a> <span class="when">asked about %s ago</span>', 'ap'), ap_user_display_name(false, true), ap_human_time(get_the_time('U'))); ?> </div> </div> <div class="question-content" itemprop="text"> <?php the_content(); ?> </div> <ul class="ap-user-actions clearfix"> <li><?php ap_edit_q_btn_html(); ?> </li>
/** * Get last active time * @param integer $post_id Question or answer ID. * @return string $html HTML formatted? * @since 2.0.1 */ function ap_post_active_time($post_id = false, $html = true) { 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; } if (!$html) { return $activity['date']; } $title = ap_activity_short_title($activity['type']); $title = esc_html('<span class="ap-post-history">' . sprintf(__('%s %s %s', 'ap'), ap_user_display_name($activity['user_id']), $title, '<time datetime="' . mysql2date('c', $activity['date']) . '">' . ap_human_time(mysql2date('U', $activity['date'])) . '</time>') . '</span>'); return sprintf(__('Active %s', 'ap'), '<a class="ap-tip" href="#" title="' . $title . '"><time datetime="' . mysql2date('c', $activity['date']) . '">' . ap_human_time(mysql2date('U', $activity['date']))) . '</time></a>'; }
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 }
public function select_answer($user_id, $question_id, $answer_id) { $post_url = get_permalink($question_id); $post = get_post($post_id); $subject = __('Your answer is selected as a best', 'ap'); $message = sprintf(__('Hello!, <br /><br /> You answer on %s is selected as best by %s <br />', 'ap'), $pos->post_title, ap_user_display_name($user_id, true)); $message .= "<br /><br /><a href='" . $post_url . "'>" . __('View question', 'ap') . "</a><br />"; $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . ' <a href="http://open-wp.com">AnsPress</a></p>'; $emails = ap_get_email_to_notify($post->post_parent, $user_id); if (!empty($emails)) { foreach ($emails as $email) { wp_mail($email, $subject, $message); } } //sends email wp_mail(get_option('admin_email'), $subject, $message); }
/** * Add user dropdown and notification menu * @param string $o Menu html. * @param object $item Menu item object. * @param integer $depth Menu depth. * @param object $args Menu args. * @return string */ public function walker_nav_menu_start_el($o, $item, $depth, $args) { if (!is_user_logged_in() && (ap_is_notification_menu($item) || ap_is_profile_menu($item))) { $o = ''; } if (!ap_is_profile_active() && (ap_is_notification_menu($item) || ap_is_profile_menu($item))) { return ''; } if (in_array('anspress-page-profile', $item->classes) && is_user_logged_in()) { $menus = ap_get_user_menu(get_current_user_id()); $active_user_page = get_query_var('user_page') ? esc_attr(get_query_var('user_page')) : 'about'; $o = '<a id="ap-user-menu-anchor" class="ap-dropdown-toggle" href="#">'; $o .= get_avatar(get_current_user_id(), 80); $o .= '<span class="name">' . ap_user_display_name(get_current_user_id()) . '</span>'; $o .= ap_icon('chevron-down', true); $o .= '</a>'; $o .= '<ul id="ap-user-menu-link" class="ap-dropdown-menu ap-user-dropdown-menu">'; foreach ($menus as $m) { $class = !empty($m['class']) ? ' ' . $m['class'] : ''; $o .= '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '>'; $o .= '<a href="' . $m['link'] . '" class="ap-user-link-' . $m['slug'] . $class . '">'; $o .= $m['title'] . '</a>'; $o .= '</li>'; } $o .= '</ul>'; } elseif (in_array('anspress-page-notification', $item->classes) && is_user_logged_in()) { $o = '<a id="ap-user-notification-anchor" class="ap-dropdown-toggle ap-sidetoggle ' . ap_icon('globe') . '" href="#">' . ap_get_the_total_unread_notification(false, false) . '</a>'; global $ap_activities; /** * Dropdown notification arguments. * Allow filtering of dropdown notification arguments. * @since 2.4.5 * @var array */ $notification_args = apply_filters('ap_dropdown_notification_args', array('per_page' => 20, 'notification' => true, 'user_id' => ap_get_displayed_user_id())); $ap_activities = ap_get_activities($notification_args); ob_start(); ap_get_template_part('user/notification-dropdown'); $o .= ob_get_clean(); } return $o; }
public function ap_trash_answer($post) { if (!ap_opt('notify_admin_trash_answer')) { return; } $current_user = wp_get_current_user(); // don't bother if current user is admin if (ap_opt('notify_admin_email') == $current_user->user_email) { return; } $args = array('{user}' => ap_user_display_name(get_current_user_id()), '{question_title}' => $post->post_title, '{question_link}' => get_permalink($post->post_parent)); $args = apply_filters('ap_trash_answer_email_tags', $args); $subject = $this->replace_tags(ap_opt('trash_answer_email_subject'), $args); $message = $this->replace_tags(ap_opt('trash_answer_email_body'), $args); // sends email $this->send_mail(ap_opt('notify_admin_email'), $subject, $message); }
?> "><?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_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; }
</div> <a class="ap-user-name" href="<?php ap_user_the_link(); ?> "><?php ap_user_the_display_name(); ?> </a> <?php if (!ap_opt('disable_reputation')) { echo '<span class="ap-user-reputation">'; printf(__('%s Rep.', 'ap'), ap_user_get_the_reputation()); echo '</span>'; } ?> </div> <?php $menus = ap_get_user_menu(get_current_user_id()); $active_user_page = get_query_var('user_page'); $active_user_page = $active_user_page ? $active_user_page : 'about'; $item_output = '<a id="ap-user-menu-anchor" href="#">' . get_avatar(get_current_user_id(), 20) . ap_user_display_name(get_current_user_id()) . ap_icon('chevron-down', true) . '</a>'; echo '<ul class="ap-user-widget-links">'; foreach ($menus as $m) { $class = !empty($m['class']) ? ' ' . $m['class'] : ''; echo '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '><a href="' . $m['link'] . '" class="ap-user-link-' . $m['slug'] . $class . '">' . $m['title'] . '</a></li>'; } echo '</ul>'; ?> </div>
/** * @param string $user_id */ function ap_user_link_anchor($user_id, $echo = true) { $name = ap_user_display_name($user_id); if ($user_id < 1) { if ($echo) { echo $name; } else { return $name; } } $html = '<a href="' . ap_user_link($user_id) . '"' . ap_hover_card_attributes($user_id, false) . '>'; $html .= $name; $html .= '</a>'; if ($echo) { echo $html; } return $html; }
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'); } }
public function new_comment($comment, $post_type, $question_id) { $emails = ap_get_email_to_notify($comment->comment_post_ID, $comment->user_id); $post = get_post($question_id); if ($post_type == 'question') { $subject = __('New comment on: ', 'ap') . $post->post_title; $message = sprintf(__('Hello!,<br /><br /> A new comment is posted by %s <br />', 'ap'), ap_user_display_name($comment->user_id, true)); $message .= ap_truncate_chars($comment->comment_content, 100); $message .= "<br /><br /><a href='" . get_comments_link($parent->ID) . "'>" . __('View comment', 'ap') . "</a><br />"; $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . '<a href="http://open-wp.com">AnsPress</a></p>'; if (!empty($emails)) { foreach ($emails as $email) { wp_mail($email, $subject, $message); } } } else { $subject = __('New comment on answer of: ', 'ap') . $post->post_title; $message = sprintf(__('Hello!,<br /><br /> A new comment is posted by %s <br />', 'ap'), ap_user_display_name($comment->user_id, true)); $message .= ap_truncate_chars($comment->comment_content, 100); $message .= "<br /><br /><a href='" . get_comments_link($parent->ID) . "'>" . __('View comment', 'ap') . "</a><br />"; $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . '<a href="http://open-wp.com">AnsPress</a></p>'; if (!empty($emails)) { foreach ($emails as $email) { wp_mail($email, $subject, $message); } } } }
echo ap_user_link($comment->user_id); ?> "> <!-- TODO: OPTION - Avatar size --> <?php 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 $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();
function ap_get_conversation_list($id) { $recipients = ap_get_recipient($id); /* check if user is already in conversation */ if (!is_user_logged_in() && !in_array(get_current_user_id(), $recipients)) { return false; } $messages = ap_get_conversation($id); if ($messages) { echo '<div class="ap-conversation-users clearfix">'; echo '<strong>' . __('Participants', 'ap') . '</strong>'; $users = ap_get_recipient($id); foreach ($users as $u) { echo '<a class="ap-user" href="' . ap_user_link($u) . '">'; echo get_avatar($u, 18); if ($u == get_current_user_id()) { echo __('You', 'ap'); } else { echo ap_user_display_name($u, true); } echo '</a>'; } echo '</div>'; echo '<ul class="ap-message-log ap-nav">'; foreach ($messages as $m) { echo ap_get_message_html($m); } echo '</ul>'; } if (ap_user_can_message()) { ?> <form id="ap-send-message" method="post" action="" data-action="ap-send-message"> <textarea class="form-control autogrow" name="message-content" placeholder="<?php _e('Type your message', 'ap'); ?> "></textarea> <button type="submit" class="ap-btn"><?php _e('Send', 'ap'); ?> </button> <input type="hidden" name="action" value="ap_send_message" /> <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce('new_message'); ?> " /> <input type="hidden" name="conversation" value="<?php echo $id; ?> " /> </form> <?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); ?>
/** * Render Meta Box content. */ public function answers_meta_box_content() { global $answers; $answers = ap_get_answers(array('question_id' => get_the_ID())); if (ap_have_answers()) { while (ap_have_answers()) { ap_the_answer(); ?> <div id="answer_<?php the_ID(); ?> " data-id="<?php the_ID(); ?> " class="ap-ansm clearfix"> <div class="author"> <a class="ap-ansm-avatar" href="<?php ap_answer_the_author_link(); ?> "<?php ap_hover_card_attributes(ap_answer_get_author_id()); ?> > <?php ap_answer_the_author_avatar(); ?> </a> <strong class="ap-ansm-name"><?php echo ap_user_display_name(ap_answer_get_author_id()); ?> </strong> </div> <div class="ap-ansm-inner"> <div class="ap-ansm-meta"> <?php ap_answer_the_active_time(); ?> </div> <div class="ap-ansm-content"><?php the_content(); ?> </div> <div class="answer-actions"> <span><a href="<?php echo get_edit_post_link(get_the_ID()); ?> "><?php _e('Edit', 'ap'); ?> </a></span> <span class="delete vim-d vim-destructive"> | <a href="<?php echo get_delete_post_link(get_the_ID()); ?> "><?php _e('Trash', 'ap'); ?> </a></span> </div> </div> </div> <?php } } else { ?> <div class="inside"> <a href="#addanswerbtn" class="button"><?php _e('Add answer', 'ap'); ?> </a> <?php _e('No answers yet', 'ap'); ?> </div> <?php } wp_reset_postdata(); }
/** * Return notification title * @param string $notification notification type * @return string * @since 2.3 */ function ap_get_notification_title($notification, $args) { $title = array('new_question' => __('New question <b>##post_title</b>', 'ap'), 'new_answer' => __('New answer on <b>##post_title</b>', 'ap'), 'question_update' => __('Your question <b>##post_title</b> has been edited', 'ap'), 'answer_update' => __('Your answer on <b>##post_title</b> has been edited', 'ap'), 'comment_on_question' => __('New comment on question <b>##post_title</b>', 'ap'), 'comment_on_answer' => __('New comment on answer <b>##post_title</b>', 'ap'), 'new_follower' => sprintf(__('<b>%s</b> started following you', 'ap'), ap_user_display_name($args['user_id'])), 'vote_up' => sprintf(__('%s up voted on your post <b>##post_title</b>', 'ap'), ap_user_display_name($args['user_id'])), 'answer_selected' => __('Your answer on <b>##post_title</b> has been selected as best', 'ap'), 'received_reputation' => __('You have received <b>##reputation</b> reputation points', 'ap')); $title = apply_filters('ap_notification_title', $title); if (isset($title[$notification])) { return $title[$notification]; } }
/** * Display user meta * @param boolean $html for html output * @param false|integer $user_id User id, if empty then post author witll be user * @param boolen $echo * @return string */ function ap_user_display_meta($html = false, $user_id = false, $echo = false) { if (false === $user_id) { $user_id = get_the_author_meta('ID'); } $metas = array(); $metas['display_name'] = '<span class="ap-user-meta ap-user-meta-display_name">' . ap_user_display_name(array('html' => true)) . '</span>'; /** * FILTER: ap_user_display_meta_array * Can be used to alter user display meta * @var array */ $metas = apply_filters('ap_user_display_meta_array', $metas, $user_id); $output = ''; if (!empty($metas) && is_array($metas) && count($metas) > 0) { $output .= '<span class="ap-user-meta">'; foreach ($metas as $meta) { $output .= $meta . ' '; } $output .= '</span>'; } if ($echo) { echo $output; } else { return $output; } }
/** * Return active user ID * @return string */ function ap_user_get_the_display_name() { return ap_user_display_name(array('user_id' => ap_user_get_the_ID())); }
function ap_get_latest_history_html($post_id, $avatar = false, $icon = false) { $history = ap_get_latest_history($post_id); $html = ''; if ($history) { if ($icon) { $html .= '<span class="' . ap_history_icon($history['type']) . ' ap-tlicon"></span>'; } if ($avatar) { $html .= '<a class="ap-savatar" href="' . ap_user_link($history['user_id']) . '">' . get_avatar($history['user_id'], 22) . '</a>'; } if ($history['type'] == 'added_label' || $history['type'] == 'removed_label') { $label = ''; $terms = get_terms('question_label', array('include' => explode(',', $history['value']))); if ($terms) { foreach ($terms as $term) { $label .= ap_label_html($term); } } $label .= ' ' . _n('label', 'labels', count($terms), 'ap'); $title = ap_history_name($history['type'], $label); } else { $title = ap_history_name($history['type']); } $html .= '<span class="ap-post-history">' . sprintf(__('%s %s about <time class="updated" datetime="' . mysql2date('c', $history['date']) . '">%s</time> ago', 'ap'), ap_user_display_name($history['user_id']), $title, 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; }