function widget($args, $instance)
    {
        extract($args);
        // Get menu
        if (!isset($instance['speed'])) {
            $instance['speed'] = 'slow';
        }
        $widget_options = wp_parse_args($instance, $this->defaults);
        extract($widget_options, EXTR_SKIP);
        $nav_menu = wp_get_nav_menu_object($instance['nav_menu']);
        if (!$nav_menu) {
            return;
        }
        $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $classMenu = $instance['classMenu'] != '' ? $instance['classMenu'] : 'menu';
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
        }
        ?>
		
		<div class="dcjq-accordion" id="<?php 
        echo $this->id . '-item';
        ?>
">
		
			<?php 
        wp_nav_menu(array('fallback_cb' => '', 'menu' => $nav_menu, 'container' => false, 'menu_class' => $classMenu));
        ?>
		
		</div>
		<?php 
        echo $args['after_widget'];
    }
Beispiel #2
0
function theme_get_menu($args = '')
{
    $args = wp_parse_args($args, array('source' => 'Pages', 'depth' => 0, 'menu' => null, 'class' => ''));
    $source =& $args['source'];
    $menu =& $args['menu'];
    $class =& $args['class'];
    if ($menu != null && is_string($menu)) {
        // theme location
        $location = theme_get_array_value(get_nav_menu_locations(), $menu);
        if ($location) {
            $menu = wp_get_nav_menu_object($location);
            if ($menu) {
                $source = 'Custom Menu';
                //Jordi
                //$class = implode(' ', array($class, 'menu-' . $menu->term_id));
                $class = implode(' ', array($class, 'menu-' . $menu->term_id, 'nav navbar-right'));
            }
        }
    }
    if ($source == 'Custom Menu' && $menu != null) {
        return theme_get_list_menu($args);
    }
    if ($source == 'Pages') {
        return theme_get_list_pages(array_merge(array('sort_column' => 'menu_order, post_title'), $args));
    }
    if ($source == 'Categories') {
        return theme_get_list_categories(array_merge(array('title_li' => false), $args));
    }
}
 /**
  * Outputs the content for the current Custom Menu widget instance.
  *
  * @since 3.0.0
  * @access public
  *
  * @param array $args     Display arguments including 'before_title', 'after_title',
  *                        'before_widget', and 'after_widget'.
  * @param array $instance Settings for the current Custom Menu widget instance.
  */
 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu);
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      * @since 4.4.0 Added the `$instance` parameter.
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callable|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      * @param array    $instance      Array of settings for the current widget.
      */
     wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance));
     echo $args['after_widget'];
 }
    function widget($args, $instance)
    {
        global $post;
        $cache = wp_cache_get('widget_progressive_menu', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
        if (!$nav_menu) {
            return;
        }
        ob_start();
        extract($args);
        echo $before_widget;
        if (!empty($instance['title'])) {
            $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
            echo $before_title . esc_html($title) . $after_title;
        }
        echo '<nav>';
        wp_nav_menu(array('fallback_cb' => '', 'container' => false, 'menu' => $nav_menu, 'menu_class' => 'theme-menu', 'depth' => 2, 'walker' => new progressive_menu_widget_walker_nav_menu()));
        echo '</nav>';
        ?>

		<?php 
        echo $after_widget;
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('widget_progressive_menu', $cache, 'widget');
    }
Beispiel #5
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;
 }
Beispiel #6
0
 public static function register()
 {
     register_nav_menu(self::$location, self::$description);
     if (!wp_get_nav_menu_object(self::$description)) {
         self::setup();
     }
 }
function theme_get_menu($args = '')
{
    $args = apply_filters('wp_nav_menu_args', $args);
    $nav_menu = apply_filters('pre_wp_nav_menu', null, $args);
    if (null !== $nav_menu) {
        return $nav_menu;
    }
    $args = wp_parse_args($args, array('source' => 'Pages', 'depth' => 0, 'menu' => null, 'class' => ''));
    $source =& $args['source'];
    $menu =& $args['menu'];
    $class =& $args['class'];
    if ($menu != null && is_string($menu)) {
        // theme location
        $location = theme_get_array_value(get_nav_menu_locations(), $menu);
        if ($location) {
            $menu = wp_get_nav_menu_object($location);
            if ($menu) {
                $source = 'Custom Menu';
                $class = implode(' ', array($class, 'menu-' . $menu->term_id));
            }
        }
    }
    if ($source == 'Custom Menu' && $menu != null) {
        $nav_menu = theme_get_list_menu($args);
    } elseif ($source == 'Pages') {
        $nav_menu = theme_get_list_pages(array_merge(array('sort_column' => 'menu_order, post_title'), $args));
    } elseif ($source == 'Categories') {
        $nav_menu = theme_get_list_categories(array_merge(array('title_li' => false), $args));
    }
    return apply_filters('wp_nav_menu', $nav_menu, $args);
}
Beispiel #8
0
function wptouch_migrate_modded_menu()
{
    $menu_name = 'WPtouch - Recovered Page Menu';
    $menu_object = wp_get_nav_menu_object($menu_name);
    if (!$menu_object) {
        $menu_id = wp_create_nav_menu($menu_name);
        $pages = get_pages(array('post_status' => 'publish', 'sort_column' => 'menu_order, post_title'));
        $menu_items = array();
        $skipped_pages = array();
        foreach ($pages as $page) {
            if (wptouch_menu_is_disabled($page->ID)) {
                $skipped_pages[] = $page->ID;
            } elseif (!in_array($page->post_parent, $skipped_pages)) {
                $parent_id = 0;
                if (isset($menu_items[$page->post_parent])) {
                    $parent_id = $menu_items[$page->post_parent];
                }
                $args = array('menu-item-db-id' => 0, 'menu-item-object-id' => $page->ID, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-parent-id' => $parent_id, 'menu-item-status' => 'publish');
                $menu_items[$page->ID] = wp_update_nav_menu_item($menu_id, 0, $args);
                $menu_icon = get_post_meta($page->ID, '_wptouch_pro_menu_item_icon', true);
                if ($menu_icon) {
                    add_post_meta($menu_items[$page->ID], '_wptouch_pro_menu_item_icon', $menu_icon);
                }
            }
        }
    } else {
        $menu_id = $menu_object->ID;
    }
    return $menu_id;
}
    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget( $args, $instance ) {

        extract( $args );

        if( !isset( $instance['title'] ) )
            $instance['title'] = '';

        $title = apply_filters('widget_title', $instance['title'] );

        $nav_menu = isset( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : '';
        include_once( YIT_THEME_ASSETS_PATH . '/lib/Walker_Nav_Menu_Div.php' );

        $nav_args = array(
            'menu'       => $nav_menu,
            'container'  => 'div',
            'container_class' => 'submenu',
            'menu_class' => 'sub-menu clearfix',
            'depth'      => 3,
            'walker'     => new YIT_Walker_Nav_Menu_Div()
        );
        echo $before_widget;
        echo '<ul class="yit-cm"><li>';
        echo '<a href="#" class="btn-flat">'. $title .'</a>';
        wp_nav_menu( $nav_args );
        echo '</li></ul>';
        echo $after_widget;

    }
 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/default-widgets.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu, 'container-class' => 'container-fluid', 'items_wrap' => '<ul id="%1$s" class="nav nav-sidebar">%3$s</ul>', 'depth' => 1);
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      */
     wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args));
     echo $args['after_widget'];
 }
