Skip to:
Content

bbPress.org

Changeset 2788


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

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

Location:
branches/plugin/bbp-includes
Files:
5 edited

Legend:

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

    r2787 r2788  
    145145 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}
    146146 * @uses get_post() To get the forum
     147 * @uses apply_filters() Calls 'bbp_get_forum' with the forum, output type and
     148 *                        sanitation filter
    147149 * @return mixed Null if error or forum (in specified form) if success
    148150 */
     
    172174        }
    173175
    174         return apply_filters( 'bbp_get_forum', $forum );
     176        return apply_filters( 'bbp_get_forum', $forum, $output, $filter );
    175177}
    176178
     
    352354 */
    353355function bbp_get_forum_ancestors( $forum_id = 0 ) {
    354         $forum_id = bbp_get_forum_id( $forum_id );
     356        $forum_id  = bbp_get_forum_id( $forum_id );
     357        $ancestors = array();
    355358
    356359        if ( $forum = bbp_get_forum( $forum_id ) ) {
    357                 $ancestors = array();
    358360                while ( 0 !== $forum->post_parent ) {
    359361                        $ancestors[] = $forum->post_parent;
  • 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;
  • branches/plugin/bbp-includes/bbp-hooks.php

    r2786 r2788  
    7373
    7474// Template - Head, foot, errors and notices
    75 add_action( 'wp_head',              'bbp_head'           );
    76 add_action( 'wp_footer',            'bbp_footer'         );
    77 add_action( 'bbp_template_notices', 'bbp_error_messages' );
    78 add_action( 'bbp_template_notices', 'bbp_topic_notices'  );
     75add_action( 'wp_head',              'bbp_head'                 );
     76add_filter( 'wp_title',             'bbp_title',         10, 3 );
     77add_action( 'wp_footer',            'bbp_footer'               );
     78add_action( 'bbp_template_notices', 'bbp_error_messages'       );
     79add_action( 'bbp_template_notices', 'bbp_topic_notices'        );
    7980
    8081// Caps & Roles
     
    9293
    9394// Profile Page
    94 add_filter( 'wp_title',          'bbp_profile_page_title',     10, 3 );
    95 add_action( 'pre_get_posts',     'bbp_pre_get_posts',          1     );
    96 add_action( 'template_redirect', 'bbp_edit_user_handler',      1     );
     95add_action( 'pre_get_posts',     'bbp_pre_get_posts',     1 );
     96add_action( 'template_redirect', 'bbp_edit_user_handler', 1 );
    9797
    9898// Profile Page Messages
  • branches/plugin/bbp-includes/bbp-reply-template.php

    r2787 r2788  
    185185 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}
    186186 * @uses get_post() To get the reply
     187 * @uses apply_filters() Calls 'bbp_get_reply' with the reply, output type and
     188 *                        sanitation filter
    187189 * @return mixed Null if error or reply (in specified form) if success
    188190 */
     
    212214        }
    213215
    214         return $reply;
     216        return apply_filters( 'bbp_get_reply', $reply, $output, $filter );
    215217}
    216218
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r2787 r2788  
    285285 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}
    286286 * @uses get_post() To get the topic
     287 * @uses apply_filters() Calls 'bbp_get_topic' with the topic, output type and
     288 *                        sanitation filter
    287289 * @return mixed Null if error or topic (in specified form) if success
    288290 */
     
    312314        }
    313315
    314         return $topic;
     316        return apply_filters( 'bbp_get_topic', $topic, $output, $filter );
    315317}
    316318
Note: See TracChangeset for help on using the changeset viewer.