diff --git a/packages/utils/src/Service.php b/packages/utils/src/Service.php index f164cbf..3112f65 100755 --- a/packages/utils/src/Service.php +++ b/packages/utils/src/Service.php @@ -49,7 +49,8 @@ public function rest_api_init() { $namespace = Service::getNamespace($this->getCore()); register_rest_route($namespace, '/plugin', [ 'methods' => 'GET', - 'callback' => [$this, 'routePlugin'] + 'callback' => [$this, 'routePlugin'], + 'permission_callback' => '__return_true' ]); } diff --git a/packages/utils/test/phpunit/ServiceTest.php b/packages/utils/test/phpunit/ServiceTest.php index 85ab12a..1826af9 100755 --- a/packages/utils/test/phpunit/ServiceTest.php +++ b/packages/utils/test/phpunit/ServiceTest.php @@ -28,7 +28,15 @@ public function testRestApiInit() { redefine(Service::class . '::getNamespace', always('test/v1')); WP_Mock::userFunction('register_rest_route', [ - 'args' => ['test/v1', '/plugin', ['methods' => 'GET', 'callback' => [Mockery::self(), 'routePlugin']]] + 'args' => [ + 'test/v1', + '/plugin', + [ + 'methods' => 'GET', + 'callback' => [Mockery::self(), 'routePlugin'], + 'permission_callback' => '__return_true' + ] + ] ]); $this->service->rest_api_init(); diff --git a/plugins/wp-reactjs-starter/src/inc/rest/HelloWorld.php b/plugins/wp-reactjs-starter/src/inc/rest/HelloWorld.php index 4946698..1c9acfd 100644 --- a/plugins/wp-reactjs-starter/src/inc/rest/HelloWorld.php +++ b/plugins/wp-reactjs-starter/src/inc/rest/HelloWorld.php @@ -31,7 +31,8 @@ public function rest_api_init() { $namespace = Service::getNamespace($this); register_rest_route($namespace, '/hello', [ 'methods' => 'GET', - 'callback' => [$this, 'routeHello'] + 'callback' => [$this, 'routeHello'], + 'permission_callback' => '__return_true' ]); }