Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/09/2011 09:19:26 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Better handling of title attributes. Props GautamGupta via Google Code-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-functions.php

    r2787 r2788  
    19881988
    19891989/**
    1990  * Custom page title for bbPress User Profile Pages
    1991  *
    1992  * @since bbPress (r2688)
     1990 * Custom page title for bbPress pages
     1991 *
     1992 * @since bbPress (r2788)
    19931993 *
    19941994 * @param string $title Optional. The title (not used).
    1995  * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
     1995 * @param string $sep Optional, default is '»'. How to separate the
     1996 *                     various items within the page title.
    19961997 * @param string $seplocation Optional. Direction to display title, 'right'.
    19971998 * @uses bbp_is_user_profile_page() To check if it's a user profile page
     
    19992000 * @uses get_query_var() To get the user id
    20002001 * @uses get_userdata() To get the user data
    2001  * @uses apply_filters() Calls 'bbp_profile_page_wp_raw_title' with the user's
    2002  *                        display name, separator and separator location
     2002 * @uses apply_filters() Calls 'bbp_raw_title' with the title
    20032003 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
    20042004 *                        separator and separator location
    20052005 * @return string The tite
    20062006 */
    2007 function bbp_profile_page_title( $title = '', $sep = '»', $seplocation = '' ) {
    2008     if ( !bbp_is_user_profile_page() && !bbp_is_user_profile_edit() )
    2009         return;
    2010 
    2011     $userdata = get_userdata( get_query_var( 'bbp_user_id' ) );
    2012     $title    = apply_filters( 'bbp_profile_page_wp_raw_title', $userdata->display_name, $sep, $seplocation );
    2013     $t_sep    = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
    2014 
     2007function bbp_title( $title = '', $sep = '»', $seplocation = '' ) {
     2008    global $bbp;
     2009
     2010    $_title = $title;
     2011
     2012    // Profile page
     2013    if ( bbp_is_user_profile_page() ) {
     2014
     2015        if ( bbp_is_user_home() ) {
     2016            $title = __( 'Your Profile', 'bbpress' );
     2017        } else {
     2018            $userdata = get_userdata( get_query_var( 'bbp_user_id' ) );
     2019            $title    = sprintf( __( '%s\'s Profile', 'bbpress' ), $userdata->display_name );
     2020        }
     2021
     2022    // Profile edit page
     2023    } elseif ( bbp_is_user_profile_edit() ) {
     2024
     2025        if ( bbp_is_user_home() ) {
     2026            $title = __( 'Edit Your Profile', 'bbpress' );
     2027        } else {
     2028            $userdata = get_userdata( get_query_var( 'bbp_user_id' ) );
     2029            $title    = sprintf( __( 'Edit %s\'s Profile', 'bbpress' ), $userdata->display_name );
     2030        }
     2031
     2032    // Forum page
     2033    } elseif ( bbp_is_forum() ) {
     2034
     2035        $title = sprintf( __( 'Forum: %s', 'bbpress' ), bbp_get_forum_title() );
     2036
     2037    // Topic page
     2038    } elseif ( bbp_is_topic() ) {
     2039
     2040        $title = sprintf( __( 'Topic: %s', 'bbpress' ), bbp_get_topic_title() );
     2041
     2042    // Replies
     2043    } elseif ( bbp_is_reply() ) {
     2044
     2045        // Normal reply titles already have "Reply To: ", so we shouldn't add our own
     2046        $title = bbp_get_reply_title();
     2047
     2048    } elseif ( is_tax( $bbp->topic_tag_id ) ) {
     2049
     2050        $term  = get_queried_object();
     2051        $title = sprintf( __( 'Topic Tag: %s', 'bbpress' ), $term->name );
     2052
     2053    }
     2054
     2055    $title  = apply_filters( 'bbp_raw_title', $title, $sep, $seplocation );
     2056
     2057    if ( $title == $_title )
     2058        return $title;
     2059
     2060    // Temporary separator, for accurate flipping, if necessary
     2061    $t_sep  = '%WP_TITILE_SEP%';
    20152062    $prefix = '';
     2063
    20162064    if ( !empty( $title ) )
    20172065        $prefix = " $sep ";
     
    20272075    }
    20282076
    2029     $title = apply_filters( 'bbp_profile_page_wp_title', $title, $sep, $seplocation );
     2077    $title = apply_filters( 'bbp_title', $title, $sep, $seplocation );
    20302078
    20312079    return $title;
Note: See TracChangeset for help on using the changeset viewer.