From fb436fc7f53f64ebfcd08888eadf608ed27bb84b Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Tue, 18 Jun 2019 04:22:41 +0200
Subject: [PATCH] Simplify & modernize current_user_can()
---
src/wp-includes/capabilities.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php
index 256367f0b6..44a12ca350 100644
|
a
|
b
|
function map_meta_cap( $cap, $user_id ) { |
| 649 | 649 | * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is |
| 650 | 650 | * passed, whether the current user has the given meta capability for the given object. |
| 651 | 651 | */ |
| 652 | | function current_user_can( $capability ) { |
| | 652 | function current_user_can( $capability, ...$args ) { |
| 653 | 653 | $current_user = wp_get_current_user(); |
| 654 | 654 | |
| 655 | 655 | if ( empty( $current_user ) ) { |
| 656 | 656 | return false; |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | | $args = array_slice( func_get_args(), 1 ); |
| 660 | | $args = array_merge( array( $capability ), $args ); |
| 661 | | |
| 662 | | return call_user_func_array( array( $current_user, 'has_cap' ), $args ); |
| | 659 | return $current_user->has_cap( $capability, ...$args ); |
| 663 | 660 | } |
| 664 | 661 | |
| 665 | 662 | /** |