diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 256367f0b6..e2d132d217 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -33,8 +33,7 @@ * @param mixed ...$args Optional further parameters, typically starting with an object ID. * @return array Actual capabilities for meta capability. */ -function map_meta_cap( $cap, $user_id ) { - $args = array_slice( func_get_args(), 2 ); +function map_meta_cap( $cap, $user_id, ...$args ) { $caps = array(); switch ( $cap ) { @@ -649,17 +648,14 @@ function map_meta_cap( $cap, $user_id ) { * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is * passed, whether the current user has the given meta capability for the given object. */ -function current_user_can( $capability ) { +function current_user_can( $capability, ...$args ) { $current_user = wp_get_current_user(); if ( empty( $current_user ) ) { return false; } - $args = array_slice( func_get_args(), 1 ); - $args = array_merge( array( $capability ), $args ); - - return call_user_func_array( array( $current_user, 'has_cap' ), $args ); + return $current_user->has_cap( $capability, ...$args ); } /** @@ -682,7 +678,7 @@ function current_user_can( $capability ) { * @param mixed ...$args Optional further parameters, typically starting with an object ID. * @return bool Whether the user has the given capability. */ -function current_user_can_for_blog( $blog_id, $capability ) { +function current_user_can_for_blog( $blog_id, $capability, ...$args ) { $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; $current_user = wp_get_current_user(); @@ -694,10 +690,7 @@ function current_user_can_for_blog( $blog_id, $capability ) { 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 ); + $can = $current_user->has_cap( $capability, ...$args ); if ( $switched ) { restore_current_blog(); @@ -726,7 +719,7 @@ function current_user_can_for_blog( $blog_id, $capability ) { * @param mixed ...$args Optional further parameters, typically starting with an object ID. * @return bool Whether the post author has the given capability. */ -function author_can( $post, $capability ) { +function author_can( $post, $capability, ...$args ) { $post = get_post( $post ); if ( ! $post ) { return false; @@ -738,10 +731,7 @@ function author_can( $post, $capability ) { return false; } - $args = array_slice( func_get_args(), 2 ); - $args = array_merge( array( $capability ), $args ); - - return call_user_func_array( array( $author, 'has_cap' ), $args ); + return $author->has_cap( $capability, ...$args ); } /** @@ -764,7 +754,7 @@ function author_can( $post, $capability ) { * @param mixed ...$args Optional further parameters, typically starting with an object ID. * @return bool Whether the user has the given capability. */ -function user_can( $user, $capability ) { +function user_can( $user, $capability, ...$args ) { if ( ! is_object( $user ) ) { $user = get_userdata( $user ); } @@ -773,10 +763,7 @@ function user_can( $user, $capability ) { return false; } - $args = array_slice( func_get_args(), 2 ); - $args = array_merge( array( $capability ), $args ); - - return call_user_func_array( array( $user, 'has_cap' ), $args ); + return $user->has_cap( $capability, ...$args ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index ce76632ee5..e50a4c0689 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45621'; +$wp_version = '5.3-alpha-45622'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.