Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/19/2011 05:29:51 PM (14 years ago)
Author:
djpaul
Message:

Rework page <title> generation to use WP's wp_title(). Fixes #2598

File:
1 edited

Legend:

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

    r4325 r4536  
    252252    add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
    253253
     254/**
     255 * Filter the page title for BuddyPress pages
     256 *
     257 * @global object $bp BuddyPress global settings
     258 * @global unknown $post
     259 * @global WP_Query $wp_query WordPress query object
     260 * @param string $title Original page title
     261 * @param string $sep How to separate the various items within the page title.
     262 * @param string $seplocation Direction to display title
     263 * @return string new page title
     264 * @see wp_title()
     265 * @since 1.3
     266 */
     267function bp_modify_page_title( $title, $sep, $seplocation ) {
     268    global $bp, $post, $wp_query;
     269
     270    if ( bp_is_blog_page() )
     271        return $title;
     272
     273    $title = '';
     274
     275    // Displayed user
     276    if ( !empty( $bp->displayed_user->fullname ) && !is_404() ) {
     277        // translators: "displayed user's name | canonicalised component name"
     278        $title = strip_tags( sprintf( __( '%1$s | %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), ucwords( bp_current_component() ) ) );
     279
     280    // A single group
     281    } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
     282        $subnav = isset( $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] ) ? $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] : '';
     283        // translators: "group name | group nav section name"
     284        $title = sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->bp_options_title, $subnav );
     285
     286    // A single item from a component other than groups
     287    } elseif ( bp_is_single_item() ) {
     288        // translators: "root component name | component item name | component nav section name"
     289        $title = sprintf( __( '%1$s | %2$s | %3$s', 'buddypress' ), bp_get_name_from_root_slug(), $bp->bp_options_title, $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'] );
     290
     291    // An index or directory
     292    } elseif ( bp_is_directory() ) {
     293        if ( !bp_current_component() )
     294            $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug( $bp->members->slug ) );
     295        else
     296            $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
     297
     298    // Sign up page
     299    } elseif ( bp_is_register_page() ) {
     300        $title = __( 'Create an Account', 'buddypress' );
     301
     302    // Activation page
     303    } elseif ( bp_is_activation_page() ) {
     304        $title = __( 'Activate your Account', 'buddypress' );
     305
     306    // Group creation page
     307    } elseif ( bp_is_group_create() ) {
     308        $title = __( 'Create a Group', 'buddypress' );
     309
     310    // Blog creation page
     311    } elseif ( bp_is_create_blog() ) {
     312        $title = __( 'Create a Site', 'buddypress' );
     313    }
     314
     315    return apply_filters( 'bp_modify_page_title', $title . " $sep ", $title, $sep, $seplocation );
     316}
     317add_filter( 'wp_title', 'bp_modify_page_title', 10, 3 );
     318add_filter( 'bp_modify_page_title', 'wptexturize'   );
     319add_filter( 'bp_modify_page_title', 'convert_chars' );
     320add_filter( 'bp_modify_page_title', 'esc_html'      );
    254321?>
Note: See TracChangeset for help on using the changeset viewer.