BP_Messages_Component:: setup_nav (数组main_nav美元数组(),数组sub_nav美元数组()

为用户页面设置导航。

描述

参数

main_nav美元

数组(可选)看到{BP_Component: setup_nav ()详情}。

默认值:数组()

sub_nav美元

数组(可选)看到{BP_Component: setup_nav ()详情}。

默认值:数组()

文件:bp-messages /类/ class-bp-messages-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{返回;} $access = bp_core_can_edit_settings();$蛞蝓= bp_get_messages_slug ();$messages_link = trailingslashit($user_domain。美元的蛞蝓);//只有当我们在用户页面上并且当前用户有访问权限时才会抓取计数。If (bp_is_user() && bp_user_has_access()) {$count = bp_get_total_unread_messages_count(bp_displayed_user_id()); $class = ( 0 === $count ) ? 'no-count' : 'count'; $nav_name = sprintf( /* translators: %s: Unread message count for the current user */ __( 'Messages %s', 'buddyboss' ), sprintf( '%s', esc_attr( $class ), bp_core_number_format( $count ) ) ); } else { $nav_name = __( 'Messages', 'buddyboss' ); } // Add 'Messages' to the main navigation. $main_nav = array( 'name' => $nav_name, 'slug' => $slug, 'position' => 50, 'show_for_displayed_user' => $access, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $this->id ); // Add the subnav items to the profile. $sub_nav[] = array( 'name' => __( 'Messages', 'buddyboss' ), 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => $access ); // Show certain screens only if the current user is the displayed user. if ( bp_is_my_profile() ) { // Show "Compose" on the logged-in user's profile only. $sub_nav[] = array( 'name' => __( 'New Message', 'buddyboss' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => $access ); /* * Show "Notices" on the logged-in user's profile only * and then only if the user can create notices. */ if ( bp_current_user_can( 'bp_moderate' ) ) { $sub_nav[] = array( 'name' => __( 'Notices', 'buddyboss' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => true ); } } parent::setup_nav( $main_nav, $sub_nav ); }

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档,联络支持,或与我们联系销售团队