<?php
/**
* Menu Walker
*
* @package Katerio
*/
/*
--------------------------------------------------------------------------------
* Menu Walker
* ------------------------------------------------------------------------------
*/
if ( ! function_exists( 'th90_menu_walker_filters' ) ) {
function th90_menu_walker_filters( $item_output, $item, $depth, $args ) {
$attributes = $item_output = $th90_menu_template = '';
$have_template = false;
if ( 0 === $depth ) {
$th90_menu_template = get_post_meta( $item->ID, 'menu-item-th90_menu_template', true );
}
if ( 1 != $args->depth && 'nav-main' == $args->menu_class && $th90_menu_template && th90_display_elementor_content( $th90_menu_template ) && ! in_array( 'menu-item-has-children', $item->classes ) ) {
$have_template = true;
}
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
if ( $have_template ) {
$attributes .= ' class="have-megamenu"';
}
$item_output = '<a'. $attributes .'>';
$item_output .= '<span class="menu-text">';
$item_output .= $args->link_before .apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= '</span>';
// Mobile Submenu Pointer
$item_output .= 'nav-mobile' == $args->menu_class && in_array( 'menu-item-has-children', $item->classes ) ? '<span class="sub-pointer"></span>' : '';
$item_output .= '</a>';
// Menu Elementor Template
if ( $have_template ) {
$item_output .= '<ul class="sub-menu mega-template">';
$item_output .= '<li>';
$item_output .= th90_display_elementor_content( $th90_menu_template );
$item_output .= '</li>';
$item_output .= '</ul>';
}
return $item_output;
}
}
add_filter( 'walker_nav_menu_start_el', 'th90_menu_walker_filters', 10, 4 );