-
Notifications
You must be signed in to change notification settings - Fork 0
/
bp-rest-api.php
37 lines (31 loc) · 939 Bytes
/
bp-rest-api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* Plugin Name: BuddyPress REST API
* Plugin URI: https://github.com/BronsonQuick/BP-API
* Description: This plugin extends the WP JSON API to add endpoints for BuddyPress
* Author: Bronson Quick
* Version: 0.1
* Author URI: https://github.com/BronsonQuick/BP-API
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Register our new endpoints.
*/
function bp_rest_endpoints() {
// Check is BuddyPress is active.
if ( class_exists( 'BuddyPress' ) ) {
// If the activity component is loaded bring in the activity schema.
if ( bp_is_active( 'activity' ) ) {
/**
* BP_REST_Activity_Controller class.
*/
include_once( __DIR__ . '/lib/endpoints/class-bp-rest-activity-controller.php' );
$GLOBALS['bp_rest_activity_controller'] = $activity = new BP_REST_Activity_Controller();
$activity->register_routes();
}
}
}
add_action( 'rest_api_init', 'bp_rest_endpoints' );