diff --git a/wp-includes/class-wp-user.php b/wp-includes/class-wp-user.php index f4bb9b12c8..73f7cdf0d5 100644 --- a/wp-includes/class-wp-user.php +++ b/wp-includes/class-wp-user.php @@ -738,15 +738,13 @@ class WP_User { * @return bool Whether the user has the given capability, or, if an object ID is passed, whether the user has * the given capability for that object. */ - public function has_cap( $cap ) { + public function has_cap( $cap, ...$args ) { if ( is_numeric( $cap ) ) { _deprecated_argument( __FUNCTION__, '2.0.0', __( 'Usage of user levels is deprecated. Use capabilities instead.' ) ); $cap = $this->translate_level_to_cap( $cap ); } - $args = array_slice( func_get_args(), 1 ); - $args = array_merge( array( $cap, $this->ID ), $args ); - $caps = call_user_func_array( 'map_meta_cap', $args ); + $caps = map_meta_cap( $cap, $this->ID, ...$args ); // Multisite super admin has all caps by definition, Unless specifically denied. if ( is_multisite() && is_super_admin( $this->ID ) ) { @@ -756,6 +754,9 @@ class WP_User { return true; } + // Maintain BC for the argument passed to the "user_has_cap" filter. + $args = array_merge( array( $cap, $this->ID ), $args ); + /** * Dynamically filter a user's capabilities. * diff --git a/wp-includes/version.php b/wp-includes/version.php index e50a4c0689..01562a51f1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45622'; +$wp_version = '5.3-alpha-45623'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.