Quantcast
Channel: WordPress.org Forums » [WordPress MU Domain Mapping] Support
Viewing all articles
Browse latest Browse all 3502

EliasArtista on "[Plugin: WordPress MU Domain Mapping] WP MU Sub-folder - Mapped Domain - Images Failure"

$
0
0

I had this problem to. And I have rezolve it myself. It is a sunrise.php problem.
Edit your sunrise.php
Replace your code (everything) from sunrise.php with this new code:

<?php
// Compatibility mode
define('DM_COMPATIBILITY', 'yes');

// domain mapping plugin to handle VHOST and non VHOST installation
global $wpdb;

// No if statement needed as the code was the same for both VHOST and non VHOST installations
if(defined('DM_COMPATIBILITY') && DM_COMPATIBILITY == 'yes' ) {
if(!empty($wpdb->base_prefix)) {
$wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
} else {
$wpdb->dmtable = $wpdb->prefix . 'domain_mapping';
}
} else {
if(!empty($wpdb->base_prefix)) {
$wpdb->dmtable = $wpdb->base_prefix . 'domain_map';
} else {
$wpdb->dmtable = $wpdb->prefix . 'domain_map';
}
}

if(defined('COOKIE_DOMAIN')) {
define('COOKIE_DOMAIN_ERROR', true);
}

$wpdb->suppress_errors();

$using_domain = $wpdb->escape( preg_replace( "/^www\./", "", $_SERVER[ 'HTTP_HOST' ] ) );

// Check for the domain with and without the www. prefix
$mapped_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->dmtable} WHERE domain = %s OR domain = %s LIMIT 1 /* domain mapping */", $using_domain, 'www.' . $using_domain ) );

$wpdb->suppress_errors( false );

if( !empty($mapped_id) ) {
$current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1 /* domain mapping */", $mapped_id) );
$current_blog->domain = $_SERVER[ 'HTTP_HOST' ];

$blog_id = $mapped_id;
$site_id = $current_blog->site_id;

define( 'COOKIE_DOMAIN', $using_domain );

$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * from {$wpdb->site} WHERE id = %d LIMIT 0,1 /* domain mapping */", $current_blog->site_id ) );
// Add in the blog id
$current_site->blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path) );

$current_site = get_current_site_name( $current_site );

$current_blog->path = $current_site->path;

define( 'DOMAIN_MAPPING', 1 );

// Added for belt and braces
if ( !defined('WP_CONTENT_URL') ) {
$protocol = ( ( isset( $_SERVER[ 'HTTPS' ] ) && 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) || ( isset( $_SERVER[ 'SERVER_PORT' ] ) && '443' == $_SERVER[ 'SERVER_PORT' ] ) ) ? 'https://' : 'http://';
define( 'WP_CONTENT_URL', $protocol . $current_blog->domain . $current_blog->path . 'wp-content'); // full url - WP_CONTENT_DIR is defined further up
}

}

if ( !defined( 'SUNRISE_LOADED' ) )
define( 'SUNRISE_LOADED', 1 );

// let the site admin page catch the VHOST == 'yes'
$wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
$dm_domain = $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );

if( ( $nowww = preg_replace( '|^www\.|', '', $dm_domain ) ) != $dm_domain )
$where = $wpdb->prepare( 'domain IN (%s,%s)', $dm_domain, $nowww );
else
$where = $wpdb->prepare( 'domain = %s', $dm_domain );

$wpdb->suppress_errors();
$domain_mapping_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->dmtable} WHERE {$where} ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1" );
$wpdb->suppress_errors( false );
if( $domain_mapping_id ) {
$current_blog = $wpdb->get_row("SELECT * FROM {$wpdb->blogs} WHERE blog_id = '$domain_mapping_id' LIMIT 1");
$current_blog->domain = $_SERVER[ 'HTTP_HOST' ];
$current_blog->path = '/';
$blog_id = $domain_mapping_id;
$site_id = $current_blog->site_id;

define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );

$current_site = $wpdb->get_row( "SELECT * from {$wpdb->site} WHERE id = '{$current_blog->site_id}' LIMIT 0,1" );
$current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
if( function_exists( 'get_current_site_name' ) )
$current_site = get_current_site_name( $current_site );

define( 'DOMAIN_MAPPING', 1 );
}
?>


Viewing all articles
Browse latest Browse all 3502

Trending Articles