Skip to:
Content

bbPress.org

Changeset 5018


Ignore:
Timestamp:
07/10/2013 07:28:21 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Improve the flexibility of bbp_title() by allowing all data to be filtered. Props alex-ye. Fixes #1764.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/common/template-tags.php

    r5010 r5018  
    25092509    $_title = $title;
    25102510
     2511    // Title array
     2512    $title = array();
     2513
    25112514    /** Archives **************************************************************/
    25122515
    25132516    // Forum Archive
    25142517    if ( bbp_is_forum_archive() ) {
    2515         $title = bbp_get_forum_archive_title();
     2518        $title['text'] = bbp_get_forum_archive_title();
    25162519
    25172520    // Topic Archive
    25182521    } elseif ( bbp_is_topic_archive() ) {
    2519         $title = bbp_get_topic_archive_title();
     2522        $title['text'] = bbp_get_topic_archive_title();
     2523
     2524    /** Edit ******************************************************************/
     2525
     2526    // Forum edit page
     2527    } elseif ( bbp_is_forum_edit() ) {
     2528        $title['text']   = bbp_get_forum_title();
     2529        $title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' );
     2530
     2531    // Topic edit page
     2532    } elseif ( bbp_is_topic_edit() ) {
     2533        $title['text']   = bbp_get_topic_title();
     2534        $title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' );
     2535
     2536    // Reply edit page
     2537    } elseif ( bbp_is_reply_edit() ) {
     2538        $title['text']   = bbp_get_reply_title();
     2539        $title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' );
     2540
     2541    // Topic tag edit page
     2542    } elseif ( bbp_is_topic_tag_edit() ) {
     2543        $title['text']   = bbp_get_topic_tag_name();
     2544        $title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
    25202545
    25212546    /** Singles ***************************************************************/
     
    25232548    // Forum page
    25242549    } elseif ( bbp_is_single_forum() ) {
    2525         $title = sprintf( __( 'Forum: %s', 'bbpress' ), bbp_get_forum_title() );
     2550        $title['text']   = bbp_get_forum_title();
     2551        $title['format'] = esc_attr__( 'Forum: %s', 'bbpress' );
    25262552
    25272553    // Topic page
    25282554    } elseif ( bbp_is_single_topic() ) {
    2529         $title = sprintf( __( 'Topic: %s', 'bbpress' ), bbp_get_topic_title() );
     2555        $title['text']   = bbp_get_topic_title();
     2556        $title['format'] = esc_attr__( 'Topic: %s', 'bbpress' );
    25302557
    25312558    // Replies
    25322559    } elseif ( bbp_is_single_reply() ) {
    2533         $title = bbp_get_reply_title();
    2534 
    2535     // Topic tag page (or edit)
    2536     } elseif ( bbp_is_topic_tag() || bbp_is_topic_tag_edit() || get_query_var( 'bbp_topic_tag' ) ) {
    2537         $term  = get_queried_object();
    2538         $title = sprintf( __( 'Topic Tag: %s', 'bbpress' ), $term->name );
     2560        $title['text']  = bbp_get_reply_title();
     2561
     2562    // Topic tag page
     2563    } elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) {
     2564        $title['text']   = bbp_get_topic_tag_name();
     2565        $title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
    25392566
    25402567    /** Users *****************************************************************/
     
    25452572        // Current users profile
    25462573        if ( bbp_is_user_home() ) {
    2547             $title = __( 'Your Profile', 'bbpress' );
     2574            $title['text'] = esc_attr__( 'Your Profile', 'bbpress' );
    25482575
    25492576        // Other users profile
    25502577        } else {
    2551             $userdata = get_userdata( bbp_get_user_id() );
    2552             $title    = sprintf( __( '%s\'s Profile', 'bbpress' ), $userdata->display_name );
     2578            $title['text']   = get_userdata( bbp_get_user_id() )->display_name;
     2579            $title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
    25532580        }
    25542581
     
    25582585        // Current users profile
    25592586        if ( bbp_is_user_home_edit() ) {
    2560             $title = __( 'Edit Your Profile', 'bbpress' );
     2587            $title['text']   = esc_attr__( 'Edit Your Profile', 'bbpress' );
    25612588
    25622589        // Other users profile
    25632590        } else {
    2564             $userdata = get_userdata( bbp_get_user_id() );
    2565             $title    = sprintf( __( 'Edit %s\'s Profile', 'bbpress' ), $userdata->display_name );
     2591            $title['text']   = get_userdata( bbp_get_user_id() )->display_name;
     2592            $title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
    25662593        }
    25672594
     
    25702597    // Views
    25712598    } elseif ( bbp_is_single_view() ) {
    2572         $title = sprintf( __( 'View: %s', 'bbpress' ), bbp_get_view_title() );
     2599        $title['text']   = bbp_get_view_title();
     2600        $title['format'] = esc_attr__( 'View: %s', 'bbpress' );
    25732601
    25742602    /** Search ****************************************************************/
     
    25762604    // Search
    25772605    } elseif ( bbp_is_search() ) {
    2578         $title = bbp_get_search_title();
     2606        $title['text'] = bbp_get_search_title();
    25792607    }
     2608
     2609    // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
     2610    $title = apply_filters( 'bbp_raw_title_array', $title );
     2611
     2612    // Set title array defaults
     2613    $title = bbp_parse_args( $title, array(
     2614        'text'   => '',
     2615        'format' => '%s'
     2616    ), 'title' );
     2617
     2618    // Get the formatted raw title
     2619    $title = sprintf( $title['format'], $title['text'] );
    25802620
    25812621    // Filter the raw title
Note: See TracChangeset for help on using the changeset viewer.