Accept 'ID' as a valid `$field` in `get_user_by()`.
We already accept 'id'. `ID` more closely matches the database and `WP_User` schemas. Props Shelob9. Fixes #33869. Built from https://develop.svn.wordpress.org/trunk@34125 git-svn-id: http://core.svn.wordpress.org/trunk@34093 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a78e850e9c
commit
ef474c6970
|
@ -165,18 +165,24 @@ class WP_User {
|
||||||
* Return only the main user fields
|
* Return only the main user fields
|
||||||
*
|
*
|
||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
|
* @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb
|
* @global wpdb $wpdb
|
||||||
*
|
*
|
||||||
* @param string $field The field to query against: 'id', 'slug', 'email' or 'login'
|
* @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'.
|
||||||
* @param string|int $value The field value
|
* @param string|int $value The field value
|
||||||
* @return object|false Raw user object
|
* @return object|false Raw user object
|
||||||
*/
|
*/
|
||||||
public static function get_data_by( $field, $value ) {
|
public static function get_data_by( $field, $value ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
// 'ID' is an alias of 'id'.
|
||||||
|
if ( 'ID' === $field ) {
|
||||||
|
$field = 'id';
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'id' == $field ) {
|
if ( 'id' == $field ) {
|
||||||
// Make sure the value is numeric to avoid casting objects, for example,
|
// Make sure the value is numeric to avoid casting objects, for example,
|
||||||
// to int 1.
|
// to int 1.
|
||||||
|
|
|
@ -145,8 +145,9 @@ if ( !function_exists('get_user_by') ) :
|
||||||
* Retrieve user info by a given field
|
* Retrieve user info by a given field
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
|
* @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
|
||||||
*
|
*
|
||||||
* @param string $field The field to retrieve the user with. id | slug | email | login
|
* @param string $field The field to retrieve the user with. id | ID | slug | email | login.
|
||||||
* @param int|string $value A value for $field. A user ID, slug, email address, or login name.
|
* @param int|string $value A value for $field. A user ID, slug, email address, or login name.
|
||||||
* @return WP_User|false WP_User object on success, false on failure.
|
* @return WP_User|false WP_User object on success, false on failure.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34124';
|
$wp_version = '4.4-alpha-34125';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue