submenu * hidden via CSS (.eppro-mega-item--mega > .eppro-submenu) and replaced by * the rendered template panel appended in end_el(). * * @package AdMoreWidgetsSuite * @since 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) exit; class EPPRO_Mega_Menu_Walker extends Walker_Nav_Menu { /** @var array Map of menu item ID → mega config. */ private array $mega_config = []; public function __construct( array $mega_config ) { $this->mega_config = $mega_config; } // ========================================================================= // start_el — opening
  • and with toggle button // ========================================================================= public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ): void { $indent = str_repeat( "\t", $depth ); $classes = empty( $item->classes ) ? [] : (array) $item->classes; $classes[] = 'eppro-mega-item'; $classes[] = 'menu-item-' . $item->ID; if ( in_array( 'current-menu-item', $classes, true ) ) { $classes[] = 'eppro-mega-item--active'; } $has_children = $args->walker->has_children ?? false; $has_mega = $depth === 0 && isset( $this->mega_config[ $item->ID ] ) && ! empty( $this->mega_config[ $item->ID ]['template_id'] ); if ( $has_children || $has_mega ) { $classes[] = 'eppro-mega-item--has-dropdown'; } if ( $has_mega ) { $classes[] = 'eppro-mega-item--mega'; // CSS uses this to hide the