BP_Notifications_Component:: setup_nav (数组main_nav美元=数组(),数组sub_nav美元=数组())
设置组件导航。
描述
另请参阅
- BP_Component: setup_nav ():用于说明论点。
参数
- main_nav美元
-
(数组)(可选)看到BP_Component: setup_nav ()为描述。
默认值:数组()
- sub_nav美元
-
(数组)(可选)看到BP_Component: setup_nav ()为描述。
默认值:数组()
源
文件:bp-notifications /类/ class-bp-notifications-component.php
public function setup_nav($main_nav = array(), $sub_nav = array()){//确定用户使用。If (bp_displayed_user_domain()) {$user_domain = bp_displayed_user_domain();} elseif (bp_loggedin_user_domain()) {$user_domain = bp_loggedin_user_domain();} else {return;} $access = bp_core_can_edit_settings();$蛞蝓= bp_get_notifications_slug ();$notifications_link = trailingslashit($user_domain。美元的蛞蝓);//只抓取计数,如果我们在用户页面,当前用户有访问。If (bp_is_user() && bp_user_has_access()) {$count = bp_notifications_get_unread_notification_count(bp_displayed_user_id()); $class = ( 0 === $count ) ? 'no-count' : 'count'; $nav_name = sprintf( /* translators: %s: Unread notification count for the current user */ __( 'Notifications %s', 'buddyboss' ), sprintf( '%s', esc_attr( $class ), bp_core_number_format( $count ) ) ); } else { $nav_name = __( 'Notifications', 'buddyboss' ); } // Add 'Notifications' to the main navigation. $main_nav = array( 'name' => $nav_name, 'slug' => $slug, 'position' => 30, 'show_for_displayed_user' => $access, 'screen_function' => 'bp_notifications_screen_unread', 'default_subnav_slug' => 'unread', 'item_css_id' => $this->id, ); // Add the subnav items to the notifications nav item. $sub_nav[] = array( 'name' => __( 'Unread', 'buddyboss' ), 'slug' => 'unread', 'parent_url' => $notifications_link, 'parent_slug' => $slug, 'screen_function' => 'bp_notifications_screen_unread', 'position' => 10, 'item_css_id' => 'notifications-my-notifications', 'user_has_access' => $access, ); $sub_nav[] = array( 'name' => __( 'Read', 'buddyboss' ), 'slug' => 'read', 'parent_url' => $notifications_link, 'parent_slug' => $slug, 'screen_function' => 'bp_notifications_screen_read', 'position' => 20, 'user_has_access' => $access, ); parent::setup_nav( $main_nav, $sub_nav ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.9.0 | 介绍了。 |