BBP_Walker_Dropdown

Create HTML dropdown list of bbPress forums/topics.

Defined (1)

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

/includes/common/classes.php  
  1. class BBP_Walker_Dropdown extends Walker { 
  2.  
  3. /** 
  4. * @see Walker::$tree_type 
  5. * @since bbPress (r2746) 
  6. * @var string 
  7. */ 
  8. var $tree_type; 
  9.  
  10. /** 
  11. * @see Walker::$db_fields 
  12. * @since bbPress (r2746) 
  13. * @var array 
  14. */ 
  15. var $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); 
  16.  
  17. /** Methods ***************************************************************/ 
  18.  
  19. /** 
  20. * Set the tree_type 
  21. * @since bbPress (r2746) 
  22. */ 
  23. public function __construct() { 
  24. $this->tree_type = bbp_get_forum_post_type(); 
  25.  
  26. /** 
  27. * @see Walker::start_el() 
  28. * @since bbPress (r2746) 
  29. * @param string $output Passed by reference. Used to append additional 
  30. * content. 
  31. * @param object $_post Post data object. 
  32. * @param int $depth Depth of post in reference to parent posts. Used 
  33. * for padding. 
  34. * @param array $args Uses 'selected' argument for selected post to set 
  35. * selected HTML attribute for option element. 
  36. * @param int $current_object_id 
  37. * @uses bbp_is_forum_category() To check if the forum is a category 
  38. * @uses current_user_can() To check if the current user can post in 
  39. * closed forums 
  40. * @uses bbp_is_forum_closed() To check if the forum is closed 
  41. * @uses apply_filters() Calls 'bbp_walker_dropdown_post_title' with the 
  42. * title, output, post, depth and args 
  43. */ 
  44. public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { 
  45. $pad = str_repeat( ' ', (int) $depth * 3 ); 
  46. $output .= '<option class="level-' . (int) $depth . '"'; 
  47.  
  48. // Disable the <option> if: 
  49. // - we're told to do so 
  50. // - the post type is a forum 
  51. // - the forum is a category 
  52. // - forum is closed 
  53. if ( ( true === $args['disable_categories'] ) 
  54. && ( bbp_get_forum_post_type() === $object->post_type ) 
  55. && ( bbp_is_forum_category( $object->ID ) 
  56. || ( !current_user_can( 'edit_forum', $object->ID ) && bbp_is_forum_closed( $object->ID ) 
  57. ) ) { 
  58. $output .= ' disabled="disabled" value=""'; 
  59. } else { 
  60. $output .= ' value="' . (int) $object->ID .'"' . selected( $args['selected'], $object->ID, false ); 
  61.  
  62. $output .= '>'; 
  63. $title = apply_filters( 'bbp_walker_dropdown_post_title', $object->post_title, $output, $object, $depth, $args ); 
  64. $output .= $pad . esc_html( $title ); 
  65. $output .= "</option>\n";