Making WordPress.org


Ignore:
Timestamp:
04/03/2015 01:01:47 PM (10 years ago)
Author:
djpaul
Message:

BuddyPress.org/bbPress.org: replace hardcoded URLs with convenience functions for redirects and CSS loading.

These themes can now easily be run on a local dev environment. Until this change, you’ve had to use buddypress.org or bbpress.org (etc) as the domain name for your dev site. This is because the themes had a number of hardcoded redirects and URL detection which assumed the production URLs would always be used.

The change updates the redirects to use home_url, and creates new (filtered) wrapper functions used to determine if the theme is running on buddypress.org or bbpress.org.
This will help integrate the “bb” sites into https://github.com/iandunn/wordpress-meta-environment/.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/extensions.php

    r499 r1468  
    9191    // Redirect /forums/ to /support/
    9292    if ( $uri_chunks[1] === 'forums' && empty( $uri_chunks[2] ) ) {
    93         bp_core_redirect( 'http://buddypress.org/support/' );
     93        bp_core_redirect( home_url( '/support/' ) );
    9494    }
    9595
    9696    // Redirect members directory to root to block heavy paginated user queries
    9797    if ( ( $uri_chunks[1] === 'members' ) && empty( $uri_chunks[2] ) ) {
    98         bp_core_redirect( 'http://buddypress.org' );
     98        bp_core_redirect( home_url( '/' ) );
    9999    }
    100100
    101101    // Redirect old members profile pages to
    102102    if ( ( $uri_chunks[1] === 'community' ) && ( $uri_chunks[2] === 'members' ) && ! empty( $uri_chunks[3] ) ) {
    103         bp_core_redirect( 'http://buddypress.org/members/' . $uri_chunks[3] . '/' );
     103        bp_core_redirect( home_url( '/members/' . $uri_chunks[3] . '/' ) );
    104104    }
    105105
     
    109109        // Single group topic redirect
    110110        if ( !empty( $uri_chunks[5] ) && ( $uri_chunks[5] === 'topic' ) ) {
    111             bp_core_redirect( 'http://buddypress.org/support/topic/' . $uri_chunks[6] . '/' );
     111            bp_core_redirect( home_url( '/support/topic/' . $uri_chunks[6] . '/' ) );
    112112
    113113        // Single group forum redirect
     
    116116            // Use legacy group slug
    117117            if ( ! in_array( $uri_chunks[3], array( 'gallery', 'how-to-and-troubleshooting' ) ) ) {
    118                 bp_core_redirect( 'http://buddypress.org/support/forum/plugin-forums/' . $uri_chunks[3] . '/' );
     118                bp_core_redirect( home_url( '/support/forum/plugin-forums/' . $uri_chunks[3] . '/' ) );
    119119
    120120            // Root forums, maybe with new slug
     
    124124                switch ( $uri_chunks[3] ) {
    125125                    case 'gallery' :
    126                         $url = 'http://buddypress.org/support/forum/your-buddypress/';
     126                        $url = '/support/forum/your-buddypress/';
    127127                        break;
    128128                    case 'how-to-and-troubleshooting' :
    129                         $url = 'http://buddypress.org/support/forum/how-to/';
     129                        $url = '/support/forum/how-to/';
    130130                        break;
    131131                    case 'creating-and-extending' :
    132                         $url = 'http://buddypress.org/support/forum/extending/';
     132                        $url = '/support/forum/extending/';
    133133                        break;
    134134                    case 'requests-and-feedback' :
    135                         $url = 'http://buddypress.org/support/forum/feedback/';
     135                        $url = '/support/forum/feedback/';
    136136                        break;
    137137                    case 'buddypress' :
    138                         $url = 'http://buddypress.org/support/forum/installing/';
     138                        $url = '/support/forum/installing/';
    139139                        break;
    140140                    case 'third-party-plugins' :
    141                         $url = 'http://buddypress.org/support/forum/plugins/';
     141                        $url = '/support/forum/plugins/';
    142142                        break;
    143143                    default:
     
    145145                        break;
    146146                }
    147                 bp_core_redirect( $url );
     147                bp_core_redirect( home_url( $url ) );
    148148            }
    149149        }
     
    152152    // Redirect /support/topics/ to /support/
    153153    if ( $uri_chunks[1] === 'support' && ( !empty( $uri_chunks[2] ) && ( 'topics' === $uri_chunks[2] ) ) ) {
    154         bp_core_redirect( 'http://buddypress.org/support/' );
    155     }
    156 }
    157 if ( 'buddypress.org' === $_SERVER['HTTP_HOST'] && ! is_admin() && defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ) {
     154        bp_core_redirect( home_url( '/support/' ) );
     155    }
     156}
     157if ( (bool) strstr( $_SERVER['HTTP_HOST'], 'buddypress' ) && ! is_admin() && defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ) {
    158158    add_action( 'init', 'bporg_redirect', 1 ); // before bp_init
    159159}
Note: See TracChangeset for help on using the changeset viewer.