Alex (SirShurf) Frenkel's Blog

A web log of a PHP professional

WPML makes the user logged out on 3.1.8.1 upgrade

with one comment

WPML rolled out an update to their plugin version 3.1.8.1.

But since the update you cannot work in the admin panel any more, each url will have more then one slash in it.

Here is my fix for the problem (until thy will issue an update).

The problem is in the sitepress.class.php file on line 6464, and created by in the addition of line 6463.

In line 6463 they have added a selection of site_url paramtere from the global parameter set of wordpress:

$this->settings[ ‘language_domains’ ][ $default_language ] = $wpdb->get_var( “SELECT option_value FROM $wpdb->options WHERE option_name = ‘siteurl'”);

This selection have an url of the website WITH the trailing slash in it.

And this data is sent to the next line: 6464

$new_url = str_replace( $absolute_home_url, $this->settings[ ‘language_domains’ ][ $code ], $new_url );

What this creates is a URL with next features:http://localhost//wp-admin/?lang=frAnd the double slash created the logout problem.By addint my lines of code, the error can be managed, untill a more permanent fix will be applied by WPML team:Simple add next code between 6463 and 6464 (inclusive)

                        $this->settings[ ‘language_domains’ ][ $default_language ] = $wpdb->get_var( “SELECT option_value FROM $wpdb->options WHERE option_name = ‘siteurl'”);
$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’];

$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’];

$new_url = str_replace( $absolute_home_url, $this->settings[ ‘language_domains’ ][ $code ], $new_url );

Advertisement

Written by Alex (Shurf) Frenkel

October 26, 2014 at 11:03 am

Posted in Wordpress, wpml

Tagged with

One Response

Subscribe to comments with RSS.

  1. […] after my previous post WPML have relised a new version 3.1.8.2, but it looks like this error gone […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: