Make WordPress Core

Ticket #15523: 15523.diff

File 15523.diff, 2.3 KB (added by GaryJ, 14 years ago)

Inclusion of multiple and size attributes on wp_dropdown_pages(). Some whitespace fixing.

  • wp-includes/post-template.php

     
    754754 * @param array|string $args Optional. Override default arguments.
    755755 * @return string HTML content, if not displaying.
    756756 */
    757 function wp_dropdown_pages($args = '') {
     757function wp_dropdown_pages( $args = '' ) {
    758758        $defaults = array(
    759                 'depth' => 0, 'child_of' => 0,
    760                 'selected' => 0, 'echo' => 1,
    761                 'name' => 'page_id', 'id' => '',
    762                 'show_option_none' => '', 'show_option_no_change' => '',
    763                 'option_none_value' => ''
     759                'child_of'              => 0,
     760                'depth'                 => 0,
     761                'echo'                  => 1,
     762                'id'                    => '',
     763                'multiple'              => '',
     764                'name'                  => 'page_id',
     765                'option_none_value'     => '',
     766                'selected'              => 0,
     767                'show_option_no_change' => '',
     768                'show_option_none'      => '',
     769                'size'                  => ''
    764770        );
    765771
    766772        $r = wp_parse_args( $args, $defaults );
    767773        extract( $r, EXTR_SKIP );
    768774
    769         $pages = get_pages($r);
     775        $pages = get_pages( $r );
    770776        $output = '';
    771         $name = esc_attr($name);
     777        $name = esc_attr( $name );
    772778        // Back-compat with old system where both id and name were based on $name argument
    773         if ( empty($id) )
     779        if ( empty( $id ) )
    774780                $id = $name;
    775781
    776         if ( ! empty($pages) ) {
    777                 $output = "<select name=\"$name\" id=\"$id\">\n";
     782        if ( 'multiple' == $multiple )
     783                $multiple = ' multiple="multiple"';
     784       
     785        if ( is_int( $size ) || ctype_digit( $size ) )
     786                $size = " size=\"$size\"";
     787               
     788        if ( ! empty( $pages ) ) {
     789                $output = "<select name=\"$name\" id=\"$id\"$multiple$size>\n";
    778790                if ( $show_option_no_change )
    779791                        $output .= "\t<option value=\"-1\">$show_option_no_change</option>";
    780792                if ( $show_option_none )
    781                         $output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">$show_option_none</option>\n";
    782                 $output .= walk_page_dropdown_tree($pages, $depth, $r);
     793                        $output .= "\t<option value=\"" . esc_attr( $option_none_value ) . "\">$show_option_none</option>\n";
     794                $output .= walk_page_dropdown_tree( $pages, $depth, $r );
    783795                $output .= "</select>\n";
    784796        }
    785797
    786         $output = apply_filters('wp_dropdown_pages', $output);
     798        $output = apply_filters( 'wp_dropdown_pages', $output );
    787799
    788800        if ( $echo )
    789801                echo $output;