After few hours of debugging I found out, that the wps_custom_nav_menu_items() actually receives the nav_menu_items with classes, applied by the _wp_menu_item_classes_by_context, but instead of using them, it reloads the entire menu from the database!
So if you change
$nav_items = wp_get_nav_menu_items( $menu_id );
To
$nav_items = $args;
(or just remove the line and rename the function argument), it works as expected.
Related Posts:
- Check if add_menu_page exists or not
- Add custom menu item type
- Add section (add_settings_section) to a custom page (add_submenu_page)
- What’s the easiest way to duplicate an entire navigation menu?
- How to call “page specific menu items” in template [closed]
- Custom wp_nav_menu output (displaying all child elements of top menu element in current branch)
- wp_nav_menu(); Outside WordPress installation
- How to make a plugin auto-add item to nav menu
- Does the ‘nav_menu_css_class’ filter accept 2 or 3 arguments?
- How do I make a wordpress plugin with menu item etc
- Creating WordPress Plugin solely for Admin panel with dash menu and submenus
- Popup Maker nav menu item not working
- Creating a menu page in a Object Oriented developed plugin
- Multiple navigation menus to a location?
- Making menu link open in new tab?
- Include Max mega menu Plugin into theme
- How use %like% in sql statement wordpress
- Wondering what these multi-colored extra pages are?
- Set the active Navigation Menu from a plugin
- Menus, but not by theme location
- How to make a customize role and view a specific plugins base on that role?
- Creating a nav menu
- Easiest way to add dropdown to a page
- How to get the element ID from new menu list that added with add_filter()?
- Merging Two menus in the backend into one menu
- Delete mobile menu button [closed]
- html generated by theme exist but doesnt appear in browser
- Changing page URL and connect newsletter to MailChip
- Dynamic admin submenu
- Center and hide overflow of WP toolbar custom links
- How to remove admin main menu name repetition
- Custom Permalink Plugin and Current Page/Ancestor in Menus
- add_action does not call the function
- How to use my menu PHP code as sidebar?
- Redirect to another page using contact form 7? [closed]
- Hide a Menu Item on Login
- How to get menu location in wp_update_nav_menu hook
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Progmatically adding menu links to the default (Top) or Footer menu
- $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?
- Changing location of “About me” section
- Need to revert to an older version of wordpress
- WordPress Custom Menu Admin helper plugin
- How can I add a fixed vertical menu to my site? [closed]
- 2 wordpress site same database
- Hook on creating a menu entry?
- Dropdown menu on click change
- navigation among single posts
- How do i specify a url to which to redirect the user after he logs out from facebook?
- I cannot include a file in my plugin settings page
- Button and Countdown overlapping mobile menu
- Slideout submenu in mobile
- Display posts by alphabetical order
- Mobile Menu and Mobile Sidebar missing
- WP Forms not displaying,becomming an fatal error
- WordPress Dashboard add user password not working, etc
- WordPress site hamburger menu toggle not working
- Add custom WordPress admin page with pretty url via code
- I need to show side menu in wordpress
- Scroll to ID broken in main menu
- Create survey that redirects to sidebar menu customized to answers
- Circular Menu to show on pages
- jquery plugin won’t fire when hamburger class element clicked
- Page Contents showing in Footer Area
- How to disable users to view Other pages
- Sub Categories in drop down menu
- Admin page and admin menu. Permissions plugin
- WordPress menu and plugin installation problem
- Power Menus plugin destroys menu after adding new item
- How to assign plugin to top level menu?
- Adding icons next to categories in wp_nav_menu
- WP Super Large Menu Problem
- How to build a navigation menu for long-form texts like this one
- add_media_page function not creating submenu
- How can I pass value to function in add_menu_page?
- Automatically add child pages to menu
- Multiple Plugins Interacting with Menu
- Drop down menu location select widget
- How to add plugin activity in the menus?
- How change menu for each user in plugin?
- Menu items’ links are not working properly and added images
- how to change/remove/hide menu under installed plugins
- Category archive in menu
- Redirect url in plugin to somewhere else?
- How to activate/deactivate menu tab and keep the same id?
- How can I add different menus (different style menu) on each page?
- Make a Custom template for a specific category in wordpress
- How can I create a navigation menu in the sidebar that can also act like a slider?
- Call to a member function get_page_permastruct() on null
- Automatically put a menu on every post
- How to validate password length in wordpress
- Why plugin’s icon for the menu not found?
- Plugin: Custom menu item problem
- Is it possible to know which menus are owned by a plugin?
- How to make horizontal scrolling menu [closed]
- My wp_update_nav_menu action is firing twice
- How to check if the Menubar contains no items?
- How does one add numbers to an admin menu?
- Adding fontAwesome to Primary Menu returns after saving the menu
- Prevent primary navigational menu from expanding during page load (WordPress / Astra Theme)