WordPress.org

Make WordPress Core

Ticket #20810: wp_dropdown_pages_attr_opt.patch

File wp_dropdown_pages_attr_opt.patch, 1.1 KB (added by wpsmith, 6 years ago)

Extra attributes for wp_dropdown_pages()

  • post-template.php

     
    771771                'selected' => 0, 'echo' => 1,
    772772                'name' => 'page_id', 'id' => '',
    773773                'show_option_none' => '', 'show_option_no_change' => '',
    774                 'option_none_value' => ''
     774                'option_none_value' => '', 'attr' => array(),
    775775        );
    776776
    777777        $r = wp_parse_args( $args, $defaults );
     
    782782        // Back-compat with old system where both id and name were based on $name argument
    783783        if ( empty($id) )
    784784                $id = $name;
    785 
     785               
     786        $attributes = '';
     787        foreach ( (array)$attr as $attr_name => $value ) {
     788                $attributes .= " $attr_name=" . '"' . $value . '"';
     789        }
     790       
    786791        if ( ! empty($pages) ) {
    787                 $output = "<select name='" . esc_attr( $name ) . "' id='" . esc_attr( $id ) . "'>\n";
     792                $output = "<select name='" . esc_attr( $name ) . "' id='" . esc_attr( $id ) . "'$attributes>\n";
    788793                if ( $show_option_no_change )
    789794                        $output .= "\t<option value=\"-1\">$show_option_no_change</option>";
    790795                if ( $show_option_none )