diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
index 514acfa..13f0381 100644
|
|
|
add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_not
|
| 509 | 509 | * @param string $seplocation Direction to display title. |
| 510 | 510 | * @return string New page title. |
| 511 | 511 | */ |
| 512 | | function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) { |
| | 512 | function bp_modify_page_title() { |
| | 513 | $args = func_get_args(); |
| | 514 | $return_array = false; |
| 513 | 515 | |
| 514 | 516 | // If this is not a BP page, just return the title produced by WP |
| 515 | 517 | if ( bp_is_blog_page() ) { |
| 516 | | return $title; |
| | 518 | return $args[0]; |
| 517 | 519 | } |
| 518 | 520 | |
| 519 | 521 | // If this is a 404, let WordPress handle it |
| 520 | 522 | if ( is_404() ) { |
| 521 | | return $title; |
| | 523 | return $args[0]; |
| 522 | 524 | } |
| 523 | 525 | |
| 524 | 526 | // If this is the front page of the site, return WP's title |
| 525 | 527 | if ( is_front_page() || is_home() ) { |
| 526 | | return $title; |
| | 528 | return $args[0]; |
| 527 | 529 | } |
| 528 | 530 | |
| 529 | | $bp = buddypress(); |
| 530 | | $title = ''; |
| | 531 | $bp = buddypress(); |
| | 532 | $bp_title = array(); |
| | 533 | $current_filter = current_filter(); |
| | 534 | |
| | 535 | /** |
| | 536 | * wp_title_parts was introduced in WordPress 4.0 |
| | 537 | * |
| | 538 | * We first try to use it, if it fails, we still can count on the wp_title filter. We're |
| | 539 | * using this new way of filtering the title since the introduction of the 'title-tag' |
| | 540 | * feature (WordPress 4.1) in order to let WordPress build the title with our data. |
| | 541 | */ |
| | 542 | if ( 'wp_title_parts' == $current_filter ) { |
| | 543 | $return_array = true; |
| | 544 | } else if ( 'wp_title' == $current_filter ) { |
| | 545 | // Default separator is » in WordPress |
| | 546 | $sep = '»'; |
| | 547 | if ( ! empty( $args[1] ) ) { |
| | 548 | $sep = $args[1]; |
| | 549 | } |
| | 550 | |
| | 551 | // Arbitrary default seplocation if not set |
| | 552 | $seplocation = 'right'; |
| | 553 | if ( ! empty( $args[2] ) ) { |
| | 554 | $seplocation = $args[2]; |
| | 555 | } |
| | 556 | |
| | 557 | if ( ! empty( $bp->title_tag ) ) { |
| | 558 | $title = join( ' ' . $sep . ' ', $bp->title_tag ); |
| | 559 | return apply_filters( 'bp_modify_page_title', $title, $args[0], $sep, $seplocation ); |
| | 560 | } |
| | 561 | } |
| 531 | 562 | |
| 532 | 563 | // Displayed user |
| 533 | 564 | if ( bp_get_displayed_user_fullname() && ! is_404() ) { |
| … |
… |
function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) {
|
| 566 | 597 | |
| 567 | 598 | // If on the user profile's landing page, just use the fullname |
| 568 | 599 | if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) { |
| 569 | | $title = bp_get_displayed_user_fullname(); |
| | 600 | $bp_title[] = bp_get_displayed_user_fullname(); |
| 570 | 601 | |
| 571 | 602 | // Use component name on member pages |
| 572 | 603 | } else { |
| | 604 | $bp_title = array_merge( $bp_title, array_map( 'strip_tags', array( |
| | 605 | bp_get_displayed_user_fullname(), |
| | 606 | $component_name, |
| | 607 | ) ) ); |
| | 608 | |
| 573 | 609 | // If we have a subnav name, add it separately for localization |
| 574 | 610 | 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 ) ); |
| | 611 | $bp_title[] = strip_tags( $component_subnav_name ); |
| 581 | 612 | } |
| 582 | 613 | } |
| 583 | 614 | |
| 584 | 615 | // A single group |
| 585 | 616 | } elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) { |
| 586 | 617 | $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 ); |
| | 618 | $bp_title = array( $bp->bp_options_title, $subnav ); |
| 589 | 619 | |
| 590 | 620 | // A single item from a component other than groups |
| 591 | 621 | } 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 ); |
| | 622 | $bp_title = array( $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'] ); |
| 594 | 623 | |
| 595 | 624 | // An index or directory |
| 596 | 625 | } elseif ( bp_is_directory() ) { |
| 597 | 626 | $current_component = bp_current_component(); |
| 598 | 627 | |
| 599 | 628 | // 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 ); |
| | 629 | $bp_title = array( _x( 'Directory', 'component directory title', 'buddypress' ) ); |
| | 630 | |
| | 631 | if ( ! empty( $current_component ) ) { |
| | 632 | $bp_title = array( bp_get_directory_title( $current_component ) ); |
| 604 | 633 | } |
| 605 | 634 | |
| 606 | 635 | // Sign up page |
| 607 | 636 | } elseif ( bp_is_register_page() ) { |
| 608 | | $title = __( 'Create an Account', 'buddypress' ); |
| | 637 | $bp_title = array( __( 'Create an Account', 'buddypress' ) ); |
| 609 | 638 | |
| 610 | 639 | // Activation page |
| 611 | 640 | } elseif ( bp_is_activation_page() ) { |
| 612 | | $title = __( 'Activate your Account', 'buddypress' ); |
| | 641 | $bp_title = array( __( 'Activate your Account', 'buddypress' ) ); |
| 613 | 642 | |
| 614 | 643 | // Group creation page |
| 615 | 644 | } elseif ( bp_is_group_create() ) { |
| 616 | | $title = __( 'Create a Group', 'buddypress' ); |
| | 645 | $bp_title = array( __( 'Create a Group', 'buddypress' ) ); |
| 617 | 646 | |
| 618 | 647 | // Blog creation page |
| 619 | 648 | } elseif ( bp_is_create_blog() ) { |
| 620 | | $title = __( 'Create a Site', 'buddypress' ); |
| | 649 | $bp_title = array( __( 'Create a Site', 'buddypress' ) ); |
| 621 | 650 | } |
| 622 | 651 | |
| 623 | 652 | // Some BP nav items contain item counts. Remove them |
| 624 | | $title = preg_replace( '|<span>[0-9]+</span>|', '', $title ); |
| | 653 | $bp_title = array_map( function( $t ) { |
| | 654 | return preg_replace( '|<span>[0-9]+</span>|' , '', $t ); |
| | 655 | }, $bp_title); |
| | 656 | |
| | 657 | // Set a global with the bp_title merged with site title |
| | 658 | $bp->title_tag = array_merge( $bp_title, array( get_bloginfo( 'name', 'display' ) ) ); |
| | 659 | |
| | 660 | if ( ! empty( $return_array ) ) { |
| | 661 | $title = array_reverse( $bp_title ); |
| | 662 | |
| | 663 | if ( ! bp_is_directory() && ! bp_is_register_page() && ! bp_is_activation_page() ) { |
| | 664 | $title = array_merge( array( '' ), $title ); |
| | 665 | } |
| | 666 | |
| | 667 | /** |
| | 668 | * The filters wptexturize, convert_chars and esc_html |
| | 669 | * will be applied by WordPress later in wp_title() just |
| | 670 | * before returning the title. |
| | 671 | * |
| | 672 | * @param array $title list of BuddyPress page title parts |
| | 673 | */ |
| | 674 | return apply_filters( 'bp_modify_page_title_parts', $title ); |
| 625 | 675 | |
| 626 | | return apply_filters( 'bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation ); |
| | 676 | // Build the title it used to be done before 'title-tag' feature |
| | 677 | } else { |
| | 678 | // Set the title |
| | 679 | $title = join( ' ' . $sep . ' ', $bp->title_tag ); |
| | 680 | /** |
| | 681 | * @param string $title the BuddyPress page title |
| | 682 | * @param string $args[0] the original WordPress page title |
| | 683 | * @param string $sep the title parts separator |
| | 684 | * @param string $seplocation Location of the separator (left or right). |
| | 685 | */ |
| | 686 | return apply_filters( 'bp_modify_page_title', $title, $args[0], $sep, $seplocation ); |
| | 687 | } |
| 627 | 688 | } |
| 628 | | add_filter( 'wp_title', 'bp_modify_page_title', 10, 3 ); |
| | 689 | add_filter( 'wp_title_parts', 'bp_modify_page_title', 10, 1 ); |
| | 690 | add_filter( 'wp_title', 'bp_modify_page_title', 20, 3 ); |
| 629 | 691 | add_filter( 'bp_modify_page_title', 'wptexturize' ); |
| 630 | 692 | add_filter( 'bp_modify_page_title', 'convert_chars' ); |
| 631 | 693 | add_filter( 'bp_modify_page_title', 'esc_html' ); |