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 WPBBP |
---|
10 | */ |
---|
11 | |
---|
12 | namespace WordPressdotorg\Forums; |
---|
13 | |
---|
14 | $menu_items = array( |
---|
15 | /* translators: relative link to the forums home page */ |
---|
16 | _x( '/forums/', 'header menu', 'wporg-forums' ) => _x( 'Forums', 'header menu', 'wporg-forums' ), |
---|
17 | _x( 'https://wordpress.org/support/guidelines/', 'header menu', 'wporg-forums' ) => _x( 'Guidelines', 'header menu', 'wporg-forums' ), |
---|
18 | _x( 'https://wordpress.org/documentation/', 'header menu', 'wporg-forums' ) => _x( 'Documentation', 'header menu', 'wporg-forums' ), |
---|
19 | _x( 'https://make.wordpress.org/support/handbook/', 'header menu', 'wporg-forums' ) => _x( 'Get Involved', 'header menu', 'wporg-forums' ), |
---|
20 | ); |
---|
21 | |
---|
22 | \WordPressdotorg\skip_to( '#content' ); |
---|
23 | |
---|
24 | echo do_blocks( '<!-- wp:wporg/global-header /-->' ); |
---|
25 | |
---|
26 | ?> |
---|
27 | |
---|
28 | <div id="page" class="site"> |
---|
29 | <a class="skip-link screen-reader-text" href="#main"><?php esc_html_e( 'Skip to content', 'wporg-forums' ); ?></a> |
---|
30 | |
---|
31 | <div id="content" class="site-content"> |
---|
32 | <header id="masthead" class="site-header <?php echo is_front_page() ? 'home' : ''; ?>" role="banner"> |
---|
33 | <div class="site-branding"> |
---|
34 | <?php if ( is_front_page() ) : ?> |
---|
35 | <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/forums/' ) ); ?>" rel="home"><?php _ex( 'WordPress Support', 'Site title', 'wporg-forums' ); ?></a></h1> |
---|
36 | |
---|
37 | <p class="site-description"> |
---|
38 | <?php |
---|
39 | /* Translators: subhead */ |
---|
40 | _e( 'We’ve got a variety of resources to help you get the most out of WordPress.', 'wporg-forums' ); |
---|
41 | ?> |
---|
42 | </p> |
---|
43 | <?php get_search_form(); ?> |
---|
44 | <?php else : ?> |
---|
45 | <p class="site-title"><a href="<?php echo esc_url( home_url( '/forums/' ) ); ?>" rel="home"><?php _ex( 'Support', 'Site title', 'wporg-forums' ); ?></a></p> |
---|
46 | |
---|
47 | <nav id="site-navigation" class="main-navigation" role="navigation"> |
---|
48 | <button class="menu-toggle dashicons dashicons-arrow-down-alt2" aria-controls="primary-menu" aria-expanded="false" aria-label="<?php esc_attr_e( 'Primary Menu', 'wporg-forums' ); ?>"></button> |
---|
49 | <div id="primary-menu" class="menu"> |
---|
50 | <ul> |
---|
51 | <?php |
---|
52 | foreach ( $menu_items as $path => $text ) : |
---|
53 | $url = parse_url( $path ); |
---|
54 | |
---|
55 | // Check both host and path (if available). |
---|
56 | $is_same_host = ! empty( $url['host'] ) ? $url['host'] === $_SERVER['HTTP_HOST'] : true; |
---|
57 | $is_same_path = ! empty( $url['path'] ) && false !== strpos( $_SERVER['REQUEST_URI'], $url['path'] ); |
---|
58 | |
---|
59 | $class = ( $is_same_host && $is_same_path ) ? 'class="active" ' : ''; |
---|
60 | |
---|
61 | if ( ! empty( $url['host' ] ) ) { |
---|
62 | $url = esc_url( $path ); |
---|
63 | } else { |
---|
64 | $url = esc_url( home_url( $path ) ); |
---|
65 | } |
---|
66 | ?> |
---|
67 | <li class="page_item"><a <?php echo $class; ?>href="<?php echo $url; ?>"><?php echo esc_html( $text ); ?></a></li> |
---|
68 | <?php endforeach; ?> |
---|
69 | <li><?php get_search_form(); ?></li> |
---|
70 | </ul> |
---|
71 | </div> |
---|
72 | </nav><!-- #site-navigation --> |
---|
73 | <?php endif; ?> |
---|
74 | </div><!-- .site-branding --> |
---|
75 | </header><!-- #masthead --> |
---|
76 | <div id="lang-guess-wrap"></div> |
---|