<?php
/**
 * Oenology Theme Custom Hooks
 *
 * This file defines custom action and filter hooks for the Oenology Theme.
 *
 * The first section defines action hooks, which are used to append to Oenology Theme
 * template locations, and which are generally defined using terms descriptive of their
 * location, and suffixed with "_before" or "_after".
 *
 * The second section defines filter hooks, which are used to add to or to replace content
 * generated by Oenology Theme, and which are generally defined using terms descriptive of
 * their content function/location.
 *
 * In almost all cases, a given filter hook will have accompanying "_before" and "_after"
 * action hooks. This arrangement facilitates appending content before and/or after
 * Theme-generated content, or to change and/or replace entirely all Theme-generated content.
 *
 * For more information on hooks, actions, and filters, 
 * see {@link http://codex.wordpress.org/Plugin_API Plugin API}.
 * 
 * @package 	Oenology
 * @copyright	Copyright (c) 2011, Chip Bennett
 * @license		http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
 *
 * @since 		Oenology 2.0
 */

/**
 * Define custom action hooks
 */

/**
 * 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
 * can be used to add content after any other content is output.
 * 
 * Template file: footer.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_extent_after() {
	do_action( 'oenology_hook_extent_after' );
	tha_body_bottom();
}

/**
 * Action hook before content within div#extent
 * 
 * This action hook fires before content is output in the div#extent container. It
 * can be used to add content before any other content is output.
 * 
 * Template file: header.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_extent_before() {
	do_action( 'oenology_hook_extent_before' );
	tha_body_top();
}

/**
 * Action hook before html
 * 
 * This action hook fires before the HTML container tag. It
 * is a special case, useful for <DOCTYPE>, etc.
 * 
 * Template file: header.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 3.5
 */
function oenology_hook_html_before() {
	do_action( 'oenology_hook_html_before' );
	tha_html_before();
}



/**
 * Add DOCTYPE
 */
function oenology_doctype() {
	?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<?php
}
add_action( 'oenology_hook_html_before', 'oenology_doctype' );

/**
 * Action hook after content within div#loop-footer
 * 
 * This action hook fires after Loop footer content is output in the div#loop-footer container. It
 * can be used to add content after the Loop footer content is output.
 * 
 * Template file: loop.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_loop_footer_after() {
	do_action( 'oenology_hook_loop_footer_after' );
	tha_content_bottom();
}

/**
 * Action hook before content within div#loop-footer
 * 
 * This action hook fires before Loop footer content is output in the div#loop-footer container. It
 * can be used to add content before the Loop footer content is output.
 * 
 * Template file: loop.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_loop_footer_before() {
	do_action( 'oenology_hook_loop_footer_before' );
}

/**
 * Action hook after content within div#loop-header
 * 
 * This action hook fires after Loop header content is output in the div#loop-header container. It
 * can be used to add content after the Loop header text is output.
 * 
 * Template file: loop.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_loop_header_after() {
	do_action( 'oenology_hook_loop_header_after' );
}

/**
 * Action hook before content within div#loop-header
 * 
 * This action hook fires before Loop header content is output in the div#loop-header container. It
 * can be used to add content before the Loop header text is output.
 * 
 * Template file: loop.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_loop_header_before() {
	do_action( 'oenology_hook_loop_header_before' );
	tha_content_top();
	wp_body_open();
}

/**
 * Action hook before while loop if ( have_posts() )
 * 
 * This action hook fires after Loop content is output. It
 * can be used to add content after the Loop content is output.
 * 
 * Template file: loop.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 3.5
 */
function oenology_hook_loop_while_after() {
	do_action( 'oenology_hook_loop_while_after' );
	tha_content_while_after();
}

/**
 * Action hook after while loop if ( have_posts() )
 * 
 * This action hook fires before Loop content is output. It
 * can be used to add content before the Loop content is output.
 * 
 * Template file: loop.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 3.5
 */
function oenology_hook_loop_while_before() {
	do_action( 'oenology_hook_loop_while_before' );
	tha_content_while_before();
}

