Advertisement
pratikshrestha

NepalBuzz Header mod

Oct 22nd, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.80 KB | None | 0 0
  1. /**
  2.  * Display Featured Header Image div
  3.  *
  4.  * @since NepalBuzz 0.1
  5.  */
  6. function nepalbuzz_header_div() {
  7.     $status = nepalbuzz_header_media_status();
  8.  
  9.     if ( $status ) {
  10.         global $post;
  11.  
  12.         $header_image = nepalbuzz_featured_image();
  13.  
  14.         $options             = nepalbuzz_get_options();
  15.         $title               = $options['featured_header_title'];
  16.         $content             = $options['featured_header_content'];
  17.         $button_text         = $options['featured_header_button_text'];
  18.         $button_link         = $options['featured_header_button_link'];
  19.         $button_target       = $options['featured_header_button_target'];
  20.         $enable_header_image = $options['enable_featured_header_image'];
  21.  
  22.         if ( is_page() || is_single() ) {
  23.             //Individual Page/Post Image Setting
  24.             $individual_featured_image = get_post_meta( $post->ID, 'nepalbuzz-header-image', true );
  25.  
  26.             if ( 'disable' == $individual_featured_image || ( 'default' == $individual_featured_image && 'disable' == $enable_header_image ) ) {
  27.                 echo '<!-- Page/Post Disable Header Image -->';
  28.                 return false;
  29.             }
  30.         }
  31.  
  32.         $button_target_value = '_self';
  33.  
  34.         if ( $button_target ) {
  35.             $button_target_value = '_blank';
  36.         }
  37.  
  38.         $classes = array();
  39.  
  40.         $default_image = get_template_directory_uri() . '/images/header-1920x1080.jpg';
  41.  
  42.         if ( function_exists( 'get_parent_theme_file_uri' ) ) {
  43.             $default_image =  get_parent_theme_file_uri( '/images/header-1920x1080.jpg' );
  44.         }
  45.  
  46.         echo '<div class="custom-header">';
  47.  
  48.         if ( 'video' == $header_image ) {
  49.             $classes[] = 'video';
  50.         } else if ( $default_image == $header_image ) {
  51.             $classes[] = 'default';
  52.         }
  53.  
  54.         if ( has_custom_header() ) {
  55.             echo '<div class="custom-header-media">';
  56.                     the_custom_header_markup();
  57.             echo '</div>';
  58.         }
  59.  
  60.         echo '
  61.             <div class="custom-header-content ' . esc_attr( implode( ' ', $classes ) ) . '">
  62.                 <article class="hentry header-image">
  63.                     <div class="entry-container">';
  64.                         if ( '' != $title ) {
  65.                             echo '
  66.                             <header class="entry-header">
  67.                                 <h2 class="entry-title">
  68.                                     <a href="' . esc_url( $button_link ) . '" target="' . esc_attr( $button_target_value ) . '">' . wp_kses_post( $title ) . '</a>
  69.                                 </h2>
  70.                             </header>';
  71.                         }
  72.  
  73.                         if ( '' != $content || '' != $button_text ) {
  74.                             echo '
  75.                             <div class="entry-content"><p>
  76.                                 ' . $content;
  77.  
  78.                             if ( '' != $button_text ) {
  79.                                 echo '<span class="more-button"><a class="more-link" href="' . esc_url( $button_link ) . '" target="' . esc_attr( $button_target_value ) . '">'. esc_html( $button_text ) .'</a></span>';
  80.                             }
  81.                             echo '</p></div>';
  82.                         }
  83.  
  84.                     echo '
  85.                     </div><!-- .entry-container -->
  86.                 </article><!-- .hentry.header-image -->
  87.             </div><!-- #header-featured-image -->
  88.         </div><!-- .custom-header -->';
  89.     }
  90. } // nepalbuzz_header_div
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement