Ticket #2405: 2405.2.patch
File 2405.2.patch, 6.6 KB (added by , 11 years ago) |
---|
-
includes/common/template.php
2501 2501 */ 2502 2502 function bbp_title( $title = '', $sep = '»', $seplocation = '' ) { 2503 2503 2504 // Store original title to compare2505 $_title = $title;2506 2507 2504 // Title array 2508 $ title = array();2505 $new_title = array(); 2509 2506 2510 2507 /** Archives **************************************************************/ 2511 2508 2512 2509 // Forum Archive 2513 2510 if ( bbp_is_forum_archive() ) { 2514 $ title['text'] = bbp_get_forum_archive_title();2511 $new_title['text'] = bbp_get_forum_archive_title(); 2515 2512 2516 2513 // Topic Archive 2517 2514 } elseif ( bbp_is_topic_archive() ) { 2518 $ title['text'] = bbp_get_topic_archive_title();2515 $new_title['text'] = bbp_get_topic_archive_title(); 2519 2516 2520 2517 /** Edit ******************************************************************/ 2521 2518 2522 2519 // Forum edit page 2523 2520 } 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' ); 2526 2523 2527 2524 // Topic edit page 2528 2525 } 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' ); 2531 2528 2532 2529 // Reply edit page 2533 2530 } 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' ); 2536 2533 2537 2534 // Topic tag edit page 2538 2535 } 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' ); 2541 2538 2542 2539 /** Singles ***************************************************************/ 2543 2540 2544 2541 // Forum page 2545 2542 } 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' ); 2548 2545 2549 2546 // Topic page 2550 2547 } 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' ); 2553 2550 2554 2551 // Replies 2555 2552 } elseif ( bbp_is_single_reply() ) { 2556 $ title['text'] = bbp_get_reply_title();2553 $new_title['text'] = bbp_get_reply_title(); 2557 2554 2558 2555 // Topic tag page 2559 2556 } 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' ); 2562 2559 2563 2560 /** Users *****************************************************************/ 2564 2561 … … 2567 2564 2568 2565 // Current users profile 2569 2566 if ( bbp_is_user_home() ) { 2570 $ title['text'] = esc_attr__( 'Your Profile', 'bbpress' );2567 $new_title['text'] = esc_attr__( 'Your Profile', 'bbpress' ); 2571 2568 2572 2569 // Other users profile 2573 2570 } 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' ); 2576 2573 } 2577 2574 2578 2575 // Profile edit page … … 2580 2577 2581 2578 // Current users profile 2582 2579 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' ); 2584 2581 2585 2582 // Other users profile 2586 2583 } 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' ); 2589 2586 } 2590 2587 2591 2588 /** Views *****************************************************************/ 2592 2589 2593 2590 // Views 2594 2591 } 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' ); 2597 2594 2598 2595 /** Search ****************************************************************/ 2599 2596 2600 2597 // Search 2601 2598 } elseif ( bbp_is_search() ) { 2602 $ title['text'] = bbp_get_search_title();2599 $new_title['text'] = bbp_get_search_title(); 2603 2600 } 2604 2601 2605 2602 // 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 ); 2607 2604 2608 2605 // 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, 2611 2608 'format' => '%s' 2612 2609 ), 'title' ); 2613 2610 2614 2611 // Get the formatted raw title 2615 $ title = sprintf( $title['format'], $title['text'] );2612 $new_title = sprintf( $new_title['format'], $new_title['text'] ); 2616 2613 2617 2614 // 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 ); 2619 2616 2620 2617 // Compare new title with original title 2621 if ( $ title === $_title )2618 if ( $new_title === $title ) 2622 2619 return $title; 2623 2620 2624 2621 // Temporary separator, for accurate flipping, if necessary 2625 2622 $t_sep = '%WP_TITILE_SEP%'; 2626 2623 $prefix = ''; 2627 2624 2628 if ( !empty( $ title ) )2625 if ( !empty( $new_title ) ) 2629 2626 $prefix = " $sep "; 2630 2627 2631 2628 // sep on right, so reverse the order 2632 2629 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; 2635 2632 2636 2633 // sep on left, do not reverse 2637 2634 } 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 ); 2640 2637 } 2641 2638 2642 2639 // Filter and return 2643 return apply_filters( 'bbp_title', $ title, $sep, $seplocation );2640 return apply_filters( 'bbp_title', $new_title, $sep, $seplocation ); 2644 2641 }