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外贸建站优化新技巧 提升网站性能

  在外贸业务中,一个高性能的网站对于吸引国际客户和提升用户体验至关重要。本文将介绍一些最新的WordPres… Continue reading WordPress外贸建站优化新技巧 提升网站性能

wordpress调用当前页面ID

在wordpress调用当前页面ID代码

wordpress禁止多地同时登录

wordpress禁止用户在不同地点同时登录,管理员除外。

禁用WordPress中的搜索功能

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

用wordpress制作一个简单的插件案例

这只是一个简单的示例,用于演示如何创建WordPress插件。你可以根据自己的需求扩展和定制插件的功能。请参考WordPress官方文档以获取更多关于插件开发的详细信息和钩子函数的用法。

WordPress外贸网站建设的成功要素与技术点

  WordPress作为一款强大的建站平台,为外贸企业提供了丰富的功能和灵活的定制选项。在这篇文章中,我们将… Continue reading WordPress外贸网站建设的成功要素与技术点