Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2011 09:14:24 PM (15 years ago)
Author:
boonebgorges
Message:

Modifies bp_forum_topic_tag_list() to use tag data from the topic_template global. Displays the topic tags underneath the topic title on the single topic page. Fixes #2281

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-template.php

    r4147 r4149  
    822822                        }
    823823                }
     824               
     825                // Load topic tags
     826                $this->topic_tags = bb_get_topic_tags( $this->topic_id );
    824827
    825828                if ( (int)$this->total_post_count && (int)$this->pag_num ) {
     
    914917                        return false;
    915918        }
    916 
     919       
    917920        return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), $topic_template );
    918921}
     
    11931196         */
    11941197        function bp_get_forum_topic_tag_list( $format = 'string' ) {
    1195                 do_action( 'bbpress_init' );
     1198                global $topic_template;
    11961199               
    1197                 // Pull up the tag objects
    1198                 $tags_data = bb_get_topic_tags( bp_get_the_topic_id() );
     1200                $tags_data = !empty( $topic_template->topic_tags ) ? $topic_template->topic_tags : false;
    11991201               
    1200                 // Convert them to a comma-separated string
    12011202                $tags = array();
    1202                 foreach( $tags_data as $tag_data ) {
    1203                         $tags[] = $tag_data->name;
     1203               
     1204                if ( $tags_data ) {
     1205                        foreach( $tags_data as $tag_data ) {
     1206                                $tags[] = $tag_data->name;
     1207                        }
    12041208                }
    12051209               
     
    12101214        }
    12111215
     1216/**
     1217 * Returns true if the current topic has tags
     1218 *
     1219 * @package BuddyPress
     1220 * @since 1.3
     1221 *
     1222 * @return bool
     1223 */
     1224function bp_forum_topic_has_tags() {
     1225        global $topic_template;
     1226       
     1227        $has_tags = false;
     1228       
     1229        if ( !empty( $topic_template->topic_tags ) )
     1230                $has_tags = true;
     1231       
     1232        return apply_filters( 'bp_forum_topic_has_tags', $has_tags );
     1233}
     1234
    12121235function bp_forum_action() {
    12131236        echo bp_get_forum_action();
Note: See TracChangeset for help on using the changeset viewer.