Ajax Product filter does not work after the last update of WPML
After the last update of WPML Ajax Product Filter does not work, the problem is the wp_error. During the ajax call, for some reason, the code generate a wp_error exception but the original wpml class doesn't check for this. I add a check to verify if the value is valid or is a wp_error. If a wp_error occured I skip this step and go to next block of code.
I edited the line the line 3340 and line 4672 of sitepress.class.php located in wp-content/plugins/sitepress-multilingual-cms/
at line 3340 I replaced the previous code:
$language_selector = <li class="icl-' . $lang[ 'language_code' ] . '"><a href="' . $language_url . '" ' . $language_selected . '>' ;
with this:
$language_selector = ! is_wp_error( $language_url ) && ! is_wp_error( $language_selected ) ? '<li class="icl-' . $lang[ 'language_code' ]. '"><a href="' . $language_url . '" ' . $language_selected . '>' : '';
at line 4672 I replaced the previous code:
printf( '<link rel="alternate" hreflang="%s" href="%s" />' . PHP_EOL,$this->get_language_tag( $code ), str_replace( '&', '&', $alternate_hreflang ) );
with this one:
if( ! is_wp_error( $alternate_hreflang ) ){ printf( '<link rel="alternate" hreflang="%s" href="%s" />' . PHP_EOL, $this->get_language_tag( $code ), str_replace( '&', '&', $alternate_hreflang ) ); }
In this way there aren't no error during ajax call and the plugin works.