header.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * The header for our theme.
  4. *
  5. * Displays all of the <head> section
  6. *
  7. * @package Libretto
  8. */
  9. ?>
  10. <!DOCTYPE html>
  11. <html <?php language_attributes(); ?>>
  12. <head>
  13. <meta charset="<?php bloginfo( 'charset' ); ?>" />
  14. <meta name="viewport" content="width=device-width, initial-scale=1">
  15. <link rel="profile" href="http://gmpg.org/xfn/11" />
  16. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
  17. <?php wp_head(); ?>
  18. </head>
  19. <body <?php body_class(); ?>>
  20. <header class="nav-bar">
  21. <?php if ( ! is_home() ) : // On the blog index page the site title is displayed below nav-bar ?>
  22. <div class="site-branding">
  23. <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>
  24. </div>
  25. <?php endif; ?>
  26. <nav id="site-navigation" class="navigation-main" role="navigation">
  27. <div class="menu-toggle"><span class="mobile-site-title"><?php bloginfo( 'name' ); ?></span>
  28. <button id="menu-icon">
  29. <span></span>
  30. <span></span>
  31. <span></span>
  32. </button>
  33. </div>
  34. <div class="screen-reader-text skip-link">
  35. <a href="#content" title="<?php esc_attr_e( 'Skip to content', 'libretto' ); ?>"><?php esc_attr_e( 'Skip to content', 'libretto' ); ?></a>
  36. </div>
  37. <div class="menu-wrapper">
  38. <?php wp_nav_menu( array( 'theme_location' => 'primary', 'fallback_cb' => false ) ); ?>
  39. <?php get_search_form(); ?>
  40. </div>
  41. </nav><!-- .site-navigation -->
  42. </header><!-- .header-bar -->
  43. <?php if ( ! is_attachment() ) : // Don't show header for attachments ?>
  44. <header id="masthead" class="site-header" role="banner"
  45. <?php
  46. /*
  47. * If we have a custom image set, we're going to do some manipulation to the masthead height via JS,
  48. * This means that we need to pass the height of the image is being shown as a data-attribute.
  49. * This way, JS will know our image height without resorting to anything complicated.
  50. */
  51. $libretto_header_image_height = libretto_get_header_image( 'height' );
  52. if ( isset( $libretto_header_image_height ) ) :
  53. echo 'data-image-height="'. absint( $libretto_header_image_height ) . '"';
  54. endif;
  55. ?>
  56. >
  57. <!-- PAGE HEADER -->
  58. <div class="title-block">
  59. <?php if ( is_home() ) : // Show the site title & tagline ?>
  60. <?php if ( function_exists( 'jetpack_the_site_logo' ) ) :
  61. jetpack_the_site_logo();
  62. endif; ?>
  63. <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>
  64. <h3 class="site-description"><?php bloginfo( 'description' ); ?></h3>
  65. <?php elseif ( is_single() ) : // Show the post title and metadata for posts ?>
  66. <div class="entry-meta">
  67. <?php libretto_posted_on(); ?>
  68. </div><!-- .entry-meta -->
  69. <h1><?php the_title(); ?></h1>
  70. <?php elseif ( is_page() ) : // Show the page title for pages ?>
  71. <h1><?php the_title(); ?></h1>
  72. <?php elseif ( is_archive() ) : // Show archive title
  73. the_archive_title( '<h1>', '</h1>' );
  74. the_archive_description( '<h3>', '</h3>' );
  75. ?>
  76. <?php elseif ( is_404() ) : // Show "page not found" ?>
  77. <h1><?php esc_html_e( 'Error', 'libretto' ); ?></h1>
  78. <h3><?php esc_html_e( 'Oops! That page can&rsquo;t be found.', 'libretto' ); ?></h3>
  79. <?php elseif ( is_search() ) : // Search results ?>
  80. <h1><?php esc_html_e( 'Search results', 'libretto' ); ?></h1>
  81. <h3><?php printf( esc_html__( 'You searched for %s', 'libretto' ), '<span>' . get_search_query() . '</span>' ); ?></h3>
  82. <?php endif; ?>
  83. </div><!-- .title-block -->
  84. </header><!-- #masthead -->
  85. <?php endif; ?>