[wp-trac] [WordPress Trac] #45186: Admin notice jumps from above the H1 to below it when created.

WordPress Trac noreply at wordpress.org
Mon Jul 11 23:10:26 UTC 2022

#45186: Admin notice jumps from above the H1 to below it when created.
 Reporter:  dschalk         |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:  4.9.8
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |     Focuses:  ui, administration

Comment (by SergeyBiryukov):

 Replying to [comment:6 elpanda13@…]:
 > At this point maybe we can fix it by requiring "options-head.php"
 directly below the H1 on each of the settings page, it seems harmless at
 this point.

 Hi there, thanks for the investigation and the patch!

 It looks like the associated JS code that moves the notice after the first
 heading was introduced for WordPress 2.7 in [9569], and further adjusted
 in [9626], [11837], [11858], [13446], [31023], [32974], [35238], [35516],
 [36134], [38983]. Setting the version accordingly.

 Since `options-head.php` has some back-compat code for plugins not using
 the Settings API, instead of explicitly including that file on option
 screens, I wonder if a cleaner solution might be to call just
 `settings_errors()` directly, like we already do on Privacy screens:
 * [source:tags/6.0/src/wp-admin/erase-personal-data.php?marks=108#L103
 Erase Personal Data]
 * [source:tags/6.0/src/wp-admin/export-personal-data.php?marks=108#L103
 Export Personal Data]

 See [attachment:45186.diff]. For non-core files, I think we still need to
 call `settings_errors()` in `options-head.php`, hence the `file_exists()`
 check with a comment. It might also be a good idea to think how plugins or
 themes could opt-in to a later `settings_errors()` call. Perhaps a new
 action, `admin_notices_after_title`, as suggested in comment:4, would be
 the way to go?

Ticket URL: <https://core.trac.wordpress.org/ticket/45186#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list