From 436597a470d1fc786e571bc0ca531fd3da06e6e6 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Thu, 11 Jul 2019 11:12:30 +0200
Subject: [PATCH] Simplify & modernize author_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 44f3debf20..6c8f76906b 100644
|
a
|
b
|
function current_user_can_for_blog( $blog_id, $capability, ...$args ) { |
| 719 | 719 | * @param mixed ...$args Optional further parameters, typically starting with an object ID. |
| 720 | 720 | * @return bool Whether the post author has the given capability. |
| 721 | 721 | */ |
| 722 | | function author_can( $post, $capability ) { |
| | 722 | function author_can( $post, $capability, ...$args ) { |
| 723 | 723 | $post = get_post( $post ); |
| 724 | 724 | if ( ! $post ) { |
| 725 | 725 | return false; |
| … |
… |
function author_can( $post, $capability ) { |
| 731 | 731 | return false; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | | $args = array_slice( func_get_args(), 2 ); |
| 735 | | $args = array_merge( array( $capability ), $args ); |
| 736 | | |
| 737 | | return call_user_func_array( array( $author, 'has_cap' ), $args ); |
| | 734 | return $author->has_cap( $capability, ...$args ); |
| 738 | 735 | } |
| 739 | 736 | |
| 740 | 737 | /** |