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

Init the BP REST API.


Parameters Parameters

$controllers

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

Default value: array()


Source Source

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

	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 5.0.0
			 *
			 * @param array $controllers The list of BP 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 ) ) {
					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 5.0.0
		 */
		do_action( 'bp_' . $this->id . '_rest_api_init' );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.