From cbb438aa9573fc11366936eb5106ef261099f517 Mon Sep 17 00:00:00 2001 From: Nicolas Potier Date: Sat, 12 Dec 2020 22:48:25 +0100 Subject: [PATCH] Add Permission Callback in order ton be This is due to the recent change in WordPress Core: https://make.wordpress.org/core/2020/07/22/rest-api-changes-in-wordpress-5-5/ If permission_callback argument is not given, the following error will occur : Notice: register_rest_route was called incorrectly. The REST API route definition for wplf/v1/submit is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) --- wp-libre-form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/wp-libre-form.php b/wp-libre-form.php index 3e10299..f2c7b96 100644 --- a/wp-libre-form.php +++ b/wp-libre-form.php @@ -96,6 +96,7 @@ public static function load_our_textdomain() { public function register_rest_routes() { register_rest_route( 'wplf/v1', 'submit', [ 'methods' => 'POST', + 'permission_callback' => '__return_true', 'callback' => 'wplf_ajax_submit_handler', // admin-ajax handler, works but... // The REST API handbook discourages from using $_POST, and instead use $request->get_params() ]);