WPML 3.1.8.x and the double slash problems continues.
Well, after my previous post WPML have relised a new version 3.1.8.2, but it looks like this error gone unnoticed.
One other error with my solution was that on the homepage paging it had errors, so here is the revised version of the fix for WPML.
$arrUrl = parse_url($absolute_home_url);
if(!isset($arrUrl[‘path’])) $arrUrl[‘path’] = ‘/’;
$absolute_home_url = $arrUrl[‘scheme’].”://”.$arrUrl[‘host’].$arrUrl[‘path’];
if(isset($arrUrl[‘query’])) $absolute_home_url .= ‘?’.$arrUrl[‘query’];
if(isset($arrUrl[‘fragment’])) $absolute_home_url .= ‘#’.$arrUrl[‘fragment’];
unset($arrUrl);
$arrUrl = parse_url($this->settings[ ‘language_domains’ ][ $code ]);
if(!isset($arrUrl[‘path’])) $arrUrl[‘path’] = ‘/’;
$this->settings[ ‘language_domains’ ][ $code ] = $arrUrl[‘scheme’].”://”.$arrUrl[‘host’].$arrUrl[‘path’];
if(isset($arrUrl[‘query’])) $this->settings[ ‘language_domains’ ][ $code ] .= ‘?’.$arrUrl[‘query’];
if(isset($arrUrl[‘fragment’])) $this->settings[ ‘language_domains’ ][ $code ] .= ‘#’.$arrUrl[‘fragment’];
unset($arrUrl);
$arrUrl = parse_url($new_url);
if (!empty($arrUrl)){
if(!isset($arrUrl[‘path’])) $arrUrl[‘path’] = ‘/’;
$new_url = $arrUrl[‘scheme’].”://”.$arrUrl[‘host’].$arrUrl[‘path’];
if(isset($arrUrl[‘query’])) $new_url .= ‘?’.$arrUrl[‘query’];
if(isset($arrUrl[‘fragment’])) $new_url .= ‘#’.$arrUrl[‘fragment’];
}
unset($arrUrl);
The fix goes into sitepress.class.php on between lines 6463 and 6464:
$this->settings[ ‘language_domains’ ][ $default_language ] = $wpdb->get_var( “SELECT option_value FROM $wpdb->options WHERE option_name = ‘siteurl'”);
$new_url = str_replace( $absolute_home_url, $this->settings[ ‘language_domains’ ][ $code ], $new_url );
Leave a Reply