bbp_get_topic_tag_list

Return the tags of a topic.

Description

(string) bbp_get_topic_tag_list( (int) $topic_id = 0, (string) $args = '' ); 

Returns (string)

Tag list of the topic

Parameters (2)

0. $topic_id — Optional. (int)
Topic id
1. $args — Optional. (string) => ''
This function supports these arguments: - before: Before the tag list - sep: Tag separator - after: After the tag list

Usage

  1. if ( !function_exists( 'bbp_get_topic_tag_list' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4. // Optional. Topic id 
  5. $topic_id = -1; 
  6. $args = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bbp_get_topic_tag_list($topic_id, $args); 
  10.  

Defined (1)

The function is defined in the following location(s).

/includes/topics/template.php  
  1. function bbp_get_topic_tag_list( $topic_id = 0, $args = '' ) { 
  2.  
  3. // Bail if topic-tags are off 
  4. if ( ! bbp_allow_topic_tags() ) 
  5. return; 
  6.  
  7. // Parse arguments against default values 
  8. $r = bbp_parse_args( $args, array( 
  9. 'before' => '<div class="bbp-topic-tags"><p>' . esc_html__( 'Tagged:', bbpress ) . ' ',  
  10. 'sep' => ', ',  
  11. 'after' => '</p></div>' 
  12. ), 'get_topic_tag_list' ); 
  13.  
  14. $topic_id = bbp_get_topic_id( $topic_id ); 
  15.  
  16. // Topic is spammed, so display pre-spam terms 
  17. if ( bbp_is_topic_spam( $topic_id ) ) { 
  18.  
  19. // Get pre-spam terms 
  20. $terms = get_post_meta( $topic_id, '_bbp_spam_topic_tags', true ); 
  21.  
  22. // If terms exist, explode them and compile the return value 
  23. if ( !empty( $terms ) ) { 
  24. $terms = implode( $r['sep'], $terms ); 
  25. $retval = $r['before'] . $terms . $r['after']; 
  26.  
  27. // No terms so return emty string 
  28. } else { 
  29. $retval = ''; 
  30.  
  31. // Topic is not spam so display a clickable term list 
  32. } else { 
  33. $retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $r['before'], $r['sep'], $r['after'] ); 
  34.  
  35. return $retval;