function bb_list_tags($args = null)
{
    $defaults = array('tags' => false, 'format' => 'list', 'topic' => 0, 'list_id' => 'tags-list');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if (!($topic = get_topic(get_topic_id($topic)))) {
        return false;
    }
    if (!is_array($tags)) {
        $tags = bb_get_topic_tags($topic->topic_id);
    }
    if (!$tags) {
        return false;
    }
    $list_id = esc_attr($list_id);
    $r = '';
    switch (strtolower($format)) {
        case 'table':
            break;
        case 'list':
        default:
            $args['format'] = 'list';
            $r .= '<ul id="' . $list_id . '" class="tags-list list:tag">' . "\n";
            foreach ($tags as $tag) {
                $r .= _bb_list_tag_item($tag, $args);
            }
            $r .= '</ul>';
            break;
    }
    echo $r;
}
Example #2
0
     $topic = get_topic($id);
     if (!$topic) {
         die('0');
     }
     $tag_name = rawurldecode($tag_name);
     $x = new WP_Ajax_Response();
     foreach (bb_add_topic_tags($id, $tag_name) as $tag_id) {
         if (!is_numeric($tag_id) || !($tag = bb_get_tag((int) $tag_id, bb_get_current_user_info('id'), $topic->topic_id))) {
             if (!($tag = bb_get_tag($tag_id))) {
                 continue;
             }
         }
         $tag->user_id = bb_get_current_user_info('id');
         $tag_id_val = $tag->tag_id . '_' . $tag->user_id;
         $tag->raw_tag = esc_attr($tag->raw_tag);
         $x->add(array('what' => 'tag', 'id' => $tag_id_val, 'data' => _bb_list_tag_item($tag, array('list_id' => 'tags-list', 'format' => 'list'))));
     }
     $x->send();
     break;
 case 'delete-tag':
     list($tag_id, $user_id) = explode('_', $_POST['id']);
     $tag_id = (int) $tag_id;
     $user_id = (int) $user_id;
     $topic_id = (int) $_POST['topic_id'];
     if (!bb_current_user_can('edit_tag_by_on', $user_id, $topic_id)) {
         die('-1');
     }
     bb_check_ajax_referer("remove-tag_{$tag_id}|{$topic_id}");
     add_action('bb_rpe_tag_removed', 'bb_grab_results', 10, 3);
     $tag = bb_get_tag($tag_id);
     $user = bb_get_user($user_id);