';
$data['remove_nonce'] = $ajax_nonce;// $rmvBtn;
$data['id'] = $id;
$data['image'] = $this->getImage( $id );
$this->JSONresponse( $data );
}
static function convertToOldParameter( $param ){
$params = array(
'menu-item-shortcode' => '_menu_item_shortcode',
'menu-item-sidebars' => '_menu_item_sidebars',
'menu-item-highlight' => '_menu_item_highlight',
'menu-item-notext' => '_menu_item_notext',
'menu-item-nolink' => '_menu_item_nolink',
'menu-item-isheader' => '_menu_item_isheader',
'menu-item-verticaldivision' => '_menu_item_verticaldivision',
'menu-item-newcol' => '_menu_item_newcol',
'menu-item-isMega' => '_menu_item_isMega',
'menu-item-alignSubmenu' => '_menu_item_alignSubmenu',
'menu-item-floatRight' => '_menu_item_floatRight',
'menu-item-fullWidth' => '_menu_item_fullWidth',
'menu-item-numCols' => '_menu_item_numCols',
);
return $params[ $param ];
}
/*
* Save the Menu Item Options for UberMenu
*/
function updateNavMenuItem( $menu_id, $menu_item_db_id, $args ){
//Parse the serialized string of UberMenu Options into an array
$uber_options_string = isset( $_POST['uber_options'][$menu_item_db_id] ) ? $_POST['uber_options'][$menu_item_db_id] : '';
$uber_options = array();
parse_str( $uber_options_string, $uber_options );
$uber_options = wp_parse_args( $uber_options, $this->optionDefaults ); //only allow registered options
update_post_meta( $menu_item_db_id, '_uber_options', $uber_options );
}
/**
* This function is paired with a JavaScript Override Function so that we can use our custom Walker rather
* than the built-in version. This allows us to include the UberMenu Options as soon as an item is added to the menu,
*
* This is a slightly edited version of case 'add-menu-item' : located in wp-admin/admin-ajax.php
*
* In the future, if WordPress provides a hook or filter, this should be updated to use that instead.
*
*/
function addMenuItem_callback(){
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die('-1');
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
// For performance reasons, we omit some object properties from the checklist.
// The following is a hacky way to restore them when adding non-custom items.
$menu_items_data = array();
foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
if (
! empty( $menu_item_data['menu-item-type'] ) &&
'custom' != $menu_item_data['menu-item-type'] &&
! empty( $menu_item_data['menu-item-object-id'] )
) {
switch( $menu_item_data['menu-item-type'] ) {
case 'post_type' :
$_object = get_post( $menu_item_data['menu-item-object-id'] );
break;
case 'taxonomy' :
$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
break;
}
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
$_menu_item = array_shift( $_menu_items );
// Restore the missing menu item properties
$menu_item_data['menu-item-description'] = $_menu_item->description;
}
$menu_items_data[] = $menu_item_data;
}
$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
if ( is_wp_error( $item_ids ) )
wp_die( 0 );
$menu_items = array();
foreach ( (array) $item_ids as $menu_item_id ) {
$menu_obj = get_post( $menu_item_id );
if ( ! empty( $menu_obj->ID ) ) {
$menu_obj = wp_setup_nav_menu_item( $menu_obj );
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
$menu_items[] = $menu_obj;
}
}
//$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
//if ( ! class_exists( $walker_class_name ) )
// wp_die( 0 );
if ( ! empty( $menu_items ) ) {
$args = array(
'after' => '',
'before' => '',
'link_after' => '',
'link_before' => '',
//'walker' => new $walker_class_name,
'walker' => new UberMenuWalkerEdit, //EDIT FOR UBERMENU
);
echo trim( walk_nav_menu_tree( $menu_items, 0, (object) $args ) );
}
wp_die();
}
/*
* Create the UberMenu SparkOptions Panel and Settings object
*/
function optionsMenu(){
$sparkOps = new UberOptions(
UBERMENU_SETTINGS,
//Menu Page
array(
'parent_slug' => 'themes.php',
'page_title' => __( 'UberMenu Options' , 'ubermenu' ),
'menu_title' => __( 'UberMenu' , 'ubermenu' ),
'menu_slug' => 'uber-menu',
'version' => UBERMENU_VERSION,
),
$this->getOptionsMenuLinks(),
$this->coreURL.'sparkoptions/'
);
/*
* Basic Config Panel
*/
$basic = 'basic-config';
$sparkOps->registerPanel( $basic, __( 'Basic Configuration' , 'ubermenu' ), 10 );
$sparkOps->addHidden( $basic , 'current-panel-id' , $basic );
$sparkOps->addRadio( $basic,
'wpmega-orientation',
__( 'Orientation', 'ubermenu' ),
__( 'Choose a vertical (top to bottom) or horizontal (left to right) menu. Note that if your horizontal menu is forced to have a narrow width by your theme, it may appear to be vertically oriented.', 'ubermenu' ),
array(
'horizontal' => __( 'Horizontal', 'ubermenu' ),
'vertical' => __( 'Vertical', 'ubermenu' )
),
'horizontal',
'',
2
);
$weight = 15;
/* Responsiveness */
$sparkOps->addSubHeader( $basic,
'megaMenu-responsiveness',
__( 'Responsive Settings' , 'ubermenu' ),
__( 'Knowledgebase: UberMenu Responsiveness' , 'ubermenu' ),
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'responsive-menu',
__( 'Responsive Mega Menu' , 'ubermenu' ),
__( 'Enable UberMenu\'s responsive properties. Requires a responsive theme, otherwise you may have '.
'strange results if your theme is fixed-width.' , 'ubermenu' ),
'on',
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'responsive-menu-toggle',
__( 'Responsive Mega Menu - Toggle' , 'ubermenu' ),
__( 'Display a toggle button to show/hide menu on mobile devices.' , 'ubermenu' ),
'on',
'',
$weight
);
$sparkOps->addTextInput( $basic,
'responsive-menu-toggle-text',
__( 'Responsive Mega Menu - Toggle Text' , 'ubermenu' ),
__( 'Text or HTML to display on Toggle Button. Set to a single space to disable text.' , 'ubermenu' ),
'Menu',
'',
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'iOS-close-button',
__( 'Display Close Button on iOS' , 'ubermenu' ),
__( 'You can disable this if you do not wish to display the close button on iPads, iPhones, and iPods.' , 'ubermenu' ),
'on',
'',
$weight
);
/* ANIMATIONS */
$weight = 20;
$sparkOps->addSubHeader( $basic,
'wpmega-animation-header',
__( 'jQuery Animations & Auto-positioning' , 'ubermenu' ),
'',
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'wpmega-jquery',
__( 'jQuery Enhanced' , 'ubermenu' ),
__( 'Disable to use UberMenu without jQuery enhancement. All submenus will be full-width by default.' , 'ubermenu' ),
'on',
'',
$weight
);
$sparkOps->addRadio( $basic,
'wpmega-transition',
__( 'Animation' , 'ubermenu' ),
'',
array(
'slide' => __( 'Slide' , 'ubermenu' ),
'fade' => __( 'Fade' , 'ubermenu' ),
'none' => __( 'None' , 'ubermenu' ),
),
'slide',
'',
$weight
);
$sparkOps->addTextInput( $basic,
'wpmega-animation-time',
__( 'Animation Time' , 'ubermenu' ),
__( 'Set how long the animation should take in milliseconds' , 'ubermenu' ),
300,
'spark-minitext',
'ms',
$weight
);
$sparkOps->addRadio( $basic,
'wpmega-trigger',
__( 'Trigger' , 'ubermenu' ),
'',
array(
'hover' => 'Hover',
'hoverIntent' => 'Hover Intent',
'click' => 'Click'
),
'hoverIntent',
'',
$weight
);
$sparkOps->addTextInput( $basic,
'wpmega-hover-interval',
__( 'Hover Intent Interval' , 'ubermenu' ),
__( 'The number of milliseconds before the hover event is triggered. Defaults to 100. [Applies to trigger: Hover Intent]' , 'ubermenu' ),
20,
'spark-minitext',
'ms',
$weight
);
$sparkOps->addTextInput( $basic,
'wpmega-hover-timeout',
__( 'Hover Intent Timeout' , 'ubermenu' ),
__( 'The number of milliseconds before the out event is triggered (milliseconds until the submenu closes after hover-off). Defaults to 400. [Applies to trigger: Hover Intent]' , 'ubermenu' ),
400,
'spark-minitext',
'ms',
$weight
);
$sparkOps->addCheckbox( $basic,
'wpmega-submenu-full',
__( 'Full Width Submenus' , 'ubermenu' ),
__( 'Enable to force all submenus to be full-width, regardless of their content. Disable '.
'to size submenus to their content and position with Javascript.' , 'ubermenu' ),
'off',
'',
$weight
);
/* Mobile Settings */
$weight = 30;
$sparkOps->addSubHeader( $basic,
'mobile-settings-header',
__( 'Mobile Settings' , 'ubermenu' ),
'',
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'android-click',
__( 'Force Click Trigger on Android' , 'ubermenu' ),
__( 'Makes Android interface act more like iOS. By default, Android will redirect to the top level menu item link URL as soon as it is tapped. To display a submenu, users must '.
'tap, and without lifting their finger slide off of the menu item. By enabling Force-Click, the menu touch interface on Android will '.
'work similarly to iOS: a tap will open the sub menu. A second tap will follow the link.' , 'ubermenu' ),
'on',
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'windows-click',
__( 'Force Click Trigger on Windows 8 Touch' , 'ubermenu' ),
__( 'Makes Windows interface act more like iOS. By default, Windows will redirect to the top level menu item link URL as soon as it is tapped.
By enabling Force-Click, the menu touch interface on Android will '.
'work similarly to iOS: a tap will open the sub menu. A second tap will follow the link.' , 'ubermenu' ),
'on',
'',
$weight
);
/* Special */
$weight = 35;
$sparkOps->addSubHeader( $basic,
'basic-other-settings',
__( 'Submenu Positioning' , 'ubermenu' ),
'',
'',
$weight
);
$sparkOps->addCheckbox( $basic,
'reposition-on-load',
__( 'Reposition submenus on window.load' , 'ubermenu' ),
__( 'If your submenus aren\'t positioned properly, it may be because you have a font (like @font-face or Cufon) that needs to load before '.
'the menu items are positioned. Turn this on to position your submenus once your font finishes loading.' , 'ubermenu' ),
'off',
'',
$weight
);
/*
* DESCRIPTION, SHORTCODE, WIDGET SETTINGS
*/
$descConfig = 'description-config';
$sparkOps->registerPanel( $descConfig, __( 'Descriptions' , 'ubermenu' ) , 20 );
$sparkOps->addSubHeader( $descConfig,
'wpmega-desc-header',
__( 'Descriptions' , 'ubermenu' )
);
$sparkOps->addInfobox( $descConfig,
'wpmega-descriptions',
'',
__( 'You can turn on and off menu item descriptions on a per-level basis.' , 'ubermenu' )
);
$sparkOps->addCheckbox( $descConfig,
'wpmega-description-0',
__( 'Display Top-Level Descriptions' , 'ubermenu' )
);
$sparkOps->addCheckbox( $descConfig,
'wpmega-description-1',
__( 'Display Sub-Header Descriptions' , 'ubermenu' )
);
$sparkOps->addCheckbox( $descConfig,
'wpmega-description-2',
__( 'Display Sub-Menu Item Descriptions' , 'ubermenu' )
);
/* STYLE SETTINGS */
$styleConfig = 'style-config';
$sparkOps->registerPanel( $styleConfig, __( 'Style Configuration' , 'ubermenu' ) , 40 );
$sparkOps->addInfobox( $styleConfig,
'wpmega-style-settings',
'',
__( 'Configure how you want to apply styles to the menu' , 'ubermenu' )
);
$sparkOps->addRadio( $styleConfig,
'wpmega-style',
__( 'Style Application' , 'ubermenu' ),
'',
$this->getStyleApplicationOptions(),
'preset'
);
$sparkOps->addSelect( $styleConfig,
'wpmega-style-preset',
__( 'Style Preset' , 'ubermenu' ),
__( 'Only applicable if Use a Preset is selected above. Get More Skins' , 'ubermenu' ),
'ubermenu_getStylePresetOps',
array( 'execute', &$this , 'getDefaultPreset' )
);
return $sparkOps;
}
function getStyleApplicationOptions(){
return array(
'preset' => __( 'Use a Preset' , 'ubermenu' ) .
''. __( 'Select from the Preset Styles below' , 'ubermenu' ) .'',
'none' => __( 'Do Nothing ' , 'ubermenu' ) .
''.__( 'I will manually include the skin styles elsewhere, like in my style.css.' , 'ubermenu' ).'',
);
}
function getNavMenus(){
$menus = array();
foreach( wp_get_nav_menus() as $m ){
$menus[$m->slug] = $m->name;
}
return $menus;
}
function menuItemCustomOptions( $item_id ){
?>
?
showMenuOptions( $item_id ); ?>
getSettings();
$this->showCustomMenuOption(
'isMega',
$item_id,
array(
'level' => '0',
'title' => __( 'Make this item\'s submenu a mega menu. Leave unchecked to use a flyout menu, or for menu items without submenus (this will remove the submenu indicator).' , 'ubermenu' ),
'label' => __( 'Activate Mega Menu' , 'ubermenu' ),
'type' => 'checkbox',
'default' => 'on'
)
);
$this->showCustomMenuOption(
'fullWidth',
$item_id,
array(
'level' => '0',
'title' => __( 'Make this item\'s submenu the full width of the menu bar. Note that with javascript disabled, submenus are full-width by default. This is horizontal-orientation specific. To make a vertical menu full-width, set the width appropriately in the Basic Configuration Options.' , 'ubermenu' ),
'label' => __( 'Full Width Submenu' , 'ubermenu' ),
'type' => 'checkbox',
)
);
$this->showCustomMenuOption(
'alignSubmenu',
$item_id,
array(
'level' => '0',
'title' => __( 'Select where to align the submenu. Note that only mega submenus can be centered, and only if jQuery Enhancements are enabled. Horizontal-orientation specific.' , 'ubermenu' ),
'label' => __( 'Align Submenu' , 'ubermenu' ),
'type' => 'select', // 'checkbox',
'ops' => array(
'left' => __( 'Left' , 'ubermenu' ),
'center'=> __( 'Center (Mega submenus only - Left for flyout)' , 'ubermenu' ),
'right' => __( 'Right' , 'ubermenu' ),
),
'default' => 'center'
)
);
$this->showCustomMenuOption(
'numCols',
$item_id,
array(
'level' => '0',
'title' => __( 'Only valid for full-width submenus. Set how many columns should be in each row in the submenu. Columns will be sized evenly.' , 'ubermenu' ),
'label' => __( 'Submenu Columns [FullWidth]' , 'ubermenu' ),
'type' => 'select', // 'checkbox',
'ops' => array(
'auto' => __( 'Automatic' , 'ubermenu' ),
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6',
'7' => '7',
),
'default' => 'auto'
)
);
//here
$this->showCustomMenuOption(
'isheader',
$item_id,
array(
'level' => '2-plus',
'title' => __( 'Display this item as a header, like second-level menu items. Good for splitting columns vertically without starting a new row' , 'ubermenu' ),
'label' => __( 'Header Display' , 'ubermenu' ),
'type' => 'checkbox',
)
);
$this->showCustomMenuOption(
'highlight',
$item_id,
array(
'level' => '0-plus',
'title' => __( 'Make this item stand out.' , 'ubermenu' ),
'label' => __( 'Highlight this item' , 'ubermenu' ),
'type' => 'checkbox',
)
);
$this->showCustomMenuOption(
'newcol',
$item_id,
array(
'level' => '2-plus',
'title' => __( 'Use this on the item that should start the second column under the same header - for example, have two columns under "Sports"' , 'ubermenu' ),
'label' => __( 'Start a new column (under same header)?' , 'ubermenu' ),
'type' => 'checkbox',
)
);
$this->showCustomMenuOption(
'verticaldivision',
$item_id,
array(
'level' => '1',
'title' => __( 'Begin a new row with this item. You should always check this on the first item in the second row of your submenu.' , 'ubermenu' ),
'label' => __( 'New Row (Vertical Division)' , 'ubermenu' ),
'type' => 'checkbox',
)
);
$this->showCustomMenuOption(
'nolink',
$item_id,
array(
'level' => '0-plus',
'title' => __( 'Remove the link altogether. Can be used, for example, with content overrides or widgets.' , 'ubermenu' ),
'label' => __( 'Disable Link' , 'ubermenu' ),
'type' => 'checkbox',
)
);
}
function getMenuItemOption( $item_id , $id ){
$option_id = 'menu-item-'.$id;
//We haven't investigated this item yet
if( !isset( $this->menuItemOptions[ $item_id ] ) ){
$uber_options = get_post_meta( $item_id , '_uber_options', true );
//If $uber_options are set, use them
if( $uber_options ){
//echo '
'; print_r( $uber_options ); echo '
';
$this->menuItemOptions[ $item_id ] = $uber_options;
}
//Otherwise get the old meta
else{
return get_post_meta( $item_id, '_menu_item_'.$id , true );
}
}
//echo '
array(
'href' => 'http://goo.gl/YV7aw',
'class' => 'spark-outlink-hl',
'title' => __( 'Read the Support Manual' , 'ubermenu' ),
'text' => __( 'Knowledgebase →' , 'ubermenu' ),
),
2 => array(
'href' => 'http://goo.gl/G8b3r',
'class' => 'spark-outlink-hl',
'title' => __( 'Watch Video Tutorials' , 'ubermenu' ),
'text' => __( 'Video Tutorials →' , 'ubermenu' ),
),
3 => array(
'href' => 'http://j.mp/fDpVkP',
'class' => 'spark-outlink',
'title' => __( 'Get images, widgets, shortcodes, and more with a full UberMenu license.' , 'ubermenu' ),
'text' => __( 'Upgrade to UberMenu Plugin →' , 'ubermenu' )
)
);
return $links;
}
/*
* Generates a Preview Menu for display in the control panel
*/
function getPreview_callback(){
$d = $_POST['data'];
wp_parse_str($d, $data);
$style_source = $data['wpmega-style'];
$style = '';
$link = '';
// Generate CSS
$settings = $this->getStyleSettings( $data );
$gen = new StyleGenerator( UBERMENU_LESS );
$style = $gen->generateCSS( $settings );
$html = '
'.__( 'Menu Preview' , 'ubermenu' ).'
';
$html.= '
'.__( 'Note: The menu preview gives a general impression of colors and styles, but will not give an exact representation of '.
'the menu in all cases - especially when using advanced methods like widgets and shortcodes.' , 'ubermenu' ).'