[wp-trac] [WordPress Trac] #47032: Rename wp_body_open hook and function
WordPress Trac
noreply at wordpress.org
Thu Apr 25 01:33:31 UTC 2019
#47032: Rename wp_body_open hook and function
-------------------------+-------------------------------------------------
Reporter: rilwis | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: trunk
Severity: normal | Keywords: dev-feedback 2nd-opinion needs-dev-
Focuses: template | note
-------------------------+-------------------------------------------------
The `wp_body_open` hook is added to v5.2 in this ticket #12563. However, I
think the naming is bad. The hook doesn't fit the context where the body
tag opens. It happens when the body tag already opened. We can tell in
another way: we don't know that hook fires before or after the tag is
opened by just looking into its name.
I suggest using the naming convention in the
[https://github.com/zamoose/themehookalliance#conventions Theme Hook
Alliance]:
- Hooks should be of the form `prefix_ + [section of the theme] +
_[placement within block]`.
- Hooks should be named based upon the generally-accepted semantic name
for the section of a theme they cover, e.g., `prefix_content_*` should
refer to the section/block of a theme containing the content (or "The
Loop"), while `prefix_sidebar_*` would refer to the sidebars generally
called by `get_sidebar()`.
- Hooks should be suffixed based upon their placement within a block.
- Hooks immediately preceding a block should use `_before`.
- Hooks immediately following a block should use `_after`.
- Hooks placed at the very beginning of a block should use `_top`.
- Hooks placed at the very end of a block should use `_bottom`.
- If the theme section covered by a hook can contain multiple semantic
elements, it should be pluralized. (Primarily applies to
`prefix_sidebars_before/after` in the early goings.)
In this case, the prefix is `wp_`, the block is `body`, so the hook should
be `wp_body_top`.
Benefit: this provides a consistent naming conversion for future hooks
that implemented in the themes by WordPress or by theme providers.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47032>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list