Advertisement
srikat

Untitled

Jul 31st, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. <?php
  2.  
  3. //* Add opening markup for the Page Header
  4. $header_color = get_option( 'showcase_header_color', 'true' );
  5. if ( $header_color === 'white' ) {
  6. add_action( 'genesis_after_header', 'showcase_opening_page_header', 8 );
  7. } else {
  8. add_action( 'genesis_before_header', 'showcase_opening_page_header' );
  9. }
  10.  
  11. function showcase_opening_page_header() {
  12. if ( ( is_front_page() && is_active_sidebar( 'front-page-hero' ) ) || ( is_page() && !is_page_template( 'page_landing.php' ) ) || is_archive() || is_home() ) {
  13.  
  14. if ( is_front_page() && is_active_sidebar( 'front-page-hero' ) ) {
  15. $hero_image = get_option( 'showcase-hero-image', sprintf( '%s/images/hero-image-1.jpg', get_stylesheet_directory_uri() ) );
  16. $background_image = 'style="background-image: url(' . $hero_image . ')"';
  17. }
  18.  
  19. if ( ( is_page() || ( is_home() && get_option('page_for_posts') ) ) && has_post_thumbnail() ) {
  20. if ( is_home() && get_option('page_for_posts') ) {
  21. $posts_page_id = get_option('page_for_posts');
  22. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $posts_page_id ), 'full' );
  23. } else {
  24. $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
  25. }
  26. $background_image = 'style="background-image: url(' . $image[0] . ')"';
  27. }
  28.  
  29. if ( $background_image ) {
  30. $background_image_class = 'with-background-image';
  31. }
  32.  
  33. ?>
  34.  
  35. <div class="header-wrap bg-primary <?php echo $background_image_class; ?>" <?php echo $background_image; ?>>
  36.  
  37. <?php
  38. }
  39. }
  40.  
  41. //* Add closing markup for the Page Header
  42. add_action( 'genesis_after_header', 'showcase_closing_page_header' );
  43. function showcase_closing_page_header() {
  44.  
  45. if ( ( is_front_page() && is_active_sidebar( 'front-page-hero' ) ) || ( is_page() && !is_page_template( 'page_landing.php' ) ) || is_single() || is_archive() || is_home() ) {
  46.  
  47. ?>
  48. <div class="page-header">
  49. <div class="wrap">
  50. <?php
  51.  
  52. if ( is_front_page() && is_active_sidebar( 'front-page-hero' ) ) {
  53.  
  54. genesis_widget_area( 'front-page-hero', array(
  55. 'before' => '<div id="front-page-hero" class="front-page-hero widget-area">',
  56. 'after' => '</div>',
  57. ) );
  58.  
  59. } elseif ( is_archive() ) {
  60.  
  61. if ( is_category() || is_tag() || is_tax() ) {
  62.  
  63. //* Remove the description
  64. remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
  65.  
  66. echo single_term_title( '<h1>', '</h1>', true );
  67. /**
  68. * This is a weird hack to fix the non-closing h1 above, for some reason
  69. * it's including the paragraph below, so I'm echoing a closing h1 tag.
  70. */
  71. echo '</h1>';
  72. echo term_description();
  73.  
  74. } elseif ( is_author() ) {
  75.  
  76. echo genesis_author_box();
  77.  
  78. }
  79.  
  80. } elseif( is_home() && get_option('page_for_posts') ) {
  81.  
  82. $posts_page_id = get_option('page_for_posts');
  83. echo '<h1>' . get_the_title($posts_page_id) . '</h1>';
  84. remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
  85.  
  86. } else {
  87.  
  88. if ( is_singular() && !is_page_template( 'page_blog.php' ) ) {
  89.  
  90. if ( !is_singular( 'team' ) ) {
  91. genesis_post_info();
  92. }
  93.  
  94. //* Remove the entry title (requires HTML5 theme support)
  95. remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
  96.  
  97. }
  98.  
  99. echo showcase_bar_to_br( the_title( '<h1>', '</h1>', false ) );
  100. }
  101.  
  102. ?>
  103. </div>
  104. <?php genesis_do_subnav(); ?>
  105. </div>
  106. </div>
  107.  
  108. <?php
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement