Changeset 1377

Show
Ignore:
Timestamp:
07/16/08 14:06:33 (5 months ago)
Author:
donncha
Message:

Don't redirect main blog 404s and unknown blogs to signup page by default.
Added "is_main_blog()" function
Redirect to NOBLOGREDIRECT on main blog 404 and unknown blog if that constant set, fixes #677

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-config-sample.php

    r1350 r1377  
    3636//define( 'SUNRISE', 'on' ); 
    3737 
    38 // Uncomment and set this to a URL to redirect if a blog does not exist. (Useful if signup is disabled) 
    39 // Browser will redirect to constant( 'NOBLOGREDICT' ) . "?new=blogname" where blogname is the unknown blog 
     38// Uncomment and set this to a URL to redirect if a blog does not exist or is a 404 on the main blog. (Useful if signup is disabled) 
     39// For example, browser will redirect to http://examples.com/ for the following: define( 'NOBLOGREDIRECT', 'http://example.com/' ); 
    4040// define( 'NOBLOGREDIRECT', '' ); 
    4141 
  • trunk/wp-includes/wpmu-functions.php

    r1375 r1377  
    9999        global $wpdb; 
    100100        return $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE user_login = '$username'" ); 
     101} 
     102 
     103function is_main_blog() { 
     104        global $current_blog, $current_site; 
     105        if( $current_blog->domain == $current_site->domain && $current_blog->path == $current_site->path ) 
     106                return true; 
     107        return false; 
    101108} 
    102109 
     
    19621969add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' ); 
    19631970add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' ); 
     1971 
     1972function maybe_redirect_404() { 
     1973        global $wpdb; 
     1974        if( is_main_blog() && is_404() && defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) { 
     1975                header( "Location: " . constant( 'NOBLOGREDIRECT' ) ); 
     1976                die(); 
     1977        } 
     1978} 
     1979add_action( 'template_redirect', 'maybe_redirect_404' ); 
    19641980?> 
  • trunk/wpmu-settings.php

    r1373 r1377  
    104104if( defined( "WP_INSTALLING" ) == false ) { 
    105105        if( $current_site && $current_blog == null ) { 
    106                 if( defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) { 
    107                         header( "Location: " . constant( 'NOBLOGREDIRECT' ) . "?new=" . urlencode( $blogname ) ); 
    108                 } else { 
    109                         header( "Location: http://{$current_site->domain}{$current_site->path}wp-signup.php?new=" . urlencode( $blogname ) ); 
    110                 } 
    111                 die(); 
     106                $current_blog = $wpdb->get_row("SELECT * FROM {$wpdb->blogs} WHERE domain = '{$current_site->domain}' AND path = '{$current_site->path}'"); 
    112107        } 
    113108        if( $current_blog == false || $current_site == false )