Browse files

Think I've got this one ready for public comment.

  • Loading branch information...
1 parent 15b7b7e commit 233e1e80a3c7eebfd9813c421afcfe9b584f84cb @zamoose committed Jul 2, 2012
Showing with 88 additions and 0 deletions.
  1. +34 −0
  2. +18 −0 tha-example-index.php
  3. +36 −0 tha-theme-hooks.php
@@ -1,11 +1,36 @@
# Theme Hook Alliance #
+## Status ##
## What? ##
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.
## Why? ##
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.
+## What about WordPress? ##
+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.
+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.
+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.
+### When Core does it, Core wins ###
+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.
+### What if Core adds some (or all) of these filters? ###
+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.
+For example, if Core were to introduce a `before_header()` hook, we could (in theory) simply alter `tha_header_before()` as follows
+ 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.
## Conventions ##
* Hooks should be of the form `tha_` + `[section of the theme]` + `_[placement within block]`.
@@ -17,4 +42,13 @@ There have been [discussions](
* 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 `tha_sidebars_before/after` in the early goings.)
+## Usage ##
+1. Copy `tha-theme-hooks.php` to a directory inside of your theme; say, `include/`, for instance.
+2. Include `tha-theme-hooks.php` via `<?php include( 'include/tha-theme-hooks.php' ); ?>` in your `functions.php` or similar.
+3. Using `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*.
+4. Profit!
## Core Compatibility ##
+None, at the moment.
@@ -19,6 +19,24 @@
<div id="content">
<?php tha_content_top(); ?>
+ <!-- This roughly encapsulates The Loop portion of the layout -->
+ <?php tha_entry_before(); ?>
+ <div class="entry">
+ <?php tha_entry_top(); ?>
+ <h2>This is the title</h2>
+ <div class="itemtext">
+ Lorem ipsum and all that rot.
+ </div><!-- .itemtext -->
+ <?php tha_entry_bottom(); ?>
+ </div>
+ <?php tha_entry_after(); ?>
+ <!-- Close The Loop -->
+ <?php tha_comments_before(); ?>
+ <!-- comments_form() or similar goes here -->
+ <?php tha_comments_after(); ?>
<?php tha_content_bottom(); ?>
</div><!-- #content -->
<?php tha_content_after(); ?>
@@ -3,6 +3,8 @@
* Theme Hook Alliance hook stub list.
* @package themehookalliance
+* @version 1.0-draft
+* @since 1.0-draft
* @license GNU General Public License, v2 (or newer)
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +24,10 @@
define( 'THA_HOOKS_SUPPORT', true );
+ * Define the version of THA support, in case that becomes useful down the road.
+ */
+define( 'THA_HOOKS_VERSION', '1.0-draft')
* If/when WordPress Core implements similar methodology, themes and plugins will be
* able to check whether the version of THA supplied by the theme supports Core
* hooks.
@@ -79,6 +85,36 @@ function tha_content_bottom() {
+* Semantic <entry> hooks
+function tha_entry_before() {
+ do_action( 'tha_entry_before' );
+function tha_entry_after() {
+ do_action( 'tha_entry_after' );
+function tha_entry_top() {
+ do_action( 'tha_entry_top' );
+function tha_entry_bottom() {
+ do_action( 'tha_entry_bottom' );
+* Comments block hooks
+function tha_comments_before() {
+ do_action( 'tha_comments_before' );
+function tha_comments_after() {
+ do_action( 'tha_comments_after' );
* Semantic <sidebar> hooks
function tha_sidebars_before() {

0 comments on commit 233e1e8

Please sign in to comment.