bpbbpst_add_support_mention

Hooks bbp_theme_before_topic_title to add the support mention before the topic title.

Description

(string) bpbbpst_add_support_mention( (int) $topic_id = 0, (bool) $echo = true ); 

Returns (string)

the html output containing the support status

Parameters (2)

0. $topic_id — Optional. (int)
The topic id.
1. $echo — Optional. (bool) => true
True to display, false to return

Usage

  1. if ( !function_exists( 'bpbbpst_add_support_mention' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddy-bbpress-support-topic/includes/functions.php'; 
  3.  
  4. // The topic id. 
  5. $topic_id = -1; 
  6.  
  7. // true to display, false to return 
  8. $echo = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bpbbpst_add_support_mention($topic_id, $echo); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function bpbbpst_add_support_mention( $topic_id = 0, $echo = true ) { 
  2. $class = false; 
  3. $output = ''; 
  4.  
  5. if ( empty( $topic_id ) ) { 
  6. $topic_id = bbp_get_topic_id(); 
  7.  
  8. // Since 2.0, we first need to check parent forum has support for support :) 
  9. $forum_id = bbp_get_topic_forum_id( $topic_id ); 
  10.  
  11. if ( empty( $forum_id ) ) { 
  12. return; 
  13.  
  14. /** 
  15. * See bpbbpst_display_forum_setting_options() for a description 
  16. * of the different forum types 
  17. */ 
  18. $forum_status = bpbbpst_get_forum_support_setting( $forum_id ); 
  19.  
  20. if ( 3 == $forum_status ) { 
  21. return; 
  22.  
  23. $support_status = get_post_meta( $topic_id, '_bpbbpst_support_topic', true ); 
  24. $status = ''; 
  25.  
  26. if ( empty( $support_status ) ) { 
  27.  
  28. if ( ! empty( $echo ) ) { 
  29. do_action( 'bpbbpst_add_support_mention_action', $forum_id, $forum_status, $topic_id ); 
  30. } else { 
  31. $output = apply_filters( 'bpbbpst_add_support_mention_filter', '', $forum_id, $forum_status, $topic_id ); 
  32.  
  33. return $output; 
  34.  
  35. /** new since 2.0 */ 
  36. $status = bpbbpst_get_selected_support_status( $support_status ); 
  37.  
  38. if ( empty( $status ) || ! is_array( $status ) ) { 
  39. return; 
  40.  
  41. // Build the output 
  42. $output = apply_filters( 
  43. 'bpbbpst_add_support_mention',  
  44. '<span class="bbp-st-topic-support '. sanitize_html_class( $status['class'] ).'">'. $status['prefix-title'] .'</span>',  
  45. $forum_id,  
  46. $forum_status,  
  47. $topic_id 
  48. ); 
  49.  
  50. if ( ! empty( $echo ) ) { 
  51. echo $output; 
  52. } else { 
  53. return $output;