bbp_get_form_forum_status_dropdown( $args = array() )
Return the forum status dropdown
Description Description
Parameters Parameters
- $args
-
(Optional) This function supports these arguments: - select_id: Select id. Defaults to bbp_forum_status - tab: Deprecated. Tabindex - forum_id: Forum id - selected: Override the selected option
Default value: array()
Return Return
(string) HTML select list for selecting forum status
Source Source
File: includes/forums/template.php
function bbp_get_form_forum_status_dropdown( $args = array() ) {
// Backpat for handling passing of a forum ID
if ( is_int( $args ) ) {
$forum_id = (int) $args;
$args = array();
} else {
$forum_id = 0;
}
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'select_id' => 'bbp_forum_status',
'select_class' => 'bbp_dropdown',
'tab' => false,
'forum_id' => $forum_id,
'selected' => false
), 'forum_status_select' );
// No specific selected value passed
if ( empty( $r['selected'] ) ) {
// Post value is passed
if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
$r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
// No Post value was passed
} else {
// Edit topic
if ( bbp_is_forum_edit() ) {
$r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
$r['selected'] = bbp_get_forum_status( $r['forum_id'] );
// New topic
} else {
$r['selected'] = bbp_get_public_status_id();
}
}
}
// Start an output buffer, we'll finish it after the select loop
ob_start(); ?>
<select name="<?php echo esc_attr( $r['select_id'] ) ?>" id="<?php echo esc_attr( $r['select_id'] ) ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>
<?php foreach ( bbp_get_forum_statuses( $r['forum_id'] ) as $key => $label ) : ?>
<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
<?php endforeach; ?>
</select>
<?php
// Filter & return
return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |