bbp_get_form_topic_tags

Return value of topic tags field.

Description

(string) bbp_get_form_topic_tags(); 

Returns (string)

Value of topic tags field


Usage

  1. if ( !function_exists( 'bbp_get_form_topic_tags' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_form_topic_tags(); 
  7.  

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_form_topic_tags() { 
  2.  
  3. // Get _POST data 
  4. if ( bbp_is_post_request() && isset( $_POST['bbp_topic_tags'] ) ) { 
  5. $topic_tags = $_POST['bbp_topic_tags']; 
  6.  
  7. // Get edit data 
  8.  
  9. // Determine the topic id based on the post type 
  10. switch ( get_post_type() ) { 
  11.  
  12. // Post is a topic 
  13. $topic_id = get_the_ID(); 
  14. break; 
  15.  
  16. // Post is a reply 
  17. $topic_id = bbp_get_reply_topic_id( get_the_ID() ); 
  18. break; 
  19.  
  20. // Topic exists 
  21. if ( !empty( $topic_id ) ) { 
  22.  
  23. // Topic is spammed so display pre-spam terms 
  24. if ( bbp_is_topic_spam( $topic_id ) ) { 
  25.  
  26. // Get pre-spam terms 
  27. $new_terms = get_post_meta( $topic_id, '_bbp_spam_topic_tags', true ); 
  28.  
  29. // If terms exist, explode them and compile the return value 
  30. if ( empty( $new_terms ) ) { 
  31. $new_terms = ''; 
  32.  
  33. // Topic is not spam so get real terms 
  34. } else { 
  35. $terms = array_filter( (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ) ); 
  36.  
  37. // Loop through them 
  38. foreach ( $terms as $term ) { 
  39. $new_terms[] = $term->name; 
  40.  
  41. // Define local variable(s) 
  42. } else { 
  43. $new_terms = ''; 
  44.  
  45. // Set the return value 
  46. $topic_tags = ( !empty( $new_terms ) ) ? implode( ', ', $new_terms ) : ''; 
  47.  
  48. // No data 
  49. } else { 
  50. $topic_tags = ''; 
  51.  
  52. return apply_filters( 'bbp_get_form_topic_tags', esc_attr( $topic_tags ) );