BBP_Walker_Dropdown
Create HTML dropdown list of bbPress forums/topics.
Description Description
Source Source
File: includes/common/classes.php
class BBP_Walker_Dropdown extends Walker { /** * @see Walker::$tree_type * * @since 2.0.0 bbPress (r2746) * * @var string */ public $tree_type = 'forum'; /** * @see Walker::$db_fields * * @since 2.0.0 bbPress (r2746) * * @var array */ public $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); /** Methods ***************************************************************/ /** * Set the tree_type * * @since 2.0.0 bbPress (r2746) */ public function __construct() { $this->tree_type = bbp_get_forum_post_type(); } /** * @see Walker::start_el() * * @since 2.0.0 bbPress (r2746) * * @param string $output Passed by reference. Used to append additional * content. * @param object $object Post data object. * @param int $depth Depth of post in reference to parent posts. Used * for padding. * @param array $args Uses 'selected' argument for selected post to set * selected HTML attribute for option element. * @param int $current_object_id */ public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { $pad = str_repeat( ' ', (int) $depth * 3 ); $output .= '<option class="level-' . (int) $depth . '"'; // Disable the <option> if: // - we're told to do so // - the post type is a forum // - the forum is a category // - forum is closed if ( ( true === $args['disable_categories'] ) && ( bbp_get_forum_post_type() === $object->post_type ) && ( bbp_is_forum_category( $object->ID ) || ( ! current_user_can( 'edit_forum', $object->ID ) && bbp_is_forum_closed( $object->ID ) ) ) ) { $output .= ' disabled="disabled" value=""'; } else { $output .= ' value="' . (int) $object->ID .'"' . selected( $args['selected'], $object->ID, false ); } $output .= '>'; $title = apply_filters( 'bbp_walker_dropdown_post_title', $object->post_title, $output, $object, $depth, $args ); $output .= $pad . esc_html( $title ); $output .= "</option>\n"; } }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
Methods Methods
- __construct — Set the tree_type
- start_el