Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created March 5, 2014 23:43
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danielbachhuber/9379135 to your computer and use it in GitHub Desktop.
Save danielbachhuber/9379135 to your computer and use it in GitHub Desktop.
Fix network admin URL to include the "/wp/" base
<?php
/**
* Fix network admin URL to include the "/wp/" base
*
* @see https://core.trac.wordpress.org/ticket/23221
*/
add_filter( 'network_site_url', function( $url, $path, $scheme ){
$urls_to_fix = array(
'/wp-admin/network/',
'/wp-login.php',
'/wp-activate.php',
'/wp-signup.php',
);
foreach( $urls_to_fix as $maybe_fix_url ) {
$fixed_wp_url = '/wp' . $maybe_fix_url;
if ( false !== stripos( $url, $maybe_fix_url )
&& false === stripos( $url, $fixed_wp_url ) ) {
$url = str_replace( $maybe_fix_url, $fixed_wp_url, $url );
}
}
return $url;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment