dev-master
9999999-dev https://github.com/zamoose/themehookallianceTheme Hook Alliance
GPL-2.0+
by Doug Stewart
wordpress
Theme Hook Alliance
1.0, (*1)
Child theme authors and plugin developers need a consistent set of entry points to allow for easy customization and altering of functionality. Core WordPress offers a suite of action hooks and template tags but does not cover many of the common use cases. The Theme Hook Alliance is a community-driven effort to agree on a set of third-party action hooks that THA themes pledge to implement in order to give that desired consistency., (*2)
There have been discussions about implementing a common set of hooks, a Trac ticket and even an initial pass at implementing something similar. However, for whatever reason[s], these efforts have not gained traction. I proposed this third-party solution here and this project is intended to be an implementation of these goals., (*3)
As stated above, there have been attempts to have something along these lines added to WordPress Core in the past and, while they have generally been seen as good ideas, they have remained as such., (*4)
Taking this out of the realm of Core and into the third-party realm is a bit of a risky proposition, to be sure. If the conventions laid out below are not adopted in a widespread fashion, this effort will ultimately fail., (*5)
However, this is no reason to wait. Child themes have recently been approved for release in the official Themes Repository and plugin authors continue to need more reliable entry points into WordPress' content flow so as to avoid nasty hacks like output buffering., (*6)
A small note: none of the proposed theme hooks are intended to replace or rewrite existing WordPress functionality. So, for instance, if a desired result can be obtained by filtering the output of e.g. the_content()
, there is no need to create an entirely new hook. Therefore, any functions that duplicate work Core performs already should be rejected immediately., (*7)
If this idea gains enough traction, there is a chance that a partial, or even full, portion of these hooks will make their way into Core. When/if this occurs, we can simply update tha-theme-hooks.php
to include the new do_action()
calls at the appropriate places. Then, THA users will simply need to update their copy of tha-theme-hooks.php
to take advantage., (*8)
For example, if Core were to introduce a before_header
hook, we could (in theory) simply alter tha_header_before
as follows, (*9)
function tha_header_before() { do_action( 'tha_header_before' ); do_action( 'before_header' ); }
This would allow all themes using the THA hooks to avoid rewriting/refactoring in the case of a Core change., (*10)
tha_
+ [section of the theme]
+ _[placement within block]
.tha_content_*
should refer to the section/block of a theme containing the content (or "The Loop"), while tha_sidebar_*
would refer to the sidebars generally called by get_sidebar()
._before
._after
._top
._bottom
.tha_sidebars_before/after
in the early goings.)tha-theme-hooks.php
to a directory inside of your theme; say, include/
, for instance.tha-theme-hooks.php
via <?php include( 'include/tha-theme-hooks.php' ); ?>
in your functions.php
or similar.tha-example-index.php
as a guide, be sure to implement all of the hooks described in tha-theme-hooks.php
in order to offer full compatibility.Working on it!, (*11)
In-Progress, (*12)
Full Support, (*13)
Theme Hook Alliance
GPL-2.0+
wordpress