BP_Members_Component::setup_canonical_stack()
Set up canonical stack for this component.
Description
Source
File: bp-members/classes/class-bp-members-component.php
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | public function setup_canonical_stack() { $bp = buddypress(); /** Default Profile Component **************************************** */ if ( bp_displayed_user_has_front_template() && bp_is_my_profile() ) { $bp ->default_component = 'front' ; } elseif ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) { $bp ->default_component = BP_DEFAULT_COMPONENT; } elseif ( bp_is_active( 'xprofile' ) ) { $bp ->default_component = ( 'xprofile' === $bp ->profile->id ) ? 'profile' : $bp ->profile->id; } elseif ( bp_is_active( 'activity' ) && isset( $bp ->pages->activity ) ) { $bp ->default_component = bp_get_activity_slug(); } else { $bp ->default_component = ( 'xprofile' === $bp ->profile->id ) ? 'profile' : $bp ->profile->id; } // Get the default tab based on the customizer settings. $customizer_option = 'user_default_tab' ; $default_tab = '' ; if ( function_exists( 'bp_nouveau_get_temporary_setting' ) && function_exists( 'bp_nouveau_get_appearance_settings' ) ) { $default_tab = bp_nouveau_get_temporary_setting( $customizer_option ,bp_nouveau_get_appearance_settings( $customizer_option ) ); } $default_tab = bp_is_active( $default_tab ) ? $default_tab : 'profile' ; $bp ->default_component = apply_filters( 'bp_member_default_component' , ( '' === $default_tab ) ? $bp ->default_component : $default_tab ); /** Canonical Component Stack **************************************** */ if ( bp_displayed_user_id() ) { $bp ->canonical_stack[ 'base_url' ] = bp_displayed_user_domain(); if ( bp_current_component() ) { $bp ->canonical_stack[ 'component' ] = bp_current_component(); } if ( bp_current_action() ) { $bp ->canonical_stack[ 'action' ] = bp_current_action(); } if ( ! empty ( $bp ->action_variables ) ) { $bp ->canonical_stack[ 'action_variables' ] = bp_action_variables(); } // Looking at the single member root/home, so assume the default. if ( ! bp_current_component() ) { $bp ->current_component = $bp ->default_component; // The canonical URL will not contain the default component. } elseif ( bp_is_current_component( $bp ->default_component ) && ! bp_current_action() ) { unset( $bp ->canonical_stack[ 'component' ] ); } // If we're on a spammer's profile page, only users with the 'bp_moderate' cap // can view subpages on the spammer's profile. // // users without the cap trying to access a spammer's subnav page will get // redirected to the root of the spammer's profile page. this occurs by // by removing the component in the canonical stack. if ( bp_is_user_spammer( bp_displayed_user_id() ) && ! bp_current_user_can( 'bp_moderate' ) ) { unset( $bp ->canonical_stack[ 'component' ] ); } } } |
Changelog
Version | Description |
---|---|
BuddyPress 2.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.