Alex (SirShurf) Frenkel's Blog

A web log of a PHP professional

Archive for the ‘wpml’ Category

WPML 3.1.8.x and the double slash problems continues.

leave a comment »

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 );

Written by Alex (Shurf) Frenkel

October 28, 2014 at 2:12 pm

Posted in Plugin, Wordpress, wpml

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 );

Written by Alex (Shurf) Frenkel

October 26, 2014 at 11:03 am

Posted in Wordpress, wpml

Tagged with