当前位置: 首页>>代码示例>>PHP>>正文


PHP _wp_menu_item_classes_by_context函数代码示例

本文整理汇总了PHP中_wp_menu_item_classes_by_context函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_menu_item_classes_by_context函数的具体用法?PHP _wp_menu_item_classes_by_context怎么用?PHP _wp_menu_item_classes_by_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_wp_menu_item_classes_by_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: detect_mob_child

function detect_mob_child($parent, $echo = false)
{
    $parent = $parent != "" ? $parent : '0';
    $locations = get_nav_menu_locations();
    $menu = wp_get_nav_menu_object($locations['primary']);
    $menu_items = wp_get_nav_menu_items($menu->term_id);
    _wp_menu_item_classes_by_context($menu_items);
    $menu_next = array();
    foreach ((array) $menu_items as $key => $menu_item) {
        if ($menu_item->menu_item_parent == $parent) {
            $menu_next[(int) $menu_item->db_id] = $menu_item;
        }
    }
    unset($menu_items);
    if (!$echo) {
        if (!empty($menu_next)) {
            return true;
        } else {
            return false;
        }
    } else {
        $child_ul = '' . "\n";
        $ret = '';
        foreach ($menu_next as $i => $mnn) {
            //Specific additions add custom icons
            if ('page' == $mnn->object) {
                $post_finder = get_post($mnn->object_id);
                $page_slug = $post_finder->post_name;
                $newlink = strtolower(preg_replace('/[^a-zA-Z]/s', '', $page_slug));
                $href = '#' . $newlink;
                $incl_onepage = get_post_meta($mnn->object_id, 'one_page', true);
                if ($incl_onepage == 1) {
                    $href = '#' . $newlink;
                    $identifyClass = "is_mob_onepage";
                } else {
                    $href = $mnn->url;
                    $identifyClass = "not_mob_onepage";
                }
            } else {
                $href = $mnn->url;
                $identifyClass = "not_mob_onepage";
            }
            if (is_single() or is_page() or is_archive()) {
                $ret .= '<a class="' . $identifyClass . ' scroll-link" href="' . $href . '" data-soffset="0"> &nbsp;&nbsp;-' . $mnn->title . '</a>';
            } else {
                //$return .= '<option class="'.$identifyClass.'" value="'. $href .'" onClick="'.$onchange_live.'">'. $men->title .'</option>';
                $ret .= '<a class="' . $identifyClass . ' scroll-link" href="' . $href . '" data-soffset="0"> &nbsp;&nbsp;-' . $mnn->title . '</a>';
            }
            //$ret .= '<li><a class="'.$identifyClass .'" href="'.$href.'">'.$mnn->title.'</a></li>' . "\n";
        }
        unset($menu_next);
        $child_ul_close = '' . "\n";
        if (!empty($ret)) {
            return $ret;
        }
    }
}
开发者ID:solsticehc,项目名称:citadel,代码行数:57,代码来源:mobile-menu.php

示例2: get_menu_items

function get_menu_items($theme_location)
{
    $menu = get_menu($theme_location);
    $menu_items = array();
    if ($menu) {
        $menu_items = wp_get_nav_menu_items($menu->term_id, array('update_post_term_cache' => false));
        _wp_menu_item_classes_by_context($menu_items);
    }
    return $menu_items;
}
开发者ID:romanmz,项目名称:nav-menu-tools,代码行数:10,代码来源:nav-menu-tools.php

示例3: wordpress_boilerplate_find_menu_root

function wordpress_boilerplate_find_menu_root($location, $selector, $directParent = false)
{
    $locations = get_nav_menu_locations();
    $menu = wp_get_nav_menu_object($locations[$location]);
    $menuItems = wp_get_nav_menu_items($menu->term_id, array('order' => 'DESC', 'update_post_term_cache' => false));
    _wp_menu_item_classes_by_context($menuItems);
    $sorted_menu_items = array();
    foreach ((array) $menuItems as $menuItem) {
        $sorted_menu_items[$menuItem->menu_order] = $menuItem;
    }
    unset($menuItems);
    $sorted_menu_items = apply_filters('wp_nav_menu_objects', $sorted_menu_items, null);
    return wordpress_boilerplate_find_menu_root_from_items($sorted_menu_items, $selector, $directParent);
}
开发者ID:dotsunited,项目名称:wordpress-boilerplate,代码行数:14,代码来源:menu.php

