function alter(&$children)
 {
     //Reset the children each time
     $reference_index = $this->create_reference($this->source_id, $children);
     //No children?  Uh oh
     if (!isset($children[$reference_index])) {
         $notice = __('To create tabs, add child items to the Tab Item.', 'ubermenu');
         $this->manual_content = ubermenu_admin_notice($notice, false);
         return;
     }
     $children[$this->source_id] = $children[$reference_index];
 }
 function get_start_el()
 {
     $transient_key = $transient_expiry = '';
     //up( $this->settings );
     $menu_segment = $this->getSetting('menu_segment');
     $html = "<!-- begin Segment: {$menu_segment} -->";
     //prevent infinite looping
     if (isset($this->args->menu) && $this->args->menu) {
         if ($this->args->menu == $menu_segment) {
             $html .= '<!-- Prevented infinite loop with segment nesting -->';
             return $html;
         }
     }
     if ($menu_segment == '_none' || !$menu_segment) {
         $html .= '<li>' . ubermenu_admin_notice('Please set a segment for <strong>' . $this->item->title . ' (' . $this->ID . ')</strong>', false) . '</li>';
         return $html .= '<!-- no menu set -->';
     }
     $menu_object = wp_get_nav_menu_object($menu_segment);
     if (!$menu_object) {
         $html .= '<li>' . ubermenu_admin_notice('No menu with ID ' . $menu_segment . ' for menu item: <strong>' . $this->item->title . ' (' . $this->ID . ')</strong>', false) . '</li>';
         return $html . '<!-- no menu with ID "' . $menu_segment . '" -->';
     }
     $segment_html = false;
     if ($this->getSetting('segment_transient_cache') == 'on') {
         $transient_key = 'ubertk_mseg_' . $this->ID;
         //$this->get_transient_key( 'mseg_' );
         $transient_expiry_hours = $this->getSetting('segment_transient_cache_expiry');
         if (!is_numeric($transient_expiry_hours)) {
             $transient_expiry_hours = 12;
         }
         $transient_expiry = $transient_expiry_hours * HOUR_IN_SECONDS;
         $segment_html = get_transient($transient_key);
     }
     //If we're not using transients, no transient set, or transient has expired
     if (false === $segment_html) {
         //Submenus of this item should defer to parent
         if ($this->depth > 0) {
             //If this is top level, we don't need to set
             $this->settings['submenu_type_calc'] = $this->walker->parent_item()->getSetting('submenu_type_calc');
         }
         //Set Depth offset for segment
         $current_depth_offset = $this->walker->get_offset_depth();
         $this->walker->set_offset_depth($this->depth);
         $segment_html = wp_nav_menu(array('menu' => $menu_segment, 'echo' => false, 'container' => false, 'items_wrap' => '%3$s', 'walker' => $this->walker, 'uber_instance' => $this->args->uber_instance, 'uber_segment' => $this->ID));
         //Reset depth offset
         $this->walker->set_offset_depth($current_depth_offset);
         set_transient($transient_key, $segment_html, $transient_expiry);
     } else {
         $html .= "<!-- cached segment {$transient_expiry_hours} hours / Transient Key: {$transient_key} -->";
     }
     $html .= $segment_html;
     return $html;
 }
