Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglascabral/2fdadd85144acff6321d053cd52b485d to your computer and use it in GitHub Desktop.
Save douglascabral/2fdadd85144acff6321d053cd52b485d to your computer and use it in GitHub Desktop.
<?php
add_filter( 'rest_endpoints', 'disable_default_endpoints' );
function disable_default_endpoints( $endpoints ) {
$allowed = ['/some/route/here'];
foreach ( $endpoints as $maybe_endpoint => $object ) {
if ( ! in_array($maybe_endpoint, $allowed) ) {
unset( $endpoints[ $maybe_endpoint ] );
}
}
return $endpoints;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment