Last active
November 12, 2015 22:42
-
-
Save frozzare/e089576ceaa9528526d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?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