BP_Members_Component::setup_canonical_stack()
Set up canonical stack for this component.
Description
Source
File: bp-members/classes/class-bp-members-component.php
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.