Example #3
0
function uberMenu_easyIntegrate($config_id = 'main', $args = array())
{
    //Check that Easy Integration is enabled
    if (ubermenu_op('ubermenu_theme_location', 'general') != 'on') {
        $msg = 'To use Easy Integration, please enable the <strong>Register Easy Integration UberMenu Theme Location</strong> setting in the <a target="_blank" href="' . admin_url('themes.php?page=ubermenu-settings') . '">UberMenu Control Panel > General Settings > Advanced</a> and <a target="_blank" href="' . admin_url('nav-menus.php?action=locations') . '">assign a menu</a> to the <strong>UberMenu [Easy Integration]</strong> theme locaiton';
        ubermenu_admin_notice($msg);
        return;
    } else {
        if (!has_nav_menu('ubermenu')) {
            $msg = 'To use Easy Integration, please <a target="_blank" href="' . admin_url('nav-menus.php?action=locations') . '">assign a menu</a> to the <strong>UberMenu [Easy Integration]</strong> theme location';
            ubermenu_admin_notice($msg);
            return;
        }
    }
    //$args = array();
    $args['theme_location'] = 'ubermenu';
    return ubermenu($config_id, $args);
}
 /**
  * Get the Anchor and its contents
  * @param  array $atts An array of attributes to add to the anchor
  * @return string       The HTML for the anchor
  */
 function get_anchor($atts)
 {
     $term = $this->term;
     //up( $term );
     $a = '';
     $tag = 'a';
     //Image
     //$image = $this->get_image();
     $this->settings['item_image'] = apply_filters('ubermenu_dt_image', '', $this->ID, $term);
     $image = $this->get_image();
     if ($image) {
         $atts['class'] .= ' ubermenu-target-with-image';
     }
     //Icon
     $icon = $this->getSetting('icon');
     if ($icon) {
         $atts['class'] .= ' ubermenu-target-with-icon';
         $icon = '<i class="ubermenu-icon ' . $icon . '"></i>';
     }
     //Layout
     $layout = $this->getSetting('item_layout');
     $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     //Content Align
     $content_align = $this->getSetting('content_alignment');
     if ($content_align != 'default') {
         $atts['class'] .= ' ubermenu-content-align-' . $content_align;
     }
     if ($layout == 'default') {
         if ($image) {
             $layout = 'image_left';
         } else {
             if ($icon) {
                 if (function_exists('ubermenu_icon_layout_default')) {
                     $layout = ubermenu_icon_layout_default($this);
                 } else {
                     $layout = 'icon_left';
                 }
             } else {
                 $layout = 'text_only';
             }
         }
         $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     }
     $layout_order = ubermenu_get_item_layouts($layout);
     if (!$layout_order) {
         ubermenu_admin_notice(__('Unknown layout order:', 'ubermenu') . ' ' . $layout . ' [' . $this->item->title . '] (' . $this->ID . ')');
     }
     //No wrap
     if ($this->getSetting('no_wrap') == 'on') {
         $atts['class'] .= ' ubermenu-target-nowrap';
     }
     //Disabled Link (change tag)
     $disable_link = false;
     if ($this->getSetting('disable_link') == 'on') {
         $tag = 'span';
         $disable_link = true;
         unset($atts['href']);
     }
     //Anchor Attributes
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     //Title
     $title = '';
     if ($this->getSetting('disable_text') == 'off') {
         $title .= '<span class="ubermenu-target-title ubermenu-target-text">';
         $title .= $term->name;
         //apply_filters( 'the_title', $term->name, $this->item->ID );
         if ($this->getSetting('dt_display_term_counts') == 'on') {
             $title .= ' <span class="ubermenu-term-count">' . UBERMENU_TERM_COUNT_WRAP_START . $term->count . UBERMENU_TERM_COUNT_WRAP_END . '</span>';
         }
         //$title .= ' ['. $term->term_id .'] ['.$this->ID.']';
         $title .= '</span>';
     } else {
         //Flag items with disabled text
         $atts['class'] .= ' ubermenu-item-notext';
     }
     //Description
     $description = '';
     //if( $this->getSetting( 'disable_text' ) == 'off' ){
     if ($this->item->description) {
         $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
         $description .= $this->item->description;
         $description .= '</span>';
     }
     //Check if we still have something to print
     if (!$title && !$description && !$image && !$icon) {
         return '';
     }
     //Build the Layout
     //Get custom pieces
     $custom_pieces = array();
     extract(apply_filters('ubermenu_custom_item_layout_data', $custom_pieces, $layout, $this->ID, $term->term_id));
     //Gather all the pieces in the layout order into an array
     $layout_pieces = compact($layout_order);
     //Output the anchor
     $a .= $this->args->before;
     $a .= '<' . $tag . $attributes . '>';
     $a .= $this->args->link_before;
     //Add pieces based on layout order
     foreach ($layout_pieces as $piece) {
         $a .= $piece;
     }
     $a .= $this->args->link_after;
     $a .= '</' . $tag . '>';
     $a .= $this->args->after;
     return $a;
 }
 function get_widget_area()
 {
     $html = '';
     $widget_area_id = $this->getSetting('widget_area');
     if ($this->getSetting('auto_widget_area')) {
         $custom_area_id = 'umitem_' . $this->ID;
         if (is_active_sidebar($custom_area_id)) {
             $widget_area_id = $custom_area_id;
         } else {
             $notice = __('The widget area is empty.', 'ubermenu');
             $notice .= ' <a target="_blank" href="' . admin_url('widgets.php') . '">' . __('Assign a widget', 'ubermenu') . '</a>';
             global $wp_registered_sidebars;
             if (isset($wp_registered_sidebars[$custom_area_id])) {
                 $sidebar = $wp_registered_sidebars[$custom_area_id];
                 $notice .= ' to <strong>' . $sidebar['name'] . '</strong>';
             }
             $html .= ubermenu_admin_notice($notice, false);
             return $html;
         }
     }
     //If this is a top level widget and that setting is not enabled, show an admin message
     if ($this->depth == 0 && $widget_area_id && ubermenu_op('allow_top_level_widgets', 'general') != 'on') {
         $msg = '<strong>[Menu Item: ' . $this->item->title . ']</strong> ' . __('You have assigned a widget area to a top level menu item.  If you want the widget to appear in a submenu, please attach it to a child menu item.  If you want the widget to appear in the menu bar (always visible), please enable the setting in the UberMenu Control Panel > General Settings > Widgets > Allow Top Level Widgets', 'ubermenu');
         ubermenu_admin_notice($msg, true);
         //Deliberately printed BEFORE the menu rather than within it because the message is so long.
         //$html.= ubermenu_admin_notice( $msg , true );
         return $html;
     }
     if ($widget_area_id && is_active_sidebar($widget_area_id)) {
         global $wp_registered_sidebars;
         global $wp_registered_widgets;
         //global $_wp_sidebars_widgets;
         $sidebars_widgets = wp_get_sidebars_widgets();
         $num_widgets = count($sidebars_widgets[$widget_area_id]);
         //Evenly divided
         $cols = 'ubermenu-column-1-' . $num_widgets;
         //If col number is set
         $widget_area_columns = $this->getSetting('widget_area_columns');
         if (is_numeric($widget_area_columns)) {
             $cols = 'ubermenu-column-1-' . $widget_area_columns;
         }
         foreach ($sidebars_widgets[$widget_area_id] as $widget_id) {
             $wp_registered_widgets[$widget_id]['classname'] .= ' ' . $cols;
         }
         //ob_flush();
         ob_start();
         dynamic_sidebar($widget_area_id);
         $widget_area = ob_get_contents();
         //$widget_area = ob_get_clean(); //ob_get_contents();
         ob_end_clean();
         $html .= '<ul class="ubermenu-content-block ubermenu-widget-area ubermenu-row ubermenu-autoclear">';
         $html .= $widget_area;
         $html .= '</ul>';
     } else {
         if ($widget_area_id) {
             global $wp_registered_sidebars;
             $notice = __('The widget area is empty.  ', 'ubermenu');
             $notice .= '<a target="_blank" href="' . admin_url('widgets.php') . '">' . __('Assign a widget', 'ubermenu') . '</a>';
             if (isset($wp_registered_sidebars[$widget_area_id])) {
                 $sidebar = $wp_registered_sidebars[$widget_area_id];
                 $notice .= ' to <strong>' . $sidebar['name'] . '</strong>';
             }
             $html .= ubermenu_admin_notice($notice, false);
             return $html;
         } else {
             //Nothing assigned - fine if a normal menu item, but if this is a Widget Area menu item, stop the presses.
             if ($this->type == 'widget_area') {
                 $notice = __('Please enter a name for your Custom Widget Area, or assign a Reusable Widget Area to this menu item.', 'ubermenu');
                 $notice .= ' <strong>Item ID: ' . $this->ID . ' ' . $this->item->title . '</strong>';
                 $html .= ubermenu_admin_notice($notice, false);
             }
         }
     }
     return $html;
 }
