WordPress.org

Make WordPress Core

Ticket #12132: 12132_categories.patch

File 12132_categories.patch, 1.8 KB (added by johnbillion, 8 years ago)

Adds an 'id' parameter to wp_dropdown_categories()

  • wp-includes/category-template.php

     
    314314 *     'echo' (bool|int) default is 1 - Whether to display or retrieve content.
    315315 *     'depth' (int) - The max depth.
    316316 *     'tab_index' (int) - Tab index for select element.
    317  *     'name' (string) - The name attribute value for selected element.
    318  *     'class' (string) - The class attribute value for selected element.
     317 *     'name' (string) - The name attribute value for select element.
     318 *     'id' (string) - The ID attribute value for select element.
     319 *     'class' (string) - The class attribute value for select element.
    319320 *     'selected' (int) - Which category ID is selected.
    320321 *
    321322 * The 'hierarchical' argument, which is disabled by default, will override the
     
    336337                'hide_empty' => 1, 'child_of' => 0,
    337338                'exclude' => '', 'echo' => 1,
    338339                'selected' => 0, 'hierarchical' => 0,
    339                 'name' => 'cat', 'class' => 'postform',
    340                 'depth' => 0, 'tab_index' => 0,
    341                 'taxonomy' => 'category', 'hide_if_empty' => false
     340                'name' => 'cat', 'id' => '',
     341                'class' => 'postform', 'depth' => 0,
     342                'tab_index' => 0, 'taxonomy' => 'category',
     343                'hide_if_empty' => false
    342344        );
    343345
    344346        $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
     
    359361        $categories = get_terms( $taxonomy, $r );
    360362        $name = esc_attr($name);
    361363        $class = esc_attr($class);
     364        $id = $id ? $id : $name;
    362365
    363366        if ( ! $r['hide_if_empty'] || ! empty($categories) )
    364                 $output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";
     367                $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
    365368        else
    366369                $output = '';
    367370        if ( ! empty( $categories ) ) {