Skip to content

Commit

Permalink
Troubleshooting Mode: Use correct URL for the disable action in subdi…
Browse files Browse the repository at this point in the history
…rectory scenarios.

When either WordPress is installed in a subdirectory, or a multisite is used, the path to the site is added to `site_url()`. The Troubleshooting Mode event of deactivating itself would append `$_SERVER['REQUEST_URI']` to this call, leading to unintentionally appending double subdirectory entries.

Props @ipajen.
Fixes #445.
  • Loading branch information
Clorith committed Jun 26, 2023
1 parent 906e7e7 commit 1e0b6f5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mu-plugin/health-check-troubleshooting-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,13 @@ function disable_troubleshooting_mode() {
*/
private function get_clean_url( $url = null ) {
if ( ! $url ) {
$url = site_url( $_SERVER['REQUEST_URI'] );
// The full URL for the current request.
$raw_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

// We prepare the `REQUEST_URI` entry our selves, to account for WP installs in subdirectories or similar.
$request_uri = str_ireplace( site_url( '/' ), '', $raw_url );

$url = site_url( $request_uri );
}

return remove_query_arg( $this->available_query_args, $url );
Expand Down

0 comments on commit 1e0b6f5

Please sign in to comment.