bp_core_register_subnav_screen_function (|字符串数组args美元''字符串美元的组件“成员”

注册一个屏幕功能,无论相关的子导航链接是否存在。

描述

参数

args美元

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

  • “鼻涕虫”
    (字符串)子导航项的唯一URL蛞蝓。
  • “parent_slug”
    (字符串)新的子导航项应该被添加到顶层导航项的蛞蝓(蛞蝓)。
  • “parent_url”
    (字符串)父导航项的URL。
  • “user_has_access”
    (保龄球)可选的。如果登录的用户可以访问子导航项,则为True,否则为false。可以在注册子导航时动态设置;例如,使用bp_is_my_profile ()仅限配置文件所有者访问。默认值:真的。
  • “site_admin_only”
    (保龄球)可选的。nav项目是否应该只对网站管理员可见(那些“bp_moderate”帽)。默认值:false。
  • “位置”
    (int)可选的。指定项目在子导航数组中的位置的数值索引。默认值:90。
  • “screen_function”
    (调用)当导航项被点击时运行的回调函数。
  • “链接”
    (字符串)可选的。子导航项应该指向的URL。默认为$parent_url + $slug生成的值。
  • “show_in_admin_bar”
    (保龄球)可选的。是否应该将导航项添加到组管理员的“编辑”管理栏菜单中。默认值:false。

默认值:“

美元的组件

字符串(可选)导航附加到的组件。默认为“成员”。

默认值:“成员”

返回

(零|假)失败时返回false。

文件:bp-core / bp-core-buddybar.php

函数bp_core_register_subnav_screen_function($args = ", $component = 'members') {$bp = buddypress();$r = wp_parse_args($args, array('slug' => false, //屏幕的URL slug。'parent_slug' => false, //父屏幕的URL slug。'user_has_access' => true, //用户可以访问此屏幕吗?'no_access_url' => ', 'site_admin_only' => false, //只有站点管理员可以访问此屏幕吗?'screen_function' => false, //单击时要运行的函数的名称。));/* *为添加的子导航项钩子屏幕函数。但只有当这个子导航项是当前视图,并且用户可以访问*子导航项时,才需要执行*。*(1)或者:* (a)父slug匹配current_component,或者* (b)父slug匹配current_item * (2) * (a) the current_action matches $slug, or * (b) there is no current_action (ie, this is the default subnav for the parent nav) * and this subnav item is the default for the parent item (which we check by * comparing this subnav item's screen function with the screen function of the * parent nav item in the component's primary nav). This condition only arises * when viewing a user, since groups should always have an action set. */ // If we *don't* meet condition (1), return. if ( ! bp_is_current_component( $r['parent_slug'] ) && ! bp_is_current_item( $r['parent_slug'] ) ) { return; } $parent_nav = $bp->{$component}->nav->get_primary( array( 'slug' => $r['parent_slug'] ), false ); if ( is_array( $parent_nav ) ) { $parent_nav = reset( $parent_nav ); } // If we *do* meet condition (2), then the added subnav item is currently being requested. if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ! empty( $parent_nav->screen_function ) && $r['screen_function'] == $parent_nav->screen_function ) ) { // If this is for site admins only and the user is not one, don't create the subnav item. if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) { return false; } $hooked = bp_core_maybe_hook_new_subnav_screen_function( $r, $component ); // If redirect args have been returned, perform the redirect now. if ( ! empty( $hooked['status'] ) && 'failure' === $hooked['status'] && isset( $hooked['redirect_args'] ) ) { bp_core_no_access( $hooked['redirect_args'] ); } } }

更新日志

更新日志
版本 描述
BuddyPress测试盒框 介绍了。

问题吗?

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