Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/19/2011 05:29:51 PM (15 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-template.php

    r4532 r4536  
    212212function bp_get_plugin_sidebar() {
    213213        locate_template( array( 'plugin-sidebar.php' ), true );
    214 }
    215 
    216 function bp_page_title() {
    217         echo bp_get_page_title();
    218 }
    219 
    220 function bp_get_page_title() {
    221         global $bp, $post, $wp_query;
    222 
    223         $title = '';
    224 
    225         // Home
    226         if ( is_front_page() || ( is_home() && bp_is_page( 'home' ) ) ) {
    227                 $title = _x( 'Home', 'Home page title', 'buddypress' );
    228 
    229         // Blog
    230         } elseif ( bp_is_blog_page() ) {
    231                 if ( is_single() ) {
    232                         $title = sprintf( __( 'Site &#124; %s', 'buddypress' ), $post->post_title );
    233                 } else if ( is_category() ) {
    234                         $title = sprintf( __( 'Site &#124; Categories &#124; %s', 'buddypress' ), ucwords( $wp_query->query_vars['category_name'] ) );
    235                 } else if ( is_tag() ) {
    236                         $title = sprintf( __( 'Site &#124; Tags &#124; %s', 'buddypress' ), ucwords( $wp_query->query_vars['tag'] ) );
    237                 } else if ( is_page() ){
    238                         $title = $post->post_title;
    239                 } else
    240                         $title = __( 'Site', 'buddypress' );
    241 
    242         // Displayed user
    243         } elseif ( !empty( $bp->displayed_user->fullname ) && !is_404() ) {
    244                 // translators: "displayed user's name | canonicalised component name"
    245                 $title = strip_tags( sprintf( __( '%1$s &#124; %2$s', 'buddypress' ), $bp->displayed_user->fullname, ucwords( bp_current_component() ) ) );
    246 
    247         // A single group
    248         } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
    249                 $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'] : '';
    250                 // translators: "group name | group nav section name"
    251                 $title = sprintf( __( '%1$s &#124; %2$s', 'buddypress' ), $bp->bp_options_title, $subnav );
    252 
    253         // A single item from a component other than groups
    254         } elseif ( bp_is_single_item() ) {
    255                 // translators: "root component name | component item name | component nav section name"
    256                 $title = sprintf( __( '%1$s &#124; %2$s &#124; %3$s', 'buddypress' ), bp_get_name_from_root_slug(), $bp->bp_options_title, $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'] );
    257 
    258         // An index or directory
    259         } elseif ( bp_is_directory() ) {
    260                 if ( !bp_current_component() )
    261                         $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug( $bp->members->slug ) );
    262                 else
    263                         $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
    264 
    265         // Sign up page
    266         } elseif ( bp_is_register_page() ) {
    267                 $title = __( 'Create an Account', 'buddypress' );
    268 
    269         // Activation page
    270         } elseif ( bp_is_activation_page() ) {
    271                 $title = __( 'Activate your Account', 'buddypress' );
    272 
    273         // Group creation page
    274         } elseif ( bp_is_group_create() ) {
    275                 $title = __( 'Create a Group', 'buddypress' );
    276 
    277         // Blog creation page
    278         } elseif ( bp_is_create_blog() ) {
    279                 $title = __( 'Create a Site', 'buddypress' );
    280         }
    281 
    282         $site_title = get_bloginfo( 'name', 'display' );
    283 
    284         // Filter the title
    285         if ( !empty( $title ) )
    286                 $site_title .= ' &#124; ' . $title;
    287 
    288         return apply_filters( 'bp_page_title', esc_attr( $site_title ), esc_attr( $site_title ) );
    289 }
    290 
    291 function bp_styles() {
    292         do_action( 'bp_styles' );
    293         wp_print_styles();
    294214}
    295215
Note: See TracChangeset for help on using the changeset viewer.