wp.example.com your subdomains will be site1.wp.example.com. This plugin removes the extra wp part so that the site instead will be named site1.example.com.
Author: Odin Hørthe Omdal
Version: 1.2
Author URI: http://velmont.no/
*/
/* Change this to your primary wordpress dashboard.
* Normally you don't need to change this if you followed
* my tutorial. */
define('REMOVE_DOMAIN_PART', '.wp.');
function remove_domain_part( $blog_id )
{
switch_to_blog( $blog_id );
update_option( 'siteurl', str_replace(REMOVE_DOMAIN_PART, '.', get_option( 'siteurl')) );
update_option( 'home', str_replace(REMOVE_DOMAIN_PART, '.', get_option( 'home')) );
update_option( 'fileupload_url', str_replace(REMOVE_DOMAIN_PART, '.', get_option( 'fileupload_url')) );
update_blog_details($blog_id, array('domain' =>
str_replace('http://', '',
str_replace(REMOVE_DOMAIN_PART, '.', get_option( 'siteurl'))
)
));
restore_current_blog();
}
add_action( 'wpmu_new_blog', 'remove_domain_part', 4, 1 );
add_action( 'wpmu_activate_blog', 'remove_domain_part', 4, 1 );
function remove_domain_part_filter($content) {
if (!has_filter('wp_mail', 'remove_domain_part_wpmail'))
add_filter('wp_mail', 'remove_domain_part_wpmail');
return str_replace(REMOVE_DOMAIN_PART, '.', $content);
}
function remove_domain_part_wpmail($mail) {
$mail['message'] = remove_domain_part_filter($mail['message']);
$mail['subject'] = remove_domain_part_filter($mail['subject']);
return $mail;
}
add_filter( 'update_welcome_email',
'remove_domain_part_filter', 4, 1 );
add_filter( 'update_welcome_user_email',
'remove_domain_part_filter', 4, 1 );
add_filter( 'newblog_notify_siteadmin',
'remove_domain_part_filter', 4, 1 );
function remove_domain_part_activationemail($msg, $domain, $path, $title, $user, $user_email, $key, $meta) {
$activate_url = network_site_url("wp-activate.php?key=$key");
$siteurl = remove_domain_part_filter(esc_url("http://{$domain}{$path}"));
return sprintf(
$msg,
$activate_url,
esc_url( "http://{$domain}{$path}" ),
$key
);
}
add_filter( 'wpmu_signup_blog_notification_email',
'remove_domain_part_activationemail', 3, 8 );