bp_core_register_nav_screen_function (数组|字符串$ args.=''的)

注册主导航阵列中的项目的屏幕函数。

描述

参数

$ args.

数组|字符串的)(可选的)描述新导航项目的数组。

  • “名字”
    (细绳)导航项目的显示名称。
  • 'slug'
    (细绳)导航项目的唯一URL SLUS。
  • 'item_css_id'
    (布尔|字符串)可选的。'id'属性为导航项。默认值:美元蛞蝓
  • “show_for_displayed_user”
    (BOOL)可选的。查看除了您自己以外的成员配置文件时是否应可见。默认值:true。
  • 'site_admin_only'
    (BOOL)可选的。NAV项目是否应仅对网站管理员(BP_Moderate'章)有关。默认值:false。
  • '位置'
    (int)可选的。数字索引指定项目应在导航阵列中出现的位置。默认值:99。
  • 'screen_function'
    (可调用)单击导航项时将运行的回调函数。
  • “default_subnav_slug”
    (布尔|字符串)可选的。单击默认子Nav项目的SLUP以选择“导航项目”。

默认值: ''

返回

(false | null)返回错误的故障。

文件:BP-Core / BP-Core-BuddyBar.php

函数bp_core_register_nav_screen_function($args = ") {$bp = buddypress();$defaults = array('name' => false, //显示nav项的名称。'slug' => false, // nav项目的URL slug。'item_css_id' => false, //应用到导航项的HTML的CSS ID。'show_for_displayed_user' => true, //当查看另一个用户时,这个导航项显示吗?'site_admin_only' => false, //只有站点管理员才能看到这个导航项吗?'position' => 99, //该导航项应该定位的索引。'screen_function' => false, //单击时要运行的函数的名称。'default_subnav_slug' => false //默认subnav项目点击时选择的slug。);$r = wp_parse_args($args, $defaults); // If we don't have the required info we need, don't register this screen function. if ( empty( $r['slug'] ) ) { return false; } /** * If this is for site admins only and the user is not one, * don't register this screen function. */ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) { return false; } /** * If this nav item is hidden for the displayed user, and * the logged in user is not the displayed user * looking at their own profile, don't don't register this screen function. */ if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) { return false; } /** * If the nav item is visible, we are not viewing a user, and this is a root * component, don't attach the default subnav function so we can display a * directory or something else. */ if ( ( -1 != $r['position'] ) && bp_is_root_component( $r['slug'] ) && ! bp_displayed_user_id() ) { return; } // Look for current component. if ( bp_is_current_component( $r['slug'] ) || bp_is_current_item( $r['slug'] ) ) { // The requested URL has explicitly included the default subnav // (eg: http://example.com/members/membername/activity/just-me/) // The canonical version will not contain this subnav slug. if ( ! empty( $r['default_subnav_slug'] ) && bp_is_current_action( $r['default_subnav_slug'] ) && ! bp_action_variable( 0 ) ) { unset( $bp->canonical_stack['action'] ); } elseif ( ! bp_current_action() ) { // Add our screen hook if screen function is callable. if ( is_callable( $r['screen_function'] ) ) { add_action( 'bp_screens', $r['screen_function'], 3 ); } if ( ! empty( $r['default_subnav_slug'] ) ) { /** * Filters the default component subnav item. * * @since BuddyPress 1.5.0 * * @param string $value The slug of the default subnav item * to select when clicked. * @param array $r Parsed arguments for the nav item. */ $bp->current_action = apply_filters( 'bp_default_component_subnav', $r['default_subnav_slug'], $r ); } } } /** * Fires after the screen function for an item in the BuddyPress main * navigation is registered. * * @since BuddyPress 2.4.0 * * @param array $r Parsed arguments for the nav item. * @param array $args Originally passed in arguments for the nav item. * @param array $defaults Default arguments for a nav item. */ do_action( 'bp_core_register_nav_screen_function', $r, $args, $defaults ); }

变更乐

变更乐
版本 描述
BuddyPress 2.4.0. 介绍了。

问题?

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