BP_REST_Settings_Endpoint::get_items( WP_REST_Request $request )
Retrieve settings.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-core/classes/class-bp-rest-settings-endpoint.php
public function get_items( $request ) {
$args = array();
/**
* Filter the query arguments for the request.
*
* @param array $args Key value array of query var to query value.
* @param WP_REST_Request $request The request sent to the API.
*
* @since 0.1.0
*/
$args = apply_filters( 'bp_rest_settings_get_items_query_args', $args, $request );
$bp_plugin_file = 'buddypress/bp-loader.php';
$bb_plugin_file = 'bbpress/bbpress.php';
$buddyboss_platform_plugin_file = 'buddyboss-platform/bp-loader.php';
$results = array();
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
// Check BuddyBoss Platform activate and get the settings.
if ( is_plugin_active( $buddyboss_platform_plugin_file ) ) {
$platform_settings = $this->get_buddyboss_platform_settings();
$results['platform'] = apply_filters( 'bp_rest_platform_settings', $platform_settings );
} else {
// Check BuddyPress activate and get the settings.
if ( is_plugin_active( $bp_plugin_file ) ) {
$buddypress_settings = $this->get_buddypress_settings();
$results['buddypress'] = apply_filters( 'bp_rest_buddypress_settings', $buddypress_settings );
}
// Check bbPress activate and get the settings.
if ( is_plugin_active( $bb_plugin_file ) ) {
$bbpress_settings = $this->get_bbpress_settings();
$results['bbpress'] = apply_filters( 'bp_rest_bbpress_settings', $bbpress_settings );
}
}
$response = rest_ensure_response( $results );
/**
* Fires after a list of settings is fetched via the REST API.
*
* @param WP_REST_Response $response The response data.
* @param WP_REST_Request $request The request sent to the API.
*
* @since 0.1.0
*/
do_action( 'bp_rest_settings_get_items', $response, $request );
return $response;
}
Changelog
| Version | Description |
|---|---|
| 0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.