Beginning in Breadcrumb NavXT 6.2, the REST API endpoints provided by Breadcrumb NavXT are no longer automatically enabled. Instead, the specific endpoints must be requested using the bcn_register_rest_endpoint
filter. Currently, there are three available endpoints: post, taxonomy, and author.
Below is an example of how to enable the Breadcrumb NavXT post endpoint. It is recommended to run this in the WordPress rest_api_init
action at a priority of 9 or higher. This is to ensure the filter is registered before Breadcrumb NavXT attempts to run it.
add_filter('bcn_register_rest_endpoint', 'my_bcn_endpoint_filter', 10, 4);
function my_bcn_endpoint_filter($register_rest_endpoint, $endpoint, $version, $methods)
{
if($endpoint === 'post')
{
$register_rest_endpoint = true;
}
return $register_rest_endpoint;
}
Enabling multiple endpoints is as simple as ORing checks of the value of $endpoint
in the if statement. One important behavior to note: if BCN_DISABLE_REST_API
is set to true, the Breadcrumb NavXT REST API will not be available. That is, an endpoint will be enabled if it is requested via the bcn_register_rest_endpoint
filter and BCN_DISABLE_REST_API
is set to false or is not set.
-John Havlik
[end of transmission, stay tuned]