Example #6
0
function ubermenu_direct_injection()
{
    if (ubermenu_op('direct_inject', 'main') == 'on') {
        if (has_nav_menu('ubermenu-direct-inject')) {
            ubermenu('main', array('theme_location' => 'ubermenu-direct-inject'));
        } else {
            echo '<div class="ubermenu ubermenu-loc-ubermenu-direct-inject">';
            ubermenu_admin_notice('Please <a target="_blank" href="' . admin_url('nav-menus.php?action=locations') . '">assign a menu</a> to the <strong>UberMenu [Direct Injection]</strong> theme location');
            echo '</div>';
        }
    }
}
 /**
  * Get the Anchor and its contents
  * @param  array $atts An array of attributes to add to the anchor
  * @return string       The HTML for the anchor
  */
 function get_anchor($atts)
 {
     $p = $this->post;
     $a = '';
     $tag = 'a';
     //Image
     $image = $this->get_image();
     if ($image) {
         $atts['class'] .= ' ubermenu-target-with-image';
     }
     //Icon
     $icon = $this->getSetting('icon');
     if ($icon) {
         $atts['class'] .= ' ubermenu-target-with-icon';
         $icon = '<i class="ubermenu-icon ' . $icon . '"></i>';
     }
     //Layout
     $layout = $this->getSetting('item_layout');
     $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     //Content Align
     $content_align = $this->getSetting('content_alignment');
     if ($content_align != 'default') {
         $atts['class'] .= ' ubermenu-content-align-' . $content_align;
     }
     if ($layout == 'default') {
         if ($image) {
             $layout = 'image_above';
             //Different from normal
         } else {
             if ($icon) {
                 if (function_exists('ubermenu_icon_layout_default')) {
                     $layout = ubermenu_icon_layout_default($this);
                 } else {
                     $layout = 'icon_left';
                 }
             } else {
                 $layout = 'text_only';
             }
         }
         $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     }
     $layout_order = ubermenu_get_item_layouts($layout);
     if (!$layout_order) {
         ubermenu_admin_notice(__('Unknown layout order:', 'ubermenu') . ' ' . $layout . ' [' . $this->item->title . '] (' . $this->ID . ')');
     }
     //No wrap
     if ($this->getSetting('no_wrap') == 'on') {
         $atts['class'] .= ' ubermenu-target-nowrap';
     }
     //Disabled Link (change tag)
     $disable_link = false;
     if ($this->getSetting('disable_link') == 'on') {
         $tag = 'span';
         $disable_link = true;
         unset($atts['href']);
     }
     //Anchor Attributes
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     //Disabled (change el)
     //TODO
     //Title
     $title = '';
     if ($this->getSetting('disable_text') == 'off') {
         $title = apply_filters('the_title', $p->post_title, $p->ID);
         $title = apply_filters('ubermenu_dp_title', $title, $this->source_id, $p->ID);
         $title = '<span class="ubermenu-target-title ubermenu-target-text">' . $title . '</span>';
     }
     //Description
     $description = '';
     //if( $this->getSetting( 'disable_text' ) == 'off' ){
     if ($this->item->description) {
         $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
         $description .= $this->item->description;
         $description .= '</span>';
     }
     //Dynamic Subcontent
     //Treat as description
     //$subcontent = '';
     $subcontent_type = $this->getSetting('dp_subcontent');
     if ($subcontent_type != 'none') {
         switch ($subcontent_type) {
             case 'excerpt':
                 $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
                 $description .= $p->post_excerpt;
                 $description .= '</span>';
                 break;
             case 'date':
                 $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
                 $description .= mysql2date(get_option('date_format'), $p->post_date);
                 $description .= '</span>';
                 break;
             case 'author':
                 $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
                 $description .= get_the_author_meta('display_name', $p->post_author);
                 $description .= '</span>';
                 break;
             case 'custom':
                 $description = apply_filters('ubermenu_dp_subcontent', $description, $p, $this->ID);
                 break;
             default:
                 break;
         }
     }
     //$description.= $subcontent;	//Treat as description
     //Check if we still have something to print
     if (!$title && !$description && !$image && !$icon) {
         return '';
     }
     //Build the Layout
     //Get custom pieces
     $custom_pieces = array();
     extract(apply_filters('ubermenu_custom_item_layout_data', $custom_pieces, $layout, $this->ID, $p->ID));
     //Gather all the pieces in the layout order into an array
     $layout_pieces = compact($layout_order);
     //Output the anchor
     $a .= $this->args->before;
     $a .= '<' . $tag . $attributes . '>';
     $a .= $this->args->link_before;
     //Add pieces based on layout order
     foreach ($layout_pieces as $piece) {
         $a .= $piece;
     }
     $a .= $this->args->link_after;
     $a .= '</' . $tag . '>';
     $a .= $this->args->after;
     return $a;
 }
 function get_start_el()
 {
     //up( $this->settings );
     $menu_segment = $this->getSetting('menu_segment');
     $html = "<!-- begin Segment: {$menu_segment} -->";
     //prevent infinite looping
     if (isset($this->args->menu) && $this->args->menu) {
         if ($this->args->menu == $menu_segment) {
             $html .= '<!-- Prevented infinite loop with segment nesting -->';
             return $html;
         }
     }
     if ($menu_segment == '_none' || !$menu_segment) {
         $html .= '<li>' . ubermenu_admin_notice('Please set a segment for <strong>' . $this->item->title . ' (' . $this->ID . ')</strong>', false) . '</li>';
         return $html .= '<!-- no menu set -->';
     }
     $menu_object = wp_get_nav_menu_object($menu_segment);
     if (!$menu_object) {
         $html .= '<li>' . ubermenu_admin_notice('No menu with ID ' . $menu_segment . ' for menu item: <strong>' . $this->item->title . ' (' . $this->ID . ')</strong>', false) . '</li>';
         return $html . '<!-- no menu with ID "' . $menu_segment . '" -->';
     }
     //Submenus of this item should defer to parent
     if ($this->depth > 0) {
         //If this is top level, we don't need to set
         $this->settings['submenu_type_calc'] = $this->walker->parent_item()->getSetting('submenu_type_calc');
     }
     //Set Depth offset for segment
     $current_depth_offset = $this->walker->get_offset_depth();
     $this->walker->set_offset_depth($this->depth);
     $html .= wp_nav_menu(array('menu' => $menu_segment, 'echo' => false, 'container' => false, 'items_wrap' => '%3$s', 'walker' => $this->walker, 'uber_instance' => $this->args->uber_instance, 'uber_segment' => $this->ID));
     //Reset depth offset
     $this->walker->set_offset_depth($current_depth_offset);
     return $html;
 }