-
-
Save pippinsplugins/3126005 to your computer and use it in GitHub Desktop.
Filter to apply a div before menu output
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
<?php | |
function tumble_menu( $args = array() ) { | |
/* Default arguments */ | |
$defaults = array( | |
'container' => 'ul', | |
'menu_class' => 'nav', | |
'menu_id' => 'top_nav', | |
'theme_location' => 'top-menu', | |
'echo' => false, | |
'before' => '', | |
'after' => '', | |
'link_before' => '', | |
'link_after' => '', | |
'depth' => 1, | |
'sort_column' => 'menu_order', | |
'walker' => '' | |
); | |
$defaults = apply_filters( 'tumble_nav_default_args', $defaults); | |
$args = wp_parse_args( $args, $defaults ); | |
$main_menu = wp_nav_menu( $args ); | |
} | |
function tumble_add_menu_wrapper($html, $begin, $end) { | |
// wrap our original HTML with the new tags | |
return $begin . $html . $end; | |
} | |
add_filter( 'tumble_menu_wrap', 'tumble_add_menu_wrapper', 10, 3 ); | |
function tumble_do_menu_wrapper() { | |
$html = tumble_menu(); | |
echo apply_filters( 'tumble_menu_wrap', $html, '<div class="menu-button">Menu</div>','' ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated the site with the new code, does the same thing, menu under ul