dmtable = $wpdb->base_prefix . 'domain_mapping'; if( VHOST == 'no' ) { die( 'Sorry, domain mapping only works on virtual host installs.' ); } if( is_site_admin() ) { if($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->dmtable}'") != $wpdb->dmtable) { $wpdb->query( "CREATE TABLE IF NOT EXISTS `{$wpdb->dmtable}` ( `id` bigint(20) NOT NULL auto_increment, `blog_id` bigint(20) NOT NULL, `domain` varchar(255) NOT NULL, `active` tinyint(4) default '1', PRIMARY KEY (`id`), KEY `blog_id` (`blog_id`,`domain`,`active`) );" ); ?>
" . __( "As a site admin on this site you can set the IP address users need to point their DNS A records at. If you don't know what it is, ping this blog to get the IP address." ) . "
"; echo '" . __( 'If your domain name includes a hostname like "blog" or some other prefix before the actual domain name you will need to add a CNAME for that hostname in your DNS pointing at this blog URL. "www" does not count because it will be removed from the domain name.' ) . "
"; echo "" . __( 'If you want to redirect a domain you will need to add a DNS "A" record pointing at the IP address of this server: ' ) . "" . get_site_option( 'dm_ipaddress', 'IP not set by admin yet.' ) . "
"; echo ""; } function domain_mapping_siteurl( $setting ) { global $wpdb; if( is_admin() ) return $setting; $s = $wpdb->suppress_errors(); $domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->dmtable} WHERE blog_id = '{$wpdb->blogid}'" ); $wpdb->suppress_errors( $s ); $protocol = ( 'on' == strtolower($_SERVER['HTTPS']) ) ? 'https://' : 'http://'; if( $domain ) return $protocol . $domain; return $setting; } add_action( 'pre_option_siteurl', 'domain_mapping_siteurl' ); add_action( 'pre_option_home', 'domain_mapping_siteurl' ); ?>