禁用 WordPress 的 JSON REST API

WordPress 4.4 默认集成了备受关注的 JSON REST API,这个对于开发者来说,无疑是非常有用的,通过 JSON REST API 可以在外部程序(当然,WP自身也OK)中很方便地调用 WordPress 网站的数据,比如可以用来制作app程序等。

2016-01-07_214517_wpdaxue_com

但是,对于大多数用户来说,这个功能是几乎用不到的了,JSON REST API 采用 GET 请求方式来获取数据,这个为 DDOS 攻击提供了一个新的攻击途径,就像 XML-RPC 接口一样,为了避免这个,我们可以在当前主题的 functions.php 文件中添加下面的代码即可禁用 JSON REST API :

/**
 * 禁用 WordPress 的 JSON REST API 
 * https://www.wpdaxue.com/disable-json-rest-api-in-wordpress.html
 */
add_filter('json_enabled', '__return_false');
add_filter('json_jsonp_enabled', '__return_false');

当然,如果你不会折腾代码,可以直接下载安装 Disable JSON API 插件激活即可,无需设置。

参考:http://www.wpbeginner.com/wp-tutorials/how-to-disable-json-rest-api-in-wordpress/

来源:

https://www.wpdaxue.com/disable-json-rest-api-in-wordpress.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32372.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?