BP_REST_Media_Endpoint::bp_rest_media_default_scope( string $scope, array $args = array() )

Get default scope for the media.

Description

Parameters

$scope

(Required) Default scope.

$args

(Optional) Array of request parameters.

Default value: array()

Return

(string)

Source

File: bp-media/classes/class-bp-rest-media-endpoint.php

2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
public function bp_rest_media_default_scope( $scope, $args = array() ) {
    $new_scope = array();
 
    if ( ( 'all' === $scope || empty( $scope ) ) && ( empty( $args['group_id'] ) && empty( $args['user_id'] ) ) ) {
        $new_scope[] = 'public';
 
        if ( bp_is_active( 'friends' ) && bp_is_profile_media_support_enabled() ) {
            $new_scope[] = 'friends';
        }
 
        if ( bp_is_active( 'groups' ) && bp_is_group_media_support_enabled() ) {
            $new_scope[] = 'groups';
        }
 
        if ( is_user_logged_in() && bp_is_profile_media_support_enabled() ) {
            $new_scope[] = 'personal';
        }
    } elseif ( ! empty( $args['user_id'] ) && ( 'all' === $scope || empty( $scope ) ) && bp_is_profile_media_support_enabled() ) {
        $new_scope[] = 'personal';
    } elseif ( bp_is_active( 'groups' ) && ! empty( $args['group_id'] ) && ( 'all' === $scope || empty( $scope ) ) ) {
        $new_scope[] = 'groups';
    }
 
    $new_scope = array_unique( $new_scope );
 
    if ( empty( $new_scope ) ) {
        $new_scope = (array) $scope;
    }
 
    /**
     * Filter to update default scope for rest api.
     *
     * @since 0.1.0
     */
    $new_scope = apply_filters( 'bp_rest_media_default_scope', $new_scope );
 
    return implode( ',', $new_scope );
}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.