Changeset 1422

Show
Ignore:
Timestamp:
08/13/08 17:05:18 (4 months ago)
Author:
donncha
Message:

Added "DOMAIN_CURRENT_SITE" and "PATH_CURRENT_SITE" to hardcode current site.
Use object cache to store current site if only 1 site (probably majority of mu sites)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/index-install.php

    r1351 r1422  
    338338                                fwrite($handle, str_replace('BASE', $base, $line)); 
    339339                                break; 
     340                        case "define('DOMAIN_C": 
     341                                $domain = get_clean_basedomain(); 
     342                                fwrite($handle, str_replace("current_site_domain", $domain, $line)); 
     343                                break; 
     344                        case "define('PATH_CUR": 
     345                                fwrite($handle, str_replace("current_site_path", str_replace( 'index.php', '', $_SERVER[ 'REQUEST_URI' ] ), $line)); 
     346                                break; 
    340347                        case "define('SECRET_K": 
    341348                        case "define('SECRET_S": 
     
    355362} 
    356363 
     364function get_clean_basedomain() { 
     365        global $wpdb; 
     366        $domain =   $wpdb->escape( $_POST[ 'basedomain' ] ); 
     367        $domain = str_replace( 'http://', '', $domain ); 
     368        if( substr( $domain, 0, 4 ) == 'www.' ) 
     369                $domain = substr( $domain, 4 ); 
     370        if( strpos( $domain, '/' ) ) 
     371                $domain = substr( $domain, 0, strpos( $domain, '/' ) ); 
     372        return $domain; 
     373} 
     374 
    357375function step3() { 
    358376        global $wpdb, $current_site, $dirs, $wpmu_version; 
     
    361379                $base .= "/"; 
    362380        }  
    363         $domain =   $wpdb->escape( $_POST[ 'basedomain' ] ); 
    364         $domain = str_replace( 'http://', '', $domain ); 
    365         if( substr( $domain, 0, 4 ) == 'www.' ) 
    366                 $domain = substr( $domain, 4 ); 
    367         if( strpos( $domain, '/' ) ) 
    368                 $domain = substr( $domain, 0, strpos( $domain, '/' ) ); 
     381        $domain = get_clean_basedomain(); 
    369382        $email = $wpdb->escape( $_POST[ 'email' ] ); 
    370383        if( $email == '' ) 
  • trunk/wp-config-sample.php

    r1413 r1422  
    1010define('VHOST', 'VHOSTSETTING');  
    1111$base = 'BASE'; 
     12define('DOMAIN_CURRENT_SITE', 'current_site_domain' ); 
     13define('PATH_CURRENT_SITE', 'current_site_path' ); 
    1214 
    1315// Change each KEY to a different unique phrase.  You won't have to remember the phrases later, 
  • trunk/wpmu-settings.php

    r1377 r1422  
    2727function wpmu_current_site() { 
    2828        global $wpdb, $current_site, $domain, $path, $sites; 
     29        if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) { 
     30                $current_site->id = 1; 
     31                $current_site->domain = DOMAIN_CURRENT_SITE; 
     32                $current_site->path   = PATH_CURRENT_SITE; 
     33                return $current_site; 
     34        } 
     35 
     36        $current_site = wp_cache_get( "current_site", "site-options" ); 
     37        if( $current_site ) 
     38                return $current_site; 
     39                 
     40        $wpdb->suppress_errors(); 
     41        $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site 
     42        if( count( $sites ) == 1 ) { 
     43                $current_site = $sites[0]; 
     44                $path = $current_site->path; 
     45                wp_cache_set( "current_site", $current_site, "site-options" ); 
     46                return $current_site; 
     47        } 
    2948        $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) ); 
    3049        if( constant( 'VHOST' ) == 'yes' ) { 
     
    7190} 
    7291 
    73 $wpdb->suppress_errors(); 
    74 $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site 
    75 if( count( $sites ) == 1 ) { 
    76         $current_site = $sites[0]; 
    77         $path = $current_site->path; 
    78 } else { 
    79         $current_site = wpmu_current_site(); 
    80 
    81  
     92$current_site = wpmu_current_site(); 
    8293 
    8394if( constant( 'VHOST' ) == 'yes' ) {