Make WordPress Core


Ignore:
Timestamp:
10/08/2024 10:30:57 PM (9 months ago)
Author:
johnbillion
Message:

Role/Capability: Introduce the current_user_can_for_site() and user_can_for_site() functions.

The current_user_can_for_site() function is a replacement for current_user_can_for_blog() which is now deprecated. user_can_for_site() is a renaming of the user_can_for_blog() function which was introduced in [59123]. The intention of this change is to prevent the introduction of a new function which uses the old "blog" naming structure.

Props swissspidy, spacedmonkey, flixos90, johnjamesjacoby

Fixes #45197

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r59039 r59198  
    64076407    return $variation . '--' . md5( serialize( $block ) );
    64086408}
     6409
     6410/**
     6411 * Returns whether the current user has the specified capability for a given site.
     6412 *
     6413 * @since 3.0.0
     6414 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
     6415 *              by adding it to the function signature.
     6416 * @since 5.8.0 Wraps current_user_can() after switching to blog.
     6417 * @deprecated 6.7.0 Use current_user_can_for_site() instead.
     6418 *
     6419 * @param int    $blog_id    Site ID.
     6420 * @param string $capability Capability name.
     6421 * @param mixed  ...$args    Optional further parameters, typically starting with an object ID.
     6422 * @return bool Whether the user has the given capability.
     6423 */
     6424function current_user_can_for_blog( $blog_id, $capability, ...$args ) {
     6425    return current_user_can_for_site( $blog_id, $capability, ...$args );
     6426}
Note: See TracChangeset for help on using the changeset viewer.