bpbbpst_maybe_output_support_field

Outputs a field to specify the topic is a support one.

Description

(string) bpbbpst_maybe_output_support_field(); 

First checks for parent forum support setting

Returns (string)

the html output


Usage

  1. if ( !function_exists( 'bpbbpst_maybe_output_support_field' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddy-bbpress-support-topic/includes/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bpbbpst_maybe_output_support_field(); 
  7.  

Defined (1)

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

/includes/functions.php  
  1. function bpbbpst_maybe_output_support_field() { 
  2. $checked = $output = false; 
  3. $forum_id = bbp_get_forum_id(); 
  4. $topic_id = bbp_get_topic_id(); 
  5.  
  6. if ( empty( $forum_id ) ) { 
  7. $forum_id = bbp_get_topic_forum_id( $topic_id ); 
  8.  
  9. $parent_forum_support_feature = bpbbpst_get_forum_support_setting( $forum_id ); 
  10.  
  11. switch( $parent_forum_support_feature ) { 
  12.  
  13. case 2: 
  14. $output = '<input type="hidden" value="support" name="_bp_bbp_st_is_support" id="bp_bbp_st_is_support_hidden">'; 
  15. break; 
  16.  
  17. case 3: 
  18. $output = false; 
  19. break; 
  20.  
  21. case 1: 
  22. default: 
  23. if ( bbp_is_topic_edit() ) { 
  24.  
  25. $support_status = get_post_meta( $topic_id, '_bpbbpst_support_topic', true ); 
  26.  
  27. if ( ! empty( $support_status ) ) { 
  28. $checked = true; 
  29.  
  30. $output = '<label for="bp_bbp_st_is_support"><input type="checkbox" value="support" name="_bp_bbp_st_is_support" id="bp_bbp_st_is_support" '. checked( true, $checked, false ).'> '. __('This is a support topic', 'buddy-bbpress-support-topic') . '</label>' ; 
  31. break; 
  32.  
  33. if ( empty( $output ) ) { 
  34. return false; 
  35. ?> 
  36. <p> 
  37. <?php echo $output;?> 
  38.  
  39. <?php do_action( 'bpbbpst_output_support_extra_field', $parent_forum_support_feature );?> 
  40.  
  41. <?php wp_nonce_field( 'bpbbpst_support_define', '_wpnonce_bpbbpst_support_define' ); ?> 
  42. </p> 
  43. <?php