[wp-trac] [WordPress Trac] #48887: Consistent use of wp_body_open() and body opening actions
WordPress Trac
noreply at wordpress.org
Thu Dec 5 17:29:43 UTC 2019
#48887: Consistent use of wp_body_open() and body opening actions
--------------------------------------+-----------------------------
Reporter: ramiy | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version:
Severity: normal | Keywords: has-patch
Focuses: administration, template |
--------------------------------------+-----------------------------
== Background ==
In changeset [changeset:"45042" 45042] WordPress 5.2 finally introduced
the long waited
[https://developer.wordpress.org/reference/functions/wp_body_open/
wp_body_open()] function which fires the
[https://developer.wordpress.org/reference/hooks/wp_body_open/
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 by `wp_head()`
* `wp_footer` action fired by `wp_footer()`
* `wp_body_open` action fired by `wp_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` action
* `admin_footer` action
Missing `admin_body_open` action.
=== Login Page ===
The login page uses the following action hooks:
* `login_head` action
* `login_footer` action
Missing `login_body_open` action.
=== Embed Templates ===
The embed templates uses the following action hooks:
* `embed_head` action
* `embed_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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48887>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list