* @copyright Copyright (c) 2013, Nicolas GUILLAUME
* @link http://themesandco.com/customizr
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
if ( ! class_exists( 'TC_headings' ) ) :
class TC_headings {
static $instance;
function __construct () {
self::$instance =& $this;
//Headings for archives, authors, search, 404
add_action ( '__before_loop' , array( $this , 'tc_archives_headings' ));
//Headings for post, page, attachment
add_action ( '__before_content' , array( $this , 'tc_content_headings' ));
}
/**
* The template part for displaying the not post/page headings : archives, author, search, 404 and the post page heading (if not font page)
*
* @package Customizr
* @since Customizr 3.1.0
*/
function tc_archives_headings() {
//case page for posts but not on front
global $wp_query;
if ( $wp_query -> is_posts_page && ! is_front_page() ) {
//get page for post ID
$page_for_post_id = get_option('page_for_posts');
$header_class = 'entry-header';
$content = sprintf('<%1$s class="entry-title %2$s">%3$s%1$s>',
apply_filters( 'tc_content_title_tag' , 'h1' ),
apply_filters( 'tc_content_title_icon', 'format-icon' ),
get_the_title( $page_for_post_id )
);
$content = apply_filters( 'tc_page_for_post_header_content', $content );
}
//404
if ( is_404() ) {
$header_class = 'entry-header';
$content = sprintf('
%2$s
',
apply_filters( 'tc_archive_icon', '' ),
apply_filters( 'tc_404_title' , __( 'Ooops, page not found' , 'customizr' ) )
);
$content = apply_filters( 'tc_404_header_content', $content );
}
//search results
if ( is_search() && !is_singular() ) {
$header_class = 'search-header';
$content = sprintf( '',
apply_filters( 'tc_search_result_header_title_class', 'span8' ),
apply_filters( 'tc_archive_icon', 'format-icon' ),
have_posts() ? '' : __( 'No' , 'customizr' ).' ' ,
apply_filters( 'tc_search_results_title' , __( 'Search Results for :' , 'customizr' ) ),
'' . get_search_query() . '',
apply_filters( 'tc_search_result_header_form_class', 'span4' ),
have_posts() ? get_search_form(false) : ''
);
$content = apply_filters( 'tc_search_results_header_content', $content );
}
//author's posts page
if ( !is_singular() && is_author() ) {
//gets the user ID
$user_id = get_query_var( 'author' );
$header_class = 'archive-header';
$content = sprintf( '%2$s %3$s
',
apply_filters( 'tc_archive_icon', 'format-icon' ),
apply_filters( 'tc_author_archive_title' , __( 'Author Archives :' , 'customizr' ) ),
'' . get_the_author_meta( 'display_name' , $user_id ) . ''
);
if ( apply_filters ( 'tc_show_author_meta' , get_the_author_meta( 'description', $user_id ) ) ) {
$content .= sprintf('%1$s',
apply_filters( 'tc_author_meta_separator', '
' ),
apply_filters( 'tc_author_meta_wrapper_class', 'row-fluid' ),
sprintf('%2$s
',
apply_filters( 'tc_author_meta_avatar_class', 'comment-avatar author-avatar span2'),
get_avatar( get_the_author_meta( 'user_email', $user_id ), apply_filters( 'tc_author_bio_avatar_size' , 100 ) ),
apply_filters( 'tc_author_meta_content_class', 'author-description span10' ),
sprintf( __( 'About %s' , 'customizr' ), get_the_author() ),
get_the_author_meta( 'description' , $user_id )
)
);
}
$content = apply_filters( 'tc_author_header_content', $content );
}
//category archives
if ( !is_singular() && is_category() ) {
$header_class = 'archive-header';
$content = sprintf( '%2$s %3$s
',
apply_filters( 'tc_archive_icon', 'format-icon' ),
apply_filters( 'tc_category_archive_title' , __( 'Category Archives :' , 'customizr' ) ),
'' . single_cat_title( '' , false ) . ''
);
if ( apply_filters ( 'tc_show_cat_description' , category_description() ) ) {
$content .= sprintf('%1$s
',
category_description()
);
}
$content = apply_filters( 'tc_category_archive_header_content', $content );
}
//tag archives
if ( !is_singular() && is_tag() ) {
$header_class = 'archive-header';
$content = sprintf( '%2$s %3$s
',
apply_filters( 'tc_archive_icon', 'format-icon' ),
apply_filters( 'tag_archive_title' , __( 'Tag Archives :' , 'customizr' ) ),
'' . single_tag_title( '' , false ) . ''
);
if ( apply_filters ( 'tc_show_tag_description' , tag_description() ) ) {
$content .= sprintf('%1$s
',
tag_description()
);
}
$content = apply_filters( 'tc_tag_archive_header_content', $content );
}
//time archives
if ( !is_singular() && ( is_day() || is_month() || is_year() ) ) {
$archive_type = is_day() ? sprintf( __( 'Daily Archives: %s' , 'customizr' ), '' . get_the_date() . '' ) : __( 'Archives' , 'customizr' );
$archive_type = is_month() ? sprintf( __( 'Monthly Archives: %s' , 'customizr' ), '' . get_the_date( _x( 'F Y' , 'monthly archives date format' , 'customizr' ) ) . '' ) : $archive_type;
$archive_type = is_year() ? sprintf( __( 'Yearly Archives: %s' , 'customizr' ), '' . get_the_date( _x( 'Y' , 'yearly archives date format' , 'customizr' ) ) . '' ) : $archive_type;
$header_class = 'archive-header';
$content = sprintf('%2$s
',
apply_filters( 'tc_archive_icon', 'format-icon' ),
$archive_type
);
$content = apply_filters( 'tc_time_archive_header_content', $content );
}
//renders the heading
if ( !isset($content) || !isset($header_class) )
return;
global $wp_query;
ob_start();
?>
post_formats_with_no_header );
if( in_array( get_post_format(), $post_formats_with_no_header ) )
return;
//by default we don't display the title of the front page
if( apply_filters('tc_show_page_title', is_front_page() && 'page' == get_option( 'show_on_front' ) ) )
return
?>