Users: add `__unset` to `WP_User`.
Adds unit tests. Props johnjamesjacoby, MikeHansenMe, wonderboymusic. Fixes #20043. Built from https://develop.svn.wordpress.org/trunk@34380 git-svn-id: http://core.svn.wordpress.org/trunk@34344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d093242095
commit
eb1e8f41a0
|
@ -324,6 +324,26 @@ class WP_User {
|
|||
$this->data->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method for unsetting a certain custom field
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
function __unset( $key ) {
|
||||
if ( 'id' == $key ) {
|
||||
_deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
|
||||
$key = 'ID';
|
||||
}
|
||||
|
||||
if ( isset( $this->data->$key ) ) {
|
||||
unset( $this->data->$key );
|
||||
}
|
||||
|
||||
if ( isset( self::$back_compat_keys[ $key ] ) ) {
|
||||
unset( self::$back_compat_keys[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user exists in the database.
|
||||
*
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34379';
|
||||
$wp_version = '4.4-alpha-34380';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue