Full Code of buddypress/BP-REST for AI

master 6e5c75355710 cached
59 files
1.1 MB
330.1k tokens
1161 symbols
1 requests
Download .txt
Showing preview only (1,135K chars total). Download the full file or copy to clipboard to get everything.
Repository: buddypress/BP-REST
Branch: master
Commit: 6e5c75355710
Files: 59
Total size: 1.1 MB

Directory structure:
gitextract_dwozqvnr/

├── .distignore
├── .editorconfig
├── .gitignore
├── .phpcs/
│   └── .gitkeep
├── CONTRIBUTING.md
├── README.md
├── bp-rest.php
├── composer.json
├── includes/
│   ├── bp-activity/
│   │   └── classes/
│   │       └── class-bp-rest-activity-endpoint.php
│   ├── bp-attachments/
│   │   └── classes/
│   │       └── trait-attachments.php
│   ├── bp-blogs/
│   │   └── classes/
│   │       ├── class-bp-rest-attachments-blog-avatar-endpoint.php
│   │       └── class-bp-rest-blogs-endpoint.php
│   ├── bp-components/
│   │   └── classes/
│   │       └── class-bp-rest-components-endpoint.php
│   ├── bp-friends/
│   │   └── classes/
│   │       └── class-bp-rest-friends-endpoint.php
│   ├── bp-groups/
│   │   └── classes/
│   │       ├── class-bp-rest-attachments-group-avatar-endpoint.php
│   │       ├── class-bp-rest-attachments-group-cover-endpoint.php
│   │       ├── class-bp-rest-group-invites-endpoint.php
│   │       ├── class-bp-rest-group-membership-endpoint.php
│   │       ├── class-bp-rest-group-membership-request-endpoint.php
│   │       └── class-bp-rest-groups-endpoint.php
│   ├── bp-members/
│   │   └── classes/
│   │       ├── class-bp-rest-attachments-member-avatar-endpoint.php
│   │       ├── class-bp-rest-attachments-member-cover-endpoint.php
│   │       ├── class-bp-rest-members-endpoint.php
│   │       └── class-bp-rest-signup-endpoint.php
│   ├── bp-messages/
│   │   └── classes/
│   │       ├── class-bp-rest-messages-endpoint.php
│   │       └── class-bp-rest-sitewide-notices-endpoint.php
│   ├── bp-notifications/
│   │   └── classes/
│   │       └── class-bp-rest-notifications-endpoint.php
│   └── bp-xprofile/
│       └── classes/
│           ├── class-bp-rest-xprofile-data-endpoint.php
│           ├── class-bp-rest-xprofile-field-groups-endpoint.php
│           └── class-bp-rest-xprofile-fields-endpoint.php
├── package.json
├── phpcs.xml.dist
├── phpunit.xml.dist
├── readme.txt
├── tests/
│   ├── bootstrap.php
│   ├── define-constants.php
│   ├── multisite.xml
│   └── testcases/
│       ├── activity/
│       │   └── test-controller.php
│       ├── attachments/
│       │   ├── test-blog-avatar-controller.php
│       │   ├── test-group-avatar-controller.php
│       │   ├── test-group-cover-controller.php
│       │   ├── test-member-avatar-controller.php
│       │   └── test-member-cover-controller.php
│       ├── blogs/
│       │   └── test-controller.php
│       ├── components/
│       │   └── test-controller.php
│       ├── friends/
│       │   └── test-controller.php
│       ├── groups/
│       │   ├── test-controller.php
│       │   └── test-group-invites-controller.php
│       ├── members/
│       │   └── test-controller.php
│       ├── membership/
│       │   ├── test-group-membership-controller.php
│       │   └── test-group-membership-request-controller.php
│       ├── messages/
│       │   └── test-controller.php
│       ├── notifications/
│       │   └── test-controller.php
│       ├── signup/
│       │   └── test-controller.php
│       ├── sitewide-notices/
│       │   └── test-controller.php
│       └── xprofile/
│           ├── test-data-controller.php
│           ├── test-field-controller.php
│           └── test-group-controller.php
└── wp-env.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .distignore
================================================
.DS_Store
.git
.gitignore
.gitlab-ci.yml
.editorconfig
.travis.yml
behat.yml
circle.yml
bin/
features/
utils/
*.zip
*.tar.gz


================================================
FILE: .editorconfig
================================================
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.yml]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[{*.txt}]
end_of_line = crlf


================================================
FILE: .gitignore
================================================
# Files and folders related to build/test tools
/phpunit.xml
/node_modules
/npm-debug.log
/vendor/
.vscode
.wp-env.override.json
composer.lock
.phpunit.result.cache

# Operating system specific files
.DS_Store

# Cache files
.phpcs/*.json


================================================
FILE: .phpcs/.gitkeep
================================================
# This directory can't be empty.


================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Hi, and thanks for considering contributing! Before you do though, here's a few
notes on how best to contribute. Don't worry, I'll keep it short!

## Best Practices

### Commit Messages
Commit messages should follow the standard laid out in the git manual; that is,
a one-line summary ()

	Short (50 chars or less) summary of changes

	More detailed explanatory text, if necessary.  Wrap it to about 72
	characters or so.  In some contexts, the first line is treated as the
	subject of an email and the rest of the text as the body.  The blank
	line separating the summary from the body is critical (unless you omit
	the body entirely); tools like rebase can get confused if you run the
	two together.

	Further paragraphs come after blank lines.

	 - Bullet points are okay, too

	 - Typically a hyphen or asterisk is used for the bullet, preceded by a
	   single space, with blank lines in between, but conventions vary here

## Commit Process
Changes are proposed in the form of pull requests by you, the contributor! After
submitting your proposed changes, a member of the API team will review your
commits and mark them for merge by assigning it to themselves. Your pull request
will then be merged after final review by another member.

## Unit tests
It's important the code submitted comes with proper unit tests and comply with the WordPress Coding Standards.


================================================
FILE: README.md
================================================
# BuddyPress RESTful API

[![Project Status: Active.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive)

Access your BuddyPress site's data through an easy-to-use HTTP REST API.

## Documentation

This plugin has been deprecated since the V2 of the BP REST API was introduced
at [#9145](https://buddypress.trac.wordpress.org/ticket/9145) and is no longer maintained.


================================================
FILE: bp-rest.php
================================================
<?php
/**
 * Plugin Name:       BuddyPress RESTful API (Deprecated)
 * Plugin URI:        https://buddypress.org
 * Description:       Access your BuddyPress site's data through an easy-to-use HTTP REST API.
 * Author:            The BuddyPress Community
 * Author URI:        https://buddypress.org/
 * Version:           0.9.0
 * Text Domain:       buddypress
 * Requires at least: 6.1
 * Tested up to:      6.7
 * Requires PHP:      5.6
 * Requires Plugins:  buddypress
 * License:           GNU General Public License v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 *
 * @package BuddyPress
 * @since 0.1.0
 */

/**
 * Copyright (c) 2020 BuddyPress (email: contact@buddypress.org)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2 or, at
 * your discretion, any later version, as published by the Free
 * Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

defined( 'ABSPATH' ) || exit;

/**
 * Register BuddyPress endpoints.
 *
 * @since 0.1.0
 */
function bp_rest() {
	// Bail early if no core rest support.
	if ( ! class_exists( 'WP_REST_Controller' ) ) {
		return;
	}

	require_once __DIR__ . '/includes/bp-components/classes/class-bp-rest-components-endpoint.php';
	$controller = new BP_REST_Components_Endpoint();
	$controller->register_routes();

	if ( bp_is_active( 'members' ) ) {
		require_once __DIR__ . '/includes/bp-members/classes/class-bp-rest-members-endpoint.php';
		$controller = new BP_REST_Members_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-attachments/classes/trait-attachments.php';

		// Support Member's Avatar.
		require_once __DIR__ . '/includes/bp-members/classes/class-bp-rest-attachments-member-avatar-endpoint.php';
		$controller = new BP_REST_Attachments_Member_Avatar_Endpoint();
		$controller->register_routes();

		// Support Member's Cover.
		if ( bp_is_active( 'members', 'cover_image' ) ) {
			require_once __DIR__ . '/includes/bp-members/classes/class-bp-rest-attachments-member-cover-endpoint.php';
			$controller = new BP_REST_Attachments_Member_Cover_Endpoint();
			$controller->register_routes();
		}

		if ( bp_get_signup_allowed() ) {
			require_once __DIR__ . '/includes/bp-members/classes/class-bp-rest-signup-endpoint.php';
			$controller = new BP_REST_Signup_Endpoint();
			$controller->register_routes();
		}
	}

	if ( bp_is_active( 'activity' ) ) {
		require_once __DIR__ . '/includes/bp-activity/classes/class-bp-rest-activity-endpoint.php';
		$controller = new BP_REST_Activity_Endpoint();
		$controller->register_routes();
	}

	if ( is_multisite() && bp_is_active( 'blogs' ) ) {
		require_once __DIR__ . '/includes/bp-blogs/classes/class-bp-rest-blogs-endpoint.php';
		$controller = new BP_REST_Blogs_Endpoint();
		$controller->register_routes();

		// Support to Blog Avatar.
		if ( bp_is_active( 'blogs', 'site-icon' ) ) {
			require_once __DIR__ . '/includes/bp-attachments/classes/trait-attachments.php';
			require_once __DIR__ . '/includes/bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php';
			$controller = new BP_REST_Attachments_Blog_Avatar_Endpoint();
			$controller->register_routes();
		}
	}

	if ( bp_is_active( 'xprofile' ) ) {
		require_once __DIR__ . '/includes/bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php';
		$controller = new BP_REST_XProfile_Fields_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-xprofile/classes/class-bp-rest-xprofile-field-groups-endpoint.php';
		$controller = new BP_REST_XProfile_Field_Groups_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-xprofile/classes/class-bp-rest-xprofile-data-endpoint.php';
		$controller = new BP_REST_XProfile_Data_Endpoint();
		$controller->register_routes();
	}

	if ( bp_is_active( 'groups' ) ) {
		require_once __DIR__ . '/includes/bp-groups/classes/class-bp-rest-groups-endpoint.php';
		$controller = new BP_REST_Groups_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-groups/classes/class-bp-rest-group-membership-endpoint.php';
		$controller = new BP_REST_Group_Membership_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-groups/classes/class-bp-rest-group-invites-endpoint.php';
		$controller = new BP_REST_Group_Invites_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-groups/classes/class-bp-rest-group-membership-request-endpoint.php';
		$controller = new BP_REST_Group_Membership_Request_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-attachments/classes/trait-attachments.php';
		require_once __DIR__ . '/includes/bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php';
		$controller = new BP_REST_Attachments_Group_Avatar_Endpoint();
		$controller->register_routes();

		// Support to Group Cover.
		if ( bp_is_active( 'groups', 'cover_image' ) ) {
			require_once __DIR__ . '/includes/bp-groups/classes/class-bp-rest-attachments-group-cover-endpoint.php';
			$controller = new BP_REST_Attachments_Group_Cover_Endpoint();
			$controller->register_routes();
		}
	}

	if ( bp_is_active( 'messages' ) ) {
		require_once __DIR__ . '/includes/bp-messages/classes/class-bp-rest-messages-endpoint.php';
		$controller = new BP_REST_Messages_Endpoint();
		$controller->register_routes();

		require_once __DIR__ . '/includes/bp-messages/classes/class-bp-rest-sitewide-notices-endpoint.php';
		$controller = new BP_REST_Sitewide_Notices_Endpoint();
		$controller->register_routes();
	}

	if ( bp_is_active( 'notifications' ) ) {
		require_once __DIR__ . '/includes/bp-notifications/classes/class-bp-rest-notifications-endpoint.php';
		$controller = new BP_REST_Notifications_Endpoint();
		$controller->register_routes();
	}

	if ( bp_is_active( 'friends' ) ) {
		require_once __DIR__ . '/includes/bp-friends/classes/class-bp-rest-friends-endpoint.php';
		$controller = new BP_REST_Friends_Endpoint();
		$controller->register_routes();
	}
}
add_action( 'bp_rest_api_init', 'bp_rest', 5 );

/**
 * Set the current BP REST namespace.
 *
 * @return string
 */
function bp_filter_v1_rest_current_rest_namespace() {
	return 'buddypress';
}
add_filter( 'bp_rest_namespace', 'bp_filter_v1_rest_current_rest_namespace' );

/**
 * Set the current BP REST version.
 *
 * @return string
 */
function bp_filter_v1_rest_current_rest_version() {
	return 'v1';
}
add_filter( 'bp_rest_version', 'bp_filter_v1_rest_current_rest_version' );

/**
 * Filter the Blog url in the WP_REST_Request::from_url().
 *
 * @param WP_REST_Request $request Request used to generate the response.
 * @param string          $url     URL being requested.
 * @return WP_REST_Request
 */
function bp_filter_v1_rest_request_blog_url( $request, $url ) {

	if ( ! bp_is_active( 'blogs' ) || empty( $url ) ) {
		return $request;
	}

	// Get url info.
	$bits      = wp_parse_url( $url );
	$home_bits = wp_parse_url( get_home_url() );

	if ( empty( $bits['host'] ) || empty( $home_bits['host'] ) ) {
		return $request;
	}

	// Bail early if the request URL is the same as the current site.
	if ( $bits['host'] === $home_bits['host'] ) {
		return $request;
	}

	// Create a fake request to bypass the current logic.
	$request = new WP_REST_Request( 'GET', $bits['path'] );
	$request->set_query_params( array( 'bp_blogs_url' => $url ) );

	return $request;
}
add_filter( 'rest_request_from_url', 'bp_filter_v1_rest_request_blog_url', 10, 2 );

/**
 * Output BuddyPress blog response.
 *
 * @param WP_REST_Response $response Response generated by the request.
 * @param WP_REST_Server   $instance Server instance.
 * @param WP_REST_Request  $request  Request used to generate the response.
 * @return WP_REST_Response
 */
function bp_filter_v1_rest_post_dispatch( $response, $instance, $request ) {
	if (
		! bp_is_active( 'blogs' )
		|| 404 !== $response->get_status()
		|| 'embed' !== $request->get_param( 'context' )
		|| empty( $request->get_param( 'bp_blogs_url' ) )
		|| empty( $request->get_route() )
	) {
		return $response;
	}

	// Get domain from url.
	$bits = wp_parse_url( $request->get_param( 'bp_blogs_url' ) );

	// We need those two to proceed.
	if ( empty( $bits['host'] ) || empty( $bits['path'] ) ) {
		return $response;
	}

	// Request route and requested URL path should match.
	if ( $request->get_route() !== $bits['path'] ) {
		return $response;
	}

	// Get site using the domain.
	$site = get_site_by_path( $bits['host'], $bits['path'] );

	if ( ! $site instanceof WP_Site || empty( $site->blog_id ) ) {
		return $response;
	}

	switch_to_blog( absint( $site->blog_id ) );

	$response = rest_do_request(
		new WP_REST_Request(
			'GET',
			str_replace(
				'/wp-json',
				'',
				$request->get_route()
			)
		)
	);

	restore_current_blog();

	// Return it, regardless if it was successful or not.
	return $response;
}
add_filter( 'rest_post_dispatch', 'bp_filter_v1_rest_post_dispatch', 10, 3 );


================================================
FILE: composer.json
================================================
{
	"name": "buddypress/bp-rest",
	"description": "Access your BuddyPress site's data through an easy-to-use HTTP REST API.",
	"type": "wordpress-plugin",
	"keywords": [
		"bp-rest",
		"bp-rest-api",
		"buddypress",
		"rest",
		"plugin"
	],
	"homepage": "https://buddypress.org",
	"license": "GPL-2.0-or-later",
	"authors": [
		{
			"name": "BuddyPress Community",
			"homepage": "https://buddypress.org/about/"
		}
	],
	"support": {
		"forum": "https://buddypress.org/support/",
		"docs": "https://codex.buddypress.org/",
		"issues": "https://buddypress.trac.wordpress.org/",
		"rss": "https://buddypress.org/feed/",
		"source": "https://buddypress.trac.wordpress.org/browser/",
		"wiki": "https://codex.buddypress.org/"
	},
	"config": {
		"archive-format": "zip",
		"allow-plugins": {
			"dealerdirect/phpcodesniffer-composer-installer": true,
			"composer/installers": true
		}
	},
	"require": {
		"php": ">=5.6.0"
	},
	"require-dev": {
		"buddypress/bp-coding-standards": "dev-trunk",
		"yoast/phpunit-polyfills": "^1.0"
	},
	"scripts": {
		"test": "@php ./vendor/phpunit/phpunit/phpunit",
		"test_multi": "@php ./vendor/phpunit/phpunit/phpunit -c tests/multisite.xml",
		"phpunit": "@test",
		"phpcs": "@php ./vendor/bin/phpcs . --basepath=.",
		"phpcbf": "@php ./vendor/bin/phpcbf . --basepath=."
	},
	"archive": {
		"exclude": [
			"*.xml",
			"*.dist",
			"*.cache",
			"phpcs.xml.dist",
			"phpunit.xml.dist",
			"wp-env.json",
			"composer.json",
			"composer.lock",
			"package.json",
			"package-lock.json",
			".editorconfig",
			"CHANGELOG.md",
			"CONTRIBUTING.md",
			"README.md",
			".gitignore",
			".distignore",
			".deployignore",
			".github/",
			".phpcs/",
			"tests/",
			"bp-rest-api.zip",
			"!vendor/"
		]
	}
}


================================================
FILE: includes/bp-activity/classes/class-bp-rest-activity-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Activity_Endpoint class
 *
 * @package BuddyPress
 * @since 0.1.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Activity endpoints.
 *
 * @since 0.1.0
 */
class BP_REST_Activity_Endpoint extends WP_REST_Controller {

	/**
	 * User favorites.
	 *
	 * @since 0.1.0
	 *
	 * @var array|null
	 */
	protected $user_favorites = null;

