Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (46 sloc) 5.078 kB
3569176 @zamoose More changes.
authored
1 # Theme Hook Alliance #
4af1908 @zamoose Initial commit
authored
2
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
3 ## Status ##
ecb7728 @zamoose Updating README to reflect the current state.
authored
4 **1.0**
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
5
be5dc26 @zamoose That extra space makes @github's Markdown parser go a bit nutty.
authored
6 ## What? ##
d8097bb @zamoose More README additions, more hooks.
authored
7 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](http://codex.wordpress.org/Plugin_API/Action_Reference/) and [template tags](http://codex.wordpress.org/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.
cfd7aab @zamoose Adding skeleton files.
authored
8
3569176 @zamoose More changes.
authored
9 ## Why? ##
d8097bb @zamoose More README additions, more hooks.
authored
10 There have been [discussions](http://www.wptavern.com/forum/themes-templates/494-standard-theme-hook-names.html) about implementing a common set of hooks, a [Trac ticket](http://core.trac.wordpress.org/ticket/18561#comment:92) and even an [initial pass](http://codex.wordpress.org/User_talk:Dcole07) at implementing something similar. However, for whatever reason[s], these efforts have not gained traction. I proposed this third-party solution [here](http://literalbarrage.org/blog/2012/06/29/wordpress-theme-hook-alliance) and this project is intended to be an implementation of these goals.
3569176 @zamoose More changes.
authored
11
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
12 ## What about WordPress? ##
13 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.
14
15 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.
16
17 However, this is no reason to wait. Child themes have recently been approved for release in the official [Themes Repository](http://wordpress.org/extend/themes) and plugin authors continue to need more reliable entry points into WordPress' content flow so as to avoid nasty hacks like output buffering.
18
19 ### When Core does it, Core wins ###
20 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.
21
22 ### What if Core adds some (or all) of these filters? ###
23 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.
24
25 For example, if Core were to introduce a `before_header()` hook, we could (in theory) simply alter `tha_header_before()` as follows
26
31c07e7 @zamoose Force formatting for PHP.
authored
27 ```php
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
28 function tha_header_before() {
29 do_action( 'tha_header_before' );
30 do_action( 'before_header' );
31 }
31c07e7 @zamoose Force formatting for PHP.
authored
32 ```
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
33
34 This would allow all themes using the THA hooks to avoid rewriting/refactoring in the case of a Core change.
35
3569176 @zamoose More changes.
authored
36 ## Conventions ##
37
d8097bb @zamoose More README additions, more hooks.
authored
38 * Hooks should be of the form `tha_` + `[section of the theme]` + `_[placement within block]`.
39 * Hooks should be named based upon the generally-accepted semantic name for the section of a theme they cover, e.g., `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()`.
40 * Hooks should be suffixed based upon their placement within a block.
41 * Hooks immediately *preceding* a block should use `_before`.
42 * Hooks immediately *following* a block should use `_after`.
43 * Hooks placed at the very *beginning* of a block should use `_top`.
44 * Hooks placed at the very *end* of a block should use `_bottom`.
45 * 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.)
15b7b7e @zamoose README updates.
authored
46
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
47 ## Usage ##
48
49 1. Copy `tha-theme-hooks.php` to a directory inside of your theme; say, `include/`, for instance.
50 2. Include `tha-theme-hooks.php` via `<?php include( 'include/tha-theme-hooks.php' ); ?>` in your `functions.php` or similar.
51 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*.
52 4. Profit!
53
15b7b7e @zamoose README updates.
authored
54 ## Core Compatibility ##
ecb7728 @zamoose Updating README to reflect the current state.
authored
55 Working on it!
233e1e8 @zamoose Think I've got this one ready for public comment.
authored
56
c11a61d @zamoose Supported themes.
authored
57 ## THA-Compatible Themes ##
58 * **In-Progress**
59 * [Oenology](http://www.chipbennett.net/themes/oenology/) by Chip Bennett ([github](https://github.com/chipbennett/oenology))
60 * [Elbee Elgee](http://literalbarrage.org/blog/code/elbee-elgee) by Doug Stewart ([bitbucket](https://bitbucket.org/zamoose/elbee-elgee))
61 * **Full Support**
f5d5a31 @zamoose Adding Documentation to the list of themes supporting THA.
authored
62 * [The Bootstrap](http://wordpress.org/extend/themes/the-bootstrap) by Konstantin Obenland ([github](https://github.com/obenland/the-bootstrap))
63 * [Documentation](https://github.com/bueltge/Documentation) by Frank Bültge
Something went wrong with that request. Please try again.