\n"; } } /** * Remove the id="" on nav menu items */ add_filter( 'nav_menu_item_id', '__return_null' ); /** * add span around text in links, add icon, add description. */ function ascend_menu_nav_args($args, $item, $depth) { $ascend_iconmenu = get_post_meta($item->ID, '_menu_item_kticonmenu', true); $args->link_before = ! empty( $ascend_iconmenu) ? '' : ''; if ( $depth == 0 ) { $args->after = ! empty( $item->description ) ? '' . esc_attr( $item->description ) . '' : ''; } return $args; } add_filter( 'nav_menu_item_args', 'ascend_menu_nav_args', 20, 3 ); /** * add classes */ function ascend_menu_nav_li_css_classes( $classes, $item, $args, $depth = null ) { if ( $ascend_lgmenu = get_post_meta( $item->ID, '_menu_item_ktlgmenu', true ) ) { $classes[] = 'kt-lgmenu'; if ( $ascend_columnmenu = get_post_meta( $item->ID, '_menu_item_ktcolumnmenu', true ) ) { $classes[] = 'kt-menu-column-' . $ascend_columnmenu; } } if ( in_array( 'menu-item-has-children', $classes ) ) { if ( $depth === 0 ) { $classes[] = 'sf-dropdown'; } elseif ( $depth === 1 ) { $classes[] = 'sf-dropdown-submenu'; } elseif ( $depth === 2 ) { $classes[] = 'sf-dropdown-submenu'; } elseif ( $depth === 3 ) { $classes[] = 'sf-dropdown-submenu'; } } return $classes; } add_filter( 'nav_menu_css_class', 'ascend_menu_nav_li_css_classes', 20, 4 ); /** * Clean up wp_nav_menu_args * * Remove the container * * @param array $args array of args. */ function ascend_nav_menu_args( $args = '' ) { $ascend_args = array(); if ( ( ! isset( $args['container_class'] ) || empty( $args['container_class'] ) ) && ( ! isset( $args['container_id'] ) || empty( $args['container_id'] ) ) ) { $ascend_args['container'] = false; } if ( ! $args['items_wrap'] ) { $ascend_args['items_wrap'] = ''; } if ( ! $args['walker'] ) { $ascend_args['walker'] = new Ascend_Nav_Walker(); } return array_merge( $args, $ascend_args ); } add_filter( 'wp_nav_menu_args', 'ascend_nav_menu_args', '10' ); /** * Custom Menu Walker */ class ascend_mobile_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $output .= "\n