/**
  * Return default menu toggle block settings
  *
  * @since 2.1
  * @return array
  */
 private function get_default_menu_toggle_block($theme_id = 'default')
 {
     $style_manager = new Mega_Menu_Style_Manager();
     $themes = $style_manager->get_themes();
     $menu_theme = isset($themes[$theme_id]) ? $themes[$theme_id] : $themes['default'];
     $defaults = array('type' => 'menu_toggle', 'align' => 'right', 'closed_text' => isset($menu_theme['responsive_text']) ? $menu_theme['responsive_text'] : "MENU", 'open_text' => isset($menu_theme['responsive_text']) ? $menu_theme['responsive_text'] : "MENU", 'closed_icon' => 'dash-f333', 'open_icon' => 'dash-f153', 'icon_position' => 'after', 'text_color' => isset($menu_theme['toggle_font_color']) ? $menu_theme['toggle_font_color'] : '#fff', 'icon_color' => isset($menu_theme['toggle_font_color']) ? $menu_theme['toggle_font_color'] : '#fff');
     return $defaults;
 }
Exemple #2
0
 /**
  *
  * @since 1.4
  */
 public function init()
 {
     if (class_exists("Mega_Menu_Style_Manager")) {
         $style_manager = new Mega_Menu_Style_Manager();
         $this->themes = $style_manager->get_themes();
         $this->id = isset($_GET['theme']) ? $_GET['theme'] : 'default';
         $this->active_theme = $this->themes[$this->id];
     }
 }
 /**
  * Constructor
  *
  * @since 1.0
  */
 public function __construct()
 {
     add_action('admin_post_megamenu_save_theme', array($this, 'save'));
     add_action('admin_post_megamenu_add_theme', array($this, 'create'));
     add_action('admin_post_megamenu_delete_theme', array($this, 'delete'));
     add_action('admin_post_megamenu_revert_theme', array($this, 'revert'));
     add_action('admin_post_megamenu_duplicate_theme', array($this, 'duplicate'));
     add_action('admin_menu', array($this, 'megamenu_themes_page'));
     add_action("admin_enqueue_scripts", array($this, 'enqueue_theme_editor_scripts'));
     if (class_exists("Mega_Menu_Style_Manager")) {
         $style_manager = new Mega_Menu_Style_Manager();
         $this->themes = $style_manager->get_themes();
         $this->id = isset($_GET['theme']) ? $_GET['theme'] : 'default';
         $this->active_theme = $this->themes[$this->id];
     }
 }
Exemple #4
0
 /**
  * Retrieve the enabled Google Fonts from the settings
  *
  * @since 1.0
  */
 public function set_enabled_fonts()
 {
     $settings = get_option("megamenu_settings");
     if (!is_array($settings)) {
         return;
     }
     if (!class_exists('Mega_Menu_Style_Manager')) {
         return;
     }
     $style_manager = new Mega_Menu_Style_Manager();
     $google_fonts = $this->google_fonts();
     foreach ($settings as $location => $settings) {
         if (isset($settings['enabled']) && has_nav_menu($location)) {
             $theme_id = isset($settings['theme']) ? $settings['theme'] : 'default';
             $all_themes = $style_manager->get_themes();
             $theme_settings = isset($all_themes[$theme_id]) ? $all_themes[$theme_id] : $all_themes['default'];
             foreach ($theme_settings as $theme_setting => $value) {
                 if (in_array($value, $google_fonts)) {
                     $this->enabled_fonts[$value] = $value;
                 }
             }
         }
     }
 }
Exemple #5
0
 /**
  * Use the Mega Menu walker to output the menu
  * Resets all parameters used in the wp_nav_menu call
  * Wraps the menu in mega-menu IDs and classes
  *
  * @since 1.0
  * @param $args array
  * @return array
  */
 public function modify_nav_menu_args($args)
 {
     $settings = get_option('megamenu_settings');
     $current_theme_location = $args['theme_location'];
     $locations = get_nav_menu_locations();
     if (isset($settings[$current_theme_location]['enabled']) && $settings[$current_theme_location]['enabled'] == true) {
         if (!isset($locations[$current_theme_location])) {
             return $args;
         }
         $menu_id = $locations[$current_theme_location];
         if (!$menu_id) {
             return $args;
         }
         $style_manager = new Mega_Menu_Style_Manager();
         $themes = $style_manager->get_themes();
         $menu_theme = isset($themes[$settings[$current_theme_location]['theme']]) ? $themes[$settings[$current_theme_location]['theme']] : $themes['default'];
         $menu_settings = $settings[$current_theme_location];
         $wrap_attributes = apply_filters("megamenu_wrap_attributes", array("id" => '%1$s', "class" => '%2$s mega-no-js', "data-event" => isset($menu_settings['event']) ? $menu_settings['event'] : 'hover', "data-effect" => isset($menu_settings['effect']) ? $menu_settings['effect'] : 'disabled', "data-panel-width" => preg_match('/^\\d/', $menu_theme['panel_width']) !== 1 ? $menu_theme['panel_width'] : '', "data-second-click" => isset($settings['second_click']) ? $settings['second_click'] : 'close', "data-mobile-behaviour" => isset($settings['mobile_behaviour']) ? $settings['mobile_behaviour'] : 'standard', "data-breakpoint" => absint($menu_theme['responsive_breakpoint'])), $menu_id, $menu_settings, $settings, $current_theme_location);
         $attributes = "";
         foreach ($wrap_attributes as $attribute => $value) {
             if (strlen($value)) {
                 $attributes .= " " . $attribute . '="' . $value . '"';
             }
         }
         $sanitized_location = str_replace(apply_filters("megamenu_location_replacements", array("-", " ")), "-", $current_theme_location);
         $defaults = array('menu' => $menu_id, 'container' => 'div', 'container_class' => 'mega-menu-wrap', 'container_id' => 'mega-menu-wrap-' . $sanitized_location, 'menu_class' => 'mega-menu mega-menu-horizontal', 'menu_id' => 'mega-menu-' . $sanitized_location, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul' . $attributes . '>%3$s</ul>', 'depth' => 0, 'walker' => new Mega_Menu_Walker());
         $args = array_merge($args, apply_filters("megamenu_nav_menu_args", $defaults, $menu_id, $current_theme_location));
     }
     return $args;
 }
Exemple #6
0
        /**
         * Print the list of Mega Menu settings
         *
         * @since 1.0
         */
        public function settings_table($location, $settings)
        {
            ?>
        <table>
            <tr>
                <td><?php 
            _e("Enable", "megamenu");
            ?>
</td>
                <td>
                    <input type='checkbox' class='megamenu_enabled' name='megamenu_meta[<?php 
            echo $location;
            ?>
][enabled]' value='1' <?php 
            checked(isset($settings[$location]['enabled']));
            ?>
 />
                </td>
            </tr>
            <tr>
                <td><?php 
            _e("Event", "megamenu");
            ?>
</td>
                <td>
                    <select name='megamenu_meta[<?php 
            echo $location;
            ?>
][event]'>
                        <option value='hover' <?php 
            selected(isset($settings[$location]['event']) && $settings[$location]['event'] == 'hover');
            ?>
><?php 
            _e("Hover", "megamenu");
            ?>
</option>
                        <option value='click' <?php 
            selected(isset($settings[$location]['event']) && $settings[$location]['event'] == 'click');
            ?>
><?php 
            _e("Click", "megamenu");
            ?>
</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><?php 
            _e("Effect", "megamenu");
            ?>
</td>
                <td>
                    <select name='megamenu_meta[<?php 
            echo $location;
            ?>
][effect]'>
                    <?php 
            $selected = isset($settings[$location]['effect']) ? $settings[$location]['effect'] : 'disabled';
            $options = apply_filters("megamenu_effects", array("disabled" => array('label' => __("None", "megamenu"), 'selected' => $selected == 'disabled'), "fade" => array('label' => __("Fade", "megamenu"), 'selected' => $selected == 'fade'), "slide" => array('label' => __("Slide", "megamenu"), 'selected' => $selected == 'slide')), $selected);
            foreach ($options as $key => $value) {
                ?>
<option value='<?php 
                echo $key;
                ?>
' <?php 
                selected($value['selected']);
                ?>
><?php 
                echo $value['label'];
                ?>
</option><?php 
            }
            ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td><?php 
            _e("Theme", "megamenu");
            ?>
