Zack Tollman (@tollmanz)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • Zack Tollman
    Participant

    @tollmanz

    Hi there!

    I just updated to bbPress 2.4 and experienced the same problem. All titles not on bbPress pages were rendered as blank titles.

    It seems bbPress 2.4 introduced a new function that filters the wp_title function. As a temporary workaround that does not required bbPress plugin file changes, I have added the following to my theme’s functions.php:

    /**
     * Restore non bbPress page titles.
     *
     * v2.4 of bbPress introduced a bug where titles for all non-bbPress pages were blank. This function restores order
     * without overwriting the bbPress core files. It uses the exact same function as bbPress for the titles with one
     * change: if none of the bbPress queries match, it returns the original title.
     *
     * The function first removes the bbPress filter that performs this action, then uses it's own routine to determine the
     * title.
     *
     * @param  string    $title          Optional. The title (not used).
     * @param  string    $sep            Optional, default is '»'. How to separate the various items within the page title.
     * @param  string    $seplocation    Optional. Direction to display title, 'right'.
     * @return string                    Modified title.
     */
    function my_prefix_bbp_title( $title, $sep, $seplocation ) {
    	// Get rid of the core "bbp_title" filter callback
    	remove_filter( 'wp_title', 'bbp_title', 10, 3 );
    
    	// Store original title to compare
    	$_title = $title;
    
    	// Title array
    	$title = array();
    
    	/** Archives **************************************************************/
    
    	// Forum Archive
    	if ( bbp_is_forum_archive() ) {
    		$title['text'] = bbp_get_forum_archive_title();
    
    	// Topic Archive
    	} elseif ( bbp_is_topic_archive() ) {
    		$title['text'] = bbp_get_topic_archive_title();
    
    	/** Edit ******************************************************************/
    
    	// Forum edit page
    	} elseif ( bbp_is_forum_edit() ) {
    		$title['text']   = bbp_get_forum_title();
    		$title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' );
    
    	// Topic edit page
    	} elseif ( bbp_is_topic_edit() ) {
    		$title['text']   = bbp_get_topic_title();
    		$title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' );
    
    	// Reply edit page
    	} elseif ( bbp_is_reply_edit() ) {
    		$title['text']   = bbp_get_reply_title();
    		$title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' );
    
    	// Topic tag edit page
    	} elseif ( bbp_is_topic_tag_edit() ) {
    		$title['text']   = bbp_get_topic_tag_name();
    		$title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
    
    	/** Singles ***************************************************************/
    
    	// Forum page
    	} elseif ( bbp_is_single_forum() ) {
    		$title['text']   = bbp_get_forum_title();
    		$title['format'] = esc_attr__( 'Forum: %s', 'bbpress' );
    
    	// Topic page
    	} elseif ( bbp_is_single_topic() ) {
    		$title['text']   = bbp_get_topic_title();
    		$title['format'] = esc_attr__( 'Topic: %s', 'bbpress' );
    
    	// Replies
    	} elseif ( bbp_is_single_reply() ) {
    		$title['text']   = bbp_get_reply_title();
    
    	// Topic tag page
    	} elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) {
    		$title['text']   = bbp_get_topic_tag_name();
    		$title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
    
    	/** Users *****************************************************************/
    
    	// Profile page
    	} elseif ( bbp_is_single_user() ) {
    
    		// Current users profile
    		if ( bbp_is_user_home() ) {
    			$title['text'] = esc_attr__( 'Your Profile', 'bbpress' );
    
    		// Other users profile
    		} else {
    			$title['text']   = get_userdata( bbp_get_user_id() )->display_name;
    			$title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
    		}
    
    	// Profile edit page
    	} elseif ( bbp_is_single_user_edit() ) {
    
    		// Current users profile
    		if ( bbp_is_user_home_edit() ) {
    			$title['text']   = esc_attr__( 'Edit Your Profile', 'bbpress' );
    
    		// Other users profile
    		} else {
    			$title['text']   = get_userdata( bbp_get_user_id() )->display_name;
    			$title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
    		}
    
    	/** Views *****************************************************************/
    
    	// Views
    	} elseif ( bbp_is_single_view() ) {
    		$title['text']   = bbp_get_view_title();
    		$title['format'] = esc_attr__( 'View: %s', 'bbpress' );
    
    	/** Search ****************************************************************/
    
    	// Search
    	} elseif ( bbp_is_search() ) {
    		$title['text'] = bbp_get_search_title();
    	} else {
    		return $_title;
    	}
    
    	// This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
    	$title = apply_filters( 'bbp_raw_title_array', $title );
    
    	// Set title array defaults
    	$title = bbp_parse_args( $title, array(
    		'text'   => '',
    		'format' => '%s'
    	), 'title' );
    
    	// Get the formatted raw title
    	$title = sprintf( $title['format'], $title['text'] );
    
    	// Filter the raw title
    	$title = apply_filters( 'bbp_raw_title', $title, $sep, $seplocation );
    
    	// Compare new title with original title
    	if ( $title === $_title )
    		return $title;
    
    	// Temporary separator, for accurate flipping, if necessary
    	$t_sep  = '%WP_TITILE_SEP%';
    	$prefix = '';
    
    	if ( !empty( $title ) )
    		$prefix = " $sep ";
    
    	// sep on right, so reverse the order
    	if ( 'right' === $seplocation ) {
    		$title_array = array_reverse( explode( $t_sep, $title ) );
    		$title       = implode( " $sep ", $title_array ) . $prefix;
    
    	// sep on left, do not reverse
    	} else {
    		$title_array = explode( $t_sep, $title );
    		$title       = $prefix . implode( " $sep ", $title_array );
    	}
    
    	// Filter and return
    	return apply_filters( 'bbp_title', $title, $sep, $seplocation );
    }
    
    add_filter( 'wp_title', 'my_prefix_bbp_title', 9, 3 );
Viewing 1 replies (of 1 total)