bp_modify_document_title_parts

Filter the document title for BuddyPress pages.

Description

(array) bp_modify_document_title_parts( (array) $title = array() ); 

Returns (array)

the unchanged title parts or the BuddyPress ones

Parameters (1)

0. $title — Optional. (array) => array()
The WordPress document title parts.

Usage

  1. if ( !function_exists( 'bp_modify_document_title_parts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-filters.php'; 
  3.  
  4. // The WordPress document title parts. 
  5. $title = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_modify_document_title_parts($title); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-filters.php  
  1. function bp_modify_document_title_parts( $title = array() ) { 
  2. // Get the BuddyPress title parts. 
  3. $bp_title_parts = bp_get_title_parts(); 
  4.  
  5. // If not set, simply return the original title. 
  6. if ( ! $bp_title_parts ) { 
  7. return $title; 
  8.  
  9. // Get the separator used by wp_get_document_title(). 
  10.  
  11. // Build the BuddyPress portion of the title. 
  12. // We don't need to sanitize this as WordPress will take care of it. 
  13. $bp_title = array( 
  14. 'title' => join( " $sep ", $bp_title_parts ) 
  15. ); 
  16.  
  17. // Add the pagination number if needed (not sure if this is necessary). 
  18. if ( isset( $title['page'] ) && ! bp_is_single_activity() ) { 
  19. $bp_title['page'] = $title['page']; 
  20.  
  21. // Add the sitename if needed. 
  22. if ( isset( $title['site'] ) ) { 
  23. $bp_title['site'] = $title['site']; 
  24.  
  25. /** 
  26. * Filters BuddyPress title parts that will be used into the document title. 
  27. * @since 2.4.3 
  28. * @param array $bp_title The BuddyPress page title parts. 
  29. * @param array $title The original WordPress title parts. 
  30. */ 
  31. return apply_filters( 'bp_modify_document_title_parts', $bp_title, $title );