Users: Check if the user ID passed as `selected` to `wp_dropdown_users()` corresponds to an existing user.
This avoids a few PHP notices if the `include_selected` parameter was specified and a non-existing user ID was passed. Props campusboy1987. Fixes #51370. Built from https://develop.svn.wordpress.org/trunk@49036 git-svn-id: http://core.svn.wordpress.org/trunk@48798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a16faa6989
commit
d4a319c453
|
@ -1191,6 +1191,7 @@ function wp_dropdown_users( $args = '' ) {
|
|||
if ( $parsed_args['include_selected'] && ( $parsed_args['selected'] > 0 ) ) {
|
||||
$found_selected = false;
|
||||
$parsed_args['selected'] = (int) $parsed_args['selected'];
|
||||
|
||||
foreach ( (array) $users as $user ) {
|
||||
$user->ID = (int) $user->ID;
|
||||
if ( $user->ID === $parsed_args['selected'] ) {
|
||||
|
@ -1199,7 +1200,10 @@ function wp_dropdown_users( $args = '' ) {
|
|||
}
|
||||
|
||||
if ( ! $found_selected ) {
|
||||
$users[] = get_userdata( $parsed_args['selected'] );
|
||||
$selected_user = get_userdata( $parsed_args['selected'] );
|
||||
if ( $selected_user ) {
|
||||
$users[] = $selected_user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.6-alpha-49035';
|
||||
$wp_version = '5.6-alpha-49036';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue