-
-
Save billerickson/ec95e8eb1e1dff851dc1c81ed15da49f to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Register AMP Menu | |
* | |
*/ | |
function ea_register_amp_menu() { | |
register_nav_menu( 'amp-header', 'AMP Header' ); | |
} | |
add_action( 'after_setup_theme', 'ea_register_amp_menu' ); | |
/** | |
* Load header file from our theme | |
* | |
*/ | |
function ea_amp_header( $file, $type, $post ) { | |
if( 'header-bar' == $type ) { | |
$file = get_stylesheet_directory() . '/amp-templates/header-bar.php'; | |
} | |
return $file; | |
} | |
add_filter( 'amp_post_template_file', 'ea_amp_header', 10, 3 ); | |
/** | |
* Header CSS | |
* | |
*/ | |
function ea_amp_header_css() { | |
// only CSS here please... | |
?> | |
.amp-wp-title-bar { | |
background: #3daad4; | |
height: 68px; | |
} | |
.amp-wp-title-bar a { | |
color: #fff; | |
text-decoration: none; | |
} | |
.amp-wp-title-bar a.logo { | |
height: 68px; | |
line-height: 68px; | |
} | |
.amp-wp-title-bar .nav-header { | |
float: right; | |
width: auto; | |
} | |
.amp-wp-title-bar .nav-header .mobile-open, | |
.amp-wp-title-bar .nav-header .mobile-close { | |
display: none; | |
} | |
.amp-wp-title-bar .nav-header ul { | |
margin: 0; | |
padding: 0; | |
} | |
.amp-wp-title-bar .nav-header li { | |
display: block; | |
list-style-type: none; | |
float: left; | |
} | |
.amp-wp-title-bar .nav-header a { | |
display: block; | |
padding: 20px; | |
font-family: sans-serif; | |
} | |
@media only screen and (max-width: 767px) { | |
.amp-wp-title-bar { | |
height: auto; | |
} | |
.amp-wp-title-bar .nav-header { | |
float: none; | |
overflow: hidden; | |
width: 100%; | |
} | |
.amp-wp-title-bar .nav-header ul { | |
height: 0; | |
} | |
.amp-wp-title-bar .nav-header:hover ul { | |
height: auto; | |
} | |
.amp-wp-title-bar .nav-header .mobile-open { | |
position: absolute; | |
top: 0; | |
right: 0; | |
display: block; | |
color: #fff; | |
font-size: 18px; | |
padding: 20px; | |
cursor: pointer; | |
} | |
.amp-wp-title-bar .nav-header li { | |
float: none; | |
} | |
.amp-wp-title-bar .nav-header a { | |
padding: 10px 16px; | |
text-align: center; | |
} | |
} | |
<?php | |
} | |
add_action( 'amp_post_template_css', 'ea_amp_header_css' ); |
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
<div class="amp-wp-title-bar"> | |
<div class="wrap"> | |
<a class="logo" href="<?php echo esc_url( $this->get( 'home_url' ) ); ?>"> | |
<?php echo esc_html( $this->get( 'blog_name' ) ); ?> | |
</a> | |
<?php | |
if( has_nav_menu( 'header' ) ) { | |
echo '<nav class="nav-header"><div class="mobile-open">☰</div>'; | |
wp_nav_menu( array( 'theme_location' => 'header', 'container' => 'false', 'depth' => 1 ) ); | |
echo '</nav>'; | |
} | |
?> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment