From d91c273679218269e1c318cc11eaab293ab37f2a Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Thu, 11 Jul 2019 11:10:55 +0200
Subject: [PATCH] Simplify & modernize current_user_can_for_blog()
---
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 c9c91848c2..44f3debf20 100644
|
a
|
b
|
function current_user_can( $capability, ...$args ) { |
| 678 | 678 | * @param mixed ...$args Optional further parameters, typically starting with an object ID. |
| 679 | 679 | * @return bool Whether the user has the given capability. |
| 680 | 680 | */ |
| 681 | | function current_user_can_for_blog( $blog_id, $capability ) { |
| | 681 | function current_user_can_for_blog( $blog_id, $capability, ...$args ) { |
| 682 | 682 | $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; |
| 683 | 683 | |
| 684 | 684 | $current_user = wp_get_current_user(); |
| … |
… |
function current_user_can_for_blog( $blog_id, $capability ) { |
| 690 | 690 | return false; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | | $args = array_slice( func_get_args(), 2 ); |
| 694 | | $args = array_merge( array( $capability ), $args ); |
| 695 | | |
| 696 | | $can = call_user_func_array( array( $current_user, 'has_cap' ), $args ); |
| | 693 | $can = $current_user->has_cap( $capability, ...$args ); |
| 697 | 694 | |
| 698 | 695 | if ( $switched ) { |
| 699 | 696 | restore_current_blog(); |