WordPress.org

Make WordPress Core

Ticket #47678: patch-47678.patch

File patch-47678.patch, 1.2 KB (added by jrf, 12 months ago)
  • src/wp-includes/capabilities.php

    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 ) { 
    649649 * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
    650650 *              passed, whether the current user has the given meta capability for the given object.
    651651 */
    652 function current_user_can( $capability ) {
     652function current_user_can( $capability, ...$args ) {
    653653        $current_user = wp_get_current_user();
    654654
    655655        if ( empty( $current_user ) ) {
    656656                return false;
    657657        }
    658658
    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 );
    663660}
    664661
    665662/**