bpbbpst_get_selectbox

Outputs the selectbox of available support status.

Description

bpbbpst_get_selectbox( (int) $support_status = 1, (int) $topic_id = 0 ); 

Parameters (2)

0. $support_status — Optional. (int) => 1
The current support status
1. $topic_id — Optional. (int)
The id of the topic

Usage

  1. if ( !function_exists( 'bpbbpst_get_selectbox' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddy-bbpress-support-topic/includes/functions.php'; 
  3.  
  4. // the current support status 
  5. $support_status = 1; 
  6.  
  7. // the id of the topic 
  8. $topic_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bpbbpst_get_selectbox($support_status, $topic_id); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function bpbbpst_get_selectbox( $support_status = 1, $topic_id = 0 ) { 
  2.  
  3. if ( empty( $topic_id ) ) { 
  4. return; 
  5.  
  6. $all_status = bpbbpst_get_support_status(); 
  7.  
  8. if ( empty( $all_status ) || ! is_array( $all_status ) ) { 
  9. return; 
  10.  
  11. $output = '<span class="support-select-box">'; 
  12. $output .= '<select class="support-select-status" name="_support_status" data-topicsupport="'.$topic_id.'">'; 
  13.  
  14. if ( $topic_id == 'adminlist' ) { 
  15. $output .= '<option value="-1">' . __( 'All support status', 'buddy-bbpress-support-topic' ) .'</option>'; 
  16.  
  17. foreach ( $all_status as $status ) { 
  18.  
  19. if ( $topic_id == 'adminlist' && $status['value'] == 0 ) { 
  20. continue; 
  21.  
  22. $output .= '<option value="'. $status['value'] .'" '; 
  23. $output .= selected( $support_status, $status['value'], false ); 
  24. $output .= '>'. $status['sb-caption'] .'</option>'; 
  25.  
  26. $output .= '</select>'; 
  27.  
  28. // nonce field 
  29. if ( $topic_id != 'adminlist' ) { 
  30. $output .= wp_nonce_field( 'bpbbpst_support_status', '_wpnonce_bpbbpst_support_status', true, false ); 
  31.  
  32. $output .= '</span>'; 
  33.  
  34. return apply_filters( 'bpbbpst_get_selectbox', $output, $support_status, $topic_id ); 
  35.