Last active
October 8, 2019 13:05
-
-
Save jamesozzie/430555b1b7c539e8d98b7c660a8dc707 to your computer and use it in GitHub Desktop.
Reader mode: Navigation menu & search popup extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Header bar template part. | |
* | |
* This is a forked version of the header-bar.php in the AMP plugin. | |
* | |
* @link https://github.com/ampproject/amp-wp/blob/e63d2c3034d079f1a1b5bb2f0a2d1e0a221cadb9/templates/header-bar.php | |
* @package AMP_Reader_Nav_Menu | |
*/ | |
namespace AMP_Reader_Nav_Menu; | |
/** | |
* Context. | |
* | |
* @var \AMP_Post_Template $this | |
*/ | |
?> | |
<div id="modal1" class="overlay"> | |
<a class="cancel" href="#"></a> | |
<div class="modal"> | |
<div class="content"> | |
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo site_url(); ?>" | |
target="_top"> | |
<label class="screen-reader-text" for="s"></label> | |
<div class="af_searchbutton"> | |
<div class="search"> | |
<input type="text" value="" name="s" id="s" class="searchTerm" placeholder="Search..." | |
autofocus="" tabindex="1"> | |
<button type="submit" class="searchButton" id="searchsubmit" value="Search"> | |
<svg style="height:1em;" viewBox="0 0 12 13"> | |
<g stroke-width="2" stroke="#fff" fill="none"> | |
<path d="M11.29 11.71l-4-4"></path> | |
<circle cx="5" cy="5" r="4"></circle> | |
</g> | |
</svg> | |
</button> | |
</div> | |
</div> | |
</form> | |
</div> | |
</div> | |
</div> | |
<header id="top" class="amp-wp-header"> | |
<div> | |
<?php if ( has_nav_menu( NAV_MENU_LOCATION ) ) : ?> | |
<button id="toggleNavMenu" type="button" on="tap:navMenu.open" | |
aria-label="<?php esc_html__( 'Open nav menu', 'amp-reader-nav-menu' ); ?>">☰</button> | |
<?php endif; ?> | |
<a href="#modal1" class="button"> | |
<button type="submit" class="standalone_searchButton" id="searchsubmit" value="Search"> | |
<svg style="height:0.9em;" viewBox="0 0 12 13"> | |
<g stroke-width="2" stroke="#666" fill="none"> | |
<path d="M11.29 11.71l-4-4"></path> | |
<circle cx="5" cy="5" r="4"></circle> | |
</g> | |
</svg> | |
</button> | |
</a> | |
<a href="<?php echo esc_url( $this->get( 'home_url' ) ); ?>"> | |
<?php $site_icon_url = $this->get( 'site_icon_url' ); ?> | |
<?php if ( $site_icon_url ) : ?> | |
<amp-img src="<?php echo esc_url( $site_icon_url ); ?>" width="32" height="32" class="amp-wp-site-icon"> | |
</amp-img> | |
<?php endif; ?> | |
<span class="amp-site-title"> | |
<?php echo esc_html( wptexturize( $this->get( 'blog_name' ) ) ); ?> | |
</span> | |
</a> | |
<?php $canonical_link_url = $this->get( 'post_canonical_link_url' ); ?> | |
<?php if ( $canonical_link_url ) : ?> | |
<?php $canonical_link_text = $this->get( 'post_canonical_link_text' ); ?> | |
<a class="amp-wp-canonical-link" href="<?php echo esc_url( $canonical_link_url ); ?>"> | |
<?php echo esc_html( $canonical_link_text ); ?> | |
</a> | |
<?php endif; ?> | |
</div> | |
</header> | |
<?php if ( has_nav_menu( NAV_MENU_LOCATION ) ) : ?> | |
<?php | |
printf( | |
'<amp-sidebar id="navMenu" layout="nodisplay" side="%s">%s</amp-sidebar>', | |
esc_attr( is_rtl() ? 'right' : 'left' ), | |
wp_nav_menu( | |
[ | |
'location' => NAV_MENU_LOCATION, | |
'echo' => false, | |
'depth' => 3, | |
] | |
) | |
); | |
?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment