傻大憨

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文章模板

在写文章的时候选择不同的文章形式,然后打开文章的时候会调用不同文章形式的模板。比如,文章形式为video ,就调用single-video.php模板,其它文章形式类似,可以添加多个文章样式。

文心一言与SORA在WP企业网站程序开发中的对比

本文将对比文心一言与SORA在WordPress企业网站首页程序开发中的应用,并深入探讨文心一言在这一领域的优势。

买WordPress主题一定要找原创开发者购买正版

买WordPress主题自建网站,为什么一定要找主题的原创开发者购买正版?为什么一定要认准主题开发者的官网?以及使用盗版WordPress主题会带来哪些严重后果。

wordpress父页面调用子页面标题

在服务项目父页面通过以下代码,调用出子页面的标题

禁用WordPress中的搜索功能

以下代码可以禁止使用wordpress中的搜索功能

如何在wordpress顶部header.php中引用css/bootstrap.css文件

在 WordPress 的 header.php 文件中引用 CSS 文件(如 bootstrap.css)是实现主题样式化的一种常见方式。以下是具体的步骤和代码示例