Skip to content
Corex

ScreenNotices

Corex\Config\AdminUi\ScreenNotices · class · Config layer

Moves what WordPress prints above the page into the CoreX shell, under the page header. ## What was wrong wp-admin/admin-header.php fires admin_notices and all_admin_notices as the first thing inside #wpbody-content, before the page callback runs. On a CoreX screen that is above the shell: core’s update nag sat in a band of its own and pushed the whole product 54px down the page, on every screen, on any site with a core update pending. WordPress’s own script moves a notice under the page heading, and skips one marked inline. The update nag is marked inline, so it stayed where it was printed. ## Why the output is captured, and not moved by a script or hidden A script would move the nag after the page had been drawn with it above the shell, so every load would jump by its height. Hiding it until a script had moved it would hide a security update from an administrator whenever that script did not run. Capturing the output on the server puts it in the right place in the first response. Everything the two hooks print is taken, not only the nag: a plugin’s notice marked inline has the same defect, and one that is not is moved by core’s script anyway. ## Why nothing can be lost The shell asks for the captured markup through the corex_admin_notices filter ({@see \Corex\Admin\AdminPage::open()}). A page under the CoreX menu that draws no shell never asks, so whatever is still held when the page callback has finished is printed there, as WordPress printed it. The markup is printed as it was captured. It is output WordPress and other plugins had already sent in this request, each having escaped its own; escaping it again here would remove the links, forms and scripts a notice is made of.

Hands the captured notices to the shell, once: a second shell in the same request gets nothing, so no notice is printed twice. A filter callback that also empties what it answers with. Answering without emptying would need a second call to say “printed”, and a filter has nowhere to make one.

Prints what no shell asked for, after the page callback and still inside the page body.