Browse files

fixes #4

Makes placement of `tha_footer_bottom` and `tha_head_bottom` optional,
falling back to @obenland idea of hooking into the corresponding wp
standard hooks. Priority of `tha_body_bottom` moved higher then default
`wp_footer`. Also, a few whitespace cleanups.
  • Loading branch information...
1 parent 1f5b4e6 commit 662b2d13df74dda48a763f04074d32a20650b8f1 Ken Newman committed Nov 2, 2012
Showing with 18 additions and 14 deletions.
  1. +18 −14 tha-theme-hooks.php
View
32 tha-theme-hooks.php
@@ -18,9 +18,9 @@
* GNU General Public License for more details.
*/
-/**
- * Define the version of THA support, in case that becomes useful down the road.
- */
+/**
+ * Define the version of THA support, in case that becomes useful down the road.
+ */
define( 'THA_HOOKS_VERSION', '1.0-draft' );
/**
@@ -65,7 +65,7 @@
'sidebar',
'footer',
- /**
+ /**
* 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.
@@ -101,20 +101,22 @@ function tha_current_theme_supports( $bool, $args, $registered ) {
* Special case, useful for <DOCTYPE>, etc.
* $tha_supports[] = 'html;
*/
- function tha_html_before() {
- do_action( 'tha_html_before' );
- }
+function tha_html_before() {
+ do_action( 'tha_html_before' );
+}
/**
* HTML <body> hooks
* $tha_supports[] = 'body';
*/
- function tha_body_top() {
- do_action( 'tha_body_top' );
- }
+function tha_body_top() {
+ do_action( 'tha_body_top' );
+}
- function tha_body_bottom() {
- do_action( 'tha_body_bottom' );
- }
+function tha_body_bottom() {
+ if ( current_theme_supports( 'tha_hooks', 'body' ) && ! did_action( 'tha_body_bottom' ) )
+ do_action( 'tha_body_bottom' );
+}
+add_action( 'wp_footer', 'tha_body_bottom', 1 );
/**
* HTML <head> hooks
@@ -126,8 +128,10 @@ function tha_head_top() {
}
function tha_head_bottom() {
- do_action( 'tha_head_bottom' );
+ if ( current_theme_supports( 'tha_hooks', 'body' ) && ! did_action( 'tha_head_bottom' ) )
+ do_action( 'tha_head_bottom' );
}
+add_action( 'wp_head', 'tha_head_bottom', 1 );
/**
* Semantic <header> hooks

3 comments on commit 662b2d1

@WraithKenny
Owner

I used the Mac Github app. Not sure what happened to the whitespace in some of these. There's no change on lines 21-23, 68

@zamoose

Weird. Want me to reject and then you can submit another one?

@WraithKenny
Owner

it shouldn't have any effect, just looks weird on the diff.

Please sign in to comment.