Skip to:
Content

BuddyPress.org

Changeset 5670


Ignore:
Timestamp:
01/29/2012 05:45:11 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Use the component name in bp_modify_page_title() if one exists. Fall back on current_component if needed (and for backpat with components without names.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-filters.php

    r5604 r5670  
    244244 *
    245245 * @global object $bp BuddyPress global settings
    246  * @global unknown $post
    247  * @global WP_Query $wp_query WordPress query object
    248246 * @param string $title Original page title
    249247 * @param string $sep How to separate the various items within the page title.
     
    254252 */
    255253function bp_modify_page_title( $title, $sep, $seplocation ) {
    256         global $bp, $post, $wp_query;
     254        global $bp;
    257255
    258256        // If this is not a BP page, just return the title produced by WP
     
    268266        // Displayed user
    269267        if ( !empty( $bp->displayed_user->fullname ) && !is_404() ) {
     268
     269                // Get the component's ID to try and get it's name
     270                $component_id = $component_name = bp_current_component();
     271               
     272                // Use the actual component name
     273                if ( !empty( $bp->{$component_id}->name ) ) {
     274                        $component_name = $bp->{$component_id}->name;
     275                       
     276                // Fall back on the component ID (probably same as current_component)
     277                } elseif ( !empty( $bp->{$component_id}->id ) ) {
     278                        $component_name = $bp->{$component_id}->id;
     279                }
     280
    270281                // translators: "displayed user's name | canonicalised component name"
    271                 $title = strip_tags( sprintf( __( '%1$s | %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), ucwords( bp_current_component() ) ) );
     282                $title = strip_tags( sprintf( __( '%1$s | %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), ucwords( $component_name ) ) );
    272283
    273284        // A single group
Note: See TracChangeset for help on using the changeset viewer.