Skip to:
Content

BuddyPress.org

Ticket #8355: 8355.3.patch

File 8355.3.patch, 2.0 KB (added by imath, 5 years ago)
  • src/bp-core/bp-core-caps.php

    diff --git src/bp-core/bp-core-caps.php src/bp-core/bp-core-caps.php
    index 7d1d00482..0a9bf122d 100644
    function bp_user_can( $user_id, $capability, $args = array() ) { 
    344344        return $retval;
    345345}
    346346
     347/**
     348 * Adds the `bp_moderate` cap to Administrators when BuddyPress is not active on the network.
     349 *
     350 * @since 7.0.0
     351 *
     352 * @param WP_Roles $wp_roles The WordPress roles object.
     353 */
     354function _bp_roles_init( WP_Roles $wp_roles ) {
     355        if ( isset( $wp_roles->roles[ 'administrator' ], $wp_roles->role_objects[ 'administrator' ] ) && ! bp_is_network_activated() ) {
     356                $wp_roles->roles[ 'administrator' ]['capabilities']['bp_moderate']      = true;
     357                $wp_roles->role_objects[ 'administrator' ]->capabilities['bp_moderate'] = true;
     358        }
     359}
     360add_action( 'wp_roles_init', '_bp_roles_init', 10, 1 );
     361
     362/** Deprecated ****************************************************************/
     363
    347364/**
    348365 * Temporary implementation of 'bp_moderate' cap.
    349366 *
    function bp_user_can( $user_id, $capability, $args = array() ) { 
    363380 * Plugin authors: Please do not use this function; thank you. :)
    364381 *
    365382 * @since 1.6.0
     383 * @deprecated 7.0.0
    366384 *
    367385 * @access private
    368386 *
    function bp_user_can( $user_id, $capability, $args = array() ) { 
    375393 * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
    376394 */
    377395function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
     396        _deprecated_function( __FUNCTION__, '7.0.0' );
    378397
    379398        // Bail if not checking the 'bp_moderate' cap.
    380399        if ( 'bp_moderate' !== $cap ) {
    function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $us 
    394413        // Only users that can 'manage_options' on this site can 'bp_moderate'.
    395414        return array( 'manage_options' );
    396415}
    397 add_filter( 'map_meta_cap', '_bp_enforce_bp_moderate_cap_for_admins', 10, 4 );
    398 
    399 /** Deprecated ****************************************************************/
    400416
    401417/**
    402418 * Adds BuddyPress-specific user roles.