예제 #1
0
 /**
  * Generate arguments depends on location and menu
  */
 function get_args($args)
 {
     $this->profile_id = WR_Megamenu_Helpers_Functions::get_profile_by_location($args['theme_location']);
     if ($this->profile_id) {
         // Show only once in one location
         if ($this->echo == $args['theme_location']) {
             $args['echo'] = FALSE;
         }
         $this->echo = $args['theme_location'];
         $args['profile_id'] = $this->profile_id;
         $this->settings = WR_Megamenu_Helpers_Builder::get_megamenu_data($this->profile_id);
         // load assets for a profile
         $this->load_profile_assets();
         $menu_type = $this->settings['menu_type'];
         $location = $this->settings['location'];
         // Get the nav menu based on the requested menu
         $menu = wp_get_nav_menu_object($menu_type);
         $locations = get_nav_menu_locations();
         if (!$menu && $location && isset($locations[$location])) {
             // Get the nav menu based on the theme_location
             $menu = wp_get_nav_menu_object($locations[$location]);
         }
         if ($menu && $menu->term_id == $menu_type && isset($locations[$location])) {
             $args['menu_type'] = $menu_type;
             $args['theme_location'] = $location;
             $helper = new WR_Megamenu_Helpers_Frontend();
             return $helper->get_args($args);
         } else {
             return $args;
         }
     } else {
         return $args;
     }
     return $args;
 }
예제 #2
0
파일: walker.php 프로젝트: WP-Panda/m.video
 /**
  * Starting build menu element
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $item Menu item data object.
  * @param int $depth Depth of menu item. Used for padding.
  * @param int $current_page Menu item ID.
  * @param object $args
  */
 function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0)
 {
     $el_styles = array();
     $item_output = '<a href="' . $item->url . '" class="menu-item-link">';
     if (isset($item->icon) && $item->icon != '') {
         $item_output .= ' <i class="' . $item->icon . '"></i>';
     }
     $item_output .= '<span class="menu_title">' . $item->title . '</span></a>';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'wr-megamenu-item';
     $classes[] = 'level-' . $depth;
     $data = WR_Megamenu_Helpers_Builder::get_megamenu_data($args->profile_id, $item->ID);
     if ($depth == 0) {
         if (count($data) && $data['is_mega'] == 'true') {
             $this->is_mega = true;
             $classes[] = 'mega-item';
             $settings = $data['setting_menu'];
             if (isset($settings['full_width_value']) && $settings['full_width_value'] == '1') {
                 // min width
                 $this->mega_wrapper_width = '100%;';
                 $el_styles[] = 'position:static !important';
             } else {
                 $this->mega_wrapper_width = @$settings['container_width'] ? $settings['container_width'] . 'px' : '100%';
                 $classes[] = 'wr-megamenu-fixed';
             }
             $this->style = 'style="width:' . $this->mega_wrapper_width . '; left:0;"';
             if ($this->is_mega) {
                 $item_output .= '<div class="wr-megamenu-inner" ' . $this->style . ' data-container="940">';
                 $shortcode_content = urldecode($data['shortcode_content']);
                 if (!empty($shortcode_content)) {
                     $shortcode_content = preg_replace_callback('/\\[wr_megamenu_widget\\s+([A-Za-z0-9_-]+=\\"[^"\']*\\"\\s*)*\\s*\\](.*)\\[\\/wr_megamenu_widget\\]/Us', array('WR_Megamenu_Helpers_Shortcode', 'widget_content'), $shortcode_content);
                     $item_output .= do_shortcode($shortcode_content);
                 }
                 $item_output .= '</div>';
             }
         } else {
             $classes[] = 'menu-default';
             $this->is_mega = false;
             $this->style = '';
             $this->mega_wrapper_width = 'auto';
         }
     }
     // Generate class and style attribute
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
     $el_styles = $el_styles ? ' style="' . esc_attr(join(';', $el_styles)) . '"' : '';
     if ($depth != 0 && $this->is_mega) {
         $output .= '';
         $item_output = '';
     } else {
         $output .= '<li ' . $class_names . ' ' . $el_styles . '>';
     }
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
예제 #3
0
    /**
     * Get submenu items
     */
    public function get_menu_items()
    {
        $html = array();
        $location = $_POST['location'];
        $profile_id = $_POST['profile_id'];
        $depth = isset($_POST['depth']) ? (int) $_POST['depth'] : '1';
        $parent_id = isset($_POST['menu_id']) ? $_POST['menu_id'] : '';
        $locations = get_nav_menu_locations();
        $menu_type = 0;
        if (isset($locations[$location])) {
            $menu_type = $locations[$location];
        }
        $menu = wp_get_nav_menu_object($menu_type);
        if ($menu_type && $menu) {
            $helper = new WR_Megamenu_Helpers_Menu();
            $items = $helper->get_menu_items($menu_type, $parent_id, $depth);
            $html[] = '<input type="hidden" value="false" id="is-mega">';
            if (count($items)) {
                $html[] = '<ul id="top-level-menu" class="nav navbar-nav">';
                foreach ($items as $item) {
                    $data = WR_Megamenu_Helpers_Builder::get_megamenu_data($profile_id, $item->ID);
                    $container_width = '600';
                    $full_width_value = '';
                    $is_mega = 'false';
                    if (count($data)) {
                        $setting_menu = @$data['setting_menu'];
                        $is_mega = @$data['is_mega'];
                        $container_width = isset($setting_menu['container_width']) && $setting_menu['container_width'] != '' ? $setting_menu['container_width'] : '600';
                        $full_width_value = isset($setting_menu['full_width_value']) && $setting_menu['full_width_value'] != '' ? $setting_menu['full_width_value'] : '0';
                    }
                    $check = $full_width_value == '1' ? 'active' : '';
                    $full_width = $check == 'active' ? $check : '';
                    $fixed_width = $check == '' ? 'active' : '';
                    if ($is_mega == 'true') {
                        $switch = '<button class="btn btn-xs on active btn-success">' . __('ON', WR_MEGAMENU_TEXTDOMAIN) . '</button><button class="btn btn-xs off btn-default">' . __('OFF', WR_MEGAMENU_TEXTDOMAIN) . '</button>';
                    } else {
                        $switch = '<button class="btn btn-xs on btn-default">' . __('ON', WR_MEGAMENU_TEXTDOMAIN) . '</button><button class="btn btn-xs off active btn-danger">' . __('OFF', WR_MEGAMENU_TEXTDOMAIN) . '</button>';
                    }
                    $html[] = '<li class="top-level-item">
								<div class="btn-group">
									<button class="btn btn-default btn-menu-title" id="menu-item-' . $item->ID . '">' . $item->title . '</button>
									<button class="btn btn-menu-setting-popover hidden dropup" data-menu="' . $item->ID . '">
										<span class="glyphicon glyphicon-cog"></span>
									</button>
									<div class="popover bottom setting-menu-item" id="setting-menu-item-' . $item->ID . '">
										<div class="arrow"></div>
										<h3 class="popover-title">
											' . __('Configuration', WR_MEGAMENU_TEXTDOMAIN) . '
											  <div class="btn-group btn-toggle pull-right">
												 ' . $switch . '
											  </div>
										</h3>
										<div class="popover-content">
											<div class="form-horizontal setting-content">
												<input type="hidden" value="' . $is_mega . '" id="is-mega-' . $item->ID . '">
												<div class="form-group">
													<label class="col-sm-4 control-label">' . __('Container Width', WR_MEGAMENU_TEXTDOMAIN) . '</label>
													<div class="col-sm-4 container-width">
														<div id="container_group" class="btn-group">
														  <button type="button" id="full_width" class="btn btn-default ' . $full_width . '">' . __('Full', WR_MEGAMENU_TEXTDOMAIN) . '</button>
														  <button type="button" id="fixed_width" class="btn btn-default ' . $fixed_width . '">' . __('Fixed', WR_MEGAMENU_TEXTDOMAIN) . '</button>
														</div>
													</div>
													<div class="col-sm-4 fixed-with">
														<div class="input-group">
														  <input type="number" min="100" id="container_width" name="container_width" class="form-control"  value="' . $container_width . '" />
														  <span class="input-group-addon">' . __('px') . '</span>
														  <input type="hidden" id="full_width_value" name="full_width_value" value="' . $full_width_value . '" />
														</div>

													</div>
												  </div>

											</div>
										</div>
									</div>
								</div>
						  </li>';
                }
                $html[] = '</ul>';
                $html[] = '<div class="clearbreak"></div>';
            } else {
                $html[] = '<p class="jsn-bglabel">' . __('This menu does not have any sub menu item.') . ' <a href="' . admin_url('nav-menus.php?action=edit&menu=' . $menu->term_id) . '" target="_blank">' . __('Add new') . '</a>' . '</p>';
            }
            echo json_encode(array('menu_type' => $menu->term_id, 'html' => implode("\n", $html)));
        } else {
            $html[] = '<p id="wr-assign-menu" class="jsn-bglabel">' . __('No menu assigned to this location.') . '<br/><a href="' . admin_url('nav-menus.php?action=locations') . '" target="_blank" class="btn btn-default">' . __('Manage Locations') . '</a>' . '</p>';
            echo json_encode(array('menu_type' => '', 'html' => implode("\n", $html)));
        }
        exit;
    }
예제 #4
0
<?php

/**
 * @version    $Id$
 * @package    WR MegaMenu
 * @author     WooRockets Team <*****@*****.**>
 * @copyright  Copyright (C) 2014 WooRockets.com All Rights Reserved.
 * @license    GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.woorockets.com
 * Technical Support:  Feedback - http://www.woorockets.com
 */
wp_nonce_field('wr_mm_builder', WR_MEGAMENU_NONCE . '_builder');
$locations = get_registered_nav_menus();
$menus = wp_get_nav_menus();
$data = WR_Megamenu_Helpers_Builder::get_megamenu_data($profile->ID);
$menu_type = isset($data['menu_type']) ? $data['menu_type'] : (isset($menus[0]->term_id) ? $menus[0]->term_id : '');
$tab_contents = array('menu_bar' => 'Menu Bar', 'submenu_panel' => 'Submenu Panel');
$styling_fields = array();
$styling_fields['menu_bar'] = array(array('name' => __('Menu layout', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-menu_layout', 'type' => 'radio_button_group', 'std' => 'horizontal', 'icons' => 'wr-icon-horizontal_#_wr-icon-vertical', 'options' => array('horizontal' => __('Horizontal', WR_MEGAMENU_TEXTDOMAIN), 'vertical' => __('Vertical', WR_MEGAMENU_TEXTDOMAIN))), array('name' => __('Stick menu to top', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-stick_menu', 'type' => 'radio_group', 'std' => 'no', 'options' => array('no' => __('No', WR_MEGAMENU_TEXTDOMAIN), 'yes' => __('Yes', WR_MEGAMENU_TEXTDOMAIN)), 'tooltip' => __('Stick menu to top when scroll down', WR_MEGAMENU_TEXTDOMAIN)), array('name' => __('Font', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-font', 'type' => 'select', 'class' => 'input-sm', 'std' => __('inherit', WR_MEGAMENU_TEXTDOMAIN), 'options' => array('inherit' => 'Inherit', 'custom' => 'Custom'), 'has_depend' => '1'), array('name' => __('Font Face', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-font_family', 'type' => array(array('id' => 'menu-bar-font_type', 'type' => 'select', 'class' => 'font-type ', 'std' => 'Standard Font', 'options' => array('Standard Font' => 'Standard Font', 'Google Font' => 'Google Font')), array('id' => 'menu-bar-font_face', 'type' => 'select', 'class' => 'font-face', 'std' => 'Arial', 'options' => array('Arial' => 'Arial', 'Verdana' => 'Verdana', 'Times New Roman' => 'Times New Roman'))), 'dependency' => array('menu-bar-font', '=', 'custom')), array('name' => __('Font Attributes', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-font_attributes', 'type' => array(array('id' => 'menu-bar-font_weight', 'type' => 'select', 'class' => 'form-control pull-left', 'std' => 'normal', 'options' => array('bold' => 'Bold', 'light' => 'Light', 'normal' => 'Normal', 'thin' => 'Thin')), array('id' => 'menu-bar-font_size', 'type' => 'select', 'class' => 'form-control pull-left', 'std' => '10', 'options' => array('10' => '10', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20')), array('id' => 'menu-bar-menu_color', 'type' => 'color_picker2', 'std' => '#000', 'hide_value' => 'true', 'wrap_color_class' => '')), 'dependency' => array('menu-bar-font', '=', 'custom')), array('name' => __('Background Color', WR_MEGAMENU_TEXTDOMAIN), 'type' => array(array('id' => 'menu-bar-bg', 'type' => 'color_picker2', 'std' => '#ffffff')), 'container_class' => 'combo-group'), array('name' => __('Background On Hover', WR_MEGAMENU_TEXTDOMAIN), 'type' => array(array('id' => 'menu-bar-on_hover', 'type' => 'color_picker2', 'std' => '#ffffff')), 'container_class' => 'combo-group'), array('name' => __('Icon', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-icon_spacer', 'class' => 'wr_spacer', 'blank_output' => '1', 'type' => 'spacer', 'tooltip' => __('To add icon for menu item, access to WP Menu management', WR_MEGAMENU_TEXTDOMAIN)), array('name' => __('Display Mode', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-icon_display_mode', 'type' => 'radio_button_group', 'std' => 'text_only', 'icons' => 'wr-icon-text-only_#_wr-icon-icon-only_#_wr-icon-icon-text', 'options' => array('text_only' => __('Text Only', WR_MEGAMENU_TEXTDOMAIN), 'icon_only' => __('Icon Only', WR_MEGAMENU_TEXTDOMAIN), 'icon_text' => __('Icon vs Text', WR_MEGAMENU_TEXTDOMAIN)), 'has_depend' => '1'), array('name' => __('Icon Position', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-icon_position', 'type' => 'radio_group', 'std' => 'left', 'options' => array('left' => __('Left', WR_MEGAMENU_TEXTDOMAIN), 'top' => __('Top', WR_MEGAMENU_TEXTDOMAIN)), 'tooltip' => __('the position of icon', WR_MEGAMENU_TEXTDOMAIN), 'dependency' => array('menu-bar-icon_display_mode', '=', 'icon_text')), array('name' => __('Icon Size', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'menu-bar-icon_size', 'type' => 'text_number', 'exclude_class' => array('form-control'), 'std' => '16', 'dependency' => array('menu-bar-icon_display_mode', '!=', 'text_only')));
$styling_fields['submenu_panel'] = array(array('name' => __('Heading Text', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'heading-text-font', 'type' => 'select', 'class' => 'input-sm', 'std' => __('inherit', WR_MEGAMENU_TEXTDOMAIN), 'options' => array('inherit' => 'Inherit', 'custom' => 'Custom'), 'has_depend' => '1'), array('name' => __('Font Face', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'heading-text-font_family', 'type' => array(array('id' => 'heading-text-font_type', 'type' => 'select', 'class' => 'font-type', 'std' => 'Standard Font', 'options' => array('Standard Font' => 'Standard Font', 'Google Font' => 'Google Font')), array('id' => 'heading-text-font_face', 'type' => 'select', 'class' => 'font-face', 'std' => __('Arial', WR_MEGAMENU_TEXTDOMAIN), 'role' => 'title', 'options' => array('Arial' => 'Arial', 'Verdana' => 'Verdana', 'Times New Roman' => 'Times New Roman'))), 'dependency' => array('heading-text-font', '=', 'custom')), array('name' => __('Font Attributes', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'heading-text-font_attributes', 'type' => array(array('id' => 'heading-text-font_weight', 'type' => 'select', 'class' => 'form-control', 'std' => 'bold', 'options' => array('bold' => 'Bold', 'light' => 'Light', 'normal' => 'Normal', 'thin' => 'Thin')), array('id' => 'heading-text-font_size', 'type' => 'select', 'class' => 'form-control', 'std' => '10', 'options' => array('10' => '10', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20')), array('id' => 'heading-text-menu_color', 'type' => 'color_picker2', 'hide_value' => 'true', 'std' => '#000', 'wrap_color_class' => '')), 'dependency' => array('heading-text-font', '=', 'custom')), array('name' => __('Normal Text', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'normal-text-font', 'type' => 'select', 'class' => 'input-sm', 'std' => __('inherit', WR_MEGAMENU_TEXTDOMAIN), 'options' => array('inherit' => 'Inherit', 'custom' => 'Custom'), 'has_depend' => '1'), array('name' => __('Font Face', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'normal-text-font_family', 'type' => array(array('id' => 'normal-text-font_type', 'type' => 'select', 'class' => 'font-type', 'std' => 'Standard Font', 'options' => array('Standard Font' => 'Standard Font', 'Google Font' => 'Google Font')), array('id' => 'normal-text-font_face', 'type' => 'select', 'class' => 'font-face', 'std' => 'Arial', 'role' => 'title', 'options' => array('Arial' => 'Arial', 'Verdana' => 'Verdana', 'Times New Roman' => 'Times New Roman'))), 'dependency' => array('normal-text-font', '=', 'custom')), array('name' => __('Font Attributes', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'normal-text-font_attributes', 'type' => array(array('id' => 'normal-text-font_weight', 'type' => 'select', 'class' => 'form-control', 'std' => 'bold', 'role' => 'title', 'options' => array('bold' => 'Bold', 'light' => 'Light', 'normal' => 'Normal', 'thin' => 'Thin')), array('id' => 'normal-text-font_size', 'type' => 'select', 'class' => 'form-control', 'std' => '10', 'role' => 'title', 'options' => array('10' => '10', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20')), array('id' => 'normal-text-menu_color', 'class' => 'form-control', 'hide_value' => 'true', 'type' => 'color_picker2', 'std' => '#000', 'wrap_color_class' => '')), 'dependency' => array('normal-text-font', '=', 'custom')), array('name' => __('Enable Bullet Icon', WR_MEGAMENU_TEXTDOMAIN), 'id' => 'submenu-panel-bullet_icon', 'type' => 'radio_group', 'std' => 'yes', 'options' => array('no' => __('No', WR_MEGAMENU_TEXTDOMAIN), 'yes' => __('Yes', WR_MEGAMENU_TEXTDOMAIN))));
?>
<div id="wr-megamenu-builder" class="jsn-master">
	<div class="wr-megamenu-builder-container jsn-section-content jsn-style-light jsn-bootstrap3">
		<div id="wr-menu-controls" class="">
			<div id="wr-menu-top-options">

				<div class="control-group">
					<label class="control-label" for="locations"><?php 
_e('Location', WR_MEGAMENU_TEXTDOMAIN);
?>