/**
 * Action hook after div.post
 * 
 * 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
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_after() {
	do_action( 'oenology_hook_post_after' );
	tha_entry_after();
}

/**
 * Action hook before div.post
 * 
 * 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
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
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();
}

/**
 * Action hook after content within div#comments
 * 
 * This action hook fires after content is output in the div#comments container. It
 * can be used to add content after post comments content is output.
 * 
 * Template file: comments.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_comments_after() {
	do_action( 'oenology_hook_post_comments_after' );
	tha_comments_after();
}

/**
 * Action hook before content within div#comments
 * 
 * This action hook fires before content is output in the div#comments container. It
 * can be used to add content before post comments content is output.
 * 
 * Template file: comments.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_comments_before() {
	do_action( 'oenology_hook_post_comments_before' );
	tha_comments_before();
}

/**
 * Action hook after content within div.post-entry
 * 
 * This action hook fires after content is output in the div.post-entry container. It
 * can be used to add content after post entry content is output.
 * 
 * Template file: post.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_entry_after() {
	do_action( 'oenology_hook_post_entry_after' );
	tha_entry_content_after();
}

/**
 * Action hook before content within div.post-entry
 * 
 * This action hook fires before content is output in the div.post-entry container. It
 * can be used to add content before post entry content is output.
 * 
 * Template file: post.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_entry_before() {
	do_action( 'oenology_hook_post_entry_before' );
	tha_entry_content_before();
}



/**
 * Add Post-Entry container for Post Format icon
 * 
 * @uses	oenology_get_post_formats()	Defined in functions/custom.php
 */
function oenology_post_format_entry_icon_container() {
	if ( 'post' != get_post_type() ) {
		return;
	}
	$postformat = ( get_post_format() ? get_post_format() : 'standard' );
	$iconformats = oenology_get_post_formats();
	
	foreach ( $iconformats as $format ) {
		if ( $postformat == $format['slug'] ) {
			if ( 'entry' == $format['location'] || ( ! is_single() && 'both' == $format['location'] ) ) {
				?>
				<div class="post-format-icon-container genericon"><span class="genericon-<?php echo $format['slug']; ?>"></span></div>
				<?php
			}
		}
	}
}
add_action( 'oenology_hook_post_entry_before', 'oenology_post_format_entry_icon_container' );

/**
 * Action hook after content within div.post-footer
 * 
 * This action hook fires after content is output in the div.post-footer container. It
 * can be used to add content after post footer content is output.
 * 
 * Template file: post.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_footer_after() {
	do_action( 'oenology_hook_post_footer_after' );
}

/**
 * Action hook before content within div.post-footer
 * 
 * This action hook fires before content is output in the div.post-footer container. It
 * can be used to add content before post footer content is output.
 * 
 * Template file: post.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_footer_before() {
	do_action( 'oenology_hook_post_footer_before' );
}

/**
 * Action hook after content within div.post-header
 * 
 * This action hook fires after content is output in the div.post-header container. It
 * can be used to add content after post header content is output.
 * 
 * Template file: post.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_header_after() {
	do_action( 'oenology_hook_post_header_after' );
}

/**
 * Add Post-Title container for Post Format icon
 * 
 * @uses	oenology_get_post_formats()	Defined in functions/custom.php
 */
function oenology_post_format_title_icon_container() {
	if ( 'post' != get_post_type() ) {
		return;
	}
	$postformat = ( get_post_format() ? get_post_format() : 'standard' );
	$iconformats = oenology_get_post_formats();
	
	foreach ( $iconformats as $format ) {
		if ( $postformat == $format['slug'] ) {
			if ( 'title' == $format['location'] || 'both' == $format['location'] ) {
				?>
				<div class="post-format-icon-container genericon"><span class="genericon-<?php echo $format['slug']; ?>"></span></div>
				<?php
			}
		}
	}
}
add_action( 'oenology_hook_post_header_before', 'oenology_post_format_title_icon_container' );

/**
 * Action hook before content within div.post-header
 * 
 * This action hook fires before content is output in the div.post-header container. It
 * can be used to add content before post header content is output.
 * 
 * Template file: post.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
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();
}



/**
 * Output social icons
 * 
 * Outputs social icons at the top of the 
 * main/double-wide sidebar.
 */
function oenology_display_social_icons() {
	oenology_social_icons();
}
add_action( 'oenology_hook_sidebars_top', 'oenology_display_social_icons' );

