Custom Menu Wizard Widget

Show branches or levels of your menu in a widget, or in content using a shortcode, with full customisation.


Contributors: wizzud
Donate link:
Tags: menu, widget, widgets, navigation, nav, custom menus, custom menu, partial menu, menu level, menu branch
Requires at least: 3.6
Tested up to: 3.9
Stable tag: 2.1.0
License: GPLv2 or Later


Description

This plugin is a boosted version of the WordPress "Custom Menu" widget. It provides full control over most of the parameters available when calling WP's wp_nav_menu() function, as well as providing pre-filtering of the menu items in order to be able to select a specific portion of the custom menu. It also automatically adds a couple of custom classes. And there is now (v1.2.0) a shortcode that enables you to include the widget's output in your content.

Features include:

Documentation for the Widget Options, and the associated Shortcode Parameters, can be found under Other Notes.


Installation

  1. EITHER Upload the zip package via 'Plugins > Add New > Upload' in your WP Admin

    OR Extract the zip package and upload custom-menu-wizard folder to the /wp-content/plugins/ directory

  2. Activate the plugin through the 'Plugins' menu in your WP Admin

The widget will now be available in the 'Widgets' admin page. As long as you already have at least one Menu defined, you can add the new widget to a sidebar and configure it however you want. Alternatively, you can use the shortcode in your content.


Frequently Asked Questions

If you have a question or problem that is not covered here, please use the integrated Support forum.

Are there any known problems?

Yep, 'fraid so :

  1. The widget will only recognise one "current" item (as of v2.0.2, that's the first one encountered; prior to that it was the last one found). It is perfectly possible to have more than one menu item marked as "current", but if CMW has been configured to filter on anything related to a "current menu item" it can only choose one. The simplest example of multiple "current" items is if you add the same page to a menu more than once, but any plugin that adds and/or manipulates menu items, could potentially cause problems for the widget.

Why isn't it working? Why is there no output?

I don't know. With all due respect (and a certain amount of confidence in the widget) I would venture to suggest that it is probably due to the option settings on the widget/shortcode. The quickest way to resolve any such issues is to use the widget's interactive "assist", and ensure that you set the current menu item correctly for the page(s) that you are having problems with. However, I am well aware that I not infallible, and if you still have problems then please let me have as much information as possible and I will endeavour to help. (Please note that simply reporting "It doesn't work" is not the most useful of feedbacks, and is unlikely to get a response other than, possibly, a request for more details).

How do I use the "assist"?

The widget's interactive "assist" is specific to each widget instance. It is a javascript-driven emulator that uses the widget instance's option settings - including the menu selected - to build a pictorial representation of the menu and show you, in blue, which menu items will be output according to the current option settings. It also shows a very basic output list of those menu items, although it will not apply some of the more advanced HTML-modifying options such as can be found under the Container, Classes or Links sections. Any of the displayed menu items can be designated as the "current menu item" simply by clicking on it (click again to deselect, or another item to change). The "current menu item" is shaded red, with its parent shaded orange and ancestors shaded yellow. All changes in the "current menu item" and the widget options are immediately reflected by the "assist" (text fields in the widget options simply need to lose focus).

Once you are happy with the results, having tested all possible settings of "current menu item" (if it applies), then simply Save the widget. Alternatively, simply copy-paste the shortcode code produced by the "assist" straight into your post (you do not need to Save the widget!). The widget does not have to Saved to test any of the options.

Is there an easy way to construct the shortcode to get the results that I want?

Yes. Use the widget's interactive "assist" capability (see above). Note that you do not need to have the widget in a sidebar : the "assist" also works off a widget that is in the Inactive Widgets area of the widget admin page.

How do I get the menu item ids for the `Items` option?

Use the widget's interactive "assist" (see above). Within the representation menu structure, each menu item's id is set in its title attribute, so should be seen when the cursor is moved over the item. A simpler way is to check the Items option : the "assist" will then show a green tick "checkbox" beside each menu item and you simply [un]check the items as required. Each selection will be reflected back into the widget's Items settings, and also in the shortcode code.

Alternatively, go to Appearance, Menus and select the relevant menu; hover over the edit, Remove, or Cancel link for an item and look in the URL (the link's href) for menu-item=NNN ... the NNN is the menu item id.

How can I find all my posts/pages that have a CMW shortcode so that I can upgrade them?

There is a button on the widget's "assist" - [...] - that will provide a list of posts that contain any CMW shortcode. Each entry is a link that opens the item in a new tab/window. The link's title gives a bit more information : post type, id, and shortcode(s) concerned. This utility *only* looks at post content; it does not check custom fields, widgets, etc.


Changelog

2.1.0

2.0.6

2.0.5

2.0.4

2.0.3

2.0.2

2.0.1

2.0.0

1.2.2

1.2.1

1.2.0

1.1.0

1.0.0

Initial release


Upgrade Notice

2.1.0 (incorporated into v3.0.0 release)
Minimum requirement for WordPress is now v3.6! Added the ability to handle duplicate menu ids, and made the widget compatible with Widget Customizer. Tweaked some styling in the "assist". Please note that there is no separate release package for v2.1.0!
2.0.5
Fixed a bug to prevent PHP warnings of Undefined index/offset being output.
2.0.4
Fixed a bug that prevented the container field being removed, and added removal of the menu-item-has-children class when the filtered item no longer has children. The admin widget styling and javascript have been tweaked to accommodate WordPress 3.8.
2.0.3
Fixed a minor bug with a missing global when enqueuing script and style for the admin.
2.0.2
Fixed a bug with the Include Ancestors option, where it was not automatically including the Parent. Fixed a bug in the "assist", where it was incorrectly calculating Depth Relative to Current Item when the current menu item was outside the scope of the Filtered items. Changed determination
2.0.1
Fixed a bug whereby a test for a specific-items filter prevented show-all from producing any output.
2.0.0
! Possible Breaker ! My apologies if this affects you, but there are 2 possible scenarios where settings that previously resulted in no output might now produce output : + if you have set a Children of filter, and you have changed the Start Level to a level greater than 2, or + if you have set the
1.2.2
Bugfix : The fallback for Current Item with no children was failing because the parent's children weren't being picked out correctly
1.2.1
Added a few extra custom classes, and changed the defaults for new widgets such that only the Filter section is open by default. Fixed Show All processing so that custom classes always get applied, and 'Title from "Current" Item' works regardless of filter settings. Fixed a cou
1.2.0
Added custom_menu_wizard shortcode, to run the widget from within content. Added a new fallback for Current Item having no children, and moved all fallbacks into a collapsible Fallbacks section. Fixed a bug with optgroups/options made available for the 'Children of' selector after the widg

Widget Options

There are quite a few options, which makes the widget settings box very long. I have therefore grouped most of the options into logical sections and made each section collapsible (with remembered state once saved). As of v1.2.1, only the Filter section is open by default; all sections below that start off collapsed.


Shortcode Parameters

The shortcode is [custom_menu_wizard]. Most of the attributes reflect the options available to the widget, but some have been simplified for easier use in the shortcode format. Please note that the Hide Widget if Empty option is not available to the shortcode : it is set to enabled, and if there are no menu items found then there will be no output from the shortcode.

The simplest way to build a shortcode is to use the widget's "assist" facility (new in v2.0.0). The facilty is available even when the widget is in the Inactive Widgets area, so you don't have to add an unwanted instance of the widget to a sidebar.

Shortcode Examples