Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/27/2019 04:53:16 AM (4 years ago)
Author:
imath
Message:

Only load BP REST API Avatar Controllers when avatar uploads are on

  • Move the loading of the BP_REST_Attachments_Member_Avatar_Endpoint controller into the xProfile component's class. User Avatar is an xProfile feature.
  • Make sure to check the community administrator allowed member avatar uploads before loading this controller.
  • Make sure to check the community administrator allowed group avatar uploads before loading BP_REST_Attachments_Group_Avatar_Endpoint.

Fixes #8151 (Branch 5.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/bp-groups/classes/class-bp-groups-component.php

    r12463 r12483  
    933933     */
    934934    public function rest_api_init( $controllers = array() ) {
    935         parent::rest_api_init( array(
     935        $controllers = array(
    936936            'BP_REST_Groups_Endpoint',
    937937            'BP_REST_Group_Membership_Endpoint',
    938938            'BP_REST_Group_Invites_Endpoint',
    939939            'BP_REST_Group_Membership_Request_Endpoint',
    940             'BP_REST_Attachments_Group_Avatar_Endpoint',
    941         ) );
     940        );
     941
     942        // Only Load the Group's Avatar controller if Group Avatar uploads are allowed.
     943        if ( ! bp_disable_group_avatar_uploads() ) {
     944            $controllers[] = 'BP_REST_Attachments_Group_Avatar_Endpoint';
     945        }
     946
     947        parent::rest_api_init( $controllers );
    942948    }
    943949}
Note: See TracChangeset for help on using the changeset viewer.