header.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * The header for our theme.
  4. *
  5. * This is the template that displays all of the <head> section and everything up until <div id="content">
  6. *
  7. * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
  8. *
  9. * @package Pen
  10. */
  11. ob_start();
  12. ?><!doctype html>
  13. <html <?php language_attributes(); ?> class="no-js">
  14. <head>
  15. <meta charset="<?php bloginfo( 'charset' ); ?>">
  16. <meta name="viewport" content="width=device-width, initial-scale=1">
  17. <link rel="profile" href="https://gmpg.org/xfn/11">
  18. <?php
  19. wp_head();
  20. ?>
  21. </head>
  22. <body <?php body_class(); ?>>
  23. <div id="page" class="site">
  24. <div class="pen_wrapper">
  25. <?php
  26. if ( ! is_customize_preview() ) {
  27. pen_html_jump_menu( 'color_schemes' );
  28. pen_html_jump_menu( 'font_presets' );
  29. }
  30. ?>
  31. <a class="screen-reader-shortcut screen-reader-text" href="#content">
  32. <?php
  33. esc_html_e( 'Skip to content', 'pen' );
  34. ?>
  35. </a>
  36. <?php
  37. $header_primary = false;
  38. if ( pen_sidebar_check( 'sidebar-header-primary' ) && is_active_sidebar( 'sidebar-header-primary' ) ) {
  39. $header_primary = true;
  40. }
  41. $header_secondary = false;
  42. if ( pen_sidebar_check( 'sidebar-header-secondary' ) && is_active_sidebar( 'sidebar-header-secondary' ) ) {
  43. $header_secondary = true;
  44. }
  45. $connect = pen_html_connect( 'header' );
  46. $connect_display = 'hide';
  47. if ( $connect ) {
  48. $connect_display = 'show';
  49. }
  50. $search_html = pen_html_search_box();
  51. $search_location = '';
  52. $search_display = 'hide';
  53. $search_location = get_post_meta( get_the_ID(), 'pen_content_search_location_override', true );
  54. if ( ! $search_location || 'default' === $search_location ) {
  55. $search_location = pen_option_get( 'search_location' );
  56. }
  57. if ( $search_html ) {
  58. if ( 'header' === $search_location ) {
  59. $search_display = 'show';
  60. } elseif ( 'content' === $search_location ) {
  61. $search_display = 'show_toolbar';
  62. }
  63. }
  64. $logo = pen_html_logo();
  65. $phone = pen_option_get( 'phone' );
  66. $phone_display = ( $phone && pen_option_get( 'phone_header_display' ) ) ? 'show' : 'hide';
  67. ob_start( 'trim' );
  68. get_template_part( 'partials/site', 'navigation' );
  69. $navigation = ob_get_clean();
  70. $classes_header = array(
  71. 'site-header',
  72. $logo ? 'pen_has_logo' : '',
  73. $navigation ? 'pen_navigation_show' : 'pen_navigation_hide',
  74. 'pen_phone_' . sanitize_html_class( $phone_display ),
  75. 'pen_connect_' . sanitize_html_class( $connect_display ),
  76. 'pen_search_' . sanitize_html_class( $search_display ),
  77. 'pen_navigation_' . sanitize_html_class( pen_option_get( 'navigation_display' ) ? 'show' : 'hide' ),
  78. 'pen_navigation_mobile_' . sanitize_html_class( pen_option_get( 'navigation_mobile_display' ) ? 'show' : 'hide' ),
  79. );
  80. $classes_header = trim( implode( ' ', array_filter( $classes_header ) ) );
  81. ?>
  82. <header id="pen_header" class="<?php echo esc_attr( $classes_header ); ?>" role="banner">
  83. <div class="pen_header_inner">
  84. <div class="pen_header_main">
  85. <div class="pen_container clearfix">
  86. <h1>
  87. <?php
  88. echo $logo; /* phpcs:ignore */
  89. get_template_part( 'partials/site', 'title' );
  90. ?>
  91. </h1>
  92. <?php
  93. if ( $header_primary || $header_secondary || 'show' === $phone_display || $connect || ( 'header' === $search_location && $search_html ) ) {
  94. ?>
  95. <div class="pen_header_wrap pen_animate_on_scroll pen_custom_animation_fadeIn">
  96. <?php
  97. pen_sidebar_get( 'sidebar-header-primary' );
  98. if ( 'show' === $phone_display ) {
  99. ?>
  100. <div class="pen_phone <?php pen_class_animation( 'phone_header' ); /* phpcs:ignore */ ?>">
  101. <a href="tel:<?php echo esc_attr( $phone ); ?>">
  102. <?php
  103. echo esc_html( $phone );
  104. ?>
  105. </a>
  106. </div>
  107. <?php
  108. }
  109. echo $connect; /* phpcs:ignore */
  110. if ( 'header' === $search_location ) {
  111. echo $search_html; /* phpcs:ignore */
  112. }
  113. pen_sidebar_get( 'sidebar-header-secondary' );
  114. ?>
  115. </div>
  116. <?php
  117. }
  118. ?>
  119. </div>
  120. <?php
  121. pen_html_jump_menu( 'header' );
  122. ?>
  123. </div>
  124. <?php
  125. // Adds the main navigation menu.
  126. echo $navigation; /* phpcs:ignore */
  127. ?>
  128. </div><!-- .pen_header_inner -->
  129. <?php
  130. if ( $search_html && 'content' === $search_location ) {
  131. ?>
  132. <div id="pen_search">
  133. <div class="pen_container">
  134. <?php
  135. pen_sidebar_get( 'sidebar-search-top' );
  136. ?>
  137. </div>
  138. <div class="pen_container">
  139. <?php
  140. pen_sidebar_get( 'sidebar-search-left' );
  141. ?>
  142. <div id="pen_search_form">
  143. <?php
  144. echo $search_html; /* phpcs:ignore */
  145. ?>
  146. </div>
  147. <?php
  148. pen_sidebar_get( 'sidebar-search-right' );
  149. ?>
  150. </div>
  151. <div class="pen_container">
  152. <?php
  153. pen_sidebar_get( 'sidebar-search-bottom' );
  154. pen_html_jump_menu( 'search_bar' );
  155. ?>
  156. </div>
  157. </div>
  158. <?php
  159. }
  160. ?>
  161. </header>
  162. <div id="pen_section">
  163. <?php
  164. pen_sidebar_get( 'sidebar-top' );
  165. ?>
  166. <div class="pen_container">
  167. <div id="content" class="site-content clearfix">