示例#1
0
/**
 * Display the notifications list.
 *
 * @since 0.0.2
 */
function vp_notifications_list()
{
    $user_id = get_current_user_id();
    $notifications = get_user_meta($user_id, 'v2press_notifications', true);
    if (!is_array($notifications) || empty($notifications)) {
        $notifications = array();
    }
    $notifications = array_reverse($notifications);
    $output = '';
    if (empty($notifications)) {
        $output .= '<p class="xlarge center fade">' . __('No notifications yet.', 'v2press') . '</p>';
    } else {
        $output .= '<ul class="notifications-list">';
        foreach ($notifications as $cmt_id) {
            $comment = get_comment($cmt_id);
            $comment_date = $comment->comment_date;
            $comment_content = $comment->comment_content;
            $user_id = $comment->user_id;
            $user_link = vp_get_user_profile_link($user_id, false);
            $user_avatar_link = vp_get_user_avatar_link(24, $user_id);
            $topic_id = $comment->comment_post_ID;
            $topic_title = get_the_title($topic_id);
            $topic_permalink = get_permalink($topic_id);
            $topic_link = '<a href="' . $topic_permalink . '" rel="bookmark">' . esc_attr($topic_title) . '</a>';
            $output .= '<li class="notification-item">' . $user_avatar_link;
            $output .= sprintf(__('%1$s mentioned you when reply %2$s at %3$s', 'v2press'), $user_link, $topic_link, $comment_date);
            $output .= '<div class="notification-content">' . $comment_content . '</div>';
            $output .= '<a class="notification-delete" href="?delete=' . $cmt_id . '">' . _x('delete', 'notification', 'v2press') . '</a></li>';
        }
        $output .= '</ul>';
    }
    echo $output;
}
示例#2
0
/**
 * Display the user's profile avatar link.
 *
 * @since 0.0.1
 */
function vp_user_avatar_link($size = 48, $user_id = false)
{
    echo vp_get_user_avatar_link($size, $user_id);
}