X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..5d244c8fd9a27c9f89dd08da2af6fbc67d4fce63:/wp-includes/capabilities.php diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 30c38b2c..bdb5c7a2 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -13,14 +13,12 @@ * the name in value of the 'name' key. The capabilities are stored as an array * in the value of the 'capability' key. * - * - * array ( - * 'rolename' => array ( - * 'name' => 'rolename', - * 'capabilities' => array() - * ) - * ) - * + * array ( + * 'rolename' => array ( + * 'name' => 'rolename', + * 'capabilities' => array() + * ) + * ) * * @since 2.0.0 * @package WordPress @@ -104,7 +102,8 @@ class WP_Roles { * * @since 2.1.0 * @access protected - * @uses $wpdb Used to get the database prefix. + * + * @global wpdb $wpdb WordPress database abstraction object. * @global array $wp_user_roles Used to set the 'roles' property value. */ protected function _init() { @@ -612,6 +611,8 @@ class WP_User { * Magic method for checking the existence of a certain custom field * * @since 3.3.0 + * @param string $key + * @return bool */ public function __isset( $key ) { if ( 'id' == $key ) { @@ -632,6 +633,8 @@ class WP_User { * Magic method for accessing custom fields * * @since 3.3.0 + * @param string $key + * @return mixed */ public function __get( $key ) { if ( 'id' == $key ) { @@ -1205,8 +1208,8 @@ function map_meta_cap( $cap, $user_id ) { /** * Filter whether the user is allowed to add post meta to a post. * - * The dynamic portion of the hook name, $meta_key, refers to the - * meta key passed to map_meta_cap(). + * The dynamic portion of the hook name, `$meta_key`, refers to the + * meta key passed to {@see map_meta_cap()}. * * @since 3.3.0 * @@ -1371,21 +1374,25 @@ function current_user_can( $capability ) { * @return bool */ function current_user_can_for_blog( $blog_id, $capability ) { - if ( is_multisite() ) - switch_to_blog( $blog_id ); + $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; $current_user = wp_get_current_user(); - if ( empty( $current_user ) ) + if ( empty( $current_user ) ) { + if ( $switched ) { + restore_current_blog(); + } return false; + } $args = array_slice( func_get_args(), 2 ); $args = array_merge( array( $capability ), $args ); $can = call_user_func_array( array( $current_user, 'has_cap' ), $args ); - if ( is_multisite() ) + if ( $switched ) { restore_current_blog(); + } return $can; }