Skip to content

Instantly share code, notes, and snippets.

@aaronhartland
Created June 3, 2012 20:53
Show Gist options
  • Save aaronhartland/2865020 to your computer and use it in GitHub Desktop.
Save aaronhartland/2865020 to your computer and use it in GitHub Desktop.
breaking stuff - genesis | bootstrap
<?php
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action('genesis_before_header', 'ah_genesis_do_nav');
/**
* Echoes the "Primary Navigation" menu.
*
* The preferred option for creating menus is the Custom Menus feature in
* WordPress. There is also a fallback to using the Genesis wrapper functions
* for creating a menu of Pages, or a menu of Categories (maintained only for
* backwards compatibility).
*
* Either output can be filtered via 'genesis_do_nav'.
*
* @since 1.0.0
*
* @uses genesis_get_option() Get theme setting value
* @uses genesis_nav() Use old-style Genesis Pages or Categories menu
* @uses genesis_structural_wrap() Adds optional internal wrap divs
*/
function ah_genesis_do_nav() {
/** Do nothing if menu not supported */
if ( ! genesis_nav_menu_supported( 'primary' ) )
return;
if ( genesis_get_option( 'nav' ) ) {
if ( has_nav_menu( 'primary' ) ) {
$args = array(
'theme_location' => 'primary',
'container' => '',
'menu_class' => genesis_get_option( 'nav_superfish' ) ? 'menu menu-primary superfish' : 'menu menu-primary',
'echo' => 0,
);
$nav = wp_nav_menu( $args );
} elseif ( 'nav-menu' != genesis_get_option( 'nav_type', 'genesis-vestige' ) ) {
$args = array(
'theme_location' => 'primary',
'menu_class' => genesis_get_option( 'nav_superfish' ) ? 'menu menu-primary superfish' : 'menu menu-primary',
'show_home' => genesis_get_option( 'nav_home', 'genesis-vestige' ),
'type' => genesis_get_option( 'nav_type', 'genesis-vestige' ),
'sort_column' => genesis_get_option( 'nav_pages_sort', 'genesis-vestige' ),
'orderby' => genesis_get_option( 'nav_categories_sort', 'genesis-vestige' ),
'depth' => genesis_get_option( 'nav_depth', 'genesis-vestige' ),
'exclude' => genesis_get_option( 'nav_exclude', 'genesis-vestige' ),
'include' => genesis_get_option( 'nav_include', 'genesis-vestige' ),
'echo' => false,
);
$nav = genesis_nav( $args );
}
$nav_output = sprintf( '<div class="navbar">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="nav-collapse collapse"><div id="nav">%2$s%1$s%3$s</div>
</div></div></div></div>', $nav, genesis_structural_wrap( 'nav', 'open', 0 ), genesis_structural_wrap( 'nav', 'close', 0 ));
echo apply_filters( 'ah_genesis_do_nav', $nav_output, $nav, $args );
}
}
add_action( 'genesis_meta', 'bootstrap_css_stuff' );
/**
* Add in bootstrap stuff as needed
*
*/
function bootstrap_css_stuff() {
$bootstrap_to_header = '<link rel="stylesheet" href="'.get_bloginfo( 'stylesheet_directory' ).'/assets/css/bootstrap-responsive.css">';
echo $bootstrap_to_header;
}
add_action( 'genesis_after', 'bootstrap_stuff' );
/**
* Add in bootstrap stuff as needed
*
*/
function bootstrap_stuff() {
$bootstrap_to_footer = '<script src="'.get_bloginfo( 'stylesheet_directory' ).'/assets/js/bootstrap-collapse.js"></script>';
echo $bootstrap_to_footer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment