Skip to:
Content

bbPress.org


Ignore:
Timestamp:
09/03/2013 05:21:27 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Tweak bbp_title() to better integrate with other plugins that filter 'wp_title'. Fixes #2405. (2.4 branch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/includes/common/template.php

    r5084 r5102  
    25022502function bbp_title( $title = '', $sep = '»', $seplocation = '' ) {
    25032503
    2504     // Store original title to compare
    2505     $_title = $title;
    2506 
    25072504    // Title array
    2508     $title = array();
     2505    $new_title = array();
    25092506
    25102507    /** Archives **************************************************************/
     
    25122509    // Forum Archive
    25132510    if ( bbp_is_forum_archive() ) {
    2514         $title['text'] = bbp_get_forum_archive_title();
     2511        $new_title['text'] = bbp_get_forum_archive_title();
    25152512
    25162513    // Topic Archive
    25172514    } elseif ( bbp_is_topic_archive() ) {
    2518         $title['text'] = bbp_get_topic_archive_title();
     2515        $new_title['text'] = bbp_get_topic_archive_title();
    25192516
    25202517    /** Edit ******************************************************************/
     
    25222519    // Forum edit page
    25232520    } elseif ( bbp_is_forum_edit() ) {
    2524         $title['text']   = bbp_get_forum_title();
    2525         $title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' );
     2521        $new_title['text']   = bbp_get_forum_title();
     2522        $new_title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' );
    25262523
    25272524    // Topic edit page
    25282525    } elseif ( bbp_is_topic_edit() ) {
    2529         $title['text']   = bbp_get_topic_title();
    2530         $title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' );
     2526        $new_title['text']   = bbp_get_topic_title();
     2527        $new_title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' );
    25312528
    25322529    // Reply edit page
    25332530    } elseif ( bbp_is_reply_edit() ) {
    2534         $title['text']   = bbp_get_reply_title();
    2535         $title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' );
     2531        $new_title['text']   = bbp_get_reply_title();
     2532        $new_title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' );
    25362533
    25372534    // Topic tag edit page
    25382535    } elseif ( bbp_is_topic_tag_edit() ) {
    2539         $title['text']   = bbp_get_topic_tag_name();
    2540         $title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
     2536        $new_title['text']   = bbp_get_topic_tag_name();
     2537        $new_title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
    25412538
    25422539    /** Singles ***************************************************************/
     
    25442541    // Forum page
    25452542    } elseif ( bbp_is_single_forum() ) {
    2546         $title['text']   = bbp_get_forum_title();
    2547         $title['format'] = esc_attr__( 'Forum: %s', 'bbpress' );
     2543        $new_title['text']   = bbp_get_forum_title();
     2544        $new_title['format'] = esc_attr__( 'Forum: %s', 'bbpress' );
    25482545
    25492546    // Topic page
    25502547    } elseif ( bbp_is_single_topic() ) {
    2551         $title['text']   = bbp_get_topic_title();
    2552         $title['format'] = esc_attr__( 'Topic: %s', 'bbpress' );
     2548        $new_title['text']   = bbp_get_topic_title();
     2549        $new_title['format'] = esc_attr__( 'Topic: %s', 'bbpress' );
    25532550
    25542551    // Replies
    25552552    } elseif ( bbp_is_single_reply() ) {
    2556         $title['text']   = bbp_get_reply_title();
     2553        $new_title['text']   = bbp_get_reply_title();
    25572554
    25582555    // Topic tag page
    25592556    } elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) {
    2560         $title['text']   = bbp_get_topic_tag_name();
    2561         $title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
     2557        $new_title['text']   = bbp_get_topic_tag_name();
     2558        $new_title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
    25622559
    25632560    /** Users *****************************************************************/
     
    25682565        // Current users profile
    25692566        if ( bbp_is_user_home() ) {
    2570             $title['text'] = esc_attr__( 'Your Profile', 'bbpress' );
     2567            $new_title['text'] = esc_attr__( 'Your Profile', 'bbpress' );
    25712568
    25722569        // Other users profile
    25732570        } else {
    2574             $title['text']   = get_userdata( bbp_get_user_id() )->display_name;
    2575             $title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
     2571            $new_title['text']   = get_userdata( bbp_get_user_id() )->display_name;
     2572            $new_title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
    25762573        }
    25772574
     
    25812578        // Current users profile
    25822579        if ( bbp_is_user_home_edit() ) {
    2583             $title['text']   = esc_attr__( 'Edit Your Profile', 'bbpress' );
     2580            $new_title['text']   = esc_attr__( 'Edit Your Profile', 'bbpress' );
    25842581
    25852582        // Other users profile
    25862583        } else {
    2587             $title['text']   = get_userdata( bbp_get_user_id() )->display_name;
    2588             $title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
     2584            $new_title['text']   = get_userdata( bbp_get_user_id() )->display_name;
     2585            $new_title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
    25892586        }
    25902587
     
    25932590    // Views
    25942591    } elseif ( bbp_is_single_view() ) {
    2595         $title['text']   = bbp_get_view_title();
    2596         $title['format'] = esc_attr__( 'View: %s', 'bbpress' );
     2592        $new_title['text']   = bbp_get_view_title();
     2593        $new_title['format'] = esc_attr__( 'View: %s', 'bbpress' );
    25972594
    25982595    /** Search ****************************************************************/
     
    26002597    // Search
    26012598    } elseif ( bbp_is_search() ) {
    2602         $title['text'] = bbp_get_search_title();
     2599        $new_title['text'] = bbp_get_search_title();
    26032600    }
    26042601
    26052602    // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
    2606     $title = apply_filters( 'bbp_raw_title_array', $title );
     2603    $new_title = apply_filters( 'bbp_raw_title_array', $new_title );
    26072604
    26082605    // Set title array defaults
    2609     $title = bbp_parse_args( $title, array(
    2610         'text'   => '',
     2606    $new_title = bbp_parse_args( $new_title, array(
     2607        'text'   => $title,
    26112608        'format' => '%s'
    26122609    ), 'title' );
    26132610
    26142611    // Get the formatted raw title
    2615     $title = sprintf( $title['format'], $title['text'] );
     2612    $new_title = sprintf( $new_title['format'], $new_title['text'] );
    26162613
    26172614    // Filter the raw title
    2618     $title = apply_filters( 'bbp_raw_title', $title, $sep, $seplocation );
     2615    $new_title = apply_filters( 'bbp_raw_title', $new_title, $sep, $seplocation );
    26192616
    26202617    // Compare new title with original title
    2621     if ( $title === $_title )
     2618    if ( $new_title === $title )
    26222619        return $title;
    26232620
     
    26262623    $prefix = '';
    26272624
    2628     if ( !empty( $title ) )
     2625    if ( !empty( $new_title ) )
    26292626        $prefix = " $sep ";
    26302627
    26312628    // sep on right, so reverse the order
    26322629    if ( 'right' === $seplocation ) {
    2633         $title_array = array_reverse( explode( $t_sep, $title ) );
    2634         $title       = implode( " $sep ", $title_array ) . $prefix;
     2630        $new_title_array = array_reverse( explode( $t_sep, $new_title ) );
     2631        $new_title       = implode( " $sep ", $new_title_array ) . $prefix;
    26352632
    26362633    // sep on left, do not reverse
    26372634    } else {
    2638         $title_array = explode( $t_sep, $title );
    2639         $title       = $prefix . implode( " $sep ", $title_array );
     2635        $new_title_array = explode( $t_sep, $new_title );
     2636        $new_title       = $prefix . implode( " $sep ", $new_title_array );
    26402637    }
    26412638
    26422639    // Filter and return
    2643     return apply_filters( 'bbp_title', $title, $sep, $seplocation );
    2644 }
     2640    return apply_filters( 'bbp_title', $new_title, $sep, $seplocation );
     2641}
Note: See TracChangeset for help on using the changeset viewer.