Permalink
Browse files

More README additions, more hooks.

  • Loading branch information...
1 parent 1c5f5a4 commit d8097bbaa590546b79fcbede0747579a3f206486 @zamoose committed Jul 2, 2012
Showing with 114 additions and 14 deletions.
  1. +10 −9 README.md
  2. +24 −4 tha-example-index.php
  3. +80 −1 tha-theme-hooks.php
View
@@ -1,17 +1,18 @@
# Theme Hook Alliance #
## What? ##
-Let's all come together and agree on a nice standard set of WordPress theme hooks.
+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.
## Why? ##
-Original idea [here](http://literalbarrage.org/blog/2012/06/29/wordpress-theme-hook-alliance).
+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.
## Conventions ##
-* Hooks should be of the form `tha_` + `[section of the theme]` + `_[placement within block]`
-* 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()`
-* Hooks should be suffixed based upon their placement within a block
- * Hooks immediately *preceding* a block should use `_before`
- * Hooks immediately *following* a block should use `_after`
- * Hooks placed at the very *beginning* of a block should use `_top`
- * Hooks placed at the very *end* of a block should use `_bottom`
+* Hooks should be of the form `tha_` + `[section of the theme]` + `_[placement within block]`.
+* 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()`.
+* Hooks should be suffixed based upon their placement within a block.
+ * Hooks immediately *preceding* a block should use `_before`.
+ * Hooks immediately *following* a block should use `_after`.
+ * Hooks placed at the very *beginning* of a block should use `_top`.
+ * 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.)
View
@@ -8,25 +8,45 @@
<body>
<?php tha_header_before(); ?>
<div id="header">
-
+ <?php tha_header_top(); ?>
+ <h1>This is an example page</h1>
+ <p class="dscription">This is to demonstrate a simple implementation of Theme Hook Alliance hooks.</p>
+ <?php tha_header_bottom(); ?>
</div><!-- #header -->
<?php tha_header_after(); ?>
+ <?php tha_content_before(); ?>
<div id="content">
<?php tha_content_top(); ?>
<?php tha_content_bottom(); ?>
</div><!-- #content -->
+ <?php tha_content_after(); ?>
<?php tha_sidebars_before(); ?>
<div id="sidebar">
-
+ <?php tha_sidebar_top(); ?>
+ <ul>
+ <li><h4>Sidebar Widget #1</h4>
+ <p>Widget #1 content</p>
+ </li>
+ <li><h4>Sidebar Widget #2</h4>
+ <p>Widget #2 content</p>
+ </li>
+ </ul>
+ <?php tha_sidebar_bottom(); ?>
</div><!-- #sidebar-->
<?php tha_sidebars_after(); ?>
+ <?php tha_footer_before(); ?>
<div id="footer">
-
+ <?php tha_footer_top(); ?>
+
+ <h3>Footer</h3>
+ <p>This is some sample footer text.</p>
+
+ <?php tha_footer_bottom(); ?>
</div><!-- #footer -->
-
+ <?php tha_footer_after(); ?>
</body>
</html>
View
@@ -1,5 +1,10 @@
<?php
-/*
+/**
+* Theme Hook Alliance hook stub list.
+*
+* @package themehookalliance
+* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
+*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -11,8 +16,21 @@
* GNU General Public License for more details.
*/
+/**
+ * Themes and plugins can check for THA_HOOKS_SUPPORT to determine whether a theme
+ * declares itself to support THA hooks.
+ */
define( 'THA_HOOKS_SUPPORT', true );
+/**
+ * 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.
+ */
+define( 'THA_CORE_SUPPORT', false );
+/**
+* HTML <head> hooks
+*/
function tha_head_top() {
do_action( 'tha_head_top' );
}
@@ -21,6 +39,10 @@ function tha_head_bottom() {
do_action( 'tha_head_bottom' );
}
+
+/**
+* Semantic <header> hooks
+*/
function tha_header_before() {
do_action( 'tha_header_before' );
}
@@ -29,10 +51,67 @@ function tha_header_after() {
do_action( 'tha_header_after' );
}
+function tha_header_top() {
+ do_action( 'tha_header_top' );
+}
+
+function tha_header_bottom() {
+ do_action( 'tha_header_bottom' );
+}
+
+/**
+* Semantic <content> hooks
+*/
+function tha_content_before() {
+ do_action( 'tha_content_before' );
+}
+
+function tha_content_after() {
+ do_action( 'tha_content_after' );
+}
+
function tha_content_top() {
do_action( 'tha_content_top' );
}
function tha_content_bottom() {
do_action( 'tha_content_bottom' );
+}
+
+/**
+* Semantic <sidebar> hooks
+*/
+function tha_sidebars_before() {
+ do_action( 'tha_sidebars_before' );
+}
+
+function tha_sidebars_after() {
+ do_action( 'tha_sidebars_after' );
+}
+
+function tha_sidebar_top() {
+ do_action( 'tha_sidebar_top' );
+}
+
+function tha_sidebar_bottom() {
+ do_action( 'tha_sidebar_bottom' );
+}
+
+/**
+* Semantic <footer> hooks
+*/
+function tha_footer_before() {
+ do_action( 'tha_footer_before' );
+}
+
+function tha_footer_after() {
+ do_action( 'tha_footer_after' );
+}
+
+function tha_footer_top() {
+ do_action( 'tha_footer_top' );
+}
+
+function tha_footer_bottom() {
+ do_action( 'tha_footer_bottom' );
}

0 comments on commit d8097bb

Please sign in to comment.