Beispiel #11
0
function expanded_nav_menu_css_class($classes = array(), $item, $args)
{
    $location_name = 'expanded_navigation';
    static $top_level_count = 0;
    //Top level menu items counter
    if ($args->theme_location == $location_name) {
        //Limit to this menu location only
        if ($item->menu_item_parent == 0 and $top_level_count !== null) {
            //Count top level menu items
            $top_level_count++;
            //Increment
        }
        if (($locations = get_nav_menu_locations()) && isset($locations[$location_name])) {
            $main_nav = wp_get_nav_menu_object($locations[$location_name]);
            if ($item->menu_item_parent == 0) {
                $classes[] = 'col-lg-15 col-md-3 col-sm-4 ex-menu-item';
            }
            if ($item->menu_order == 1) {
                $classes[] = 'menu-item menu-item-first';
                //First menu item
            }
            if ($top_level_count == count_top_level_menu_items($main_nav->term_id)) {
                $classes[] = 'menu-item-last';
                //Last top level menu item
                $top_level_count = null;
                //Disable our counter, no need for it
            }
        }
    }
    return $classes;
}
 function start_el(&$output, $item, $depth, $args)
 {
     global $wp_query;
     $ul_class = 'nobulletpoints col-sm-6 hidden-xs';
     if (!isset($this->current_menu)) {
         $this->current_menu = wp_get_nav_menu_object($args->menu);
     }
     if (!isset($this->break_point)) {
         $this->break_point = ceil($this->current_menu->count / 2) + 1;
     }
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     if ($this->break_point == $item->menu_order) {
         $output .= $indent . '</li></ul><ul class="' . $ul_class . '"><li' . $id . $value . $class_names . '>';
     } else {
         $output .= $indent . '<li' . $id . $value . $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) . '"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
 function van_check_menu()
 {
     global $VAN;
     //If custom menu exist,get the ID of pages
     if (($locations = get_nav_menu_locations()) && $locations['primary_navi']) {
         $menu = wp_get_nav_menu_object($locations['primary_navi']);
         $menu_items = wp_get_nav_menu_items($menu->term_id);
         $pageID = array();
         foreach ($menu_items as $item) {
             if ($item->object == 'page') {
                 $pageID[] = $item->object_id;
             }
         }
         query_posts(array('post_type' => 'page', 'post__in' => $pageID, 'posts_per_page' => count($pageID), 'orderby' => 'post__in'));
     } else {
         //If custom menu doesn't exist,check default page menu setting in theme options
         //If default page menu setting exist
         if (isset($VAN['pages_navi']) && $VAN['pages_navi'] != '') {
             query_posts(array('post_type' => 'page', 'post__in' => $VAN['pages_navi'], 'posts_per_page' => count($VAN['pages_navi']), 'orderby' => 'menu_order', 'order' => 'ASC'));
         } else {
             //If default page menu setting doesn't exist
             query_posts(array('post_type' => 'page', 'posts_per_page' => 6, 'orderby' => 'menu_order', 'order' => 'ASC'));
         }
     }
 }
Beispiel #14
0
function theme_get_menu($args = '')
{
    $args = wp_parse_args($args, array('source' => 'Pages', 'depth' => 0, 'menu' => null, 'class' => ''));
    $source =& $args['source'];
    $menu =& $args['menu'];
    if (function_exists('get_nav_menu_locations') && $menu != null && is_string($menu)) {
        // theme location
        $location = theme_get_array_value(get_nav_menu_locations(), $menu);
        if ($location) {
            $menu = wp_get_nav_menu_object($location);
            if ($menu) {
                $source = 'Custom Menu';
            }
        }
    }
    if ($source == 'Custom Menu' && function_exists('wp_nav_menu') && $menu != null) {
        return theme_get_list_menu($args);
    }
    if ($source == 'Pages') {
        return theme_get_list_pages(array_merge(array('sort_column' => 'menu_order, post_title'), $args));
    }
    if ($source == 'Categories') {
        return theme_get_list_categories(array_merge(array('title_li' => false), $args));
    }
}
Beispiel #15
0
 private function _402()
 {
     /* Fixed double key active_plugins */
     $plugins = get_option('active_plugins');
     if (is_array($plugins)) {
         $_plugins = array();
         foreach ($plugins as $plugin) {
             if (!in_array($plugin, $_plugins)) {
                 array_push($_plugins, $plugin);
             }
         }
         update_option('active_plugins', $_plugins);
     }
     /* Create new menu - top nav  */
     $menu_name = 'Top Navigation';
     //wp_delete_nav_menu( $menu_name );
     $menu_exists = wp_get_nav_menu_object($menu_name);
     if (!$menu_exists) {
         $menu_id = wp_create_nav_menu($menu_name);
         wp_update_nav_menu_item($menu_id, 0, array('menu-item-title' => __('<i class="fa fa-lock"></i>&nbsp; Login'), 'menu-item-url' => home_url('/?action=login'), 'menu-item-status' => 'publish'));
         wp_update_nav_menu_item($menu_id, 0, array('menu-item-title' => __('<i class="fa fa-pencil-square-o"></i>&nbsp; Register'), 'menu-item-url' => home_url('/?action=register'), 'menu-item-classes' => 'two active', 'menu-item-status' => 'publish'));
         $thememods = 'theme_mods_' . get_option('stylesheet', true);
         $mod = get_option($thememods);
         if (!isset($mod)) {
             $mod = array('nav_menu_locations' => array('top_nav' => $menu_id));
         } else {
             $mod['nav_menu_locations']['top_nav'] = $menu_id;
         }
         add_option($thememods, $mod) || update_option($thememods, $mod);
     }
 }
Beispiel #16
0
 public function __construct($menu_term_slug)
 {
     parent::__construct();
     $menu = wp_get_nav_menu_object($menu_term_slug);
     if (!empty($menu)) {
         $this->menu = $menu;
         $nav_menu_items = wp_get_nav_menu_items($this->menu->term_id);
         cfd_tmp_dbg('nav_menu_items_raw.txt', $nav_menu_items, 'print');
         foreach ($nav_menu_items as $item) {
             $menu_item = wp_setup_nav_menu_item($item);
             $menu_item->metadata = get_metadata('post', $item->ID);
             foreach ($menu_item->metadata as $key => &$value) {
                 $value[0] = maybe_unserialize($value[0]);
             }
             if ($menu_item->type == 'post_type') {
                 $menu_item->parent = get_post($menu_item->metadata['_menu_item_object_id'][0]);
             } elseif ($menu_item->type == 'taxonomy' && (!property_exists($menu, 'object') || $menu->object != 'custom')) {
                 $menu_item->term = get_term($menu_item->metadata['_menu_item_object_id'][0], $menu_item->metadata['_menu_item_object'][0]);
             }
             $this->items[] = $menu_item;
         }
     } else {
         throw new Exception(__('Invalid menu id', 'cf-deploy') . ': ' . esc_attr($menu_term_slug));
     }
 }
function _wpsc_menu_exists($args)
{
    $args = (object) $args;
    // Get the nav menu based on the requested menu
    $menu = wp_get_nav_menu_object($args->menu);
    // Get the nav menu based on the theme_location
    if (!$menu && $args->theme_location && ($locations = get_nav_menu_locations()) && isset($locations[$args->theme_location])) {
        $menu = wp_get_nav_menu_object($locations[$args->theme_location]);
    }
    // get the first menu that has items if we still can't find a menu
    if (!$menu && !$args->theme_location) {
        $menus = wp_get_nav_menus();
        foreach ($menus as $menu_maybe) {
            if ($menu_items = wp_get_nav_menu_items($menu_maybe->term_id)) {
                $menu = $menu_maybe;
                break;
            }
        }
    }
    // If the menu exists, get its items.
    if ($menu && !is_wp_error($menu) && !isset($menu_items)) {
        $menu_items = wp_get_nav_menu_items($menu->term_id);
    }
    // If no menu was found or if the menu has no items and no location was requested, call the fallback_cb if it exists
    if (!$menu || is_wp_error($menu) || isset($menu_items) && empty($menu_items) && !$args->theme_location) {
        return false;
    }
    // If no fallback function was specified and the menu doesn't exists, bail.
    if (!$menu || is_wp_error($menu) || empty($menu_items)) {
        return false;
    }
    return (bool) $menu;
}
 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['offcanvas_nav_menu']) ? wp_get_nav_menu_object($instance['offcanvas_nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/default-widgets.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu, 'echo' => false, 'container' => 'ul', 'menu_class' => 'off-canvas-list');
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      */
     echo str_replace('sub-menu', 'sub-menu left-submenu', wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args)));
     echo $args['after_widget'];
 }
