wpemerge icon indicating copy to clipboard operation
wpemerge copied to clipboard

Impossible to create route urls from admin to web/ajax or vice versa

Open calvinalkan opened this issue 3 years ago • 0 comments

Version

  • WP Emerge: latest
  • WordPress: 5.6
  • PHP: 7.3

Expected behaviour

Trying to create a reverse route URL from a web route to an admin route is impossible and throws a Configuration Exception ( named route not found ).

Actual behaviour

Created a route to an admin page inside a web route creates an URL to that route.

Steps to reproduce (in case of a bug)

  1. Create an admin route with the name admin.foo
  2. Create a menu page using add_menu_page with the slug of foo
  3. Create any web route that just returns this
return App::routeUrl('admin.foo')

See the error message.

Comments

It's clear why this happens. The admin routes are never loaded for a web request and web routes are not loaded for admin requests.

This makes sense from a performance point but I don't know whether losing the described functionality was intended or just an unknown side effect.

calvinalkan avatar May 12 '21 17:05 calvinalkan