babble
babble copied to clipboard
Add WP REST API support
It would be awesome to build in support for the upcoming API in WordPress. The fix of PR #182 is a start of it.
I recently resolved this with the following:
/**
* Prevent Babble from interfering with REST API requests
*/
function babble_wp_json_compat( $rules ) {
global $wp_rewrite;
// From rest_api_register_rewrites()
$rest_rules = array(
'^' . rest_get_url_prefix() . '/?$',
'^' . rest_get_url_prefix() . '/(.*)?',
'^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$',
'^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?',
);
return array_merge( $rules, $rest_rules );
}
add_filter( 'bbl_non_translated_queries', 'babble_wp_json_compat' );
It assumes that translated REST routes aren't needed, but it's sufficient for my need (for the moment).