diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 241e35de29..acb1625cde 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -331,7 +331,7 @@ function wp_dropdown_categories( $args = '' ) { 'name' => 'cat', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'category', - 'hide_if_empty' => false + 'hide_if_empty' => false, 'option_none_value' => -1 ); $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; @@ -343,6 +343,7 @@ function wp_dropdown_categories( $args = '' ) { } $r = wp_parse_args( $args, $defaults ); + $option_none_value = $r['option_none_value']; if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { $r['pad_counts'] = true; @@ -381,7 +382,7 @@ function wp_dropdown_categories( $args = '' ) { * @param string $element Taxonomy element to list. */ $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] ); - $output .= "\t\n"; + $output .= "\t\n"; } if ( ! empty( $categories ) ) { @@ -398,8 +399,8 @@ function wp_dropdown_categories( $args = '' ) { /** This filter is documented in wp-includes/category-template.php */ $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] ); - $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : ''; - $output .= "\t\n"; + $selected = selected( $option_none_value, $r['selected'], false ); + $output .= "\t\n"; } if ( $r['hierarchical'] ) { diff --git a/wp-includes/user.php b/wp-includes/user.php index 3da96815cb..7eef1a57d0 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1285,7 +1285,8 @@ function wp_dropdown_users( $args = '' ) { 'include' => '', 'exclude' => '', 'multi' => 0, 'show' => 'display_name', 'echo' => 1, 'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '', - 'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false + 'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false, + 'option_none_value' => -1 ); $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; @@ -1294,6 +1295,7 @@ function wp_dropdown_users( $args = '' ) { $show = $r['show']; $show_option_all = $r['show_option_all']; $show_option_none = $r['show_option_none']; + $option_none_value = $r['option_none_value']; $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); $query_args['fields'] = array( 'ID', 'user_login', $show ); @@ -1314,8 +1316,8 @@ function wp_dropdown_users( $args = '' ) { } if ( $show_option_none ) { - $_selected = selected( -1, $r['selected'], false ); - $output .= "\t\n"; + $_selected = selected( $option_none_value, $r['selected'], false ); + $output .= "\t\n"; } $found_selected = false;