Make WordPress Core

Changeset 28564


Ignore:
Timestamp:
05/23/2014 08:46:18 PM (11 years ago)
Author:
wonderboymusic
Message:

wp_dropdown_pages() allows option_none_value to be passed. Add that arg to the $defaults for wp_dropdown_users() and wp_dropdown_categories() as well.

Props solarissmoke.
Fixes #16625.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r28504 r28564  
    332332        'class' => 'postform', 'depth' => 0,
    333333        'tab_index' => 0, 'taxonomy' => 'category',
    334         'hide_if_empty' => false
     334        'hide_if_empty' => false, 'option_none_value' => -1
    335335    );
    336336
     
    344344
    345345    $r = wp_parse_args( $args, $defaults );
     346    $option_none_value = $r['option_none_value'];
    346347
    347348    if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
     
    382383         */
    383384        $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
    384         $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";
     385        $output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
    385386    }
    386387
     
    399400            /** This filter is documented in wp-includes/category-template.php */
    400401            $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
    401             $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
    402             $output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
     402            $selected = selected( $option_none_value, $r['selected'], false );
     403            $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
    403404        }
    404405
  • trunk/src/wp-includes/user.php

    r28528 r28564  
    12861286        'show' => 'display_name', 'echo' => 1,
    12871287        'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '',
    1288         'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false
     1288        'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false,
     1289        'option_none_value' => -1
    12891290    );
    12901291
     
    12951296    $show_option_all = $r['show_option_all'];
    12961297    $show_option_none = $r['show_option_none'];
     1298    $option_none_value = $r['option_none_value'];
    12971299
    12981300    $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );
     
    13151317
    13161318        if ( $show_option_none ) {
    1317             $_selected = selected( -1, $r['selected'], false );
    1318             $output .= "\t<option value='-1'$_selected>$show_option_none</option>\n";
     1319            $_selected = selected( $option_none_value, $r['selected'], false );
     1320            $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n";
    13191321        }
    13201322
Note: See TracChangeset for help on using the changeset viewer.