function clean_custom_menus() {
$menu_name = ‘primary’; // specify custom menu slug
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);
$menu_list = ‘<ul class=”nav navbar-nav”>’;
foreach( $menu_items as $menu_item ) {
if( $menu_item->menu_item_parent == 0 ) {
$parent = $menu_item->ID;
$menu_array = array();
foreach( $menu_items as $submenu ) {
if( $submenu->menu_item_parent == $parent ) {
$bool = true;
$menu_array[] = ‘<li><a href=”#’ . strtolower(str_replace(‘ ‘, ‘_’, $submenu->title)) . ‘”>’ . $submenu->title . ‘</a></li>’ .”\n”;
}
}
if( $bool == true && count( $menu_array ) > 0 ) {
$menu_list .= ‘<a class=”btn btn-default dropdown-toggle” type=”button” id=”dropdownMenu1″ data-toggle=”dropdown” aria-haspopup=”true” aria-expanded=”true”>
‘ . $menu_item->title . ‘ <i class = “fa fa-angle-down”></i>
</a>’ .”\n”;
$menu_list .= ‘<ul class=”sub-menu”>’ .”\n”;
$menu_list .= implode( “\n”, $menu_array );
$menu_list .= ‘</ul>’ .”\n”;
} else {
$menu_list .= ‘<li><a href=”#’ . strtolower(str_replace(‘ ‘, ‘_’, $menu_item->title)) . ‘”>’ . $menu_item->title . ‘</a></li>’ .”\n”;
}
}
}
}
$menu_list .= ‘</ul>’;
echo $menu_list;
}
काक चेष्टा, बको ध्यानं, श्वान निंद्रा तथैव च । अल्पाहारी, सदाचारी एतद विद्यार्थिन पंच लक्षणं ।।...read more
Quote Of The Day