classes)) { return ''; } return $title; } /** * Add account dropdown with dynamic menu items and SVG icons * Features: Desktop hover dropdown, mobile fixed menu, accessible close button, keyboard support */ add_action('wp_footer', 'add_account_dropdown'); function add_account_dropdown() { $menu_items = array(); $menu_name = 'mobile-my-account'; if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) { $menu = wp_get_nav_menu_object($locations[$menu_name]); $all_items = wp_get_nav_menu_items($menu->term_id); if ($all_items) { $parent_id = 0; foreach ($all_items as $item) { if (in_array('offcanvas-account-trigger', $item->classes)) { $parent_id = $item->ID; break; } } if ($parent_id) { foreach ($all_items as $item) { if ($item->menu_item_parent == $parent_id) { $menu_items[] = $item; } } } } } $icons = array( 0 => '', 1 => '', 2 => '', 3 => '', ); $is_logged_in = is_user_logged_in(); $current_user = $is_logged_in ? wp_get_current_user() : null; ?>