Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/13/2015 04:45:43 PM (6 years ago)
Author:
imath
Message:

Make sure document/page title tags are correctly generated for BuddyPress pages

  • Remove all the BuddyPress process to create BuddyPress title parts from bp_modify_page_title() and create the new function

bp_get_title_parts() and put this process here. This allowes plugin/theme to directly use it if needed.

  • Keep the filter on wp_title so that themes not supporting the title-tag feature or breadcrumb plugins can still easily get BuddyPress title parts.
  • Filter document_title_parts with a new function bp_modify_document_title_parts() to build the BuddyPress title parts if needed.
  • Both functions bp_modify_page_title() and bp_modify_document_title_parts() are using bp_get_title_parts().

Props slaFFik, mercime, r-a-y, DJPaul

See #6675 (branch 2.4)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/src/bp-core/bp-core-functions.php

    r10110 r10402  
    22972297add_action( 'bp_init', 'bp_remove_adjacent_posts_rel_link' );
    22982298
     2299/**
     2300 * Strip the span count of a menu item or of a title part.
     2301 *
     2302 * @since 2.2.2
     2303 *
     2304 * @param string $title_part Title part to clean up.
     2305 * @return string
     2306 */
     2307function _bp_strip_spans_from_title( $title_part = '' ) {
     2308    $title = $title_part;
     2309    $span = strpos( $title, '<span' );
     2310    if ( false !== $span ) {
     2311        $title = substr( $title, 0, $span - 1 );
     2312    }
     2313    return trim( $title );
     2314}
     2315
    22992316/** Nav Menu ******************************************************************/
    23002317
     
    23482365
    23492366        // Remove <span>number</span>
    2350         $item_name = preg_replace( '/([.0-9]+)/', '', $bp_item['name'] );
    2351         $item_name = trim( strip_tags( $item_name ) );
     2367        $item_name = _bp_strip_spans_from_title( $bp_item['name'] );
    23522368
    23532369        $page_args[ $bp_item['slug'] ] = (object) array(
Note: See TracChangeset for help on using the changeset viewer.