Skip to content

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

@calvinalkan

Description

@calvinalkan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions