bp_get_root_slug (字符串美元的组件''

获取给定组件的根代码段。

描述

“根鼻涕虫”是连接组件目录url时使用的字符串。例如,在Groups组件目录所在的安装上http://example.com/groups/, Groups组件的根代码段是' Groups '。这个字符串通常对应组件目录页的page_name。

为了保持向后兼容性,使用了以下过程:1)使用short slug从活动组件数组中获取规范组件名。2)使用组件名从$bp global中适当的部分获得根蛞蝓。3)如果什么都没有出现,这可能意味着$component本身就是一个根蛞蝓。

例如:如果你的groups目录在/community/companies,这个函数首先使用短片段' companies '(即当前组件)在$bp->active_components中查找规范名称' groups '。然后它使用' groups '获取根slug,从$bp->groups->root_slug。

参数

美元的组件

字符串(可选)默认为当前组件。

默认值:“

返回

(字符串)$root_slug根slug。

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

函数bp_get_root_slug($component = ") {$bp = buddypress();$ root_slug =”;//如果没有传入,则使用当前全局组件。If (empty($component)) {$component = bp_current_component();} //组件是激活的。如果(!$bp->active_components[$component])){//向后兼容性:在遗留插件中,规范组件id //以数组的形式存储在$bp->active_components中。$component = ('1' == $bp->active_components[$component]) ?组件:英国石油美元- > active_components(美元组件);//组件有特定的根slug。 if ( ! empty( $bp->{$component_name}->root_slug ) ) { $root_slug = $bp->{$component_name}->root_slug; } } // No specific root slug, so fall back to component slug. if ( empty( $root_slug ) ) { $root_slug = $component; } /** * Filters the root slug for given component. * * @since BuddyPress 1.5.0 * * @param string $root_slug Root slug for given component. * @param string $component Current component. */ return apply_filters( 'bp_get_root_slug', $root_slug, $component ); }

更新日志

更新日志
版本 描述
BuddyPress 1.5.0 介绍了。

问题吗?

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