</td>
                <td>

                    <select name='megamenu_meta[<?php 
            echo $location;
            ?>
][theme]'>
                        <?php 
            $style_manager = new Mega_Menu_Style_Manager();
            $themes = $style_manager->get_themes();
            $selected_theme = isset($settings[$location]['theme']) ? $settings[$location]['theme'] : 'default';
            foreach ($themes as $key => $theme) {
                echo "<option value='{$key}' " . selected($selected_theme, $key) . ">{$theme['title']}</option>";
            }
            ?>
                    </select>
                </td>
            </tr>

            <?php 
            do_action('megamenu_settings_table', $location, $settings);
            ?>
        </table>
        <?php 
        }
 /**
  * @since 2.0.2
  * @param string $location - theme location identifier
  */
 function mmm_get_theme_for_location($location = false)
 {
     if (!$location) {
         return false;
     }
     if (!has_nav_menu($location)) {
         return false;
     }
     // if a location has been passed, check to see if MMM has been enabled for the location
     $settings = get_option('megamenu_settings');
     $style_manager = new Mega_Menu_Style_Manager();
     $themes = $style_manager->get_themes();
     if (is_array($settings) && isset($settings[$location]['enabled']) && isset($settings[$location]['theme'])) {
         $theme = $settings[$location]['theme'];
         $menu_theme = isset($themes[$theme]) ? $themes[$theme] : $themes['default'];
         return $menu_theme;
     }
     return $themes['default'];
 }
        /**
         * Print the list of Mega Menu settings
         *
         * @since 1.0
         */
        public function settings_table($location, $settings)
        {
            ?>
        <table>
            <tr>
                <td><?php 
            _e("Enable", "megamenu");
            ?>
</td>
                <td>
                    <input type='checkbox' name='megamenu_meta[<?php 
            echo $location;
            ?>
][enabled]' value='1' <?php 
            checked(isset($settings[$location]['enabled']));
            ?>
 />
                </td>
            </tr>
            <tr>
                <td><?php 
            _e("Event", "megamenu");
            ?>
</td>
                <td>
                    <select name='megamenu_meta[<?php 
            echo $location;
            ?>
][event]'>
                        <option value='hover' <?php 
            selected(isset($settings[$location]['event']) && $settings[$location]['event'] == 'hover');
            ?>
><?php 
            _e("Hover", "megamenu");
            ?>
</option>
                        <option value='click' <?php 
            selected(isset($settings[$location]['event']) && $settings[$location]['event'] == 'click');
            ?>
><?php 
            _e("Click", "megamenu");
            ?>
</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><?php 
            _e("Effect", "megamenu");
            ?>
</td>
                <td>
                    <select name='megamenu_meta[<?php 
            echo $location;
            ?>
][effect]'>
                        <option value='disabled' <?php 
            selected(isset($settings[$location]['effect']) && $settings[$location]['effect'] == 'disabled');
            ?>
><?php 
            _e("None", "megamenu");
            ?>
</option>
                        <option value='fade' <?php 
            selected(isset($settings[$location]['effect']) && $settings[$location]['effect'] == 'fade');
            ?>
><?php 
            _e("Fade", "megamenu");
            ?>
</option>
                        <option value='slide' <?php 
            selected(isset($settings[$location]['effect']) && $settings[$location]['effect'] == 'slide');
            ?>
><?php 
            _e("Slide", "megamenu");
            ?>
</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><?php 
            _e("Theme", "megamenu");
            ?>
</td>
                <td>

                    <select name='megamenu_meta[<?php 
            echo $location;
            ?>
][theme]'>
                        <?php 
            $style_manager = new Mega_Menu_Style_Manager();
            $themes = $style_manager->get_themes();
            foreach ($themes as $key => $theme) {
                echo "<option value='{$key}' " . selected($settings[$location]['theme'], $key) . ">{$theme['title']}</option>";
            }
            ?>
                    </select>
                </td>
            </tr>

            <?php 
            do_action('megamenu_settings_table', $location, $settings);
            ?>
        </table>
        <?php 
        }