SOHO创业

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 SOHO

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

如何在WordPress中通过post文章ID获取分类名称

这是个简单的方法,在WordPress中列出一篇文章的所属类别名称。通过以下这段代码就可以实现。

外贸建站服务商WaiMaoYes

歪猫建站(WaiMaoYes)是一家专注于外贸网站建设的公司,提供从建站策划、网页设计、前后端开发到运营推广的… Continue reading 外贸建站服务商WaiMaoYes

禁用WordPress中的搜索功能

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

The best independent website building platform for foreign trade

The best template website building platform

WordPress外贸建站平台引领市场潮流

  随着全球数字化的浪潮,WordPress外贸建站平台正以其强大的功能和灵活性,成为国际市场推广的新方向引领… Continue reading WordPress外贸建站平台引领市场潮流

俄贸SEO :专业的俄罗斯外贸网络营销推广与Yandex SEO服务商

俄贸SEO yandex-seo.com凭借其专业的服务和丰富的经验,已成为众多企业进入俄罗斯市场、提升品牌知名度和销售业绩的可靠选择。