function ubermenu_get_settings_fields()
{
    $prefix = UBERMENU_PREFIX;
    $settings_fields = _UBERMENU()->get_settings_fields();
    if ($settings_fields) {
        return $settings_fields;
    }
    $main_assigned = '';
    if (!has_nav_menu('ubermenu')) {
        $main_assigned = 'No Menu Assigned';
    } else {
        $menus = get_nav_menu_locations();
        $menu_title = wp_get_nav_menu_object($menus['ubermenu'])->name;
        $main_assigned = $menu_title;
    }
    $main_assigned = '<span class="ubermenu-main-assigned">' . $main_assigned . '</span>  <p class="ubermenu-desc-understated">The menu assigned to the <strong>UberMenu [Main]</strong> theme location will be displayed.  <a href="' . admin_url('nav-menus.php?action=locations') . '">Assign a menu</a></p>';
    $config_id = 'main';
    $fields = array($prefix . $config_id => ubermenu_get_settings_fields_instance($config_id));
    $fields = apply_filters('ubermenu_settings_panel_fields', $fields);
    //Allow ordering
    foreach ($fields as $section_id => $section_fields) {
        ksort($fields[$section_id]);
        $fields[$section_id] = array_values($fields[$section_id]);
    }
    _UBERMENU()->set_settings_fields($fields);
    // up( $fields , 2 );
    //up( $fields );
    return $fields;
}
function acp_skiplinks_output()
{
    check_ajax_referer('acp-sec-skiplinks', 'security');
    $hp_skiplinks = get_option('acp_skiplinks_home', false);
    if ($hp_skiplinks) {
        $menu_name = is_home() || is_front_page() ? 'skiplinks-home' : 'skiplinks';
    } else {
        $menu_name = 'skiplinks';
    }
    if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
        $menu = wp_get_nav_menu_object($locations[$menu_name]);
        $menu_items = wp_get_nav_menu_items($menu->term_id);
        $menu_side = get_option('acp_skiplinks_side', false);
        $menu_list = '<ul id="acp_skiplinks" role="navigation" class="' . $menu_side . '">';
        foreach ((array) $menu_items as $key => $menu_item) {
            $title = $menu_item->title;
            $url = $menu_item->url;
            $menu_list .= '<li><a href="' . $url . '" class="skiplinks">' . $title . '</a></li>';
        }
        $menu_list .= '</ul></nav>';
    } else {
        $menu_list = '<ul><li>Menu "' . $menu_name . '" not defined.</li></ul>';
    }
    if (get_option('acp_skiplinks', false)) {
        echo $menu_list;
    }
    die;
}
Beispiel #21
0
  * 
  */
 load_theme_textdomain('szia', get_template_directory() . '/languages');
 // This theme styles the visual editor with editor-style.css to match the theme style.
 add_editor_style();
 // Custom Header
 $defaults = array('default-image' => '', 'random-default' => false, 'width' => 0, 'height' => 0, 'flex-height' => false, 'flex-width' => false, 'default-text-color' => '', 'header-text' => true, 'uploads' => true, 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '');
 add_theme_support('custom-header', $defaults);
 // Adds RSS feed links to <head> for posts and comments.
 add_theme_support('automatic-feed-links');
 // This theme supports a variety of post formats.
 add_theme_support('post-formats', array('gallery', 'image', 'video'));
 // This theme uses wp_nav_menu() in one location.
 register_nav_menu('primary', __('Primary Menu', 'szia'));
 register_nav_menu('secondary', __('Secondary Menu', 'szia'));
 /*
  * This theme supports custom background color and image, and here
  * we also set up the default background color.
  */
 add_theme_support('custom-background', array('default-color' => 'e6e6e6'));
 // This theme uses a custom image size for featured images, displayed on "standard" posts.
 add_theme_support('post-thumbnails');
 //set_post_thumbnail_size( 590, 211 ); // Unlimited height, soft crop
 // Used for large feature (header) images.
 //add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
