Index: src/bp-core/bp-core-filters.php
--- src/bp-core/bp-core-filters.php
+++ src/bp-core/bp-core-filters.php
@@ -505,13 +505,14 @@
  * @see wp_title()
  * @global object $bp BuddyPress global settings.
  *
- * @param string $title Original page title.
- * @param string $sep How to separate the various items within the page title.
- * @param string $seplocation Direction to display title.
- * @return string New page title.
+ * @param  string $title       Original page title.
+ * @param  string $sep         How to separate the various items within the page title.
+ * @param  string $seplocation Direction to display title.
+ *
+ * @return string              New page title.
  */
-function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) {
-	global $bp;
+function bp_modify_page_title( $title = '', $sep = '&raquo;', $seplocation = 'right' ) {
+	global $bp, $paged, $page, $_wp_theme_features;
 
 	// If this is not a BP page, just return the title produced by WP
 	if ( bp_is_blog_page() ) {
@@ -528,24 +529,48 @@
 		return $title;
 	}
 
-	$title = '';
+	// Return WP's title if not a BuddyPress page
+	if ( ! is_buddypress() ) {
+		return $title;
+	}
 
+	// Setup an empty title parts array
+	$title_parts = array();
+
+	// Is there a displayed user, and do they have a name?
+	$displayed_user_name = bp_get_displayed_user_fullname();
+
+	/**
+	 * Strip span tags out of title part strings.
+	 *
+	 * This is a temporary function for compatibility with WordPress versions
+	 * less than 4.0, and should be removed at a later date.
+	 *
+	 * @param  string $title_part
+	 * @return string
+	 */
+	function _bp_strip_spans_from_title( $title_part = '' ) {
+		$title = $title_part;
+		$span = strpos( $title, '<span' );
+		if ( false !== $span ) {
+			$title = substr( $title, 0, $span - 1 );
+		}
+		return $title;
+	}
+
 	// Displayed user
-	if ( bp_get_displayed_user_fullname() && ! is_404() ) {
+	if ( ! empty( $displayed_user_name ) && ! is_404() ) {
+
 		// Get the component's ID to try and get its name
 		$component_id = $component_name = bp_current_component();
 
+		// Set empty subnav name
+		$component_subnav_name = '';
+
 		// Use the component nav name
 		if ( ! empty( $bp->bp_nav[$component_id] ) ) {
-			// Remove counts that are added by the nav item
-			$span = strpos( $bp->bp_nav[ $component_id ]['name'], '<span' );
-			if ( false !== $span ) {
-				$component_name = substr( $bp->bp_nav[ $component_id ]['name'], 0, $span - 1 );
+			$component_name = _bp_strip_spans_from_title( $bp->bp_nav[ $component_id ]['name'] );
 
-			} else {
-				$component_name = $bp->bp_nav[ $component_id ]['name'];
-			}
-
 		// Fall back on the component ID
 		} elseif ( ! empty( $bp->{$component_id}->id ) ) {
 			$component_name = ucwords( $bp->{$component_id}->id );
@@ -555,83 +580,149 @@
 		if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) {
 			$component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' );
 
-			if ( $component_subnav_name ) {
+			if ( ! empty( $component_subnav_name ) ) {
 				$component_subnav_name = array_shift( $component_subnav_name );
-			} else {
-				$component_subnav_name = '';
 			}
-
-		} else {
-			$component_subnav_name = '';
 		}
 
 		// If on the user profile's landing page, just use the fullname
-		if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) {
-			$title = bp_get_displayed_user_fullname();
+		if ( bp_is_current_component( $bp->default_component ) && ( bp_get_requested_url() === bp_displayed_user_domain() ) ) {
+			$title_parts[] = $displayed_user_name;
 
 		// Use component name on member pages
 		} else {
+			$title_parts = array_merge( $title_parts, array_map( 'strip_tags', array(
+				$displayed_user_name,
+				$component_name,
+			) ) );
+
 			// If we have a subnav name, add it separately for localization
 			if ( ! empty( $component_subnav_name ) ) {
-				// translators: construct the page title. 1 = user name, 2 = component name, 3 = separator, 4 = component subnav name
-				$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 ) );
-
-			} else {
-				// translators: construct the page title. 1 = user name, 2 = component name, 3 = separator
-				$title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep ) );
+				$title_parts[] = strip_tags( $component_subnav_name );
 			}
 		}
 
 	// A single group
 	} elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) {
-		$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'] : '';
-		// translators: 1 = group name, 2 = group nav section name, 3 = separator
-		$title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $subnav, $sep );
+		$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'] : '';
+		$title_parts = array( $bp->bp_options_title, $subnav );
 
 	// A single item from a component other than groups
 	} elseif ( bp_is_single_item() ) {
-		// translators: 1 = component item name, 2 = component nav section name, 3 = separator
-		$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 );
+		$title_parts = array( $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'] );
 
 	// An index or directory
 	} elseif ( bp_is_directory() ) {
 		$current_component = bp_current_component();
 
 		// No current component (when does this happen?)
-		if ( empty( $current_component ) ) {
-			$title = _x( 'Directory', 'component directory title', 'buddypress' );
-		} else {
-			$title = bp_get_directory_title( $current_component );
-		}
+		$title_parts = array( _x( 'Directory', 'component directory title', 'buddypress' ) );
 
+		if ( ! empty( $current_component ) ) {
+			$title_parts = array( bp_get_directory_title( $current_component ) );
+ 		}
+
 	// Sign up page
 	} elseif ( bp_is_register_page() ) {
-		$title = __( 'Create an Account', 'buddypress' );
+		$title_parts = array( __( 'Create an Account', 'buddypress' ) );
 
 	// Activation page
 	} elseif ( bp_is_activation_page() ) {
-		$title = __( 'Activate your Account', 'buddypress' );
+		$title_parts = array( __( 'Activate your Account', 'buddypress' ) );
 
 	// Group creation page
 	} elseif ( bp_is_group_create() ) {
-		$title = __( 'Create a Group', 'buddypress' );
+		$title_parts = array( __( 'Create a Group', 'buddypress' ) );
 
 	// Blog creation page
 	} elseif ( bp_is_create_blog() ) {
-		$title = __( 'Create a Site', 'buddypress' );
+		$title_parts = array( __( 'Create a Site', 'buddypress' ) );
 	}
 
