bbp_get_form_topic_status_dropdown

Returns topic status downdown.

Description

bbp_get_form_topic_status_dropdown( (string) $args = '' ); 

This dropdown is only intended to be seen by users with the moderate capability. Because of this, no additional capablitiy checks are performed within this function to check available topic statuses.

Parameters (1)

0. $args — Optional. (string) => ''
This function supports these arguments: - select_id: Select id. Defaults to bbp_open_close_topic - tab: Tabindex - topic_id: Topic id - selected: Override the selected option

Usage

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

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_form_topic_status_dropdown( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'select_id' => 'bbp_topic_status',  
  6. 'tab' => bbp_get_tab_index(),  
  7. 'topic_id' => 0,  
  8. 'selected' => false 
  9. ), 'topic_open_close_select' ); 
  10.  
  11. // No specific selected value passed 
  12. if ( empty( $r['selected'] ) ) { 
  13.  
  14. // Post value is passed 
  15. if ( bbp_is_post_request() && isset( $_POST[ $r['select_id'] ] ) ) { 
  16. $r['selected'] = $_POST[ $r['select_id'] ]; 
  17.  
  18. // No Post value was passed 
  19. } else { 
  20.  
  21. // Edit topic 
  22. if ( bbp_is_topic_edit() ) { 
  23. $r['topic_id'] = bbp_get_topic_id( $r['topic_id'] ); 
  24. $r['selected'] = bbp_get_topic_status( $r['topic_id'] ); 
  25.  
  26. // New topic 
  27. } else { 
  28. $r['selected'] = bbp_get_public_status_id(); 
  29.  
  30. // Used variables 
  31. $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : ''; 
  32.  
  33. // Start an output buffer, we'll finish it after the select loop 
  34. ob_start(); ?> 
  35.  
  36. <select name="<?php echo esc_attr( $r['select_id'] ) ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select"<?php echo $tab; ?>> 
  37.  
  38. <?php foreach ( bbp_get_topic_statuses( $r['topic_id'] ) as $key => $label ) : ?> 
  39.  
  40. <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> 
  41.  
  42. <?php endforeach; ?> 
  43.  
  44. </select> 
  45.  
  46. <?php 
  47.  
  48. // Return the results 
  49. return apply_filters( 'bbp_get_form_topic_status_dropdown', ob_get_clean(), $r );