function ubermenu_reset_settings()
{
    if (isset($_GET['page']) && $_GET['page'] == 'ubermenu-settings') {
        if (!current_user_can('manage_options')) {
            die('You need to be an admin to do that');
        }
        if (isset($_GET['do']) && $_GET['do'] == 'reset-all') {
            $instances = ubermenu_get_menu_instances(true);
            foreach ($instances as $config_id) {
                delete_option(UBERMENU_PREFIX . $config_id);
            }
            delete_option(UBERMENU_PREFIX . 'general');
            ubermenu_save_all_menu_styles();
        } else {
            if (isset($_GET['do']) && $_GET['do'] == 'reset-styles') {
                $instances = ubermenu_get_menu_instances(true);
                $all_fields = ubermenu_get_settings_fields();
                foreach ($instances as $config_id) {
                    $ops = ubermenu_get_instance_options($config_id);
                    $fields = $all_fields[UBERMENU_PREFIX . $config_id];
                    //up( $fields , 2 );
                    foreach ($fields as $field) {
                        if ($field['group'] == 'style_customizations' && $field['type'] != 'header') {
                            $ops[$field['name']] = isset($field['default']) ? $field['default'] : '';
                        }
                    }
                    //up( $ops );
                    update_option(UBERMENU_PREFIX . $config_id, $ops);
                    ubermenu_save_all_menu_styles();
                }
            }
        }
    }
}
Exemplo n.º 2
0
function ubermenu_sticky_load_assets()
{
    if (UM_STICKY()->sticky_apply()) {
        if (SCRIPT_DEBUG) {
            wp_enqueue_script('ubermenu-sticky-js', UM_STICKY_PLUGIN_URL . 'assets/ubermenu.sticky.js', array('jquery', 'ubermenu'), UM_STICKY_VERSION, true);
        } else {
            wp_enqueue_script('ubermenu-sticky-js', UM_STICKY_PLUGIN_URL . 'assets/ubermenu.sticky.min.js', array('jquery', 'ubermenu'), UM_STICKY_VERSION, true);
        }
        $menus = ubermenu_get_menu_instances(true);
        $settings = array();
        foreach ($menus as $config_id) {
            if (UM_STICKY()->sticky_apply($config_id)) {
                $is_sticky = 1;
                if (wp_is_mobile() && ubermenu_op('sticky_mobile', $config_id) != 'on') {
                    $is_sticky = 0;
                }
                $is_permanent = ubermenu_op('sticky_permanent', $config_id) == 'on' ? 1 : 0;
                if ($is_permanent == 1) {
                    $is_sticky = 1;
                }
                //$mid = UBERMENU_PREFIX.$config_id;
                $settings[$config_id] = array('full_width_menu_bar' => ubermenu_op('sticky_full_width', $config_id), 'center_inner_width' => ubermenu_op('sticky_center_inner_width', $config_id), 'offset' => ubermenu_op('sticky_offset', $config_id), 'mobile' => ubermenu_op('sticky_mobile', $config_id), 'sticky_offset' => ubermenu_op('sticky_offset', $config_id), 'is_sticky' => $is_sticky, 'permanent' => $is_permanent, 'is_mobile' => wp_is_mobile() ? 1 : 0);
                //}
            }
        }
        wp_localize_script('ubermenu-sticky-js', 'ubermenu_sticky_settings', $settings);
    }
}
Exemplo n.º 3
0
function ubermenu_load_fonts()
{
    $menus = ubermenu_get_menu_instances(true);
    foreach ($menus as $menu) {
        $google_font = ubermenu_op('google_font', $menu);
        if ($google_font) {
            //echo $google_font.'<br/>';
            ubermenu_load_font($google_font);
        }
    }
}
Exemplo n.º 4
0
function ubermenu_save_all_menu_styles()
{
    ubermenu_save_menu_styles('main');
    if (function_exists('ubermenu_get_menu_instances')) {
        $menus = ubermenu_get_menu_instances();
        foreach ($menus as $menu_id) {
            ubermenu_save_menu_styles($menu_id);
        }
    }
    ubermenu_reset_generated_styles();
    //clears transient
    add_settings_error('menu', 'menu-styles', 'Custom menu styles updated.', 'updated');
}
 static function sticky_apply($config_id = false)
 {
     //global $uberMenu, $post, $ubermenusticky_apply;
     if ($config_id == false) {
         //Figure it out it not already determined
         if (self::$sticky_apply_global == -1) {
             $menus = ubermenu_get_menu_instances(true);
             foreach ($menus as $config_id) {
                 self::$sticky_apply_global = self::$sticky_apply_global || self::sticky_apply($config_id);
             }
         }
         return self::$sticky_apply_global;
     } else {
         //Not yet determined
         if (!isset(self::$sticky_apply[$config_id])) {
             $apply = false;
             if (ubermenu_op('sticky_enabled', $config_id) == 'on') {
                 $apply_to = ubermenu_op('sticky_apply_to', $config_id);
                 if ($apply_to === '') {
                     $apply = true;
                 } else {
                     $apply_to = explode(',', $apply_to);
                     $apply = false;
                     global $post;
                     foreach ($apply_to as $post_id) {
                         //echo $post_id . ' :: ' .$post->ID;
                         if ($post_id == $post->ID || $post_id == 'front' && is_front_page()) {
                             $apply = true;
                             break;
                         }
                     }
                 }
             }
             $apply = apply_filters('ubermenu_sticky_apply', $apply, $config_id);
             self::$sticky_apply[$config_id] = $apply;
         }
         return self::$sticky_apply[$config_id];
     }
     return self::$sticky_apply;
 }
