header.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * The header for our theme.
  4. *
  5. * Displays all of the <head> section and everything up till <div id="content">
  6. *
  7. * @package Pique
  8. */
  9. ?><!DOCTYPE html>
  10. <html <?php language_attributes(); ?>>
  11. <head>
  12. <meta charset="<?php bloginfo( 'charset' ); ?>">
  13. <meta name="viewport" content="width=device-width, initial-scale=1">
  14. <link rel="profile" href="http://gmpg.org/xfn/11">
  15. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
  16. <?php wp_head(); ?>
  17. </head>
  18. <body <?php body_class(); ?>>
  19. <div id="page" class="hfeed site">
  20. <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'pique' ); ?></a>
  21. <header id="masthead" class="site-header" role="banner">
  22. <?php
  23. $jetpack_options = get_theme_mod( 'jetpack_testimonials' );
  24. // Let's show a header image if we aren't on the front page
  25. if ( ! pique_is_frontpage() ) :
  26. // If the post uses a Featured Image, let's show that
  27. if ( is_singular() && pique_is_woocommerce_in_view() && has_post_thumbnail() ) : ?>
  28. <a class="pique-header" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
  29. <?php the_post_thumbnail( 'pique-header', array( 'id' => 'pique-header-image' ) ); ?>
  30. </a>
  31. <?php
  32. // If on the Testimonials archive type
  33. elseif ( is_post_type_archive( 'jetpack-testimonial' ) && 0 != $jetpack_options['featured-image'] ) :
  34. $testimonials_header = wp_get_attachment_image_src( (int)$jetpack_options['featured-image'], 'pique-header' ); ?>
  35. <a class="pique-header" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
  36. <img src="<?php echo esc_url( $testimonials_header[0] ); ?>" id="pique-header-image">
  37. </a>
  38. <?php
  39. // Otherwise, let's just show the header image
  40. elseif ( get_header_image() ): ?>
  41. <a class="pique-header" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
  42. <img id="pique-header-image" src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="<?php bloginfo( 'name' ); ?>">
  43. </a>
  44. <?php endif; // End featured image check. ?>
  45. <?php endif; // End is frontpage check. ?>
  46. <div class="site-branding">
  47. <?php pique_the_site_logo(); ?>
  48. <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
  49. <p class="site-description"><?php bloginfo( 'description' ); ?></p>
  50. </div><!-- .site-branding -->
  51. <?php if ( pique_is_frontpage() AND get_theme_mod( 'pique_menu' ) ) : ?>
  52. <?php
  53. // Get each of our panels and output a link to that section ID on the page
  54. foreach ( range( 1, 8 ) as $panel ) :
  55. if ( get_theme_mod( 'pique_panel' . $panel ) ) :
  56. $post = get_post( get_theme_mod( 'pique_panel' . $panel ) );
  57. setup_postdata( $post );
  58. // Just in case the user didn't set a title for the page, we're going to generate one from the slug
  59. if ( '' === get_the_title() ) :
  60. $title = str_replace( '-', ' ', $post->post_name );
  61. else :
  62. $title = get_the_title();
  63. endif;
  64. $panel_links[] = '<li><a href="#post-' . get_the_ID() . '">' . $title . '</a></li>';
  65. wp_reset_postdata();
  66. endif;
  67. endforeach;
  68. // Output our menu only if we actually have menu items
  69. if ( isset( $panel_links ) ) : ?>
  70. <div id="site-navigation-wrapper">
  71. <nav id="site-navigation" class="main-navigation" role="navigation">
  72. <ul id="primary-menu" class="menu nav-menu">
  73. <?php
  74. foreach ( $panel_links as $key => $link ) :
  75. // Output menu link
  76. echo wp_kses( $link, array(
  77. 'a' => array(
  78. 'href' => array(),
  79. 'title' => array(),
  80. ),
  81. 'li' => array(),
  82. )
  83. );
  84. endforeach;
  85. ?>
  86. <li id="more-menu" class="menu-item menu-item-has-children"><a href="#"><span class="screen-reader-text">More</span></a><ul class="sub-menu"></ul></li>
  87. </ul>
  88. </nav><!-- #site-navigation -->
  89. </div>
  90. <?php endif; ?>
  91. <?php elseif ( has_nav_menu( 'primary' ) ) : ?>
  92. <div id="site-navigation-wrapper">
  93. <nav id="site-navigation" class="main-navigation" role="navigation">
  94. <?php
  95. wp_nav_menu( array(
  96. 'theme_location' => 'primary',
  97. 'menu_id' => 'primary-menu',
  98. 'fallback_cb' => 'wp_page_menu',
  99. 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
  100. 'walker' => new Pique_Menu(),
  101. ) );
  102. ?>
  103. </nav><!-- #site-navigation -->
  104. </div>
  105. <?php endif; ?>
  106. </header><!-- #masthead -->
  107. <div id="content" class="site-content">