Last active
November 3, 2016 00:34
-
-
Save 2aces/530ba377c5a9a590332f6eadaed8092d to your computer and use it in GitHub Desktop.
allow customizer to use the mapped domain when WordPress MU Domain Mapping is set to "Redirect administration pages to site's original domain"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dm_redirect_admin() {// line 607 on WordPress MU Domain Mapping 0.5.5.1 | |
// don't redirect admin ajax calls | |
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin/admin-ajax.php' ) !== false ) | |
return; | |
global $wp_customize; // gets $wp_customize global | |
if ( get_site_option( 'dm_redirect_admin' ) && !isset($wp_customize) ) { // redirects to original url only if $wp_customize is not set | |
// redirect mapped domain admin page to original url | |
$url = get_original_url( 'siteurl' ); | |
if ( false === strpos( $url, $_SERVER[ 'HTTP_HOST' ] ) ) { | |
wp_redirect( untrailingslashit( $url ) . $_SERVER[ 'REQUEST_URI' ] ); | |
exit; | |
} | |
} else { | |
global $current_blog; | |
// redirect original url to primary domain wp-admin/ - remote login is disabled! | |
$url = domain_mapping_siteurl( false ); | |
$request_uri = str_replace( $current_blog->path, '/', $_SERVER[ 'REQUEST_URI' ] ); | |
if ( false === strpos( $url, $_SERVER[ 'HTTP_HOST' ] ) ) { | |
wp_redirect( str_replace( '//wp-admin', '/wp-admin', trailingslashit( $url ) . $request_uri ) ); | |
exit; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dm_redirect_admin() {// line 607 on WordPress MU Domain Mapping 0.5.5.1 | |
// don't redirect admin ajax calls | |
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin/admin-ajax.php' ) !== false ) | |
return; | |
if ( get_site_option( 'dm_redirect_admin' ) ) { | |
// redirect mapped domain admin page to original url | |
$url = get_original_url( 'siteurl' ); | |
if ( false === strpos( $url, $_SERVER[ 'HTTP_HOST' ] ) ) { | |
wp_redirect( untrailingslashit( $url ) . $_SERVER[ 'REQUEST_URI' ] ); | |
exit; | |
} | |
} else { | |
global $current_blog; | |
// redirect original url to primary domain wp-admin/ - remote login is disabled! | |
$url = domain_mapping_siteurl( false ); | |
$request_uri = str_replace( $current_blog->path, '/', $_SERVER[ 'REQUEST_URI' ] ); | |
if ( false === strpos( $url, $_SERVER[ 'HTTP_HOST' ] ) ) { | |
wp_redirect( str_replace( '//wp-admin', '/wp-admin', trailingslashit( $url ) . $request_uri ) ); | |
exit; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment