Make WordPress Core

Changeset 17198


Ignore:
Timestamp:
01/01/2011 01:52:03 AM (16 years ago)
Author:
ryan
Message:

Introduce include_selected arg for wp_dropdown_users(). Add current author to dropdown in post_author_meta_box(). fixes #16045

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/meta-boxes.php

    r17141 r17198  
    531531                'who' => 'authors',
    532532                'name' => 'post_author_override',
    533                 'selected' => empty($post->ID) ? $user_ID : $post->post_author
     533                'selected' => empty($post->ID) ? $user_ID : $post->post_author,
     534                'include_selected' => true
    534535        ) );
    535536}
  • trunk/wp-includes/user.php

    r17189 r17198  
    958958 * <li>echo - Default is '1'. Whether to display or retrieve content.</li>
    959959 * <li>selected - Which User ID is selected.</li>
     960 * <li>include_selected - Always include the selected user ID in the dropdown. Default is false.</li>
    960961 * <li>name - Default is 'user'. Name attribute of select element.</li>
    961962 * <li>id - Default is the value of the 'name' parameter. ID attribute of select element.</li>
     
    978979                'show' => 'display_name', 'echo' => 1,
    979980                'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '',
    980                 'blog_id' => $GLOBALS['blog_id'], 'who' => ''
     981                'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false
    981982        );
    982983
     
    10081009                }
    10091010
     1011                $found_selected = false;
    10101012                foreach ( (array) $users as $user ) {
    10111013                        $user->ID = (int) $user->ID;
     1014                        $_selected = selected( $user->ID, $selected, false );
     1015                        if ( $_selected )
     1016                                $found_selected = true;
     1017                        $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
     1018                        $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
     1019                }
     1020
     1021                if ( $include_selected && ! $found_selected && ( $selected > 0 ) ) {
     1022                        $user = get_userdata( $selected );
    10121023                        $_selected = selected( $user->ID, $selected, false );
    10131024                        $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
Note: See TracChangeset for help on using the changeset viewer.