Opened 5 years ago
Last modified 5 years ago
#48887 new enhancement
New action hooks: admin_body_open, login_body_open & embed_body_open
Reported by: | ramiy | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch |
Focuses: | administration, template | Cc: |
Description
Background
In changeset 45042 WordPress 5.2 finally introduced the long waited wp_body_open() function which fires the wp_body_open action hook immediately after the opening body
tag.
This little action helps developers to insert JavaScript right after the opening body tag required by 3rd party services like Google Tag Manager.
Dev note: https://make.wordpress.org/core/2019/04/24/miscellaneous-developer-updates-in-5-2/
We did a very good job but the hooks are not consistent on other pages (dashboard, login pages and embed templates). This will allow developers to insert code not only to the theme.
Theme Structure
The new theme structure uses several basic functions which fires action hooks:
wp_head
action fired bywp_head()
wp_footer
action fired bywp_footer()
wp_body_open
action fired bywp_body_open()
But the front end is not the only place where developers need to insert JavaScript.
WP Admin
The WordPress dashboard uses the following action hooks:
admin_head
actionadmin_footer
action
Missing admin_body_open
action.
Login Page
The login page uses the following action hooks:
login_head
actionlogin_footer
action
Missing login_body_open
action.
Embed Templates
The embed templates uses the following action hooks:
embed_head
actionembed_footer
action
Missing embed_body_open
action.
Other
The attached patch added the missing {$page}_body_open
hooks.
If you know about other pages that missed, please comment bellow and I'll update the patch.
fix wrong location in wp-admin/admin-header.php