Skip to content

Instantly share code, notes, and snippets.

@frozzare
Last active November 12, 2015 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frozzare/e089576ceaa9528526d6 to your computer and use it in GitHub Desktop.
Save frozzare/e089576ceaa9528526d6 to your computer and use it in GitHub Desktop.
<?php
/**
* Fix network admin URL to include the "/wp/" base.
*
* @see https://core.trac.wordpress.org/ticket/23221
*
* @param string $url
*
* @return string
*/
function bedrock_wp_directory( $url ) {
$urls_to_fix = [
'/wp-admin',
'/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;
}
add_filter( 'network_site_url', 'bedrock_wp_directory', 99 );
add_filter( 'site_url', 'bedrock_wp_directory', 99 );
add_filter( 'admin_url', 'bedrock_wp_directory', 99 );
add_filter( 'network_admin_url', 'bedrock_wp_directory', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment