-
-
Notifications
You must be signed in to change notification settings - Fork 0
Endpoints Helper
Mattias edited this page Aug 1, 2021
·
1 revision
The buildArray function registers new api endpoints. addTheActions registers defined endpoints with buildArray.
buildArray(string $namespace, string $route, array $args)
- namespace (string) (Required)
- route (string) (Required)
- args (array) (Required) Array of options for the endpoint.
endpoints()->buildArray('iroh', '/iroh-route', [
'methods' => 'POST',
'callback' => 'iroh_example_function',
'permission_callback' => '__return_true',
])->buildArray('iroh', '/iroh-route-1', [
'methods' => 'GET',
'callback' => 'iroh_example_function',
'permission_callback' => '__return_true',
])->addTheActions();
function iroh_example_function()
{
return wp_send_json('iroh', 200);
}