Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #122 from jmr06005/master
Browse files Browse the repository at this point in the history
Set default menu style on left nav check
  • Loading branch information
jmr06005 committed Aug 26, 2015
2 parents 9283864 + e65ec61 commit adbf606
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions inc/submenu-check.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
<?php
$navoption1 = get_option( 'navoption1');

$has_sub_menu = false;
$menu_name = 'primary';
$current_id = 0;
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
$level = 0;
$stack = array('0');
if(is_array($menu_items)){
foreach($menu_items as $key => $menu_item) {
if($menu_item->object_id == get_the_ID()) $current_id = $menu_item->ID;
}
foreach($menu_items as $key => $menu_item) {
while(in_array($menu_item->menu_item_parent, $stack) && $menu_item->menu_item_parent != array_pop($stack)) {
$level--;
}
$level++;
$stack[] = $menu_item->menu_item_parent;
$stack[] = $menu_item->ID;
$menu_items[$key]->level = $level;

if($menu_item->menu_item_parent == $current_id && $level > 2 || $menu_item->ID == $current_id && $level > 2 && $navoption1 == 'drop'){
$has_sub_menu = true;
}
}
}
//print_r($menu_items);
}
if($has_sub_menu){
?>
<div class="row">
<div class="col-sm-3">
<nav id="nav-secondary">
<?php include('sidemenu-walker.php')?>
</nav>
</div>
<div class="col-sm-9">
<?php
$navoption1 = get_option( 'navoption1', 'drop' );

$has_sub_menu = false;
$menu_name = 'primary';
$current_id = 0;
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
$level = 0;
$stack = array('0');
if(is_array($menu_items)){
foreach($menu_items as $key => $menu_item) {
if($menu_item->object_id == get_the_ID()) $current_id = $menu_item->ID;
}
foreach($menu_items as $key => $menu_item) {
while(in_array($menu_item->menu_item_parent, $stack) && $menu_item->menu_item_parent != array_pop($stack)) {
$level--;
}
$level++;
$stack[] = $menu_item->menu_item_parent;
$stack[] = $menu_item->ID;
$menu_items[$key]->level = $level;

if($menu_item->menu_item_parent == $current_id && $level > 2 || $menu_item->ID == $current_id && $level > 2 && $navoption1 == 'drop'){
$has_sub_menu = true;
}
}
}
//print_r($menu_items);
}
if($has_sub_menu){
?>
<div class="row">
<div class="col-sm-3">
<nav id="nav-secondary">
<?php include('sidemenu-walker.php')?>
</nav>
</div>
<div class="col-sm-9">
<?php } /* end checkMenu */?>

0 comments on commit adbf606

Please sign in to comment.