From 55f3f0c2fd0df909e5bbcb986cb2954a4a14d87a Mon Sep 17 00:00:00 2001 From: dwindown Date: Thu, 20 Nov 2025 00:44:45 +0700 Subject: [PATCH] debug: Add comprehensive logging to trace route registration Added logging at 3 critical points: 1. rest_api_init hook firing 2. Before ProductsController::register_routes() 3. After ProductsController::register_routes() 4. Inside ProductsController::get_products() This will show us: - Is rest_api_init hook firing? - Is ProductsController being registered? - Is get_products() being called when we hit /products? Expected log sequence: 1. WooNooW Routes: rest_api_init hook fired 2. WooNooW Routes: Registering ProductsController routes 3. WooNooW Routes: ProductsController routes registered 4. WooNooW ProductsController::get_products() CALLED (when API called) If any are missing, we know where the problem is. --- includes/Api/ProductsController.php | 1 + includes/Api/Routes.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/includes/Api/ProductsController.php b/includes/Api/ProductsController.php index 2f2f193..30b0fbf 100644 --- a/includes/Api/ProductsController.php +++ b/includes/Api/ProductsController.php @@ -85,6 +85,7 @@ class ProductsController { * Get products list with filters */ public static function get_products(WP_REST_Request $request) { + error_log('WooNooW ProductsController::get_products() CALLED'); $page = max(1, (int) $request->get_param('page')); $per_page = min(100, max(1, (int) ($request->get_param('per_page') ?: 20))); $search = $request->get_param('search'); diff --git a/includes/Api/Routes.php b/includes/Api/Routes.php index 59a209e..c2903db 100644 --- a/includes/Api/Routes.php +++ b/includes/Api/Routes.php @@ -25,6 +25,7 @@ class Routes { OrdersController::init(); add_action('rest_api_init', function () { + error_log('WooNooW Routes: rest_api_init hook fired'); $namespace = 'woonoow/v1'; // Auth endpoints (public - no permission check) @@ -92,7 +93,9 @@ class Routes { $activity_log_controller->register_routes(); // Products controller + error_log('WooNooW Routes: Registering ProductsController routes'); ProductsController::register_routes(); + error_log('WooNooW Routes: ProductsController routes registered'); }); } }