| 806 | | // Append the prefix for pre `title-tag` compatibility |
| 807 | | if ( false === $title_tag_compatibility ) { |
| 808 | | $new_title = $new_title . $prefix; |
| | 807 | // Append the prefix for pre `title-tag` compatibility |
| | 808 | if ( false === $title_tag_compatibility ) { |
| | 809 | $new_title = $new_title . $prefix; |
| | 810 | } |
| | 811 | |
| | 812 | /** |
| | 813 | * Filters the page title for BuddyPress pages. |
| | 814 | * |
| | 815 | * @since 1.5.0 |
| | 816 | * |
| | 817 | * @param string $new_title The BuddyPress page title. |
| | 818 | * @param string $title The original WordPress page title. |
| | 819 | * @param string $sep The title parts separator. |
| | 820 | * @param string $seplocation Location of the separator (left or right). |
| | 821 | */ |
| | 822 | return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation ); |
| | 823 | } else { |
| | 824 | // Remove site & page to only keep the title of the viewed page |
| | 825 | $bp_title_parts = array_diff_key( $title_parts, array( 'site' => false, 'page' => false ) ); |
| | 826 | |
| | 827 | // Get the new separator |
| | 828 | $sep = apply_filters( 'document_title_separator', '-' ); |
| | 829 | |
| | 830 | // Build the new title, we don't need to sanitize it, as WordPress will take care of this. |
| | 831 | $new_title = array( 'title' => join( " $sep ", $bp_title_parts ) ); |
| | 832 | |
| | 833 | // Add the page argument if needed |
| | 834 | if ( isset( $title_parts['page'] ) ) { |
| | 835 | $new_title['page'] = $title_parts['page']; |
| | 836 | } |
| | 837 | |
| | 838 | // Add the site argument if needed |
| | 839 | if ( isset( $title_parts['site'] ) ) { |
| | 840 | $new_title['site'] = $title_parts['site']; |
| | 841 | } |
| | 842 | |
| | 843 | /** |
| | 844 | * Filters the document title for BuddyPress pages. |
| | 845 | * |
| | 846 | * @since 2.4.0 |
| | 847 | * |
| | 848 | * @param array $new_title The BuddyPress page title. |
| | 849 | * @param array $title The original WordPress page title. |
| | 850 | * @param string $sep The title separator |
| | 851 | * @param array $title_parts The BuddyPress title parts |
| | 852 | */ |
| | 853 | return apply_filters( 'bp_modify_document_title', $new_title, $title, $sep, $title_parts ); |
| 811 | | /** |
| 812 | | * Filters the page title for BuddyPress pages. |
| 813 | | * |
| 814 | | * @since 1.5.0 |
| 815 | | * |
| 816 | | * @param string $new_title The BuddyPress page title. |
| 817 | | * @param string $title The original WordPress page title. |
| 818 | | * @param string $sep The title parts separator. |
| 819 | | * @param string $seplocation Location of the separator (left or right). |
| 820 | | */ |
| 821 | | return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation ); |
| | 857 | /** |
| | 858 | * Once the active theme is set up, use the best filter to render the document title |
| | 859 | * for BuddyPress pages |
| | 860 | * |
| | 861 | * @since 2.4.0 |
| | 862 | */ |
| | 863 | function bp_do_document_title() { |
| | 864 | $filter = 'wp_title'; |
| | 865 | |
| | 866 | if ( function_exists( 'wp_get_document_title' ) && true === current_theme_supports( 'title-tag' ) ) { |
| | 867 | $filter = 'document_title_parts'; |
| | 868 | } |
| | 869 | |
| | 870 | add_filter( $filter, 'bp_modify_page_title', 20, 3 ); |