傻大憨

wordpress禁用Rest API

将以下代码插入到functions.php文件中即可

add_filter("json_enabled", "__return_false");
add_filter("json_jsonp_enabled", "__return_false");
add_filter("rest_enabled", "__return_false");
add_filter("rest_jsonp_enabled", "__return_false");
remove_action("init", "rest_api_init");
remove_action("rest_api_init", "rest_api_default_filters", 10);
remove_action("parse_request", "rest_api_loaded");
remove_action("wp_head", "rest_output_link_wp_head", 10);
remove_action("template_redirect", "rest_output_link_header", 11);
remove_action("auth_cookie_malformed", "rest_cookie_collect_status");
remove_action("auth_cookie_expired", "rest_cookie_collect_status");
remove_action("auth_cookie_bad_username", "rest_cookie_collect_status");
remove_action("auth_cookie_bad_hash", "rest_cookie_collect_status");
remove_action("auth_cookie_valid", "rest_cookie_collect_status");
 
add_filter("rest_authentication_errors", function () {
    return new WP_Error("rest_disabled", __("The REST API on this site has been disabled."), ["status" => rest_authorization_required_code()]);
});
Published
Categorized as 建站知识 Tagged

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

推荐公司官网建站的wordpress企业主题

推荐3个最适合公司建站的wordpress企业主题,三种很经典的wordpress企业网站风格。

外贸老板用wordpress搭建独立站 需要懂哪些技术

越来越多的外贸老板,自己买wordpress模板,自己搭建外贸独立站。作为外贸老板,想要使用WordPress自己搭建独立站,需要了解一些基本的网站技术和概念。

用WordPress需要学习哪些编程知识

要使用WordPress搭建和管理网站,您需要掌握一些基本的编程知识。以下是一些关键的技能和概念。

wordpress建站必备的函数大全

wordpress主题二次开发时常用到的函数

挑选适合你业务的建站引擎

  在选择外贸建站程序时,挑选适合你业务需求的建站引擎是至关重要的一步。本文将为您提供一份全面的选购指南,帮助… Continue reading 挑选适合你业务的建站引擎

WordPress外贸建站服务的最佳实践

  在竞争激烈的外贸市场,成功建站不仅仅是网站的技术实现,更涉及到对业务的高效管理。本文将介绍一些WordPr… Continue reading WordPress外贸建站服务的最佳实践