bp_modify_document_title_parts( array $title = array() )

Filter the document title for BuddyPress pages.


Parameters Parameters

$title

(array) (Optional) The WordPress document title parts.

Default value: array()


Top ↑

Return Return

(array) the unchanged title parts or the BuddyPress ones


Source Source

File: bp-core/bp-core-filters.php

function bp_modify_document_title_parts( $title = array() ) {
	// Get the BuddyPress title parts.
	$bp_title_parts = bp_get_title_parts();

	// If not set, simply return the original title.
	if ( ! $bp_title_parts ) {
		return $title;
	}

	// Get the separator used by wp_get_document_title().
	$sep = apply_filters( 'document_title_separator', '-' );

	// Build the BuddyPress portion of the title.
	// We don't need to sanitize this as WordPress will take care of it.
	$bp_title = array(
		'title' => join( " $sep ", $bp_title_parts )
	);

	// Add the pagination number if needed (not sure if this is necessary).
	if ( isset( $title['page'] ) && ! bp_is_single_activity() ) {
		$bp_title['page'] = $title['page'];
	}

	// Add the sitename if needed.
	if ( isset( $title['site'] ) ) {
		$bp_title['site'] = $title['site'];
	}

	/**
	 * Filters BuddyPress title parts that will be used into the document title.
	 *
	 * @since 2.4.3
	 *
	 * @param array $bp_title The BuddyPress page title parts.
	 * @param array $title    The original WordPress title parts.
	 */
	return apply_filters( 'bp_modify_document_title_parts', $bp_title, $title );
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.4.3 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.