Last active
August 29, 2015 14:01
-
-
Save wkw/452fe5f9fe116929b20f to your computer and use it in GitHub Desktop.
WPML Language Switcher Bug Workaround
This file contains 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
// | |
// referencing v3.1.5 of WPML sitepress plugin | |
// in file: sitepress-multilingual-cms/sitepress.class.php | |
// at or near line: 5898 (inside method `convert_url`) | |
// | |
Add these three lines of code after the first larger if/block. | |
if ( is_null( $code ) ) { | |
$code = $default_language; | |
} | |
so.... the function should begin this way: | |
function convert_url( $url, $code = null ) { | |
if(!$url) return false; | |
$default_language = $this->get_default_language(); | |
$language_negotiation_type = $this->settings[ 'language_negotiation_type' ]; | |
if ( is_null( $code ) && $language_negotiation_type == '2' && isset( $this->settings[ 'language_domains' ] ) ) { | |
foreach ( $this->settings[ 'language_domains' ] as $lang => $domain ) { | |
$domain = preg_replace( '/^https?\:\/\//', '', $domain ); | |
$domain_data = explode('/', $domain); | |
$domain = $domain_data[0]; | |
if ( $domain == $this->get_server_host_name() ) { | |
$code = $lang; | |
} | |
} | |
if ( is_null( $code ) ) { | |
$code = $default_language; | |
} | |
} | |
// -- BEGIN HACK -- | |
if ( is_null( $code ) ) { | |
$code = $default_language; | |
} | |
// -- END HACK -- | |
if ( is_null( $code ) ) { | |
$code = $this->this_lang; | |
} | |
... rest of method ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment