BBP_Walker_Reply_Dropdown::start_el( string $output, object $object, int $depth, array $args = array(), int $current_object_id )


Description Description

See also See also


Top ↑

Parameters Parameters

$output

(Required) Passed by reference. Used to append additional content.

$object

(Required) Post data object.

$depth

(Required) Depth of post in reference to parent posts. Used for padding.

$args

(Optional) Uses 'selected' argument for selected post to set selected HTML attribute for option element.

Default value: array()

$current_object_id

(Required) Not Used


Top ↑

Source Source

File: includes/common/classes.php

	public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {

		// Set up reply
		$depth++;

		// Get the reply ID
		if ( isset( $args['exclude'][0] ) ) {
			$reply_id = (int) $args['exclude'][0];
		} else {
			$reply_id = bbp_get_reply_id();
		}

		// Get ancestors to determine which items to disable
		$ancestors = bbp_get_reply_ancestors( $object->ID );
		array_push( $ancestors, $object->ID );

		// Determine the indentation
		$pad = str_repeat( ' ', (int) $depth * 3 );

		// Determine reply title (either post_title, or excerpt of post_content)
		$title = ! empty( $object->post_title ) ? $object->post_title : wp_html_excerpt( $object->post_content, 10 );
		$title   = sprintf( esc_html__( '%1$s - %2$s', 'bbpress' ), (int) $object->ID, $title );
		$title   = apply_filters( 'bbp_walker_dropdown_post_title', $title, $output, $object, $depth, $args );

		// Attributes
		$class = 'level-' . (int) $depth;
		$value = (int) $object->ID;

		// Start an output buffer to make late escaping easier
		ob_start(); ?>

		<option class="<?php echo esc_attr( $class ); ?>" value="<?php echo esc_attr( $value ); ?>"<?php selected( $args['selected'], $object->ID ); ?> <?php disabled( in_array( $reply_id, $ancestors ), true ); ?>><?php echo $pad . esc_html( $title ); ?></option>

		<?php

		// Append the output buffer to the $output variable
		$output .= ob_get_clean();
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.