BP_Component::rest_api_init( array $controllers = array() )

Init the BuddyBoss REST API.

Description

Parameters

$controllers

(Optional) The list of BP REST controllers to load.

Default value: array()

Source

File: bp-core/classes/class-bp-component.php

860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
public function rest_api_init( $controllers = array() ) {
    if ( is_array( $controllers ) && $controllers ) {
        // Built-in controllers.
        $_controllers = $controllers;
 
        /**
         * Use this filter to disable all or some REST API controllers
         * for the component.
         *
         * This is a dynamic hook that is based on the component string ID.
         *
         * @since BuddyBoss 1.3.5
         *
         * @param array $controllers The list of BuddyBoss REST API controllers to load.
         */
        $controllers = (array) apply_filters( 'bp_' . $this->id . '_rest_api_controllers', $controllers );
 
        foreach( $controllers as $controller ) {
            if ( ! in_array( $controller, $_controllers, true ) || ! class_exists( $controller ) ) {
                continue;
            }
 
            $component_controller = new $controller;
            $component_controller->register_routes();
        }
    }
 
    /**
     * Fires in the rest_api_init method inside BP_Component.
     *
     * This is a dynamic hook that is based on the component string ID.
     *
     * @since BuddyBoss 1.3.5
     */
    do_action( 'bp_' . $this->id . '_rest_api_init' );
}

Changelog

Changelog
Version Description
BuddyBoss 1.3.5 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.