API / Minn\Runtime / AdminActionController

AdminActionController final readonly class

Minn\Runtime\AdminActionController · public/minn/src/Minn/Runtime/AdminActionController.php · 138 lines

The wp-admin pages a plugin answers itself. The admin is Minn Admin, so the engine draws no wp-admin screen, but a page builder opens its editor from one: Elementor's "Edit with Elementor" is post.php?post=N&action=elementor, whose handler (admin_action_elementor) prints a whole page of its own and ends the request before any screen is drawn.

A request to a wp-admin page that names an action boots as an admin request, as the reference's does. The admin cookie (scoped to /wp-admin) is asked for, for the user the request is read as; without it the visitor signs in and comes back. admin_init fires, then the action's handlers. When no plugin handles the action, or its handlers return, the request lands in Minn Admin, where every other wp-admin address goes.

One page is an endpoint instead: the media modal's uploader posts its files to async-upload.php (action upload-attachment), which the reference answers as an ajax request, in plain text. After the page's action the upload runs the handlers registered for the upload-attachment ajax action, as admin-ajax.php would: WordPress's own answer comes with the Minn Legacy Pack, the plugin that brings the modal.

Constants and properties

privatePAGE = '#^/wp-admin/[a-z0-9-]+\\.php$#'
privateUPLOAD = '/wp-admin/async-upload.php'
privatePOST = '/wp-admin/admin-post.php'
privatereadonly Minn\Auth\Cookie $cookie

Promoted from the constructor.

privatereadonly Minn\Front\Permalinks $permalinks

Promoted from the constructor.

Public

new__construct(Minn\Auth\Cookie $cookie, Minn\Front\Permalinks $permalinks)#
staticclaims(Minn\Http\Request $request): bool#

Whether a request is for a wp-admin page with an action to run, which the runtime boots as an admin request.

staticuploads(Minn\Http\Request $request): bool#

Whether a request is the media modal's upload, which the reference answers as an ajax request (DOING_AJAX).

methoddispatch(Minn\Http\Request $request): Minn\Http\Response* /wp-admin/{page:[a-z0-9-]+\.php} (public)#

Runs the handlers a plugin hooked for the action, or sends the visitor on.

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatepost(Minn\Http\Request $request): Minn\Http\Response#

admin-post.php, where plugins' forms post, as the reference answers it (runtime suite, "admin-post.php"): an admin request with the admin headers, admin_init, then admin_post_{action} for someone signed in (by the admin cookie, else the front end's) or admin_post_nopriv_{action} for a visitor, and admin_post or admin_post_nopriv when no action is named. A named action nobody handles is a 400; what the handlers print is the page, and a handler that redirects and exits sends its redirect.

privateupload(string $action): Minn\Http\Response#

The upload, answered in plain text from the first byte a handler prints. A handler ends the request with its answer; when none does, the answer is admin-ajax.php's for an action nobody handles.

privateaction(Minn\Http\Request $request): ?string#

The action the request names, the posted field over the query's, or null when there is none.