WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 5 weeks ago

#20287 new enhancement

Load header and footer template files using hooks

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 1.5
Component: Themes Keywords: has-patch
Focuses: template Cc:

Description

The theme header and footer files are loaded from inside the get_header() and get_footer() functions.

If these files were instead loaded from helper functions that were hooked into actions inside get_header and get_footer then we'd get two nice benefits:

  1. Theme frameworks that call a function or fire an action immediately after the header would be able to use the hooks instead of placing the calls directly in each file. For example, Thematic calls thematic_abovecontainer() in each template file immediately after get_header(). It could instead add this via a hook.
  2. Fancy schmancy themes or plugins that add partial-page AJAX loading (using a system such as PJAX) could unhook the header and footer when they're unneeded in AJAX requests.

Patch coming up.

Attachments (2)

20287.patch (4.5 KB) - added by johnbillion 3 years ago.
20287.1.diff (2.4 KB) - added by MikeHansenMe 5 weeks ago.
refreshed

Download all attachments as: .zip

Change History (8)

@johnbillion3 years ago

comment:1 @johnbillion3 years ago

  • Keywords has-patch added

Patch. I might not have explained the use cases above very well. If it needs clarifying please let me know.

comment:2 @c3mdigital19 months ago

  • Keywords needs-refresh added
  • Version set to 1.5

Related #21506

comment:3 @bungeshea15 months ago

  • Cc info@… added

comment:4 @nacin13 months ago

  • Component changed from Template to Themes
  • Focuses template added

@MikeHansenMe5 weeks ago

refreshed

comment:5 @MikeHansenMe5 weeks ago

  • Keywords needs-refresh removed

comment:6 @obenland5 weeks ago

20287.1.diff looks incomplete, @MikeHansenMe.

@johnbillion: Should the get_(header|footer) action be moved inside the load functions? They're currently being used in a context where template loading happens immediately afterwards. I'd also suspect that in most cases where you wouldn't want header of footer to be loaded, you wouldn't want these actions to fire either.

Note: See TracTickets for help on using tickets.