Making WordPress.org

Changeset 1468


Ignore:
Timestamp:
04/03/2015 01:01:47 PM (9 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/.

Location:
sites/trunk/buddypress.org/public_html/wp-content
Files:
5 edited

Legend:

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

    r529 r1468  
    2929        return;
    3030
    31     wp_safe_redirect( 'http://bbpress.org' );
     31    wp_safe_redirect( home_url( '/' ) );
    3232    die;
    3333}
  • 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}
  • sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/toolbar.php

    r1263 r1468  
    269269
    270270    // bbPress Codex
    271     } elseif ( 'codex.bbpress.org' == $_SERVER['HTTP_HOST'] ) {
     271    } elseif ( bb_base_is_bbpress() ) {
    272272        $wp_admin_bar->add_menu( array(
    273273            'id'    => 'bp-site-name',
  • sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base/functions.php

    r1263 r1468  
    2323}
    2424
     25/**
     26 * Are we looking at a buddypress.org site?
     27 *
     28 * @return bool
     29 */
     30function bb_base_is_buddypress() {
     31    $retval = (bool) strstr( $_SERVER['HTTP_HOST'], 'buddypress' );
     32    return (bool) apply_filters( 'bb_base_is_buddypress', $retval );
     33}
     34
     35/**
     36 * Are we looking at a bbpress.org site?
     37 *
     38 * @return bool
     39 */
     40function bb_base_is_bbpress() {
     41    $retval = (bool) strstr( $_SERVER['HTTP_HOST'], 'bbpress' );
     42    return (bool) apply_filters( 'bb_base_is_bbpress', $retval );
     43}
     44
     45
    2546// Include in Codex code on codex sites
    2647if ( bb_base_is_codex() ) {
     
    4061
    4162    // Handle root styling for buddypress/bbpress
    42     if ( strstr( $_SERVER['HTTP_HOST'], 'bbpress.org' ) ) {
     63    if ( bb_base_is_bbpress() ) {
    4364        $root = 'style-bbpress.css';
    44     } elseif ( strstr( $_SERVER['HTTP_HOST'], 'buddypress.org' ) ) {
     65    } elseif ( bb_base_is_buddypress() ) {
    4566        $root = 'style-buddypress.css';
    4667    }
  • sites/trunk/buddypress.org/public_html/wp-content/themes/buddypress-org/header-front.php

    r1008 r1468  
    1 <?php if ( 'buddypress.org' === parse_url( get_home_url(), PHP_URL_HOST ) && is_front_page() ) : ?>
     1<?php if ( bb_base_is_buddypress() && is_front_page() ) : ?>
    22
    33    <div id="headline"><div id="headline-inner">
Note: See TracChangeset for help on using the changeset viewer.