WP_Route
WP_Route copied to clipboard
Match route to request
Problem:
Defined route:
WP_Route::get('flights', 'callbackFn');
Any of the following request URIs will match with the above route definition and 'callbackFn' get fired: "/flight", "/anytext", "/tttttttt", "eeee" ...etc
Fix:
An additional utility method called "matchRouteToRequest" has been added. Then, we add a filter inside the 'handler' to filter-out the routes with a pattern that do not match the requested URI.