Improve SSL compatibility
-
Hi there,
First of all, I’ve been using this plugin for some time and I think it is a great piece of work, so thanks for sharing it!
I recently noticed an issue when logged-in users are forced to use SSL, but not for scripts (i.e.,
site_url()
returns https://mysite.com, butget_stylesheet_directory_uri()
returns https://mysite.com/wp-content/themes/mytheme). In such cases, theprocess_media_source()
method won’t return the correct output (it will be something like http:/mysite.com/wp-content/themes/mythemestyle.css instead of /wp-content/themes/mythemestyle.css), so minification will not happen either. A typical situation could consist in a filter being applied tosite_url()
, forcing it to always use HTTPS as scheme, or having FORCE_SSL_LOGIN set to true in wp-config.php.In my own environment, I was able to solve this issue by modifying some lines from
process_media_source
, found intoincludes/class-bwp-minify.php
. More exactly, I replaced this:$tmp_src = str_replace(site_url(), '', $src);
With this:
$site_url = site_url(); if ( 0 === strpos( $src, 'https' ) ) { $src = str_replace( 'https', 'http', $src ); } if ( 0 === strpos( $site_url, 'https' ) ) { $site_url = str_replace( 'https', 'http', $site_url ); } $tmp_src = str_replace( $site_url, '', $src );
Could this really be an important issue? Maybe I’m doing something wrong and there’s a better way to sort this problem?
- The topic ‘Improve SSL compatibility’ is closed to new replies.