	/**
	 * Constructor.
	 *
	 * @since 0.1.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Activity_REST_Controller' );

		$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base = buddypress()->activity->id;
	}

	/**
	 * Register the component routes.
	 *
	 * @since 0.1.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_items' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
					'args'                => $this->get_collection_params(),
				),
				array(
					'methods'             => WP_REST_Server::CREATABLE,
					'callback'            => array( $this, 'create_item' ),
					'permission_callback' => array( $this, 'create_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);

		$activity_endpoint = '/' . $this->rest_base . '/(?P<id>[\d]+)';

		register_rest_route(
			$this->namespace,
			$activity_endpoint,
			array(
				'args'   => array(
					'id' => array(
						'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => array(
						'context' => $this->get_context_param( array( 'default' => 'view' ) ),
					),
				),
				array(
					'methods'             => WP_REST_Server::EDITABLE,
					'callback'            => array( $this, 'update_item' ),
					'permission_callback' => array( $this, 'update_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
				),
				array(
					'methods'             => WP_REST_Server::DELETABLE,
					'callback'            => array( $this, 'delete_item' ),
					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);

		// Register the favorite route.
		register_rest_route(
			$this->namespace,
			$activity_endpoint . '/favorite',
			array(
				'args'   => array(
					'id' => array(
						'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::EDITABLE,
					'callback'            => array( $this, 'update_favorite' ),
					'permission_callback' => array( $this, 'update_favorite_permissions_check' ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Retrieve activities.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response List of activities response data.
	 */
	public function get_items( $request ) {
		$args = array(
			'exclude'           => $request->get_param( 'exclude' ),
			'in'                => $request->get_param( 'include' ),
			'page'              => $request->get_param( 'page' ),
			'per_page'          => $request->get_param( 'per_page' ),
			'search_terms'      => $request->get_param( 'search' ),
			'sort'              => $request->get_param( 'order' ),
			'spam'              => $request->get_param( 'status' ),
			'display_comments'  => $request->get_param( 'display_comments' ),
			'site_id'           => $request->get_param( 'site_id' ),
			'group_id'          => $request->get_param( 'group_id' ),
			'scope'             => $request->get_param( 'scope' ),
			'count_total'       => true,
			'fields'            => 'all',
			'show_hidden'       => false,
			'update_meta_cache' => true,
			'filter'            => array(),
		);

		if ( empty( $args['display_comments'] ) || 'false' === $args['display_comments'] ) {
			$args['display_comments'] = false;
		}

		if ( empty( $request->get_param( 'exclude' ) ) ) {
			$args['exclude'] = false;
		}

		if ( empty( $request->get_param( 'include' ) ) ) {
			$args['in'] = false;
		}

		if ( ! empty( $request->get_param( 'after' ) ) ) {
			$args['since'] = $request->get_param( 'after' );
		}

		if ( ! empty( $request->get_param( 'user_id' ) ) ) {
			$args['filter']['user_id'] = $request->get_param( 'user_id' );
		}

		$item_id = 0;
		if ( ! empty( $args['group_id'] ) ) {
			$args['filter']['object']     = 'groups';
			$args['filter']['primary_id'] = $args['group_id'];

			if ( empty( $request->get_param( 'component' ) ) ) {
				$request->set_param( 'component', 'groups' );
			}

			$item_id = $args['group_id'];
		}

		if ( ! empty( $args['site_id'] ) ) {
			$args['filter']['object']     = 'blogs';
			$args['filter']['primary_id'] = $args['site_id'];

			$item_id = $args['site_id'];
		}

		if ( empty( $args['group_id'] ) && empty( $args['site_id'] ) ) {
			if ( ! empty( $request->get_param( 'component' ) ) ) {
				$args['filter']['object'] = $request->get_param( 'component' );
			}

			if ( ! empty( $request->get_param( 'primary_id' ) ) ) {
				$item_id                      = $request->get_param( 'primary_id' );
				$args['filter']['primary_id'] = $item_id;
			}
		}

		if ( empty( $request->get_param( 'scope' ) ) ) {
			$args['scope'] = false;
		}

		if ( ! empty( $request->get_param( 'type' ) ) ) {
			$args['filter']['action'] = $request->get_param( 'type' );
		}

		if ( ! empty( $request->get_param( 'secondary_id' ) ) ) {
			$args['filter']['secondary_id'] = $request->get_param( 'secondary_id' );
		}

		if ( $args['in'] ) {
			$args['count_total'] = false;
		}

		if ( $this->show_hidden( $request->get_param( 'component' ), $item_id ) ) {
			$args['show_hidden'] = true;
		}

		/**
		 * Filter the query arguments for the request.
		 *
		 * @since 0.1.0
		 *
		 * @param array           $args    Key value array of query var to query value.
		 * @param WP_REST_Request $request Full data about the request.
		 */
		$args = apply_filters( 'bp_rest_activity_get_items_query_args', $args, $request );

		// Actually, query it.
		$activities = bp_activity_get( $args );

		$retval = array();
		foreach ( $activities['activities'] as $activity ) {
			$retval[] = $this->prepare_response_for_collection(
				$this->prepare_item_for_response( $activity, $request )
			);
		}

		$response = rest_ensure_response( $retval );
		$response = bp_rest_response_add_total_headers( $response, $activities['total'], $args['per_page'] );

		/**
		 * Fires after a list of activities is fetched via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param array            $activities Fetched activities.
		 * @param WP_REST_Response $response   The response data.
		 * @param WP_REST_Request  $request    Full data about the request.
		 */
		do_action( 'bp_rest_activity_get_items', $activities, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to activity items.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return true|WP_Error
	 */
	public function get_items_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'activity' ) ) ) {
			$retval = true;
		}

		/**
		 * Filter the activity `get_items` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request Full data about the request.
		 */
		return apply_filters( 'bp_rest_activity_get_items_permissions_check', $retval, $request );
	}

	/**
	 * Retrieve an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$activity = $this->get_activity_object( $request );

		if ( empty( $activity->id ) ) {
			return new WP_Error(
				'bp_rest_invalid_id',
				__( 'Invalid activity ID.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $activity, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after an activity is fetched via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Activity_Activity $activity Fetched activity.
		 * @param WP_REST_Response     $response The response data.
		 * @param WP_REST_Request      $request  The request sent to the API.
		 */
		do_action( 'bp_rest_activity_get_item', $activity, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to get information about a specific activity.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you cannot view the activities.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'activity' ) ) && $this->can_see( $request ) ) {
			$retval = true;
		}

		/**
		 * Filter the activity `get_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_activity_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Create an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full data about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function create_item( $request ) {
		$request->set_param( 'context', 'edit' );

		if ( empty( $request->get_param( 'content' ) ) ) {
			return new WP_Error(
				'bp_rest_create_activity_empty_content',
				__( 'Please, enter some content.', 'buddypress' ),
				array(
					'status' => 400,
				)
			);
		}

		$prepared_activity = $this->prepare_item_for_database( $request );

		// Fallback for the activity_update type.
		$type = 'activity_update';
		if ( ! empty( $request->get_param( 'type' ) ) ) {
			$type = $request->get_param( 'type' );
		}

		$prime       = $request->get_param( 'primary_item_id' );
		$activity_id = 0;

		// Post a regular activity update.
		if ( 'activity_update' === $type ) {
			if ( bp_is_active( 'groups' ) && ! is_null( $prime ) ) {
				$activity_id = groups_post_update( $prepared_activity );
			} else {
				$activity_id = bp_activity_post_update( $prepared_activity );
			}

			// Post an activity comment.
		} elseif ( 'activity_comment' === $type ) {

			// ID of the root activity item.
			if ( isset( $prime ) ) {
				$prepared_activity->activity_id = (int) $prime;
			}

			// ID of a parent comment.
			if ( ! empty( $request->get_param( 'secondary_item_id' ) ) ) {
				$prepared_activity->parent_id = $request->get_param( 'secondary_item_id' );
			}

			$activity_id = bp_activity_new_comment( $prepared_activity );

			// Otherwise add an activity.
		} else {
			$activity_id = bp_activity_add( $prepared_activity );
		}

		if ( ! is_numeric( $activity_id ) ) {
			return new WP_Error(
				'bp_rest_user_cannot_create_activity',
				__( 'Cannot create new activity.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$activity = bp_activity_get(
			array(
				'in'               => $activity_id,
				'display_comments' => 'stream',
				'show_hidden'      => true,
			)
		);

		$activity      = current( $activity['activities'] );
		$fields_update = $this->update_additional_fields_for_object( $activity, $request );

		if ( is_wp_error( $fields_update ) ) {
			return $fields_update;
		}

		// Update current user's last activity.
		bp_update_user_last_activity();

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $activity, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after an activity item is created via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Activity_Activity $activity The created activity.
		 * @param WP_REST_Response     $response The response data.
		 * @param WP_REST_Request      $request  The request sent to the API.
		 */
		do_action( 'bp_rest_activity_create_item', $activity, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to create an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function create_item_permissions_check( $request ) {
		$error = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to create activities.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		$retval = $error;

		if ( is_user_logged_in() ) {
			$user_id = $request->get_param( 'user_id' );

			if ( empty( $user_id ) || (int) bp_loggedin_user_id() === (int) $user_id ) {
				$item_id   = $request->get_param( 'primary_item_id' );
				$component = $request->get_param( 'component' );

				// The current user can create an activity.
				$retval = true;

				if ( bp_is_active( 'groups' ) && buddypress()->groups->id === $component && ! is_null( $item_id ) ) {
					if ( ! $this->show_hidden( $component, $item_id ) ) {
						$retval = $error;
					}
				}
			}
		}

		/**
		 * Filter the activity `create_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_activity_create_item_permissions_check', $retval, $request );
	}

	/**
	 * Update an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function update_item( $request ) {
		$request->set_param( 'context', 'edit' );

		if ( empty( $request->get_param( 'content' ) ) ) {
			return new WP_Error(
				'bp_rest_update_activity_empty_content',
				__( 'Please, enter some content.', 'buddypress' ),
				array(
					'status' => 400,
				)
			);
		}

		$activity_id = bp_activity_add( $this->prepare_item_for_database( $request ) );

		if ( ! is_numeric( $activity_id ) ) {
			return new WP_Error(
				'bp_rest_user_cannot_update_activity',
				__( 'Cannot update existing activity.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$activity      = $this->get_activity_object( $activity_id );
		$fields_update = $this->update_additional_fields_for_object( $activity, $request );

		if ( is_wp_error( $fields_update ) ) {
			return $fields_update;
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $activity, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after an activity is updated via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Activity_Activity $activity The updated activity.
		 * @param WP_REST_Response     $response The response data.
		 * @param WP_REST_Request      $request  The request sent to the API.
		 */
		do_action( 'bp_rest_activity_update_item', $activity, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to update an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function update_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to update this activity.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( is_user_logged_in() ) {
			$activity = $this->get_activity_object( $request );

			if ( empty( $activity->id ) ) {
				$retval = new WP_Error(
					'bp_rest_invalid_id',
					__( 'Invalid activity ID.', 'buddypress' ),
					array(
						'status' => 404,
					)
				);
			} elseif ( bp_activity_user_can_delete( $activity ) ) {
				$retval = true;
			}
		}

		/**
		 * Filter the activity `update_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_activity_update_item_permissions_check', $retval, $request );
	}

	/**
	 * Delete activity.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function delete_item( $request ) {
		// Setting context.
		$request->set_param( 'context', 'edit' );

		// Get the activity before it's deleted.
		$activity = $this->get_activity_object( $request );
		$previous = $this->prepare_item_for_response( $activity, $request );

		if ( 'activity_comment' === $activity->type ) {
			$retval = bp_activity_delete_comment( $activity->item_id, $activity->id );
		} else {
			$retval = bp_activity_delete(
				array(
					'id' => $activity->id,
				)
			);
		}

		if ( ! $retval ) {
			return new WP_Error(
				'bp_rest_activity_cannot_delete',
				__( 'Could not delete the activity.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Build the response.
		$response = new WP_REST_Response();
		$response->set_data(
			array(
				'deleted'  => true,
				'previous' => $previous->get_data(),
			)
		);

		/**
		 * Fires after an activity is deleted via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Activity_Activity $activity The deleted activity.
		 * @param WP_REST_Response     $response The response data.
		 * @param WP_REST_Request      $request  The request sent to the API.
		 */
		do_action( 'bp_rest_activity_delete_item', $activity, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to delete an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function delete_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to delete this activity.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( is_user_logged_in() ) {
			$activity = $this->get_activity_object( $request );

			if ( empty( $activity->id ) ) {
				$retval = new WP_Error(
					'bp_rest_invalid_id',
					__( 'Invalid activity ID.', 'buddypress' ),
					array(
						'status' => 404,
					)
				);
			} elseif ( bp_activity_user_can_delete( $activity ) ) {
				$retval = true;
			}
		}

		/**
		 * Filter the activity `delete_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_activity_delete_item_permissions_check', $retval, $request );
	}

	/**
	 * Gets the current user's favorites.
	 *
	 * @since 0.1.0
	 *
	 * @return array Array of activity IDs.
	 */
	public function get_user_favorites() {
		if ( null === $this->user_favorites ) {
			if ( is_user_logged_in() ) {
				$user_favorites       = bp_activity_get_user_favorites( get_current_user_id() );
				$this->user_favorites = array_filter( wp_parse_id_list( $user_favorites ) );
			} else {
				$this->user_favorites = array();
			}
		}

		return $this->user_favorites;
	}

	/**
	 * Adds or removes the activity from the current user's favorites.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function update_favorite( $request ) {
		$activity = $this->get_activity_object( $request );

		if ( empty( $activity->id ) ) {
			return new WP_Error(
				'bp_rest_invalid_id',
				__( 'Invalid activity ID.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$user_id = get_current_user_id();

		$result = false;
		if ( in_array( $activity->id, $this->get_user_favorites(), true ) ) {
			$result  = bp_activity_remove_user_favorite( $activity->id, $user_id );
			$message = __( 'Sorry, you cannot remove the activity from your favorites.', 'buddypress' );

			// Update the user favorites, removing the activity ID.
			$this->user_favorites = array_diff( $this->get_user_favorites(), array( $activity->id ) );
		} else {
			$result  = bp_activity_add_user_favorite( $activity->id, $user_id );
			$message = __( 'Sorry, you cannot add the activity to your favorites.', 'buddypress' );

			// Update the user favorites, adding the activity ID.
			$this->user_favorites[] = (int) $activity->id;
		}

		if ( ! $result ) {
			return new WP_Error(
				'bp_rest_user_cannot_update_activity_favorite',
				$message,
				array(
					'status' => 500,
				)
			);
		}

		// Prepare the response now the user favorites has been updated.
		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $activity, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after user favorited activities has been updated via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Activity_Activity $activity       The updated activity.
		 * @param array                $user_favorites The updated user favorites.
		 * @param WP_REST_Response     $response       The response data.
		 * @param WP_REST_Request      $request        The request sent to the API.
		 */
		do_action( 'bp_rest_activity_update_favorite', $activity, $this->get_user_favorites(), $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to update user favorites.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function update_favorite_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to update favorites.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( is_user_logged_in() && bp_activity_can_favorite() && $this->can_see( $request ) ) {
			$retval = true;
		}

		/**
		 * Filter the activity `update_favorite` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_activity_update_favorite_permissions_check', $retval, $request );
	}

	/**
	 * Renders the content of an activity.
	 *
	 * @since 0.1.0
	 *
	 * @param BP_Activity_Activity $activity Activity data.
	 * @return string The rendered activity content.
	 */
	public function render_item( $activity ) {
		$rendered = '';

		if ( empty( $activity->content ) ) {
			return $rendered;
		}

		// Do not truncate activities.
		add_filter( 'bp_activity_maybe_truncate_entry', '__return_false' );

		if ( 'activity_comment' === $activity->type ) {
			$rendered = apply_filters( 'bp_get_activity_content', $activity->content );
		} else {
			$activities_template = null;

			if ( isset( $GLOBALS['activities_template'] ) ) {
				$activities_template = $GLOBALS['activities_template'];
			}

			// Set the `activities_template` global for the current activity.
			$GLOBALS['activities_template']           = new stdClass();
			$GLOBALS['activities_template']->activity = $activity;

			// Set up activity oEmbed cache.
			bp_activity_embed();

			$rendered = apply_filters( 'bp_get_activity_content_body', $activity->content, $activity );

			// Restore the `activities_template` global.
			$GLOBALS['activities_template'] = $activities_template;
		}

		// Restore the filter to truncate activities.
		remove_filter( 'bp_activity_maybe_truncate_entry', '__return_false' );

		return $rendered;
	}

	/**
	 * Prepares activity data for return as an object.
	 *
	 * @since 0.1.0
	 *
	 * @param BP_Activity_Activity $activity Activity object.
	 * @param WP_REST_Request      $request  Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $activity, $request ) {
		$data = array(
			'user_id'           => $activity->user_id,
			'component'         => $activity->component,
			'content'           => array(
				'raw'      => $activity->content,
				'rendered' => $this->render_item( $activity ),
			),
			'date'              => bp_rest_prepare_date_response( $activity->date_recorded, get_date_from_gmt( $activity->date_recorded ) ),
			'date_gmt'          => bp_rest_prepare_date_response( $activity->date_recorded ),
			'id'                => $activity->id,
			'link'              => bp_activity_get_permalink( $activity->id ),
			'primary_item_id'   => $activity->item_id,
			'secondary_item_id' => $activity->secondary_item_id,
			'status'            => $activity->is_spam ? 'spam' : 'published',
			'title'             => $activity->action,
			'type'              => $activity->type,
			'hidden'            => (bool) $activity->hide_sitewide,
			'favorited'         => in_array( $activity->id, $this->get_user_favorites(), true ),
		);

		// Get item schema.
		$schema = $this->get_item_schema();

		// Get comments (count).
		if ( ! empty( $activity->children ) ) {
			$comment_count         = wp_filter_object_list( $activity->children, array( 'type' => 'activity_comment' ), 'AND', 'id' );
			$data['comment_count'] = ! empty( $comment_count ) ? count( $comment_count ) : 0;

			if ( ! empty( $schema['properties']['comments'] ) && 'threaded' === $request->get_param( 'display_comments' ) ) {
				$data['comments'] = $this->prepare_activity_comments( $activity->children, $request );
			}
		}

		if ( true === buddypress()->avatar->show_avatars ) {
			$data['user_avatar'] = array(
				'full'  => bp_core_fetch_avatar(
					array(
						'item_id' => $activity->user_id,
						'html'    => false,
						'type'    => 'full',
					)
				),
				'thumb' => bp_core_fetch_avatar(
					array(
						'item_id' => $activity->user_id,
						'html'    => false,
					)
				),
			);
		}

		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $data, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		$response->add_links( $this->prepare_links( $activity ) );

		/**
		 * Filter an activity value returned from the API.
		 *
		 * @since 0.1.0
		 *
		 * @param WP_REST_Response     $response The response data.
		 * @param WP_REST_Request      $request  Request used to generate the response.
		 * @param BP_Activity_Activity $activity The activity object.
		 */
		return apply_filters( 'bp_rest_activity_prepare_value', $response, $request, $activity );
	}

	/**
	 * Prepare activity comments.
	 *
	 * @since 0.1.0
	 *
	 * @param  array           $comments Array of comments.
	 * @param  WP_REST_Request $request  Full details about the request.
	 * @return array           An array of activity comments.
	 */
	protected function prepare_activity_comments( $comments, $request ) {
		$data = array();

		if ( empty( $comments ) ) {
			return $data;
		}

		foreach ( $comments as $comment ) {
			$data[] = $this->prepare_response_for_collection(
				$this->prepare_item_for_response( $comment, $request )
			);
		}

		/**
		 * Filter activity comments returned from the API.
		 *
		 * @since 0.1.0
		 *
		 * @param array           $data     An array of activity comments with proper API response.
		 * @param array           $comments An array of activity comments.
		 * @param WP_REST_Request $request  Full details about the request.
		 */
		return apply_filters( 'bp_rest_activity_prepare_comments', $data, $comments, $request );
	}

	/**
	 * Prepare an activity for create or update.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return stdClass|WP_Error Object or WP_Error.
	 */
	protected function prepare_item_for_database( $request ) {
		$prepared_activity = new stdClass();
		$schema            = $this->get_item_schema();
		$activity          = $this->get_activity_object( $request );

		if ( ! empty( $schema['properties']['id'] ) && ! empty( $activity->id ) ) {
			$prepared_activity->id = $activity->id;

			if ( 'activity_comment' !== $request->get_param( 'type' ) ) {
				$prepared_activity->error_type = 'wp_error';
			}
		}

		// Activity author ID.
		if ( ! empty( $activity->user_id ) ) {
			$prepared_activity->user_id = (int) $activity->user_id;
		} else {
			$prepared_activity->user_id = get_current_user_id();
		}

		// Activity component.
		if ( ! empty( $schema['properties']['component'] ) && ! empty( $request->get_param( 'component' ) ) ) {
			$prepared_activity->component = $request->get_param( 'component' );
		} else {
			$prepared_activity->component = buddypress()->activity->id;
		}

		// Activity date.
		if ( ! empty( $activity->date_recorded ) ) {
			$prepared_activity->recorded_time = $activity->date_recorded;
		}

		// Activity Item ID.
		if ( ! empty( $schema['properties']['primary_item_id'] ) && ! empty( $request->get_param( 'primary_item_id' ) ) ) {
			$item_id = (int) $request->get_param( 'primary_item_id' );

			// Use a generic item ID.
			$prepared_activity->item_id = $item_id;

			// Set the group ID, used in the `groups_post_update` helper function only.
			if ( bp_is_active( 'groups' ) && isset( $prepared_activity->component ) && buddypress()->groups->id === $prepared_activity->component ) {
				$prepared_activity->group_id = $item_id;
			}
		}

		// Secondary Item ID.
		if ( ! empty( $schema['properties']['secondary_item_id'] ) && ! empty( $request->get_param( 'secondary_item_id' ) ) ) {
			$prepared_activity->secondary_item_id = (int) $request->get_param( 'secondary_item_id' );
		}

		// Activity type.
		if ( ! empty( $schema['properties']['type'] ) && ! empty( $request->get_param( 'type' ) ) ) {
			$prepared_activity->type = $request->get_param( 'type' );
		}

		// Activity content.
		if ( ! empty( $schema['properties']['content'] ) && ! empty( $request->get_param( 'content' ) ) ) {
			if ( is_string( $request->get_param( 'content' ) ) ) {
				$prepared_activity->content = $request->get_param( 'content' );
			} elseif ( isset( $request['content']['raw'] ) ) {
				$prepared_activity->content = $request['content']['raw'];
			}
		}

		// Activity Sitewide visibility.
		if ( ! empty( $schema['properties']['hidden'] ) ) {
			$is_hidden = $request->get_param( 'hidden' );

			if ( ! is_null( $is_hidden ) ) {
				$is_hidden = wp_validate_boolean( $is_hidden );
			} elseif ( isset( $activity->hide_sitewide ) ) {
				$is_hidden = (bool) $activity->hide_sitewide;
			} elseif ( bp_is_active( 'groups' ) && isset( $prepared_activity->item_id, $prepared_activity->component ) && $prepared_activity->item_id && buddypress()->groups->id === $prepared_activity->component ) {
				$group     = bp_get_group_by( 'id', $prepared_activity->item_id );
				$is_hidden = isset( $group->status ) && 'public' !== $group->status;
			}

			$prepared_activity->hide_sitewide = $is_hidden;
		}

		/**
		 * Filters an activity before it is inserted or updated via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param stdClass        $prepared_activity An object prepared for inserting or updating the database.
		 * @param WP_REST_Request $request Request object.
		 */
		return apply_filters( 'bp_rest_activity_pre_insert_value', $prepared_activity, $request );
	}

	/**
	 * Prepare links for the request.
	 *
	 * @since 0.1.0
	 *
	 * @param BP_Activity_Activity $activity Activity object.
	 * @return array
	 */
	protected function prepare_links( $activity ) {
		$base = sprintf( '/%1$s/%2$s/', $this->namespace, $this->rest_base );
		$url  = $base . $activity->id;

		// Entity meta.
		$links = array(
			'self'       => array(
				'href' => rest_url( $url ),
			),
			'collection' => array(
				'href' => rest_url( $base ),
			),
		);

		// Embeds.
		if ( ! empty( $activity->user_id ) ) {
			$links['user'] = array(
				'href'       => bp_rest_get_object_url( absint( $activity->user_id ), 'members' ),
				'embeddable' => true,
			);
		}

		if ( 'activity_comment' === $activity->type ) {
			$links['up'] = array(
				'href' => rest_url( $url ),
			);
		}

		// Embed Group.
		if ( bp_is_active( 'groups' ) && buddypress()->groups->id === $activity->component && ! empty( $activity->item_id ) ) {
			$links['group'] = array(
				'embeddable' => true,
				'href'       => rest_url(
					sprintf(
						'/%1$s/%2$s/%3$d',
						$this->namespace,
						buddypress()->groups->id,
						absint( $activity->item_id )
					)
				),
			);
		}

		// Embed Blog.
		if ( is_multisite() && bp_is_active( 'blogs' ) && buddypress()->blogs->id === $activity->component && ! empty( $activity->item_id ) ) {
			$links['blog'] = array(
				'embeddable' => true,
				'href'       => rest_url(
					sprintf(
						'/%1$s/%2$s/%3$d',
						$this->namespace,
						buddypress()->blogs->id,
						absint( $activity->item_id )
					)
				),
			);
		}

		// Actions.
		if ( is_user_logged_in() && bp_activity_can_favorite() ) {
			$favorite_action = array(
				'href'        => rest_url( $url . '/favorite' ),
				'activity_id' => $activity->id,
			);

			// Will be deprecated.
			$links['favorite']           = $favorite_action;
			$links['bp-action-favorite'] = $favorite_action;
		}

		/**
		 * Filter links prepared for the REST response.
		 *
		 * @since 0.1.0
		 *
		 * @param array                $links     The prepared links of the REST response.
		 * @param BP_Activity_Activity $activity  Activity object.
		 */
		return apply_filters( 'bp_rest_activity_prepare_links', $links, $activity );
	}

	/**
	 * Can this user see the activity?
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return boolean
	 */
	protected function can_see( $request ) {
		return bp_activity_user_can_read(
			$this->get_activity_object( $request ),
			bp_loggedin_user_id()
		);
	}

	/**
	 * Show hidden activity?
	 *
	 * @since 0.1.0
	 *
	 * @param  string $component The component the activity is from.
	 * @param  int    $item_id   The activity item ID.
	 * @return boolean
	 */
	protected function show_hidden( $component, $item_id ) {
		$user_id = get_current_user_id();
		$retval  = false;

		if ( ! is_null( $component ) ) {
			// If activity is from a group, check the user is a confirmed member/admin or mod of the group.
			if ( 'groups' === $component && bp_is_active( 'groups' ) && ! empty( $item_id ) ) {
				$retval = (bool) groups_is_user_member( $user_id, $item_id );
			}

			/**
			 * Filter here to manage hidden activity for the component.
			 *
			 * @since 0.7.0
			 *
			 * @param bool   $retval    True to show hidden activities. False otherwise.
			 * @param string $component The component name/ID.
			 * @param int    $user_id   The current user ID.
			 */
			$retval = apply_filters( 'bp_rest_activity_show_hidden', $retval, $component, $user_id );
		}

		// Moderators as well.
		if ( bp_current_user_can( 'bp_moderate' ) ) {
			$retval = true;
		}

		return (bool) $retval;
	}

	/**
	 * Get activity object.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return BP_Activity_Activity|string An activity object.
	 */
	public function get_activity_object( $request ) {
		$activity_id = is_numeric( $request ) ? $request : (int) $request->get_param( 'id' );

		$activity = bp_activity_get_specific(
			array(
				'activity_ids'     => array( $activity_id ),
				'display_comments' => true,
			)
		);

		if ( is_array( $activity ) && ! empty( $activity['activities'][0] ) ) {
			return $activity['activities'][0];
		}

		return '';
	}

	/**
	 * Edit the type of the some properties for the CREATABLE & EDITABLE methods.
	 *
	 * @since 0.1.0
	 *
	 * @param string $method Optional. HTTP method of the request.
	 * @return array Endpoint arguments.
	 */
	public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
		$args = parent::get_endpoint_args_for_item_schema( $method );
		$key  = 'get_item';

		if ( WP_REST_Server::CREATABLE === $method || WP_REST_Server::EDITABLE === $method ) {
			$key                     = 'create_item';
			$args['content']['type'] = 'string';
			unset( $args['content']['properties'] );

			if ( WP_REST_Server::EDITABLE === $method ) {
				$key                      = 'update_item';
				$args['type']['required'] = true;
			}
		} elseif ( WP_REST_Server::DELETABLE === $method ) {
			$key = 'delete_item';
		}

		/**
		 * Filters the method query arguments.
		 *
		 * @since 0.1.0
		 *
		 * @param array  $args   Query arguments.
		 * @param string $method HTTP method of the request.
		 */
		return apply_filters( "bp_rest_activity_{$key}_query_arguments", $args, $method );
	}

	/**
	 * Get the plugin schema, conforming to JSON Schema.
	 *
	 * @since 0.1.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_activity',
				'type'       => 'object',
				'properties' => array(
					'id'                => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'primary_item_id'   => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The ID of some other object primarily associated with this one.', 'buddypress' ),
						'type'        => 'integer',
					),
					'secondary_item_id' => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The ID of some other object also associated with this one.', 'buddypress' ),
						'type'        => 'integer',
					),
					'user_id'           => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The ID for the author of the activity.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'link'              => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The permalink to this activity on the site.', 'buddypress' ),
						'format'      => 'uri',
						'type'        => 'string',
					),
					'component'         => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The active BuddyPress component the activity relates to.', 'buddypress' ),
						'type'        => 'string',
						'enum'        => array_keys( buddypress()->active_components ),
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_key',
						),
					),
					'type'              => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The activity type of the activity.', 'buddypress' ),
						'type'        => 'string',
						'enum'        => array_keys( bp_activity_get_types() ),
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_key',
						),
					),
					'title'             => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The description of the activity\'s type (eg: Username posted an update)', 'buddypress' ),
						'type'        => 'string',
						'readonly'    => true,
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_text_field',
						),
					),
					'content'           => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'Allowed HTML content for the activity.', 'buddypress' ),
						'type'        => 'object',
						'arg_options' => array(
							'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
							'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
						),
						'properties'  => array(
							'raw'      => array(
								'description' => __( 'Content for the activity, as it exists in the database.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'edit' ),
							),
							'rendered' => array(
								'description' => __( 'HTML content for the activity, transformed for display.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit', 'embed' ),
								'readonly'    => true,
							),
						),
					),
					'date'              => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The date the activity was published, in the site\'s timezone.', 'buddypress' ),
						'readonly'    => true,
						'type'        => array( 'string', 'null' ),
						'format'      => 'date-time',
					),
					'date_gmt'          => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The date the activity was published, as GMT.', 'buddypress' ),
						'readonly'    => true,
						'type'        => array( 'string', 'null' ),
						'format'      => 'date-time',
					),
					'status'            => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'Whether the activity has been marked as spam or not.', 'buddypress' ),
						'type'        => 'string',
						'enum'        => array( 'published', 'spam' ),
						'readonly'    => true,
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_key',
						),
					),
					'comments'          => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'A list of objects children of the activity object.', 'buddypress' ),
						'type'        => 'array',
						'readonly'    => true,
					),
					'comment_count'     => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'Total number of comments of the activity object.', 'buddypress' ),
						'type'        => 'integer',
						'readonly'    => true,
					),
					'hidden'            => array(
						'context'     => array( 'edit', 'embed' ),
						'description' => __( 'Whether the activity object should be sitewide hidden or not.', 'buddypress' ),
						'type'        => 'boolean',
					),
					'favorited'         => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'Whether the activity object has been favorited by the current user.', 'buddypress' ),
						'type'        => 'boolean',
						'readonly'    => true,
					),
				),
			);

			if ( true === buddypress()->avatar->show_avatars ) {
				$avatar_properties = array();

				$avatar_properties['full'] = array(
					'context'     => array( 'view', 'edit', 'embed' ),
					/* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
					'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
				);

				$avatar_properties['thumb'] = array(
					'context'     => array( 'view', 'edit', 'embed' ),
					/* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
					'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
				);

				$schema['properties']['user_avatar'] = array(
					'context'     => array( 'view', 'edit', 'embed' ),
					'description' => __( 'Avatar URLs for the author of the activity.', 'buddypress' ),
					'type'        => 'object',
					'readonly'    => true,
					'properties'  => $avatar_properties,
				);
			}

			// Cache current schema here.
			$this->schema = $schema;
		}

		/**
		 * Filters the activity schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_activity_schema', $this->add_additional_fields_schema( $this->schema ) );
	}

	/**
	 * Get the query params for collections of plugins.
	 *
	 * @since 0.1.0
	 *
	 * @return array
	 */
	public function get_collection_params() {
		$params                       = parent::get_collection_params();
		$params['context']['default'] = 'view';

		$params['exclude'] = array(
			'description'       => __( 'Ensure result set excludes specific IDs.', 'buddypress' ),
			'default'           => array(),
			'type'              => 'array',
			'items'             => array( 'type' => 'integer' ),
			'sanitize_callback' => 'wp_parse_id_list',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['include'] = array(
			'description'       => __( 'Ensure result set includes specific IDs.', 'buddypress' ),
			'default'           => array(),
			'type'              => 'array',
			'items'             => array( 'type' => 'integer' ),
			'sanitize_callback' => 'wp_parse_id_list',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['order'] = array(
			'description'       => __( 'Order sort attribute ascending or descending.', 'buddypress' ),
			'default'           => 'desc',
			'type'              => 'string',
			'enum'              => array( 'asc', 'desc' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['after'] = array(
			'description'       => __( 'Limit result set to items published after a given ISO8601 compliant date.', 'buddypress' ),
			'type'              => 'string',
			'format'            => 'date-time',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['user_id'] = array(
			'description'       => __( 'Limit result set to items created by a specific user (ID).', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['status'] = array(
			'description'       => __( 'Limit result set to items with a specific status.', 'buddypress' ),
			'default'           => 'ham_only',
			'type'              => 'string',
			'enum'              => array( 'ham_only', 'spam_only', 'all' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['scope'] = array(
			'description'       => __( 'Limit result set to items with a specific scope.', 'buddypress' ),
			'type'              => 'string',
			'enum'              => array( 'just-me', 'friends', 'groups', 'favorites', 'mentions' ),
			'sanitize_callback' => 'sanitize_text_field',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['group_id'] = array(
			'description'       => __( 'Limit result set to items created by a specific group.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['site_id'] = array(
			'description'       => __( 'Limit result set to items created by a specific site.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['primary_id'] = array(
			'description'       => __( 'Limit result set to items with a specific prime association ID.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['secondary_id'] = array(
			'description'       => __( 'Limit result set to items with a specific secondary association ID.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['component'] = array(
			'description'       => __( 'Limit result set to items with a specific active BuddyPress component.', 'buddypress' ),
			'type'              => 'string',
			'enum'              => array_keys( buddypress()->active_components ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['type'] = array(
			'description'       => __( 'Limit result set to items with a specific activity type.', 'buddypress' ),
			'type'              => 'array',
			'items'             => array(
				'enum' => array_keys( bp_activity_get_types() ),
				'type' => 'string',
			),
			'sanitize_callback' => 'wp_parse_list',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['display_comments'] = array(
			'description'       => __( 'No comments by default, stream for within stream display, threaded for below each activity item.', 'buddypress' ),
			'default'           => '',
			'type'              => 'string',
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		/**
		 * Filters the collection query params.
		 *
		 * @param array $params Query params.
		 */
		return apply_filters( 'bp_rest_activity_collection_params', $params );
	}
}


================================================
FILE: includes/bp-attachments/classes/trait-attachments.php
================================================
<?php
/**
 * BP REST: Attachments Trait
 *
 * @package BuddyPress
 * @since 0.1.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Attachments Trait
 *
 * @since 0.1.0
 */
trait BP_REST_Attachments {

	/**
	 * Cover upload from file.
	 *
	 * @since 6.0.0
	 *
	 * @param array $file $_FILES superglobal.
	 * @return string|WP_Error
	 */
	protected function upload_cover_from_file( $file ) {

		// Set global variables.
		$bp = buddypress();
		switch ( $this->object ) {
			case 'group':
				$bp->groups->current_group = $this->group;
				$bp->current_component     = 'groups';
				break;
			case 'user':
			default:
				$bp->displayed_user     = new stdClass();
				$bp->displayed_user->id = (int) $this->user->ID;
				break;
		}

		// Try to upload image.
		$uploaded_image = $this->attachment_instance->upload( $file );

		// Bail with error.
		if ( ! empty( $uploaded_image['error'] ) ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_cover_upload_error",
				sprintf(
					/* translators: %s: the upload error message */
					__( 'Upload Failed! Error was: %s', 'buddypress' ),
					$uploaded_image['error']
				),
				array(
					'status' => 500,
					'reason' => 'upload_error',
				)
			);
		}

		$component                  = $this->get_cover_object_component();
		$item_id                    = $this->get_item_id();
		$bp_attachments_uploads_dir = bp_attachments_cover_image_upload_dir(
			array(
				'object_directory' => $component,
				'object_id'        => $item_id,
			)
		);

		// The BP Attachments Uploads Dir is not set, stop.
		if ( ! $bp_attachments_uploads_dir ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_cover_upload_error",
				__( 'The BuddyPress attachments uploads directory is not set.', 'buddypress' ),
				array(
					'status' => 500,
					'reason' => 'attachments_upload_dir',
				)
			);
		}

		$cover_subdir = $bp_attachments_uploads_dir['subdir'];
		$cover_dir    = $bp_attachments_uploads_dir['basedir'] . $cover_subdir;

		// If upload path doesn't exist, stop.
		if ( 1 === validate_file( $cover_dir ) || ! is_dir( $cover_dir ) ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_cover_upload_error",
				__( 'The cover image directory is not valid.', 'buddypress' ),
				array(
					'status' => 500,
					'reason' => 'cover_image_dir',
				)
			);
		}

		// Upload cover.
		$cover = bp_attachments_cover_image_generate_file(
			array(
				'file'            => $uploaded_image['file'],
				'component'       => $component,
				'cover_image_dir' => $cover_dir,
			)
		);

		// Bail if any error happened.
		if ( false === $cover ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_cover_upload_error",
				__( 'There was a problem uploading the cover image.', 'buddypress' ),
				array(
					'status' => 500,
					'reason' => 'unknown',
				)
			);
		}

		// Bail with error if too small.
		if ( true === $cover['is_too_small'] ) {

			// Get cover image advised dimensions.
			$cover_dimensions = bp_attachments_get_cover_image_dimensions( $component );

			return new WP_Error(
				"bp_rest_attachments_{$this->object}_cover_upload_error",
				sprintf(
					/* translators: %$1s and %$2s is replaced with the correct sizes. */
					__( 'You have selected an image that is smaller than recommended. For better results, make sure to upload an image that is larger than %1$spx wide, and %2$spx tall.', 'buddypress' ),
					(int) $cover_dimensions['width'],
					(int) $cover_dimensions['height']
				),
				array(
					'status'     => 400,
					'reason'     => 'image_too_small',
					'min_width'  => (int) $cover_dimensions['width'],
					'min_height' => (int) $cover_dimensions['height'],
				)
			);
		}

		return sprintf(
			'%1$s/%2$s/%3$s',
			$bp_attachments_uploads_dir['baseurl'],
			$cover_subdir,
			$cover['cover_basename']
		);
	}

	/**
	 * Avatar upload from File.
	 *
	 * @since 0.1.0
	 *
	 * @param array $files $_FILES superglobal.
	 * @return stdClass|WP_Error
	 */
	protected function upload_avatar_from_file( $files ) {

		// Set global variables.
		$bp = buddypress();
		switch ( $this->object ) {
			case 'group':
				$bp->groups->current_group = $this->group;
				$upload_main_dir           = 'groups_avatar_upload_dir';
				break;
			case 'user':
			default:
				$upload_main_dir        = 'bp_members_avatar_upload_dir';
				$bp->displayed_user     = new stdClass();
				$bp->displayed_user->id = (int) $this->user->ID;
				break;
		}

		$avatar_attachment = $this->avatar_instance;
		$avatar_original   = $avatar_attachment->upload( $files, $upload_main_dir );

		// Bail early in case of an error.
		if ( ! empty( $avatar_original['error'] ) ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_avatar_upload_error",
				sprintf(
					/* translators: %s: the upload error message */
					__( 'Upload failed! Error was: %s.', 'buddypress' ),
					$avatar_original['error']
				),
				array(
					'status' => 500,
					'reason' => 'upload_error',
				)
			);
		}

		// Get image and bail early if there is an error.
		$image_file = $this->resize( $avatar_original['file'] );
		if ( is_wp_error( $image_file ) ) {
			return $image_file;
		}

		// If the uploaded image is smaller than the "full" dimensions, throw a warning.
		if ( $avatar_attachment->is_too_small( $image_file ) ) {
			$full_width  = bp_core_avatar_full_width();
			$full_height = bp_core_avatar_full_height();

			return new WP_Error(
				"bp_rest_attachments_{$this->object}_avatar_error",
				sprintf(
					/* translators: %1$s and %2$s is replaced with the correct sizes. */
					__( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %1$s x %2$s pixels.', 'buddypress' ),
					$full_width,
					$full_height
				),
				array(
					'status'     => 400,
					'reason'     => 'image_too_small',
					'min_width'  => $full_width,
					'min_height' => $full_height,
				)
			);
		}

		// Delete existing image if one exists.
		$this->delete_existing_image();

		// Crop the profile photo accordingly and bail early in case of an error.
		$cropped = $this->crop_image( $image_file );
		if ( is_wp_error( $cropped ) ) {
			return $cropped;
		}

		// Set the arguments for the avatar.
		$args = array();
		foreach ( array( 'full', 'thumb' ) as $key_type ) {

			// Update path with an url.
			$url = str_replace( bp_core_avatar_upload_path(), '', $cropped[ $key_type ] );

			// Set image url to its size/type.
			$args[ $key_type ] = bp_core_avatar_url() . $url;
		}

		// Build response object.
		$avatar_object = $this->get_avatar_object( $args );

		if ( file_exists( $avatar_original['file'] ) ) {
			wp_delete_file( $avatar_original['file'] );
		}

		return $avatar_object;
	}

	/**
	 * Resize image.
	 *
	 * @since 0.1.0
	 *
	 * @param string $file Image to resize.
	 * @return string|WP_Error
	 */
	protected function resize( $file ) {
		$bp          = buddypress();
		$upload_path = bp_core_avatar_upload_path();

		if ( ! isset( $bp->avatar_admin ) ) {
			$bp->avatar_admin = new stdClass();
		}

		// The Avatar UI available width.
		$ui_available_width = 0;

		// Try to set the ui_available_width using the avatar_admin global.
		if ( isset( $bp->avatar_admin->ui_available_width ) ) {
			$ui_available_width = $bp->avatar_admin->ui_available_width;
		}

		$resized = $this->avatar_instance->shrink( $file, $ui_available_width );

		// We only want to handle one image after resize.
		if ( empty( $resized ) ) {
			$image_file = $file;
			$img_dir    = str_replace( $upload_path, '', $file );
		} else {
			$image_file = $resized['path'];
			$img_dir    = str_replace( $upload_path, '', $resized['path'] );

			wp_delete_file( $file );
		}

		// Check for WP_Error on what should be an image.
		if ( is_wp_error( $img_dir ) ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_avatar_upload_error",
				sprintf(
					/* translators: %s: the upload error message */
					__( 'Upload failed! Error was: %s', 'buddypress' ),
					$img_dir->get_error_message()
				),
				array(
					'status' => 500,
					'reason' => 'resize_error',
				)
			);
		}

		return $image_file;
	}

	/**
	 * Crop image.
	 *
	 * @since 0.1.0
	 *
	 * @param string $image_file Image to crop.
	 * @return array|WP_Error
	 */
	protected function crop_image( $image_file ) {
		$image          = getimagesize( $image_file );
		$avatar_to_crop = str_replace( bp_core_avatar_upload_path(), '', $image_file );

		// Get avatar full width and height.
		$full_height = bp_core_avatar_full_height();
		$full_width  = bp_core_avatar_full_width();

		// Use as much as possible of the image.
		$avatar_ratio = $full_width / $full_height;
		$image_ratio  = $image[0] / $image[1];

		if ( $image_ratio >= $avatar_ratio ) {
			// Uploaded image is wider than BP ratio, so we crop horizontally.
			$crop_y = 0;
			$crop_h = $image[1];

			// Get the target width by multiplying unmodified image height by target ratio.
			$crop_w    = $avatar_ratio * $image[1];
			$padding_w = round( ( $image[0] - $crop_w ) / 2 );
			$crop_x    = $padding_w;
		} else {
			// Uploaded image is narrower than BP ratio, so we crop vertically.
			$crop_x = 0;
			$crop_w = $image[0];

			// Get the target height by multiplying unmodified image width by target ratio.
			$crop_h    = $avatar_ratio * $image[0];
			$padding_h = round( ( $image[1] - $crop_h ) / 2 );
			$crop_y    = $padding_h;
		}

		add_filter( 'bp_attachments_current_user_can', '__return_true' );

		// Crop the image.
		$cropped = $this->avatar_instance->crop(
			array(
				'object'        => $this->object,
				'avatar_dir'    => ( 'group' === $this->object ) ? 'group-avatars' : 'avatars',
				'item_id'       => $this->get_item_id(),
				'original_file' => $avatar_to_crop,
				'crop_w'        => $crop_w,
				'crop_h'        => $crop_h,
				'crop_x'        => $crop_x,
				'crop_y'        => $crop_y,
			)
		);

		remove_filter( 'bp_attachments_current_user_can', '__return_false' );

		// Check for errors.
		if ( empty( $cropped['full'] ) || empty( $cropped['thumb'] ) || is_wp_error( $cropped['full'] ) || is_wp_error( $cropped['thumb'] ) ) {
			return new WP_Error(
				"bp_rest_attachments_{$this->object}_avatar_crop_error",
				sprintf(
					/* translators: %s is replaced with object type. */
					__( 'There was a problem cropping your %s photo.', 'buddypress' ),
					$this->object
				),
				array(
					'status' => 500,
				)
			);
		}

		return $cropped;
	}

	/**
	 * Delete group's existing avatar if one exists.
	 *
	 * @since 0.1.0
	 */
	protected function delete_existing_image() {
		// Get existing avatar.
		$existing_avatar = bp_core_fetch_avatar(
			array(
				'object'  => $this->object,
				'item_id' => $this->get_item_id(),
				'html'    => false,
			)
		);

		// Check if the avatar exists before deleting.
		if ( ! empty( $existing_avatar ) ) {
			bp_core_delete_existing_avatar(
				array(
					'object'  => $this->object,
					'item_id' => $this->get_item_id(),
				)
			);
		}
	}

	/**
	 * Returns the avatar object.
	 *
	 * @since 6.0.0
	 *
	 * @param array $args {
	 *    An array of arguments to build the Avatar object.
	 *
	 *    @type string $full  The url to the full version of the avatar.
	 *    @type string $thumb The url to the thumb version of the avatar.
	 * }
	 * @return object The avatar object.
	 */
	protected function get_avatar_object( $args = array() ) {
		$avatar_object = array_intersect_key(
			$args,
			array(
				'full'  => '',
				'thumb' => '',
			)
		);

		return (object) $avatar_object;
	}

	/**
	 * Get item id.
	 *
	 * @since 5.0.0
	 *
	 * @return int
	 */
	protected function get_item_id() {
		return ( 'group' === $this->object ) ? $this->group->id : $this->user->ID;
	}

	/**
	 * Get cover object component.
	 *
	 * @since 6.0.0
	 *
	 * @return string
	 */
	protected function get_cover_object_component() {
		return ( 'group' === $this->object ) ? 'groups' : 'members';
	}
}


================================================
FILE: includes/bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Attachments_Blog_Avatar_Endpoint class
 *
 * @package BuddyPress
 * @since 6.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Blog avatar endpoints.
 *
 * @since 6.0.0
 */
class BP_REST_Attachments_Blog_Avatar_Endpoint extends WP_REST_Controller {
	use BP_REST_Attachments;

	/**
	 * Reuse some parts of the BP_REST_Blogs_Endpoint class.
	 *
	 * @since 6.0.0
	 *
	 * @var BP_REST_Blogs_Endpoint
	 */
	protected $blogs_endpoint;

	/**
	 * This variable is used to query for the requested blog only once.
	 * It is set during the permission check methods.
	 *
	 * @since 6.0.0
	 *
	 * @var BP_Blogs_Blog
	 */
	protected $blog;

	/**
	 * Constructor.
	 *
	 * @since 6.0.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Blogs_Avatar_REST_Controller' );

		$this->namespace      = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base      = buddypress()->blogs->id;
		$this->blogs_endpoint = new BP_REST_Blogs_Endpoint();
	}

	/**
	 * Register the component routes.
	 *
	 * @since 6.0.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<id>[\d]+)/avatar',
			array(
				'args'   => array(
					'id' => array(
						'description' => __( 'A unique numeric ID for the blog.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => $this->get_item_collection_params(),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Fetch an existing blog avatar.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$no_user_grav = (bool) $request->get_param( 'no_user_gravatar' );

		if ( empty( $this->blog->admin_user_id ) && ! $no_user_grav ) {
			return new WP_Error(
				'bp_rest_blog_avatar_get_item_user_failed',
				__( 'There was a problem confirming the blog\'s user admin is valid.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Set the requested args.
		$requested_args = array(
			'blog_id' => $request->get_param( 'id' ),
			'no_grav' => $no_user_grav,
			'html'    => (bool) $request->get_param( 'html' ),
		);

		if ( ! empty( $request->get_param( 'alt' ) ) ) {
			$requested_args['alt'] = $request->get_param( 'alt' );
		}

		if ( ! $no_user_grav ) {
			$requested_args['admin_user_id'] = (int) $this->blog->admin_user_id;

			if ( ! isset( $requested_args['alt'] ) ) {
				$requested_args['alt'] = '';
			}
		}

		$args = array();
		foreach ( array( 'full', 'thumb' ) as $type ) {
			$requested_args['type'] = $type;
			$args[ $type ]          = bp_get_blog_avatar( $requested_args );
		}

		// Get the avatar object.
		$avatar = $this->get_avatar_object( $args );

		if ( ! $avatar->full && ! $avatar->thumb ) {
			return new WP_Error(
				'bp_rest_attachments_blog_avatar_no_image',
				__( 'Sorry, there was a problem fetching the blog avatar.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $avatar, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a blog avatar is fetched via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param stdClass          $avatar   The avatar object.
		 * @param WP_REST_Response  $response The response data.
		 * @param WP_REST_Request   $request  The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_blog_avatar_get_item', $avatar, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to get a blog avatar.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'blogs' ) ) ) {
			$this->blog = $this->blogs_endpoint->get_blog_object( $request->get_param( 'id' ) );

			if ( ! is_object( $this->blog ) ) {
				$retval = new WP_Error(
					'bp_rest_blog_invalid_id',
					__( 'Invalid group ID.', 'buddypress' ),
					array( 'status' => 404 )
				);
			} elseif ( buddypress()->avatar->show_avatars ) {
				$retval = true;
			} else {
				$retval = new WP_Error(
					'bp_rest_attachments_blog_avatar_disabled',
					__( 'Sorry, blog avatar is disabled.', 'buddypress' ),
					array( 'status' => 500 )
				);
			}
		}

		/**
		 * Filter the blog avatar `get_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_blog_avatar_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Prepares avatar data to return as an object.
	 *
	 * @since 6.0.0
	 *
	 * @param stdClass        $avatar  Avatar object.
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $avatar, $request ) {
		$data = array(
			'full'  => $avatar->full,
			'thumb' => $avatar->thumb,
		);

		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $data, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		/**
		 * Filter a blog avatar value returned from the API.
		 *
		 * @since 6.0.0
		 *
		 * @param WP_REST_Response  $response Response.
		 * @param WP_REST_Request   $request  Request used to generate the response.
		 * @param object            $avatar   Avatar object.
		 */
		return apply_filters( 'bp_rest_attachments_blog_avatar_prepare_value', $response, $request, $avatar );
	}

	/**
	 * Get the blog avatar schema, conforming to JSON Schema.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$this->schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_attachments_blog_avatar',
				'type'       => 'object',
				'properties' => array(
					'full'  => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Full size of the image file.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'uri',
						'readonly'    => true,
					),
					'thumb' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Thumb size of the image file.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'uri',
						'readonly'    => true,
					),
				),
			);
		}

		/**
		 * Filters the blog avatar schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_attachments_blog_avatar_schema', $this->add_additional_fields_schema( $this->schema ) );
	}

	/**
	 * Get the query params for the `get_item`.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_item_collection_params() {
		$params                       = parent::get_collection_params();
		$params['context']['default'] = 'view';

		// Removing unused params.
		unset( $params['search'], $params['page'], $params['per_page'] );

		$params['html'] = array(
			'description'       => __( 'Whether to return an <img> HTML element, vs a raw URL to an avatar.', 'buddypress' ),
			'default'           => false,
			'type'              => 'boolean',
			'sanitize_callback' => 'rest_sanitize_boolean',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['alt'] = array(
			'description'       => __( 'The alt attribute for the <img> element.', 'buddypress' ),
			'default'           => '',
			'type'              => 'string',
			'sanitize_callback' => 'sanitize_text_field',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['no_user_gravatar'] = array(
			'description'       => __( 'Whether to disable the default Gravatar Admin user fallback.', 'buddypress' ),
			'default'           => false,
			'type'              => 'boolean',
			'sanitize_callback' => 'rest_sanitize_boolean',
			'validate_callback' => 'rest_validate_request_arg',
		);

		/**
		 * Filters the item collection query params.
		 *
		 * @param array $params Query params.
		 */
		return apply_filters( 'bp_rest_attachments_blog_avatar_collection_params', $params );
	}
}


================================================
FILE: includes/bp-blogs/classes/class-bp-rest-blogs-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Blogs_Endpoint class
 *
 * @package BuddyPress
 * @since 6.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Blogs endpoints.
 *
 * Use /blogs/
 * Use /blogs/{id}
 *
 * @since 6.0.0
 */
class BP_REST_Blogs_Endpoint extends WP_REST_Controller {

	/**
	 * Constructor.
	 *
	 * @since 6.0.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Blogs_REST_Controller' );

		$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base = buddypress()->blogs->id;
	}

	/**
	 * Register the component routes.
	 *
	 * @since 6.0.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_items' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
					'args'                => $this->get_collection_params(),
				),
				array(
					'methods'             => WP_REST_Server::CREATABLE,
					'callback'            => array( $this, 'create_item' ),
					'permission_callback' => array( $this, 'create_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);

		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<id>[\d]+)',
			array(
				'args'   => array(
					'id' => array(
						'description' => __( 'A unique numeric ID for the Blog.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => array(
						'context' => $this->get_context_param(
							array(
								'default' => 'view',
							)
						),
					),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Retrieve Blogs.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_items( $request ) {
		$args = array(
			'type'             => $request->get_param( 'type' ),
			'include_blog_ids' => $request->get_param( 'include' ),
			'user_id'          => $request->get_param( 'user_id' ),
			'search_terms'     => $request->get_param( 'search' ),
			'page'             => $request->get_param( 'page' ),
			'per_page'         => $request->get_param( 'per_page' ),
		);

		/**
		 * Filter the query arguments for the request.
		 *
		 * @since 6.0.0
		 *
		 * @param array           $args    Key value array of query var to query value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		$args = apply_filters( 'bp_rest_blogs_get_items_query_args', $args, $request );

		// false is the default value for some args.
		foreach ( $args as $key => $value ) {
			if ( empty( $value ) ) {
				$args[ $key ] = false;
			}
		}

		// Check if user is valid.
		if ( 0 !== absint( $args['user_id'] ) ) {
			$user = get_user_by( 'id', absint( $args['user_id'] ) );
			if ( ! $user instanceof WP_User ) {
				return new WP_Error(
					'bp_rest_blogs_get_items_user_failed',
					__( 'There was a problem confirming if user ID provided is a valid one.', 'buddypress' ),
					array(
						'status' => 404,
					)
				);
			}
		}

		// Actually, query it.
		$blogs  = bp_blogs_get_blogs( $args );
		$retval = array();
		foreach ( (array) $blogs['blogs'] as $blog ) {
			$retval[] = $this->prepare_response_for_collection(
				$this->prepare_item_for_response( $blog, $request )
			);
		}

		$response = rest_ensure_response( $retval );
		$response = bp_rest_response_add_total_headers( $response, $blogs['total'], $args['per_page'] );

		/**
		 * Fires after blogs are fetched via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param array            $blogs     Fetched blogs.
		 * @param WP_REST_Response $response  The response data.
		 * @param WP_REST_Request  $request   The request sent to the API.
		 */
		do_action( 'bp_rest_blogs_get_items', $blogs, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to blog items.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return true|WP_Error
	 */
	public function get_items_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'blogs' ) ) ) {
			$retval = true;
		}

		/**
		 * Filter the blogs `get_items` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_blogs_get_items_permissions_check', $retval, $request );
	}

	/**
	 * Retrieve a blog.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$blog = $this->get_blog_object( $request->get_param( 'id' ) );

		if ( empty( $blog->blog_id ) || empty( $blog->admin_user_id ) ) {
			return new WP_Error(
				'bp_rest_blog_invalid_id',
				__( 'Invalid blog ID.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $blog, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a blog is fetched via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param stdClass         $blog     Fetched blog.
		 * @param WP_REST_Response $response The response data.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */
		do_action( 'bp_rest_blogs_get_item', $blog, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to get information about a specific blog.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'blogs' ) ) ) {
			$retval = true;
		}

		/**
		 * Filter the blog `get_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_blogs_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Create a new blog.
	 *
	 * @since 7.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function create_item( $request ) {
		$request->set_param( 'context', 'edit' );

		// Get WP_User object.
		$user = bp_rest_get_user( $request->get_param( 'user_id' ) );

		// Validate blog signup.
		$blog_meta = wpmu_validate_blog_signup(
			$request->get_param( 'name' ),
			$request->get_param( 'title' ),
			$user
		);

		// Check if validation failed.
		if ( is_wp_error( $blog_meta['errors'] ) && ! empty( $blog_meta['errors']->errors ) ) {
			return new WP_Error(
				'bp_rest_blog_validation_failed',
				$blog_meta['errors']->get_error_message(),
				array(
					'status' => 500,
				)
			);
		}

		$site_id = $request->get_param( 'site_id' );
		$meta    = $request->get_param( 'meta' );

		// Assign blog meta.
		if ( empty( $meta['public'] ) ) {
			$meta['public'] = 1;
		}

		if ( empty( $meta['lang_id'] ) ) {
			$meta['lang_id'] = 1;
		}

		/**
		 * Filter the meta arguments for the new Blog.
		 *
		 * @since 7.0.0
		 *
		 * @param array           $args    Key value array of query var to query value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		$meta = apply_filters( 'bp_rest_blogs_create_item_meta', $meta, $request );

		// Create blog.
		$blog_id = wpmu_create_blog(
			$blog_meta['domain'],
			$blog_meta['path'],
			$blog_meta['blog_title'],
			$user->ID,
			$meta,
			$site_id
		);

		// If something went wrong, bail it.
		if ( is_wp_error( $blog_id ) ) {
			return new WP_Error(
				'bp_rest_blogs_create_error',
				__( 'There was a problem creating blog.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$blog = $this->get_blog_object( $blog_id );

		if ( empty( $blog->blog_id ) || empty( $blog->admin_user_id ) ) {
			return new WP_Error(
				'bp_rest_blog_invalid_id',
				__( 'Invalid blog ID.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $blog, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a blog is created via the REST API.
		 *
		 * @since 7.0.0
		 *
		 * @param stdClass         $blog     Created blog.
		 * @param WP_REST_Response $response The response data.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */
		do_action( 'bp_rest_blogs_create_item', $blog, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to create a blog.
	 *
	 * @since 7.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function create_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( is_user_logged_in() ) {
			if ( true === bp_blog_signup_enabled() ) {
				$retval = true;
			} else {
				$retval = new WP_Error(
					'bp_rest_blogs_signup_disabled',
					__( 'Sorry, blog creation is disabled.', 'buddypress' ),
					array(
						'status' => 500,
					)
				);
			}
		}

		/**
		 * Filter the blogs `create_item` permissions check.
		 *
		 * @since 7.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_blogs_create_item_permissions_check', $retval, $request );
	}

	/**
	 * Prepares blogs data for return as an object.
	 *
	 * @since 6.0.0
	 *
	 * @param stdClass        $blog    Blog object.
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $blog, $request ) {
		$data = array(
			'id'                => absint( $blog->blog_id ),
			'user_id'           => absint( $blog->admin_user_id ),
			'name'              => apply_filters( 'bp_get_blog_name', $blog->name ),
			'domain'            => (string) $blog->domain,
			'path'              => (string) $blog->path,
			'permalink'         => $this->get_blog_permalink( $blog ),
			'last_activity'     => bp_rest_prepare_date_response( $blog->last_activity, get_date_from_gmt( $blog->last_activity ) ),
			'last_activity_gmt' => bp_rest_prepare_date_response( $blog->last_activity ),
			'lastest_post_id'   => 0,
			'description'       => array(
				'raw'      => $blog->description,
				'rendered' => apply_filters( 'bp_get_blog_description', $blog->description ),
			),
		);

		if ( ! empty( $blog->latest_post->ID ) ) {
			$data['lastest_post_id'] = absint( $blog->latest_post->ID );
		}

		// Blog Avatars.
		if ( true === buddypress()->avatar->show_avatars ) {
			$data['avatar_urls'] = array(
				'thumb' => bp_get_blog_avatar(
					array(
						'type'    => 'thumb',
						'blog_id' => $blog->blog_id,
						'html'    => false,
					)
				),
				'full'  => bp_get_blog_avatar(
					array(
						'type'    => 'full',
						'blog_id' => $blog->blog_id,
						'html'    => false,
					)
				),
			);
		}

		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $data, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		$response->add_links( $this->prepare_links( $blog ) );

		/**
		 * Filter a blog returned from the API.
		 *
		 * @since 6.0.0
		 *
		 * @param WP_REST_Response  $response Response generated by the request.
		 * @param WP_REST_Request   $request  Request used to generate the response.
		 * @param stdClass          $blog     The blog object.
		 */
		return apply_filters( 'bp_rest_blogs_prepare_value', $response, $request, $blog );
	}

	/**
	 * Prepare links for the request.
	 *
	 * @since 6.0.0
	 *
	 * @param stdClass $blog Blog object.
	 * @return array
	 */
	protected function prepare_links( $blog ) {
		$base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );

		// Entity meta.
		$links = array(
			'self'       => array(
				'href' => rest_url( $base . $blog->blog_id ),
			),
			'collection' => array(
				'href' => rest_url( $base ),
			),
		);

		if ( ! empty( $blog->admin_user_id ) ) {
			$links['user'] = array(
				'href'       => bp_rest_get_object_url( absint( $blog->admin_user_id ), 'members' ),
				'embeddable' => true,
			);
		}

		// Embed the latest blog post.
		if ( ! empty( $blog->latest_post->ID ) ) {
			$links['post'] = array(
				'embeddable' => true,
				'href'       => sprintf(
					'%s/%d',
					get_rest_url( absint( $blog->blog_id ), 'wp/v2/posts' ),
					absint( $blog->latest_post->ID )
				),
			);
		}

		/**
		 * Filter links prepared for the REST response.
		 *
		 * @since 0.1.0
		 *
		 * @param array    $links The prepared links of the REST response.
		 * @param stdClass $blog  The blog object.
		 */
		return apply_filters( 'bp_rest_blogs_prepare_links', $links, $blog );
	}

	/**
	 * Get blog permalink.
	 *
	 * @param stdClass $blog Blog object.
	 * @return string
	 */
	protected function get_blog_permalink( $blog ) {

		// Bail early.
		if ( empty( $blog->domain ) && empty( $blog->path ) ) {
			return '';
		}

		if ( empty( $blog->domain ) && ! empty( $blog->path ) ) {
			return bp_get_root_url() . $blog->path;
		}

		$protocol  = is_ssl() ? 'https://' : 'http://';
		$permalink = $protocol . $blog->domain . $blog->path;

		return apply_filters( 'bp_get_blog_permalink', $permalink );
	}

	/**
	 * Get a blog object from a blog_id.
	 *
	 * @since 6.0.0
	 *
	 * @param int $blog_id Blog ID.
	 * @return stdClass|int
	 */
	public function get_blog_object( $blog_id ) {
		$blogs = current(
			bp_blogs_get_blogs(
				array(
					'include_blog_ids' => array( $blog_id ),
				)
			)
		);

		if ( ! empty( $blogs[0] ) ) {
			return $blogs[0];
		}

		return 0;
	}

	/**
	 * Edit the type of the some properties for the CREATABLE method.
	 *
	 * @since 7.0.0
	 *
	 * @param string $method Optional. HTTP method of the request.
	 * @return array Endpoint arguments.
	 */
	public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
		$args = parent::get_endpoint_args_for_item_schema( $method );
		$key  = 'get_item';

		if ( WP_REST_Server::CREATABLE === $method ) {
			$key = 'create_item';

			unset( $args['last_activity'] );

			$args['name'] = array(
				'required'          => true,
				'description'       => __( 'The new site\'s name (used for the site URL).', 'buddypress' ),
				'type'              => 'string',
				'sanitize_callback' => 'sanitize_key',
				'validate_callback' => 'rest_validate_request_arg',
			);

			$args['title'] = array(
				'required'          => true,
				'description'       => __( 'The new site\'s title.', 'buddypress' ),
				'type'              => 'string',
				'sanitize_callback' => 'sanitize_text_field',
				'validate_callback' => 'rest_validate_request_arg',
			);

			$args['site_id'] = array(
				'required'          => false,
				'default'           => get_current_network_id(),
				'description'       => __( 'The new site\'s network ID. (Only relevant on multi-network installations)', 'buddypress' ),
				'type'              => 'integer',
				'sanitize_callback' => 'absint',
				'validate_callback' => 'rest_validate_request_arg',
			);

			$args['user_id'] = array(
				'required'          => false,
				'default'           => bp_loggedin_user_id(),
				'description'       => __( 'The user ID of the new site\'s admin.', 'buddypress' ),
				'type'              => 'integer',
				'sanitize_callback' => 'absint',
				'validate_callback' => 'rest_validate_request_arg',
			);

			$args['meta'] = array(
				'required'          => false,
				'description'       => __( 'Set initial Blog options.', 'buddypress' ),
				'default'           => array(),
				'type'              => 'array',
				'items'             => array( 'type' => 'string' ),
				'validate_callback' => 'rest_validate_request_arg',
			);
		}

		/**
		 * Filters the method query arguments.
		 *
		 * @since 7.0.0
		 *
		 * @param array  $args   Query arguments.
		 * @param string $method HTTP method of the request.
		 */
		return apply_filters( "bp_rest_blogs_{$key}_query_arguments", $args, $method );
	}

	/**
	 * Get the blogs schema, conforming to JSON Schema.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_blogs',
				'type'       => 'object',
				'properties' => array(
					'id'                => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'A unique numeric ID for the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'user_id'           => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'A unique numeric ID for the blog admin.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'name'              => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The name of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_text_field',
						),
					),
					'permalink'         => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The permalink of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
						'format'      => 'uri',
					),
					'description'       => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The description of the blog.', 'buddypress' ),
						'type'        => 'object',
						'arg_options' => array(
							'sanitize_callback' => null,
							'validate_callback' => null,
						),
						'properties'  => array(
							'raw'      => array(
								'description' => __( 'Content for the description of the blog, as it exists in the database.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit' ),
							),
							'rendered' => array(
								'description' => __( 'HTML content for the description of the blog, transformed for display.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit', 'embed' ),
								'readonly'    => true,
							),
						),
					),
					'path'              => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The path of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
					),
					'domain'            => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The domain of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
					),
					'last_activity'     => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The date of the last activity from the blog, in the site\'s timezone.', 'buddypress' ),
						'readonly'    => true,
						'type'        => array( 'string', 'null' ),
						'format'      => 'date-time',
					),
					'last_activity_gmt' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The date of the last activity from the blog, as GMT.', 'buddypress' ),
						'readonly'    => true,
						'type'        => array( 'string', 'null' ),
						'format'      => 'date-time',
					),
					'lastest_post_id'   => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The latest post ID from the blog', 'buddypress' ),
						'type'        => 'integer',
						'readonly'    => true,
					),
				),
			);

			if ( true === buddypress()->avatar->show_avatars ) {
				$avatar_properties = array();

				$avatar_properties['full'] = array(
					/* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
					'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'view', 'edit', 'embed' ),
				);

				$avatar_properties['thumb'] = array(
					/* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
					'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'view', 'edit', 'embed' ),
				);

				$schema['properties']['avatar_urls'] = array(
					'description' => __( 'Avatar URLs for the blog.', 'buddypress' ),
					'type'        => 'object',
					'context'     => array( 'view', 'edit', 'embed' ),
					'readonly'    => true,
					'properties'  => $avatar_properties,
				);
			}

			// Cache current schema here.
			$this->schema = $schema;
		}

		/**
		 * Filter the blogs schema.
		 *
		 * @since 6.0.0
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_blogs_schema', $this->add_additional_fields_schema( $this->schema ) );
	}

	/**
	 * Get the query params for blogs collections.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_collection_params() {
		$params                       = parent::get_collection_params();
		$params['context']['default'] = 'view';

		$params['user_id'] = array(
			'description'       => __( 'ID of the user whose blogs user can post to.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['include'] = array(
			'description'       => __( 'Ensure result set includes specific IDs.', 'buddypress' ),
			'default'           => array(),
			'type'              => 'array',
			'items'             => array( 'type' => 'integer' ),
			'sanitize_callback' => 'wp_parse_id_list',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['type'] = array(
			'description'       => __( 'Limit result set to items with a specific type.', 'buddypress' ),
			'default'           => 'active',
			'type'              => 'string',
			'enum'              => array( 'active', 'alphabetical', 'newest', 'random' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		/**
		 * Filters the collection query params.
		 *
		 * @param array $params Query params.
		 */
		return apply_filters( 'bp_rest_blogs_collection_params', $params );
	}
}


================================================
FILE: includes/bp-components/classes/class-bp-rest-components-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Components_Endpoint class
 *
 * @package BuddyPress
 * @since 0.1.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Components endpoints.
 *
 * @since 0.1.0
 */
class BP_REST_Components_Endpoint extends WP_REST_Controller {

	/**
	 * Constructor.
	 *
	 * @since 0.1.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Core_Components_REST_Controller' );

		$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base = 'components';
	}

	/**
	 * Register the component routes.
	 *
	 * @since 0.1.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_items' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
					'args'                => $this->get_collection_params(),
				),
				array(
					'methods'             => WP_REST_Server::EDITABLE,
					'callback'            => array( $this, 'update_item' ),
					'permission_callback' => array( $this, 'update_item_permissions_check' ),
					'args'                => array(
						'name'   => array(
							'type'        => 'string',
							'required'    => true,
							'description' => __( 'Name of the component.', 'buddypress' ),
						),
						'action' => array(
							'description' => __( 'Whether to activate or deactivate the component.', 'buddypress' ),
							'type'        => 'string',
							'enum'        => array( 'activate', 'deactivate' ),
							'required'    => true,
						),
					),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Retrieve components.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response
	 */
	public function get_items( $request ) {
		$args = array(
			'type'     => $request->get_param( 'type' ),
			'status'   => $request->get_param( 'status' ),
			'per_page' => $request->get_param( 'per_page' ),
		);

		/**
		 * Filter the query arguments for the request.
		 *
		 * @since 0.1.0
		 *
		 * @param array           $args    Key value array of query var to query value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		$args = apply_filters( 'bp_rest_components_get_items_query_args', $args, $request );

		$type = $args['type'];

		// Get all components based on type.
		$components = bp_core_get_components( $type );

		// Active components.
		$active_components = (array) apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );

		// Core component is always active.
		if ( 'optional' !== $type && ! empty( $components['core'] ) ) {
			$active_components['core'] = '1';
		}

		// Inactive components.
		$inactive_components = array_diff( array_keys( $components ), array_keys( $active_components ) );

		$current_components = array();
		switch ( $args['status'] ) {
			case 'all':
				foreach ( array_keys( $components ) as $name ) {
					$current_components[] = $this->get_component_info( $name );
				}
				break;

			case 'active':
				foreach ( array_keys( $active_components ) as $component ) {
					$current_components[] = $this->get_component_info( $component );
				}
				break;

			case 'inactive':
				foreach ( $inactive_components as $component ) {
					$current_components[] = $this->get_component_info( $component );
				}
				break;
		}

		$retval = array();
		foreach ( $current_components as $component ) {
			$retval[] = $this->prepare_response_for_collection(
				$this->prepare_item_for_response( $component, $request )
			);
		}

		$response = rest_ensure_response( $retval );
		$response = bp_rest_response_add_total_headers( $response, count( $current_components ), $args['per_page'] );

		/**
		 * Fires after a list of components is fetched via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param array            $current_components Fetched components.
		 * @param WP_REST_Response $response           The response data.
		 * @param WP_REST_Request  $request            The request sent to the API.
		 */
		do_action( 'bp_rest_components_get_items', $current_components, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to list components.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return true|WP_Error
	 */
	public function get_items_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		// The `get_items` endpoint can be used by BP Blocks to check whether some component's features are active or not.
		if ( bp_current_user_can( 'manage_options' ) || ( 'active' === $request->get_param( 'status' ) && current_user_can( 'publish_posts' ) ) ) {
			$retval = true;
		}

		/**
		 * Filter the components `get_items` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_components_get_items_permissions_check', $retval, $request );
	}

	/**
	 * Activate/Deactivate a component.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function update_item( $request ) {
		$component = $request->get_param( 'name' );

		if ( ! $this->component_exists( $component ) ) {
			return new WP_Error(
				'bp_rest_component_nonexistent',
				__( 'Sorry, this component does not exist.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		if ( 'activate' === $request->get_param( 'action' ) ) {
			if ( bp_is_active( $component ) ) {
				return new WP_Error(
					'bp_rest_component_already_active',
					__( 'Sorry, this component is already active.', 'buddypress' ),
					array(
						'status' => 400,
					)
				);
			}

			$component_info = $this->activate_helper( $component );
		} else {
			if ( ! bp_is_active( $component ) ) {
				return new WP_Error(
					'bp_rest_component_inactive',
					__( 'Sorry, this component is not active.', 'buddypress' ),
					array(
						'status' => 400,
					)
				);
			}

			if ( array_key_exists( $component, bp_core_get_components( 'required' ) ) ) {
				return new WP_Error(
					'bp_rest_required_component',
					__( 'Sorry, you cannot deactivate a required component.', 'buddypress' ),
					array(
						'status' => 400,
					)
				);
			}

			$component_info = $this->deactivate_helper( $component );
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $component_info, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a component is updated via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param array             $component_info Component info.
		 * @param WP_REST_Response  $response       The response data.
		 * @param WP_REST_Request   $request        The request sent to the API.
		 */
		do_action( 'bp_rest_components_update_item', $component_info, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to update a component.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function update_item_permissions_check( $request ) {
		$retval = $this->get_items_permissions_check( $request );

		/**
		 * Filter the components `update_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_components_update_item_permissions_check', $retval, $request );
	}

	/**
	 * Prepares component data for return as an object.
	 *
	 * @since 0.1.0
	 *
	 * @param array           $component The component and its values.
	 * @param WP_REST_Request $request   Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $component, $request ) {
		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $component, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		/**
		 * Filter a component value returned from the API.
		 *
		 * @since 0.1.0
		 *
		 * @param WP_REST_Response $response  The Response data.
		 * @param WP_REST_Request  $request   Request used to generate the response.
		 * @param array            $component The component and its values.
		 */
		return apply_filters( 'bp_rest_components_prepare_value', $response, $request, $component );
	}

	/**
	 * Verify Component Status.
	 *
	 * @since 0.1.0
	 * @since 9.0.0 Adds the `$return_type` parameter.
	 *
	 * @param string $name        Component name.
	 * @param string $return_type Use `string` to get the l10n string. Default.
	 *                            Use `bool` to get whether the component is active or not.
	 *                            Use `array` to get both information.
	 * @return string|bool|array By default a l10n string is returned.
	 *                           True if the component is active, false otherwise when 'bool' is requested.
	 *                           An array containing both information when 'array' is requested.
	 */
	protected function verify_component_status( $name, $return_type = 'string' ) {
		$retval = array(
			'string' => __( 'inactive', 'buddypress' ),
			'bool'   => false,
		);

		if ( 'core' === $name || bp_is_active( $name ) ) {
			$retval = array(
				'string' => __( 'active', 'buddypress' ),
				'bool'   => true,
			);
		}

		if ( isset( $retval[ $return_type ] ) ) {
			return $retval[ $return_type ];
		}

		return $retval;
	}

	/**
	 * Deactivate component helper.
	 *
	 * @since 0.1.0
	 *
	 * @param string $component Component id.
	 * @return array
	 */
	protected function deactivate_helper( $component ) {

		$active_components =& buddypress()->active_components;

		// Set for the rest of the page load.
		unset( $active_components[ $component ] );

		// Save in the db.
		bp_update_option( 'bp-active-components', $active_components );

		return $this->get_component_info( $component );
	}

	/**
	 * Activate component helper.
	 *
	 * @since 0.1.0
	 *
	 * @param string $component Component id.
	 * @return array
	 */
	protected function activate_helper( $component ) {

		$active_components =& buddypress()->active_components;

		// Set for the rest of the page load.
		$active_components[ $component ] = 1;

		// Save in the db.
		bp_update_option( 'bp-active-components', $active_components );

		// Ensure that dbDelta() is defined.
		if ( ! function_exists( 'dbDelta' ) ) {
			require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		}

		// Run the setup, in case tables have to be created.
		require_once buddypress()->plugin_dir . 'bp-core/admin/bp-core-admin-schema.php';

		bp_core_install( $active_components );
		bp_core_add_page_mappings( $active_components );

		return $this->get_component_info( $component );
	}

	/**
	 * Get component info helper.
	 *
	 * @since 0.1.0
	 * @since 9.0.0 Adds a `features` property to component's info.
	 *
	 * @param string $component Component id.
	 * @return array
	 */
	public function get_component_info( $component ) {

		// Get all components.
		$components = bp_core_get_components();

		// Init the component's data.
		$data = array();

		// Get specific component info.
		if ( isset( $components[ $component ] ) ) {
			$data = (array) $components[ $component ];
		}

		// Return empty early.
		if ( ! $data ) {
			return $data;
		}

		// Get BuddyPress main instance.
		$bp = buddypress();

		// Get status data.
		$status = $this->verify_component_status( $component, 'array' );

		// Set component's basic information.
		$info = array(
			'name'        => $component,
			'status'      => $status['string'],
			'is_active'   => $status['bool'],
			'title'       => $data['title'],
			'description' => $data['description'],
			'features'    => array(),
		);

		// Set component's features.
		if ( $status['bool'] ) {
			// @todo check the features list is exhaustive.
			switch ( $component ) {
				case 'groups':
					$features = array(
						'avatar'         => $bp->avatar && $bp->avatar->show_avatars && ! bp_disable_group_avatar_uploads(),
						'cover'          => bp_is_active( 'groups', 'cover_image' ),
						'group_creation' => bp_restrict_group_creation() ? 'adminsonly' : 'members',
					);
					break;
				case 'members':
					$features = array(
						'account_deletion'    => ! bp_disable_account_deletion(),
						'avatar'              => $bp->avatar && $bp->avatar->show_avatars,
						'cover'               => bp_is_active( 'members', 'cover_image' ),
						'invitations'         => bp_get_members_invitations_allowed(),
						'membership_requests' => bp_is_active( 'members', 'membership_requests' ) && ! bp_get_signup_allowed() && (bool) bp_get_option( 'bp-enable-membership-requests' ),
					);
					break;
				case 'activity':
					$features = array(
						'auto_refresh' => bp_is_activity_heartbeat_active(),
						'embeds'       => bp_is_active( 'activity', 'embeds' ),
						'favorite'     => bp_activity_can_favorite(),
						'mentions'     => bp_activity_do_mentions(),
						'types'        => bp_activity_get_types_list(),
					);
					break;
				case 'blogs':
					$features = array(
						'site_icon'       => bp_is_active( 'blogs', 'site-icon' ),
						'sites_directory' => is_multisite(),
					);
					break;
				case 'messages':
					$features = array(
						'star' => bp_is_active( 'messages', 'star' ),
					);
					break;
				default:
					$features = array();
					break;
			}

			/**
			 * Filter here to edit component's features.
			 *
			 * The dynamic portion of the filter is filled with the component's ID.
			 *
			 * @since 9.0.0
			 *
			 * @param array $features The component's features.
			 */
			$info['features'] = apply_filters( 'bp_rest_' . $component . '_component_features', $features );
		}

		return $info;
	}

	/**
	 * Does the component exist?
	 *
	 * @since 0.1.0
	 *
	 * @param string $component Component.
	 * @return bool
	 */
	protected function component_exists( $component ) {
		return in_array( $component, array_keys( bp_core_get_components() ), true );
	}

	/**
	 * Get the components schema, conforming to JSON Schema.
	 *
	 * @since 0.1.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$this->schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_components',
				'type'       => 'object',
				'properties' => array(
					'name'        => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Name of the object.', 'buddypress' ),
						'type'        => 'string',
					),
					'is_active'   => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Whether the component is active or not.', 'buddypress' ),
						'type'        => 'boolean',
						'default'     => false,
					),
					'status'      => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Whether the object is active or inactive.', 'buddypress' ),
						'type'        => 'string',
						// We need to use what returns `$this->verify_component_status()` by default here.
						'enum'        => array(
							__( 'active', 'buddypress' ),
							__( 'inactive', 'buddypress' ),
						),
					),
					'title'       => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'HTML title of the object.', 'buddypress' ),
						'type'        => 'string',
					),
					'description' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'HTML description of the object.', 'buddypress' ),
						'type'        => 'string',
					),
					'features'    => array(
						'description' => __( 'Information about active features for the component.', 'buddypress' ),
						'type'        => 'array',
						'context'     => array( 'view', 'edit' ),
						'default'     => array(),
					),
				),
			);
		}

		/**
		 * Filters the components schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_components_schema', $this->add_additional_fields_schema( $this->schema ) );
	}

	/**
	 * Get the query params for collections.
	 *
	 * @since 0.1.0
	 *
	 * @return array
	 */
	public function get_collection_params() {
		$params                       = parent::get_collection_params();
		$params['context']['default'] = 'view';

		$params['status'] = array(
			'description'       => __( 'Limit result set to items with a specific status.', 'buddypress' ),
			'default'           => 'all',
			'type'              => 'string',
			'enum'              => array( 'all', 'active', 'inactive' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['type'] = array(
			'description'       => __( 'Limit result set to items with a specific type.', 'buddypress' ),
			'default'           => 'all',
			'type'              => 'string',
			'enum'              => array( 'all', 'optional', 'retired', 'required' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		/**
		 * Filters the collection query params.
		 *
		 * @param array $params Query params.
		 */
		return apply_filters( 'bp_rest_components_collection_params', $params );
	}
}


================================================
FILE: includes/bp-friends/classes/class-bp-rest-friends-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Friends_Endpoint class
 *
 * @package BuddyPress
 * @since 6.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Friendship endpoints.
 *
 * /friends/
 * /friends/{id}
 *
 * @since 6.0.0
 */
class BP_REST_Friends_Endpoint extends WP_REST_Controller {

	/**
	 * Constructor.
	 *
	 * @since 6.0.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Friends_REST_Controller' );

		$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base = buddypress()->friends->id;
	}

	/**
	 * Register the component routes.
	 *
	 * @since 6.0.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_items' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
					'args'                => $this->get_collection_params(),
				),
				array(
					'methods'             => WP_REST_Server::CREATABLE,
					'callback'            => array( $this, 'create_item' ),
					'permission_callback' => array( $this, 'create_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);

		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<id>[\w-]+)',
			array(
				'args'   => array(
					'id' => array(
						'description' => __( 'Numeric identifier of a user ID.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::READABLE ),
				),
				array(
					'methods'             => WP_REST_Server::EDITABLE,
					'callback'            => array( $this, 'update_item' ),
					'permission_callback' => array( $this, 'update_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
				),
				array(
					'methods'             => WP_REST_Server::DELETABLE,
					'callback'            => array( $this, 'delete_item' ),
					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::DELETABLE ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Retrieve friendships.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_items( $request ) {
		$args = array(
			'id'                => $request->get_param( 'id' ),
			'initiator_user_id' => $request->get_param( 'initiator_id' ),
			'friend_user_id'    => $request->get_param( 'friend_id' ),
			'is_confirmed'      => $request->get_param( 'is_confirmed' ),
			'order_by'          => $request->get_param( 'order_by' ),
			'sort_order'        => strtoupper( $request->get_param( 'order' ) ),
			'page'              => $request->get_param( 'page' ),
			'per_page'          => $request->get_param( 'per_page' ),
		);

		/**
		 * Filter the query arguments for the request.
		 *
		 * @since 6.0.0
		 *
		 * @param array           $args    Key value array of query var to query value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		$args = apply_filters( 'bp_rest_friends_get_items_query_args', $args, $request );

		// null is the default values.
		foreach ( $args as $key => $value ) {
			if ( empty( $value ) ) {
				$args[ $key ] = null;
			}
		}

		// Check if user is valid.
		$user = get_user_by( 'id', $request->get_param( 'user_id' ) );
		if ( ! $user instanceof WP_User ) {
			return new WP_Error(
				'bp_rest_friends_get_items_user_failed',
				__( 'There was a problem confirming if user is valid.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		// Actually, query it.
		$friendships = BP_Friends_Friendship::get_friendships( $user->ID, $args );

		$retval = array();
		foreach ( (array) $friendships as $friendship ) {
			$retval[] = $this->prepare_response_for_collection(
				$this->prepare_item_for_response( $friendship, $request )
			);
		}

		$response = rest_ensure_response( $retval );
		$response = bp_rest_response_add_total_headers( $response, count( $friendships ), $args['per_page'] );

		/**
		 * Fires after friendships are fetched via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param array            $friendships Fetched friendships.
		 * @param WP_REST_Response $response    The response data.
		 * @param WP_REST_Request  $request     The request sent to the API.
		 */
		do_action( 'bp_rest_friends_get_items', $friendships, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to friendship items.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return true|WP_Error
	 */
	public function get_items_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you need to be logged in to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( is_user_logged_in() ) {
			$retval = true;
		}

		/**
		 * Filter the friends `get_items` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_friends_get_items_permissions_check', $retval, $request );
	}

	/**
	 * Retrieve single friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$user = get_user_by( 'id', $request->get_param( 'id' ) );

		// Check if user is valid.
		if ( false === $user ) {
			return new WP_Error(
				'bp_rest_friends_get_item_failed',
				__( 'There was a problem confirming if user is valid.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		// Get friendship.
		$friendship = $this->get_friendship_object(
			BP_Friends_Friendship::get_friendship_id( bp_loggedin_user_id(), $user->ID )
		);

		if ( ! $friendship || empty( $friendship->id ) ) {
			return new WP_Error(
				'bp_rest_invalid_id',
				__( 'Friendship does not exist.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $friendship, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires before a friendship is retrieved via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param BP_Friends_Friendship $friendship  The friendship object.
		 * @param WP_REST_Response      $response    The response data.
		 * @param WP_REST_Request       $request     The request sent to the API.
		 */
		do_action( 'bp_rest_friends_get_item', $friendship, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to get a friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full data about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you need to be logged in to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( is_user_logged_in() ) {
			$retval = true;
		}

		/**
		 * Filter the friendship `get_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_friends_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Create a new friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function create_item( $request ) {
		$initiator_id = get_user_by( 'id', $request->get_param( 'initiator_id' ) );
		$friend_id    = get_user_by( 'id', $request->get_param( 'friend_id' ) );

		// Check if users are valid.
		if ( ! $initiator_id || ! $friend_id ) {
			return new WP_Error(
				'bp_rest_friends_create_item_failed',
				__( 'There was a problem confirming if user is valid.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		// Check if users are friends or if there is a friendship request.
		if ( 'not_friends' !== friends_check_friendship_status( $initiator_id->ID, $friend_id->ID ) ) {
			return new WP_Error(
				'bp_rest_friends_create_item_failed',
				__( 'Those users are already friends or have sent friendship request(s) recently.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$is_moderator    = bp_current_user_can( 'bp_moderate' );
		$current_user_id = bp_loggedin_user_id();

		/**
		 * - Only admins can create friendship requests for other people.
		 * - Admins can't create friendship requests to themselves from other people.
		 * - Users can't create friendship requests to themselves from other people.
		 */
		if (
			( $current_user_id !== $initiator_id->ID && ! $is_moderator )
			|| ( $current_user_id === $friend_id->ID && $is_moderator )
			|| ( ! in_array( $current_user_id, array( $initiator_id->ID, $friend_id->ID ), true ) && ! $is_moderator )
		) {
			return new WP_Error(
				'bp_rest_friends_create_item_failed',
				__( 'You are not allowed to perform this action.', 'buddypress' ),
				array(
					'status' => 403,
				)
			);
		}

		// Only admins can force a friendship request.
		$force = ( true === $request->get_param( 'force' ) && $is_moderator );

		// Adding friendship.
		if ( ! friends_add_friend( $initiator_id->ID, $friend_id->ID, $force ) ) {
			return new WP_Error(
				'bp_rest_friends_create_item_failed',
				__( 'There was an error trying to create the friendship.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Get friendship.
		$friendship = $this->get_friendship_object(
			BP_Friends_Friendship::get_friendship_id( $initiator_id->ID, $friend_id->ID )
		);

		if ( ! $friendship || empty( $friendship->id ) ) {
			return new WP_Error(
				'bp_rest_invalid_id',
				__( 'Friendship does not exist.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $friendship, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a friendship is created via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param BP_Friends_Friendship $friendship The friendship object.
		 * @param WP_REST_Response      $retval     The response data.
		 * @param WP_REST_Request       $request    The request sent to the API.
		 */
		do_action( 'bp_rest_friends_create_item', $friendship, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to create a friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function create_item_permissions_check( $request ) {
		$retval = $this->get_item_permissions_check( $request );

		/**
		 * Filter the friends `create_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_friends_create_item_permissions_check', $retval, $request );
	}

	/**
	 * Update, accept, friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function update_item( $request ) {
		$user = get_user_by( 'id', $request->get_param( 'id' ) );

		// Check if user is valid.
		if ( false === $user ) {
			return new WP_Error(
				'bp_rest_friends_update_item_failed',
				__( 'There was a problem confirming if user is valid.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		// Get friendship.
		$friendship = $this->get_friendship_object(
			BP_Friends_Friendship::get_friendship_id( bp_loggedin_user_id(), $user->ID )
		);

		if ( ! $friendship || empty( $friendship->id ) ) {
			return new WP_Error(
				'bp_rest_invalid_id',
				__( 'Invalid friendship ID.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		// Accept friendship.
		if ( false === friends_accept_friendship( $friendship->id ) ) {
			return new WP_Error(
				'bp_rest_friends_cannot_update_item',
				__( 'Could not accept friendship.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Getting new, updated, friendship object.
		$friendship = $this->get_friendship_object( $friendship->id );

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $friendship, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a friendship is updated via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param BP_Friends_Friendship $friendship Friendship object.
		 * @param WP_REST_Response      $response   The response data.
		 * @param WP_REST_Request       $request    The request sent to the API.
		 */
		do_action( 'bp_rest_friends_update_item', $friendship, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to update a friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function update_item_permissions_check( $request ) {
		$retval = $this->get_item_permissions_check( $request );

		/**
		 * Filter the friendship `update_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_friends_update_item_permissions_check', $retval, $request );
	}

	/**
	 * Reject/withdraw/remove friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function delete_item( $request ) {
		$user = get_user_by( 'id', $request->get_param( 'id' ) );

		// Check if user is valid.
		if ( false === $user ) {
			return new WP_Error(
				'bp_rest_friends_delete_item_failed',
				__( 'There was a problem confirming if user is valid.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		// Get friendship.
		$friendship = $this->get_friendship_object(
			BP_Friends_Friendship::get_friendship_id( bp_loggedin_user_id(), $user->ID )
		);

		if ( ! $friendship || empty( $friendship->id ) ) {
			return new WP_Error(
				'bp_rest_invalid_id',
				__( 'Invalid friendship ID.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$previous = $this->prepare_item_for_response( $friendship, $request );

		// Remove a friendship.
		if ( true === $request->get_param( 'force' ) ) {
			$deleted = friends_remove_friend( $friendship->initiator_user_id, $friendship->friend_user_id );

			/**
			 * If this change is being initiated by the initiator,
			 * use the `reject` function.
			 *
			 * This is the user who requested the friendship, and is doing the withdrawing.
			 */
		} elseif ( bp_loggedin_user_id() === $friendship->initiator_user_id ) {
			$deleted = friends_withdraw_friendship( $friendship->initiator_user_id, $friendship->friend_user_id );
		} else {
			/**
			 * Otherwise, this change is being initiated by the user, friend,
			 * who received the friendship reject.
			 */
			$deleted = friends_reject_friendship( $friendship->id );
		}

		if ( false === $deleted ) {
			return new WP_Error(
				'bp_rest_friends_cannot_delete_item',
				__( 'Could not delete friendship.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Build the response.
		$response = new WP_REST_Response();
		$response->set_data(
			array(
				'deleted'  => true,
				'previous' => $previous->get_data(),
			)
		);

		/**
		 * Fires after a friendship is deleted via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param BP_Friends_Friendship $friendship Friendship object.
		 * @param WP_REST_Response      $response   The response data.
		 * @param WP_REST_Request       $request    The request sent to the API.
		 */
		do_action( 'bp_rest_friends_delete_item', $friendship, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to delete a friendship.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function delete_item_permissions_check( $request ) {
		$retval = $this->get_item_permissions_check( $request );

		/**
		 * Filter the friendship `delete_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_friends_delete_item_permissions_check', $retval, $request );
	}

	/**
	 * Prepares friendship data to return as an object.
	 *
	 * @since 6.0.0
	 *
	 * @param BP_Friends_Friendship $friendship Friendship object.
	 * @param WP_REST_Request       $request    Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $friendship, $request ) {
		$data = array(
			'id'               => (int) $friendship->id,
			'initiator_id'     => (int) $friendship->initiator_user_id,
			'friend_id'        => (int) $friendship->friend_user_id,
			'is_confirmed'     => (bool) $friendship->is_confirmed,
			'date_created'     => bp_rest_prepare_date_response( $friendship->date_created, get_date_from_gmt( $friendship->date_created ) ),
			'date_created_gmt' => bp_rest_prepare_date_response( $friendship->date_created ),
		);

		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $data, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		// Add prepare links.
		$response->add_links( $this->prepare_links( $friendship ) );

		/**
		 * Filter a friendship value returned from the API.
		 *
		 * @since 6.0.0
		 *
		 * @param WP_REST_Response      $response   Response generated by the request.
		 * @param WP_REST_Request       $request    Request used to generate the response.
		 * @param BP_Friends_Friendship $friendship The friendship object.
		 */
		return apply_filters( 'bp_rest_friends_prepare_value', $response, $request, $friendship );
	}

	/**
	 * Prepare links for the request.
	 *
	 * @since 6.0.0
	 *
	 * @param BP_Friends_Friendship $friendship Friendship object.
	 * @return array
	 */
	protected function prepare_links( $friendship ) {
		$base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );

		// Entity meta.
		$links = array(
			'self'       => array(
				'href' => rest_url( $base . $friendship->id ),
			),
			'collection' => array(
				'href' => rest_url( $base ),
			),
			'initiator'  => array(
				'href'       => bp_rest_get_object_url( $friendship->initiator_user_id, 'members' ),
				'embeddable' => true,
			),
			'friend'     => array(
				'href'       => bp_rest_get_object_url( $friendship->friend_user_id, 'members' ),
				'embeddable' => true,
			),
		);

		/**
		 * Filter links prepared for the REST response.
		 *
		 * @since 0.1.0
		 *
		 * @param array                 $links      The prepared links of the REST response.
		 * @param BP_Friends_Friendship $friendship Friendship object.
		 */
		return apply_filters( 'bp_rest_friends_prepare_links', $links, $friendship );
	}

	/**
	 * Get friendship object.
	 *
	 * @since 6.0.0
	 *
	 * @param int $friendship_id Friendship ID.
	 * @return BP_Friends_Friendship
	 */
	public function get_friendship_object( $friendship_id ) {
		return new BP_Friends_Friendship( (int) $friendship_id );
	}

	/**
	 * Edit some arguments for the endpoint's methods.
	 *
	 * @since 6.0.0
	 *
	 * @param string $method Optional. HTTP method of the request.
	 * @return array Endpoint arguments.
	 */
	public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
		$args    = parent::get_endpoint_args_for_item_schema( $method );
		$context = 'view';

		$args['id']['required']    = true;
		$args['id']['description'] = __( 'A unique numeric ID of a user.', 'buddypress' );

		if ( WP_REST_Server::EDITABLE === $method ) {
			$key = 'update_item';

			unset( $args['initiator_id'] );
			unset( $args['friend_id'] );
		} elseif ( WP_REST_Server::CREATABLE === $method ) {
			$key = 'create_item';

			// Remove the ID for POST requests since it is not available.
			unset( $args['id'] );

			// Those fields are required.
			$args['initiator_id']['required'] = true;
			$args['friend_id']['required']    = true;

			// This one is optional.
			$args['force'] = array(
				'description'       => __( 'Whether to force the friendship agreement.', 'buddypress' ),
				'default'           => false,
				'type'              => 'boolean',
				'sanitize_callback' => 'rest_sanitize_boolean',
				'validate_callback' => 'rest_validate_request_arg',
			);

		} elseif ( WP_REST_Server::DELETABLE === $method ) {
			$key = 'delete_item';

			// This one is optional.
			$args['force'] = array(
				'description'       => __( 'Whether to force friendship removal.', 'buddypress' ),
				'default'           => false,
				'type'              => 'boolean',
				'sanitize_callback' => 'rest_sanitize_boolean',
				'validate_callback' => 'rest_validate_request_arg',
			);

			unset( $args['initiator_id'] );
			unset( $args['friend_id'] );
		} elseif ( WP_REST_Server::READABLE === $method ) {
			$key = 'get_item';

			$args['id']['required'] = true;

			// Removing those args from the GET request.
			unset( $args['initiator_id'] );
			unset( $args['friend_id'] );
		}

		if ( 'get_item' !== $key ) {
			$context = 'edit';
		}

		$args = array_merge(
			array(
				'context' => $this->get_context_param(
					array(
						'default' => $context,
					)
				),
			),
			$args
		);

		/**
		 * Filters the method query arguments.
		 *
		 * @since 6.0.0
		 *
		 * @param array  $args   Query arguments.
		 * @param string $method HTTP method of the request.
		 */
		return apply_filters( "bp_rest_friends_{$key}_query_arguments", $args, $method );
	}

	/**
	 * Get the friends schema, conforming to JSON Schema.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$this->schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_friends',
				'type'       => 'object',
				'properties' => array(
					'id'               => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Unique numeric identifier of the friendship.', 'buddypress' ),
						'type'        => 'integer',
					),
					'initiator_id'     => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The unique numeric identifier of the user who is requesting the Friendship.', 'buddypress' ),
						'type'        => 'integer',
					),
					'friend_id'        => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The unique numeric identifier of the user who is invited to agree to the Friendship request.', 'buddypress' ),
						'type'        => 'integer',
					),
					'is_confirmed'     => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Whether the friendship been confirmed/accepted.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'boolean',
					),
					'date_created'     => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The date the friendship was created, in the site\'s timezone.', 'buddypress' ),
						'readonly'    => true,
						'type'        => array( 'string', 'null' ),
						'format'      => 'date-time',
					),
					'date_created_gmt' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The date the friendship was created, as GMT.', 'buddypress' ),
						'readonly'    => true,
						'type'        => array( 'string', 'null' ),
						'format'      => 'date-time',
					),
				),
			);
		}

		/**
		 * Filters the friends schema.
		 *
		 * @since 6.0.0
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_friends_schema', $this->add_additional_fields_schema( $this->schema ) );
	}

	/**
	 * Get the query params for friends collections.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_collection_params() {
		$params                       = parent::get_collection_params();
		$params['context']['default'] = 'view';

		unset( $params['search'] );

		$params['user_id'] = array(
			'description'       => __( 'ID of the member whose friendships are being retrieved.', 'buddypress' ),
			'default'           => bp_loggedin_user_id(),
			'type'              => 'integer',
			'required'          => true,
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['is_confirmed'] = array(
			'description'       => __( 'Wether the friendship has been accepted.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['id'] = array(
			'description'       => __( 'Unique numeric identifier of the friendship.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['initiator_id'] = array(
			'description'       => __( 'The ID of the user who is requesting the Friendship.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['friend_id'] = array(
			'description'       => __( 'The ID of the user who is invited to agree to the Friendship request.', 'buddypress' ),
			'default'           => 0,
			'type'              => 'integer',
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['order_by'] = array(
			'description'       => __( 'Column name to order the results by.', 'buddypress' ),
			'default'           => 'date_created',
			'type'              => 'string',
			'enum'              => array( 'date_created', 'initiator_user_id', 'friend_user_id', 'id' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['order'] = array(
			'description'       => __( 'Order results ascending or descending.', 'buddypress' ),
			'default'           => 'desc',
			'type'              => 'string',
			'enum'              => array( 'asc', 'desc' ),
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		);

		/**
		 * Filters the collection query params.
		 *
		 * @param array $params Query params.
		 */
		return apply_filters( 'bp_rest_friends_collection_params', $params );
	}
}


================================================
FILE: includes/bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Attachments_Group_Avatar_Endpoint class
 *
 * @package BuddyPress
 * @since 0.1.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Group Avatar endpoints.
 *
 * @since 0.1.0
 */
class BP_REST_Attachments_Group_Avatar_Endpoint extends WP_REST_Controller {
	use BP_REST_Attachments;

	/**
	 * Reuse some parts of the BP_REST_Groups_Endpoint class.
	 *
	 * @since 0.1.0
	 *
	 * @var BP_REST_Groups_Endpoint
	 */
	protected $groups_endpoint;

	/**
	 * BP_Attachment_Avatar Instance.
	 *
	 * @since 0.1.0
	 *
	 * @var BP_Attachment_Avatar
	 */
	protected $avatar_instance;

	/**
	 * Hold the group object.
	 *
	 * @since 0.1.0
	 *
	 * @var BP_Groups_Group
	 */
	protected $group;

	/**
	 * Group object type.
	 *
	 * @since 0.1.0
	 *
	 * @var string
	 */
	protected $object = 'group';

	/**
	 * Constructor.
	 *
	 * @since 0.1.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Groups_Avatar_REST_Controller' );

		$this->namespace       = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base       = buddypress()->groups->id;
		$this->groups_endpoint = new BP_REST_Groups_Endpoint();
		$this->avatar_instance = new BP_Attachment_Avatar();
	}

	/**
	 * Register the component routes.
	 *
	 * @since 0.1.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<group_id>[\d]+)/avatar',
			array(
				'args'   => array(
					'group_id' => array(
						'description' => __( 'A unique numeric ID for the Group.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => $this->get_item_collection_params(),
				),
				array(
					'methods'             => WP_REST_Server::CREATABLE,
					'callback'            => array( $this, 'create_item' ),
					'permission_callback' => array( $this, 'create_item_permissions_check' ),
				),
				array(
					'methods'             => WP_REST_Server::DELETABLE,
					'callback'            => array( $this, 'delete_item' ),
					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Fetch an existing group avatar.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$args = array();

		foreach ( array( 'full', 'thumb' ) as $type ) {
			$args[ $type ] = bp_core_fetch_avatar(
				array(
					'object'  => $this->object,
					'type'    => $type,
					'item_id' => (int) $this->group->id,
					'html'    => (bool) $request->get_param( 'html' ),
					'alt'     => $request->get_param( 'alt' ),
				)
			);
		}

		// Get the avatar object.
		$avatar = $this->get_avatar_object( $args );

		if ( ! $avatar->full && ! $avatar->thumb ) {
			return new WP_Error(
				'bp_rest_attachments_group_avatar_no_image',
				__( 'Sorry, there was a problem fetching this group avatar.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $avatar, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a group avatar is fetched via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param string            $avatar   The group avatar.
		 * @param WP_REST_Response  $response The response data.
		 * @param WP_REST_Request   $request  The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_group_avatar_get_item', $avatar, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to get a group avatar.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you cannot view group details.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'groups' ) ) ) {
			$retval = new WP_Error(
				'bp_rest_group_invalid_id',
				__( 'Invalid group ID.', 'buddypress' ),
				array( 'status' => 404 )
			);

			$this->group = $this->groups_endpoint->get_group_object( $request );

			if ( false !== $this->group ) {
				$retval = true;
			}
		}

		/**
		 * Filter the group avatar `get_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_group_avatar_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Upload a group avatar.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function create_item( $request ) {
		$request->set_param( 'context', 'edit' );

		// Get the image file from $_FILES.
		$files = $request->get_file_params();

		if ( empty( $files ) ) {
			return new WP_Error(
				'bp_rest_attachments_group_avatar_no_image_file',
				__( 'Sorry, you need an image file to upload.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Upload the avatar.
		$avatar = $this->upload_avatar_from_file( $files );
		if ( is_wp_error( $avatar ) ) {
			return $avatar;
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $avatar, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a group avatar is uploaded via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param stdClass          $avatar   The group avatar object.
		 * @param WP_REST_Response  $response The response data.
		 * @param WP_REST_Request   $request  The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_group_avatar_create_item', $avatar, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to upload a group avatar.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function create_item_permissions_check( $request ) {
		$retval = $this->get_item_permissions_check( $request );

		if ( ! is_wp_error( $retval ) ) {
			if ( bp_disable_group_avatar_uploads() || false === buddypress()->avatar->show_avatars ) {
				$retval = new WP_Error(
					'bp_rest_attachments_group_avatar_disabled',
					__( 'Sorry, group avatar upload is disabled.', 'buddypress' ),
					array(
						'status' => 500,
					)
				);
			} elseif ( groups_is_user_admin( bp_loggedin_user_id(), $this->group->id ) || current_user_can( 'bp_moderate' ) ) {
				$retval = true;
			} else {
				$retval = new WP_Error(
					'bp_rest_authorization_required',
					__( 'Sorry, you are not authorized to perform this action.', 'buddypress' ),
					array(
						'status' => rest_authorization_required_code(),
					)
				);
			}
		}

		/**
		 * Filter the group avatar `create_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_group_avatar_create_item_permissions_check', $retval, $request );
	}

	/**
	 * Delete an existing group avatar.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function delete_item( $request ) {
		$request->set_param( 'context', 'edit' );
		$group_id = (int) $this->group->id;

		if ( ! bp_get_group_has_avatar( $group_id ) ) {
			return new WP_Error(
				'bp_rest_attachments_group_avatar_no_uploaded_avatar',
				__( 'Sorry, there are no uploaded avatars for this group on this site.', 'buddypress' ),
				array(
					'status' => 404,
				)
			);
		}

		$args = array();

		foreach ( array( 'full', 'thumb' ) as $type ) {
			$args[ $type ] = bp_core_fetch_avatar(
				array(
					'object'  => $this->object,
					'type'    => $type,
					'item_id' => $group_id,
					'html'    => false,
				)
			);
		}

		// Get the avatar object before deleting it.
		$avatar = $this->get_avatar_object( $args );

		$deleted = bp_core_delete_existing_avatar(
			array(
				'object'  => $this->object,
				'item_id' => $group_id,
			)
		);

		if ( ! $deleted ) {
			return new WP_Error(
				'bp_rest_attachments_group_avatar_delete_failed',
				__( 'Sorry, there was a problem deleting this group avatar.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Build the response.
		$response = new WP_REST_Response();
		$response->set_data(
			array(
				'deleted'  => true,
				'previous' => $avatar,
			)
		);

		/**
		 * Fires after a group avatar is deleted via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param WP_REST_Response  $response The response data.
		 * @param WP_REST_Request   $request  The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_group_avatar_delete_item', $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to delete a group avatar.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function delete_item_permissions_check( $request ) {
		$retval = $this->create_item_permissions_check( $request );

		/**
		 * Filter the group avatar `delete_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_group_avatar_delete_item_permissions_check', $retval, $request );
	}

	/**
	 * Prepares avatar data to return as an object.
	 *
	 * @since 0.1.0
	 *
	 * @param stdClass|string $avatar  Avatar object or string with url or image with html.
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $avatar, $request ) {
		$data = array(
			'full'  => $avatar->full,
			'thumb' => $avatar->thumb,
		);

		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $data, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		/**
		 * Filter a group avatar value returned from the API.
		 *
		 * @since 0.1.0
		 *
		 * @param WP_REST_Response  $response Response.
		 * @param WP_REST_Request   $request  Request used to generate the response.
		 * @param stdClass|string   $avatar   Avatar object or string with url or image with html.
		 */
		return apply_filters( 'bp_rest_attachments_group_avatar_prepare_value', $response, $request, $avatar );
	}

	/**
	 * Get the plugin schema, conforming to JSON Schema.
	 *
	 * @since 0.1.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$this->schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_attachments_group_avatar',
				'type'       => 'object',
				'properties' => array(
					'full'  => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Full size of the image file.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'uri',
						'readonly'    => true,
					),
					'thumb' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Thumb size of the image file.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'uri',
						'readonly'    => true,
					),
				),
			);
		}

		/**
		 * Filters the attachments group avatar schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_attachments_group_avatar_schema', $this->add_additional_fields_schema( $this->schema ) );
	}

	/**
	 * Get the query params for the `get_item`.
	 *
	 * @since 0.1.0
	 *
	 * @return array
	 */
	public function get_item_collection_params() {
		$params                       = parent::get_collection_params();
		$params['context']['default'] = 'view';

		// Removing unused params.
		unset( $params['search'], $params['page'], $params['per_page'] );

		$params['html'] = array(
			'description'       => __( 'Whether to return an <img> HTML element, vs a raw URL to a group avatar.', 'buddypress' ),
			'default'           => false,
			'type'              => 'boolean',
			'sanitize_callback' => 'rest_sanitize_boolean',
			'validate_callback' => 'rest_validate_request_arg',
		);

		$params['alt'] = array(
			'description'       => __( 'The alt attribute for the <img> element.', 'buddypress' ),
			'default'           => '',
			'type'              => 'string',
			'sanitize_callback' => 'sanitize_text_field',
			'validate_callback' => 'rest_validate_request_arg',
		);

		/**
		 * Filters the item collection query params.
		 *
		 * @param array $params Query params.
		 */
		return apply_filters( 'bp_rest_attachments_group_avatar_collection_params', $params );
	}
}


================================================
FILE: includes/bp-groups/classes/class-bp-rest-attachments-group-cover-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Attachments_Group_Cover_Endpoint class
 *
 * @package BuddyPress
 * @since 6.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Group Cover endpoints.
 *
 * /groups/<group_id>/cover
 *
 * @since 6.0.0
 */
class BP_REST_Attachments_Group_Cover_Endpoint extends WP_REST_Controller {
	use BP_REST_Attachments;

	/**
	 * BP_Attachment_Cover_Image Instance.
	 *
	 * @since 6.0.0
	 *
	 * @var BP_Attachment_Cover_Image
	 */
	protected $attachment_instance;

	/**
	 * Reuse some parts of the BP_REST_Groups_Endpoint class.
	 *
	 * @since 6.0.0
	 *
	 * @var BP_REST_Groups_Endpoint
	 */
	protected $groups_endpoint;

	/**
	 * Hold the group object.
	 *
	 * @since 6.0.0
	 *
	 * @var BP_Groups_Group
	 */
	protected $group;

	/**
	 * Group object type.
	 *
	 * @since 6.0.0
	 *
	 * @var string
	 */
	protected $object = 'group';

	/**
	 * Constructor.
	 *
	 * @since 6.0.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Groups_Cover_REST_Controller' );

		$this->namespace           = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base           = buddypress()->groups->id;
		$this->groups_endpoint     = new BP_REST_Groups_Endpoint();
		$this->attachment_instance = new BP_Attachment_Cover_Image();
	}

	/**
	 * Register the component routes.
	 *
	 * @since 6.0.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<group_id>[\d]+)/cover',
			array(
				'args'   => array(
					'group_id' => array(
						'description' => __( 'A unique numeric ID for the Group.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
				),
				array(
					'methods'             => WP_REST_Server::CREATABLE,
					'callback'            => array( $this, 'create_item' ),
					'permission_callback' => array( $this, 'create_item_permissions_check' ),
				),
				array(
					'methods'             => WP_REST_Server::DELETABLE,
					'callback'            => array( $this, 'delete_item' ),
					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Fetch an existing group cover.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$cover_url = bp_get_group_cover_url( $this->group );

		if ( empty( $cover_url ) ) {
			return new WP_Error(
				'bp_rest_attachments_group_cover_no_image',
				__( 'Sorry, there was a problem fetching this group cover.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $cover_url, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a group cover is fetched via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param string            $cover_url  The group cover url.
		 * @param WP_REST_Response  $response   The response data.
		 * @param WP_REST_Request   $request    The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_group_cover_get_item', $cover_url, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to get a group cover.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you cannot view group details.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'groups' ) ) ) {
			$retval = new WP_Error(
				'bp_rest_group_invalid_id',
				__( 'Invalid group ID.', 'buddypress' ),
				array( 'status' => 404 )
			);

			$this->group = $this->groups_endpoint->get_group_object( $request );

			if ( false !== $this->group && $this->groups_endpoint->can_see( $this->group ) ) {
				$retval = true;
			}
		}

		/**
		 * Filter the group cover `get_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_group_cover_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Upload a group cover.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function create_item( $request ) {
		$request->set_param( 'context', 'edit' );

		// Get the image file from $_FILES.
		$files = $request->get_file_params();

		if ( empty( $files ) ) {
			return new WP_Error(
				'bp_rest_attachments_group_cover_no_image_file',
				__( 'Sorry, you need an image file to upload.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Upload the group cover.
		$cover_url = $this->upload_cover_from_file( $files );
		if ( is_wp_error( $cover_url ) ) {
			return $cover_url;
		}

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $cover_url, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a group cover is uploaded via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param string            $cover_url  The group cover url.
		 * @param WP_REST_Response  $response   The response data.
		 * @param WP_REST_Request   $request    The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_group_cover_create_item', $cover_url, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to upload a group cover.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function create_item_permissions_check( $request ) {
		$retval = $this->delete_item_permissions_check( $request );

		if ( ! is_wp_error( $retval ) && bp_disable_group_cover_image_uploads() ) {
			$retval = new WP_Error(
				'bp_rest_attachments_group_cover_disabled',
				__( 'Sorry, group cover upload is disabled.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		/**
		 * Filter the group cover `create_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_group_cover_create_item_permissions_check', $retval, $request );
	}

	/**
	 * Delete an existing group cover.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function delete_item( $request ) {
		$request->set_param( 'context', 'edit' );

		$cover_url = bp_get_group_cover_url( $this->group );
		$deleted   = bp_attachments_delete_file(
			array(
				'item_id'    => (int) $this->group->id,
				'object_dir' => $this->get_cover_object_component(),
				'type'       => 'cover-image',
			)
		);

		if ( ! $deleted ) {
			return new WP_Error(
				'bp_rest_attachments_group_cover_delete_failed',
				__( 'Sorry, there was a problem deleting this group cover.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		// Build the response.
		$response = new WP_REST_Response();
		$response->set_data(
			array(
				'deleted'  => true,
				'previous' => $cover_url,
			)
		);

		/**
		 * Fires after a group cover is deleted via the REST API.
		 *
		 * @since 6.0.0
		 *
		 * @param BP_Groups_Group   $group     The group object.
		 * @param WP_REST_Response  $response  The response data.
		 * @param WP_REST_Request   $request   The request sent to the API.
		 */
		do_action( 'bp_rest_attachments_group_cover_delete_item', $this->group, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to delete a group cover.
	 *
	 * @since 6.0.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function delete_item_permissions_check( $request ) {
		$retval = $this->get_item_permissions_check( $request );

		if ( ! is_wp_error( $retval ) ) {
			$args  = array();
			$error = new WP_Error(
				'bp_rest_authorization_required',
				__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
				array(
					'status' => rest_authorization_required_code(),
				)
			);

			if ( ! isset( $this->group->id ) || ! isset( $this->object ) ) {
				$retval = $error;
			} else {
				$args = array(
					'item_id' => (int) $this->group->id,
					'object'  => $this->object,
				);

				if ( ! is_user_logged_in() ) {
					$retval = new WP_Error(
						'bp_rest_authorization_required',
						__( 'Sorry, you need to be logged in to perform this action.', 'buddypress' ),
						array(
							'status' => rest_authorization_required_code(),
						)
					);
				} elseif ( bp_attachments_current_user_can( 'edit_cover_image', $args ) ) {
					$retval = true;
				} else {
					$retval = $error;
				}
			}
		}

		/**
		 * Filter the group cover `delete_item` permissions check.
		 *
		 * @since 6.0.0
		 *
		 * @param true|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_group_cover_delete_item_permissions_check', $retval, $request );
	}

	/**
	 * Prepares group cover to return as an object.
	 *
	 * @since 6.0.0
	 *
	 * @param string          $cover_url Group cover url.
	 * @param WP_REST_Request $request   Full details about the request.
	 * @return WP_REST_Response
	 */
	public function prepare_item_for_response( $cover_url, $request ) {
		$data = array(
			'image' => $cover_url,
		);

		$context  = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
		$data     = $this->add_additional_fields_to_object( $data, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		/**
		 * Filter a group cover value returned from the API.
		 *
		 * @since 6.0.0
		 *
		 * @param WP_REST_Response  $response  Response.
		 * @param WP_REST_Request   $request   Request used to generate the response.
		 * @param string            $cover_url Group cover url.
		 */
		return apply_filters( 'bp_rest_attachments_group_cover_prepare_value', $response, $request, $cover_url );
	}

	/**
	 * Get the plugin schema, conforming to JSON Schema.
	 *
	 * @since 6.0.0
	 *
	 * @return array
	 */
	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$this->schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_attachments_group_cover',
				'type'       => 'object',
				'properties' => array(
					'image' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Full size of the image file.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'uri',
						'readonly'    => true,
					),
				),
			);
		}

		/**
		 * Filters the attachments group cover schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_attachments_group_cover_schema', $this->add_additional_fields_schema( $this->schema ) );
	}
}


================================================
FILE: includes/bp-groups/classes/class-bp-rest-group-invites-endpoint.php
================================================
<?php
/**
 * BP REST: BP_REST_Group_Invites_Endpoint class
 *
 * @package BuddyPress
 * @since 0.1.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Group Invites endpoints.
 *
 * Use /groups/{group_id}/invites
 * Use /groups/{group_id}/invites/{invite_id}
 *
 * @since 0.1.0
 */
class BP_REST_Group_Invites_Endpoint extends WP_REST_Controller {

	/**
	 * Reuse some parts of the BP_REST_Groups_Endpoint class.
	 *
	 * @since 0.1.0
	 *
	 * @var BP_REST_Groups_Endpoint
	 */
	protected $groups_endpoint;

	/**
	 * Constructor.
	 *
	 * @since 0.1.0
	 */
	public function __construct() {
		_deprecated_class( __CLASS__, '15.0.0', 'BP_Groups_Invite_REST_Controller' );

		$this->namespace              = bp_rest_namespace() . '/' . bp_rest_version();
		$this->rest_base              = buddypress()->groups->id . '/invites';
		$this->groups_endpoint        = new BP_REST_Groups_Endpoint();
		$this->group_members_endpoint = new BP_REST_Group_Membership_Endpoint();
	}

	/**
	 * Register the component routes.
	 *
	 * @since 0.1.0
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_items' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
					'args'                => $this->get_collection_params(),
				),
				array(
					'methods'             => WP_REST_Server::CREATABLE,
					'callback'            => array( $this, 'create_item' ),
					'permission_callback' => array( $this, 'create_item_permissions_check' ),
					'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),

				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);

		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<invite_id>[\d]+)',
			array(
				'args'   => array(
					'invite_id' => array(
						'description' => __( 'A unique numeric ID for the group invitation.', 'buddypress' ),
						'type'        => 'integer',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => array(
						'context' => $this->get_context_param( array( 'default' => 'view' ) ),
					),
				),
				array(
					'methods'             => WP_REST_Server::EDITABLE,
					'callback'            => array( $this, 'update_item' ),
					'permission_callback' => array( $this, 'update_item_permissions_check' ),
				),
				array(
					'methods'             => WP_REST_Server::DELETABLE,
					'callback'            => array( $this, 'delete_item' ),
					'permission_callback' => array( $this, 'delete_item_permissions_check' ),
				),
				'schema' => array( $this, 'get_item_schema' ),
			)
		);
	}

	/**
	 * Retrieve group invitations.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response
	 */
	public function get_items( $request ) {
		$args = array(
			'item_id'     => $request->get_param( 'group_id' ),
			'user_id'     => $request->get_param( 'user_id' ),
			'invite_sent' => $request->get_param( 'invite_sent' ),
			'per_page'    => $request->get_param( 'per_page' ),
			'page'        => $request->get_param( 'page' ),
		);

		/**
		 * Inviter_id is a special case, because 0 can be meaningful for requests,
		 * but if it is zero for invitations, we can safely ignore it and should.
		 * So, only apply non-zero inviter_ids.
		 */
		if ( $request->get_param( 'inviter_id' ) ) {
			$args['inviter_id'] = $request->get_param( 'inviter_id' );
		}

		// If the query is not restricted by group, user or inviter, limit it to the current user, if not an admin.
		if ( ! $args['item_id'] && ! $args['user_id'] && ! $args['inviter_id'] && ! bp_current_user_can( 'bp_moderate' ) ) {
			$args['user_id'] = bp_loggedin_user_id();
		}

		/**
		 * Filter the query arguments for the request.
		 *
		 * @since 0.1.0
		 *
		 * @param array           $args    Key value array of query var to query value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		$args = apply_filters( 'bp_rest_group_invites_get_items_query_args', $args, $request );

		// Get invites.
		$invites_data = groups_get_invites( $args );

		$retval = array();
		foreach ( $invites_data as $invitation ) {
			if ( $invitation instanceof BP_Invitation ) {
				$retval[] = $this->prepare_response_for_collection(
					$this->prepare_item_for_response( $invitation, $request )
				);
			}
		}

		$response = rest_ensure_response( $retval );
		$response = bp_rest_response_add_total_headers( $response, count( $invites_data ), $args['per_page'] );

		/**
		 * Fires after a list of group invites are fetched via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param array            $invites_data  Invited users from the group.
		 * @param WP_REST_Response $response      The response data.
		 * @param WP_REST_Request  $request       The request sent to the API.
		 */
		do_action( 'bp_rest_group_invites_get_items', $invites_data, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to group invitations.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return bool|WP_Error
	 */
	public function get_items_permissions_check( $request ) {
		$error = new WP_Error(
			'bp_rest_group_invites_cannot_get_items',
			__( 'Sorry, you are not allowed to fetch group invitations with those arguments.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		$retval = $error;

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'groups' ) ) ) {
			$group_id        = (int) $request->get_param( 'group_id' );
			$current_user_id = (int) bp_loggedin_user_id();
			$user_id_arg     = (int) $request->get_param( 'user_id' );
			$inviter_id      = (int) $request->get_param( 'inviter_id' );

			if ( ! is_user_logged_in() ) {
				$retval = new WP_Error(
					'bp_rest_authorization_required',
					__( 'Sorry, you need to be logged in to see the group invitations.', 'buddypress' ),
					array(
						'status' => rest_authorization_required_code(),
					)
				);
			} elseif ( $group_id ) {
				if ( ! $user_id_arg ) {
					$user_id_arg = $current_user_id;
				}

				$user = bp_rest_get_user( $user_id_arg );

				// Check the user is valid.
				if ( ! $user instanceof WP_User ) {
					$retval = new WP_Error(
						'bp_rest_member_invalid_id',
						__( 'Invalid member ID.', 'buddypress' ),
						array(
							'status' => 404,
						)
					);
				} else {
					$group = $this->groups_endpoint->get_group_object( $group_id );

					// Check the group is valid.
					if ( ! $group instanceof BP_Groups_Group ) {
						$retval = new WP_Error(
							'bp_rest_group_invalid_id',
							__( 'Invalid group ID.', 'buddypress' ),
							array(
								'status' => 404,
							)
						);
					} elseif ( bp_current_user_can( 'bp_moderate' ) || $this->can_see( $group->id ) ) {
						/*
						* Users can see invitations if they
						* - are a site admin,
						* - are a group admin of the subject group (group_id must be specified).
						*/
						$retval = true;
					} else {
						$retval = $error;
					}
				}
			} elseif ( $user_id_arg ) {
				$user = bp_rest_get_user( $user_id_arg );

				// Check the user is valid.
				if ( ! $user instanceof WP_User ) {
					$retval = new WP_Error(
						'bp_rest_member_invalid_id',
						__( 'Invalid member ID.', 'buddypress' ),
						array(
							'status' => 404,
						)
					);
				} elseif ( bp_current_user_can( 'bp_moderate' ) || $user->ID === $current_user_id ) {
					/*
					* Users can see invitations if they:
					* - are a site admin,
					* - are the invite recipient (user_id must be specified).
					*/
					$retval = true;
				} else {
					$retval = $error;
				}
			} elseif ( $inviter_id ) {
				$inviter = bp_rest_get_user( $inviter_id );

				// Check the inviter is valid.
				if ( ! $inviter instanceof WP_User ) {
					$retval = new WP_Error(
						'bp_rest_member_invalid_id',
						__( 'Invalid member ID.', 'buddypress' ),
						array(
							'status' => 404,
						)
					);
				} elseif ( bp_current_user_can( 'bp_moderate' ) || $inviter->ID === $current_user_id ) {
					/*
					* Users can see invitations if they:
					* - are a site admin,
					* - are the inviter (inviter_id must be specified).
					*/
					$retval = true;
				} else {
					$retval = $error;
				}
			}
		}

		/**
		 * Filter the group invites `get_items` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Whether the request can continue.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_group_invites_get_items_permissions_check', $retval, $request );
	}

	/**
	 * Fetch a specific group invitation by ID.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full data about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function get_item( $request ) {
		$invite = $this->fetch_single_invite( $request->get_param( 'invite_id' ) );
		$retval = $this->prepare_response_for_collection(
			$this->prepare_item_for_response( $invite, $request )
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a membership request is fetched via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Invitation     $invite      Invitation object.
		 * @param WP_REST_Response  $response    The response data.
		 * @param WP_REST_Request   $request     The request sent to the API.
		 */
		do_action( 'bp_rest_group_invite_get_item', $invite, $response, $request );

		return $response;
	}

	/**
	 * Check if a given request has access to fetch group invitation.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function get_item_permissions_check( $request ) {
		$retval = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( bp_current_user_can( 'bp_view', array( 'bp_component' => 'groups' ) ) ) {
			$user_id = bp_loggedin_user_id();

			if ( ! $user_id ) {
				$retval = new WP_Error(
					'bp_rest_authorization_required',
					__( 'Sorry, you need to be logged in to see the group invitations.', 'buddypress' ),
					array(
						'status' => rest_authorization_required_code(),
					)
				);
			} else {
				$invite = $this->fetch_single_invite( $request->get_param( 'invite_id' ) );

				if ( ! $invite ) {
					$retval = new WP_Error(
						'bp_rest_group_invite_invalid_id',
						__( 'Invalid group invitation ID.', 'buddypress' ),
						array(
							'status' => 404,
						)
					);
				} elseif ( bp_current_user_can( 'bp_moderate' ) || $this->can_see( $invite->item_id ) || in_array( $user_id, array( $invite->user_id, $invite->inviter_id ), true ) ) {
					/*
					* Users can see a specific invitation if they
					* - are a site admin
					* - are a group admin of the subject group
					* - are the invite recipient
					* - are the inviter
					*/
					$retval = true;
				} else {
					$retval = new WP_Error(
						'bp_rest_group_invites_cannot_get_item',
						__( 'Sorry, you are not allowed to fetch an invitation.', 'buddypress' ),
						array(
							'status' => rest_authorization_required_code(),
						)
					);
				}
			}
		}

		/**
		 * Filter the group membership request `get_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Whether the request can continue.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_group_invites_get_item_permissions_check', $retval, $request );
	}

	/**
	 * Invite a member to a group.
	 *
	 * @since 0.1.0
	 *
	 * @param  WP_REST_Request $request Full data about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function create_item( $request ) {
		$inviter_id_arg = ! empty( $request->get_param( 'inviter_id' ) ) ? $request->get_param( 'inviter_id' ) : bp_loggedin_user_id();
		$group          = $this->groups_endpoint->get_group_object( $request->get_param( 'group_id' ) );
		$user           = bp_rest_get_user( $request->get_param( 'user_id' ) );
		$inviter        = bp_rest_get_user( $inviter_id_arg );

		$invite_id = groups_invite_user(
			array(
				'user_id'     => $user->ID,
				'group_id'    => $group->id,
				'inviter_id'  => $inviter->ID,
				'send_invite' => ! empty( $request->get_param( 'invite_sent' ) ) ? (bool) $request->get_param( 'invite_sent' ) : 1,
				'content'     => $request->get_param( 'message' ),
			)
		);

		if ( ! $invite_id ) {
			return new WP_Error(
				'bp_rest_group_invite_cannot_create_item',
				__( 'Could not invite member to the group.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$invite = new BP_Invitation( $invite_id );

		// Set context.
		$request->set_param( 'context', 'edit' );

		$retval = array(
			$this->prepare_response_for_collection(
				$this->prepare_item_for_response( $invite, $request )
			),
		);

		$response = rest_ensure_response( $retval );

		/**
		 * Fires after a member is invited to a group via the REST API.
		 *
		 * @since 0.1.0
		 *
		 * @param BP_Invitation    $invite         The invitation object.
		 * @param WP_User          $user           The invited user.
		 * @param WP_User          $inviter        The inviter user.
		 * @param BP_Groups_Group  $group          The group object.
		 * @param WP_REST_Response $response       The response data.
		 * @param WP_REST_Request  $request        The request sent to the API.
		 */
		do_action( 'bp_rest_group_invites_create_item', $invite, $user, $inviter, $group, $response, $request );

		return $response;
	}

	/**
	 * Checks if a given request has access to invite a member to a group.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error
	 */
	public function create_item_permissions_check( $request ) {
		$inviter_id_arg = ! empty( $request->get_param( 'inviter_id' ) ) ? $request->get_param( 'inviter_id' ) : bp_loggedin_user_id();
		$retval         = new WP_Error(
			'bp_rest_authorization_required',
			__( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);

		if ( ! is_user_logged_in() ) {
			$retval = new WP_Error(
				'bp_rest_authorization_required',
				__( 'Sorry, you need to be logged in to create an invitation.', 'buddypress' ),
				array(
					'status' => rest_authorization_required_code(),
				)
			);
		} else {
			$user    = bp_rest_get_user( $request->get_param( 'user_id' ) );
			$inviter = bp_rest_get_user( $inviter_id_arg );

			if ( empty( $user->ID ) || empty( $inviter->ID ) || $user->ID === $inviter->ID ) {
				$retval = new WP_Error(
					'bp_rest_member_invalid_id',
					__( 'Invalid member ID.', 'buddypress' ),
					array(
						'status' => 404,
					)
				);
			} else {
				$group = $this->groups_endpoint->get_group_object( $request->get_param( 'group_id' ) );

				if ( empty( $group->id ) ) {
					$retval = new WP_Error(
						'bp_rest_group_invalid_id',
						__( 'Invalid group ID.', 'buddypress' ),
						array(
							'status' => 404,
						)
					);
				} elseif ( bp_current_user_can( 'bp_moderate' ) || bp_loggedin_user_id() === $inviter_id_arg ) {
						$retval = true;
				} else {
					$retval = new WP_Error(
						'bp_rest_group_invite_cannot_create_item',
						__( 'Sorry, you are not allowed to create the invitation as requested.', 'buddypress' ),
						array(
							'status' => rest_authorization_required_code(),
						)
					);
				}
			}
		}

		/**
		 * Filter the group invites `create_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param true|WP_Error   $retval  Whether the request can continue.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_group_invites_create_item_permissions_check', $retval, $request );
	}

	/**
	 * Accept a group invitation.
	 *
	 * @since 0.1.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error
	 */
	public function update_item( $request ) {
		$request->set_param( 'context', 'edit' );

		$invite = $this->fetch_single_invite( $request->get_param( 'invite_id' ) );
		$accept = groups_accept_invite( $invite->user_id, $invite->item_id );
		if ( ! $accept ) {
			return new WP_Error(
				'bp_rest_group_invite_cannot_update_item',
				__( 'Could not accept group invitation.', 'buddypress' ),
				array(
					'status' => 500,
				)
			);
		}

		$accepted_member = new BP_Groups_Member( $invite->user_id, $invite->item_id );

		$retval = array(
			$this->prepare_response_for_collection(
				$this->group_members_endpoint->prepare_item_for_response( $accepted_mem
Download .txt
gitextract_dwozqvnr/

├── .distignore
├── .editorconfig
├── .gitignore
├── .phpcs/
│   └── .gitkeep
├── CONTRIBUTING.md
├── README.md
├── bp-rest.php
├── composer.json
├── includes/
│   ├── bp-activity/
│   │   └── classes/
│   │       └── class-bp-rest-activity-endpoint.php
│   ├── bp-attachments/
│   │   └── classes/
│   │       └── trait-attachments.php
│   ├── bp-blogs/
│   │   └── classes/
│   │       ├── class-bp-rest-attachments-blog-avatar-endpoint.php
│   │       └── class-bp-rest-blogs-endpoint.php
│   ├── bp-components/
│   │   └── classes/
│   │       └── class-bp-rest-components-endpoint.php
│   ├── bp-friends/
│   │   └── classes/
│   │       └── class-bp-rest-friends-endpoint.php
│   ├── bp-groups/
│   │   └── classes/
│   │       ├── class-bp-rest-attachments-group-avatar-endpoint.php
│   │       ├── class-bp-rest-attachments-group-cover-endpoint.php
│   │       ├── class-bp-rest-group-invites-endpoint.php
│   │       ├── class-bp-rest-group-membership-endpoint.php
│   │       ├── class-bp-rest-group-membership-request-endpoint.php
│   │       └── class-bp-rest-groups-endpoint.php
│   ├── bp-members/
│   │   └── classes/
│   │       ├── class-bp-rest-attachments-member-avatar-endpoint.php
│   │       ├── class-bp-rest-attachments-member-cover-endpoint.php
│   │       ├── class-bp-rest-members-endpoint.php
│   │       └── class-bp-rest-signup-endpoint.php
│   ├── bp-messages/
│   │   └── classes/
│   │       ├── class-bp-rest-messages-endpoint.php
│   │       └── class-bp-rest-sitewide-notices-endpoint.php
│   ├── bp-notifications/
│   │   └── classes/
│   │       └── class-bp-rest-notifications-endpoint.php
│   └── bp-xprofile/
│       └── classes/
│           ├── class-bp-rest-xprofile-data-endpoint.php
│           ├── class-bp-rest-xprofile-field-groups-endpoint.php
│           └── class-bp-rest-xprofile-fields-endpoint.php
├── package.json
├── phpcs.xml.dist
├── phpunit.xml.dist
├── readme.txt
├── tests/
│   ├── bootstrap.php
│   ├── define-constants.php
│   ├── multisite.xml
│   └── testcases/
│       ├── activity/
│       │   └── test-controller.php
│       ├── attachments/
│       │   ├── test-blog-avatar-controller.php
│       │   ├── test-group-avatar-controller.php
│       │   ├── test-group-cover-controller.php
│       │   ├── test-member-avatar-controller.php
│       │   └── test-member-cover-controller.php
│       ├── blogs/
│       │   └── test-controller.php
│       ├── components/
│       │   └── test-controller.php
│       ├── friends/
│       │   └── test-controller.php
│       ├── groups/
│       │   ├── test-controller.php
│       │   └── test-group-invites-controller.php
│       ├── members/
│       │   └── test-controller.php
│       ├── membership/
│       │   ├── test-group-membership-controller.php
│       │   └── test-group-membership-request-controller.php
│       ├── messages/
│       │   └── test-controller.php
│       ├── notifications/
│       │   └── test-controller.php
│       ├── signup/
│       │   └── test-controller.php
│       ├── sitewide-notices/
│       │   └── test-controller.php
│       └── xprofile/
│           ├── test-data-controller.php
│           ├── test-field-controller.php
│           └── test-group-controller.php
└── wp-env.json
Download .txt
SYMBOL INDEX (1161 symbols across 45 files)

FILE: bp-rest.php
  function bp_rest (line 46) | function bp_rest() {
  function bp_filter_v1_rest_current_rest_namespace (line 175) | function bp_filter_v1_rest_current_rest_namespace() {
  function bp_filter_v1_rest_current_rest_version (line 185) | function bp_filter_v1_rest_current_rest_version() {
  function bp_filter_v1_rest_request_blog_url (line 197) | function bp_filter_v1_rest_request_blog_url( $request, $url ) {
  function bp_filter_v1_rest_post_dispatch (line 232) | function bp_filter_v1_rest_post_dispatch( $response, $instance, $request...

FILE: includes/bp-activity/classes/class-bp-rest-activity-endpoint.php
  class BP_REST_Activity_Endpoint (line 16) | class BP_REST_Activity_Endpoint extends WP_REST_Controller {
    method __construct (line 32) | public function __construct() {
    method register_routes (line 44) | public function register_routes() {
    method get_items (line 129) | public function get_items( $request ) {
    method get_items_permissions_check (line 264) | public function get_items_permissions_check( $request ) {
    method get_item (line 296) | public function get_item( $request ) {
    method get_item_permissions_check (line 339) | public function get_item_permissions_check( $request ) {
    method create_item (line 371) | public function create_item( $request ) {
    method create_item_permissions_check (line 481) | public function create_item_permissions_check( $request ) {
    method update_item (line 529) | public function update_item( $request ) {
    method update_item_permissions_check (line 591) | public function update_item_permissions_check( $request ) {
    method delete_item (line 635) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 694) | public function delete_item_permissions_check( $request ) {
    method get_user_favorites (line 737) | public function get_user_favorites() {
    method update_favorite (line 758) | public function update_favorite( $request ) {
    method update_favorite_permissions_check (line 830) | public function update_favorite_permissions_check( $request ) {
    method render_item (line 862) | public function render_item( $activity ) {
    method prepare_item_for_response (line 909) | public function prepare_item_for_response( $activity, $request ) {
    method prepare_activity_comments (line 989) | protected function prepare_activity_comments( $comments, $request ) {
    method prepare_item_for_database (line 1022) | protected function prepare_item_for_database( $request ) {
    method prepare_links (line 1121) | protected function prepare_links( $activity ) {
    method can_see (line 1210) | protected function can_see( $request ) {
    method show_hidden (line 1226) | protected function show_hidden( $component, $item_id ) {
    method get_activity_object (line 1264) | public function get_activity_object( $request ) {
    method get_endpoint_args_for_item_schema (line 1289) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 1324) | public function get_item_schema() {
    method get_collection_params (line 1505) | public function get_collection_params() {

FILE: includes/bp-attachments/classes/trait-attachments.php
  type BP_REST_Attachments (line 16) | trait BP_REST_Attachments {
    method upload_cover_from_file (line 26) | protected function upload_cover_from_file( $file ) {
    method upload_avatar_from_file (line 157) | protected function upload_avatar_from_file( $files ) {
    method resize (line 259) | protected function resize( $file ) {
    method crop_image (line 315) | protected function crop_image( $image_file ) {
    method delete_existing_image (line 388) | protected function delete_existing_image() {
    method get_avatar_object (line 422) | protected function get_avatar_object( $args = array() ) {
    method get_item_id (line 441) | protected function get_item_id() {
    method get_cover_object_component (line 452) | protected function get_cover_object_component() {

FILE: includes/bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php
  class BP_REST_Attachments_Blog_Avatar_Endpoint (line 16) | class BP_REST_Attachments_Blog_Avatar_Endpoint extends WP_REST_Controller {
    method __construct (line 43) | public function __construct() {
    method register_routes (line 56) | public function register_routes() {
    method get_item (line 86) | public function get_item( $request ) {
    method get_item_permissions_check (line 167) | public function get_item_permissions_check( $request ) {
    method prepare_item_for_response (line 216) | public function prepare_item_for_response( $avatar, $request ) {
    method get_item_schema (line 246) | public function get_item_schema() {
    method get_item_collection_params (line 286) | public function get_item_collection_params() {

FILE: includes/bp-blogs/classes/class-bp-rest-blogs-endpoint.php
  class BP_REST_Blogs_Endpoint (line 19) | class BP_REST_Blogs_Endpoint extends WP_REST_Controller {
    method __construct (line 26) | public function __construct() {
    method register_routes (line 38) | public function register_routes() {
    method get_items (line 94) | public function get_items( $request ) {
    method get_items_permissions_check (line 169) | public function get_items_permissions_check( $request ) {
    method get_item (line 201) | public function get_item( $request ) {
    method get_item_permissions_check (line 244) | public function get_item_permissions_check( $request ) {
    method create_item (line 276) | public function create_item( $request ) {
    method create_item_permissions_check (line 385) | public function create_item_permissions_check( $request ) {
    method prepare_item_for_response (line 428) | public function prepare_item_for_response( $blog, $request ) {
    method prepare_links (line 496) | protected function prepare_links( $blog ) {
    method get_blog_permalink (line 545) | protected function get_blog_permalink( $blog ) {
    method get_blog_object (line 570) | public function get_blog_object( $blog_id ) {
    method get_endpoint_args_for_item_schema (line 594) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 665) | public function get_item_schema() {
    method get_collection_params (line 806) | public function get_collection_params() {

FILE: includes/bp-components/classes/class-bp-rest-components-endpoint.php
  class BP_REST_Components_Endpoint (line 16) | class BP_REST_Components_Endpoint extends WP_REST_Controller {
    method __construct (line 23) | public function __construct() {
    method register_routes (line 35) | public function register_routes() {
    method get_items (line 77) | public function get_items( $request ) {
    method get_items_permissions_check (line 163) | public function get_items_permissions_check( $request ) {
    method update_item (line 196) | public function update_item( $request ) {
    method update_item_permissions_check (line 275) | public function update_item_permissions_check( $request ) {
    method prepare_item_for_response (line 298) | public function prepare_item_for_response( $component, $request ) {
    method verify_component_status (line 330) | protected function verify_component_status( $name, $return_type = 'str...
    method deactivate_helper (line 358) | protected function deactivate_helper( $component ) {
    method activate_helper (line 379) | protected function activate_helper( $component ) {
    method get_component_info (line 412) | public function get_component_info( $component ) {
    method component_exists (line 514) | protected function component_exists( $component ) {
    method get_item_schema (line 525) | public function get_item_schema() {
    method get_collection_params (line 588) | public function get_collection_params() {

FILE: includes/bp-friends/classes/class-bp-rest-friends-endpoint.php
  class BP_REST_Friends_Endpoint (line 19) | class BP_REST_Friends_Endpoint extends WP_REST_Controller {
    method __construct (line 26) | public function __construct() {
    method register_routes (line 38) | public function register_routes() {
    method get_items (line 100) | public function get_items( $request ) {
    method get_items_permissions_check (line 176) | public function get_items_permissions_check( $request ) {
    method get_item (line 208) | public function get_item( $request ) {
    method get_item_permissions_check (line 267) | public function get_item_permissions_check( $request ) {
    method create_item (line 299) | public function create_item( $request ) {
    method create_item_permissions_check (line 406) | public function create_item_permissions_check( $request ) {
    method update_item (line 428) | public function update_item( $request ) {
    method update_item_permissions_check (line 501) | public function update_item_permissions_check( $request ) {
    method delete_item (line 523) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 615) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 638) | public function prepare_item_for_response( $friendship, $request ) {
    method prepare_links (line 676) | protected function prepare_links( $friendship ) {
    method get_friendship_object (line 716) | public function get_friendship_object( $friendship_id ) {
    method get_endpoint_args_for_item_schema (line 728) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 816) | public function get_item_schema() {
    method get_collection_params (line 879) | public function get_collection_params() {

FILE: includes/bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php
  class BP_REST_Attachments_Group_Avatar_Endpoint (line 16) | class BP_REST_Attachments_Group_Avatar_Endpoint extends WP_REST_Controll...
    method __construct (line 60) | public function __construct() {
    method register_routes (line 74) | public function register_routes() {
    method get_item (line 114) | public function get_item( $request ) {
    method get_item_permissions_check (line 172) | public function get_item_permissions_check( $request ) {
    method create_item (line 214) | public function create_item( $request ) {
    method create_item_permissions_check (line 266) | public function create_item_permissions_check( $request ) {
    method delete_item (line 310) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 387) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 410) | public function prepare_item_for_response( $avatar, $request ) {
    method get_item_schema (line 440) | public function get_item_schema() {
    method get_item_collection_params (line 480) | public function get_item_collection_params() {

FILE: includes/bp-groups/classes/class-bp-rest-attachments-group-cover-endpoint.php
  class BP_REST_Attachments_Group_Cover_Endpoint (line 18) | class BP_REST_Attachments_Group_Cover_Endpoint extends WP_REST_Controller {
    method __construct (line 62) | public function __construct() {
    method register_routes (line 76) | public function register_routes() {
    method get_item (line 115) | public function get_item( $request ) {
    method get_item_permissions_check (line 158) | public function get_item_permissions_check( $request ) {
    method create_item (line 200) | public function create_item( $request ) {
    method create_item_permissions_check (line 252) | public function create_item_permissions_check( $request ) {
    method delete_item (line 284) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 337) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 394) | public function prepare_item_for_response( $cover_url, $request ) {
    method get_item_schema (line 423) | public function get_item_schema() {

FILE: includes/bp-groups/classes/class-bp-rest-group-invites-endpoint.php
  class BP_REST_Group_Invites_Endpoint (line 19) | class BP_REST_Group_Invites_Endpoint extends WP_REST_Controller {
    method __construct (line 35) | public function __construct() {
    method register_routes (line 49) | public function register_routes() {
    method get_items (line 112) | public function get_items( $request ) {
    method get_items_permissions_check (line 182) | public function get_items_permissions_check( $request ) {
    method get_item (line 312) | public function get_item( $request ) {
    method get_item_permissions_check (line 342) | public function get_item_permissions_check( $request ) {
    method create_item (line 413) | public function create_item( $request ) {
    method create_item_permissions_check (line 477) | public function create_item_permissions_check( $request ) {
    method update_item (line 551) | public function update_item( $request ) {
    method update_item_permissions_check (line 600) | public function update_item_permissions_check( $request ) {
    method delete_item (line 661) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 729) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 789) | public function prepare_item_for_response( $invite, $request ) {
    method prepare_links (line 833) | protected function prepare_links( $invite ) {
    method can_see (line 868) | protected function can_see( $group_id ) {
    method fetch_single_invite (line 886) | public function fetch_single_invite( $invite_id = 0 ) {
    method get_endpoint_args_for_item_schema (line 903) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 948) | public function get_item_schema() {
    method get_collection_params (line 1044) | public function get_collection_params() {

FILE: includes/bp-groups/classes/class-bp-rest-group-membership-endpoint.php
  class BP_REST_Group_Membership_Endpoint (line 19) | class BP_REST_Group_Membership_Endpoint extends WP_REST_Controller {
    method __construct (line 44) | public function __construct() {
    method register_routes (line 58) | public function register_routes() {
    method get_items (line 108) | public function get_items( $request ) {
    method get_items_permissions_check (line 178) | public function get_items_permissions_check( $request ) {
    method create_item (line 221) | public function create_item( $request ) {
    method create_item_permissions_check (line 305) | public function create_item_permissions_check( $request ) {
    method update_item (line 368) | public function update_item( $request ) {
    method update_item_permissions_check (line 453) | public function update_item_permissions_check( $request ) {
    method delete_item (line 540) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 593) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 683) | public function prepare_item_for_response( $group_member, $request ) {
    method prepare_links (line 735) | protected function prepare_links( $group_member ) {
    method get_endpoint_args_for_method (line 771) | public function get_endpoint_args_for_method( $method = WP_REST_Server...
    method get_item_schema (line 840) | public function get_item_schema() {
    method get_collection_params (line 914) | public function get_collection_params() {

FILE: includes/bp-groups/classes/class-bp-rest-group-membership-request-endpoint.php
  class BP_REST_Group_Membership_Request_Endpoint (line 19) | class BP_REST_Group_Membership_Request_Endpoint extends WP_REST_Controll...
    method __construct (line 44) | public function __construct() {
    method register_routes (line 59) | public function register_routes() {
    method get_items (line 121) | public function get_items( $request ) {
    method get_items_permissions_check (line 178) | public function get_items_permissions_check( $request ) {
    method get_item (line 258) | public function get_item( $request ) {
    method get_item_permissions_check (line 288) | public function get_item_permissions_check( $request ) {
    method create_item (line 349) | public function create_item( $request ) {
    method create_item_permissions_check (line 420) | public function create_item_permissions_check( $request ) {
    method update_item (line 481) | public function update_item( $request ) {
    method update_item_permissions_check (line 531) | public function update_item_permissions_check( $request ) {
    method delete_item (line 589) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 659) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 718) | public function prepare_item_for_response( $invite, $request ) {
    method prepare_links (line 760) | protected function prepare_links( $invite ) {
    method fetch_single_membership_request (line 797) | public function fetch_single_membership_request( $request_id = 0 ) {
    method get_endpoint_args_for_item_schema (line 814) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 854) | public function get_item_schema() {
    method get_collection_params (line 890) | public function get_collection_params() {

FILE: includes/bp-groups/classes/class-bp-rest-groups-endpoint.php
  class BP_REST_Groups_Endpoint (line 16) | class BP_REST_Groups_Endpoint extends WP_REST_Controller {
    method __construct (line 23) | public function __construct() {
    method register_routes (line 35) | public function register_routes() {
    method get_items (line 129) | public function get_items( $request ) {
    method get_items_permissions_check (line 211) | public function get_items_permissions_check( $request ) {
    method get_item (line 243) | public function get_item( $request ) {
    method get_item_permissions_check (line 276) | public function get_item_permissions_check( $request ) {
    method create_item (line 320) | public function create_item( $request ) {
    method create_item_permissions_check (line 390) | public function create_item_permissions_check( $request ) {
    method update_item (line 425) | public function update_item( $request ) {
    method update_item_permissions_check (line 478) | public function update_item_permissions_check( $request ) {
    method delete_item (line 527) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 576) | public function delete_item_permissions_check( $request ) {
    method get_current_user_groups (line 625) | public function get_current_user_groups( $request ) {
    method get_current_user_groups_permissions_check (line 699) | public function get_current_user_groups_permissions_check( $request ) {
    method prepare_item_for_response (line 732) | public function prepare_item_for_response( $item, $request ) {
    method prepare_item_for_database (line 857) | protected function prepare_item_for_database( $request ) {
    method prepare_links (line 965) | protected function prepare_links( $group ) {
    method can_user_delete_or_update (line 1072) | protected function can_user_delete_or_update( $group ) {
    method can_see (line 1084) | public function can_see( $group ) {
    method can_see_hidden_groups (line 1102) | protected function can_see_hidden_groups( $request ) {
    method get_group_object (line 1122) | public function get_group_object( $request ) {
    method get_endpoint_args_for_item_schema (line 1150) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 1211) | public function get_item_schema() {
    method get_collection_params (line 1422) | public function get_collection_params() {

FILE: includes/bp-members/classes/class-bp-rest-attachments-member-avatar-endpoint.php
  class BP_REST_Attachments_Member_Avatar_Endpoint (line 16) | class BP_REST_Attachments_Member_Avatar_Endpoint extends WP_REST_Control...
    method __construct (line 51) | public function __construct() {
    method register_routes (line 64) | public function register_routes() {
    method get_item (line 104) | public function get_item( $request ) {
    method get_item_permissions_check (line 163) | public function get_item_permissions_check( $request ) {
    method create_item (line 206) | public function create_item( $request ) {
    method create_item_permissions_check (line 258) | public function create_item_permissions_check( $request ) {
    method delete_item (line 322) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 399) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 422) | public function prepare_item_for_response( $avatar, $request ) {
    method get_item_schema (line 452) | public function get_item_schema() {
    method get_item_collection_params (line 492) | public function get_item_collection_params() {

FILE: includes/bp-members/classes/class-bp-rest-attachments-member-cover-endpoint.php
  class BP_REST_Attachments_Member_Cover_Endpoint (line 18) | class BP_REST_Attachments_Member_Cover_Endpoint extends WP_REST_Controll...
    method __construct (line 53) | public function __construct() {
    method register_routes (line 66) | public function register_routes() {
    method get_item (line 105) | public function get_item( $request ) {
    method get_item_permissions_check (line 153) | public function get_item_permissions_check( $request ) {
    method create_item (line 196) | public function create_item( $request ) {
    method create_item_permissions_check (line 248) | public function create_item_permissions_check( $request ) {
    method delete_item (line 280) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 337) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 394) | public function prepare_item_for_response( $cover_url, $request ) {
    method get_item_schema (line 424) | public function get_item_schema() {

FILE: includes/bp-members/classes/class-bp-rest-members-endpoint.php
  class BP_REST_Members_Endpoint (line 19) | class BP_REST_Members_Endpoint extends WP_REST_Users_Controller {
    method __construct (line 26) | public function __construct() {
    method register_routes (line 40) | public function register_routes() {
    method get_items (line 107) | public function get_items( $request ) {
    method get_items_permissions_check (line 205) | public function get_items_permissions_check( $request ) {
    method get_item (line 237) | public function get_item( $request ) {
    method get_item_permissions_check (line 265) | public function get_item_permissions_check( $request ) {
    method create_item_permissions_check (line 321) | public function create_item_permissions_check( $request ) {
    method update_item_permissions_check (line 343) | public function update_item_permissions_check( $request ) {
    method delete_item_permissions_check (line 409) | public function delete_item_permissions_check( $request ) {
    method delete_current_item_permissions_check (line 432) | public function delete_current_item_permissions_check( $request ) {
    method delete_current_item (line 465) | public function delete_current_item( $request ) {
    method prepare_item_for_response (line 514) | public function prepare_item_for_response( $user, $request ) {
    method prepare_links (line 549) | protected function prepare_links( $user, $user_data = array() ) {
    method user_data (line 629) | public function user_data( $user, $context, $request ) {
    method prepare_item_for_database (line 786) | protected function prepare_item_for_database( $request ) {
    method xprofile_data (line 831) | protected function xprofile_data( $user_id ) {
    method can_manage_member (line 880) | protected function can_manage_member( $user, $action = 'delete' ) {
    method update_additional_fields_for_object (line 902) | protected function update_additional_fields_for_object( $user, $reques...
    method get_endpoint_args_for_item_schema (line 924) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 988) | public function get_item_schema() {
    method get_collection_params (line 1218) | public function get_collection_params() {

FILE: includes/bp-members/classes/class-bp-rest-signup-endpoint.php
  class BP_REST_Signup_Endpoint (line 21) | class BP_REST_Signup_Endpoint extends WP_REST_Controller {
    method __construct (line 28) | public function __construct() {
    method register_routes (line 40) | public function register_routes() {
    method get_items (line 142) | public function get_items( $request ) {
    method get_items_permissions_check (line 201) | public function get_items_permissions_check( $request ) {
    method get_item (line 239) | public function get_item( $request ) {
    method get_item_permissions_check (line 272) | public function get_item_permissions_check( $request ) {
    method create_item (line 322) | public function create_item( $request ) {
    method create_item_permissions_check (line 612) | public function create_item_permissions_check( $request ) {
    method delete_item (line 633) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 682) | public function delete_item_permissions_check( $request ) {
    method activate_item (line 704) | public function activate_item( $request ) {
    method activate_item_permissions_check (line 754) | public function activate_item_permissions_check( $request ) {
    method signup_resend_activation_email (line 790) | public function signup_resend_activation_email( $request ) {
    method signup_resend_activation_email_permissions_check (line 829) | public function signup_resend_activation_email_permissions_check( $req...
    method prepare_item_for_response (line 863) | public function prepare_item_for_response( $signup, $request ) {
    method prepare_links (line 931) | protected function prepare_links( $signup ) {
    method get_signup_object (line 973) | public function get_signup_object( $identifier ) {
    method check_user_password (line 1001) | public function check_user_password( $value ) {
    method is_blog_signup_allowed (line 1022) | public function is_blog_signup_allowed() {
    method get_available_languages (line 1035) | public function get_available_languages() {
    method get_endpoint_args_for_item_schema (line 1049) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 1138) | public function get_item_schema() {
    method get_collection_params (line 1271) | public function get_collection_params() {

FILE: includes/bp-messages/classes/class-bp-rest-messages-endpoint.php
  class BP_REST_Messages_Endpoint (line 20) | class BP_REST_Messages_Endpoint extends WP_REST_Controller {
    method __construct (line 27) | public function __construct() {
    method register_routes (line 39) | public function register_routes() {
    method get_items (line 117) | public function get_items( $request ) {
    method get_items_permissions_check (line 186) | public function get_items_permissions_check( $request ) {
    method get_item (line 238) | public function get_item( $request ) {
    method get_item_permissions_check (line 297) | public function get_item_permissions_check( $request ) {
    method create_item (line 349) | public function create_item( $request ) {
    method create_item_permissions_check (line 407) | public function create_item_permissions_check( $request ) {
    method update_item (line 457) | public function update_item( $request ) {
    method update_item_permissions_check (line 565) | public function update_item_permissions_check( $request ) {
    method update_starred (line 587) | public function update_starred( $request ) {
    method update_starred_permissions_check (line 650) | public function update_starred_permissions_check( $request ) {
    method delete_item (line 702) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 768) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_database (line 790) | protected function prepare_item_for_database( $request ) {
    method prepare_message_for_response (line 847) | public function prepare_message_for_response( $message, $request ) {
    method prepare_recipient_for_response (line 898) | public function prepare_recipient_for_response( $recipient, $request ) {
    method prepare_item_for_response (line 951) | public function prepare_item_for_response( $thread, $request ) {
    method prepare_links (line 1022) | protected function prepare_links( $thread ) {
    method get_thread_object (line 1066) | public function get_thread_object( $thread_id, $user_id = 0 ) {
    method get_message_object (line 1090) | public function get_message_object( $message_id ) {
    method get_endpoint_args_for_item_schema (line 1108) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 1274) | public function get_item_schema() {
    method get_collection_params (line 1444) | public function get_collection_params() {

FILE: includes/bp-messages/classes/class-bp-rest-sitewide-notices-endpoint.php
  class BP_REST_Sitewide_Notices_Endpoint (line 16) | class BP_REST_Sitewide_Notices_Endpoint extends WP_REST_Controller {
    method __construct (line 23) | public function __construct() {
    method register_routes (line 35) | public function register_routes() {
    method get_items (line 110) | public function get_items( $request ) {
    method get_items_permissions_check (line 188) | public function get_items_permissions_check( $request ) {
    method get_item (line 225) | public function get_item( $request ) {
    method get_item_permissions_check (line 253) | public function get_item_permissions_check( $request ) {
    method create_item (line 305) | public function create_item( $request ) {
    method create_item_permissions_check (line 356) | public function create_item_permissions_check( $request ) {
    method update_item (line 378) | public function update_item( $request ) {
    method update_item_permissions_check (line 436) | public function update_item_permissions_check( $request ) {
    method dismiss_notice (line 458) | public function dismiss_notice( $request ) {
    method dismiss_notice_permissions_check (line 509) | public function dismiss_notice_permissions_check( $request ) {
    method delete_item (line 541) | public function delete_item( $request ) {
    method manage_item_permissions_check (line 603) | public function manage_item_permissions_check( $request ) {
    method delete_item_permissions_check (line 635) | public function delete_item_permissions_check( $request ) {
    method prepare_links (line 657) | protected function prepare_links( $notice ) {
    method prepare_item_for_response (line 690) | public function prepare_item_for_response( $notice, $request ) {
    method get_notice_object (line 734) | public function get_notice_object( $id ) {
    method get_endpoint_args_for_item_schema (line 752) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 810) | public function get_item_schema() {
    method get_collection_params (line 910) | public function get_collection_params() {
    method prepare_item_for_database (line 932) | protected function prepare_item_for_database( $request ) {

FILE: includes/bp-notifications/classes/class-bp-rest-notifications-endpoint.php
  class BP_REST_Notifications_Endpoint (line 16) | class BP_REST_Notifications_Endpoint extends WP_REST_Controller {
    method __construct (line 23) | public function __construct() {
    method register_routes (line 35) | public function register_routes() {
    method get_items (line 102) | public function get_items( $request ) {
    method get_items_permissions_check (line 175) | public function get_items_permissions_check( $request ) {
    method get_item (line 205) | public function get_item( $request ) {
    method get_item_permissions_check (line 237) | public function get_item_permissions_check( $request ) {
    method create_item (line 289) | public function create_item( $request ) {
    method create_item_permissions_check (line 342) | public function create_item_permissions_check( $request ) {
    method update_item (line 364) | public function update_item( $request ) {
    method update_item_permissions_check (line 436) | public function update_item_permissions_check( $request ) {
    method delete_item (line 458) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 507) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 530) | public function prepare_item_for_response( $notification, $request ) {
    method prepare_item_for_database (line 571) | protected function prepare_item_for_database( $request ) {
    method prepare_links (line 643) | protected function prepare_links( $notification ) {
    method can_see (line 728) | protected function can_see( $notification_id = 0 ) {
    method get_notification_object (line 747) | public function get_notification_object( $request ) {
    method get_endpoint_args_for_item_schema (line 767) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 801) | public function get_item_schema() {
    method get_collection_params (line 879) | public function get_collection_params() {

FILE: includes/bp-xprofile/classes/class-bp-rest-xprofile-data-endpoint.php
  class BP_REST_XProfile_Data_Endpoint (line 18) | class BP_REST_XProfile_Data_Endpoint extends WP_REST_Controller {
    method __construct (line 34) | public function __construct() {
    method register_routes (line 47) | public function register_routes() {
    method get_item (line 100) | public function get_item( $request ) {
    method get_item_permissions_check (line 134) | public function get_item_permissions_check( $request ) {
    method update_item (line 204) | public function update_item( $request ) {
    method update_item_permissions_check (line 285) | public function update_item_permissions_check( $request ) {
    method delete_item (line 337) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 406) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 429) | public function prepare_item_for_response( $field_data, $request ) {
    method prepare_links (line 471) | protected function prepare_links( $field_data ) {
    method get_xprofile_field_object (line 507) | public function get_xprofile_field_object( $field_id ) {
    method get_xprofile_field_data_object (line 520) | public function get_xprofile_field_data_object( $field_id, $user_id ) {
    method can_see (line 532) | protected function can_see( $field_user_id ) {
    method get_item_schema (line 543) | public function get_item_schema() {

FILE: includes/bp-xprofile/classes/class-bp-rest-xprofile-field-groups-endpoint.php
  class BP_REST_XProfile_Field_Groups_Endpoint (line 19) | class BP_REST_XProfile_Field_Groups_Endpoint extends WP_REST_Controller {
    method __construct (line 35) | public function __construct() {
    method register_routes (line 48) | public function register_routes() {
    method get_endpoint_args_for_item_schema (line 108) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_items (line 144) | public function get_items( $request ) {
    method get_items_permissions_check (line 226) | public function get_items_permissions_check( $request ) {
    method get_item (line 258) | public function get_item( $request ) {
    method get_item_permissions_check (line 301) | public function get_item_permissions_check( $request ) {
    method create_item (line 333) | public function create_item( $request ) {
    method create_item_permissions_check (line 413) | public function create_item_permissions_check( $request ) {
    method update_item (line 445) | public function update_item( $request ) {
    method update_item_permissions_check (line 523) | public function update_item_permissions_check( $request ) {
    method delete_item (line 545) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 604) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 627) | public function prepare_item_for_response( $group, $request ) {
    method prepare_links (line 675) | protected function prepare_links( $group ) {
    method get_xprofile_field_group_object (line 707) | public function get_xprofile_field_group_object( $request ) {
    method get_item_schema (line 750) | public function get_item_schema() {
    method get_collection_params (line 829) | public function get_collection_params() {

FILE: includes/bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php
  class BP_REST_XProfile_Fields_Endpoint (line 19) | class BP_REST_XProfile_Fields_Endpoint extends WP_REST_Controller {
    method __construct (line 26) | public function __construct() {
    method register_routes (line 38) | public function register_routes() {
    method get_items (line 123) | public function get_items( $request ) {
    method get_items_permissions_check (line 199) | public function get_items_permissions_check( $request ) {
    method get_item (line 231) | public function get_item( $request ) {
    method get_item_permissions_check (line 288) | public function get_item_permissions_check( $request ) {
    method set_additional_field_properties (line 320) | public function set_additional_field_properties( $field_id, WP_REST_Re...
    method create_item (line 373) | public function create_item( $request ) {
    method create_item_permissions_check (line 454) | public function create_item_permissions_check( $request ) {
    method update_item (line 486) | public function update_item( $request ) {
    method update_item_permissions_check (line 585) | public function update_item_permissions_check( $request ) {
    method delete_item (line 607) | public function delete_item( $request ) {
    method delete_item_permissions_check (line 656) | public function delete_item_permissions_check( $request ) {
    method prepare_item_for_response (line 701) | public function prepare_item_for_response( $field, $request ) {
    method assemble_response_data (line 728) | public function assemble_response_data( $field, $request ) {
    method prepare_links (line 792) | protected function prepare_links( $field ) {
    method get_xprofile_field_object (line 829) | public function get_xprofile_field_object( $request ) {
    method get_profile_field_rendered_value (line 856) | public function get_profile_field_rendered_value( $value = '', $profil...
    method get_profile_field_unserialized_value (line 901) | public function get_profile_field_unserialized_value( $value = '' ) {
    method get_endpoint_args_for_item_schema (line 922) | public function get_endpoint_args_for_item_schema( $method = WP_REST_S...
    method get_item_schema (line 995) | public function get_item_schema() {
    method get_collection_params (line 1147) | public function get_collection_params() {

FILE: tests/bootstrap.php
  function _manually_load_plugins (line 28) | function _manually_load_plugins() {
  function toggle_component_visibility (line 50) | function toggle_component_visibility( $visibility = true ) {

FILE: tests/testcases/activity/test-controller.php
  class BP_Test_REST_Activity_Endpoint (line 9) | class BP_Test_REST_Activity_Endpoint extends WP_Test_REST_Controller_Tes...
    method set_up (line 17) | public function set_up() {
    method test_register_routes (line 34) | public function test_register_routes() {
    method test_get_items (line 49) | public function test_get_items() {
    method test_get_items_with_support_for_the_community_visibility (line 69) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_items_multiple_types (line 84) | public function test_get_items_multiple_types() {
    method test_get_items_with_invalid_type (line 117) | public function test_get_items_with_invalid_type() {
    method test_get_public_groups_items (line 133) | public function test_get_public_groups_items() {
    method test_get_items_from_a_specific_group (line 180) | public function test_get_items_from_a_specific_group() {
    method test_get_private_group_items (line 235) | public function test_get_private_group_items() {
    method test_get_private_group_items_without_access (line 286) | public function test_get_private_group_items_without_access() {
    method test_get_private_group_items_with_the_group_id_param (line 325) | public function test_get_private_group_items_with_the_group_id_param() {
    method test_get_private_group_items_for_mod (line 375) | public function test_get_private_group_items_for_mod() {
    method test_get_private_group_items_for_admin (line 417) | public function test_get_private_group_items_for_admin() {
    method test_get_private_group_items_with_group_id_param_without_access (line 459) | public function test_get_private_group_items_with_group_id_param_witho...
    method test_get_paginated_items (line 497) | public function test_get_paginated_items() {
    method test_get_items_with_the_groups_scope (line 526) | public function test_get_items_with_the_groups_scope() {
    method test_get_items_with_favorite (line 571) | public function test_get_items_with_favorite() {
    method test_get_items_with_no_favorite (line 596) | public function test_get_items_with_no_favorite() {
    method test_get_item (line 618) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 639) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_embedded_hidden_group_from_activity (line 655) | public function test_get_embedded_hidden_group_from_activity() {
    method test_get_embedded_hidden_group_from_activity_without_permission (line 689) | public function test_get_embedded_hidden_group_from_activity_without_p...
    method test_get_embedded_private_group_from_activity_without_permission (line 718) | public function test_get_embedded_private_group_from_activity_without_...
    method test_get_item_for_item_belonging_to_private_group (line 747) | public function test_get_item_for_item_belonging_to_private_group() {
    method test_render_item (line 793) | public function test_render_item() {
    method test_render_item_with_embed_post (line 816) | public function test_render_item_with_embed_post() {
    method test_create_item (line 840) | public function test_create_item() {
    method test_rest_create_item (line 857) | public function test_rest_create_item() {
    method test_create_item_with_no_content (line 874) | public function test_create_item_with_no_content() {
    method test_create_item_user_not_logged_in (line 891) | public function test_create_item_user_not_logged_in() {
    method test_create_item_in_a_group (line 906) | public function test_create_item_in_a_group() {
    method test_create_item_in_a_private_group (line 930) | public function test_create_item_in_a_private_group() {
    method test_create_item_in_an_hidden_group (line 955) | public function test_create_item_in_an_hidden_group() {
    method test_create_item_and_get_comment (line 980) | public function test_create_item_and_get_comment() {
    method test_create_item_and_get_reply (line 1029) | public function test_create_item_and_get_reply() {
    method test_create_item_and_get_comment_in_a_group (line 1085) | public function test_create_item_and_get_comment_in_a_group() {
    method test_create_item_with_no_content_in_a_group (line 1138) | public function test_create_item_with_no_content_in_a_group() {
    method test_create_blog_post_item (line 1163) | public function test_create_blog_post_item() {
    method test_update_item (line 1203) | public function test_update_item() {
    method test_update_item_but_keep_date_the_same (line 1234) | public function test_update_item_but_keep_date_the_same() {
    method test_update_item_posted_in_a_group (line 1259) | public function test_update_item_posted_in_a_group() {
    method test_update_item_invalid_id (line 1311) | public function test_update_item_invalid_id() {
    method test_update_item_user_not_logged_in (line 1326) | public function test_update_item_user_not_logged_in() {
    method test_update_item_without_permission (line 1343) | public function test_update_item_without_permission() {
    method test_update_item_without_content (line 1366) | public function test_update_item_without_content() {
    method test_update_item_without_type (line 1388) | public function test_update_item_without_type() {
    method test_delete_item (line 1413) | public function test_delete_item() {
    method test_delete_item_invalid_id (line 1439) | public function test_delete_item_invalid_id() {
    method test_delete_item_user_not_logged_in (line 1451) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 1464) | public function test_delete_item_without_permission() {
    method test_update_favorite (line 1483) | public function test_update_favorite() {
    method test_update_favorite_remove (line 1505) | public function test_update_favorite_remove() {
    method test_update_favorite_when_disabled (line 1528) | public function test_update_favorite_when_disabled() {
    method test_prepare_item (line 1547) | public function test_prepare_item() {
    method test_additional_fields (line 1568) | public function test_additional_fields() {
    method test_update_additional_fields (line 1609) | public function test_update_additional_fields() {
    method check_activity_data (line 1641) | protected function check_activity_data( $activity, $data, $context ) {
    method check_add_edit_activity (line 1666) | protected function check_add_edit_activity( $response, $update = false...
    method set_activity_data (line 1678) | protected function set_activity_data( $args = array() ) {
    method check_update_activity_response (line 1686) | protected function check_update_activity_response( $response ) {
    method check_create_activity_response (line 1701) | protected function check_create_activity_response( $response ) {
    method test_get_item_schema (line 1713) | public function test_get_item_schema() {
    method test_context_param (line 1739) | public function test_context_param() {
    method update_additional_field (line 1757) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 1761) | public function get_additional_field( $data, $attribute )  {

FILE: tests/testcases/attachments/test-blog-avatar-controller.php
  class BP_Test_REST_Attachments_Blog_Avatar_Endpoint (line 9) | class BP_Test_REST_Attachments_Blog_Avatar_Endpoint extends WP_Test_REST...
    method set_up (line 15) | public function set_up() {
    method test_register_routes (line 26) | public function test_register_routes() {
    method test_get_items (line 38) | public function test_get_items() {
    method test_get_item (line 45) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 70) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_site_icon (line 86) | public function test_get_item_site_icon() {
    method test_get_item_no_grav (line 113) | public function test_get_item_no_grav() {
    method test_get_item_invalid_user_id (line 139) | public function test_get_item_invalid_user_id() {
    method filter_admin_user_id (line 163) | public function filter_admin_user_id( $blog_results ) {
    method test_get_item_invalid_blog_id (line 172) | public function test_get_item_invalid_blog_id() {
    method test_create_item (line 183) | public function test_create_item() {
    method test_update_item (line 190) | public function test_update_item() {
    method test_delete_item (line 197) | public function test_delete_item() {
    method test_prepare_item (line 204) | public function test_prepare_item() {
    method test_get_item_schema (line 208) | public function test_get_item_schema() {
    method test_context_param (line 224) | public function test_context_param() {

FILE: tests/testcases/attachments/test-group-avatar-controller.php
  class BP_Test_REST_Attachments_Group_Avatar_Endpoint (line 9) | class BP_Test_REST_Attachments_Group_Avatar_Endpoint extends WP_Test_RES...
    method set_up (line 18) | public function set_up() {
    method test_register_routes (line 41) | public function test_register_routes() {
    method test_get_items (line 53) | public function test_get_items() {
    method test_get_item (line 60) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 78) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_invalid_group_id (line 91) | public function test_get_item_invalid_group_id() {
    method test_get_item_with_no_image (line 100) | public function test_get_item_with_no_image() {
    method test_create_item (line 114) | public function test_create_item() {
    method copy_file (line 170) | public function copy_file( $return, $file, $new_file ) {
    method return_100 (line 174) | public function return_100() {
    method test_create_item_with_image_upload_disabled (line 181) | public function test_create_item_with_image_upload_disabled() {
    method test_create_item_empty_image (line 217) | public function test_create_item_empty_image() {
    method test_create_item_user_not_logged_in (line 228) | public function test_create_item_user_not_logged_in() {
    method test_create_item_invalid_group (line 237) | public function test_create_item_invalid_group() {
    method test_update_item (line 250) | public function test_update_item() {
    method test_delete_item (line 257) | public function test_delete_item() {
    method test_delete_item_failed (line 264) | public function test_delete_item_failed() {
    method test_delete_item_user_not_logged_in (line 276) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_invalid_group (line 285) | public function test_delete_item_invalid_group() {
    method test_prepare_item (line 296) | public function test_prepare_item() {
    method test_get_item_schema (line 300) | public function test_get_item_schema() {
    method test_context_param (line 311) | public function test_context_param() {

FILE: tests/testcases/attachments/test-group-cover-controller.php
  class BP_Test_REST_Attachments_Group_Cover_Endpoint (line 9) | class BP_Test_REST_Attachments_Group_Cover_Endpoint extends WP_Test_REST...
    method set_up (line 18) | public function set_up() {
    method test_register_routes (line 41) | public function test_register_routes() {
    method test_get_items (line 53) | public function test_get_items() {
    method test_get_item (line 60) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 67) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_with_no_image (line 80) | public function test_get_item_with_no_image() {
    method test_get_item_invalid_group_id (line 90) | public function test_get_item_invalid_group_id() {
    method test_create_item (line 99) | public function test_create_item() {
    method test_create_item_no_valid_image_directory (line 106) | public function test_create_item_no_valid_image_directory() {
    method test_create_item_image_upload_disabled (line 134) | public function test_create_item_image_upload_disabled() {
    method test_create_item_empty_image (line 165) | public function test_create_item_empty_image() {
    method test_create_item_user_not_logged_in (line 176) | public function test_create_item_user_not_logged_in() {
    method test_create_item_unauthorized_user (line 185) | public function test_create_item_unauthorized_user() {
    method test_create_item_invalid_group_id (line 198) | public function test_create_item_invalid_group_id() {
    method test_update_item (line 209) | public function test_update_item() {
    method test_delete_item (line 216) | public function test_delete_item() {
    method test_delete_item_user_not_logged_in (line 223) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_unauthorized_user (line 232) | public function test_delete_item_unauthorized_user() {
    method test_delete_item_invalid_group_id (line 245) | public function test_delete_item_invalid_group_id() {
    method test_delete_item_failed (line 256) | public function test_delete_item_failed() {
    method test_prepare_item (line 268) | public function test_prepare_item() {
    method test_get_item_schema (line 272) | public function test_get_item_schema() {
    method test_context_param (line 282) | public function test_context_param() {

FILE: tests/testcases/attachments/test-member-avatar-controller.php
  class BP_Test_REST_Attachments_Member_Avatar_Endpoint (line 9) | class BP_Test_REST_Attachments_Member_Avatar_Endpoint extends WP_Test_RE...
    method set_up (line 17) | public function set_up() {
    method test_register_routes (line 34) | public function test_register_routes() {
    method test_get_items (line 46) | public function test_get_items() {
    method test_get_item (line 53) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 73) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_publicly (line 86) | public function test_get_item_publicly() {
    method test_get_item_invalid_member_id (line 102) | public function test_get_item_invalid_member_id() {
    method test_create_item (line 111) | public function test_create_item() {
    method copy_file (line 170) | public function copy_file( $return, $file, $new_file ) {
    method return_100 (line 174) | public function return_100() {
    method test_create_item_with_upload_disabled (line 181) | public function test_create_item_with_upload_disabled() {
    method test_create_item_empty_image (line 195) | public function test_create_item_empty_image() {
    method test_create_item_user_not_logged_in (line 206) | public function test_create_item_user_not_logged_in() {
    method test_create_item_invalid_member_id (line 215) | public function test_create_item_invalid_member_id() {
    method test_update_item (line 228) | public function test_update_item() {
    method test_delete_item (line 235) | public function test_delete_item() {
    method test_delete_item_failed (line 242) | public function test_delete_item_failed() {
    method test_delete_item_user_not_logged_in (line 254) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_invalid_member_id (line 263) | public function test_delete_item_invalid_member_id() {
    method test_prepare_item (line 272) | public function test_prepare_item() {
    method test_get_item_schema (line 276) | public function test_get_item_schema() {
    method test_context_param (line 287) | public function test_context_param() {

FILE: tests/testcases/attachments/test-member-cover-controller.php
  class BP_Test_REST_Attachments_Member_Cover_Endpoint (line 9) | class BP_Test_REST_Attachments_Member_Cover_Endpoint extends WP_Test_RES...
    method set_up (line 16) | public function set_up() {
    method test_register_routes (line 32) | public function test_register_routes() {
    method test_get_items (line 44) | public function test_get_items() {
    method test_get_item (line 51) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 58) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_with_no_image (line 71) | public function test_get_item_with_no_image() {
    method test_get_item_invalid_member_id (line 80) | public function test_get_item_invalid_member_id() {
    method test_create_item (line 89) | public function test_create_item() {
    method test_create_item_with_upload_disabled (line 96) | public function test_create_item_with_upload_disabled() {
    method test_create_item_empty_image (line 112) | public function test_create_item_empty_image() {
    method test_create_item_user_not_logged_in (line 123) | public function test_create_item_user_not_logged_in() {
    method test_create_item_unauthorized_user (line 132) | public function test_create_item_unauthorized_user() {
    method test_create_item_invalid_member_id (line 145) | public function test_create_item_invalid_member_id() {
    method test_update_item (line 156) | public function test_update_item() {
    method test_delete_item (line 163) | public function test_delete_item() {
    method test_delete_item_user_not_logged_in (line 170) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_unauthorized_user (line 179) | public function test_delete_item_unauthorized_user() {
    method test_delete_item_invalid_member_id (line 192) | public function test_delete_item_invalid_member_id() {
    method test_delete_item_failed (line 203) | public function test_delete_item_failed() {
    method test_prepare_item (line 215) | public function test_prepare_item() {
    method test_get_item_schema (line 219) | public function test_get_item_schema() {
    method test_context_param (line 229) | public function test_context_param() {

FILE: tests/testcases/blogs/test-controller.php
  class BP_Test_REST_Blogs_Endpoint (line 9) | class BP_Test_REST_Blogs_Endpoint extends WP_Test_REST_Controller_Testca...
    method set_up (line 16) | public function set_up() {
    method test_register_routes (line 31) | public function test_register_routes() {
    method test_get_items (line 46) | public function test_get_items() {
    method test_get_item (line 71) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 97) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_invalid_blog_id (line 117) | public function test_get_item_invalid_blog_id() {
    method test_get_embedded_latest_post_from_blog_using_subdirectory (line 129) | public function test_get_embedded_latest_post_from_blog_using_subdirec...
    method test_get_embedded_latest_post_from_blog_using_subdomain (line 174) | public function test_get_embedded_latest_post_from_blog_using_subdomai...
    method test_create_item (line 221) | public function test_create_item() {
    method test_create_item_user_not_logged_in (line 255) | public function test_create_item_user_not_logged_in() {
    method test_create_item_signup_disabled (line 272) | public function test_create_item_signup_disabled() {
    method test_create_item_without_required_field (line 302) | public function test_create_item_without_required_field() {
    method test_update_item (line 325) | public function test_update_item() {
    method test_delete_item (line 332) | public function test_delete_item() {
    method test_prepare_item (line 339) | public function test_prepare_item() {
    method set_blog_data (line 343) | protected function set_blog_data( $args = array() ) {
    method get_additional_field (line 357) | public function get_additional_field( $data, $attribute )  {
    method test_get_additional_fields (line 364) | public function test_get_additional_fields() {
    method test_get_item_schema (line 408) | public function test_get_item_schema() {
    method test_context_param (line 427) | public function test_context_param() {

FILE: tests/testcases/components/test-controller.php
  class BP_Test_REST_Components_Endpoint (line 9) | class BP_Test_REST_Components_Endpoint extends WP_Test_REST_Controller_T...
    method set_up (line 16) | public function set_up() {
    method test_register_routes (line 32) | public function test_register_routes() {
    method test_get_items (line 43) | public function test_get_items() {
    method test_get_items_paginated (line 64) | public function test_get_items_paginated() {
    method test_get_items_invalid_status (line 90) | public function test_get_items_invalid_status() {
    method test_get_items_user_is_not_logged_in (line 107) | public function test_get_items_user_is_not_logged_in() {
    method test_get_items_without_permission (line 117) | public function test_get_items_without_permission() {
    method test_get_items_active_permission (line 132) | public function test_get_items_active_permission() {
    method test_get_items_active_component_features (line 156) | public function test_get_items_active_component_features() {
    method test_get_items_inactive_component_features (line 177) | public function test_get_items_inactive_component_features() {
    method deactivate_activity_component (line 199) | public function deactivate_activity_component( $retval, $component ) {
    method test_get_items_inactive_component (line 210) | public function test_get_items_inactive_component() {
    method test_get_item (line 236) | public function test_get_item() {
    method test_create_item (line 243) | public function test_create_item() {
    method test_update_item (line 250) | public function test_update_item() {
    method test_update_item_nonexistent_component (line 271) | public function test_update_item_nonexistent_component() {
    method test_update_item_empty_action (line 287) | public function test_update_item_empty_action() {
    method test_update_item_invalid_action (line 303) | public function test_update_item_invalid_action() {
    method test_update_item_user_is_not_logged_in (line 319) | public function test_update_item_user_is_not_logged_in() {
    method test_update_item_without_permission (line 333) | public function test_update_item_without_permission() {
    method test_delete_item (line 351) | public function test_delete_item() {
    method test_prepare_item (line 355) | public function test_prepare_item() {
    method check_component_data (line 359) | protected function check_component_data( $component, $data ) {
    method test_get_item_schema (line 366) | public function test_get_item_schema() {
    method test_context_param (line 379) | public function test_context_param() {

FILE: tests/testcases/friends/test-controller.php
  class BP_Test_REST_Friends_Endpoint (line 9) | class BP_Test_REST_Friends_Endpoint extends WP_Test_REST_Controller_Test...
    method set_up (line 18) | public function set_up() {
    method test_register_routes (line 40) | public function test_register_routes() {
    method test_get_items (line 55) | public function test_get_items() {
    method test_get_items_user_not_logged_in (line 85) | public function test_get_items_user_not_logged_in() {
    method test_get_item (line 95) | public function test_get_item() {
    method test_get_item_with_invalid_friend_id (line 115) | public function test_get_item_with_invalid_friend_id() {
    method test_get_item_user_not_logged_in (line 127) | public function test_get_item_user_not_logged_in() {
    method test_create_item (line 138) | public function test_create_item() {
    method test_create_item_to_myself_from_someone_else (line 163) | public function test_create_item_to_myself_from_someone_else() {
    method test_admins_create_item_to_myself_from_someone_else (line 186) | public function test_admins_create_item_to_myself_from_someone_else() {
    method test_create_item_already_friends (line 208) | public function test_create_item_already_friends() {
    method test_create_item_user_not_logged_in (line 231) | public function test_create_item_user_not_logged_in() {
    method test_regular_user_can_not_create_friendship_to_others (line 245) | public function test_regular_user_can_not_create_friendship_to_others() {
    method test_admins_can_create_friendship_to_others (line 261) | public function test_admins_can_create_friendship_to_others() {
    method test_admins_can_force_friendship_creation (line 281) | public function test_admins_can_force_friendship_creation() {
    method test_regular_users_can_not_force_friendship_creation (line 303) | public function test_regular_users_can_not_force_friendship_creation() {
    method test_create_item_without_initiator_id (line 330) | public function test_create_item_without_initiator_id() {
    method test_create_item_without_friend_id (line 345) | public function test_create_item_without_friend_id() {
    method test_update_item (line 356) | public function test_update_item() {
    method test_initiator_can_not_accept_its_own_friendship_request (line 375) | public function test_initiator_can_not_accept_its_own_friendship_reque...
    method test_update_item_invalid_friend_id (line 389) | public function test_update_item_invalid_friend_id() {
    method test_update_item_user_not_logged_in (line 401) | public function test_update_item_user_not_logged_in() {
    method test_delete_item (line 411) | public function test_delete_item() {
    method test_delete_item_using_the_initiator (line 430) | public function test_delete_item_using_the_initiator() {
    method test_reject_and_remove_item_from_database (line 449) | public function test_reject_and_remove_item_from_database() {
    method test_reject_and_remove_item_from_database_using_initiator (line 469) | public function test_reject_and_remove_item_from_database_using_initia...
    method test_reject_and_remove_item_from_database_using_initiator_and_testing_force (line 489) | public function test_reject_and_remove_item_from_database_using_initia...
    method test_reject_friendship_request (line 509) | public function test_reject_friendship_request() {
    method test_reject_friendship_with_invalid_friendship_id (line 528) | public function test_reject_friendship_with_invalid_friendship_id() {
    method test_reject_friendship_with_user_not_logged_in (line 542) | public function test_reject_friendship_with_user_not_logged_in() {
    method test_prepare_item (line 552) | public function test_prepare_item() {
    method test_get_item_schema (line 569) | public function test_get_item_schema() {
    method test_context_param (line 584) | public function test_context_param() {
    method set_friendship_data (line 602) | protected function set_friendship_data( $args = array() ) {
    method create_friendship (line 612) | protected function create_friendship( $u = 0 ) {
    method check_friendship_data (line 628) | protected function check_friendship_data( $friend, $data ) {

FILE: tests/testcases/groups/test-controller.php
  class BP_Test_REST_Group_Endpoint (line 9) | class BP_Test_REST_Group_Endpoint extends WP_Test_REST_Controller_Testca...
    method set_up (line 17) | public function set_up() {
    method test_register_routes (line 39) | public function test_register_routes() {
    method test_get_items (line 54) | public function test_get_items() {
    method test_get_items_with_support_for_the_community_visibility (line 71) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_items_including_hidden_groups (line 86) | public function test_get_items_including_hidden_groups() {
    method test_get_items_including_private_groups (line 121) | public function test_get_items_including_private_groups() {
    method test_get_items_not_including_hidden_groups_when_not_using_user_id_param (line 158) | public function test_get_items_not_including_hidden_groups_when_not_us...
    method test_get_paginated_items (line 188) | public function test_get_paginated_items() {
    method test_get_items_edit_context (line 244) | public function test_get_items_edit_context() {
    method test_get_items_edit_context_users_private_data (line 269) | public function test_get_items_edit_context_users_private_data() {
    method test_get_items_extra (line 297) | public function test_get_items_extra() {
    method test_get_items_with_group_types (line 345) | public function test_get_items_with_group_types() {
    method test_get_item (line 380) | public function test_get_item() {
    method test_get_item_unauthenticated_with_support_for_the_community_visibility (line 400) | public function test_get_item_unauthenticated_with_support_for_the_com...
    method test_get_item_unauthenticated (line 415) | public function test_get_item_unauthenticated() {
    method test_get_item_invalid_group_id (line 432) | public function test_get_item_invalid_group_id() {
    method test_get_hidden_group (line 444) | public function test_get_hidden_group() {
    method test_get_hidden_group_without_being_from_group (line 469) | public function test_get_hidden_group_without_being_from_group() {
    method test_get_item_with_avatar (line 490) | public function test_get_item_with_avatar() {
    method test_get_item_without_avatar (line 510) | public function test_get_item_without_avatar() {
    method test_get_item_extra (line 532) | public function test_get_item_extra() {
    method test_render_item (line 556) | public function test_render_item() {
    method test_create_item (line 577) | public function test_create_item() {
    method test_rest_create_item (line 594) | public function test_rest_create_item() {
    method test_create_item_with_group_type (line 611) | public function test_create_item_with_group_type() {
    method test_create_item_with_no_name (line 630) | public function test_create_item_with_no_name() {
    method test_create_item_user_not_logged_in (line 647) | public function test_create_item_user_not_logged_in() {
    method test_create_item_invalid_status (line 662) | public function test_create_item_invalid_status() {
    method test_update_item (line 677) | public function test_update_item() {
    method test_update_group_type (line 706) | public function test_update_group_type() {
    method test_remove_group_type (line 728) | public function test_remove_group_type() {
    method test_append_group_type (line 749) | public function test_append_group_type() {
    method test_update_item_invalid_id (line 771) | public function test_update_item_invalid_id() {
    method test_update_item_user_not_logged_in (line 783) | public function test_update_item_user_not_logged_in() {
    method test_update_item_without_permission (line 797) | public function test_update_item_without_permission() {
    method test_site_admins_can_update_item (line 820) | public function test_site_admins_can_update_item() {
    method test_group_admins_can_update_item (line 846) | public function test_group_admins_can_update_item() {
    method test_group_moderators_can_not_update_item (line 877) | public function test_group_moderators_can_not_update_item() {
    method test_update_item_invalid_status (line 899) | public function test_update_item_invalid_status() {
    method test_delete_item (line 917) | public function test_delete_item() {
    method test_delete_item_invalid_id (line 933) | public function test_delete_item_invalid_id() {
    method test_delete_item_user_not_logged_in (line 945) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 955) | public function test_delete_item_without_permission() {
    method test_group_moderators_can_not_delete_group (line 967) | public function test_group_moderators_can_not_delete_group() {
    method test_site_admins_can_delete_group (line 984) | public function test_site_admins_can_delete_group() {
    method test_group_admins_can_delete_group (line 1000) | public function test_group_admins_can_delete_group() {
    method test_get_current_user_groups (line 1021) | public function test_get_current_user_groups() {
    method test_get_current_user_groups_max_one (line 1046) | public function test_get_current_user_groups_max_one() {
    method test_get_current_user_groups_not_loggedin (line 1075) | public function test_get_current_user_groups_not_loggedin() {
    method test_prepare_item (line 1083) | public function test_prepare_item() {
    method check_group_data (line 1100) | protected function check_group_data( $group, $data, $context ) {
    method check_add_edit_group (line 1129) | protected function check_add_edit_group( $response, $update = false ) {
    method set_group_data (line 1142) | protected function set_group_data( $args = array() ) {
    method check_update_group_response (line 1151) | protected function check_update_group_response( $response ) {
    method check_create_group_response (line 1165) | protected function check_create_group_response( $response ) {
    method test_get_item_schema (line 1177) | public function test_get_item_schema() {
    method test_get_item_schema_group_types_enum (line 1208) | public function test_get_item_schema_group_types_enum() {
    method test_context_param (line 1224) | public function test_context_param() {
    method update_additional_field (line 1242) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 1246) | public function get_additional_field( $data, $attribute )  {
    method test_additional_fields (line 1253) | public function test_additional_fields() {
    method test_update_additional_fields (line 1294) | public function test_update_additional_fields() {

FILE: tests/testcases/groups/test-group-invites-controller.php
  class BP_Test_REST_Group_Invites_Endpoint (line 9) | class BP_Test_REST_Group_Invites_Endpoint extends WP_Test_REST_Controlle...
    method set_up (line 19) | public function set_up() {
    method test_register_routes (line 55) | public function test_register_routes() {
    method test_get_items (line 72) | public function test_get_items() {
    method test_get_items_with_support_for_the_community_visibility (line 103) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_items_as_group_admin (line 126) | public function test_get_items_as_group_admin() {
    method test_get_items_as_user (line 158) | public function test_get_items_as_user() {
    method test_get_items_as_inviter (line 203) | public function test_get_items_as_inviter() {
    method test_get_items_user_not_logged_in (line 252) | public function test_get_items_user_not_logged_in() {
    method test_get_items_without_permission (line 268) | public function test_get_items_without_permission() {
    method test_get_item (line 285) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 308) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_as_user (line 330) | public function test_get_item_as_user() {
    method test_get_item_as_inviter (line 353) | public function test_get_item_as_inviter() {
    method test_create_item (line 376) | public function test_create_item() {
    method test_create_item_as_group_admin (line 401) | public function test_create_item_as_group_admin() {
    method test_inviter_cannot_invite_member_to_group_if_already_member (line 427) | public function test_inviter_cannot_invite_member_to_group_if_already_...
    method test_create_item_user_not_logged_in (line 445) | public function test_create_item_user_not_logged_in() {
    method test_create_item_invalid_member_id (line 463) | public function test_create_item_invalid_member_id() {
    method test_create_item_invalid_inviter_id (line 480) | public function test_create_item_invalid_inviter_id() {
    method test_create_item_invalid_group_id (line 499) | public function test_create_item_invalid_group_id() {
    method test_create_item_without_permission (line 519) | public function test_create_item_without_permission() {
    method test_update_item (line 539) | public function test_update_item() {
    method test_update_item_as_invitee (line 564) | public function test_update_item_as_invitee() {
    method test_update_item_invalid_id (line 588) | public function test_update_item_invalid_id() {
    method test_update_item_user_not_logged_in (line 600) | public function test_update_item_user_not_logged_in() {
    method test_update_item_without_permission (line 619) | public function test_update_item_without_permission() {
    method test_delete_item (line 641) | public function test_delete_item() {
    method test_delete_item_as_user (line 666) | public function test_delete_item_as_user() {
    method test_delete_item_as_inviter (line 691) | public function test_delete_item_as_inviter() {
    method test_delete_item_as_group_admin (line 719) | public function test_delete_item_as_group_admin() {
    method test_delete_item_user_not_logged_in (line 748) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 771) | public function test_delete_item_without_permission() {
    method test_delete_item_invalid_id (line 796) | public function test_delete_item_invalid_id() {
    method test_prepare_item (line 808) | public function test_prepare_item() {
    method check_invited_user_data (line 812) | protected function check_invited_user_data( $user, $data ) {
    method populate_group_with_invites (line 818) | protected function populate_group_with_invites( $users, $group_id ) {
    method test_get_item_schema (line 829) | public function test_get_item_schema() {
    method test_context_param (line 841) | public function test_context_param() {

FILE: tests/testcases/members/test-controller.php
  class BP_Test_REST_Members_Endpoint (line 9) | class BP_Test_REST_Members_Endpoint extends WP_Test_REST_Controller_Test...
    method wpSetUpBeforeClass (line 18) | public static function wpSetUpBeforeClass( $factory ) {
    method wpTearDownAfterClass (line 36) | public static function wpTearDownAfterClass() {
    method set_up (line 44) | public function set_up() {
    method test_register_routes (line 58) | public function test_register_routes() {
    method test_get_items (line 74) | public function test_get_items() {
    method test_get_items_with_support_for_the_community_visibility (line 101) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_items_extra (line 121) | public function test_get_items_extra() {
    method test_get_paginated_items (line 178) | public function test_get_paginated_items() {
    method test_get_items_with_types (line 211) | public function test_get_items_with_types() {
    method test_get_items_filtered_by_xprofile (line 248) | public function test_get_items_filtered_by_xprofile() {
    method test_get_items_filtered_by_xprofile_with_and_relation (line 290) | public function test_get_items_filtered_by_xprofile_with_and_relation() {
    method test_get_items_filtered_by_xprofile_with_or_relation (line 345) | public function test_get_items_filtered_by_xprofile_with_or_relation() {
    method test_get_item (line 405) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 424) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_extras (line 444) | public function test_get_item_extras() {
    method test_get_item_me_extras (line 491) | public function test_get_item_me_extras() {
    method test_get_item_without_avatar (line 518) | public function test_get_item_without_avatar() {
    method test_get_item_schema_show_avatar (line 542) | function test_get_item_schema_show_avatar() {
    method test_get_item_invalid_id (line 564) | public function test_get_item_invalid_id() {
    method test_create_item (line 574) | public function test_create_item() {
    method test_create_item_without_permission (line 601) | public function test_create_item_without_permission() {
    method test_update_item (line 623) | public function test_update_item() {
    method test_update_item_user_not_logged_in (line 652) | public function test_update_item_user_not_logged_in() {
    method test_update_item_invalid_id (line 665) | public function test_update_item_invalid_id() {
    method test_update_item_without_permission (line 684) | public function test_update_item_without_permission() {
    method test_update_item_types (line 705) | public function test_update_item_types() {
    method test_update_item_member_type_as_regular_user (line 731) | public function test_update_item_member_type_as_regular_user() {
    method test_update_item_member_type_as_admin_user (line 754) | public function test_update_item_member_type_as_admin_user() {
    method test_delete_item (line 776) | public function test_delete_item() {
    method test_delete_item_invalid_id (line 800) | public function test_delete_item_invalid_id() {
    method test_delete_item_user_not_logged_in (line 814) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 828) | public function test_delete_item_without_permission() {
    method test_delete_current_item (line 845) | public function test_delete_current_item() {
    method test_prepare_item (line 866) | public function test_prepare_item() {
    method check_get_user_response (line 877) | protected function check_get_user_response( $response, $context = 'vie...
    method check_add_edit_user_response (line 884) | protected function check_add_edit_user_response( $response, $update = ...
    method check_user_data (line 895) | protected function check_user_data( $user, $data, $context ) {
    method allow_user_to_manage_multisite (line 927) | protected function allow_user_to_manage_multisite() {
    method test_get_item_schema (line 935) | public function test_get_item_schema() {
    method test_get_item_schema_member_types_enum (line 967) | public function test_get_item_schema_member_types_enum() {
    method test_context_param (line 989) | public function test_context_param() {
    method update_additional_field (line 1007) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 1011) | public function get_additional_field( $data, $attribute )  {
    method test_additional_fields (line 1018) | public function test_additional_fields() {
    method test_update_additional_fields (line 1067) | public function test_update_additional_fields() {

FILE: tests/testcases/membership/test-group-membership-controller.php
  class BP_Test_REST_Group_Membership_Endpoint (line 9) | class BP_Test_REST_Group_Membership_Endpoint extends WP_Test_REST_Contro...
    method set_up (line 18) | public function set_up() {
    method test_register_routes (line 40) | public function test_register_routes() {
    method test_get_items (line 58) | public function test_get_items() {
    method test_get_items_by_specific_group_role (line 94) | public function test_get_items_by_specific_group_role() {
    method test_get_items_with_support_for_the_community_visibility (line 137) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_paginated_items (line 158) | public function test_get_paginated_items() {
    method test_get_items_no_search_terms (line 200) | public function test_get_items_no_search_terms() {
    method test_get_items_has_search_terms (line 226) | public function test_get_items_has_search_terms() {
    method group_members_query_args (line 262) | public function group_members_query_args( $args ) {
    method test_get_item (line 273) | public function test_get_item() {
    method test_create_item (line 280) | public function test_create_item() {
    method test_create_item_as_admin (line 300) | public function test_create_item_as_admin() {
    method test_member_can_add_himself_to_public_group (line 327) | public function test_member_can_add_himself_to_public_group() {
    method test_member_can_not_add_himself_to_private_group (line 356) | public function test_member_can_not_add_himself_to_private_group() {
    method test_member_can_not_add_himself_to_hidden_group (line 375) | public function test_member_can_not_add_himself_to_hidden_group() {
    method test_member_cannot_add_others_to_public_group (line 397) | public function test_member_cannot_add_others_to_public_group() {
    method test_update_item (line 418) | public function test_update_item() {
    method test_group_mod_can_not_ban_member (line 445) | public function test_group_mod_can_not_ban_member() {
    method test_group_mod_can_not_ban_random_member (line 471) | public function test_group_mod_can_not_ban_random_member() {
    method test_group_admin_can_ban_member (line 498) | public function test_group_admin_can_ban_member() {
    method test_group_admin_can_not_ban_random_member (line 533) | public function test_group_admin_can_not_ban_random_member() {
    method test_site_admin_can_unban_member_from_group (line 555) | public function test_site_admin_can_unban_member_from_group() {
    method test_site_admin_can_not_unban_random_member (line 591) | public function test_site_admin_can_not_unban_random_member() {
    method test_group_admin_can_unban_member (line 623) | public function test_group_admin_can_unban_member() {
    method test_group_mod_can_not_unban_member (line 663) | public function test_group_mod_can_not_unban_member() {
    method test_site_admin_can_promote_member_to_mod (line 695) | public function test_site_admin_can_promote_member_to_mod() {
    method test_group_admin_can_promote_member (line 725) | public function test_group_admin_can_promote_member() {
    method test_member_can_not_promote_other_member (line 758) | public function test_member_can_not_promote_other_member() {
    method test_group_mods_can_not_promote_members (line 783) | public function test_group_mods_can_not_promote_members() {
    method test_group_mod_can_not_promote_himself (line 808) | public function test_group_mod_can_not_promote_himself() {
    method test_site_admin_can_demote_group_admin_to_member (line 831) | public function test_site_admin_can_demote_group_admin_to_member() {
    method test_site_admin_can_not_demote_the_only_group_admin (line 870) | public function test_site_admin_can_not_demote_the_only_group_admin() {
    method test_site_admin_can_not_demote_himself (line 893) | public function test_site_admin_can_not_demote_himself() {
    method test_site_admin_can_demote_group_admins (line 916) | public function test_site_admin_can_demote_group_admins() {
    method test_site_admin_can_demote_group_mods (line 959) | public function test_site_admin_can_demote_group_mods() {
    method test_site_admin_can_not_demote_already_group_members (line 998) | public function test_site_admin_can_not_demote_already_group_members() {
    method test_group_admin_can_demote_another_group_admin_to_mod (line 1027) | public function test_group_admin_can_demote_another_group_admin_to_mod...
    method test_group_admin_can_not_demote_himself (line 1064) | public function test_group_admin_can_not_demote_himself() {
    method test_group_admin_can_not_demote_already_group_members (line 1086) | public function test_group_admin_can_not_demote_already_group_members() {
    method test_member_can_not_demote_another_member (line 1108) | public function test_member_can_not_demote_another_member() {
    method test_member_can_not_demote_himself (line 1130) | public function test_member_can_not_demote_himself() {
    method test_update_item_invalid_group_id (line 1152) | public function test_update_item_invalid_group_id() {
    method test_update_item_user_not_logged_in (line 1170) | public function test_update_item_user_not_logged_in() {
    method test_delete_item (line 1180) | public function test_delete_item() {
    method test_member_can_remove_himself_from_group (line 1210) | public function test_member_can_remove_himself_from_group() {
    method test_banned_member_can_not_remove_himself_from_group (line 1239) | public function test_banned_member_can_not_remove_himself_from_group() {
    method test_member_can_not_remove_others_from_group (line 1264) | public function test_member_can_not_remove_others_from_group() {
    method test_group_admin_can_remove_member_from_group (line 1286) | public function test_group_admin_can_remove_member_from_group() {
    method test_group_admin_can_remove_himself_from_group (line 1314) | public function test_group_admin_can_remove_himself_from_group() {
    method test_last_group_admin_can_not_remove_himself_from_group (line 1346) | public function test_last_group_admin_can_not_remove_himself_from_grou...
    method test_group_admin_can_remove_another_group_admin (line 1367) | public function test_group_admin_can_remove_another_group_admin() {
    method test_site_admin_can_not_remove_himself_group_admin (line 1398) | public function test_site_admin_can_not_remove_himself_group_admin() {
    method test_site_admin_can_remove_group_admin (line 1420) | public function test_site_admin_can_remove_group_admin() {
    method test_site_admin_can_not_remove_last_group_admin (line 1451) | public function test_site_admin_can_not_remove_last_group_admin() {
    method test_prepare_item (line 1472) | public function test_prepare_item() {
    method populate_group_with_members (line 1479) | protected function populate_group_with_members( $members, $group_id ) {
    method check_user_data (line 1485) | protected function check_user_data( $user, $data, $member_object, $con...
    method test_get_item_schema (line 1515) | public function test_get_item_schema() {
    method test_context_param (line 1553) | public function test_context_param() {

FILE: tests/testcases/membership/test-group-membership-request-controller.php
  class BP_Test_REST_Group_Membership_Request_Endpoint (line 9) | class BP_Test_REST_Group_Membership_Request_Endpoint extends WP_Test_RES...
    method set_up (line 19) | public function set_up() {
    method test_register_routes (line 54) | public function test_register_routes() {
    method test_get_items (line 71) | public function test_get_items() {
    method test_get_items_with_support_for_the_community_visibility (line 98) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_items_as_group_admin (line 122) | public function test_get_items_as_group_admin() {
    method test_get_items_as_requestor (line 147) | public function test_get_items_as_requestor() {
    method test_get_items_user_is_not_logged_in (line 170) | public function test_get_items_user_is_not_logged_in() {
    method test_get_items_user_has_no_access_to_group (line 186) | public function test_get_items_user_has_no_access_to_group() {
    method test_get_items_user_has_no_access_to_user (line 206) | public function test_get_items_user_has_no_access_to_user() {
    method test_get_items_invalid_group (line 226) | public function test_get_items_invalid_group() {
    method test_get_item (line 242) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 265) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_user_is_not_logged_in (line 281) | public function test_get_item_user_is_not_logged_in() {
    method test_get_item_invalid_membership_request (line 297) | public function test_get_item_invalid_membership_request() {
    method test_get_item_no_access (line 310) | public function test_get_item_no_access() {
    method test_create_item (line 328) | public function test_create_item() {
    method test_create_item_as_subscriber (line 349) | public function test_create_item_as_subscriber() {
    method test_create_item_user_is_not_logged_in (line 371) | public function test_create_item_user_is_not_logged_in() {
    method test_create_item_invalid_member (line 389) | public function test_create_item_invalid_member() {
    method test_create_item_invalid_group (line 406) | public function test_create_item_invalid_group() {
    method test_create_item_with_an_already_group_member (line 424) | public function test_create_item_with_an_already_group_member() {
    method test_create_item_fails_with_pending_request (line 444) | public function test_create_item_fails_with_pending_request() {
    method test_update_item (line 464) | public function test_update_item() {
    method test_update_item_as_group_admin (line 487) | public function test_update_item_as_group_admin() {
    method test_update_item_user_is_not_logged_in (line 509) | public function test_update_item_user_is_not_logged_in() {
    method test_update_item_user_has_no_access (line 525) | public function test_update_item_user_has_no_access() {
    method test_update_item_invalid_id (line 543) | public function test_update_item_invalid_id() {
    method test_delete_item (line 558) | public function test_delete_item() {
    method test_delete_item_as_requestor (line 578) | public function test_delete_item_as_requestor() {
    method test_delete_item_as_group_admin (line 598) | public function test_delete_item_as_group_admin() {
    method test_delete_item_user_is_not_logged_in (line 618) | public function test_delete_item_user_is_not_logged_in() {
    method test_delete_item_user_has_no_access (line 634) | public function test_delete_item_user_has_no_access() {
    method test_prepare_item (line 652) | public function test_prepare_item() {
    method test_get_item_schema (line 656) | public function test_get_item_schema() {
    method test_context_param (line 668) | public function test_context_param() {

FILE: tests/testcases/messages/test-controller.php
  class BP_Test_REST_Messages_Endpoint (line 10) | class BP_Test_REST_Messages_Endpoint extends WP_Test_REST_Controller_Tes...
    method set_up (line 17) | public function set_up() {
    method test_register_routes (line 30) | public function test_register_routes() {
    method test_get_items (line 54) | public function test_get_items() {
    method test_get_items_and_paginate_messages_recipients (line 94) | public function test_get_items_and_paginate_messages_recipients() {
    method test_get_item (line 155) | public function test_get_item() {
    method test_get_thread_messages_paginated (line 183) | public function test_get_thread_messages_paginated() {
    method test_get_item_admin_access (line 232) | public function test_get_item_admin_access() {
    method test_get_item_with_edit_context (line 273) | public function test_get_item_with_edit_context() {
    method test_get_item_user_with_no_access (line 315) | public function test_get_item_user_with_no_access() {
    method test_get_item_user_is_not_logged_in (line 338) | public function test_get_item_user_is_not_logged_in() {
    method test_get_item_invalid_id (line 361) | public function test_get_item_invalid_id() {
    method test_create_item (line 373) | public function test_create_item() {
    method test_create_item_user_is_not_logged_in (line 401) | public function test_create_item_user_is_not_logged_in() {
    method test_create_item_with_no_content (line 421) | public function test_create_item_with_no_content() {
    method test_create_item_with_no_receipts (line 443) | public function test_create_item_with_no_receipts() {
    method test_update_item (line 465) | public function test_update_item() {
    method test_update_thread_to_unread (line 496) | public function test_update_thread_to_unread() {
    method test_update_item_user_is_not_logged_in (line 536) | public function test_update_item_user_is_not_logged_in() {
    method test_update_item_invalid_id (line 558) | public function test_update_item_invalid_id() {
    method test_update_item_with_user_with_no_access (line 570) | public function test_update_item_with_user_with_no_access() {
    method test_delete_item (line 595) | public function test_delete_item() {
    method test_delete_item_admin_access (line 623) | public function test_delete_item_admin_access() {
    method test_delete_item_with_user_with_no_access (line 650) | public function test_delete_item_with_user_with_no_access() {
    method test_delete_item_user_is_not_logged_in (line 674) | public function test_delete_item_user_is_not_logged_in() {
    method test_get_starred_items (line 695) | public function test_get_starred_items() {
    method test_update_starred_add_star (line 752) | public function test_update_starred_add_star() {
    method test_update_starred_remove_star (line 785) | public function test_update_starred_remove_star() {
    method test_update_starred_user_is_not_logged_in (line 813) | public function test_update_starred_user_is_not_logged_in() {
    method test_update_starred_user_with_no_access (line 836) | public function test_update_starred_user_with_no_access() {
    method test_update_starred_using_invalid_id (line 862) | public function test_update_starred_using_invalid_id() {
    method update_additional_field (line 871) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 875) | public function get_additional_field( $data, $attribute )  {
    method test_additional_fields_for_get_item (line 882) | public function test_additional_fields_for_get_item() {
    method test_additional_fields_for_created_thread (line 926) | public function test_additional_fields_for_created_thread() {
    method test_additional_fields_for_created_reply (line 967) | public function test_additional_fields_for_created_reply() {
    method test_additional_fields_for_last_message_updated (line 1020) | public function test_additional_fields_for_last_message_updated() {
    method test_additional_fields_for_specific_message_updated (line 1080) | public function test_additional_fields_for_specific_message_updated() {
    method test_prepare_prepare_recipient_for_response (line 1141) | public function test_prepare_prepare_recipient_for_response() {
    method test_prepare_add_links_to_response (line 1182) | public function test_prepare_add_links_to_response() {
    method test_prepare_item (line 1217) | public function test_prepare_item() {
    method check_thread_data (line 1221) | protected function check_thread_data( $thread, $data ) {
    method test_get_item_schema (line 1236) | public function test_get_item_schema() {
    method test_context_param (line 1255) | public function test_context_param() {

FILE: tests/testcases/notifications/test-controller.php
  class BP_Test_REST_Notifications_Endpoint (line 9) | class BP_Test_REST_Notifications_Endpoint extends WP_Test_REST_Controlle...
    method set_up (line 17) | public function set_up() {
    method test_register_routes (line 34) | public function test_register_routes() {
    method test_get_items (line 49) | public function test_get_items() {
    method test_admin_can_get_items_from_multiple_users (line 69) | public function test_admin_can_get_items_from_multiple_users() {
    method test_user_can_not_get_items_from_multiple_users (line 97) | public function test_user_can_not_get_items_from_multiple_users() {
    method test_get_items_user_not_logged_in (line 118) | public function test_get_items_user_not_logged_in() {
    method test_get_items_user_cannot_see_notifications_from_others (line 129) | public function test_get_items_user_cannot_see_notifications_from_othe...
    method test_get_item (line 143) | public function test_get_item() {
    method test_get_embedded_user_from_notification_item (line 164) | public function test_get_embedded_user_from_notification_item() {
    method test_get_embedded_group_from_notification_item (line 190) | public function test_get_embedded_group_from_notification_item() {
    method test_get_embedded_activity_from_notification_item (line 226) | public function test_get_embedded_activity_from_notification_item() {
    method test_get_embedded_blog_from_notification_item (line 262) | public function test_get_embedded_blog_from_notification_item() {
    method test_get_item_user_not_logged_in (line 309) | public function test_get_item_user_not_logged_in() {
    method test_get_item_user_cannot_see_notification (line 322) | public function test_get_item_user_cannot_see_notification() {
    method test_create_item (line 338) | public function test_create_item() {
    method test_rest_create_item (line 355) | public function test_rest_create_item() {
    method test_create_item_user_not_logged_in (line 372) | public function test_create_item_user_not_logged_in() {
    method test_create_item_user_cannot_create (line 387) | public function test_create_item_user_cannot_create() {
    method test_update_item (line 405) | public function test_update_item() {
    method test_update_item_invalid_id (line 430) | public function test_update_item_invalid_id() {
    method test_update_item_user_not_logged_in (line 446) | public function test_update_item_user_not_logged_in() {
    method test_update_item_user_without_access (line 457) | public function test_update_item_user_without_access() {
    method test_update_item_same_status (line 473) | public function test_update_item_same_status() {
    method test_delete_item (line 492) | public function test_delete_item() {
    method test_delete_item_invalid_id (line 515) | public function test_delete_item_invalid_id() {
    method test_delete_item_user_not_logged_in (line 528) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_user_without_access (line 539) | public function test_delete_item_user_without_access() {
    method test_prepare_item (line 555) | public function test_prepare_item() {
    method check_notification_data (line 572) | protected function check_notification_data( $notification, $data ) {
    method set_notification_data (line 587) | protected function set_notification_data( $args = array() ) {
    method check_update_notification_response (line 594) | protected function check_update_notification_response( $response ) {
    method check_create_notification_response (line 610) | protected function check_create_notification_response( $response ) {
    method test_get_item_schema (line 623) | public function test_get_item_schema() {
    method test_context_param (line 641) | public function test_context_param() {
    method update_additional_field (line 660) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 664) | public function get_additional_field( $data, $attribute )  {
    method test_additional_fields (line 671) | public function test_additional_fields() {
    method test_update_additional_fields (line 713) | public function test_update_additional_fields() {

FILE: tests/testcases/signup/test-controller.php
  class BP_Test_REST_Signup_Endpoint (line 9) | class BP_Test_REST_Signup_Endpoint extends WP_Test_REST_Controller_Testc...
    method set_up (line 18) | public function set_up() {
    method tear_down (line 51) | public function tear_down() {
    method test_register_routes (line 61) | public function test_register_routes() {
    method test_get_items (line 78) | public function test_get_items() {
    method test_get_paginated_items (line 98) | public function test_get_paginated_items() {
    method test_get_items_user_not_logged_in (line 128) | public function test_get_items_user_not_logged_in() {
    method test_get_items_unauthorized_user (line 139) | public function test_get_items_unauthorized_user() {
    method test_get_item (line 154) | public function test_get_item() {
    method test_get_item_with_invalid_signup_id (line 174) | public function test_get_item_with_invalid_signup_id() {
    method test_get_item_user_not_logged_in (line 186) | public function test_get_item_user_not_logged_in() {
    method test_get_item_unauthorized_user (line 197) | public function test_get_item_unauthorized_user() {
    method test_create_item (line 212) | public function test_create_item() {
    method test_create_item_with_signup_fields (line 232) | public function test_create_item_with_signup_fields() {
    method test_create_item_without_the_required_field_name_field (line 326) | public function test_create_item_without_the_required_field_name_field...
    method test_create_item_without_a_custom_required_field_name_field (line 395) | public function test_create_item_without_a_custom_required_field_name_...
    method test_create_item_a_custom_required_field_name_field_value_missing (line 466) | public function test_create_item_a_custom_required_field_name_field_va...
    method test_create_item_without_the_default_required_field_value (line 538) | public function test_create_item_without_the_default_required_field_va...
    method test_create_item_without_the_signup_field_data_param (line 559) | public function test_create_item_without_the_signup_field_data_param() {
    method test_create_item_unauthorized_password (line 573) | public function test_create_item_unauthorized_password() {
    method test_update_item (line 587) | public function test_update_item() {
    method test_update_item_invalid_invalid_activation_key (line 604) | public function test_update_item_invalid_invalid_activation_key() {
    method test_delete_item (line 614) | public function test_delete_item() {
    method test_delete_item_invalid_signup_id (line 634) | public function test_delete_item_invalid_signup_id() {
    method test_delete_item_user_not_logged_in (line 647) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_unauthorized_user (line 658) | public function test_delete_item_unauthorized_user() {
    method test_resend_activation_email (line 672) | public function test_resend_activation_email() {
    method test_resend_acivation_email_to_active_signup (line 690) | public function test_resend_acivation_email_to_active_signup() {
    method test_resend_activation_email_invalid_signup_id (line 715) | public function test_resend_activation_email_invalid_signup_id() {
    method test_prepare_item (line 724) | public function test_prepare_item() {
    method set_signup_data (line 741) | protected function set_signup_data( $args = array() ) {
    method create_signup (line 759) | protected function create_signup() {
    method check_signup_data (line 773) | protected function check_signup_data( $signup, $data ) {
    method test_get_item_schema (line 783) | public function test_get_item_schema() {
    method test_context_param (line 814) | public function test_context_param() {

FILE: tests/testcases/sitewide-notices/test-controller.php
  class BP_Test_REST_Sitewide_Notices_Endpoint (line 9) | class BP_Test_REST_Sitewide_Notices_Endpoint extends WP_Test_REST_Contro...
    method set_up (line 17) | public function set_up() {
    method tear_down (line 36) | public function tear_down() {
    method catch_inserted_id (line 43) | public function catch_inserted_id( $query ) {
    method add_filter_update_last_active_query (line 52) | public function add_filter_update_last_active_query() {
    method set_last_inserted_notice_id (line 56) | public function set_last_inserted_notice_id( $notice_obj ) {
    method test_register_routes (line 65) | public function test_register_routes() {
    method create_notice (line 86) | public function create_notice( $notices = array() ) {
    method test_get_items (line 117) | public function test_get_items() {
    method test_get_items_no_edit_access (line 151) | public function test_get_items_no_edit_access() {
    method test_get_items_view_active (line 176) | public function test_get_items_view_active() {
    method test_get_items_no_active (line 209) | public function test_get_items_no_active() {
    method test_get_item (line 226) | public function test_get_item() {
    method test_get_item_admin_access (line 262) | public function test_get_item_admin_access() {
    method test_get_item_no_access (line 295) | public function test_get_item_no_access() {
    method test_get_item_view_active (line 325) | public function test_get_item_view_active() {
    method test_get_item_with_invalid_id (line 361) | public function test_get_item_with_invalid_id() {
    method test_create_item (line 374) | public function test_create_item() {
    method test_create_item_no_access (line 398) | public function test_create_item_no_access() {
    method test_create_item_no_subject (line 418) | public function test_create_item_no_subject() {
    method test_update_item (line 437) | public function test_update_item() {
    method test_update_item_no_access (line 466) | public function test_update_item_no_access() {
    method test_update_item_no_message (line 490) | public function test_update_item_no_message() {
    method test_update_item_with_invalid_id (line 511) | public function test_update_item_with_invalid_id() {
    method test_delete_item (line 524) | public function test_delete_item() {
    method test_delete_item_no_access (line 550) | public function test_delete_item_no_access() {
    method test_delete_item_with_invalid_id (line 573) | public function test_delete_item_with_invalid_id() {
    method test_dismiss_item (line 585) | public function test_dismiss_item() {
    method test_dismiss_item_no_actives (line 615) | public function test_dismiss_item_no_actives() {
    method test_dismiss_item_not_logged_in (line 638) | public function test_dismiss_item_not_logged_in() {
    method test_prepare_item (line 659) | public function test_prepare_item() {
    method check_notice_data (line 663) | protected function check_notice_data( $notice, $data, $context = 'view...
    method test_get_item_schema (line 681) | public function test_get_item_schema() {
    method test_context_param (line 696) | public function test_context_param() {

FILE: tests/testcases/xprofile/test-data-controller.php
  class BP_Test_REST_XProfile_Data_Endpoint (line 9) | class BP_Test_REST_XProfile_Data_Endpoint extends WP_Test_REST_Controlle...
    method set_up (line 19) | public function set_up() {
    method test_register_routes (line 39) | public function test_register_routes() {
    method test_get_items (line 51) | public function test_get_items() {
    method test_get_item (line 58) | public function test_get_item() {
    method test_get_item_with_support_for_the_community_visibility (line 77) | public function test_get_item_with_support_for_the_community_visibilit...
    method test_get_item_hidden_for_user (line 91) | public function test_get_item_hidden_for_user() {
    method test_update_item (line 105) | public function test_update_item() {
    method test_update_checkbox (line 122) | public function test_update_checkbox() {
    method test_update_multiselectbox (line 170) | public function test_update_multiselectbox() {
    method test_update_multiselectbox_with_invalid_item (line 227) | public function test_update_multiselectbox_with_invalid_item() {
    method test_update_multiselectbox_with_empty_value (line 260) | public function test_update_multiselectbox_with_empty_value() {
    method test_update_multiselectbox_with_apostrophe_value (line 301) | public function test_update_multiselectbox_with_apostrophe_value() {
    method test_update_checkbox_with_apostrophe_value (line 352) | public function test_update_checkbox_with_apostrophe_value() {
    method test_update_textbox (line 402) | public function test_update_textbox() {
    method test_update_textbox_with_apostrophe_value (line 435) | public function test_update_textbox_with_apostrophe_value() {
    method test_update_selectbox (line 476) | public function test_update_selectbox() {
    method test_update_item_user_not_logged_in (line 517) | public function test_update_item_user_not_logged_in() {
    method test_update_item_user_without_permission (line 530) | public function test_update_item_user_without_permission() {
    method test_update_item_user_without_permission_with_param (line 546) | public function test_update_item_user_without_permission_with_param() {
    method test_update_item_invalid_field_id (line 564) | public function test_update_item_invalid_field_id() {
    method test_update_item_invalid_member_id (line 580) | public function test_update_item_invalid_member_id() {
    method test_create_item (line 596) | public function test_create_item() {
    method test_delete_item (line 603) | public function test_delete_item() {
    method test_delete_item_field_owner_can_delete (line 631) | public function test_delete_item_field_owner_can_delete() {
    method test_delete_item_invalid_field_id (line 662) | public function test_delete_item_invalid_field_id() {
    method test_delete_item_invalid_user_id (line 674) | public function test_delete_item_invalid_user_id() {
    method test_delete_item_user_not_logged_in (line 686) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 696) | public function test_delete_item_without_permission() {
    method test_prepare_item (line 709) | public function test_prepare_item() {
    method test_additional_fields (line 728) | public function test_additional_fields() {
    method update_additional_field (line 758) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 762) | public function get_additional_field( $data, $attribute )  {
    method check_create_field_response (line 766) | protected function check_create_field_response( $response ) {
    method set_field_data (line 778) | protected function set_field_data( $args = array() ) {
    method check_field_data (line 787) | protected function check_field_data( $field_data, $data ) {
    method test_get_item_schema (line 798) | public function test_get_item_schema() {
    method test_context_param (line 813) | public function test_context_param() {

FILE: tests/testcases/xprofile/test-field-controller.php
  class BP_Test_REST_XProfile_Fields_Endpoint (line 9) | class BP_Test_REST_XProfile_Fields_Endpoint extends WP_Test_REST_Control...
    method set_up (line 18) | public function set_up() {
    method test_register_routes (line 37) | public function test_register_routes() {
    method test_get_items (line 52) | public function test_get_items() {
    method test_public_get_items (line 75) | public function test_public_get_items() {
    method test_public_get_items_with_support_for_the_community_visibility (line 96) | public function test_public_get_items_with_support_for_the_community_v...
    method test_get_items_include_groups (line 110) | public function test_get_items_include_groups() {
    method test_get_item (line 138) | public function test_get_item() {
    method test_get_public_item (line 159) | public function test_get_public_item() {
    method test_get_public_item_with_support_for_the_community_visibility (line 178) | public function test_get_public_item_with_support_for_the_community_vi...
    method test_get_item_with_invalid_id (line 193) | public function test_get_item_with_invalid_id() {
    method test_create_item (line 205) | public function test_create_item() {
    method test_rest_create_item (line 222) | public function test_rest_create_item() {
    method test_create_item_with_without_required_field (line 239) | public function test_create_item_with_without_required_field() {
    method test_create_item_with_invalid_type (line 256) | public function test_create_item_with_invalid_type() {
    method test_create_item_user_not_logged_in (line 273) | public function test_create_item_user_not_logged_in() {
    method test_create_item_user_without_permission (line 288) | public function test_create_item_user_without_permission() {
    method test_update_item (line 306) | public function test_update_item() {
    method test_update_item_invalid_id (line 332) | public function test_update_item_invalid_id() {
    method test_update_item_user_not_logged_in (line 347) | public function test_update_item_user_not_logged_in() {
    method test_update_item_without_permission (line 361) | public function test_update_item_without_permission() {
    method test_delete_item (line 377) | public function test_delete_item() {
    method test_delete_item_invalid_id (line 397) | public function test_delete_item_invalid_id() {
    method test_delete_item_user_not_logged_in (line 409) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 419) | public function test_delete_item_without_permission() {
    method test_prepare_item (line 432) | public function test_prepare_item() {
    method test_additional_fields (line 452) | public function test_additional_fields() {
    method test_update_additional_fields (line 493) | public function test_update_additional_fields() {
    method update_additional_field (line 526) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 530) | public function get_additional_field( $data, $attribute )  {
    method check_create_field_response (line 534) | protected function check_create_field_response( $response ) {
    method set_field_data (line 547) | protected function set_field_data( $args = array() ) {
    method check_field_data (line 555) | protected function check_field_data( $field, $data, $context = 'view' ) {
    method test_get_item_schema (line 580) | public function test_get_item_schema() {
    method test_context_param (line 604) | public function test_context_param() {

FILE: tests/testcases/xprofile/test-group-controller.php
  class BP_Test_REST_XProfile_Groups_Endpoint (line 9) | class BP_Test_REST_XProfile_Groups_Endpoint extends WP_Test_REST_Control...
    method set_up (line 17) | public function set_up() {
    method test_register_routes (line 35) | public function test_register_routes() {
    method test_get_items (line 50) | public function test_get_items() {
    method test_get_items_with_support_for_the_community_visibility (line 74) | public function test_get_items_with_support_for_the_community_visibili...
    method test_get_items_include_groups (line 89) | public function test_get_items_include_groups() {
    method test_get_items_publicly (line 120) | public function test_get_items_publicly() {
    method test_get_item (line 142) | public function test_get_item() {
    method test_get_item_publicly_with_support_for_the_community_visibility (line 163) | public function test_get_item_publicly_with_support_for_the_community_...
    method test_get_item_publicly (line 179) | public function test_get_item_publicly() {
    method test_get_item_invalid_id (line 198) | public function test_get_item_invalid_id() {
    method test_create_item (line 211) | public function test_create_item() {
    method test_rest_create_item (line 228) | public function test_rest_create_item() {
    method test_create_item_user_not_logged_in (line 244) | public function test_create_item_user_not_logged_in() {
    method test_create_item_user_without_permission (line 258) | public function test_create_item_user_without_permission() {
    method test_update_item (line 275) | public function test_update_item() {
    method test_update_item_invalid_id (line 299) | public function test_update_item_invalid_id() {
    method test_update_item_user_not_logged_in (line 311) | public function test_update_item_user_not_logged_in() {
    method test_update_item_without_permission (line 321) | public function test_update_item_without_permission() {
    method test_delete_item (line 334) | public function test_delete_item() {
    method test_delete_item_invalid_id (line 355) | public function test_delete_item_invalid_id() {
    method test_delete_item_user_not_logged_in (line 367) | public function test_delete_item_user_not_logged_in() {
    method test_delete_item_without_permission (line 377) | public function test_delete_item_without_permission() {
    method test_prepare_item (line 390) | public function test_prepare_item() {
    method check_create_field_group_response (line 408) | protected function check_create_field_group_response( $response ) {
    method check_group_data (line 421) | protected function check_group_data( $group, $data, $context, $links ) {
    method set_field_group_data (line 434) | protected function set_field_group_data( $args = array() ) {
    method test_get_item_schema (line 442) | public function test_get_item_schema() {
    method test_context_param (line 457) | public function test_context_param() {
    method update_additional_field (line 467) | public function update_additional_field( $value, $data, $attribute ) {
    method get_additional_field (line 471) | public function get_additional_field( $data, $attribute )  {
    method test_additional_fields (line 478) | public function test_additional_fields() {
    method test_update_additional_fields (line 519) | public function test_update_additional_fields() {
Condensed preview — 59 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,237K chars).
[
  {
    "path": ".distignore",
    "chars": 125,
    "preview": ".DS_Store\n.git\n.gitignore\n.gitlab-ci.yml\n.editorconfig\n.travis.yml\nbehat.yml\ncircle.yml\nbin/\nfeatures/\nutils/\n*.zip\n*.ta"
  },
  {
    "path": ".editorconfig",
    "chars": 433,
    "preview": "# This file is for unifying the coding style for different editors and IDEs\n# editorconfig.org\n\n# WordPress Coding Stand"
  },
  {
    "path": ".gitignore",
    "chars": 239,
    "preview": "# Files and folders related to build/test tools\n/phpunit.xml\n/node_modules\n/npm-debug.log\n/vendor/\n.vscode\n.wp-env.overr"
  },
  {
    "path": ".phpcs/.gitkeep",
    "chars": 33,
    "preview": "# This directory can't be empty.\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 1383,
    "preview": "# Contributing\nHi, and thanks for considering contributing! Before you do though, here's a few\nnotes on how best to cont"
  },
  {
    "path": "README.md",
    "chars": 411,
    "preview": "# BuddyPress RESTful API\n\n[![Project Status: Active.](https://www.repostatus.org/badges/latest/inactive.svg)](https://ww"
  },
  {
    "path": "bp-rest.php",
    "chars": 9484,
    "preview": "<?php\n/**\n * Plugin Name:       BuddyPress RESTful API (Deprecated)\n * Plugin URI:        https://buddypress.org\n * Desc"
  },
  {
    "path": "composer.json",
    "chars": 1738,
    "preview": "{\n\t\"name\": \"buddypress/bp-rest\",\n\t\"description\": \"Access your BuddyPress site's data through an easy-to-use HTTP REST AP"
  },
  {
    "path": "includes/bp-activity/classes/class-bp-rest-activity-endpoint.php",
    "chars": 50314,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Activity_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSPATH' "
  },
  {
    "path": "includes/bp-attachments/classes/trait-attachments.php",
    "chars": 11953,
    "preview": "<?php\n/**\n * BP REST: Attachments Trait\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSPATH' ) || exit;\n\n/*"
  },
  {
    "path": "includes/bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php",
    "chars": 8952,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Attachments_Blog_Avatar_Endpoint class\n *\n * @package BuddyPress\n * @since 6.0.0\n */\n\ndefi"
  },
  {
    "path": "includes/bp-blogs/classes/class-bp-rest-blogs-endpoint.php",
    "chars": 24226,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Blogs_Endpoint class\n *\n * @package BuddyPress\n * @since 6.0.0\n */\n\ndefined( 'ABSPATH' ) |"
  },
  {
    "path": "includes/bp-components/classes/class-bp-rest-components-endpoint.php",
    "chars": 17899,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Components_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSPATH"
  },
  {
    "path": "includes/bp-friends/classes/class-bp-rest-friends-endpoint.php",
    "chars": 27898,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Friends_Endpoint class\n *\n * @package BuddyPress\n * @since 6.0.0\n */\n\ndefined( 'ABSPATH' )"
  },
  {
    "path": "includes/bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php",
    "chars": 13519,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Attachments_Group_Avatar_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndef"
  },
  {
    "path": "includes/bp-groups/classes/class-bp-rest-attachments-group-cover-endpoint.php",
    "chars": 11685,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Attachments_Group_Cover_Endpoint class\n *\n * @package BuddyPress\n * @since 6.0.0\n */\n\ndefi"
  },
  {
    "path": "includes/bp-groups/classes/class-bp-rest-group-invites-endpoint.php",
    "chars": 33843,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Group_Invites_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSP"
  },
  {
    "path": "includes/bp-groups/classes/class-bp-rest-group-membership-endpoint.php",
    "chars": 31340,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Group_Membership_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'A"
  },
  {
    "path": "includes/bp-groups/classes/class-bp-rest-group-membership-request-endpoint.php",
    "chars": 28734,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Group_Membership_Request_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndef"
  },
  {
    "path": "includes/bp-groups/classes/class-bp-rest-groups-endpoint.php",
    "chars": 49408,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Groups_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSPATH' ) "
  },
  {
    "path": "includes/bp-members/classes/class-bp-rest-attachments-member-avatar-endpoint.php",
    "chars": 14073,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Attachments_Member_Avatar_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\nde"
  },
  {
    "path": "includes/bp-members/classes/class-bp-rest-attachments-member-cover-endpoint.php",
    "chars": 11402,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Attachments_Member_Cover_Endpoint class\n *\n * @package BuddyPress\n * @since 6.0.0\n */\n\ndef"
  },
  {
    "path": "includes/bp-members/classes/class-bp-rest-members-endpoint.php",
    "chars": 41740,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Members_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSPATH' )"
  },
  {
    "path": "includes/bp-members/classes/class-bp-rest-signup-endpoint.php",
    "chars": 41019,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Signup_Endpoint class\n *\n * @package BuddyPress\n * @since 6.0.0\n */\n\ndefined( 'ABSPATH' ) "
  },
  {
    "path": "includes/bp-messages/classes/class-bp-rest-messages-endpoint.php",
    "chars": 49301,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Messages_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSPATH' "
  },
  {
    "path": "includes/bp-messages/classes/class-bp-rest-sitewide-notices-endpoint.php",
    "chars": 29257,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Sitewide_Notices_Endpoint class\n *\n * @package BuddyPress\n * @since 9.0.0\n */\n\ndefined( 'A"
  },
  {
    "path": "includes/bp-notifications/classes/class-bp-rest-notifications-endpoint.php",
    "chars": 31098,
    "preview": "<?php\n/**\n * BP REST: BP_REST_Notifications_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSP"
  },
  {
    "path": "includes/bp-xprofile/classes/class-bp-rest-xprofile-data-endpoint.php",
    "chars": 18341,
    "preview": "<?php\n/**\n * BP REST: BP_REST_XProfile_Data_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'ABSP"
  },
  {
    "path": "includes/bp-xprofile/classes/class-bp-rest-xprofile-field-groups-endpoint.php",
    "chars": 29728,
    "preview": "<?php\n/**\n * BP REST: BP_REST_XProfile_Field_Groups_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefine"
  },
  {
    "path": "includes/bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php",
    "chars": 41637,
    "preview": "<?php\n/**\n * BP REST: BP_REST_XProfile_Fields_Endpoint class\n *\n * @package BuddyPress\n * @since 0.1.0\n */\n\ndefined( 'AB"
  },
  {
    "path": "package.json",
    "chars": 791,
    "preview": "{\n\t\"name\": \"buddypress\",\n\t\"description\": \"REST API endpoints for BuddyPress\",\n\t\"homepage\": \"https://buddypress.org\",\n\t\"b"
  },
  {
    "path": "phpcs.xml.dist",
    "chars": 989,
    "preview": "<?xml version=\"1.0\"?>\n<ruleset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"BP REST API Coding Standards "
  },
  {
    "path": "phpunit.xml.dist",
    "chars": 488,
    "preview": "<phpunit\n\tbootstrap=\"tests/bootstrap.php\"\n\tbackupGlobals=\"false\"\n\tcolors=\"true\"\n\tconvertErrorsToExceptions=\"true\"\n\tconve"
  },
  {
    "path": "readme.txt",
    "chars": 1025,
    "preview": "=== BP-REST ===\nContributors:      The BuddyPress Community\nDonate link:       https://buddypress.org\nRequires at least:"
  },
  {
    "path": "tests/bootstrap.php",
    "chars": 1597,
    "preview": "<?php\n/**\n * PHPUnit bootstrap file\n *\n * @package BP_REST\n */\n\n// Setting PHPUnit polyfills.\nconst WP_TESTS_PHPUNIT_POL"
  },
  {
    "path": "tests/define-constants.php",
    "chars": 1140,
    "preview": "<?php\n/**\n * Define constants needed by test suite.\n */\n\nif ( ! defined( 'BP_TESTS_DIR' ) ) {\n\tdefine( 'BP_TESTS_DIR', d"
  },
  {
    "path": "tests/multisite.xml",
    "chars": 394,
    "preview": "<phpunit\n\tbootstrap=\"bootstrap.php\"\n\tbackupGlobals=\"false\"\n\tcolors=\"true\"\n\tconvertErrorsToExceptions=\"true\"\n\tconvertNoti"
  },
  {
    "path": "tests/testcases/activity/test-controller.php",
    "chars": 55555,
    "preview": "<?php\n/**\n * Activity Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group activity\n */\nclass BP_T"
  },
  {
    "path": "tests/testcases/attachments/test-blog-avatar-controller.php",
    "chars": 6487,
    "preview": "<?php\n/**\n * Blog Avatar Endpoints Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group blog-avatar\n */\ncla"
  },
  {
    "path": "tests/testcases/attachments/test-group-avatar-controller.php",
    "chars": 9356,
    "preview": "<?php\n/**\n * Group Avatar Endpoints Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group group-avatar\n */\nc"
  },
  {
    "path": "tests/testcases/attachments/test-group-cover-controller.php",
    "chars": 8712,
    "preview": "<?php\n/**\n * Group Cover Endpoints Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group group-cover\n */\ncla"
  },
  {
    "path": "tests/testcases/attachments/test-member-avatar-controller.php",
    "chars": 8650,
    "preview": "<?php\n/**\n * Member Avatar Endpoints Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group member-avatar\n */"
  },
  {
    "path": "tests/testcases/attachments/test-member-cover-controller.php",
    "chars": 7226,
    "preview": "<?php\n/**\n * Member Cover Endpoints Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group member-cover\n */\nc"
  },
  {
    "path": "tests/testcases/blogs/test-controller.php",
    "chars": 12390,
    "preview": "<?php\n/**\n * Blogs Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group blogs\n */\nclass BP_Test_RE"
  },
  {
    "path": "tests/testcases/components/test-controller.php",
    "chars": 10654,
    "preview": "<?php\n/**\n * Components Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group components\n */\nclass "
  },
  {
    "path": "tests/testcases/friends/test-controller.php",
    "chars": 19225,
    "preview": "<?php\n/**\n * Friends Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group friends\n */\nclass BP_Tes"
  },
  {
    "path": "tests/testcases/groups/test-controller.php",
    "chars": 43381,
    "preview": "<?php\n/**\n * Group Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group group\n */\nclass BP_Test_RE"
  },
  {
    "path": "tests/testcases/groups/test-group-invites-controller.php",
    "chars": 24502,
    "preview": "<?php\n/**\n * Group Invites Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group group-invites\n */\n"
  },
  {
    "path": "tests/testcases/members/test-controller.php",
    "chars": 33866,
    "preview": "<?php\n/**\n * BuddyPress Members Endpoints Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group members\n */\n"
  },
  {
    "path": "tests/testcases/membership/test-group-membership-controller.php",
    "chars": 48721,
    "preview": "<?php\n/**\n * Group Membership Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group group-membershi"
  },
  {
    "path": "tests/testcases/membership/test-group-membership-request-controller.php",
    "chars": 22968,
    "preview": "<?php\n/**\n * Group Membership Request Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group group-m"
  },
  {
    "path": "tests/testcases/messages/test-controller.php",
    "chars": 37830,
    "preview": "<?php\n\n/**\n * Messages Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group messages\n */\nclass BP_"
  },
  {
    "path": "tests/testcases/notifications/test-controller.php",
    "chars": 26012,
    "preview": "<?php\n/**\n * Notifications Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group notifications\n */\n"
  },
  {
    "path": "tests/testcases/signup/test-controller.php",
    "chars": 24150,
    "preview": "<?php\n/**\n * Signup Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group signup\n */\nclass BP_Test_"
  },
  {
    "path": "tests/testcases/sitewide-notices/test-controller.php",
    "chars": 19295,
    "preview": "<?php\n/**\n * Sitewide Notices Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group notices\n */\ncla"
  },
  {
    "path": "tests/testcases/xprofile/test-data-controller.php",
    "chars": 25883,
    "preview": "<?php\n/**\n * XProfile Data Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group xprofile-data\n */\n"
  },
  {
    "path": "tests/testcases/xprofile/test-field-controller.php",
    "chars": 20895,
    "preview": "<?php\n/**\n * XProfile Field Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group xprofile-field\n *"
  },
  {
    "path": "tests/testcases/xprofile/test-group-controller.php",
    "chars": 18354,
    "preview": "<?php\n/**\n * XProfile Field Groups Endpoint Tests.\n *\n * @package BuddyPress\n * @subpackage BP_REST\n * @group xprofile-g"
  },
  {
    "path": "wp-env.json",
    "chars": 161,
    "preview": "{\n  \"core\": \"WordPress/WordPress#master\",\n  \"plugins\": [\"buddypress/buddypress#master\", \".\"],\n  \"config\": {\n    \"WP_DEBU"
  }
]

About this extraction

This page contains the full source code of the buddypress/BP-REST GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 59 files (1.1 MB), approximately 330.1k tokens, and a symbol index with 1161 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!