bbp_get_form_topic_type_dropdown

Returns topic type select box (normal/sticky/super sticky).

Description

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

Parameters (1)

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

Usage

  1. if ( !function_exists( 'bbp_get_form_topic_type_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_type_dropdown($args); 
  7.  

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_form_topic_type_dropdown( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'select_id' => 'bbp_stick_topic',  
  6. 'tab' => bbp_get_tab_index(),  
  7. 'topic_id' => 0,  
  8. 'selected' => false 
  9. ), 'topic_type_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 passed 
  19. } else { 
  20.  
  21. // Edit topic 
  22.  
  23. // Get current topic id 
  24. $topic_id = bbp_get_topic_id( $r['topic_id'] ); 
  25.  
  26. // Topic is super sticky 
  27. if ( bbp_is_topic_super_sticky( $topic_id ) ) { 
  28. $r['selected'] = 'super'; 
  29.  
  30. // Topic is sticky or normal 
  31. } else { 
  32. $r['selected'] = bbp_is_topic_sticky( $topic_id, false ) ? 'stick' : 'unstick'; 
  33.  
  34. // Used variables 
  35. $tab = !empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : ''; 
  36.  
  37. // Start an output buffer, we'll finish it after the select loop 
  38. ob_start(); ?> 
  39.  
  40. <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select"<?php echo $tab; ?>> 
  41.  
  42. <?php foreach ( bbp_get_topic_types() as $key => $label ) : ?> 
  43.  
  44. <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> 
  45.  
  46. <?php endforeach; ?> 
  47.  
  48. </select> 
  49.  
  50. <?php 
  51.  
  52. // Return the results 
  53. return apply_filters( 'bbp_get_form_topic_type_dropdown', ob_get_clean(), $r );