Instantly share code, notes, and snippets.

Embed
What would you like to do?
Turn off Wordpress's default endpoint.
add_filter( 'rest_endpoints', function( $endpoints ){
if ( isset( $endpoints['/wp/v2/posts'] ) ) {
unset( $endpoints['/wp/v2'] );
}
if ( isset( $endpoints['/wp/v2/posts'] ) ) {
unset( $endpoints['/wp/v2/posts'] );
}
if ( isset( $endpoints['/wp/v2/posts'] ) ) {
unset( $endpoints['/wp/v2/posts'] );
}
if ( isset( $endpoints['/wp/v2/posts/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/posts/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/posts/(?P<parent>[\d]+)/revisions'] ) ) {
unset( $endpoints['/wp/v2/posts/(?P<parent>[\d]+)/revisions'] );
}
if ( isset( $endpoints['/wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/pages'] ) ) {
unset( $endpoints['/wp/v2/pages'] );
}
if ( isset( $endpoints['/wp/v2/pages/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/pages/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/pages/(?P<parent>[\d]+)/revisions'] ) ) {
unset( $endpoints['/wp/v2/pages/(?P<parent>[\d]+)/revisions'] );
}
if ( isset( $endpoints['/wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/media'] ) ) {
unset( $endpoints['/wp/v2/media'] );
}
if ( isset( $endpoints['/wp/v2/media/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/media/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/types'] ) ) {
unset( $endpoints['/wp/v2/types'] );
}
if ( isset( $endpoints['/wp/v2/types/(?P<type>[\w-]+)'] ) ) {
unset( $endpoints['/wp/v2/types/(?P<type>[\w-]+)types'] );
}
if ( isset( $endpoints['/wp/v2/statuses'] ) ) {
unset( $endpoints['/wp/v2/statuses'] );
}
if ( isset( $endpoints['/wp/v2/statuses/(?P<status>[\w-]+)'] ) ) {
unset( $endpoints['/wp/v2/statuses/(?P<status>[\w-]+)'] );
}
if ( isset( $endpoints['/wp/v2/taxonomies'] ) ) {
unset( $endpoints['/wp/v2/taxonomies'] );
}
if ( isset( $endpoints['/wp/v2/taxonomies/(?P<taxonomy>[\w-]+)'] ) ) {
unset( $endpoints['/wp/v2/taxonomies/(?P<taxonomy>[\w-]+)'] );
}
if ( isset( $endpoints['/wp/v2/categories'] ) ) {
unset( $endpoints['/wp/v2/categories'] );
}
if ( isset( $endpoints['/wp/v2/categories/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/categories/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/tags'] ) ) {
unset( $endpoints['/wp/v2/tags'] );
}
if ( isset( $endpoints['/wp/v2/tags/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/tags/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/users'] ) ) {
unset( $endpoints['/wp/v2/users'] );
}
if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/users/me'] ) ) {
unset( $endpoints['/wp/v2/users/me'] );
}
if ( isset( $endpoints['/wp/v2/comments'] ) ) {
unset( $endpoints['/wp/v2/comments'] );
}
if ( isset( $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] );
}
if ( isset( $endpoints['/wp/v2/settings'] ) ) {
unset( $endpoints['/wp/v2/settings'] );
}
return $endpoints;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment