Plugin: | UberMenu Conditionals |
Plugin by: | Chris Mavricos, SevenSpark |
Website: | sevenspark.com |
Created: | September 10, 2012 |
Guide Last Updated: | September 10, 2012 |
Welcome to UberMenu Conditionals! Thank you for purchasing this plugin, I appreciate it!
This guide should answer all your questions about how to use this plugin. You can browse the document using the navigation sidebar on the left, or search the entire document by using CTRL+F in your browser.
The latest version of this support guide can always be found here: UberMenu Conditionals Support Guide.
Please be polite when requesting support, and I'll be sure to respond as soon as possible. I'll do my best to answer your questions, but unfortunately I generally can't offer customizations beyond a few lines of code - there just aren't enought hours in the day! Of course, I will always provide fixes for any bugs that crop up as soon as can be :)
You can install UberMenu Conditionals via the WordPress plugin uploader without unzipping the file.
You can also install UberMenu Conditionals via FTP
ubermenu-conditionals
folder (this directory is created when you unzip the file).ubermenu-conditionals
folder to your wp-content/plugins
directory.Installing the plugin doesn't automatically change any navigation menus - so it immediately affect anything on your site, either. Once you install the plugin, you'll get:
If you deactivate the UberMenu Conditional Plugins and then save your menu, you will lose all of your previously set conditions. In other words, if you save your menu while the plugin is disabled, you will reset all of your conditions to the default.
Activating UberMenu Conditionals will add two new options to each of your menu items in Appearance > Menus, Conditional Display: Show item and Conditional Parameters.
Setting the option here will enforce that the menu item is displayed ONLY when the chosen condition is met. For example, if "On front page" is selected, the item will be displayed on the front page, and not on any others.
Condition | Function | Explanation |
---|---|---|
(blank) | none | This setting will not affect the menu item at all |
Always | N/A | The menu item will always be displayed. The difference compared to the blank setting is that this will override any filters with lesser importance. |
If user is logged in | is_user_logged_in() | Item will be displayed only if the curreunt user is logged in to your site. |
If user is not logged in | !is_user_logged_in() | Item will be displayed only if the curreunt user is NOT logged in to your site. |
If user can [capability] | current_user_can( $capability ) | Item will be displayed only if the current user has the capability which is set in the Conditional Parameters (required) |
If user cannot [capability] | !current_user_can( $capability ) | Item will be displayed only if the current user DOES NOT HAVE the capability which is set in the Conditional Parameters (required) |
On front page | is_front_page() | Item will be displayed only when the main blog page is being displayed and the Settings > Reading > Front page displays is set to "Your latest posts", or when is set to "A static page" and the "Front Page" value is the current Page being displayed. In other words, displayed only on the main URL of your site |
Not on front page | !is_front_page() | Displayed on all pages but the front page (main URL) of your site |
On home page (main blog) | is_home() | Item will be displayed when the main blog page is being displayed. This is the page which shows the time based blog content of your site, so if you've set a static Page for the Front Page (see below), then this will only be true on the Page which you set as the "Posts page" in Administration > Settings > Reading. |
Not on home page (main blog) | !is_home() | Item will be displayed when any page EXCEPT the main blog page is being displayed. |
On a page | is_page() | Item will be displayed when on a Page |
Not on a page | !is_page() | Item will be displayed when NOT on a Page |
On a single post | is_single() | Item will be displayed when a single Post is being displayed. |
Not on a single post | !is_single() | Item will be displayed when a single Post is NOT being displayed. |
On a page template | is_page_template() | Item will be displayed when on a page template. |
On a page template | is_page_template() | Item will be displayed when NOT on a page template. |
On a Category Archive | is_category() | Item will be displayed on Category Archive pages |
On a Tag Archive | is_tag() | Item will be displayed on Tag Archive pages |
On a Taxonomy Archive | is_tax() | Item will be displayed on Taxonomy Archive pages |
On an Author Archive Page | is_author() | Item will be displayed on Author Archive pages |
On any archive page | is_archive | Item will be displayed on any archive page |
On Search Results Page | is_search | Item will be displayed on search results page |
On 404 Page | is_404 | Item will be displayed on 404 page |
On a single Page, Post, or Attachment | is_singular | Item will be displayed when a single Page, Post, or Attachment is being displayed. |
Some of the conditional functions used can take a parameter. UberMenu Conditionals uses the Conditional Parameters setting to pass additional information to the functions.
For example, to display an item only on a particular page, set the Conditional Display to On a page and set the Conditional Parameter to the ID of that page.
In the example above, the menu item will only be displayed on the page with the ID 255
Some of the conditional functions allow you to pass an array of strings or integers as a parameter. To do so, use a comma-delimited list in the parameters setting. UberMenu Conditionals will automatically convert any value with a comma into an array to pass to the conditional function.
For example, to display an item only on a specific group of pages, set the Conditional Parameters to a comma-delimited string of the page IDs: 255, 119
In the example above, the menu item will be displayed only on two pages: page 255 and page 119.
Tip: The content Conditional Parameters input box will always be passed as the first parameter of the conditional function. If the value contains commas, it will be passed as an array. To pass a second parameter to the few conditional functions that support it, you'd need to write a custom conditional filter.
If you need a conditional statement more advanced than the provided parameters, UberMenu Conditionals allows you to write a custom conditional filter.
The best place to put custom conditional filters would be in your child theme's functions.php, or in a separate plugin. This is totally up to you and depends on how you manage your site.
Here's an example of a custom conditional filter that makes sure a particular menu item will not display on the front page for logged in users.
function my_custom_conditional_filter( $display_on , $walker , $element , $max_depth, $depth, $args ){ //The ID of the menu item currently being filtered $id = $element->ID; //Check for that specific menu item if( $id == 268 ){ //If we're currently logged in AND on the front page if( is_user_logged_in() && is_front_page() ){ //Disable the menu item $display_on = false; } } //Return the filtered display boolean return $display_on; } add_filter( 'uberMenu_display_item', 'my_custom_conditional_filter', 20, 6 );Important notes:
Will be updated as questions are asked.