Changeset 5895
- Timestamp:
- 03/09/2012 03:25:20 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
bp-core/bp-core-buddybar.php (modified) (3 diffs)
-
bp-core/bp-core-catchuri.php (modified) (3 diffs)
-
bp-groups/bp-groups-loader.php (modified) (1 diff)
-
bp-loader.php (modified) (1 diff)
-
bp-members/bp-members-loader.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-buddybar.php
r5868 r5895 65 65 66 66 // Look for current component 67 if ( bp_is_current_component( $slug ) && !bp_current_action() ) { 68 if ( !is_object( $screen_function[0] ) ) 69 add_action( 'bp_screens', $screen_function ); 70 else 71 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 ); 72 73 if ( !empty( $default_subnav_slug ) ) { 74 $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r ); 75 $bp->redirect_stack['action'] = $bp->current_action; 67 if ( bp_is_current_component( $slug ) ) { 68 if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) ) { 69 // The requested URL has explicitly included the default subnav (eg 70 // example.com/members/membername/activity/just-me/). The canonical 71 // version will not contain this subnav slug. 72 unset( $bp->canonical_stack['action'] ); 73 } else if ( !bp_current_action() ) { 74 if ( !is_object( $screen_function[0] ) ) 75 add_action( 'bp_screens', $screen_function ); 76 else 77 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 ); 78 79 if ( !empty( $default_subnav_slug ) ) { 80 $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r ); 81 } 76 82 } 77 83 78 84 // Look for current item 79 } elseif ( bp_is_current_item( $slug ) && !bp_current_action() ) { 80 if ( !is_object( $screen_function[0] ) ) 81 add_action( 'bp_screens', $screen_function ); 82 else 83 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 ); 84 85 if ( !empty( $default_subnav_slug ) ) { 86 $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r ); 87 $bp->redirect_stack['action'] = $bp->current_action; 85 } elseif ( bp_is_current_item( $slug ) ) { 86 if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) ) { 87 // The requested URL has explicitly included the default subnav (eg 88 // example.com/members/membername/activity/just-me/). The canonical 89 // version will not contain this subnav slug. 90 unset( $bp->canonical_stack['action'] ); 91 } else if ( !bp_current_action() ) { 92 if ( !is_object( $screen_function[0] ) ) 93 add_action( 'bp_screens', $screen_function ); 94 else 95 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 ); 96 97 if ( !empty( $default_subnav_slug ) ) { 98 $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r ); 99 } 88 100 } 89 101 } … … 109 121 $r = wp_parse_args( $args, $defaults ); 110 122 extract( $r, EXTR_SKIP ); 111 123 112 124 if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) { 113 125 if ( !is_object( $function[0] ) ) … … 119 131 $bp->bp_nav[$parent_slug]['screen_function'] = &$screen_function; 120 132 121 // If the current_action has been set to the default_subnav_slug, it will be reflected 122 // in the redirect_stack. Unset the action manually so that the new nav default can be set 123 if ( !empty( $bp->redirect_stack['action'] ) && $bp->redirect_stack['action'] == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) { 124 $bp->current_action = ''; 125 } 126 127 if ( bp_is_current_component( $parent_slug ) && !bp_current_action() ) { 128 if ( !is_object( $screen_function[0] ) ) { 129 add_action( 'bp_screens', $screen_function ); 133 if ( bp_is_current_component( $parent_slug ) ) { 134 135 // The only way to tell whether to set the subnav is to peek at the unfiltered_uri 136 // Find the component 137 $component_uri_key = array_search( $parent_slug, $bp->unfiltered_uri ); 138 139 if ( false !== $component_uri_key ) { 140 if ( !empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) { 141 $unfiltered_action = $bp->unfiltered_uri[$component_uri_key + 1]; 142 } 143 } 144 145 if ( empty( $unfiltered_action ) ) { 146 // No subnav item has been requested in the URL, so set a new nav default 147 if ( !bp_is_current_action( $subnav_slug ) ) { 148 if ( !is_object( $screen_function[0] ) ) { 149 add_action( 'bp_screens', $screen_function ); 150 } else { 151 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 152 } 153 154 $bp->current_action = $subnav_slug; 155 unset( $bp->canonical_stack['action'] ); 156 } 157 } else if ( $unfiltered_action == $subnav_slug ) { 158 // The URL is explicitly requesting the new subnav item, but should be 159 // directed to the canonical URL 160 unset( $bp->canonical_stack['action'] ); 130 161 } else { 131 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );132 }133 134 if ( $subnav_slug ) {135 $bp->current_action = $subnav_slug;136 $bp->redirect_stack['action'] = $bp->current_action;137 }138 }162 // In all other cases (including the case where the original subnav item 163 // is explicitly called in the URL), the canonical URL will contain the 164 // subnav slug 165 $bp->canonical_stack['action'] = bp_current_action(); 166 } 167 } 168 169 return; 139 170 } 140 171 -
trunk/bp-core/bp-core-catchuri.php
r5870 r5895 521 521 * 522 522 * This function ensures that requests for BuddyPress content are always redirected to their 523 * most specific, trailingslashed versions. 523 * canonical versions. Canonical versions are always trailingslashed, and are typically the most 524 * general possible versions of the URL - eg, example.com/groups/mygroup/ instead of 525 * example.com/groups/mygroup/home/ 524 526 * 525 527 * @since 1.6 526 * @see BP_Members_Component::setup_globals() where $bp-> redirect_stack['base_url'] and528 * @see BP_Members_Component::setup_globals() where $bp->canonical_stack['base_url'] and 527 529 * ['component'] may be set 528 * @see bp_core_new_nav_item() where $bp-> redirect_stack['action'] may be set530 * @see bp_core_new_nav_item() where $bp->canonical_stack['action'] may be set 529 531 */ 530 532 function bp_redirect_canonical() { … … 549 551 $req_url_clean = $url_stack[0]; 550 552 551 // Processthe redirect stack552 if ( isset( $bp-> redirect_stack['base_url'] ) ) {553 $url_stack[0] = $bp-> redirect_stack['base_url'];554 } 555 556 if ( isset( $bp-> redirect_stack['component'] ) ) {557 $url_stack[0] = trailingslashit( $url_stack[0] . $bp-> redirect_stack['component'] );558 } 559 560 if ( isset( $bp-> redirect_stack['action'] ) ) {561 $url_stack[0] = trailingslashit( $url_stack[0] . $bp-> redirect_stack['action'] );562 } 563 564 if ( !empty( $bp-> redirect_stack['action_variables'] ) ) {565 foreach( (array) $bp-> redirect_stack['action_variables'] as $av ) {553 // Build the canonical URL out of the redirect stack 554 if ( isset( $bp->canonical_stack['base_url'] ) ) { 555 $url_stack[0] = $bp->canonical_stack['base_url']; 556 } 557 558 if ( isset( $bp->canonical_stack['component'] ) ) { 559 $url_stack[0] = trailingslashit( $url_stack[0] . $bp->canonical_stack['component'] ); 560 } 561 562 if ( isset( $bp->canonical_stack['action'] ) ) { 563 $url_stack[0] = trailingslashit( $url_stack[0] . $bp->canonical_stack['action'] ); 564 } 565 566 if ( !empty( $bp->canonical_stack['action_variables'] ) ) { 567 foreach( (array) $bp->canonical_stack['action_variables'] as $av ) { 566 568 $url_stack[0] = trailingslashit( $url_stack[0] . $av ); 567 569 } … … 570 572 // Add trailing slash 571 573 $url_stack[0] = trailingslashit( $url_stack[0] ); 572 574 573 575 // Only redirect if we've assembled a URL different from the request 574 576 if ( $url_stack[0] !== $req_url_clean ) { -
trunk/bp-groups/bp-groups-loader.php
r5868 r5895 164 164 } 165 165 166 if ( bp_is_groups_component() && !empty( $this->current_group ) && !bp_current_action() ) { 167 $bp->current_action = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ); 166 if ( bp_is_groups_component() && !empty( $this->current_group ) ) { 167 168 // Prepare for a redirect to the canonical URL 169 $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group ); 168 170 169 // Prepare for a redirect to the canonical URL 170 $bp->redirect_stack['base_url'] = bp_get_group_permalink( $this->current_group ); 171 $bp->redirect_stack['action'] = bp_current_action(); 171 if ( bp_current_action() ) { 172 $bp->canonical_stack['action'] = bp_current_action(); 173 } 174 175 if ( !empty( $bp->action_variables ) ) { 176 $bp->canonical_stack['action_variables'] = bp_action_variables(); 177 } 178 179 $groups_default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ); 180 181 if ( !bp_current_action() ) { 182 $bp->current_action = $groups_default_extension; 183 } else if ( bp_is_current_action( $groups_default_extension ) && !empty( $bp->action_variables ) ) { 184 unset( $bp->canonical_stack['action'] ); 185 } 172 186 } 173 187 -
trunk/bp-loader.php
r5866 r5895 165 165 */ 166 166 public $no_status_set = false; 167 168 /** 169 * @var array The canonical URI stack 170 * @see bp_redirect_canonical() 171 * @see bp_core_new_nav_item() 172 */ 173 public $canonical_stack = array(); 167 174 168 175 /** Components ************************************************************/ -
trunk/bp-members/bp-members-loader.php
r5705 r5895 113 113 $bp->default_component = BP_DEFAULT_COMPONENT; 114 114 } 115 116 if ( !bp_current_component() && bp_displayed_user_id() ) { 117 $bp->current_component = $bp->default_component; 115 116 if ( bp_displayed_user_id() ) { 117 $bp->canonical_stack['base_url'] = bp_displayed_user_domain(); 118 119 if ( bp_current_component() ) { 120 $bp->canonical_stack['component'] = bp_current_component(); 121 } 118 122 119 // Prepare for a redirect to the canonical URL 120 $bp->redirect_stack['base_url'] = bp_displayed_user_domain(); 121 $bp->redirect_stack['component'] = $bp->default_component; 123 if ( bp_current_action() ) { 124 $bp->canonical_stack['action'] = bp_current_action(); 125 } 126 127 if ( !empty( $bp->action_variables ) ) { 128 $bp->canonical_stack['action_variables'] = bp_action_variables(); 129 } 130 131 if ( !bp_current_component() ) { 132 $bp->current_component = $bp->default_component; 133 } else if ( bp_is_current_component( $bp->default_component ) && !bp_current_action() ) { 134 // The canonical URL will not contain the default component 135 unset( $bp->canonical_stack['component'] ); 136 } 122 137 } 123 138 }
Note: See TracChangeset
for help on using the changeset viewer.