Skip to:
Content

BuddyPress.org

Changeset 7437


Ignore:
Timestamp:
10/17/2013 04:04:41 PM (13 years ago)
Author:
boonebgorges
Message:

Canonical URL detection should be sensitive to page_on_front

When a BP directory is set to page_on_front, it should no longer be accessible
at the regular directory URL (to avoid duplicate URLs for the same content).

A special exception is required for the Register page. Because BP blocks access
to Register for logged-in users, the canonical redirect for Register when
viewed by a logged-in user must be something other than the front page. As in
bp_core_screen_signup(), we use the Members directory in this case (a page we
can be reasonably sure will always be present).

Fixes #5199

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-catchuri.php

    r7291 r7437  
    622622    extract( $r );
    623623
     624    // Special case: when a BuddyPress directory (eg example.com/members)
     625    // is set to be the front page, ensure that the current canonical URL
     626    // is the home page URL.
     627    if ( 'page' == get_option( 'show_on_front' ) && $page_on_front = (int) get_option( 'page_on_front' ) ) {
     628        $front_page_component = array_search( $page_on_front, bp_core_get_directory_page_ids() );
     629
     630        // If requesting the front page component directory, canonical
     631        // URL is the front page
     632        if ( false !== $front_page_component && is_page( $page_on_front ) ) {
     633            $bp->canonical_stack['canonical_url'] = trailingslashit( bp_get_root_domain() );
     634
     635        // Except when the front page is set to the registration page
     636        // and the current user is logged in. In this case we send to
     637        // the members directory to avoid redirect loops
     638        } else if ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
     639            $bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
     640        }
     641    }
     642
    624643    if ( empty( $bp->canonical_stack['canonical_url'] ) ) {
    625644        // Build the URL in the address bar
Note: See TracChangeset for help on using the changeset viewer.