-
-
Save AnnaCrumina/0489116a8007b5348242 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
register_nav_menu('top-bar-l', __( 'Top Bar Left', 'reactor')); | |
register_nav_menu('top-bar-r', __( 'Top Bar Right', 'reactor')); | |
/** | |
* Top bar left menu | |
* | |
* @since 1.0.0 | |
* @see wp_nav_menu | |
* @param array $locations Associative array of menu location identifiers (like a slug) and descriptive text. | |
*/ | |
if ( !function_exists('reactor_top_bar_l') ) { | |
function reactor_top_bar_l() { | |
$defaults = array( | |
'theme_location' => 'top-bar-l', | |
'container' => false, | |
'menu_class' => 'top-bar-menu left', | |
'echo' => 0, | |
'fallback_cb' => false, | |
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', | |
'depth' => 0, | |
'walker' => new Top_Bar_Walker() | |
); | |
return wp_nav_menu( $defaults ); | |
} | |
} | |
/** | |
* Top bar right menu | |
* | |
* @since 1.0.0 | |
* @see wp_nav_menu | |
* @param array $locations Associative array of menu location identifiers (like a slug) and descriptive text. | |
*/ | |
if ( !function_exists('reactor_top_bar_r') ) { | |
function reactor_top_bar_r() { | |
$defaults = array( | |
'theme_location' => 'top-bar-r', | |
'container' => false, | |
'menu_class' => 'top-bar-menu right', | |
'echo' => 0, | |
'fallback_cb' => false, | |
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', | |
'depth' => 0, | |
'walker' => new Top_Bar_Walker() | |
); | |
return wp_nav_menu( $defaults ); | |
} | |
} | |
/** | |
* Top Bar Function | |
* output code for the Foundation top bar structure | |
* | |
* @package Reactor | |
* @author Anthony Wilhelm (@awshout / anthonywilhelm.com) | |
* @since 1.0.0 | |
* @license GNU General Public License v2 or later (http://www.gnu.org/licenses/gpl-2.0.html) | |
*/ | |
if ( !function_exists('reactor_top_bar') ) { | |
function reactor_top_bar( $args = '' ) { | |
$defaults = array( | |
'title' => get_bloginfo('name'), | |
'title_url' => home_url(), | |
'menu_name' => 'Menu', | |
'left_menu' => 'reactor_top_bar_l', | |
'right_menu' => 'reactor_top_bar_r', | |
'fixed' => false, | |
'contained' => true, | |
'sticky' => false, | |
); | |
$args = wp_parse_args( $args, $defaults ); | |
$args = apply_filters( 'reactor_top_bar_args', $args ); | |
/* call functions to create right and left menus in the top bar. defaults to the registered menus for top bar */ | |
$left_menu = ( ( $args['left_menu'] && is_callable( $args['left_menu'] ) ) ) ? call_user_func( $args['left_menu'], (array) $args ) : ''; | |
$right_menu = ( ( $args['right_menu'] && is_callable( $args['right_menu'] ) ) ) ? call_user_func( $args['right_menu'], (array) $args ) : ''; | |
// assemble classes for top bar | |
$classes = array(); $output = ''; | |
$classes[] = ( $args['fixed'] ) ? 'fixed' : ''; | |
$classes[] = ( $args['contained'] ) ? 'contain-to-grid' : ''; | |
$classes[] = ( $args['sticky'] ) ? 'sticky' : ''; | |
$classes = array_filter( $classes ); | |
$classes = implode( ' ', array_map( 'esc_attr', $classes ) ); | |
// start top bar output | |
if ( has_nav_menu('top-bar-l') || has_nav_menu('top-bar-r') ) { | |
$output .= '<div class="top-bar-container ' . $classes . '">'; | |
$output .= '<nav class="top-bar">'; | |
$output .= '<ul class="title-area">'; | |
$output .= '<li class="name">'; | |
$output .= '<p><a href="' . $args['title_url'].'">' . $args['title'] . '</a></p>'; | |
$output .= '</li>'; | |
$output .= '<li class="toggle-topbar menu-icon"><a href="#"><span>' . $args['menu_name'] . '</span></a></li>'; | |
$output .= '</ul>'; | |
$output .= '<section class="top-bar-section">'; | |
$output .= $left_menu; | |
$output .= $right_menu; | |
$output .= '</section>'; | |
$output .= '</nav>'; | |
$output .= '</div>'; | |
echo apply_filters('reactor_top_bar', $output, $args); | |
} | |
} | |
} | |
function reactor_do_top_bar() | |
{ | |
$topbar_args = array( | |
'title' => false, | |
'title_url' => false, | |
'fixed' => false, | |
'contained' => true, | |
); | |
reactor_top_bar($topbar_args); | |
} | |
add_action('reactor_header_before', 'reactor_do_top_bar', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment