我想在 WordPress rest api 中隐藏端点的定义...在 https://www.wpwhitesecurity.com/wp-json 的情况下我想返回一个 404 或一个空数组,而不是站点的端点列表。
一些想法?
谢谢!
最佳答案
从版本 4.4.0 开始存在 Hook rest_index,文档在 https://developer.wordpress.org/reference/hooks/rest_index/ 中描述:
This contains the data describing the API. This includes information about supported authentication schemes, supported namespaces, routes available on the API, and a small amount of data about the site.
下一个代码可以完美地满足我的需要:
function my_site_rest_index( $response ){
return array();
}
add_filter('rest_index', 'my_site_rest_index');
关于wordpress - 隐藏 WordPress Rest API 端点定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47568286/