Created
November 29, 2015 19:12
-
-
Save daveharrisonnet/f5e5a7e9e35c1aa9d8be 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
// megamenu remove default menu and replace with hacked version split up by top level category | |
function do_things_late() { | |
global $listify_job_manager; | |
$template = $listify_job_manager->template; | |
$childargs = ''; | |
global $listify_navigation; | |
remove_action( 'wp_nav_menu_items', array( $template, 'taxonomy_mega_menu' ), 0, 2 ); | |
//add_action( 'wp_nav_menu_items', 'modified_taxonomy_mega_menu' , 20); | |
add_action( 'wp_nav_menu_items', 'modified_taxonomy_mega_menu', 0, 2 ); | |
function modified_taxonomy_mega_menu( $items, $childargs ) { | |
if ( 'none' == listify_theme_mod( 'nav-megamenu' ) ) { | |
return $items; | |
} | |
if ( 'secondary' != $childargs->theme_location ) { | |
return $items; | |
} | |
$taxonomy = get_taxonomy( listify_theme_mod( 'nav-megamenu' ) ); | |
if ( is_wp_error( $taxonomy ) ) { | |
return $items; | |
} | |
global $listify_strings; | |
$link = sprintf( | |
'<a href="%s">' . __( 'Browse ALL %s', 'listify' ) . '</a>', | |
get_post_type_archive_link( 'job_listing' ), | |
str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->name ) | |
); | |
$submenu = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$link1 = '<a href="/listings/things-to-do">Things To Do</a>'; | |
$submenu1 = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 146, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$link2 = '<a href="/listings/services">Services</a>'; | |
$submenu2 = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
//'child_of' => 480, | |
'child_of' => 254, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$link3 = '<a href="/listings/lifestyle">Lifestyle</a>'; | |
$submenu3 = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 159, | |
//child_of' => 481, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$dropdown = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$dropdown1 = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 146, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$dropdown2 = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 254, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$dropdown3 = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 159, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$submenu = | |
'<ul class="sub-menu category-list">' . | |
'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown . '</form> | |
<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
$submenu1 = | |
'<ul class="sub-menu category-list">' . | |
//'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown1 . '</form> | |
'<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu1 . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
$submenu2 = | |
'<ul class="sub-menu category-list">' . | |
//'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown2 . '</form> | |
'<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu2 . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
$submenu3 = | |
'<ul class="sub-menu category-list">' . | |
//'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown3 . '</form> | |
'<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu3 . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
return '<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link . $submenu .'<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link1 . $submenu1 . '<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link2 . $submenu2 . '<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link3 . $submenu3 . '' .$items; | |
} | |
} | |
add_action( 'init', 'do_things_late', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment