Skip to content

Commit

Permalink
Merge pull request #512 from buddypress/feature/v2-changes
Browse files Browse the repository at this point in the history
Setting the plugin to V1
  • Loading branch information
renatonascalves authored Oct 2, 2024
2 parents 2dec281 + 9825e98 commit edb2ae6
Show file tree
Hide file tree
Showing 28 changed files with 96 additions and 165 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/coding-standards.yml

This file was deleted.

95 changes: 0 additions & 95 deletions .github/workflows/unit-tests.yml

This file was deleted.

23 changes: 3 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
# BuddyPress RESTful API

[![Project Status: Active.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![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

We have extensive documentation of each endpoint/components and their CRUD actions: <https://developer.buddypress.org/bp-rest-api/>

## System Requirements (relevant for CI tests only)

* PHP >= 7.4
* WP >= 6.1
* BuddyPress >= Latest

## Installation

Drop this plugin in the wp-content/plugins directory and activate it. You need at least [WordPress 6.1](https://wordpress.org/download/) and [BuddyPress](https://buddypress.org/download/) to use the plugin.

## About

WordPress is moving towards becoming a fully-fledged application framework. BuddyPress can benefit from this new API by adding endpoints to access social data.

This plugin provides an easy to use REST API Endpoints for BuddyPress, available via HTTP. Grab your
site's data in simple JSON format, including users, groups, xprofile and more.
Retrieving or updating data is as simple as sending a HTTP request.
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.
30 changes: 25 additions & 5 deletions bp-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,34 @@ function bp_rest() {
}
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_rest_request_blog_url( $request, $url ) {
function bp_filter_v1_rest_request_blog_url( $request, $url ) {

if ( ! bp_is_active( 'blogs' ) || empty( $url ) ) {
return $request;
Expand All @@ -200,7 +220,7 @@ function bp_filter_rest_request_blog_url( $request, $url ) {

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

/**
* Output BuddyPress blog response.
Expand All @@ -210,7 +230,7 @@ function bp_filter_rest_request_blog_url( $request, $url ) {
* @param WP_REST_Request $request Request used to generate the response.
* @return WP_REST_Response
*/
function bp_rest_post_dispatch( $response, $instance, $request ) {
function bp_filter_v1_rest_post_dispatch( $response, $instance, $request ) {
if (
! bp_is_active( 'blogs' )
|| 404 !== $response->get_status()
Expand Down Expand Up @@ -256,7 +276,7 @@ function bp_rest_post_dispatch( $response, $instance, $request ) {

restore_current_blog();

// Return it, regardless if it was successfull or not.
// Return it, regardless if it was successful or not.
return $response;
}
add_filter( 'rest_post_dispatch', 'bp_rest_post_dispatch', 10, 3 );
add_filter( 'rest_post_dispatch', 'bp_filter_v1_rest_post_dispatch', 10, 3 );
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,29 @@
"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",
".editorconfig",
"CHANGELOG.md",
"CONTRIBUTING.md",
"README.md",
".gitignore",
".distignore",
".deployignore",
".github/",
".phpcs/",
"tests/",
"bp-rest-api.zip",
"!vendor/"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class BP_REST_Activity_Endpoint extends WP_REST_Controller {
* @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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class BP_REST_Attachments_Blog_Avatar_Endpoint extends WP_REST_Controller {
* @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();
Expand Down
2 changes: 2 additions & 0 deletions includes/bp-blogs/classes/class-bp-rest-blogs-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BP_REST_Blogs_Endpoint extends WP_REST_Controller {
* @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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class BP_REST_Components_Endpoint extends WP_REST_Controller {
* @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';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BP_REST_Friends_Endpoint extends WP_REST_Controller {
* @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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class BP_REST_Attachments_Group_Avatar_Endpoint extends WP_REST_Controller {
* @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class BP_REST_Attachments_Group_Cover_Endpoint extends WP_REST_Controller {
* @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class BP_REST_Group_Invites_Endpoint extends WP_REST_Controller {
* @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class BP_REST_Group_Membership_Endpoint extends WP_REST_Controller {
* @since 0.1.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Groups_Membership_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = buddypress()->groups->id;
$this->groups_endpoint = new BP_REST_Groups_Endpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class BP_REST_Group_Membership_Request_Endpoint extends WP_REST_Controller {
* @since 0.1.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Groups_Membership_Request_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = buddypress()->groups->id . '/membership-requests';
$this->groups_endpoint = new BP_REST_Groups_Endpoint();
Expand Down
2 changes: 2 additions & 0 deletions includes/bp-groups/classes/class-bp-rest-groups-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class BP_REST_Groups_Endpoint extends WP_REST_Controller {
* @since 0.1.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Groups_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = buddypress()->groups->id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class BP_REST_Attachments_Member_Avatar_Endpoint extends WP_REST_Controller {
* @since 0.1.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Members_Avatar_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = 'members';
$this->avatar_instance = new BP_Attachment_Avatar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class BP_REST_Attachments_Member_Cover_Endpoint extends WP_REST_Controller {
* @since 6.0.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Members_Cover_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = 'members';
$this->attachment_instance = new BP_Attachment_Cover_Image();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BP_REST_Members_Endpoint extends WP_REST_Users_Controller {
* @since 0.1.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Members_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = 'members';
}
Expand Down
2 changes: 2 additions & 0 deletions includes/bp-members/classes/class-bp-rest-signup-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class BP_REST_Signup_Endpoint extends WP_REST_Controller {
* @since 6.0.0
*/
public function __construct() {
_deprecated_class( __CLASS__, '15.0.0', 'BP_Members_Signup_REST_Controller' );

$this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
$this->rest_base = 'signup';
}
Expand Down
Loading

0 comments on commit edb2ae6

Please sign in to comment.