Patch for admin_url filter respecting relative URLs
-
We ran into an issue when running Woocommerce under a multisite install, where if you had forced SSL admin, the ajax add-to-cart buttons would stop working due to the admin-ajax.php url being redirected to the https side.
Woocommerce takes this into account by defining the scheme as ‘relative’ as such
admin_url('admin-ajax.php', 'relative');
to make sure ajax calls always come from the same scheme as the user is currently in.But because your plugin filters the admin_url function so that it always prepends the site url, even when the url is relative, the cookies are not set for the user via ajax thus making the shopping cart not work.
Below is a proposed fix for this bug, which causes the plugin to retain relative urls as relative in the admin_url filter:
--- a/domain_mapping.php +++ b/domain_mapping.php @@ -582,7 +582,7 @@ function get_original_url( $url, $blog_id = 0 ) { function domain_mapping_adminurl( $url, $path, $blog_id = 0 ) { $index = strpos( $url, '/wp-admin' ); - if( $index !== false ) { + if( $index !== false && substr( ltrim( $url ), 0, 4 ) == 'http' ) { $url = get_original_url( 'siteurl', $blog_id ) . substr( $url, $index ); // make sure admin_url is ssl if current page is ssl, or admin ssl is forced
https://www.ads-software.com/plugins/wordpress-mu-domain-mapping/
- The topic ‘Patch for admin_url filter respecting relative URLs’ is closed to new replies.