From ea0369944f6d23d084e5d3f11195f5db66efebd6 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Thu, 11 Jul 2019 11:17:47 +0200
Subject: [PATCH] Simplify & modernize 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 6c8f76906b..e2d132d217 100644
|
a
|
b
|
function author_can( $post, $capability, ...$args ) { |
| 754 | 754 | * @param mixed ...$args Optional further parameters, typically starting with an object ID. |
| 755 | 755 | * @return bool Whether the user has the given capability. |
| 756 | 756 | */ |
| 757 | | function user_can( $user, $capability ) { |
| | 757 | function user_can( $user, $capability, ...$args ) { |
| 758 | 758 | if ( ! is_object( $user ) ) { |
| 759 | 759 | $user = get_userdata( $user ); |
| 760 | 760 | } |
| … |
… |
function user_can( $user, $capability ) { |
| 763 | 763 | return false; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | | $args = array_slice( func_get_args(), 2 ); |
| 767 | | $args = array_merge( array( $capability ), $args ); |
| 768 | | |
| 769 | | return call_user_func_array( array( $user, 'has_cap' ), $args ); |
| | 766 | return $user->has_cap( $capability, ...$args ); |
| 770 | 767 | } |
| 771 | 768 | |
| 772 | 769 | /** |