Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re: Issue #82 adds support for Theme Hook Alliance hooks. @zamoose/th…

…emehookalliance
  • Loading branch information...
commit 7d4973b2745c2bbbbe86408d2df5239677a43a2a 1 parent b7e8e47
Chip Bennett authored
Showing with 467 additions and 16 deletions.
  1. +240 −16 functions/hooks.php
  2. +227 −0 tha/tha-theme-hooks.php
256 functions/hooks.php
View
@@ -31,6 +31,40 @@
*/
/**
+ * Action hook after div#content
+ *
+ * This action hook fires after the div#content container. It
+ * can be used to add content after div#content is output.
+ *
+ * Template file: footer.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_content_after() {
+ do_action( 'oenology_hook_content_after' );
+ tha_content_after();
+}
+
+/**
+ * Action hook before div#content
+ *
+ * This action hook fires before the div#content container. It
+ * can be used to add content before div#content is output.
+ *
+ * Template file: header.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_content_before() {
+ do_action( 'oenology_hook_content_before' );
+ tha_content_before();
+}
+
+/**
* Action hook after content within div#extent
*
* This action hook fires after content is output in the div#extent container. It
@@ -76,6 +110,7 @@ function oenology_hook_extent_before() {
*/
function oenology_hook_loop_footer_after() {
do_action( 'oenology_hook_loop_footer_after' );
+ tha_content_bottom();
}
/**
@@ -124,12 +159,13 @@ function oenology_hook_loop_header_after() {
*/
function oenology_hook_loop_header_before() {
do_action( 'oenology_hook_loop_header_before' );
+ tha_content_top();
}
/**
- * Action hook after content within div.post
+ * Action hook after div.post
*
- * This action hook fires after content is output in the div.post container. It
+ * This action hook fires after the div.post container. It
* can be used to add content after post content is output.
*
* Template file: loop.php
@@ -140,12 +176,13 @@ function oenology_hook_loop_header_before() {
*/
function oenology_hook_post_after() {
do_action( 'oenology_hook_post_after' );
+ tha_entry_after();
}
/**
- * Action hook before content within div.post
+ * Action hook before div.post
*
- * This action hook fires before content is output in the div.post container. It
+ * This action hook fires before the div.post container. It
* can be used to add content before post content is output.
*
* Template file: loop.php
@@ -156,6 +193,41 @@ function oenology_hook_post_after() {
*/
function oenology_hook_post_before() {
do_action( 'oenology_hook_post_before' );
+ tha_entry_before();
+}
+
+/**
+ * Action hook after content within div.post
+ *
+ * This action hook fires after content is output in the div.post container. It
+ * can be used to add content after post content is output.
+ *
+ * Template file: loop.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_post_bottom() {
+ do_action( 'oenology_hook_post_bottom' );
+ tha_entry_bottom();
+}
+
+/**
+ * Action hook before content within div.post
+ *
+ * This action hook fires before content is output in the div.post container. It
+ * can be used to add content before post content is output.
+ *
+ * Template file: loop.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_post_top() {
+ do_action( 'oenology_hook_post_top' );
+ tha_entry_top();
}
/**
@@ -172,6 +244,7 @@ function oenology_hook_post_before() {
*/
function oenology_hook_post_comments_after() {
do_action( 'oenology_hook_post_comments_after' );
+ tha_comments_after();
}
/**
@@ -188,6 +261,7 @@ function oenology_hook_post_comments_after() {
*/
function oenology_hook_post_comments_before() {
do_action( 'oenology_hook_post_comments_before' );
+ tha_comments_before();
}
/**
@@ -285,6 +359,107 @@ function oenology_hook_post_header_after() {
function oenology_hook_post_header_before() {
do_action( 'oenology_hook_post_header_before' );
}
+/**
+ * Action hook after div#sidebar-doublecol
+ *
+ * This action hook fires after the div#sidebar-doublecol container. It
+ * can be used to add content after post content is output.
+ *
+ * Template file: sidebar.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_sidebars_after() {
+ do_action( 'oenology_hook_sidebars_after' );
+ tha_sidebars_after();
+}
+
+/**
+ * Action hook before div#sidebar-doublecol
+ *
+ * This action hook fires before the div#sidebar-doublecol container. It
+ * can be used to add content before post content is output.
+ *
+ * Template file: sidebar.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_sidebars_before() {
+ do_action( 'oenology_hook_sidebars_before' );
+ tha_sidebars_before();
+}
+
+/**
+ * Action hook after content within div#sidebar-doublecol
+ *
+ * This action hook fires after content is output in the div#sidebar-doublecol container. It
+ * can be used to add content after post content is output.
+ *
+ * Template file: sidebar.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_sidebars_bottom() {
+ do_action( 'oenology_hook_sidebars_bottom' );
+ tha_sidebar_bottom();
+}
+
+/**
+ * Action hook before content within div#sidebar-doublecol
+ *
+ * This action hook fires before content is output in the div#sidebar-doublecol container. It
+ * can be used to add content before post content is output.
+ *
+ * Template file: sidebar.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_sidebars_top() {
+ do_action( 'oenology_hook_sidebars_top' );
+ tha_sidebar_top();
+}
+
+/**
+ * Action hook after div#footer
+ *
+ * This action hook fires after the div#footer container. It
+ * can be used to add content after site footer is output.
+ *
+ * Template file: footer.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_site_footer_after() {
+ do_action( 'oenology_hook_site_footer_after' );
+ tha_footer_after();
+}
+
+/**
+ * Action hook before div#footer
+ *
+ * This action hook fires before the div#footer container. It
+ * can be used to add content before site footer is output.
+ *
+ * Template file: footer.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_site_footer_before() {
+ do_action( 'oenology_hook_site_footer_before' );
+ tha_footer_before();
+}
/**
* Action hook after content within div#footer
@@ -298,8 +473,9 @@ function oenology_hook_post_header_before() {
*
* @since Oenology 2.0
*/
-function oenology_hook_site_footer_after() {
- do_action( 'oenology_hook_site_footer_after' );
+function oenology_hook_site_footer_text_after() {
+ do_action( 'oenology_hook_site_footer_text_after' );
+ tha_footer_bottom();
}
/**
@@ -314,15 +490,16 @@ function oenology_hook_site_footer_after() {
*
* @since Oenology 2.0
*/
-function oenology_hook_site_footer_before() {
- do_action( 'oenology_hook_site_footer_before' );
+function oenology_hook_site_footer_text_before() {
+ do_action( 'oenology_hook_site_footer_text_before' );
+ tha_footer_top();
}
/**
- * Action hook after content within div#site-header-text
+ * Action hook after div#header
*
- * This action hook fires after content is output in the div#site-header-text container. It
- * can be used to add content after site header text is output.
+ * This action hook fires after the div#header container. It
+ * can be used to add content after site header is output.
*
* Template file: header.php
*
@@ -332,13 +509,14 @@ function oenology_hook_site_footer_before() {
*/
function oenology_hook_site_header_after() {
do_action( 'oenology_hook_site_header_after' );
+ tha_header_after();
}
/**
- * Action hook before content within div#site-header-text
+ * Action hook before div#header
*
- * This action hook fires before content is output in the div#site-header-text container. It
- * can be used to add content before site header text is output.
+ * This action hook fires before the div#header container. It
+ * can be used to add content before site header is output.
*
* Template file: header.php
*
@@ -348,6 +526,41 @@ function oenology_hook_site_header_after() {
*/
function oenology_hook_site_header_before() {
do_action( 'oenology_hook_site_header_before' );
+ tha_header_before();
+}
+
+/**
+ * Action hook after content within div#site-header-text
+ *
+ * This action hook fires after content is output in the div#site-header-text container. It
+ * can be used to add content after site header text is output.
+ *
+ * Template file: site-header.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_site_header_text_after() {
+ do_action( 'oenology_hook_site_header_text_after' );
+ tha_header_bottom();
+}
+
+/**
+ * Action hook before content within div#site-header-text
+ *
+ * This action hook fires before content is output in the div#site-header-text container. It
+ * can be used to add content before site header text is output.
+ *
+ * Template file: site-header.php
+ *
+ * @uses do_action()
+ *
+ * @since Oenology 2.0
+ */
+function oenology_hook_site_header_text_before() {
+ do_action( 'oenology_hook_site_header_text_before' );
+ tha_header_top();
}
@@ -405,7 +618,7 @@ function oenology_hook_loop_header() {
// If this is an archive index
if( is_archive() ) {
// If this is a taxonomy archive
- if ( is_category() || is_tag() || is_tax( '', get_post_format() ) ) {
+ if ( is_category() || is_tag() || is_tax() ) {
// If this is a category or tag archive
if ( is_category() || is_tag() ) {
$tax = ( is_category() ? 'category' : 'tag' );
@@ -419,7 +632,7 @@ function oenology_hook_loop_header() {
$taxdescription = ( $taxdesc ? $taxdesc : $taxdescdefault );
}
// If this is a Post Format archive
- elseif ( is_tax( '', get_post_format() ) ) {
+ elseif ( is_tax( 'post_format', 'post-format-' . get_post_format() ) ) {
$tax = get_post_format();
$taxtitle = get_post_format_string( $tax );
$taxfeedlink = get_post_format_link( $tax ) . '/feed/';
@@ -431,6 +644,17 @@ function oenology_hook_loop_header() {
}
}
}
+ // If this is a Custom Taxonoomy archive
+ elseif ( is_tax() ) {
+ global $wp_query;
+ $tax = $wp_query->query_vars['taxonomy'];
+ $term = $wp_query->query_vars['term'];
+ $taxobject = get_taxonomy( $tax );
+ $termobject = get_term_by( 'slug', $term, $tax );
+ $taxtitle = single_term_title( '', false );
+ $taxfeedlink = get_term_link( $term, $tax ) . '/feed/';
+ $taxdescription = $termobject->description;
+ }
$colorscheme = oenology_get_color_scheme();
$rssiconcolor = ( 'light' == $colorscheme ? 'original' : 'gray' );
$rssimageurl = get_template_directory_uri() . '/images/iconsweets2/' . $rssiconcolor . '/rss16.png';
227 tha/tha-theme-hooks.php
View
@@ -0,0 +1,227 @@
+<?php
+/**
+* Theme Hook Alliance hook stub list.
+*
+* @package themehookalliance
+* @version 1.0-draft
+* @since 1.0-draft
+* @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
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*/
+
+/**
+ * Define the version of THA support, in case that becomes useful down the road.
+ */
+define( 'THA_HOOKS_VERSION', '1.0-draft' );
+
+/**
+ * Themes and Plugins can check for tha_hooks using current_theme_supports( 'tha_hooks', $hook )
+ * to determine whether a theme declares itself to support this specific hook type.
+ *
+ * Example:
+ * <code>
+ * // Declare support for all hook types
+ * add_theme_support( 'tha_hooks', array( 'all' ) );
+ *
+ * // Declare support for certain hook types only
+ * add_theme_support( 'tha_hooks', array( 'header', 'content', 'footer' ) );
+ * </code>
+ */
+add_theme_support( 'tha_hooks', array(
+
+ /**
+ * As a Theme developer, use the 'all' parameter, to declare support for all
+ * hook types.
+ * Please make sure you then actually reference all the hooks in this file,
+ * Plugin developers depend on it!
+ */
+ 'all',
+
+ /**
+ * Themes can also choose to only support certain hook types.
+ * Please make sure you then actually reference all the hooks in this type
+ * family.
+ *
+ * When the 'all' parameter was set, specific hook types do not need to be
+ * added explicitly.
+ */
+ 'head',
+ 'header',
+ 'content',
+ 'entry',
+ 'comments',
+ 'sidebars',
+ '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.
+ */
+// 'core'
+) );
+
+/**
+ * Determines, whether the specific hook type is actually supported.
+ *
+ * Plugin developers should always check for the support of a <strong>specific</strong>
+ * hook type before hooking a callback function to a hook of this type.
+ *
+ * Example:
+ * <code>
+ * if ( current_theme_supports( 'tha_hooks', 'header' ) )
+ * add_action( 'tha_head_top', 'prefix_header_top' );
+ * </code>
+ *
+ * @param bool $bool true
+ * @param array $args The hook type being checked
+ * @param array $registered All registered hook types
+ *
+ * @return bool
+ */
+function tha_current_theme_supports( $bool, $args, $registered ) {
+ return in_array( $args[0], $registered[0] ) || in_array( 'all', $registered[0] );
+}
+add_filter( 'current_theme_supports-tha_hooks', 'tha_current_theme_supports', 10, 3 );
+
+/**
+* HTML <head> hooks
+*
+* $tha_supports[] = 'head';
+*/
+function tha_head_top() {
+ do_action( 'tha_head_top' );
+}
+
+function tha_head_bottom() {
+ do_action( 'tha_head_bottom' );
+}
+
+
+/**
+* Semantic <header> hooks
+*
+* $tha_supports[] = 'header';
+*/
+function tha_header_before() {
+ do_action( 'tha_header_before' );
+}
+
+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
+*
+* $tha_supports[] = 'content';
+*/
+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 <entry> hooks
+*
+* $tha_supports[] = 'entry';
+*/
+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
+*
+* $tha_supports[] = 'comments';
+*/
+function tha_comments_before() {
+ do_action( 'tha_comments_before' );
+}
+
+function tha_comments_after() {
+ do_action( 'tha_comments_after' );
+}
+
+/**
+* Semantic <sidebar> hooks
+*
+* $tha_supports[] = 'sidebar';
+*/
+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
+*
+* $tha_supports[] = 'footer';
+*/
+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' );
+}
Please sign in to comment.
Something went wrong with that request. Please try again.