header.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 Blank Canvas
  10. * @since 1.0
  11. */
  12. $blog_info = get_bloginfo( 'name' );
  13. $description = get_bloginfo( 'description', 'display' );
  14. $show_title = ( true === get_theme_mod( 'display_title_and_tagline', true ) );
  15. $header_class = $show_title ? 'site-title' : 'screen-reader-text';
  16. ?><!doctype html>
  17. <html <?php language_attributes(); ?>>
  18. <head>
  19. <meta charset="<?php bloginfo( 'charset' ); ?>" />
  20. <meta name="viewport" content="width=device-width, initial-scale=1" />
  21. <link rel="profile" href="https://gmpg.org/xfn/11" />
  22. <?php wp_head(); ?>
  23. </head>
  24. <body <?php body_class(); ?>>
  25. <?php wp_body_open(); ?>
  26. <div id="page" class="site">
  27. <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'blank-canvas' ); ?></a>
  28. <header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
  29. <?php if ( has_custom_logo() && $show_title && ! is_singular() ) : ?>
  30. <div class="site-logo"><?php the_custom_logo(); ?></div>
  31. <?php endif; ?>
  32. <div class="site-branding">
  33. <?php if ( ! empty( $blog_info ) && $show_title && ! is_singular() ) : ?>
  34. <?php if ( is_front_page() && is_home() ) : ?>
  35. <h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo $blog_info; ?></a></h1>
  36. <?php else : ?>
  37. <p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo $blog_info; ?></a></p>
  38. <?php endif; ?>
  39. <?php endif; ?>
  40. <?php if ( ( $description || is_customize_preview() ) && $show_title && ! is_singular() ) : ?>
  41. <p class="site-description">
  42. <?php echo $description; ?>
  43. </p>
  44. <?php endif; ?>
  45. </div><!-- .site-branding -->
  46. </header><!-- #masthead -->
  47. <div id="content" class="site-content">