If Menu

Description

If Menu is a WordPress plugin which adds extra functionality for menu items, making it easy to hide or display menu items based on user-defined rules. Example:

  • display a menu item only if current User is logged in
  • hide menu items if visiting from mobile device
  • display menu items just for Admins and Editors

The plugin is easy to use, each menu item will have a “Change menu item visibility” option which will enable the selection of rules (example in Screenshots).

Features

  • Basic set of visibility rules
    • User state User is logged in
    • User roles Admin Editor Author etc
    • Page type Front page Single page Single post
    • Device Is Mobile
    • more to be added with each plugin update
  • Multiple rules – mix multiple rules for a menu item visibility
    • show if User is logged in AND Device is mobile
    • show if User is Admin AND Is front page
  • Support for adding your custom rules

Example of adding a new rule is described in the FAQ section

Screenshots

  • Enable visibility rules for Menu Items
  • Example of visibility rules

Installation

To install the plugin, follow the steps below

  1. Upload if-menu to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Enable visibility rules for your Menu Items in Appearance -> Menus page

FAQ

Installation Instructions

To install the plugin, follow the steps below

  1. Upload if-menu to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Enable visibility rules for your Menu Items in Appearance -> Menus page
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 functionality for menu items.

How can I add a custom rule for menu items?

New rules can be added by any other plugin or theme.

Example of adding a new custom rule for displaying/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_conditions');

function my_new_menu_conditions($conditions) {
  $conditions[] = array(
    'id'        =>  'single-my-custom-post-type',                       // unique ID for the rule
    'name'      =>  __('Single my-custom-post-type', 'i18n-domain'),    // name of the rule
    'condition' =>  function($item) {                                   // callback - must return Boolean
      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 custom rules 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

Convenient!

Convenient for building mobile menu items or when building sites in phases when you have pages not ready to be published. Just set the menu item to only allow admins to see it, so you can preview the updated navigation before the page launches.

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!

🙂

Read all 56 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.2

Release Date – 8 August 2017

  • Fix – Backwards compatibility with PHP < 5.4

0.6.1

Release Date – 7 August 2017

  • Improvement – Change labels & texts for easier use
  • Improvement – Better compatibility with latest versions of WordPress
  • Improvement – Better compatibility with translation plugins
  • Fix – Detection for conflict with other plugins

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](https://wordpress.org/support/topic/multi-site-user-is-logged-in-conditi
    on)
  • 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 conditional statements