Skip to:
Content

BuddyPress.org

Changeset 5990


Ignore:
Timestamp:
04/14/2012 07:54:22 PM (13 years ago)
Author:
boonebgorges
Message:

When determining canonical URL for items such as groups, don't strip the default extension slug if it's not the last part of the URL. Fixes #4084

Location:
trunk
Files:
2 edited

Legend:

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

    r5935 r5990  
    7979        // (eg: http://example.com/members/membername/activity/just-me/)
    8080        // The canonical version will not contain this subnav slug.
    81         if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) ) {
    82 
    83             // bbPress 2.x uses pretty pagination, so whitelist 'page'
    84             if ( ! bp_is_action_variable( 'page', 0 ) && ! bp_action_variable( 1 ) ) {
    85                 unset( $bp->canonical_stack['action'] );
    86             }
     81        if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) && !bp_action_variable( 0 ) ) {
     82            unset( $bp->canonical_stack['action'] );
    8783        } elseif ( ! bp_current_action() ) {
    8884            $func = is_object( $screen_function[0] ) ? array( &$screen_function[0], $screen_function[1] ) : $screen_function;
     
    115111    $r = wp_parse_args( $args, $defaults );
    116112    extract( $r, EXTR_SKIP );
    117    
     113
    118114    if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
    119115        if ( is_object( $function[0] ) ) {
     
    127123
    128124    if ( bp_is_current_component( $parent_slug ) ) {
    129        
     125
    130126        // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
    131127        // Find the component
    132128        $component_uri_key = array_search( $parent_slug, $bp->unfiltered_uri );
    133        
     129
    134130        if ( false !== $component_uri_key ) {
    135131            if ( !empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) {
     
    146142                    add_action( 'bp_screens', $screen_function, 3 );
    147143                }
    148        
     144
    149145                $bp->current_action = $subnav_slug;
    150146                unset( $bp->canonical_stack['action'] );
     
    302298                        $redirect_to = trailingslashit( bp_displayed_user_domain() . ( 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id ) );
    303299                    }
    304                    
     300
    305301                    $message     = '';
    306302                } else {
     
    308304                    $redirect_to = bp_displayed_user_domain();
    309305                }
    310                
     306
    311307                // Off-limits to this user. Throw an error and redirect to the displayed user's domain
    312308                bp_core_no_access( array(
  • trunk/bp-groups/bp-groups-loader.php

    r5989 r5990  
    172172        if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
    173173
     174            $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
     175
     176            if ( !bp_current_action() ) {
     177                $bp->current_action = $this->default_extension;
     178            }
     179
    174180            // Prepare for a redirect to the canonical URL
    175181            $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
     
    183189            }
    184190
    185             $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
    186 
    187             if ( !bp_current_action() ) {
    188                 $bp->current_action = $this->default_extension;
    189             } else if ( bp_is_current_action( $this->default_extension ) && !empty( $bp->action_variables ) )  {
     191            // When viewing the default extension, the canonical URL should not have
     192            // that extension's slug, unless more has been tacked onto the URL via
     193            // action variables
     194            if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) )  {
    190195                unset( $bp->canonical_stack['action'] );
    191196            }
     197
    192198        }
    193199
Note: See TracChangeset for help on using the changeset viewer.