In WordPress 4.4, the long awaited JSON REST API has been added. This is a great plugin for developers, but for many site owners it is simply useless. In this article, we will show you how to easily disable the JSON REST API in WordPress.
Why Do I Need To Disable The JSON REST API In WordPress?
There is no doubt that the API will bring many new features for WordPress developers. However, some site owners simply do not need such features. The API makes it very easy to get data using GET requests. This is very useful for developing applications with WordPress.
And all this potentially opens your site to a new front of DDoS attacks, which can take a lot of resources and, as a result, slow down your site.
This method is similar to turning off XML-RPC, as many administrators have already done on their WordPress sites just in case.
Disable JSON REST API In WordPress
If you want to disable the JSON REST API on your WordPress site, you can do it by simply adding the following code to the functions.php file of your theme or to the plugin for the WordPress site :
1 |
add_filter( 'json_enabled' , '__return_false' ); |
2 |
add_filter( 'json_jsonp_enabled' , '__return_false' ); |
The code uses built-in filters to disable JSON and JSONP API.
For those who do not want to manually add code, you can install and activate the Disable JSON API plugin . The plugin works out of the box, and does not contain additional options for its configuration. Simple activation plugin will disable the API on your site.
We hope this article has helped you learn how to disable Disable JSON API in WordPress