Beispiel #22
0
function wptouch_save_menu_changes($old_value, $new_value)
{
    if (isset($new_value['nav_menu_locations'])) {
        global $wptouch_pro;
        $menu_map = $new_value['nav_menu_locations'];
        if (is_array($menu_map) && count($menu_map > 0)) {
            foreach ($menu_map as $location => $menu_id) {
                if (strstr($location, 'wptouch_')) {
                    $menu_data = wp_get_nav_menu_object($menu_id);
                    $location = substr($location, 8);
                    global $wptouch_pro;
                    $menu_domain = false;
                    foreach ($wptouch_pro->theme_menus as $menu) {
                        if ($menu->setting_name == $location) {
                            $menu_domain = $menu->settings_domain;
                            continue;
                        }
                    }
                    if ($menu_domain) {
                        $settings = wptouch_get_settings($menu_domain);
                        $settings->{$location} = $menu_id;
                        $settings->save();
                    }
                }
            }
        }
        wptouch_customizer_begin_theme_override();
        set_theme_mod('nav_menu_locations', $menu_map);
        wptouch_customizer_end_theme_override();
    }
}
Beispiel #23
-1
    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget( $args, $instance ) {

        extract( $args );

        if( !isset( $instance['title'] ) )
            $instance['title'] = '';

        $title = apply_filters('widget_title', $instance['title'] );

        $nav_menu = isset( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : '';
        include_once( YIT_THEME_ASSETS_PATH . '/lib/Walker_Nav_Menu_Div.php' );

        $nav_args = array(
            'menu'       => $nav_menu,
            'container'  => 'none',
            'menu_class' => 'level-1 clearfix',
            'depth'      => apply_filters( 'yit_main_nav_depth', 3 ),
            'walker'     => new YIT_Walker_Nav_Menu_Div()
        );

        echo $before_widget;

        if ( ! empty( $title ) ) echo $before_title . $title . $after_title;

        ?><div class="nav"><?php
        wp_nav_menu( $nav_args );
        ?></div><?php

        echo $after_widget;

    }
 function get_start_el()
 {
     //up( $this->settings );
     $menu_segment = $this->getSetting('menu_segment');
     $html = "<!-- begin Segment: {$menu_segment} -->";
     //prevent infinite looping
     if (isset($this->args->menu) && $this->args->menu) {
         if ($this->args->menu == $menu_segment) {
             $html .= '<!-- Prevented infinite loop with segment nesting -->';
             return $html;
         }
     }
     if ($menu_segment == '_none' || !$menu_segment) {
         $html .= '<li>' . ubermenu_admin_notice('Please set a segment for <strong>' . $this->item->title . ' (' . $this->ID . ')</strong>', false) . '</li>';
         return $html .= '<!-- no menu set -->';
     }
     $menu_object = wp_get_nav_menu_object($menu_segment);
     if (!$menu_object) {
         $html .= '<li>' . ubermenu_admin_notice('No menu with ID ' . $menu_segment . ' for menu item: <strong>' . $this->item->title . ' (' . $this->ID . ')</strong>', false) . '</li>';
         return $html . '<!-- no menu with ID "' . $menu_segment . '" -->';
     }
     //Submenus of this item should defer to parent
     if ($this->depth > 0) {
         //If this is top level, we don't need to set
         $this->settings['submenu_type_calc'] = $this->walker->parent_item()->getSetting('submenu_type_calc');
     }
     //Set Depth offset for segment
     $current_depth_offset = $this->walker->get_offset_depth();
     $this->walker->set_offset_depth($this->depth);
     $html .= wp_nav_menu(array('menu' => $menu_segment, 'echo' => false, 'container' => false, 'items_wrap' => '%3$s', 'walker' => $this->walker, 'uber_instance' => $this->args->uber_instance, 'uber_segment' => $this->ID));
     //Reset depth offset
     $this->walker->set_offset_depth($current_depth_offset);
     return $html;
 }
    function widget($args, $instance)
    {
        extract($args);
        // Get menu
        $widget_options = wp_parse_args($instance, $this->defaults);
        extract($widget_options, EXTR_SKIP);
        $nav_menu = wp_get_nav_menu_object($instance['nav_menu']);
        if (!$nav_menu) {
            return;
        }
        $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
        }
        ?>
		<div class="dcjq-vertical-mega-menu" id="<?php 
        echo $this->id . '-item';
        ?>
">
		
		<?php 
        wp_nav_menu(array('fallback_cb' => '', 'menu' => $nav_menu, 'container' => false));
        ?>
		
		</div>
		<?php 
        echo $args['after_widget'];
    }
