コード例 #1
0
 /**
  * Get mega menu tab content
  *
  * @since  1.0.0
  *
  * @param  int    $id    menu item ID
  * @param  string $title menu item title
  * @param  int    $depth menu item depth
  * @param  array  $meta  menu item meta
  * @return string        tab HTML
  */
 public function mega_menu($id, $title, $depth, $meta)
 {
     if ($depth > 0) {
         return '<em>' . __("Mega Menus can only be created on top level menu items.", "megamenu") . '</em>';
     }
     global $cherry_mega_menu_total_columns;
     $widget_manager = new cherry_mega_menu_widget_manager();
     $all_widgets = $widget_manager->get_available_widgets();
     $meta['type'] = isset($meta['type']) ? $meta['type'] : '';
     $return = '<label class="menu_enable"><input class="toggle_menu" type="checkbox" name="type" value="megamenu" ' . checked($meta['type'], 'megamenu', false) . '/>' . __("Enable Mega Menu for current item", "cherry-mega-menu") . '</label>';
     $return .= '<select id="widget_selector">';
     $return .= '<option value="disabled">' . __("Select a Widget to add to the panel", "cherry-mega-menu") . '</option>';
     foreach ($all_widgets as $widget) {
         $return .= '<option value="' . $widget['value'] . '">' . $widget['text'] . '</option>';
     }
     $return .= '</select>';
     $return .= '<div id="widgets">';
     $panel_widgets = $widget_manager->get_widgets_for_menu_id($id);
     if (!count($panel_widgets)) {
         $return .= '<div class="message no_widgets">' . __("No widgets found", "cherry-mega-menu") . '<br /><br /><i>' . __("Use the Widget Selector (top right) to add a Widget to this panel.", "cherry-mega-menu") . '</i></div>';
     } else {
         foreach ($panel_widgets as $widget) {
             $return .= $widget_manager->get_widget_html($widget['title'], $widget['widget_id'], $widget['mega_columns'], $cherry_mega_menu_total_columns);
         }
     }
     $return .= '</div>';
     return $return;
 }