-	// Some BP nav items contain item counts. Remove them
-	$title = preg_replace( '|<span>[0-9]+</span>|', '', $title );
+	// Strip spans
+	$title_parts = array_map( '_bp_strip_spans_from_title', $title_parts );
 
-	return apply_filters( 'bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation );
+	// sep on right, so reverse the order
+	if ( 'right' == $seplocation ) {
+		$title_parts = array_reverse( $title_parts );
+	}
+
+	// Get the blog name, so we can check if the original $title included it
+	$blogname = get_bloginfo( 'name', 'display' );
+
+	/**
+	 * Are we going to fake 'title-tag' theme functionality?
+	 *
+	 * @link https://buddypress.trac.wordpress.org/ticket/6107
+	 * @see wp_title()
+	 */
+	$title_tag_compatibility = (bool) ( ! empty( $_wp_theme_features['title-tag'] ) );
+	$original_title          = bp_core_get_original_wp_title();
+	if ( ! empty( $original_title ) ) {
+		$blogname_included   = strpos( $original_title, $blogname, strlen( $original_title ) - strlen( $blogname ) );
+	} else {
+		$blogname_included   = false;
+	}
+	$blogname_added          = false;
+
+	// Append the site title to title parts if theme supports title tag
+	if ( ( true === $title_tag_compatibility ) || false !== $blogname_included ) {
+		$title_parts[] = $blogname;
+
+		if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
+			$title_parts[] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
+		}
+
+		$blogname_added = true;
+	}
+
+	// Pad the separator with 1 space on each side
+	$prefix = str_pad( $sep, strlen( $sep ) + 2, ' ', STR_PAD_BOTH );
+
+	// Join the parts together
+	$new_title = join( $prefix, array_filter( $title_parts ) );
+
+	// Append the prefix for pre `title-tag` compatibility
+	if ( false === $blogname_added ) {
+		$new_title = $new_title . $prefix;
+	}
+
+	/**
+	 * @param  string the BuddyPress page title
+	 * @param  string $title the original WordPress page title
+	 * @param  string $sep the title parts separator
+	 * @param  string $seplocation Location of the separator (left or right).
+	 */
+	return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation );
 }
-add_filter( 'wp_title', 'bp_modify_page_title', 10, 3 );
+add_filter( 'wp_title', 'bp_modify_page_title', 20, 3 );
 add_filter( 'bp_modify_page_title', 'wptexturize'     );
 add_filter( 'bp_modify_page_title', 'convert_chars'   );
 add_filter( 'bp_modify_page_title', 'esc_html'        );
 
 /**
+ * Helper function to stash the contents of `wp_title()` before some plugins
+ * but after core themes.
+ *
+ * This is an awful hack that should go away once we stop supporting usage of
+ * the `wp_title` filter in BuddyPress.
+ *
+ * @since BuddyPress 2.2.2
+ *
+ * @see bp_modify_page_title()
+ */
+function bp_core_get_original_wp_title( $title = '' ) {
+	static $the_title = null;
+
+	if ( null === $the_title ) {
+		$the_title = $title;
+	}
+
+	return $the_title;
+}
+add_filter( 'wp_title', 'bp_core_get_original_wp_title', 11 );
+
+/**
  * Add BuddyPress-specific items to the wp_nav_menu.
  *
  * @since BuddyPress (1.9.0)