/**
 * Get menu's data from his id
 * @param  array $data WP REST API data variable
 * @return object Menu's data with his items
 */
function wp_api_v2_menus_get_menu_data($data)
{
    $menu = new stdClass();
    $menu = wp_get_nav_menu_object($data['id']);
    $menu->items = wp_get_nav_menu_items($menu->term_id);
    return $menu;
}
Beispiel #27
-1
 function page_menu($menu_name)
 {
     if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
         $count = 0;
         $menu = wp_get_nav_menu_object($locations[$menu_name]);
         $menu_items = wp_get_nav_menu_items($menu->term_id);
         $menu_list = '<div class="portfolio_blocks">';
         foreach ((array) $menu_items as $key => $menu_item) {
             $count++;
             $menu_list .= '<div class="blocks_block">
                                 <div class="block_content">
                                     <figure class="block_content--image">
                                         ' . get_the_post_thumbnail($menu_item->object_id, 'full') . '
                                     </figure>
                                     <div class="block_content--heading">
                                         <h4 class="block_content--title">' . $menu_item->title . '</h4>
                                     </div>
                                     <a href="' . get_permalink($menu_item->object_id) . '" class="block_content--link"></a>
                                 </div>
                             </div>';
         }
         $menu_list .= '</div>';
     } else {
         $menu_list = '<ul><li>Menu "' . $menu_name . '" not defined.</li></ul>';
     }
     // $menu_list now ready to output
     echo $menu_list;
 }
