wordpress 对未登录用户 禁用 rest api
wordpress 默认是启用 rest api 的,如果强制关闭,对后台的操作还是有影响的。好在 wordpress 足够灵活。可以针对未登录的用户禁用 rest api
wordpress 对未登录用户 禁用 rest api
 add_filter('rest_authentication_errors', function () {
     if (!is_user_logged_in()) {
         // return new \WP_Error(403, 'not allowed');
         header('HTTP/1.1 404 Not Found');
         header('Status: 404 Not Found');
         echo "404";
         exit();
     }
 });