Make WordPress Core

Ticket #21601: 21601_wp_user.patch

File 21601_wp_user.patch, 1.3 KB (added by wpsmith, 13 years ago)
  • wp-includes/capabilities.php

     
    585585
    586586                return metadata_exists( 'user', $this->ID, $key );
    587587        }
     588       
     589        /**
     590         * Magic method for checking whether a certain custom field has a value
     591         *
     592         * @since 3.5.0
     593         */
     594        function __hasval( $key ) {
     595                if ( 'id' == $key ) {
     596                        _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
     597                        $key = 'ID';
     598                }
    588599
     600                if ( isset( $this->data->$key ) && ! empty( $this->data->$key ) )
     601                        return true;
     602
     603                if ( isset( self::$back_compat_keys[ $key ] ) )
     604                        $key = self::$back_compat_keys[ $key ];
     605
     606                if ( $this->__isset( $key ) )
     607                        $value = $this->__get( $key );
     608               
     609                if ( $value )
     610                        return $value;
     611                else
     612                        return false;
     613        }
     614
    589615        /**
    590616         * Magic method for accessing custom fields
    591617         *
     
    664690        function has_prop( $key ) {
    665691                return $this->__isset( $key );
    666692        }
     693       
     694        /**
     695         * Determine whether a property or meta key has a value
     696         *
     697         * Consults the users and usermeta tables.
     698         *
     699         * @since 3.5.0
     700         *
     701         * @param string $key Property
     702         */
     703        function has_prop_val( $key ) {
     704                return $this->__hasval( $key );
     705        }
    667706
    668707        /*
    669708         * Return an array representation.