Filter
restropress_rest_api_get_rest_namespaces
On this page
Filters the REST API namespaces and the controllers registered for each.
Called when REST routes are registered on rest_api_init. The array maps a namespace (default rp/v1) to an array of controller keys and class names. Each class is instantiated and its register_routes() method is called.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$namespaces | array | Namespaces mapped to arrays of controller key => class name. |
Return value#
array. The namespaces and controllers.
Example#
function my_register_rest_controller( $namespaces ) {
$namespaces['rp/v1']['my_reports'] = 'My_REST_Reports_Controller';
return $namespaces;
}
add_filter( 'restropress_rest_api_get_rest_namespaces', 'my_register_rest_controller' );
Notes#
The class must exist and be loadable when the filter result is processed.
Source#
Applied in:
includes/rest-api/Server.php(line 74), inServer::get_rest_namespaces()
Was this page helpful?
