bp_get_nav_menu_items (字符串美元的组件=“成员”)
在主要和次要BuddyPress导航菜单中注册项目。
描述
参数
- 美元的组件
-
(字符串)(可选)正在获取其导航项的组件。
默认值:“成员”
返回
(数组)包含所有导航项的多维数组。
源
文件:bp-core / bp-core-template.php
函数bp_get_nav_menu_items($component = 'members') {$bp = buddypress();$ =菜单数组();如果(!Isset ($bp->{$component}->nav)){返回$菜单;} //获取项目导航并构建菜单。foreach ($bp->{$component}->nav->get_item_nav() as $nav_menu){//获取正确的菜单链接。见https://buddypress.trac.wordpress.org/ticket/4624。$link = bp_loggedin_user_domain() ?Str_replace (bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav_menu->link): trailingslashit(bp_displayed_user_domain() . Str_replace (bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav_menu->link):美元nav_menu - >链接); // Add this menu. $menu = new stdClass; $menu->class = array( 'menu-parent' ); $menu->css_id = $nav_menu->css_id; $menu->link = $link; $menu->name = $nav_menu->name; $menu->parent = 0; if ( ! empty( $nav_menu->children ) ) { $submenus = array(); foreach( $nav_menu->children as $sub_menu ) { $submenu = new stdClass; $submenu->class = array( 'menu-child' ); $submenu->css_id = $sub_menu->css_id; $submenu->link = $sub_menu->link; $submenu->name = $sub_menu->name; $submenu->parent = $nav_menu->slug; // If we're viewing this item's screen, record that we need to mark its parent menu to be selected. if ( bp_is_current_action( $sub_menu->slug ) && bp_is_current_component( $nav_menu->slug ) ) { $menu->class[] = 'current-menu-parent'; $submenu->class[] = 'current-menu-item'; } $submenus[] = $submenu; } } $menus[] = $menu; if ( ! empty( $submenus ) ) { $menus = array_merge( $menus, $submenus ); } } /** * Filters the items registered in the primary and secondary BuddyPress navigation menus. * * @since BuddyPress 1.7.0 * * @param array $menus Array of items registered in the primary and secondary BuddyPress navigation. */ return apply_filters( 'bp_get_nav_menu_items', $menus ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.7.0 | 介绍了。 |