Making Customizer Work with Domain Mapping on Multisite (WordPress Network)
-
Issue is resolved – posting problem + code solution in case anyone else has the same issue or should the maintainer choose to update the plugin.
Issue:
On a site that I had a domain, mapped as primary, I ran into problems using Customizer. When I would load Customizer the left panel would display all the customizer options/settings but the iFrame preview on the right would not load, or in my local environment, would load an error message:Non-existent changeset UUID.
Settings:
My
Admin > Network > Settings > Domain Mapping
options were as follows:1 [ ] Remote Login
2 [x] Permanent redirect (better for your blogger’s pagerank)
3 [x] User domain mapping page
4 [x] Redirect administration pages to site’s original domain (remote login disabled if this redirect is disabled)
5 [ ] Disable primary domain check. Sites will not redirect to one domain name. May cause duplicate content issues.Debugging:
What was happening was the customizer iFrame was trying to loadsubdomain.example.com
but was redirecting to the primary domain.Solution:
I observed logic in the domain-mapping.php file in the function
redirect_to_mapped_domain()
that was supposed to prevent redirecting customizer requests but it appears the way to identify customizer has changed since then. I added the following condition:// But really - don't redirect theme customizer (WP ?) if ( isset( $_GET['customize_changeset_uuid'] ) ){ return; }
That complete function now looks like this:
function redirect_to_mapped_domain() { global $current_blog, $wpdb; // don't redirect the main site if ( is_main_site() ) return; // don't redirect post previews if ( isset( $_GET['preview'] ) && $_GET['preview'] == 'true' ) return; // don't redirect theme customizer (WP 3.4) if ( isset( $_POST['customize'] ) && isset( $_POST['theme'] ) && $_POST['customize'] == 'on' ) return; // But really - don't redirect theme customizer (WP ?) if ( isset( $_GET['customize_changeset_uuid'] ) ){ return; } $protocol = is_ssl() ? 'https://' : 'https://'; $url = domain_mapping_siteurl( false ); if ( $url && $url != untrailingslashit( $protocol . $current_blog->domain . $current_blog->path ) ) { $redirect = get_site_option( 'dm_301_redirect' ) ? '301' : '302'; if ( ( defined( 'VHOST' ) && constant( "VHOST" ) != 'yes' ) || ( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == false ) ) { $_SERVER[ 'REQUEST_URI' ] = str_replace( $current_blog->path, '/', $_SERVER[ 'REQUEST_URI' ] ); } header( "Location: {$url}{$_SERVER[ 'REQUEST_URI' ]}", true, $redirect ); exit; } }
Now I can use customizer both locally and live both with and without a domain mapped to the site I am trying to customize.
- The topic ‘Making Customizer Work with Domain Mapping on Multisite (WordPress Network)’ is closed to new replies.