fix: make module settings GET endpoint public

- Shop page and other customer pages need to read module settings
- Settings are non-sensitive configuration values (e.g. wishlist display)
- POST endpoint remains admin-only for security
- Fixes 401 errors on shop page for /modules/wishlist/settings
This commit is contained in:
Dwindi Ramadhana
2025-12-31 22:01:06 +07:00
parent 285589937a
commit 0dd7c7af70

View File

@@ -32,12 +32,12 @@ class ModuleSettingsController extends WP_REST_Controller {
* Register routes * Register routes
*/ */
public function register_routes() { public function register_routes() {
// GET /woonoow/v1/modules/{module_id}/settings // GET /woonoow/v1/modules/{module_id}/settings (public - needed by frontend)
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<module_id>[a-zA-Z0-9_-]+)/settings', [ register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<module_id>[a-zA-Z0-9_-]+)/settings', [
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [$this, 'get_settings'], 'callback' => [$this, 'get_settings'],
'permission_callback' => [$this, 'check_permission'], 'permission_callback' => '__return_true', // Public: settings are non-sensitive, needed by customer pages
'args' => [ 'args' => [
'module_id' => [ 'module_id' => [
'required' => true, 'required' => true,