X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/5d244c8fd9a27c9f89dd08da2af6fbc67d4fce63..fcaa67f093b5c83deea7a361a8cf8c6ac4e832d3:/wp-includes/capabilities.php diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index bdb5c7a2..588432dc 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -90,7 +90,10 @@ class WP_Roles { * @return mixed|bool Return value of the callback, false otherwise. */ public function __call( $name, $arguments ) { - return call_user_func_array( array( $this, $name ), $arguments ); + if ( '_init' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; } /** @@ -415,16 +418,31 @@ class WP_Role { * @since 2.0.0 * @package WordPress * @subpackage User + * + * @property string $nickname + * @property string $user_description + * @property string $user_firstname + * @property string $user_lastname + * @property string $user_login + * @property string $user_pass + * @property string $user_nicename + * @property string $user_email + * @property string $user_url + * @property string $user_registered + * @property string $user_activation_key + * @property string $user_status + * @property string $display_name + * @property string $spam + * @property string $deleted */ class WP_User { /** * User data container. * * @since 2.0.0 - * @access private - * @var array + * @var object */ - var $data; + public $data; /** * The user's ID. @@ -493,7 +511,6 @@ class WP_User { * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. * @param string $name Optional. User's username * @param int $blog_id Optional Blog ID, defaults to current blog. - * @return WP_User */ public function __construct( $id = 0, $name = '', $blog_id = '' ) { if ( ! isset( self::$back_compat_keys ) ) { @@ -508,7 +525,7 @@ class WP_User { ); } - if ( is_a( $id, 'WP_User' ) ) { + if ( $id instanceof WP_User ) { $this->init( $id->data, $blog_id ); return; } elseif ( is_object( $id ) ) { @@ -521,13 +538,17 @@ class WP_User { $id = 0; } - if ( $id ) + if ( $id ) { $data = self::get_data_by( 'id', $id ); - else + } else { $data = self::get_data_by( 'login', $name ); + } - if ( $data ) + if ( $data ) { $this->init( $data, $blog_id ); + } else { + $this->data = new stdClass; + } } /** @@ -550,7 +571,7 @@ class WP_User { * * @param string $field The field to query against: 'id', 'slug', 'email' or 'login' * @param string|int $value The field value - * @return object Raw user object + * @return object|false Raw user object */ public static function get_data_by( $field, $value ) { global $wpdb; @@ -918,6 +939,8 @@ class WP_User { public function add_cap( $cap, $grant = true ) { $this->caps[$cap] = $grant; update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); } /** @@ -929,10 +952,13 @@ class WP_User { * @param string $cap Capability name. */ public function remove_cap( $cap ) { - if ( ! isset( $this->caps[$cap] ) ) + if ( ! isset( $this->caps[ $cap ] ) ) { return; - unset( $this->caps[$cap] ); + } + unset( $this->caps[ $cap ] ); update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); } /** @@ -985,7 +1011,7 @@ class WP_User { * @since 2.0.0 * @since 3.7.0 Added the user object. * - * @param array $allcaps An array of all the role's capabilities. + * @param array $allcaps An array of all the user's capabilities. * @param array $caps Actual capabilities for meta capability. * @param array $args Optional parameters passed to has_cap(), typically object ID. * @param WP_User $user The user object. @@ -1319,6 +1345,9 @@ function map_meta_cap( $cap, $user_id ) { case 'customize' : $caps[] = 'edit_theme_options'; break; + case 'delete_site': + $caps[] = 'manage_options'; + break; default: // Handle meta capabilities for custom post types. $post_type_meta_caps = _post_type_meta_capabilities();