[wp-trac] [WordPress Trac] #12563: New action on body open

WordPress Trac noreply at wordpress.org
Fri Oct 5 18:46:06 UTC 2018

#12563: New action on body open
 Reporter:  joostdevalk                      |       Owner:
                                             |  adamsilverstein
     Type:  enhancement                      |      Status:  assigned
 Priority:  normal                           |   Milestone:  4.9.9
Component:  Bundled Theme                    |     Version:  3.1
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch commit needs-dev-note  |     Focuses:  template

Comment (by lgedeon):

 Replying to [comment:52 joyously]:
 > There is one option that is purely core implementation. Add the new
 action as the last thing in `get_header`. Themes already are calling that
 and the header typically ends with the body tag (and a variable amount of
 tags after).

 The "variable amount of tags after" is a huge problem in many cases. Many
 plugins need to put something inside {{{<body>}}} but above those other
 tags. Even many themes need variable content in this position and have to
 implement their own hook or some custom function call.

 This ticket sets an example for future theme builders of a standard way to
 handle a common problem that will also be compatible with plugins. The
 examples set in the "twenty" series of plugins are often copied. Also with
 the {{{wp_body_open()}}} function in core we are establishing a stable
 name for this hook.

 From here the migration path involves:

 1. Theme makers copy the examples in the "twenty" themes.
 2. We probably make a plugin to do the filtering suggested by Mike
 Instead of inserting html here, fire the hook and ob_cache that output.
 Then insert that.
 3. Any plugin that requires this hook can use "doing it wrong" or a notice
 in wp-admin to request the site owner to add the hook or install the
 filtering plugin from step 2.
 4. Documentation across the web should be updated to inform everyone about
 the new hook.

 One thing that might help adoption, is that we can encourage people to add
 this themselves since the next version of the theme should be adding it

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

More information about the wp-trac mailing list