From ade79de867e9929001adebccd188c46f41a22dfa Mon Sep 17 00:00:00 2001 From: MickeyKay Date: Mon, 23 Mar 2015 15:47:56 -0700 Subject: [PATCH] Update responsive header/full menu behavior. --- includes/admin/customizer.js | 2 +- includes/admin/customizer.php | 20 +++++++++++++ includes/functions/theme-functions.php | 39 ++++++++++++++++++++++++++ style.css | 24 ++++++++-------- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/includes/admin/customizer.js b/includes/admin/customizer.js index 5249096..7a44eb4 100644 --- a/includes/admin/customizer.js +++ b/includes/admin/customizer.js @@ -79,7 +79,7 @@ wp.customize( 'genesis-settings[trestle_read_more_text]', function( value ) { value.bind( function( value ) { - $( 'a.more-link' ).text( value ); + $( 'a.more-link' ).html( value ); }); }); diff --git a/includes/admin/customizer.php b/includes/admin/customizer.php index b8a319e..93df40a 100644 --- a/includes/admin/customizer.php +++ b/includes/admin/customizer.php @@ -161,6 +161,26 @@ function trestle_customizer_controls( $wp_customize ) { ) ); + // Primary nav extras + $wp_customize->add_setting( + 'genesis-settings[trestle_custom_nav_extras_text]', + array( + 'default' => genesis_get_option( 'trestle_custom_nav_extras_text' ), + 'type' => 'option', + 'transport' => 'postMessage', + 'capability' => 'edit_theme_options', + ) + ); + $wp_customize->add_control( + 'trestle_custom_nav_extras_text_control', + array( + 'section' => 'trestle_settings_section', + 'settings' => 'genesis-settings[trestle_custom_nav_extras_text]', + 'label' => __( 'Add search to mobile navigation', 'trestle' ), + 'type' => 'checkbox', + ) + ); + // Blog post custom read more link text $wp_customize->add_setting( 'genesis-settings[trestle_read_more_text]', diff --git a/includes/functions/theme-functions.php b/includes/functions/theme-functions.php index 33a3789..0946233 100644 --- a/includes/functions/theme-functions.php +++ b/includes/functions/theme-functions.php @@ -202,6 +202,45 @@ function trestle_do_logos( $title, $inside, $wrap ) { } +/*=========================================== + * Navigation +===========================================*/ + +add_action( 'init', 'trestle_nav_primary_location' ); +/** + * Move primary navigation into the header if need be. + * + * @since 1.2.0 + */ +function trestle_nav_primary_location() { + + if ( 'header' == genesis_get_option( 'trestle_nav_primary_location' ) ) { + remove_action( 'genesis_after_header', 'genesis_do_nav' ); + add_action( 'genesis_header', 'genesis_do_nav', 12 ); + } + +} + +add_filter( 'wp_nav_menu_items', 'trestle_custom_nav_extras', 10, 2 ); +/** + * Add custom nav extras. + * + * @since 1.0.0 + * + * @param string $nav_items
  • list of menu items. + * @param stdClass $menu_args Arguments for the menu. + * @return string
  • list of menu items with custom navigation extras
  • appended. + */ +function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) { + + if ( 'primary' == $menu_args->theme_location && genesis_get_option( 'trestle_custom_nav_extras_text' ) ) { + return $nav_items . '
  • ' . get_search_form( false ) . '
  • '; + } + + return $nav_items; +} + + /*=========================================== * Posts & Pages ===========================================*/ diff --git a/style.css b/style.css index 68fd7e7..8c5cdc8 100644 --- a/style.css +++ b/style.css @@ -1616,7 +1616,7 @@ Site Navigation .genesis-nav-menu > .right .search-form { display: inline-block; - padding: 0; + padding: 8px 0; } .genesis-nav-menu > .right input[type="submit"] { @@ -1675,12 +1675,6 @@ Site Navigation padding: 0; } -.site-header .nav-primary a:hover, -.site-header .nav-primary [class*="current-"] > a, -.site-header .nav-primary [class*="current_"] > a { - color: #333; -} - .site-header .right { padding-right: 0; } @@ -2474,7 +2468,7 @@ Media Queries --------------------------------------------- */ .genesis-nav-menu > .right { - display: inline-block; + display: none; float: right; border-top: none; } @@ -2484,10 +2478,6 @@ Media Queries margin: 0 0 0 2rem; } - .genesis-nav-menu > .search form { - padding-right: 0; - } - .genesis-nav-menu > .right input[type="submit"] { display: inline-block; } @@ -2563,6 +2553,16 @@ Media Queries padding: 0.6em 1.2em; } + .site-header .nav-primary .menu > li:last-of-type:not(.right) { + padding-right: 0; + } + + .site-header .nav-primary a:hover, + .site-header .nav-primary [class*="current-"] > a, + .site-header .nav-primary [class*="current_"] > a { + color: #333; + } + /* Plugins --------------------------------------------- */