/**
 * 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
 * 
 * This action hook fires after content is output in the div#footer container. It
 * can be used to add content after site footer content is output.
 * 
 * Template file: footer.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_site_footer_text_after() {
	do_action( 'oenology_hook_site_footer_text_after' );
	tha_footer_bottom();
}

/**
 * Action hook before content within div#footer
 * 
 * This action hook fires before content is output in the div#footer container. It
 * can be used to add content before site footer content is output.
 * 
 * Template file: footer.php
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_site_footer_text_before() {
	do_action( 'oenology_hook_site_footer_text_before' );
	tha_footer_top();
}

/**
 * Action hook after div#header
 * 
 * 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
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_site_header_after() {
	do_action( 'oenology_hook_site_header_after' );
	tha_header_after();
}

/**
 * Action hook before div#header
 * 
 * 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
 * 
 * @uses do_action()
 * 
 * @since Oenology 2.0
 */
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();
}


/**
 * Define custom filter hooks
 */

/**
 * Hook to filter content displayed in the Loop footer
 * 
 * This hook can be used to filter to content that is 
 * output in the div#loop-footer container.
 * 
 * Template file: loop-footer.php
 * 
 * @uses apply_filters()
 * @uses oenology_get_paginate_archive_page_links()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_loop_footer() {	
	$loop_footer = oenology_get_paginate_archive_page_links( 'list', 1, 3 );
	echo apply_filters( 'oenology_hook_loop_footer', $loop_footer );
}

/**
 * Hook to filter content displayed in the Loop header
 * 
 * This hook can be used to filter to content that is 
 * output in the div#loop-header container.
 * 
 * Template file: loop-header.php
 * 
 * @uses apply_filters()
 * @uses category_description()
 * @uses get_category_feed_link()
 * @uses get_post_format()
 * @uses get_post_format_link()
 * @uses get_post_format_string()
 * @uses get_search_query()
 * @uses get_tag_feed_link()
 * @uses get_template_directory_uri()
 * @uses is_archive()
 * @uses is_category()
 * @uses is_tag()
 * @uses is_tax()
 * @uses is_search()
 * @uses tag_description()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_loop_header() {	
	$loop_header = '';
	// If this is an archive index.
	if( is_archive() ) {
		// If this is a taxonomy archive.
		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' );
				$taxtitle = ( is_category() ? single_cat_title( '', false ) : single_tag_title( '', false ) );
				global $wp_query;
				$taxfeedlink = ( is_category() ? get_category_feed_link( $wp_query->get( 'cat' ) ) : get_tag_feed_link( $wp_query->get( 'tag_id' ) ) );
				$catdescription = ( ( is_category() && category_description() ) ? category_description() : false );
				$tagdescription = ( ( is_tag() && tag_description() ) ? tag_description() : false );
				$taxdesc = ( is_category() ? $catdescription : $tagdescription );
				$taxdescdefault = __( 'Posts filed under ', 'oenology' ) . $taxtitle;
				$taxdescription = ( $taxdesc ? $taxdesc : $taxdescdefault );
			}
			// If this is a Post Format archive.
			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/';
				$taxdescription = false;
				$formats = oenology_get_post_formats();
				foreach ( $formats as $format ) {
					if ( $format['slug'] == $tax ) {
						$taxdescription = '<em>' . $format['description'] . '</em>';
					}
				}
			}
			// 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;
			}
			
			$loop_header .= '<div class="cat-subscribe-feed">';
			$loop_header .= '<a href="' . $taxfeedlink .'"><span class="genericon genericon-feed"></span>';
			$loop_header .= '<br />' . $taxtitle . ' feed</a>';
			$loop_header .= '</div>';
			$loop_header .= '<h2 class="pagetitle">' . $taxtitle . '</h2>';
			$loop_header .= '<div class="cat-description">' . $taxdescription . '</div>';
		}
	}
	// If this is a search results page.
	elseif ( is_search() ) {
		$loop_header .= '<h2 class="pagetitle">Results for "' . get_search_query() . '" Search</h2>';
		$loop_header .= '<div class="cat-description">';
		$loop_header .= '<strong>' . __( 'Search', 'oenology' ) . ':</strong><em>' . __( 'to inquire, investigate, examine, or seek; conduct an examination or investigation.', 'oenology' ) . '</em>' . __( 'Below are all posts and pages related to the indicated search query.', 'oenology' );
		$loop_header .= '</div>';
	}
	echo apply_filters( 'oenology_hook_loop_header', $loop_header );
}

/**
 * Hook to filter content displayed in the Loop if no Posts are found
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post container when have_posts()
 * returns false.
 * 
 * Template file: loop.php 
 * 
 * @since Oenology 2.2
 */
function oenology_hook_loop_no_posts() {	
	$loop_no_posts = '';
	$loop_no_posts .= '<h2 class="center">' . __( 'Not Found', 'oenology' ) . '</h2>';
	$loop_no_posts .= '<p class="center">' . __( 'Sorry, but you are looking for something that isn\'t here.', 'oenology' ) . '</p>';
	echo apply_filters( 'oenology_hook_loop_no_posts', $loop_no_posts );
}

/**
 * Hook to filter content displayed on Error 404 pages
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post-entry container on Error
 * 404 pages.
 * 
 * Template file: 404.php
 * 
 * @uses apply_filters()
 * @uses get_avatar()
 * @uses get_the_author_meta()
 * @uses is_page()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_404() {	
	$post_404 = oenology_get_404_content();
	echo apply_filters( 'oenology_hook_post_404', $post_404 );
}

/**
 * Hook to filter content within div#postmetadata
 * 
 * This hook can be used to filter to content that is output in the div#postmetadata container.
 * 
 * Template file: post-footer.php
 * 
 * @uses apply_filters()
 * @uses get_avatar()
 * @uses get_the_author_meta()
 * @uses is_page()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_footer_avatar() {	
	// don't display the author's avatar on Pages.
	global $post;
	if ( ! is_page() && 'page' != $post->post_type ) { 
		// display a 20px avatar, to fit inside the post footer.
		$avatar = get_avatar( get_the_author_meta( 'email' ), $size = '20' );
		$post_footer_avatar = apply_filters( 'oenology_hook_post_footer_avatar', $avatar ); 
		echo '<span class="post-footer-gravatar">' . $post_footer_avatar . '</span>';
	}
}

/**
 * Hook to filter content within div#postmetadata
 * 
 * This hook can be used to filter to content that is output in the div#postmetadata container. To
 * use this hook, simply pass a string containing the license text. This string is automatically
 * wrapped in the appropriate container <span class="post-footer-license"></span> tags. If nothing
 * is passed to this filter, then nothing is output by default.
 * 
 * Template file: post-footer.php
 * 
 * @return	mixed
 * 
 * @uses 	apply_filters()
 * 
 * @since 	Oenology 2.0
 */
function oenology_hook_post_footer_license() {

	$license = '';
	$license = apply_filters( 'oenology_hook_post_footer_license', $license );
	if ( '' != $license ) { 
		$post_footer_license = '';
		$post_footer_license .= '<span class="post-footer-license">';
		$post_footer_license .= $license;
		$post_footer_license .= '</span>';
		echo $post_footer_license;
	}
}

/**
 * Hook to filter Post Footer Metadata
 * 
 * This hook can be used to filter to content that is 
 * output in the div#postmetadata container.
 * 
 * Template file: post-footer.php
 * 
 * @uses apply_filters()
 * @uses get_bloginfo()
 * @uses get_comments_number()
 * @uses get_edit_post_link()
 * @uses get_option()
 * @uses get_permalink()
 * @uses get_post_format()
 * @uses get_post_format_link()
 * @uses get_post_format_string()
 * @uses get_the_author()
 * @uses get_the_date()
 * @uses get_the_time()
 * @uses has_post_format()
 * @uses is_page()
 * @uses is_user_logged_in()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_footer_metadata() {

	$post_footer_metadata = array();
	global $post;
	if ( ! is_page() && 'page' != $post->post_type ) {
		$oenology_post_format_string = ( get_post_format() ? '<a href="' . get_post_format_link( get_post_format() ) . '">' . get_post_format_string( get_post_format() ) . '</a>' : 'Posted' );
	
		$post_footer_metadata['post-format-string'] = $oenology_post_format_string;
		$post_footer_metadata['post-format-string'] .= ' by ' . get_the_author() . ' ';
	
		if ( has_post_format( 'aside' ) || has_post_format( 'link' ) || has_post_format( 'quote' ) || has_post_format( 'status' ) ) {
			$post_footer_metadata['permalink'] = '<a href="' . get_permalink() . '">' . get_the_date( get_option( 'date_format' ) ) . ' at ' . get_the_time( get_option( 'time_format' ) ) . '</a>';
			// Display total number of post comments .
			$post_footer_metadata['comments'] = ' (' . get_comments_number() . ') '; 
			if ( is_user_logged_in() ) {
				// Display "Edit" link for logged-in Admin users.
				$post_footer_metadata['editlink'] = '<a href="' . get_edit_post_link() . '">' . __( 'Edit', 'oenology' ) . '</a>'; 
			}
		} else {
			$post_footer_metadata['timestamp'] = get_the_date( get_option( 'date_format' ) ) . ' at ' . get_the_time( get_option( 'time_format' ) );
		}
	} else {
		$post_footer_metadata['copyright'] = '&copy; ' . get_bloginfo( 'name' );
	}
	echo '<span class="post-footer-meta">' . implode( '', apply_filters( 'oenology_hook_post_footer_metadata', $post_footer_metadata ) ) . '</span>';
}

/**
 * Hook to filter Post Header Date
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post-title container.
 * 
 * Template file: post-header.php
 * 
 * @uses apply_filters()
 * @uses get_the_time()
 * @uses is_attachment()
 * @uses is_page()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_header_date() {	
	global $post;
	// don't display timestamp on Pages.
	if ( 'post' == get_post_type() ) {
		$post_header_date = array();
		// Post Date: Year.
		$post_header_date_year = get_the_time('Y');
		$post_header_date['year'] = '<span class="post-date-year">' . apply_filters( 'oenology_hook_post_header_date_year', $post_header_date_year ) . '</span>'; 
		// Post Date: Weekday.
		$post_header_date_weekday = get_the_time('D');
		$post_header_date['weekday'] = '<span class="post-date-weekday">' . apply_filters( 'oenology_hook_post_header_date_weekday', $post_header_date_weekday ) . '</span>'; 
		// Post Date: Day of Month.
		$post_header_date_day = get_the_time('d');
		$post_header_date['day'] = '<span class="post-date-day">' . apply_filters( 'oenology_hook_post_header_date_day', $post_header_date_day ) . '</span>'; 
		// Post Date: Month.
		$post_header_date_month = get_the_time('M');
		$post_header_date['month'] = '<span class="post-date-month">' . apply_filters( 'oenology_hook_post_header_date_month', $post_header_date_month ) . '</span>'; 
		echo '<span class="post-date">' . implode( '', apply_filters( 'oenology_hook_post_header_date', $post_header_date ) ) . '</span>';
	}
}

/**
 * Hook to filter Post Header Metadata Links
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post-title container.
 * 
 * Template file: post-header.php
 * 
 * @uses apply_filters()
 * @uses get_comments_number()
 * @uses get_edit_post_link()
 * @uses get_permalink()
 * @uses get_the_ID()
 * @uses get_the_title()
 * @uses get_trackback_url()
 * @uses is_attachment()
 * @uses is_page()
 * @uses is_singular()
 * @uses is_user_logged_in()
 * @uses wp_get_shortlink()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_header_metadata() {	

	$post_header_metadata = array();	
	
	// Post Permalink.
	$permalink = '<span id="post-' . get_the_ID() . '">';
	$permalink .= '<a href="' . get_permalink() . '" rel="bookmark" title="' . sprintf( __( 'Permanent Link to %s', 'oenology' ), esc_attr( get_the_title() ) ) . '">' . __( 'Permalink', 'oenology' ) . '</a>';
	$permalink .= '</span>';
	$post_header_metadata['permalink'] = $permalink;
	
	// Post Metadata Links.
	global $post;
	if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
		if ( ! is_attachment() ) {
			// Shortlink.
			$shortlink = '<span id="post-' . get_the_ID() . '-shortlink"><a href="' . wp_get_shortlink() . '">' . __( 'Shortlink', 'oenology' ) . '</a></span>';
			$post_header_metadata['shortlink'] = $shortlink;
		}
		// Comments Link.
		$commentslink = '<a href="' . get_comments_link() . '" target="_self" title="' . sprintf( __( 'Comment on %s', 'oenology' ), esc_attr( get_the_title() ) ) . '">';
		$commentslink .= __( 'Comments', 'oenology' ) . ' (' . get_comments_number() . ')';
		$commentslink .= '</a> ';
		$post_header_metadata['commentslink'] = $commentslink;
		// Trackback.
		$trackbacklink = '<a href="' . get_trackback_url() . '" target="_self" title="' . sprintf( __( 'Trackback to %s', 'oenology' ), esc_attr( get_the_title() ) ) . '">' . __( 'Trackback', 'oenology' ) . '</a>';	
		$post_header_metadata['trackbacklink'] = $trackbacklink;
	}
	if ( is_singular() ) { // only display a Print link on single posts, pages, and attachments.
		// Print Link.
		$printlink = '<a href="print" onclick="window.print();return false;">Print</a>';
		$post_header_metadata['printlink'] = $printlink;
	}
	if ( is_user_logged_in() ) {
		// Edit Post Link.
		$editlink = '<a href="' . get_edit_post_link() . '">' . __( 'Edit', 'oenology' ) . '</a>'; // Display "Edit" link for logged-in Admin users.
		$post_header_metadata['editlink'] = $editlink;
	}	
	echo '<span class="post-title-metadata">' . implode( ' <strong>|</strong> ', apply_filters( 'oenology_hook_post_header_metadata', $post_header_metadata ) ) . '</span>';
}
	
/**
 * Hook to filter Post Header Taxonomies
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post-title container.
 * 
 * Template file: post-header.php
 * 
 * @uses apply_filters()
 * @uses get_the_category_list()
 * @uses get_the_tag_list()
 * @uses is_page()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_header_taxonomies() {	

	$post_header_taxonomies = array();	
	
	// Post Taxonomies.
	global $post;
	if ( 'post' == get_post_type() ) {
		// Category List.
		$post_header_taxonomies['categorylist'] = '<span class="post-title-category">';
		$post_header_taxonomies['categorylist'] .= sprintf( __( 'Filed in %s', 'oenology' ), get_the_category_list( ', ' ) );
		$post_header_taxonomies['categorylist'] .= '</span>';
		// Tag List.
		if ( get_the_tag_list() ) {
			$post_header_taxonomies['taglist'] = '<span class="post-title-tags">';
			$post_header_taxonomies['taglist'] .= sprintf( __( 'Tags: %s', 'oenology' ), get_the_tag_list( '', ', ', '' ) );
			$post_header_taxonomies['taglist'] .= '</span>';
		}
	}
	echo '<span class="post-title-taxonomies">' . implode( '', apply_filters( 'oenology_hook_post_header_taxonomies', $post_header_taxonomies ) ) . '</span>';
}


/**
 * Hook to filter Post Header Title
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post-title container.
 * 
 * Template file: post-header.php
 * 
 * @uses apply_filters()
 * @uses get_permalink()
 * @uses get_the_title()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_header_title() {
	$post_header_title = '';
	
	if ( ! is_singular() && ( has_post_format( 'gallery' ) || has_post_format( 'image' ) ) ) {
		// display post title, no link.
		$post_header_title = '<h1 class="gallery-title">' . get_the_title() . '</h1>';	
	} else {	
		// link Post Headline (H1) to post permalink.
		$post_header_title = '<h1><a href="' . get_permalink() . '">' . get_the_title() . '</a></h1>';	
	}

	echo apply_filters( 'oenology_hook_post_header_title', $post_header_title );
}

/**
 * Hook to filter Post Header Thumbnail
 * 
 * This hook can be used to filter to content that is 
 * output in the div#post-title container.
 * 
 * Template file: post-header.php
 * 
 * @uses apply_filters()
 * @uses get_post_format()
 * @uses get_the_post_thumbnail()
 * @uses has_post_thumbnail()
 * @uses is_attachment()
 * @uses is_home()
 * @uses is_page()
 * @uses is_single()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_post_header_thumbnail() {
	
	// display the post thumbnail in the post header for search and archive pages, since they are excerpted.
	// don't display for custom Post Formats, since icons are displayed.
	if ( ( ! ( is_home() || is_single() || is_page() || is_attachment() ) ) && has_post_thumbnail() && ! get_post_format() ) { 

		$post_header_thumbnail = '';
		global $post;
		$post_header_thumbnail = get_the_post_thumbnail( $post->ID, 'post-title-thumbnail' );

		echo '<span class="post-title-thumbnail">' . apply_filters( 'oenology_hook_post_header_thumbnail', $post_header_thumbnail ) . '</span>';
	}
}

/**
 * Hook to filter site footer content
 * 
 * This hook can be used to filter to content that is 
 * output in the div#postmetadata container. By default, 
 * it builds an associative array: 
 * - $site_footer['copyright'] => the site copyright notice
 * - $site_footer['wordpress'] => the WordPress credit
 * - $site_footer['themecredit'] => the Theme credit (if enabled)
 * 
 * The filter is passed on the array, before the array 
 * is imploded. So to modify the output, add, remove, or 
 * modify the array keys.
 * 
 * Template file: footer.php
 * 
 * @uses apply_filters()
 * @uses date()
 * @uses function_exists()
 * @uses get_bloginfo()
 * @uses get_template_directory_uri()
 * @uses home_url()
 * @uses oenology_copyright()
 * @uses oenology_get_footer_credit()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_site_footer() {
	
	$site_footer = array();

	$site_footer['copyright'] = '<span><a href="' . home_url() . '">' . get_bloginfo('name') . '</a></span> ';

	// if the oenology_copyright() function exists, use it to output the copyright date span otherwise, just output the current year.
	if ( function_exists( 'oenology_copyright' ) ) { 
		// function to output XXXX-YYYY, where 'XXXX' is the year of the oldest post, and 'YYYY' is the current year.
		$site_footer['copyright'] .= oenology_copyright();  
	} else {  
		// current year.
		$site_footer['copyright'] .= '&copy; ' . date('Y');
	}
	
	$site_footer['wordpress'] = sprintf( __( 'Powered by %s', 'oenology' ), '<a href="' . esc_url( 'http://wordpress.org' ) . '" target="_new" class="footer-wordpress-link"><span class="genericon genericon-wordpress"></span>WordPress ' . get_bloginfo( 'version' ) . '</a>' );
	
	global $oenology_options;
	if ( 'true' == $oenology_options['display_footer_credit'] ) { 
		// Disabled by default.
		$site_footer['themecredit'] = '<a href="http://www.chipbennett.net/themes/oenology">Oenology Theme</a>';  
	}

	$site_footer['feed'] = '<a class="footer-feed-link genericon" href="' . get_bloginfo( 'rss2_url' ) . '" title="RSS"><span class="genericon-feed"></span></a>';

	echo implode( ' | ', apply_filters( 'oenology_hook_site_footer', $site_footer ) );
}

/**
 * Hook to filter site header text content
 * 
 * This hook can be used to filter to content that is 
 * output in the div#site-header-text container. By 
 * default, it outputs the Site Title inside a DIV with 
 * a class .site-header-text, and the Site Description 
 * inside paragraph tags.
 * 
 * Template file: site-header.php
 * 
 * @uses apply_filters()
 * @uses get_bloginfo()
 * 
 * @since Oenology 2.0
 */
function oenology_hook_site_header() {
	
	$site_header = '';

	$site_header_logo = ( function_exists( 'has_custom_logo' ) && has_custom_logo() ? get_custom_logo() : '&nbsp;' );
	$site_header_name = ( 'blank' != get_header_textcolor() ? get_bloginfo( 'name' ) : '&nbsp;' );
	$site_header_description = ( 'blank' != get_header_textcolor() ? get_bloginfo( 'description' ) : '&nbsp;' );

	// Displays the blog name, as defined on the General Settings page in the administration panel.
	$site_header .= '<div class="site-header-text">' . $site_header_logo . $site_header_name . '</div>';
	// Displays the blog description, as defined on the General Settings page in the administration panel.
	$site_header .= '<p>' . $site_header_description . '</p>';

	echo apply_filters( 'oenology_hook_site_header', $site_header, $site_header_name, $site_header_description );
} 