wordpress禁用REST API/移除wp-json链接的方法

付费节点推荐


免费节点


节点使用教程


WordPress 4.4更新新增了REST API功能,通过REST API可以很轻松的获取网站的数据,但是这个功能并不是每个网站都需要的,或者说我需要,但是并不希望他在head里面输出,所以给大家介绍下禁用REST API或者说移除head里面wp-json链接的方法。

禁用REST API
[cc lang=”php”]
add_filter(‘rest_enabled’, ‘_return_false’);
add_filter(‘rest_jsonp_enabled’, ‘_return_false’);

remove_action( ‘wp_head’, ‘rest_output_link_wp_head’, 10 );
remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’, 10 );
add_filter(‘rest_enabled’, ‘_return_false’);
add_filter(‘rest_jsonp_enabled’, ‘_return_false’);

remove_action( ‘wp_head’, ‘rest_output_link_wp_head’, 10 );
remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’, 10 );
[/cc]
将以上代码添加到主题functions.php文件中即可禁用REST API并去除head里面输出的链接信息。

未经允许不得转载:Bcoder资源网 » wordpress禁用REST API/移除wp-json链接的方法

相关推荐

更多优质资源关注微信公众号: bcoder

bcoder
赞 (0)
分享到:更多 ()

评论 0

评论前必须登录!

登陆 注册