Skip to:
Content

BuddyPress.org

Ticket #6107: 6107.04.patch

File 6107.04.patch, 5.6 KB (added by imath, 10 years ago)
  • src/bp-core/bp-core-filters.php

    diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
    index 514acfa..43698d4 100644
    add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_not 
    509509 * @param string $seplocation Direction to display title.
    510510 * @return string New page title.
    511511 */
    512 function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) {
     512function bp_modify_page_title( $title, $sep = '»', $seplocation = 'right' ) {
    513513
    514514        // If this is not a BP page, just return the title produced by WP
    515515        if ( bp_is_blog_page() ) {
    function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) { 
    526526                return $title;
    527527        }
    528528
    529         $bp    = buddypress();
    530         $title = '';
     529        $bp          = buddypress();
     530        $title_parts = array();
    531531
    532532        // Displayed user
    533533        if ( bp_get_displayed_user_fullname() && ! is_404() ) {
    function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) { 
    566566
    567567                // If on the user profile's landing page, just use the fullname
    568568                if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) {
    569                         $title = bp_get_displayed_user_fullname();
     569                        $title_parts[] = bp_get_displayed_user_fullname();
    570570
    571571                // Use component name on member pages
    572572                } else {
     573                        $title_parts = array_merge( $title_parts, array_map( 'strip_tags', array(
     574                                bp_get_displayed_user_fullname(),
     575                                $component_name,
     576                        ) ) );
     577
    573578                        // If we have a subnav name, add it separately for localization
    574579                        if ( ! empty( $component_subnav_name ) ) {
    575                                 // translators: construct the page title. 1 = user name, 2 = component name, 3 = separator, 4 = component subnav name
    576                                 $title = strip_tags( sprintf( __( '%1$s %3$s %2$s %3$s %4$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep, $component_subnav_name ) );
    577 
    578                         } else {
    579                                 // translators: construct the page title. 1 = user name, 2 = component name, 3 = separator
    580                                 $title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep ) );
     580                                $title_parts[] = strip_tags( $component_subnav_name );
    581581                        }
    582582                }
    583583
    584584        // A single group
    585585        } elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) {
    586586                $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'] : '';
    587                 // translators: 1 = group name, 2 = group nav section name, 3 = separator
    588                 $title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $subnav, $sep );
     587                $title_parts = array( $bp->bp_options_title, $subnav );
    589588
    590589        // A single item from a component other than groups
    591590        } elseif ( bp_is_single_item() ) {
    592                 // translators: 1 = component item name, 2 = component nav section name, 3 = separator
    593                 $title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'], $sep );
     591                $title_parts = array( $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'] );
    594592
    595593        // An index or directory
    596594        } elseif ( bp_is_directory() ) {
    597595                $current_component = bp_current_component();
    598596
    599597                // No current component (when does this happen?)
    600                 if ( empty( $current_component ) ) {
    601                         $title = _x( 'Directory', 'component directory title', 'buddypress' );
    602                 } else {
    603                         $title = bp_get_directory_title( $current_component );
     598                $title_parts = array( _x( 'Directory', 'component directory title', 'buddypress' ) );
     599
     600                if ( ! empty( $current_component ) ) {
     601                        $title_parts = array( bp_get_directory_title( $current_component ) );
    604602                }
    605603
    606604        // Sign up page
    607605        } elseif ( bp_is_register_page() ) {
    608                 $title = __( 'Create an Account', 'buddypress' );
     606                $title_parts = array( __( 'Create an Account', 'buddypress' ) );
    609607
    610608        // Activation page
    611609        } elseif ( bp_is_activation_page() ) {
    612                 $title = __( 'Activate your Account', 'buddypress' );
     610                $title_parts = array( __( 'Activate your Account', 'buddypress' ) );
    613611
    614612        // Group creation page
    615613        } elseif ( bp_is_group_create() ) {
    616                 $title = __( 'Create a Group', 'buddypress' );
     614                $title_parts = array( __( 'Create a Group', 'buddypress' ) );
    617615
    618616        // Blog creation page
    619617        } elseif ( bp_is_create_blog() ) {
    620                 $title = __( 'Create a Site', 'buddypress' );
     618                $title_parts = array( __( 'Create a Site', 'buddypress' ) );
    621619        }
    622620
    623621        // Some BP nav items contain item counts. Remove them
    624         $title = preg_replace( '|<span>[0-9]+</span>|', '', $title );
    625 
    626         return apply_filters( 'bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation );
     622        $title_parts = array_map( function( $t ) {
     623            return preg_replace( '|<span>[0-9]+</span>|' , '', $t );
     624        }, $title_parts);
     625
     626        // Append the site titl to title parts
     627        $title_parts = array_merge( $title_parts, array( get_bloginfo( 'name', 'display' ) ) );
     628
     629        /**
     630         * @param  string the BuddyPress page title
     631         * @param  string $title the original WordPress page title
     632         * @param  string $sep the title parts separator
     633         * @param  string $seplocation Location of the separator (left or right).
     634         */
     635        return apply_filters( 'bp_modify_page_title', join( ' ' . $sep . ' ', $title_parts ), $title, $sep, $seplocation );
    627636}
    628 add_filter( 'wp_title', 'bp_modify_page_title', 10, 3 );
     637add_filter( 'wp_title', 'bp_modify_page_title', 20, 3 );
    629638add_filter( 'bp_modify_page_title', 'wptexturize'     );
    630639add_filter( 'bp_modify_page_title', 'convert_chars'   );
    631640add_filter( 'bp_modify_page_title', 'esc_html'        );