From eb1e8f41a0a130a4fa3516d3e03dc5a119295a47 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 05:00:24 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-user.php | 20 ++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-user.php b/wp-includes/class-wp-user.php index 5d57a996ff..4c206c25fd 100644 --- a/wp-includes/class-wp-user.php +++ b/wp-includes/class-wp-user.php @@ -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 WP_User->ID 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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 07ee898183..2a070b31f2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.