Make WordPress Core


Ignore:
Timestamp:
05/11/2015 01:10:19 PM (9 years ago)
Author:
boonebgorges
Message:

In category dropdown, 'selected' should match against 'value_field'.

Props tlexcellent.
Fixes #32330.

File:
1 edited

Legend:

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

    r32292 r32484  
    11661166        $cat_name = apply_filters( 'list_cats', $category->name, $category );
    11671167
    1168         if ( ! isset( $args['value_field'] ) || ! isset( $category->{$args['value_field']} ) ) {
    1169             $args['value_field'] = 'term_id';
    1170         }
    1171 
    1172         $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$args['value_field']} ) . "\"";
    1173 
    1174         if ( $category->term_id == $args['selected'] )
     1168        if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) {
     1169            $value_field = $args['value_field'];
     1170        } else {
     1171            $value_field = 'term_id';
     1172        }
     1173
     1174        $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\"";
     1175
     1176        if ( $category->{$value_field} == $args['selected'] )
    11751177            $output .= ' selected="selected"';
    11761178        $output .= '>';
Note: See TracChangeset for help on using the changeset viewer.