Exemplo n.º 6
0
function ubermenu_settings_panel_fields_delete($fields = array())
{
    $delete_header = array('name' => 'header_delete', 'label' => __('Delete', 'ubermenu'), 'type' => 'header', 'group' => 'delete');
    $menus = ubermenu_get_menu_instances(false);
    foreach ($menus as $menu) {
        //Requres $menu var
        $delete_instance = array('name' => 'delete', 'label' => __('Delete Configuration', 'shiftnav'), 'desc' => '<a class="ubermenu_instance_button ubermenu_instance_button_delete" href="#" data-ubermenu-instance-id="' . $menu . '" data-ubermenu-nonce="' . wp_create_nonce('ubermenu-delete-instance') . '">' . __('Permanently Delete Configuration', 'ubermenu') . '</a>', 'type' => 'html', 'group' => 'delete');
        $fields[UBERMENU_PREFIX . $menu][2000] = $delete_header;
        $fields[UBERMENU_PREFIX . $menu][2000] = $delete_instance;
    }
    return $fields;
}
Exemplo n.º 7
0
    /**
     * Generates the administration form for the widget.
     *
     * @param array instance The array of keys and values for the widget.
     */
    public function form($instance)
    {
        extract(wp_parse_args((array) $instance, array('config_id' => 'main', 'theme_location' => 0, 'menu_id' => 0)));
        echo '<p>' . __('This widget inserts and UberMenu in one of two ways:', 'ubermenu') . '</p>';
        //Alternatively, you can set a Theme Location if you do not have a specific menu assigned to this instance, and that menu will be used.
        $instances = ubermenu_get_menu_instances(true);
        ?>

		<hr/>

		<?php 
        echo '<h4>' . __('1. By Menu Configuration', 'ubermenu') . '</h4>';
        echo '<p>' . __('(1) Set the UberMenu Configuration to use. The menu set for that Configuration\'s "Default Manual Integration Menu" will be used by default.  You can override the menu used by using the Menu setting below.', 'ubermenu') . '</p>';
        ?>
		<p>
			<strong><label for="<?php 
        echo $this->get_field_id('config_id');
        ?>
"><?php 
        _e('UberMenu Configuration:', 'ubermenu');
        ?>
</label></strong>
			<select id="<?php 
        echo $this->get_field_id('config_id');
        ?>
" name="<?php 
        echo $this->get_field_name('config_id');
        ?>
">
				<!--<option value="0"><?php 
        _e('[None - Use a Theme Location]');
        ?>
</option>-->
		<?php 
        foreach ($instances as $_config_id) {
            echo '<option value="' . $_config_id . '"' . selected($config_id, $_config_id, false) . '>' . $_config_id . '</option>';
        }
        ?>
			</select>
		</p>
		<?php 
        $menus = wp_get_nav_menus(array('orderby' => 'name'));
        ?>
		<p>
			<strong><label for="<?php 
        echo $this->get_field_id('menu_id');
        ?>
"><?php 
        _e('Menu (optional):', 'ubermenu');
        ?>
</label></strong>
			<select id="<?php 
        echo $this->get_field_id('menu_id');
        ?>
" name="<?php 
        echo $this->get_field_name('menu_id');
        ?>
">
				<option value="0"><?php 
        _e('[Automatic]');
        ?>
</option>
		<?php 
        foreach ($menus as $menu) {
            echo '<option value="' . $menu->term_id . '"' . selected($menu_id, $menu->term_id, false) . '>' . $menu->name . '</option>';
        }
        ?>
			</select>
		</p>

		<hr />
		<?php 
        echo '<h4>' . __('2. By Theme Location', 'ubermenu') . '</h4>';
        echo '<p>' . __('Alternatively, set a Theme Location to just insert a standard menu that you can then activate as an UberMenu.', 'ubermenu') . '</p>';
        $theme_locs = get_registered_nav_menus();
        ?>
		
		<p>
			<strong><label for="<?php 
        echo $this->get_field_id('theme_location');
        ?>
"><?php 
        _e('Theme Location:', 'ubermenu');
        ?>
</label></strong>
			<select id="<?php 
        echo $this->get_field_id('theme_location');
        ?>
" name="<?php 
        echo $this->get_field_name('theme_location');
        ?>
">
				<option value="0"><?php 
        _e('[None]');
        ?>
</option>
		<?php 
        foreach ($theme_locs as $loc_id => $loc_name) {
            //$loc_name
            echo '<option value="' . $loc_id . '"' . selected($loc_id, $theme_location, false) . '>' . $loc_name . '</option>';
        }
        ?>
			</select>
			<br/>
			<small>Setting the Theme Location will override the Menu Instance Settings</small>
		</p>


		<hr/>
		<?php 
    }
Exemplo n.º 8
0
function ubermenu_get_menu_instance_by_theme_location($theme_location)
{
    //Check Main
    $auto_theme_locations = ubermenu_op('auto_theme_location', 'main');
    if (is_array($auto_theme_locations)) {
        foreach ($auto_theme_locations as $loc) {
            if ($theme_location == $loc) {
                return 'main';
            }
        }
    }
    //Check Instances
    $instances = ubermenu_get_menu_instances();
    foreach ($instances as $config_id) {
        $auto_theme_locations = ubermenu_op('auto_theme_location', $config_id);
        if (is_array($auto_theme_locations)) {
            foreach ($auto_theme_locations as $loc) {
                if ($theme_location == $loc) {
                    return $config_id;
                }
            }
        }
    }
    return false;
}
Exemplo n.º 9
0
function ubermenu_generate_all_menu_preview_styles()
{
    $all_styles = array();
    //$all_styles['main'] = ubermenu_generate_menu_preview_styles( 'main' );
    $instances = ubermenu_get_menu_instances(true);
    foreach ($instances as $config_id) {
        $all_styles[$config_id] = ubermenu_generate_menu_preview_styles($config_id);
    }
    return ubermenu_generate_all_menu_styles($all_styles);
}