Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/27/2019 04:53:16 AM (5 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-xprofile/classes/class-bp-xprofile-component.php

    r12463 r12483  
    500500     */
    501501    public function rest_api_init( $controllers = array() ) {
    502         parent::rest_api_init( array(
     502        $controllers = array(
    503503            'BP_REST_XProfile_Fields_Endpoint',
    504504            'BP_REST_XProfile_Field_Groups_Endpoint',
    505505            'BP_REST_XProfile_Data_Endpoint',
    506         ) );
     506        );
     507
     508        // Only Load the Member's Avatar controller if Avatar uploads are allowed.
     509        if ( ! bp_disable_avatar_uploads() ) {
     510            $controllers[] = 'BP_REST_Attachments_Member_Avatar_Endpoint';
     511        }
     512
     513        parent::rest_api_init( $controllers );
    507514    }
    508515}
Note: See TracChangeset for help on using the changeset viewer.