BP_Members_Component::setup_canonical_stack()
Set up canonical stack for this component.
Description Description
Source 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->default_component = 'front'; } 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; } if ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) { $default_component = BP_DEFAULT_COMPONENT; if ( 'profile' === $default_component ) { $default_component = 'xprofile'; } if ( bp_is_active( $default_component ) ) { $bp->default_component = BP_DEFAULT_COMPONENT; } } /** 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 Changelog
Version | Description |
---|---|
2.1.0 | Introduced. |