BP_Groups_Component::setup_canonical_stack()
Set up canonical stack for this component.
Description Description
Source Source
File: bp-groups/classes/class-bp-groups-component.php
public function setup_canonical_stack() { if ( ! bp_is_groups_component() ) { return; } if ( empty( $this->current_group ) ) { return; } /** * Filters the default groups extension. * * @since 1.6.0 * * @param string $value BP_GROUPS_DEFAULT_EXTENSION constant if defined, * else 'home'. */ $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ); $bp = buddypress(); // If the activity component is not active and the current group has no custom front, members are displayed in the home nav. if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) { $this->default_extension = 'home'; } if ( ! bp_current_action() ) { $bp->current_action = $this->default_extension; } // Prepare for a redirect to the canonical URL. $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group ); if ( bp_current_action() ) { $bp->canonical_stack['action'] = bp_current_action(); } /** * If there's no custom front.php template for the group, we need to make sure the canonical stack action * is set to 'home' in these 2 cases: * * - the current action is 'activity' (eg: site.url/groups/single/activity) and the Activity component is active * - the current action is 'members' (eg: site.url/groups/single/members) and the Activity component is *not* active. */ if ( ! $this->current_group->front_template && ( bp_is_current_action( 'activity' ) || ( ! bp_is_active( 'activity' ) && bp_is_current_action( 'members' ) ) ) ) { $bp->canonical_stack['action'] = 'home'; } if ( ! empty( $bp->action_variables ) ) { $bp->canonical_stack['action_variables'] = bp_action_variables(); } // When viewing the default extension, the canonical URL should not have // that extension's slug, unless more has been tacked onto the URL via // action variables. if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) { unset( $bp->canonical_stack['action'] ); } }
Changelog Changelog
Version | Description |
---|---|
2.1.0 | Introduced. |