csheldon

template-tags.php (portion relating to page-title)

Nov 4th, 2013
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.09 KB | None | 0 0
  1. /**
  2.  * Page title controller.
  3.  */
  4. function presscore_page_title_controller() {
  5.     global $post;
  6.  
  7.     $title_align = of_get_option( 'general-title_align', 'center' );
  8.     $title_classes = array( 'page-title' );
  9.     switch( $title_align ) {
  10.  
  11.         case 'right' :
  12.             $title_classes[] = 'title-right';
  13.             break;
  14.  
  15.         case 'left' :
  16.             $title_classes[] = 'title-left';
  17.             break;
  18.  
  19.         default:
  20.             $title_classes[] = 'title-center';
  21.     }
  22.  
  23.     $before_title = '<div class="' . esc_attr( implode( ' ', $title_classes ) ) . '"><div class="wf-wrap"><div class="wf-table">';
  24.     $after_title = '</div></div></div>';
  25.     $title_template = '<div class="wf-td"><h1>%s</h1></div>';
  26.     $title = '';
  27.     $breadcrumbs = apply_filters( 'dt_sanitize_flag', of_get_option( 'general-show_breadcrumbs', 1 ) );
  28.     $is_single = is_single();
  29.  
  30.     if ( is_page() || $is_single ) {
  31.  
  32.         $title_mode = get_post_meta($post->ID, '_dt_header_title', true);
  33.  
  34.         if ( 'disabled' != $title_mode && presscore_is_content_visible() ) {
  35.  
  36.             if ( $is_single ) {
  37.                 $title_template = '<div class="wf-td"><h1 class="entry-title">%s</h1></div>';
  38.             }
  39.  
  40.             $title = sprintf( $title_template, apply_filters('the_title', get_the_title($post->ID)) );
  41.  
  42.         } else {
  43.             $breadcrumbs = false;
  44.             $before_title = $after_title = '';
  45.  
  46.         }
  47.  
  48.     } else if ( is_search() ) {
  49.         $message = sprintf( _x( 'Search Results for: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . get_search_query() . '</span>' );
  50.         $title = sprintf( $title_template, $message );
  51.  
  52.     } else if ( is_archive() ) {
  53.  
  54.         if ( is_category() ) {
  55.             $message = sprintf( _x( 'Category Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . single_cat_title( '', false ) . '</span>' );
  56.  
  57.         } elseif ( is_tag() ) {
  58.             $message = sprintf( _x( 'Tag Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . single_tag_title( '', false ) . '</span>' );
  59.  
  60.         } elseif ( is_author() ) {
  61.             the_post();
  62.             $message = sprintf( _x( 'Author Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' );
  63.             rewind_posts();
  64.  
  65.         } elseif ( is_day() ) {
  66.             $message = sprintf( _x( 'Daily Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . get_the_date() . '</span>' );
  67.  
  68.         } elseif ( is_month() ) {
  69.             $message = sprintf( _x( 'Monthly Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . get_the_date( 'F Y' ) . '</span>' );
  70.  
  71.         } elseif ( is_year() ) {
  72.             $message = sprintf( _x( 'Yearly Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . get_the_date( 'Y' ) . '</span>' );
  73.  
  74.         } elseif ( is_tax('dt_portfolio_category') ) {
  75.             $term = get_queried_object();
  76.             $tax = get_taxonomy( $term->taxonomy );
  77.             $message = sprintf( _x( 'Portfolio Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . single_term_title( $tax->labels->name, false ) . '</span>' );
  78.  
  79.         } elseif ( is_tax('dt_gallery_category') ) {
  80.             $term = get_queried_object();
  81.             $tax = get_taxonomy( $term->taxonomy );
  82.             $message = sprintf( _x( 'Albums Archives: %s', 'archive template title', LANGUAGE_ZONE ), '<span>' . single_term_title( $tax->labels->name, false ) . '</span>' );
  83.  
  84.         } else {
  85.             $message = _x( 'Archives:', 'archive template title', LANGUAGE_ZONE );
  86.  
  87.         }
  88.  
  89.         $title = sprintf( $title_template, $message );
  90.     } elseif ( is_404() ) {
  91.         $title = sprintf( $title_template, _x('Page not found', 'index title', LANGUAGE_ZONE) );
  92.     } else {
  93.         $title = sprintf( $title_template, _x('Blog', 'index title', LANGUAGE_ZONE) );
  94.     }
  95.  
  96.     echo $before_title;
  97.  
  98.     if ( 'right' == $title_align ) {
  99.  
  100.         echo $breadcrumbs ? presscore_get_breadcrumbs() : '';
  101.         echo apply_filters( 'presscore_page_title', $title, $title_template );
  102.     } else {
  103.  
  104.         echo apply_filters( 'presscore_page_title', $title, $title_template );
  105.         echo $breadcrumbs ? presscore_get_breadcrumbs() : '';
  106.     }
  107.  
  108.     echo $after_title;
  109. }
  110. add_action('presscore_before_main_container', 'presscore_page_title_controller', 16);
Advertisement
Add Comment
Please, Sign In to add comment