@refica – Hmm, sorry to hear that. I will have to add an option to disable the menu editor in these cases. The issue is actually in your theme, as well as in WordPress core. You can revert back to 1.4.21 since this feature was built into v1.5.0. The rest I am adding here for you and others to send to their theme authors to make this much better for everyone. It describes the entire issue, as well as a permanent & stable solution used on over 300k websites between Popup Maker, Nav Menu Roles, If Menus and various themes.
Look for the new option in v1.5.7.
Going to mark this resolved as I know the issue, am adding an option to disable on our end and detailed the solution for others & theme developers below.
Hope that helps. Please take a moment to click that it Works and to rate and review the plugin or support.
Basically in short:
WordPress core doesn’t include any way to add custom fields to the menu editor. They allow overriding a PHP class that is used to create the menu editor though, but only one plugin/theme can do this at a time.
The most common solution is to simply copy the core WP class and add your fields where they would go. This means that when another plugin tries to add fields by replacing the class WP uses the first no longer appears.
Our solution was created a few years back and will work with dozens of plugins modifying the menu editor. It is currently used in ~30 plugins on the www.remarpro.com repo and dozens of themes, as well as a lot of premium ones on codecanyon for instance. It only makes one change to the class used to override the core one, it adds a hook/action so that we can add fields via add_action, and others can do the same.
We recommend trying to reach out to your theme author and getting them to update their code, which is a much better solution as it will then allow users of your theme to also use other plugins such as User Menus, Nav Menu Roles, If Menu etc.
It has also been tested all the way back to WordPress v3.0 and works with any version between there due to lots of testing for maximum backward compatibility.
The solution if you want to point them here for reference is simple. I will put this here so we can also point other theme authors here over the coming months.
Solution
1. Replace your current wp_edit_nav_menu_walker
filter with this one. Correct paths for your needs.
function custom_nav_menu_walker( $walker ) {
global $wp_version;
// Here to prevent false warnings from If Menu and plugins that notify you of nav menu walker replacement.
if ( doing_filter( 'plugins_loaded' ) ) {
return $walker;
}
// Return early if another plugin/theme is using the same custom fields walker we are. We are already compatible.
if ( $walker == 'Walker_Nav_Menu_Edit_Custom_Fields' ) {
return $walker;
}
// Load the proper walker class based on current WP version.
if ( ! class_exists( 'Walker_Nav_Menu_Edit_Custom_Fields' ) ) {
if ( version_compare( $wp_version, '3.6', '>=' ) ) {
require_once 'menus/class-nav-menu-edit-custom-fields.php';
} else {
require_once menus/class-nav-menu-edit-custom-fields-deprecated.php';
}
}
return 'Walker_Nav_Menu_Edit_Custom_Fields';
}
2. Include the following files/classes to your plugin into the paths from the function above. Do no 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.
– https://github.com/PopupMaker/Popup-Maker/tree/master/includes/modules/menus
3. Move your custom nav menu editor fields (without modification) to a new function hooked like so.
add_action( 'wp_nav_menu_item_custom_fields', '_my_custom_nav_menu_fields', 10, 4 );
function _my_custom_nav_menu_fields( $item_id, $item, $depth, $args ) {
wp_nonce_field( 'pum-menu-editor-nonce', 'pum-menu-editor-nonce' ); ?>
<p class="field-popup_id description description-wide">
<label for="edit-menu-item-popup_id-<?php echo $item->ID; ?>">
<?php _e( 'Trigger a Popup', 'popup-maker' ); ?><br />
<select name="menu-item-pum[<?php echo $item->ID; ?>][popup_id]" id="edit-menu-item-popup_id-<?php echo $item->ID; ?>" class="widefat edit-menu-item-popup_id">
<option value=""></option>
<?php foreach ( PUM_Modules_Menu::popup_list() as $option => $label ) : ?>
<option value="<?php echo $option; ?>" <?php selected( $option, $item->popup_id ); ?>>
<?php echo esc_html( $label ); ?>
</option>
<?php endforeach; ?>
</select>
<span class="description"><?php _e( 'Choose a popup to trigger when this item is clicked.', 'popup-maker' ); ?></span>
</label>
</p>
<?php
}
4. For bonus if you want to include option to show/hide specific fields the same way WP core does in the nav editor.
// Priority of 11 is important, WP overwrites anything before that.
add_filter( 'manage_nav-menus_columns', '_my_nav_menu_columns', 11 );
function _my_nav_menu_columns( $columns = array() ) {
$columns['popup_id'] = __( 'Popup', 'popup-maker' );
return $columns;
}