Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
Last active June 4, 2020 09:47
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c to your computer and use it in GitHub Desktop.
Save helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c to your computer and use it in GitHub Desktop.
Give Nav Menu Roles priority over any competing Walkers
<?php
/*
Plugin Name: Nav Menu Roles Toggle
Plugin URI: https://gist.github.com/helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c
Description: Give NMR priority over any competing Walkers
Version: 0.2.0
Author: helgatheviking
Author URI: http://kathyisawesome.com
*/
global $wp_version;
if ( version_compare( strtolower( $wp_version ), strtolower( $version ), '>=' ) ) {
remove_all_filters( 'wp_edit_nav_menu_walker' );
} else {
add_filter( 'wp_edit_nav_menu_walker', 'kia_force_nmr_filter', 999999 );
}
function kia_force_nmr_filter( $walker ){
if( function_exists( 'Nav_Menu_Roles' ) ){
$walker = 'Walker_Nav_Menu_Edit_Roles';
}
return $walker;
}
@mikewing94
Copy link

Thank you! this is great for using with the LMS theme, this has been an issue for a while conflicting with this theme!

@tara2
Copy link

tara2 commented Sep 20, 2019

Thank you so much for this! :)
...and for anyone who's not sure how to use this plugin (like me!) ...if you download to your computer using the top-right 'Download Zip' button on this page, then change the name of the zip file to something like 'Nav Menu Rules Toggle' ...and just upload it to your plugins page like you usually do. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment