Advertisement
Guest User

sub-header.php

a guest
Dec 11th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.99 KB | None | 0 0
  1. <?php
  2.     $output = '';
  3.     $sub_img = array();
  4.     global $post;
  5.  
  6.     if(!function_exists('thmtheme_call_sub_header')){
  7.         function thmtheme_call_sub_header(){
  8.             global $themeum_options;
  9.             if(isset($themeum_options['blog-banner']['url'])){
  10.                 $output = 'style="background-image:url('.esc_url($themeum_options['blog-banner']['url']).');background-size: cover;background-position: 50% 50%;padding: 150px 0 90px;"';
  11.                 return $output;
  12.             }else{
  13.                  $output = 'style="background-color:'.esc_attr($themeum_options['blog-subtitle-bg-color']).';padding: 150px 0 90px;"';
  14.                  return $output;
  15.             }
  16.         }
  17.     }
  18.    
  19.     if( isset($post->post_name) ){
  20.         if(!empty($post->ID)){
  21.             $image_attached = esc_attr(get_post_meta( $post->ID , 'thm_subtitle_images', true ));
  22.             if(!empty($image_attached)){
  23.                 $sub_img = wp_get_attachment_image_src( $image_attached , 'blog-full');
  24.                 $output = 'style="background-image:url('.esc_url($sub_img[0]).');background-size: cover;background-position: 50% 50%;padding: 150px 0 90px;"';
  25.                 if(empty($sub_img[0])){
  26.                     $output = 'style="background-color:'.esc_attr(get_post_meta(get_the_ID(),"thm_subtitle_color",true)).';padding: 150px 0 90px;"';
  27.                     if(get_post_meta(get_the_ID(),"thm_subtitle_color",true) == ''){
  28.                         $output = thmtheme_call_sub_header();
  29.                     }
  30.                 }
  31.             }else{
  32.                 if(get_post_meta(get_the_ID(),"thm_subtitle_color",true) != "" ){
  33.                     $output = 'style="background-color:'.esc_attr(get_post_meta(get_the_ID(),"thm_subtitle_color",true)).';padding: 150px 0 90px;"';
  34.                 }else{
  35.                     $output = thmtheme_call_sub_header();
  36.                 }
  37.             }
  38.         }else{
  39.             $output = thmtheme_call_sub_header();
  40.         }
  41.     }else{
  42.             $output = thmtheme_call_sub_header();
  43.         }
  44.  
  45. ?>
  46.  
  47. <?php if (!is_front_page()) { ?>
  48.  
  49. <div class="sub-title" <?php echo $output;?>>
  50.     <div class="container">
  51.         <div class="sub-title-inner">
  52.             <h2>
  53.                 <?php
  54.                    $var = 1;
  55.                    if(function_exists('is_shop')){
  56.                        if(is_shop()&& !is_product()){
  57.                          echo esc_html__('Shop', 'themeum-core');
  58.                          $var = 2;
  59.                        }
  60.                    }
  61.                    if($var != 2){
  62.                         if( is_home() && get_option( 'page_for_posts' ) ){
  63.                             echo get_the_title( get_option( 'page_for_posts' ) );
  64.                         }elseif (is_archive()){
  65.                             echo the_archive_title( '<span class="page-title">', '</span>' );
  66.                         }else{
  67.                             the_title();
  68.                         }
  69.                    }
  70.                ?>
  71.             </h2>
  72.         </div>
  73.     </div>
  74. </div>
  75.  
  76. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement