If Menu

Description

Simple plugin that adds extra functionality to Menu Items. It will allow you to display or hide menu items based on conditions (Is single page, User is Logged In and many more).

The management is very easy, each menu item will have a “Enable Conditional Logic” option that will enable the selection of conditions – example in screenshots.

Features:
– Includes conditions for User state (logged in, has read capabilities), User roles (default + custom ones added by plugins), page types (is single page, is homepage, etc) or device type
– Multi conditions – you can build your own rules for hiding a menu item, example: hide if user is logged in OR is mobile, show if user is logged in AND is single page
– Support for custom conditions – add your own conditions in your theme or add extra functionality in your plugin

Screenshots

  • Enable conditions for Menu Items
  • Display a menu item just for Editors on mobile devices
  • Example of basic conditions included

Installation

To install the plugin, follow the steps below

  1. Upload if-menu to the /wp-content/plugins/ directory OR install through admin Plugins page
  2. Activate the plugin in ‘Plugins’ page in WordPress
  3. Go to Appearance -> Menus
  4. Enable conditions for your menu items, example in screenshots

FAQ

If Menu is broken

The code for modifying the menu items is limited, and if other plugins/themes try to alter the menu items, this plugin will break.

This is an ongoing issue with WordPress which hopefully will be fixed in a future release.

Try to use just one plugin that changes the functionality for menu items.

How can I add a conditinal statement for menu items?

Custom conditions can be added easily by any plugins or themes.

Example of adding a new condition for disaplying/hiding a menu item when current page is a custom-post-type.

// theme's functions.php or plugin file
add_filter( 'if_menu_conditions', 'my_new_menu_condition' );

function my_new_menu_condition( $conditions ) {
  $conditions[] = array(
    'name'    =>  'If single custom-post-type', // name of the condition
    'condition' =>  function($item) {          // callback - must return TRUE or FALSE
      return is_singular( 'my-custom-post-type' );
    }
  );

  return $conditions;
}
Where do I find conditional functions?

WordPress provides a lot of functions which can be used to create conditions for almost any combination that a theme/plugin developer can think of.

Who made that really cool icon

Got the icons from here https://dribbble.com/shots/1045549-Light-Switches-PSD, so giving the credit to Louie Mantia

Reviews

great plugin

hello, thank you for your plugin.

i just like to ask if there may be a way to use both if-menu and custom-menu-class plugins together, because so far when i activate the latter, if-menu ui disappears from the menu items…

thank you and great work!

🙂

Wonderfull plugin

ı tried all user menus. but really this is wonderful and easy. i can make menus different rol (author, admin etc. ) that’s great. I hope this plugin of author update that everytime.

thank you the plugin of author !

Read all 55 reviews

Contributors & Developers

“If Menu” is open source software. The following people have contributed to this plugin.

Contributors

Translate “If Menu” into your language.

Interested in development?

Browse the code or subscribe to the development log by RSS.

Changelog

0.6

Release Date – 27 August 2016

  • Improvement – Dynamic conditions based on default & custom user roles (added by plugins or themes) thanks Daniele
  • Improvement – Grouped conditions by User, Page or other types
  • Fix – Filter menu items in admin section
  • Fix – Better menu items filter saving code

0.5

Release Date – 20 August 2016

  • Improvement – Support for WordPress 4.6
  • Feature – New condition checking logged in user for current site in Multi Site requested here
  • Feature – Added support for multi conditions thanks for this ideea
  • Improvement – RO & DE translations

0.4.1

Release Date – 13 December 2015

  • Fix – Fixes issue with adding new menu items

0.4

Release Date – 29 November 2015

0.3

Small update

  • Plugin icon
  • Set as compatible with WordPress 4

0.2.1

Minor fixes

  • Fix – Editing menus – show/hide conditions when adding new item (thanks Joseph Segal)

0.2

Update for compatibility with newer versions of WordPress

  • Feature – access to menu item object in condition callback (thanks BramNL)
  • Fix – alert for leaving page even if no changes were made for menus (thanks Denny)
  • Fix – update method in Walker_Nav_Menu_Edit to be compatible with newer version of WP
  • Fix – example in Readme (thanks BramNL)

0.1

  • Plugin release. Included basic menu conditions