Add is_subdomain_install() to ms code - Fixes #11796
git-svn-id: http://svn.automattic.com/wordpress/trunk@12674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
166435891c
commit
4b8c87da92
|
@ -732,7 +732,7 @@ function site_admin_notice() {
|
|||
add_action( 'admin_notices', 'site_admin_notice' );
|
||||
|
||||
function avoid_blog_page_permalink_collision( $data, $postarr ) {
|
||||
if( constant( 'VHOST' ) == 'yes' )
|
||||
if( is_subdomain_install() )
|
||||
return $data;
|
||||
if( $data[ 'post_type' ] != 'page' )
|
||||
return $data;
|
||||
|
|
|
@ -70,7 +70,7 @@ switch( $_GET['action'] ) {
|
|||
if ( false === $blog_details ) {
|
||||
if ( is_numeric( $dashboard_blog ) )
|
||||
wp_die( __( 'Dashboard blog_id must be a blog that already exists' ) );
|
||||
if ( constant( 'VHOST' ) == 'yes' ) {
|
||||
if ( is_subdomain_install() ) {
|
||||
$domain = $dashboard_blog . '.' . $current_site->domain;
|
||||
$path = $current_site->path;
|
||||
} else {
|
||||
|
@ -145,7 +145,7 @@ switch( $_GET['action'] ) {
|
|||
if( !is_email( $email ) )
|
||||
wp_die( __('Invalid email address') );
|
||||
|
||||
if( constant( 'VHOST' ) == 'yes' ) {
|
||||
if( is_subdomain_install() ) {
|
||||
$newdomain = $domain.".".$current_site->domain;
|
||||
$path = $base;
|
||||
} else {
|
||||
|
|
|
@ -55,7 +55,7 @@ if (isset($_GET['updated'])) {
|
|||
<label><input name="registration" type="radio" id="registration3" value='user' <?php echo get_site_option('registration') == 'user' ? 'checked="checked"' : ''; ?> /> <?php _e('Only user account can be created.'); ?></label><br />
|
||||
<label><input name="registration" type="radio" id="registration4" value='blog' <?php echo get_site_option('registration') == 'blog' ? 'checked="checked"' : ''; ?> /> <?php _e('Only logged in users can create new blogs.'); ?></label><br />
|
||||
<p><?php _e('Disable or enable registration and who or what can be registered. (Default=all)'); ?></p>
|
||||
<?php if( constant( 'VHOST' ) == 'yes' ) {
|
||||
<?php if( is_subdomain_install() ) {
|
||||
echo "<p>" . __('If registration is disabled, please set "NOBLOGREDIRECT" in wp-config.php to a url you will redirect visitors to if they visit a non existant blog.') . "</p>";
|
||||
} ?>
|
||||
</td>
|
||||
|
|
|
@ -401,7 +401,7 @@ switch( $_GET['action'] ) {
|
|||
|
||||
<?php
|
||||
// define the columns to display, the syntax is 'internal name' => 'display name'
|
||||
$blogname_columns = ( constant( "VHOST" ) == 'yes' ) ? __('Domain') : __('Path');
|
||||
$blogname_columns = ( is_subdomain_install() ) ? __('Domain') : __('Path');
|
||||
$posts_columns = array(
|
||||
'id' => __('ID'),
|
||||
'blogname' => $blogname_columns,
|
||||
|
@ -457,7 +457,7 @@ switch( $_GET['action'] ) {
|
|||
}
|
||||
echo "<tr $bgcolour class='$class'>";
|
||||
|
||||
$blogname = ( constant( "VHOST" ) == 'yes' ) ? str_replace('.'.$current_site->domain, '', $blog['domain']) : $blog['path'];
|
||||
$blogname = ( is_subdomain_install() ) ? str_replace('.'.$current_site->domain, '', $blog['domain']) : $blog['path'];
|
||||
foreach( $posts_columns as $column_name=>$column_display_name ) {
|
||||
switch($column_name) {
|
||||
case 'id': ?>
|
||||
|
@ -586,7 +586,7 @@ switch( $_GET['action'] ) {
|
|||
<tr class="form-field form-required">
|
||||
<th style="text-align:center;" scope='row'><?php _e('Blog Address') ?></th>
|
||||
<td>
|
||||
<?php if ( constant( "VHOST" ) == 'yes' ) { ?>
|
||||
<?php if ( is_subdomain_install() ) { ?>
|
||||
<input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>.<?php echo $current_site->domain;?>
|
||||
<?php } else {
|
||||
echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>
|
||||
|
|
|
@ -31,7 +31,7 @@ function get_blogaddress_by_id( $blog_id ) {
|
|||
function get_blogaddress_by_name( $blogname ) {
|
||||
global $current_site;
|
||||
|
||||
if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
|
||||
if( is_subdomain_install() ) {
|
||||
if( $blogname == 'main' )
|
||||
$blogname = 'www';
|
||||
return clean_url( "http://" . $blogname . "." . $current_site->domain . $current_site->path );
|
||||
|
@ -41,7 +41,7 @@ function get_blogaddress_by_name( $blogname ) {
|
|||
}
|
||||
|
||||
function get_blogaddress_by_domain( $domain, $path ){
|
||||
if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
|
||||
if( is_subdomain_install() ) {
|
||||
$url = "http://".$domain.$path;
|
||||
} else {
|
||||
if( $domain != $_SERVER['HTTP_HOST'] ) {
|
||||
|
@ -108,7 +108,7 @@ function get_id_from_blogname( $name ) {
|
|||
if ( $blog_id )
|
||||
return $blog_id;
|
||||
|
||||
if ( defined('VHOST') && constant( 'VHOST' ) == 'yes' ) {
|
||||
if ( is_subdomain_install() ) {
|
||||
$domain = $name . '.' . $current_site->domain;
|
||||
$path = $current_site->path;
|
||||
} else {
|
||||
|
@ -1033,7 +1033,7 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
|
|||
$errors->add('blogname', __("Sorry, blog names may not contain the character '_'!"));
|
||||
|
||||
// do not allow users to create a blog that conflicts with a page on the main blog.
|
||||
if ( constant( "VHOST" ) == 'no' && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
|
||||
if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
|
||||
$errors->add( 'blogname', __( "Sorry, you may not use that blog name" ) );
|
||||
}
|
||||
|
||||
|
@ -1051,7 +1051,7 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
|
|||
$errors->add('blog_title', __("Please enter a blog title"));
|
||||
|
||||
// Check if the domain/path has been used already.
|
||||
if( constant( "VHOST" ) == 'yes' ) {
|
||||
if( is_subdomain_install() ) {
|
||||
$mydomain = "$blogname.$domain";
|
||||
$path = $base;
|
||||
} else {
|
||||
|
@ -1138,7 +1138,7 @@ function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_emai
|
|||
return false;
|
||||
|
||||
// Send email with activation link.
|
||||
if( constant( "VHOST" ) == 'no' || $current_site->id != 1 ) {
|
||||
if( !is_subdomain_install() || $current_site->id != 1 ) {
|
||||
$activate_url = "http://" . $current_site->domain . $current_site->path . "wp-activate.php?key=$key";
|
||||
} else {
|
||||
$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key";
|
||||
|
@ -1267,7 +1267,7 @@ function wpmu_create_user( $user_name, $password, $email) {
|
|||
|
||||
function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
|
||||
$domain = preg_replace( "/\s+/", '', sanitize_user( $domain, true ) );
|
||||
if( constant( 'VHOST' ) == 'yes' )
|
||||
if( is_subdomain_install() )
|
||||
$domain = str_replace( '@', '', $domain );
|
||||
$title = strip_tags( $title );
|
||||
$user_id = (int) $user_id;
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Whether a subdomain configuration is enabled
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @return bool True if subdomain configuration is enabled, false otherwise.
|
||||
*/
|
||||
function is_subdomain_install() {
|
||||
if ( defined('VHOST') && VHOST == 'yes' )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( isset( $current_site ) && isset( $current_blog ) )
|
||||
return;
|
||||
|
||||
|
@ -65,7 +80,7 @@ function wpmu_current_site() {
|
|||
return $current_site;
|
||||
}
|
||||
$path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
|
||||
if( constant( 'VHOST' ) == 'yes' ) {
|
||||
if( is_subdomain_install() ) {
|
||||
$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path) );
|
||||
if( $current_site != null )
|
||||
return $current_site;
|
||||
|
@ -113,7 +128,7 @@ $current_site = wpmu_current_site();
|
|||
if( !isset( $current_site->blog_id ) )
|
||||
$current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
|
||||
|
||||
if( constant( 'VHOST' ) == 'yes' ) {
|
||||
if( is_subdomain_install() ) {
|
||||
$current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' );
|
||||
if( !$current_blog ) {
|
||||
$current_blog = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain) );
|
||||
|
@ -143,7 +158,7 @@ if( constant( 'VHOST' ) == 'yes' ) {
|
|||
}
|
||||
}
|
||||
|
||||
if( defined( "WP_INSTALLING" ) == false && constant( 'VHOST' ) == 'yes' && !is_object( $current_blog ) ) {
|
||||
if( defined( "WP_INSTALLING" ) == false && is_subdomain_install() && !is_object( $current_blog ) ) {
|
||||
if( defined( 'NOBLOGREDIRECT' ) ) {
|
||||
$destination = constant( 'NOBLOGREDIRECT' );
|
||||
if ( $destination == '%siteurl%' )
|
||||
|
|
|
@ -56,7 +56,7 @@ get_header();
|
|||
function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
|
||||
global $current_site;
|
||||
// Blog name
|
||||
if( constant( "VHOST" ) == 'no' )
|
||||
if( !is_subdomain_install() )
|
||||
echo '<label for="blogname">' . __('Blog Name:') . '</label>';
|
||||
else
|
||||
echo '<label for="blogname">' . __('Blog Domain:') . '</label>';
|
||||
|
@ -65,14 +65,14 @@ function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
|
|||
<p class="error"><?php echo $errmsg ?></p>
|
||||
<?php }
|
||||
|
||||
if( constant( "VHOST" ) == 'no' ) {
|
||||
if( !is_subdomain_install() ) {
|
||||
echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="50" /><br />';
|
||||
} else {
|
||||
echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
|
||||
}
|
||||
if ( !is_user_logged_in() ) {
|
||||
print '(<strong>' . __( 'Your address will be ' );
|
||||
if( constant( "VHOST" ) == 'no' ) {
|
||||
if( !is_subdomain_install() ) {
|
||||
print $current_site->domain . $current_site->path . __( 'blogname' );
|
||||
} else {
|
||||
print __( 'domain.' ) . $current_site->domain . $current_site->path;
|
||||
|
@ -420,7 +420,7 @@ if( $active_signup == "none" ) {
|
|||
_e( "You're logged in already. No need to register again!" );
|
||||
}
|
||||
if ($newblogname) {
|
||||
if( constant( "VHOST" ) == 'no' )
|
||||
if( !is_subdomain_install() )
|
||||
$newblog = 'http://' . $current_site->domain . $current_site->path . $newblogname . '/';
|
||||
else
|
||||
$newblog = 'http://' . $newblogname . '.' . $current_site->domain . $current_site->path;
|
||||
|
|
Loading…
Reference in New Issue