示例4: init

 /**
  * @param int $menu_id
  */
 private function init($menu_id)
 {
     $menu = wp_get_nav_menu_items($menu_id);
     _wp_menu_item_classes_by_context($menu);
     if (is_array($menu)) {
         $menu = self::order_children($menu);
     }
     $this->items = $menu;
     $menu_info = wp_get_nav_menu_object($menu_id);
     $this->import($menu_info);
     $this->ID = $this->term_id;
     $this->id = $this->term_id;
     $this->title = $this->name;
 }
开发者ID:alexaldama,项目名称:timber,代码行数:17,代码来源:timber-menu.php

示例5: init_as_page_menu

 private function init_as_page_menu()
 {
     $menu = get_pages();
     if ($menu) {
         foreach ($menu as $mi) {
             $mi->__title = $mi->post_title;
         }
         _wp_menu_item_classes_by_context($menu);
         if (is_array($menu)) {
             $menu = self::order_children($menu);
         }
         $this->items = $menu;
     }
 }
开发者ID:wpmu,项目名称:maera,代码行数:14,代码来源:timber-menu.php

示例6: order_children

 function order_children($items)
 {
     $index = array();
     $menu = array();
     _wp_menu_item_classes_by_context($items);
     foreach ($items as $item) {
         $index[$item->ID] = new TimberMenuItem($item);
     }
     foreach ($index as $item) {
         if ($item->menu_item_parent && isset($index[$item->menu_item_parent])) {
             $index[$item->menu_item_parent]->add_child($item);
         } else {
             $menu[] = $item;
         }
     }
     return $menu;
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:17,代码来源:timber-menu.php

示例7: wp_nav_menu

function wp_nav_menu($args = array())
{
    static $menu_id_slugs = array();
    $defaults = array('menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'depth' => 0, 'walker' => '', 'theme_location' => '');
    $args = wp_parse_args($args, $defaults);
    $args = apply_filters('wp_nav_menu_args', $args);
    $args = (object) $args;
    $nav_menu = apply_filters('pre_wp_nav_menu', null, $args);
    // $nav_menu = null;
    if (null !== $nav_menu) {
        if ($args->echo) {
            echo $nav_menu;
            return;
        }
        return $nav_menu;
    }
    // Get the nav menu based on the requested menu
    // $menu = wp_get_nav_menu_object( $args->menu );
    $menu = wp_get_nav_menu_object($args->menu_id);
    // 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 ] );
    if (!$menu && $args->theme_location) {
        $menu = wp_get_nav_menu_object($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, array('update_post_term_cache' => false))) {
                $menu = $menu_maybe;
                break;
            }
        }
    }
    if (empty($args->menu)) {
        $args->menu = $menu;
    }
    // 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, array('update_post_term_cache' => false));
    }
    $nav_menu = $items = '';
    // $show_container = false;
    // if ( $args->container ) {
    // 	$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
    // 	if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags ) ) {
    // 		$show_container = true;
    // 		$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
    // 		$id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
    // 		$nav_menu .= '<'. $args->container . $id . $class . '>';
    // 	}
    // }
    // Set up the $menu_item variables
    _wp_menu_item_classes_by_context($menu_items);
    $sorted_menu_items = $menu_items_with_children = array();
    foreach ((array) $menu_items as $menu_item) {
        $sorted_menu_items[$menu_item->menu_order] = $menu_item;
        if ($menu_item->menu_item_parent) {
            $menu_items_with_children[$menu_item->menu_item_parent] = true;
        }
    }
    // Add the menu-item-has-children class where applicable
    if ($menu_items_with_children) {
        foreach ($sorted_menu_items as &$menu_item) {
            if (isset($menu_items_with_children[$menu_item->ID])) {
                $menu_item->classes[] = 'menu-item-has-children';
            }
        }
    }
    unset($menu_items, $menu_item);
    $sorted_menu_items = apply_filters('wp_nav_menu_objects', $sorted_menu_items, $args);
    $items .= walk_nav_menu_tree($sorted_menu_items, $args->depth, $args);
    unset($sorted_menu_items);
    // Attributes
    if (!empty($args->menu_id)) {
        $wrap_id = $args->menu_id;
    } else {
        $wrap_id = 'menu-' . $menu->slug;
        while (in_array($wrap_id, $menu_id_slugs)) {
            if (preg_match('#-(\\d+)$#', $wrap_id, $matches)) {
                $wrap_id = preg_replace('#-(\\d+)$#', '-' . ++$matches[1], $wrap_id);
            } else {
                $wrap_id = $wrap_id . '-1';
            }
        }
    }
    $menu_id_slugs[] = $wrap_id;
    $wrap_class = $args->menu_class ? $args->menu_class : '';
    $items = apply_filters('wp_nav_menu_items', $items, $args);
    $items = apply_filters("wp_nav_menu_{$menu->slug}_items", $items, $args);
    // Don't print any markup if there are no items at this point.
    if (empty($items)) {
        return false;
    }
    $nav_menu .= sprintf($args->items_wrap, esc_attr($wrap_id), esc_attr($wrap_class), $items);
    unset($items);
    if ($show_container) {
        $nav_menu .= '</' . $args->container . '>';
    }
//.........这里部分代码省略.........
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:101,代码来源:nav-menu-template.php

示例8: test_class_not_applied_to_taxonomies_with_same_id_as_front_page_item

 /**
  * @ticket 35272
  */
 function test_class_not_applied_to_taxonomies_with_same_id_as_front_page_item()
 {
     global $wpdb;
     $new_id = 35272;
     $page_id = self::factory()->post->create(array('post_type' => 'page', 'post_title' => 'Home Page'));
     $tag_id = self::factory()->tag->create();
     $wpdb->query("UPDATE {$wpdb->posts} SET ID={$new_id} WHERE ID={$page_id}");
     $wpdb->query("UPDATE {$wpdb->terms} SET term_id={$new_id} WHERE term_id={$tag_id}");
     $wpdb->query("UPDATE {$wpdb->term_taxonomy} SET term_id={$new_id} WHERE term_id={$tag_id}");
     update_option('page_on_front', $new_id);
     wp_update_nav_menu_item($this->menu_id, 0, array('menu-item-type' => 'taxonomy', 'menu-item-object' => 'post_tag', 'menu-item-object-id' => $new_id, 'menu-item-status' => 'publish'));
     $menu_items = wp_get_nav_menu_items($this->menu_id);
     _wp_menu_item_classes_by_context($menu_items);
     $classes = $menu_items[0]->classes;
     $this->assertNotContains('menu-item-home', $classes);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:19,代码来源:nav-menu.php

示例9: members_menu

/**
 * Allows the Main Menu to combine with the Members Menu only when the users are logged in.
 *
 */
function members_menu($sorted_menu_items)
{
    if (is_user_logged_in()) {
        $members_items = wp_get_nav_menu_items('Members Menu');
        _wp_menu_item_classes_by_context($members_items);
        foreach ($members_items as $item) {
            $sorted_menu_items[] = $item;
        }
    }
    return $sorted_menu_items;
}
开发者ID:ChadLefort,项目名称:my-government-online-wiki,代码行数:15,代码来源:functions.php

示例10: get_breadcrumbs_arr

 /**
  * Return the breadcrumbs array
  * based on a given menu
  *
  * @param string $theme_location
  * @param array  $options
  *
  * @return array|bool
  */
 public static function get_breadcrumbs_arr($theme_location = 'primary', $options = array())
 {
     $locations = get_nav_menu_locations();
     if (!isset($locations[$theme_location])) {
         return false;
     }
     $options = wp_parse_args($options, array('home_title' => __('Home')));
     $menu = wp_get_nav_menu_object($locations[$theme_location]);
     $items = wp_get_nav_menu_items($menu->term_id);
     if (empty($items)) {
         return array();
     }
     // Set up the class variables, including current-classes
     _wp_menu_item_classes_by_context($items);
     $crumbs = array();
     $current_exists = false;
     foreach ($items as $item) {
         if ($item->current_item_parent || $item->current_item_ancestor || $item->current) {
             $crumbs[] = self::get_breadcrumb_arr($item->url, $item->title, array('current' => $item->current, 'parent' => $item->current_item_parent, 'ancestor' => $item->current_item_ancestor));
             if ($item->current) {
                 $current_exists = true;
             }
         }
     }
     if (empty($crumbs)) {
         return array();
     }
     if (!$current_exists) {
         array_push($crumbs, self::get_breadcrumb_arr(get_permalink(), get_the_title(), array('current' => true)));
     }
     if (!is_front_page()) {
         array_unshift($crumbs, self::get_breadcrumb_arr(home_url(), $options['home_title'], array('home_link' => true)));
     }
     return $crumbs;
 }
开发者ID:tylershuster,项目名称:pilgrim-church,代码行数:44,代码来源:class-breadcrumbs.php

示例11: init_as_page_menu

 /**
  * @internal
  */
 protected function init_as_page_menu()
 {
     $menu = get_pages(array('sort_column' => 'menu_order'));
     if ($menu) {
         foreach ($menu as $mi) {
             $mi->__title = $mi->post_title;
         }
         _wp_menu_item_classes_by_context($menu);
         if (is_array($menu)) {
             $menu = self::order_children($menu);
         }
         $this->items = $menu;
     }
 }
开发者ID:jarednova,项目名称:timber,代码行数:17,代码来源:Menu.php

示例12: menu

 /**
  * @method menu
  * @staticvar array $menu_id_slugs
  *
  * @param     {Array} $args
  *
  * @return boolean
  */
 public static function menu($args = array())
 {
     static $menu_id_slugs = array();
     $defaults = array('menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'depth' => 0, 'walker' => '', 'theme_location' => '');
     $args = wp_parse_args($args, $defaults);
     $args = apply_filters('wp_nav_menu_args', $args);
     $args = (object) $args;
     // Get the nav menu based on the requested menu
     // move get menu part to self::get_nav_menu_object function
     // to manage cache
     $menu = self::get_nav_menu_object($args);
     // If the menu exists, get its items.
     if ($menu && !is_wp_error($menu) && !isset($menu_items)) {
         $menu_items = self::get_nav_menu_items($menu->term_id, array('update_post_term_cache' => false));
     }
     /*
      * If no menu was found:
      *  - Fall back (if one was specified), or bail.
      *
      * If no menu items were found:
      *  - Fall back, but only if no theme location was specified.
      *  - Otherwise, bail.
      */
     if ((!$menu || is_wp_error($menu) || isset($menu_items) && empty($menu_items) && !$args->theme_location) && $args->fallback_cb && is_callable($args->fallback_cb)) {
         return call_user_func($args->fallback_cb, (array) $args);
     }
     if (!$menu || is_wp_error($menu)) {
         return false;
     }
     $nav_menu = $items = '';
     $show_container = false;
     if ($args->container) {
         $allowed_tags = apply_filters('wp_nav_menu_container_allowedtags', array('div', 'nav'));
         if (in_array($args->container, $allowed_tags)) {
             $show_container = true;
             $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ' class="menu-' . $menu->slug . '-container"';
             $id = $args->container_id ? ' id="' . esc_attr($args->container_id) . '"' : '';
             $nav_menu .= '<' . $args->container . $id . $class . '>';
         }
     }
     // Set up the $menu_item variables
     _wp_menu_item_classes_by_context($menu_items);
     $sorted_menu_items = $menu_items_with_children = array();
     foreach ((array) $menu_items as $key => $menu_item) {
         $sorted_menu_items[$menu_item->menu_order] = $menu_item;
         if ($menu_item->menu_item_parent) {
             $menu_items_with_children[$menu_item->menu_item_parent] = true;
         }
     }
     // Add the menu-item-has-children class where applicable
     if (!empty($menu_items_with_children)) {
         foreach ($sorted_menu_items as &$menu_item) {
             if (isset($menu_items_with_children[$menu_item->ID])) {
                 $menu_item->classes[] = 'menu-item-has-children';
             }
         }
     }
     unset($menu_items);
     $sorted_menu_items = apply_filters('wp_nav_menu_objects', $sorted_menu_items, $args);
     $items .= walk_nav_menu_tree($sorted_menu_items, $args->depth, $args);
     unset($sorted_menu_items);
     // Attributes
     if (!empty($args->menu_id)) {
         $wrap_id = $args->menu_id;
     } else {
         $wrap_id = 'menu-' . $menu->slug;
         while (in_array($wrap_id, $menu_id_slugs)) {
             if (preg_match('#-(\\d+)$#', $wrap_id, $matches)) {
                 $wrap_id = preg_replace('#-(\\d+)$#', '-' . ++$matches[1], $wrap_id);
             } else {
                 $wrap_id = $wrap_id . '-1';
             }
         }
     }
     $menu_id_slugs[] = $wrap_id;
     $wrap_class = $args->menu_class ? $args->menu_class : '';
     // Allow plugins to hook into the menu to add their own <li>'s
     $items = apply_filters('wp_nav_menu_items', $items, $args);
     $items = apply_filters("wp_nav_menu_{$menu->slug}_items", $items, $args);
     // Don't print any markup if there are no items at this point.
     if (empty($items)) {
         return false;
     }
     $nav_menu .= sprintf($args->items_wrap, esc_attr($wrap_id), esc_attr($wrap_class), $items);
     unset($items);
     if ($show_container) {
         $nav_menu .= '</' . $args->container . '>';
     }
     $nav_menu = apply_filters('wp_nav_menu', $nav_menu, $args);
     if ($args->echo) {
         echo $nav_menu;
     } else {
//.........这里部分代码省略.........
开发者ID:voceconnect,项目名称:voce-cached-nav,代码行数:101,代码来源:voce-cached-nav.php

示例13: _render_menu_items

 protected function _render_menu_items($menu_items)
 {
     if (empty($menu_items)) {
         return '';
     }
     _wp_menu_item_classes_by_context($menu_items);
     $children = array();
     foreach ($menu_items as $item) {
         $pt = $item->menu_item_parent;
         $list = isset($children[$pt]) && !empty($children[$pt]) ? $children[$pt] : array();
         array_push($list, $item);
         $children[$pt] = $list;
     }
     $lists = $this->menu_treerecurse(0, array(), $children);
     foreach ($lists as $item) {
         $item->title = esc_html($item->title);
         $item->level = $item->level + 1;
         $key = 'item-' . $item->ID;
         $setting = isset($this->settings[$key]) ? $this->settings[$key] : array();
         // decode html tag
         if (isset($setting['caption']) && $setting['caption']) {
             $setting['caption'] = str_replace(array('[lt]', '[gt]'), array('<', '>'), $setting['caption']);
         }
         if ($item->level == 1 && isset($setting['caption']) && $setting['caption']) {
             $this->top_level_caption = true;
         }
         $item->class = '';
         $item->mega = 0;
         $item->group = 0;
         $item->dropdown = 0;
         //$item->target = '';
         if (isset($setting['group'])) {
             $item->group = 1;
         } else {
             if ($this->front_end) {
                 if ($item->children && !isset($setting['hidesub']) || isset($setting['sub'])) {
                     $item->dropdown = 1;
                 }
             } else {
                 if ($item->children || isset($setting['sub'])) {
                     $item->dropdown = 1;
                 }
             }
         }
         $item->mega = $item->group || $item->dropdown;
         if ($item->mega) {
             if (!isset($setting['sub'])) {
                 $setting['sub'] = array();
             }
             if ($item->children && (!isset($setting['sub']['rows']) || !count($setting['sub']['rows']))) {
                 $c = $item->frist_children->ID;
                 $setting['sub'] = array('rows' => array(array(array('width' => 12, 'item' => $c))));
             }
         }
         $item->setting = $setting;
         $item->url = esc_url($item->url);
         $parent = isset($this->children[$item->menu_item_parent]) ? $this->children[$item->menu_item_parent] : array();
         $parent[] = $item;
         $this->children[$item->menu_item_parent] = $parent;
         $this->items[$item->ID] = $item;
     }
 }
开发者ID:devmoonshine,项目名称:development,代码行数:62,代码来源:megamenu-base-front.php

示例14: insert_language_objects_in_nav_menu

 /**
  * insert languages list objects in nav menu at insertion point (filter wp_nav_menu_objects)
  *
  * @since 2.8.8
  * @updated 2.9.11 (page) , 2.9.20 (menu)
  * @updated 2.10.1 - singular if exists
  * @updated 2.11.2 - better class assignation (ancestor) - thanks to Bastian
  * @updated 2.12.2 - compatible
  *
  */
 function insert_language_objects_in_nav_menu($sorted_menu_items, $args)
 {
     global $post, $wp_query;
     // detect insertion point menu object and menu type
     $new_sorted_menu_items = array();
     foreach ($sorted_menu_items as $key => $menu_object) {
         if ($menu_object->url == $this->insertion_point_dummy_link_menu) {
             // #insertmenu
             $queried_object = $wp_query->get_queried_object();
             $queried_object_id = (int) $wp_query->queried_object_id;
             if (false !== strpos($menu_object->attr_title, 'menu-wo-')) {
                 $langkey = explode('-', str_replace('menu-wo-', '', $menu_object->attr_title));
                 // approach < 2.14.2
             } else {
                 $langkey_ids = explode('-', str_replace('menu-wlid-', '', $menu_object->attr_title));
                 $langkey = array();
                 $id_slug = array_flip($this->langs_ids_array);
                 foreach ($langkey_ids as $lang_id) {
                     $langkey[] = $id_slug[$lang_id];
                 }
             }
             $menu_id_list = '';
             $menu_slug_list = '';
             foreach ($menu_object->classes as $one_class) {
                 if (false !== strpos($one_class, 'xlmenulist-')) {
                     $menu_id_list = str_replace('xlmenulist-', '', $one_class);
                     continue;
                 } else {
                     if (false !== strpos($one_class, 'xlmenuslug')) {
                         // to be compatible with export xml
                         $menu_slug_list = str_replace('xlmenuslug' . $this->menu_slug_sep, '', $one_class);
                         // -- seems better than _
                         continue;
                     }
                 }
             }
             if ($menu_id_list) {
                 $menu_ids = explode('-', $menu_id_list);
                 // here saved as term_id (container of menu items) (<2.12.2)
             } else {
                 if ($menu_slug_list) {
                     $menu_slugs = explode($this->menu_slug_sep, $menu_slug_list);
                     foreach ($menu_slugs as $one_slug) {
                         $term_data = term_exists($one_slug, 'nav_menu');
                         $menu_ids[] = is_array($term_data) ? $term_data['term_id'] : 0;
                     }
                 }
             }
             $menu_list = count($langkey) == count($menu_ids) ? array_combine($langkey, $menu_ids) : array();
             // pb in count
             $curlang = the_curlang();
             if (isset($menu_list[$curlang])) {
                 $menu_structure_exists = term_exists((int) $menu_list[$curlang], 'nav_menu') ? true : false;
             } else {
                 $menu_structure_exists = false;
             }
             if ($curlang && $menu_structure_exists) {
                 $menu_items = wp_get_nav_menu_items($menu_list[$curlang]);
                 // need term_id of structure
                 _wp_menu_item_classes_by_context($menu_items);
                 // added 2.11.2
                 if ($menu_items) {
                     // added in 1.8 to sort inserted menu content and to insert class 'menu-item-has-children' as in nav-menu-template.php
                     $sorted_menu_items = $menu_items_with_children = array();
                     foreach ((array) $menu_items as $menu_item) {
                         $sorted_menu_items[$menu_item->menu_order] = $menu_item;
                         if ($menu_item->menu_item_parent) {
                             $menu_items_with_children[$menu_item->menu_item_parent] = true;
                         }
                     }
                     // Add the menu-item-has-children class where applicable
                     if ($menu_items_with_children) {
                         foreach ($sorted_menu_items as &$menu_item) {
                             if (isset($menu_items_with_children[$menu_item->ID])) {
                                 $menu_item->classes[] = 'menu-item-has-children';
                             }
                         }
                     }
                     unset($menu_items, $menu_item);
                     foreach ($sorted_menu_items as $new_menu_item) {
                         // not recursive : impossible to decode insertion point inside menu
                         if (!in_array($new_menu_item->url, array($this->insertion_point_dummy_link_menu, $this->insertion_point_dummy_link_page, $this->insertion_point_dummy_link))) {
                             $new_classes = array("insertion-point");
                             if ($new_menu_item->menu_item_parent == 0) {
                                 $new_menu_item->menu_item_parent = $menu_object->menu_item_parent;
                             }
                             // heritate from insertion point
                             $new_menu_item->classes = array_merge($menu_object->classes, $new_classes, $new_menu_item->classes);
                             // fixed 2.11.2
                             $new_sorted_menu_items[] = $new_menu_item;
//.........这里部分代码省略.........
开发者ID:ergov2015,项目名称:rideflag.dev,代码行数:101,代码来源:xili-language.php

示例15: get_site_url

		<div class="rockharbor-logo">
			<a href="<?php 
echo get_site_url();
?>
">
				<?php 
echo $theme->Html->image('logo_1.png', array('alt' => 'ROCKHARBOR', 'parent' => false));
?>
			</a>
        </div>

		<nav id="access" role="navigation" class="clearfix">
			<?php 
$menu_items = wp_get_nav_menu_items($locations['main'], array('auto_show_children' => true));
_wp_menu_item_classes_by_context($menu_items);
$menu = array();
$ids = array();
foreach ($menu_items as $key => $menu_item) {
    $a = $theme->Html->tag('a', $menu_item->title, array('href' => $menu_item->url));
    $opts = array('class' => implode(' ', $menu_item->classes));
    if ($menu_item->menu_item_parent == 0) {
        // top level
        $menu[] = array('a' => $a, 'opts' => $opts, 'children' => array());
        $ids[$menu_item->ID] = count($menu) - 1;
    } else {
        // child
        $menu[$ids[$menu_item->menu_item_parent]]['children'][] = $theme->Html->tag('li', $a, $opts);
    }
}
$output = '';
开发者ID:spiff888,项目名称:rockharbor,代码行数:30,代码来源:header.php


注:本文中的_wp_menu_item_classes_by_context函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。