Skip to:
Content

BuddyPress.org

Changeset 3923


Ignore:
Timestamp:
01/25/2011 10:23:05 PM (16 years ago)
Author:
johnjamesjacoby
Message:

Fix incorrect title tag when components are not in root directory

Location:
trunk/bp-core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-component.php

    r3922 r3923  
    220220        }
    221221
    222 
     222        /**
     223         * Setup the component title
     224         *
     225         * @since Buddypress {unknown}
     226         *
     227         * @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'
     228         */
    223229        function _setup_title( ) {
    224                
     230                do_action(  'bp_' . $this->id . '_setup_title' );
    225231        }
    226232
  • trunk/bp-core/bp-core-hooks.php

    r3917 r3923  
    2424// Setup the navigation menu
    2525add_action( 'bp_init',    'bp_setup_nav',            8 );
     26
     27// Setup the title
     28add_action( 'bp_init',    'bp_setup_title',          8 );
    2629
    2730// Setup widgets
  • trunk/bp-core/bp-core-template.php

    r3918 r3923  
    233233        // A single item of a component
    234234        } elseif ( bp_is_single_item() ) {
    235                 $title = ucwords( $bp->current_component ) . ' | ' . $bp->bp_options_title . ' | '; // . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'];
     235                $title = bp_get_name_from_root_slug() . ' | ' . $bp->bp_options_title . ' | ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'];
    236236
    237237        // An index or directory
    238238        } elseif ( bp_is_directory() ) {
    239                 if ( !$bp->current_component )
    240                         $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
     239                if ( !bp_current_component() )
     240                        $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->members->slug ) );
    241241                else
    242                         $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
     242                        $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
    243243
    244244        // Sign up page
     
    621621        }
    622622
     623/**
     624 * Return the component name based on the current root slug
     625 *
     626 * @since BuddyPress {r3923}
     627 * @global obj $bp
     628 * @param str $root_slug Needle to our active component haystack
     629 * @return mixed False if none found, component name if found
     630 */
     631function bp_get_name_from_root_slug( $root_slug = '' ) {
     632
     633        // If no slug is passed, look at current_component
     634        if ( empty( $root_slug ) ) {
     635                global $bp;
     636                $root_slug = $bp->current_component;
     637        }
     638
     639        // No current component or root slug, so flee
     640        if ( empty( $root_slug ) )
     641                return false;
     642
     643        // Loop through active components and look for a match
     644        foreach ( $bp->active_components as $component => $id )
     645                if (    isset( $bp->{$component}->root_slug ) &&
     646                                !empty( $bp->{$component}->root_slug ) &&
     647                                $bp->{$component}->root_slug == $root_slug )
     648                        return $bp->{$component}->name;
     649
     650        return false;
     651}
     652
    623653/** is_() functions to determine the current page *****************************/
    624654
Note: See TracChangeset for help on using the changeset viewer.