bp_get_title_parts (字符串seplocation美元“对”

获得BuddyPress显示页面的标题部分

描述

参数

seplocation美元

字符串(可选)分隔符的位置。

默认值:‘正确的’

返回

(数组)标题部分

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

函数bp_get_title_parts($seplocation = 'right') {$bp = buddypress();//默认为空数组。数组$ bp_title_parts = ();//如果这不是一个BP页,返回空数组。If (bp_is_blog_page()){返回$bp_title_parts;} //如果这是一个404,返回空数组。If (is_404()){返回$bp_title_parts;} //如果这是站点的首页,返回空数组。If (is_front_page() || is_home()) {return $bp_title_parts;} //如果不是BuddyPress页面,则返回空数组。 if ( ! is_buddypress() ) { return $bp_title_parts; } // Now we can build the BP Title Parts // Is there a displayed user, and do they have a name? $displayed_user_name = bp_get_displayed_user_fullname(); // Displayed user. if ( ! empty( $displayed_user_name ) && ! is_404() ) { // Get the component's ID to try and get its name. $component_id = $component_name = bp_current_component(); // Set empty subnav name. $component_subnav_name = ''; if ( ! empty( $bp->members->nav ) ) { $primary_nav_item = $bp->members->nav->get_primary( array( 'slug' => $component_id ), false ); $primary_nav_item = reset( $primary_nav_item ); } // Use the component nav name. if ( ! empty( $primary_nav_item->name ) ) { $component_name = _bp_strip_spans_from_title( $primary_nav_item->name ); // Fall back on the component ID. } elseif ( ! empty( $bp->{$component_id}->id ) ) { $component_name = ucwords( $bp->{$component_id}->id ); } if ( ! empty( $bp->members->nav ) ) { $secondary_nav_item = $bp->members->nav->get_secondary( array( 'parent_slug' => $component_id, 'slug' => bp_current_action() ), false ); if ( $secondary_nav_item ) { $secondary_nav_item = reset( $secondary_nav_item ); } } // Append action name if we're on a member component sub-page. if ( ! empty( $secondary_nav_item->name ) && ! empty( $bp->canonical_stack['action'] ) ) { $component_subnav_name = $secondary_nav_item->name; } // If on the user profile's landing page, just use the fullname. if ( bp_is_current_component( $bp->default_component ) && ( bp_get_requested_url() === bp_displayed_user_domain() ) ) { $bp_title_parts[] = $displayed_user_name; // Use component name on member pages. } else { $bp_title_parts = array_merge( $bp_title_parts, array_map( 'strip_tags', array( $displayed_user_name, $component_name, ) ) ); // If we have a subnav name, add it separately for localization. if ( ! empty( $component_subnav_name ) ) { $bp_title_parts[] = strip_tags( $component_subnav_name ); } } // A single item from a component other than Members. } elseif ( bp_is_single_item() ) { $component_id = bp_current_component(); if ( ! empty( $bp->{$component_id}->nav ) ) { $secondary_nav_item = $bp->{$component_id}->nav->get_secondary( array( 'parent_slug' => bp_current_item(), 'slug' => bp_current_action() ), false ); if ( $secondary_nav_item ) { $secondary_nav_item = reset( $secondary_nav_item ); } } $single_item_subnav = ''; if ( ! empty( $secondary_nav_item->name ) ) { $single_item_subnav = $secondary_nav_item->name; } $bp_title_parts = array( $bp->bp_options_title, $single_item_subnav ); // An index or directory. } elseif ( bp_is_directory() ) { $current_component = bp_current_component(); // No current component (when does this happen?). $bp_title_parts = array( __( 'Directory', 'buddyboss' ) ); if ( ! empty( $current_component ) ) { $bp_title_parts = array( bp_get_directory_title( $current_component ) ); } // Sign up page. } elseif ( bp_is_register_page() ) { $bp_title_parts = array( __( 'Create an Account', 'buddyboss' ) ); // Activation page. } elseif ( bp_is_activation_page() ) { $bp_title_parts = array( __( 'Activate Your Account', 'buddyboss' ) ); // Group creation page. } elseif ( bp_is_group_create() ) { $bp_title_parts = array( __( 'Create a Group', 'buddyboss' ) ); // Blog creation page. } elseif ( bp_is_create_blog() ) { $bp_title_parts = array( __( 'Create a Site', 'buddyboss' ) ); } // Strip spans. $bp_title_parts = array_map( '_bp_strip_spans_from_title', $bp_title_parts ); // Sep on right, so reverse the order. if ( 'right' === $seplocation ) { $bp_title_parts = array_reverse( $bp_title_parts ); } /** * Filter BuddyPress title parts before joining. * * @since BuddyPress 2.4.3 * * @param array $bp_title_parts Current BuddyPress title parts. * @return array */ return (array) apply_filters( 'bp_get_title_parts', $bp_title_parts ); }

更新日志

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

问题吗?

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