Make WordPress Core


Ignore:
Timestamp:
09/22/2015 04:59:35 AM (11 years ago)
Author:
wonderboymusic
Message:

Users: add __unset to WP_User.

Adds unit tests.

Props johnjamesjacoby, MikeHansenMe, wonderboymusic.
Fixes #20043.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-user.php

    r34379 r34380  
    326326
    327327        /**
     328         * Magic method for unsetting a certain custom field
     329         *
     330         * @since 4.4.0
     331         */
     332        function __unset( $key ) {
     333                if ( 'id' == $key ) {
     334                        _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
     335                        $key = 'ID';
     336                }
     337
     338                if ( isset( $this->data->$key ) ) {
     339                        unset( $this->data->$key );
     340                }
     341
     342                if ( isset( self::$back_compat_keys[ $key ] ) ) {
     343                        unset( self::$back_compat_keys[ $key ] );
     344                }
     345        }
     346
     347        /**
    328348         * Determine whether the user exists in the database.
    329349         *
Note: See TracChangeset for help on using the changeset viewer.