PHP API

Knowledgebase Docs » UberMenu 3
USEFUL? 7
UberMenu 3

The PHP API offers two functions:

ubermenu()

The ubermenu() function outputs an UberMenu. You can place it in a theme template to insert an UberMenu wherever you like.

ubermenu( $config_id = 'main' , $args = array() )

$config_id
Default: 'main'
Defines which Configuration to use for this menu. When you create a new Configuration in the UberMenu Control Panel, you provide an ID – that is the ID used here.
The Configuration determines the global properties of the menu, like the skin, transition, trigger, etc.
The default menu set in the Configuration will be displayed if no menu or theme location is passed.
$args
Default: array()
An array of arguments, which will eventually be passed to wp_nav_menu. Most will be controlled by UberMenu, but you can pass the theme_location or menu parameters to define which menu from Appearance > Menus will be used.

Examples

Display an UberMenu with the main configuration using its default Menu
<?php ubermenu(); ?>

or

<?php ubermenu( 'main' ); ?>
Display an UberMenu with the main configuration for the menu with slug ‘secondary’
<?php ubermenu( 'main' , array( 
  'menu' => 'secondary'
) ); ?>
Display an UberMenu with the “custom_blue” configuration for the theme location ‘primary’
<?php ubermenu( 'custom_blue' , array(
  'theme_location' => 'primary'
) ); ?>

Generation

Note that you can generate basic API code in the UberMenu Control Panel > {Configuration} > Integration > Manual Integration

ubermenu_toggle()

The ubermenu_toggle() function outputs the toggle button used to toggle UberMenu open and closed below the responsive breakpoint.. You can place it in a theme template to insert a toggle wherever you like.

ubermenu_toggle( $target = '_any_' , $config_id = 'main' , $echo = true , $args = array() )

$target
Default: _any_
The ID of the UberMenu element being targeted (look for the nav element’s ID attribute). The special value _any_ means this toggle will toggle any UberMenu on the page, which is mostly useful if you only have one instance on the page.
$config_id
Default: 'main'
Defines which Configuration to use for this menu. When you create a new Configuration in the UberMenu Control Panel, you provide an ID – that is the ID used here.
The Configuration determines the global properties of the menu, like the skin, transition, trigger, etc.
$echo
Default: true
true to echo the toggle, false to return the HTML markup
$args
Default: array()
Allows you to override default values for the following parameters:

'toggle_content'	=> 'Menu', //The content for the toggle button
'icon_class'		=> 'bars', //The class for the icon (will be prepended with 'fa fa-'
'tag'			=> 'a', //The HTML element to use for the toggle
'skin'			=> '', //The skin for the toggle (if overriding configuration)
'toggle_id'		=> '', //The ID for this toggle (optional)

Example

Display a toggle for the UberMenu with ID ubermenu-main-2-primary

<?php ubermenu_toggle( 'ubermenu-main-2-primary' ); ?>

Display a toggle for the UberMenu with ID ubermenu-secondary-4-below for the ‘secondary’ Configuration, with the button content as a rocket icon and the word ‘Nav’

<?php ubermenu_toggle( 'ubermenu-secondary-4-below' , 'secondary' , true , array(
  'toggle_content' => 'Nav',
  'icon_class' => 'rocket',
) ); ?>