function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $args = (object) $args;
     // check display logic
     $display_logic = $this->getMashMenuOption($item->ID, 'displayLogic');
     if ($display_logic == 'guest' && is_user_logged_in() || $display_logic == 'member' && !is_user_logged_in()) {
         return;
     }
     if (isset($classes)) {
         unset($classes['list-style']);
     }
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     //Handle class names depending on menu item settings
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $is_parent = '';
     foreach ($classes as $class) {
         if ($class == 'parent') {
             $is_parent = true;
             $classes[] = $depth == 0 ? 'dropdown' : 'dropdown-submenu';
         }
     }
     if ($depth == 0) {
         $classes[] = 'main-menu-item';
         if ($this->getMashMenuOption($item->ID, 'menu_style') == 'preview' || $this->getMashMenuOption($item->ID, 'menu_style') == 'columns') {
             $classes[] = 'dropdown-mega';
         }
     }
     if ($depth == 1 && $args->parentMega == 'preview') {
         $classes[] = 'channel-title';
     }
     if ($depth == 0 && ($opt_menu_style = $this->getMashMenuOption($item->ID, 'menu_style') == 'list')) {
         $classes[] = 'list-style';
     }
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
     $class_names = ' ' . esc_attr($class_names) . '';
     $options = get_option('mashmenu_options');
     if ($depth == 1 && $args->parentMega == 'preview') {
         $post_type = 'any';
         /* if you want exactly what kind of post types which belong to this category
          * uncomment & edit code below
          * ====================
          * if($item->object = 'custom-taxonomy') $post_type = 'custom-post-type';
          * ====================
          */
         if ($options['ajax_loading'] != 'on' || 1) {
             $output .= '<div class="channel-content" id="channel-' . $item->ID . '"><div class="row">';
             $helper = new MashMenuContentHelper();
             switch ($item->object) {
                 case 'category':
                     $output .= $helper->getLatestCategoryItems($item->object_id);
                     break;
                 case 'post_tag':
                     $output .= $helper->getLatestItemsByTag($item->object_id);
                     break;
                 case 'page':
                     $output .= $helper->getPageContent($item->object_id);
                     break;
                 case 'post':
                     $output .= $helper->getPostContent($item->object_id);
                     break;
                 case 'product_cat':
                     $output .= $helper->getWProductItems($item->object_id);
                     break;
                 default:
                     $output .= $helper->getLatestCustomCategoryItems($item->object_id, $item->object, $post_type);
                     break;
             }
             $output .= '</div></div>';
         }
         $output .= '<li id="mega-menu-item-' . $item->ID . '"' . $value . ' class="' . $class_names . '" data-target="channel-' . $item->ID . '" data-type="' . $item->type . '" data-post="' . $post_type . '" data-object="' . $item->object . '" data-id="' . $item->object_id . '">';
     } else {
         if ($depth != 1) {
             $output .= '<li id="mega-menu-item-' . $item->ID . '"' . $value . ' class="' . $class_names . '">';
         }
     }
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     //$attributes .= ! empty( $item->class )      ? ' class="'  . esc_attr( $item->class      ) .'"' : '';
     $item_output = '';
     /* Add title and normal link content - skip altogether if nolink and notext are both checked */
     if (!empty($item->title) && trim($item->title) != '') {
         //Determine the title
         $title = apply_filters('the_title', $item->title, $item->ID);
         if (!empty($args->before)) {
             $item_output = $args->before;
         }
         if (!in_array("header", $classes)) {
             $item_output .= '<a' . $attributes . '>';
         }
         $opt_icon = $this->getMashMenuOption($item->ID, 'icon');
         $opt_iconPos = $this->getMashMenuOption($item->ID, 'iconPos');
         $opt_caretDownPos = $this->getMashMenuOption($item->ID, 'caretDownPos');
         if ($depth == 0 && $opt_caretDownPos == 'left') {
             if ($options['icon_mainmenu_parent'] != '') {
                 $item_output .= "<i class='fa " . $options['icon_mainmenu_parent'] . "'></i>";
             } else {
                 $item_output .= "<i class='fa fa-caret-down'></i>";
             }
         }
         if (!empty($args->link_before)) {
             $item_output .= $args->link_before;
         }
         //Text - Title
         $prepend = '';
         $append = '';
         $item_output .= $prepend . $title . $append;
         //Description
         $description = '';
         $item_output .= $description;
         //Link After
         if (!empty($args->link_after)) {
             $item_output .= $args->link_after;
         }
         if (!in_array("header", $classes)) {
             $item_output .= '</a>';
         }
         //Append after Link
         if (!empty($args->after)) {
             $item_output .= $args->after;
         }
     }
     $with_child = '';
     if (in_array("parent", $classes)) {
         $with_child = 'parent';
     }
     if ($depth == 1 && isset($args->parentMega) && $args->parentMega == 'columns') {
         $sidebar = $this->getMashMenuOption($item->ID, 'addSidebar');
         if ($sidebar != '0') {
             ob_start();
             dynamic_sidebar($sidebar);
             $html = ob_get_contents();
             ob_end_clean();
             $output .= '<li><ul class="list"><li class="header">' . $item->title . '</li><li class="cactus-widgets">' . $html . '</li></ul>';
         } else {
             $output .= '';
         }
     } else {
         if ((!isset($args->parentMega) || $args->parentMega == 'list') && $depth == 1) {
             $output .= apply_filters('walker_nav_menu_start_el', '<li class="menu-item level' . ($depth + 1) . ' ' . $with_child . '' . $class_names . '">' . $item_output, $item, $depth, $args);
         } else {
             $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
         }
     }
 }
Beispiel #2
0
 function getChannelContent_callback()
 {
     $data = $_POST[sanitize_key('data')];
     // Array(dataType, dataId, postType)
     $helper = new MashMenuContentHelper();
     switch ($data[0]) {
         case 'category':
             echo $helper->getLatestCategoryItems($data[1]);
             break;
         case 'post_tag':
             echo $helper->getLatestItemsByTag($data[1]);
             break;
         case 'page':
             echo $helper->getPageContent($data[1]);
             break;
         case 'post':
             echo $helper->getPostContent($data[1]);
             break;
             /* WooCommerce/JigoShop Product Category */
         /* WooCommerce/JigoShop Product Category */
         case 'product_cat':
             echo $helper->getWProductItems($data[1]);
             break;
             /* Custom Taxonomy */
         /* Custom Taxonomy */
         default:
             echo $helper->getLatestCustomCategoryItems($data[1], $data[0], $data[2]);
             break;
     }
     die;
 }