header.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 Toujours
  10. */
  11. ?><!DOCTYPE html>
  12. <html <?php language_attributes(); ?>>
  13. <head>
  14. <meta charset="<?php bloginfo( 'charset' ); ?>">
  15. <meta name="viewport" content="width=device-width, initial-scale=1">
  16. <link rel="profile" href="http://gmpg.org/xfn/11">
  17. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
  18. <?php wp_head(); ?>
  19. </head>
  20. <body <?php body_class(); ?>>
  21. <div id="page" class="site">
  22. <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'toujours' ); ?></a>
  23. <?php $header_image = get_header_image(); ?>
  24. <header id="masthead" class="site-header" role="banner">
  25. <div class="wrap">
  26. <div class="site-branding">
  27. <?php
  28. if ( function_exists( 'jetpack_the_site_logo' ) ) {
  29. jetpack_the_site_logo();
  30. }
  31. if ( ! empty( $header_image ) ) : ?>
  32. <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
  33. <img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="" class="header-image">
  34. </a>
  35. <?php endif;
  36. if ( is_front_page() && is_home() ) : ?>
  37. <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
  38. <?php else : ?>
  39. <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
  40. <?php endif; ?>
  41. </div><!-- .site-branding -->
  42. <?php if ( has_nav_menu( 'primary' ) ) : ?>
  43. <nav id="site-navigation" class="main-navigation" role="navigation">
  44. <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Menu', 'toujours' ); ?></button>
  45. <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'primary-menu' ) ); ?>
  46. </nav><!-- #site-navigation -->
  47. <?php endif; ?>
  48. </div><!-- .wrap -->
  49. </header><!-- #masthead -->
  50. <?php
  51. // checks whether homepage is posts or static page
  52. $homepage = get_option( 'show_on_front' );
  53. // check what page we're on
  54. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  55. ?>
  56. <?php // if we're on a static front page, or the blog index is the homepage and we're on the first page, show the slideshow ?>
  57. <?php if ( ( is_front_page() && 'page' === $homepage ) || ( is_home() && 1 === $paged && 'posts' === $homepage ) ) { ?>
  58. <?php
  59. if ( toujours_has_banner_posts( 1 ) ) { ?>
  60. <?php get_template_part( 'template-parts/content', 'slideshow' ); ?>
  61. <?php }
  62. ?>
  63. <?php
  64. $description = get_bloginfo( 'description', 'display' );
  65. if ( $description || is_customize_preview() ) : ?>
  66. <div id="tagline">
  67. <div class="wrap">
  68. <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
  69. </div>
  70. </div>
  71. <?php endif; ?>
  72. <?php } ?>
  73. <?php // only show recent posts if is home && page one ?>
  74. <?php if ( is_home() && 1 === $paged ) { ?>
  75. <?php if ( get_theme_mod( 'toujours_recent_posts' ) ) {
  76. get_template_part( 'template-parts/content', 'recent-posts' );
  77. } ?>
  78. <?php } ?>
  79. <div id="content" class="site-content">
  80. <div class="wrap">