* @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', 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( '

%3$s%4$s %5$s

%7$s
', 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
%3$s
', apply_filters( 'tc_author_meta_separator', '
' ), apply_filters( 'tc_author_meta_wrapper_class', 'row-fluid' ), sprintf('
%2$s

%4$s

%5$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(); ?>
is_posts_page ) ? apply_filters( 'tc_archives_headings_separator', '
' ) : ''; ?>
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 ?>
%2$s', $bubble_style, get_comments_number() ); $bubble_comment = apply_filters( 'tc_bubble_comment', $bubble_comment ); //when are we showing the comments number in title? $comments_enabled = ( 1 == esc_attr( tc__f( '__get_option' , 'tc_page_comments' )) && comments_open() && get_comments_number() != 0 && !post_password_required() && is_page() ) ? true : false; $comments_enabled = ( comments_open() && get_comments_number() != 0 && !post_password_required() && !is_page() ) ? true : $comments_enabled; $comments_enabled = apply_filters( 'tc_comments_in_title', $comments_enabled ); //when are we displaying the edit link? $edit_enabled = ( (is_user_logged_in()) && current_user_can('edit_pages') && is_page() ) ? true : false; $edit_enabled = ( (is_user_logged_in()) && current_user_can('edit_post' , get_the_ID() ) && ! is_page() ) ? true : $edit_enabled; $edit_enabled = apply_filters( 'tc_edit_in_title', $edit_enabled ); //declares vars $html = ''; $filter_args = array(); if ( (get_the_title() != null) ) { //gets the post/page title if ( is_singular() || ! apply_filters('tc_display_link_for_post_titles' , true ) ) { $tc_heading_title = ( get_the_title() == null ) ? apply_filters( 'tc_no_title_post', __( '{no title} Read the post »' , 'customizr' ) ) : get_the_title(); } else { $tc_heading_title = sprintf('%3$s', get_permalink(), esc_attr( sprintf( apply_filters( 'tc_post_link_title' ,__( 'Permalink to %s' , 'customizr' ) ) , the_title_attribute( 'echo=0' ) ) ), ( get_the_title() == null ) ? apply_filters( 'tc_no_title_post', __( '{no title} Read the post »' , 'customizr' ) ) : get_the_title() );//end sprintf } $filter_args = array( $bubble_comment, $comments_enabled, $edit_enabled , $tc_heading_title ); //renders the full title $html = sprintf('<%1$s class="entry-title %2$s">%3$s %4$s %5$s', is_singular() ? apply_filters( 'tc_content_title_tag' , 'h1' ) : apply_filters( 'tc_content_title_tag' , 'h2' ), apply_filters( 'tc_content_title_icon', 'format-icon' ), $tc_heading_title, //checks if comments are opened AND if there are any comments to display $comments_enabled ? sprintf('%4$s', is_singular() ? '' : get_permalink(), __( 'Comment(s) on' , 'customizr' ), get_the_title(), $bubble_comment ) : '', $edit_enabled ? sprintf('%2$s', get_edit_post_link(), __( 'Edit' , 'customizr' ) ) : '' );//end sprintf }//end if title exists echo apply_filters( 'tc_content_headings' , $html, $filter_args ); do_action('__after_content_title'); echo is_singular() ? apply_filters( 'tc_content_headings_separator', '
' ) : ''; ?>