Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.69 KB | None | 0 0
  1. <?php
  2.  
  3. $post_id = get_queried_object_id();
  4.  
  5. if( is_singular('post') || is_home() ) {
  6. $post_id = get_option('page_for_posts');
  7. }
  8. $title = '';
  9. $sub_title = '';
  10.  
  11. // Show or Hide title
  12. $show_title = get_post_meta( $post_id, '_general_show_main_title', true );
  13. if( $show_title == 'off' ) return;
  14. $custom_title = get_post_meta( $post_id, '_general_custom_main_title', true );
  15. $custom_sub_title = get_post_meta( $post_id, '_general_custom_sub_title', true );
  16.  
  17. $title = ( $custom_title ) ? $custom_title : get_the_title( $post_id );
  18. $sub_title = ( $custom_sub_title ) ? $custom_sub_title : '';
  19.  
  20. // Blog
  21. if( is_singular('post') || is_home() ) {
  22. if(!$post_id) $title = __('Blog', 'theme_front');
  23. }
  24.  
  25. // 404 page
  26. if( is_404() ) {
  27. $title = __('<strong>404</strong> page not found', 'theme_front');
  28. $sub_title = __( 'It seems we can&rsquo;t find what you&rsquo;re looking for. isn&rsquo;t it?', 'theme_front' );
  29. }
  30.  
  31. // Search page
  32. if( is_search() ) {
  33. $title = __('<strong>Search</strong> ', 'theme_front') . $_REQUEST['s'];
  34.  
  35. if( $wp_query->found_posts > 0 ) {
  36. $sub_title = $wp_query->found_posts . __( ' results matched search query', 'theme_front' );
  37. } else {
  38. $sub_title = __( 'no results matched search query', 'theme_front' );
  39. }
  40. }
  41.  
  42. // Attachment
  43. if(is_attachment()) {
  44. $title = __('Attachment', 'theme_front');
  45. }
  46.  
  47. // Archive
  48. if( is_archive() ) {
  49. if ( is_category() ) {
  50. $title = sprintf( __( '<em>Category</em> %s', 'theme_front' ), single_cat_title( '', false ) );
  51. $sub_title = category_description();
  52. } elseif (is_tag() ) {
  53. $title = sprintf( __( '<em>Tag</em> %s', 'theme_front' ), single_tag_title( '', false ) );
  54. $sub_title = tag_description();
  55. } elseif ( is_day() ) {
  56. $title = sprintf( __( '<em>Daily</em> %s', 'theme_front' ), get_the_time( 'F jS, Y' ) );
  57. } elseif ( is_month() ) {
  58. $title = sprintf( __( '<em>Monthly</em> %s', 'theme_front' ), get_the_time( 'F, Y' ) );
  59. } elseif ( is_year() ) {
  60. $title = sprintf( __( '<em>Yearly</em> %s', 'theme_front' ), get_the_time( 'Y' ) );
  61. } elseif ( is_author() ) {
  62. if( get_query_var( 'author_name' ) ) {
  63. $curauth = get_user_by( 'slug', get_query_var('author_name') );
  64. } else {
  65. $curauth = get_userdata( get_query_var( 'author' ) );
  66. }
  67. $author_name = get_the_author_meta('display_name', $curauth->ID);
  68. $author_desc = get_the_author_meta('description', $curauth->ID);
  69. $title = sprintf( __( '<em>Author</em> %s', 'theme_front' ), $author_name );
  70. $sub_title = '';
  71. }
  72. }
  73.  
  74. // Post Type Archive
  75. if(is_post_type_archive()) {
  76. $title = post_type_archive_title(false, false);
  77. }
  78.  
  79. // Taxonomy Archive
  80. if(is_tax()) {
  81. $title = single_term_title(false, false);
  82. }
  83.  
  84. // Agent
  85. if(is_singular('agent')) {
  86. $sub_title = '<ul>';
  87. if(get_post_meta( $post_id, '_meta_role', true )) $sub_title .= '<li>'.get_post_meta( $post_id, '_meta_role', true ).'</li>';
  88. if(get_post_meta( $post_id, '_meta_phone', true )) $sub_title .= '<li>'.get_post_meta( $post_id, '_meta_phone', true ).'</li>';
  89. if(get_post_meta( $post_id, '_meta_email', true )) $sub_title .= '<li>'.get_post_meta( $post_id, '_meta_email', true ).'</li>';
  90. $sub_title .= '</ul>';
  91. }
  92.  
  93. // Member
  94. if(is_page_template('template-member.php')) {
  95. $current_user = wp_get_current_user();
  96. $phone = get_user_meta($current_user->ID, 'phone', true);
  97. $title = get_user_meta($current_user->ID, 'display_name', true);
  98.  
  99. $description = get_user_meta($current_user->ID, 'description', true);
  100. $phone = get_user_meta($current_user->ID, 'phone', true);
  101. $url = get_user_meta($current_user->ID, 'user_url', true);
  102.  
  103. $sub_title = '<ul>';
  104. if($url) $sub_title .= '<li><a href="'.esc_url($url).'" rel="no-follow">'.str_replace('http://', '', $url).'</a></li>';
  105. if($phone) $sub_title .= '<li>'.$phone.'</li>';
  106. if($current_user->user_email) $sub_title .= '<li>'.$current_user->user_email.'</li>';
  107. $sub_title .= '</ul>';
  108. }
  109.  
  110. // Property
  111. if(is_singular('property')) {
  112. if(isset($_REQUEST['compare-with'])) {
  113. return;
  114. } else {
  115. $sub_title = '<ul>';
  116.  
  117. $locations = wp_get_post_terms($post->ID, 'location');
  118. $locations_sorted = array();
  119. nt_sort_terms_hierarchicaly($locations, $locations_sorted);
  120. foreach($locations_sorted as $l) {
  121. $sub_title .= '<li><a href="'.get_term_link($l).'">'.$l->name.'</a></li>';
  122. foreach($l->children as $lc) {
  123. $sub_title .= '<li><a href="'.get_term_link($lc).'">'.$lc->name.'</a></li>';
  124. }
  125. }
  126.  
  127. $sub_title .= get_the_term_list($post->ID, 'type', '<li>', '</li><li>', '</li>');
  128. $sub_title .= '</ul>';
  129. }
  130. }
  131.  
  132. // Style
  133. $title_element_style = ( get_post_meta( $post_id, '_general_title_element_style', true ) ) ? get_post_meta( $post_id, '_general_title_element_style', true ) : nt_get_option('page', 'element_style', 'element-dark');
  134.  
  135. $title_bg_color = ( get_post_meta( $post_id, '_general_title_bg_color', true ) ) ? get_post_meta( $post_id, '_general_title_bg_color', true ) : nt_get_option('page', 'bg_color');
  136. $title_bg_color = 'background-color:'.$title_bg_color.';';
  137.  
  138. $title_bg_image = ( get_post_meta( $post_id, '_general_title_bg_image', true ) ) ? get_post_meta( $post_id, '_general_title_bg_image', true ) : nt_get_option('page', 'bg_image');
  139. if( $title_bg_image ) {
  140. $title_bg_image = wp_get_attachment_image_src($title_bg_image, 'full');
  141. $title_bg_image = $title_bg_image[0];
  142. }
  143. $title_bg_image = 'background-image: url('.$title_bg_image.');';
  144.  
  145. $title_bg_image_style = ( get_post_meta( $post_id, '_general_title_bg_image_style', true ) ) ? get_post_meta( $post_id, '_general_title_bg_image_style', true ) : nt_get_option('page', 'bg_image_style');
  146. $title_bg_image_style = 'background-size:'.$title_bg_image_style.';';
  147.  
  148.  
  149. ?>
  150.  
  151. <div class="section-title <?php if(is_singular('agent') || is_page_template('template-member.php')): ?>with-thumb<?php endif; ?> <?php echo esc_attr($title_element_style); ?>" style="<?php echo esc_attr($title_bg_color); ?> <?php echo esc_attr($title_bg_image); ?> <?php echo esc_attr($title_bg_image_style); ?>">
  152. <div class="row">
  153. <div class="columns">
  154.  
  155. <?php if(is_singular('agent')): ?>
  156. <div class="thumb"><i class="flaticon-bust"></i><?php the_post_thumbnail('full'); ?></div>
  157. <?php endif; ?>
  158.  
  159. <?php if(is_page_template('template-member.php')):
  160. $current_user = wp_get_current_user();
  161. ?>
  162. <div class="thumb"><i class="flaticon-bust"></i><?php echo get_avatar($current_user->user_email, 512, '', $current_user->display_name); ?></div>
  163. <?php endif; ?>
  164.  
  165. <h1 class="page-title"><?php echo wp_kses_data($title); ?></h1>
  166. <?php if($sub_title): ?>
  167. <div class="sub-title"><?php echo wp_kses_post($sub_title); ?></div>
  168. <?php endif; ?>
  169. </div>
  170. </div>
  171. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement