debug: Check if callback is actually callable

Testing if [__CLASS__, 'get_products'] is callable.
If NO, PHP cannot call the method (maybe method doesn't exist or wrong visibility).
If YES but still not called, WordPress routing issue.
This commit is contained in:
dwindown
2025-11-20 00:52:20 +07:00
parent 4b6459861f
commit b91c8bff61

View File

@@ -27,9 +27,13 @@ class ProductsController {
error_log('WooNooW ProductsController::register_routes() START');
// List products
$callback = [__CLASS__, 'get_products'];
$is_callable = is_callable($callback);
error_log('WooNooW ProductsController: Callback is_callable: ' . ($is_callable ? 'YES' : 'NO'));
$result = register_rest_route('woonoow/v1', '/products', [
'methods' => 'GET',
'callback' => [__CLASS__, 'get_products'],
'callback' => $callback,
'permission_callback' => [Permissions::class, 'check_admin_permission'],
]);
error_log('WooNooW ProductsController: GET /products registered: ' . ($result ? 'SUCCESS' : 'FAILED'));