function ac_activation_setup_menus()
{
    // Create the menu
    $roots_nav_theme_mod = false;
    $primary_nav = wp_get_nav_menu_object('Primary Navigation');
    if (!$primary_nav) {
        $primary_nav_id = wp_create_nav_menu('Primary Navigation', array('slug' => 'primary_navigation'));
        $roots_nav_theme_mod['primary_navigation'] = $primary_nav_id;
    } else {
        $roots_nav_theme_mod['primary_navigation'] = $primary_nav->term_id;
    }
    if ($roots_nav_theme_mod) {
        set_theme_mod('nav_menu_locations', $roots_nav_theme_mod);
    }
    // Add the pages to the menu
    $primary_nav = wp_get_nav_menu_object('Primary Navigation');
    $primary_nav_term_id = (int) $primary_nav->term_id;
    $menu_items = wp_get_nav_menu_items($primary_nav_term_id);
    if (!$menu_items || empty($menu_items)) {
        $pages = get_pages();
        foreach ($pages as $page) {
            $item = array('menu-item-object-id' => $page->ID, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish');
            wp_update_nav_menu_item($primary_nav_term_id, 0, $item);
        }
    }
}
Beispiel #29
-1
 private function setupBaseInfo()
 {
     if (null == $this->current_url) {
         $this->current_url = GantryFactMenu::_curPageURL();
     }
     if (null == $this->menu_items) {
         $this->menu_items = wp_get_nav_menu_items(wp_get_nav_menu_object($this->type));
     }
     if (null == $this->fact_menu_item) {
         foreach ($this->menu_items as $item) {
             if ($item->ID == $this->id) {
                 $this->fact_menu_item = $item;
                 break;
             }
         }
     }
     if (null == $this->children) {
         $this->children = array();
         $list = array();
         foreach ($this->menu_items as $item) {
             $thisref =& $this->children[$item->ID];
             $thisref['parent_id'] = $item->menu_item_parent;
             if ($item->menu_item_parent == 0) {
                 $list[$item->ID] =& $thisref;
             } else {
                 $this->children[$item->menu_item_parent]['children'][] = $item->ID;
             }
         }
     }
 }
Beispiel #30
-1
function seattlemennonite_section()
{
    $locations = get_nav_menu_locations();
    if (isset($locations['primary'])) {
        $menu = wp_get_nav_menu_object($locations['primary']);
        // Get an array of menu items.
        $menu_items = wp_get_nav_menu_items($menu->term_id);
        _wp_menu_item_classes_by_context($menu_items);
        // These classes indicate that this is the current menu item.
        $current_classes = array('current-menu-ancestor', 'current-menu-item', 'current-post-ancestor');
        // Create an array that maps the id of the menu item to
        // the item object.
        $map = array();
        foreach ((array) $menu_items as $key => $menu_item) {
            $map[$menu_item->db_id] = $menu_item;
        }
        unset($menu_items);
        // Loop through the menu items looking for the current one.
        foreach ($map as $key => $menu_item) {
            if (array_intersect($current_classes, $menu_item->classes)) {
                return seattlemennonite_get_section($map, $menu_item);
            }
        }
    }
}