bbp_get_form_forum_status_dropdown

Return the forum status dropdown.

Description

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

Returns (string)

HTML select list for selecting forum status

Parameters (1)

0. $args — Optional. (string) => ''
The forum id to use

Usage

  1. if ( !function_exists( 'bbp_get_form_forum_status_dropdown' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3.  
  4. // The forum id to use 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_form_forum_status_dropdown($args); 
  9.  

Defined (1)

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

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