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

	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.