Popup Maker Is Overwriting My Menu Editor Functions - How Can I Fix This?
In special circumstances, a site theme or plugin can change the behavior of the default WordPress navigation menu editor. Symptoms may include missing menu editor capabilities that were present before Popup Maker was installed and activated.
WordPress does not include a way to add custom fields to the menu editor. However, WordPress does allow the override of a PHP Class used to create the menu editor. Only one plugin or theme at a time is allowed to override this Class.
The most common solution is to copy the
Walker_Nav_Menu_Edit Class from WordPress, and add it to your theme or plugin where you intend to place custom fields in the menu editor. When another plugin or theme tries to add a custom field by replacing this Class, the first custom field added to the menu editor by the previous theme or plugin will no longer appear.
The solutions presented below were created several years back, and work with dozens of plugins that modify the WordPress menu editor. These solutions are currently used in roughly 30 plugins available in the WordPress.org plugin repository and dozens of themes, as well as by many premium (paid) plugins sold on Code Canyon.
The solution makes one change to the Class used to override the
Walker_Nav_Menu_Edit Class in WordPress core. It adds an action hook (
do_action() ) so that Popup Maker can add custom fields to a menu editor using
add_action(). The solution allows other plugins or themes to do the same within their codebase.
We recommend that you contact your theme or plugin author, and request that they update their code. This is the preferred solution because it can allow users of that theme (or plugin) to also use other plugins that include User Menus, Nav Menu Roles, and If Menu.
The solutions shown below maintain backward compatibility to WordPress version 3.0 and remain effective up to the present release.
Solution #1 -- Disable 'Popups Menu Editor' Feature via the Popup Maker Admin
Disable the Popup Maker Menu Editor:
1. In the WordPresss Admin, go to:
'Popup Maker' (menu) >> 'Settings' (submenu) >> 'Misc' (tab).
2. Select the 'Misc' category option page.
3. Select the checkbox at the bottom of the list labeled 'Disable Popups Menu Editor'.
Note: A Popup Maker 'Click Open' trigger can still be set on a navigation link, even when the popup menu editor feature is turned off. See the related article link below. Refer to either method 1 or 3 to set a trigger.
Related article: Trigger: Click Open -- Overview & Methods
Solution #2 -- Edit 'WP_Edit_Nav_Menu_Walker' Filter in a Theme or Plugin
1. In your theme or plugin, register the callback shown below to the current
wp_edit_nav_menu_walker filter from WordPress. [ The filter is located in WordPress Core at ‘/wp-admin/includes/nav-menu.php’ within the function
wp_get_nav_menu_to_edit( $menu_id = 0 ). ] Correct file paths for your needs.
2. Include the following files/classes to your plugin into the paths from the function above. Do not rename the classes. There are ample checks to prevent them from being reloaded if they exist already. Keeping these names ensures long term compatibility for all plugins using them.
To view the code used to implement this solution, refer to the files within our plugin repository below.
3. Move your custom Nav Menu Editor fields (without modification) to a new function hooked as seen below.
4. As a bonus, you can include an option to show/hide specific fields the same way WP Core does in the Nav Editor.