WPML
Status
Resolved
Reported for
WPML Multilingual CMS 4.6.12
Resolved in
WPML 4.7
Related plugin/theme
Divi
Topic tags
Compatibility

Overview of the issue

You may encounter an issue where pages are not marked as translated after completing the translation to 100% using WPML with the Divi theme. Additionally, the following error may be logged:

PHP Fatal error:  Uncaught TypeError: htmlspecialchars_decode(): Argument #1 ($string) must be of type string, array given in .../wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Shared/st/strategy/shortcode/class-wpml-pb-update-shortcodes-in-content.php:203

Workaround

Please, make sure of having a full site backup of your site before proceeding.


  • Open …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Shared/st/strategy/shortcode/class-wpml-pb-update-shortcodes-in-content.php file.

  • Look for line 206.

  • Replace:
    		if ( 'allow_html_tags' !== $encoding ) {
    			$translation = htmlspecialchars( htmlspecialchars_decode( $translation ) );
    		}


  • With:
    		// Ensure $translation is a string
    		if (is_array($translation)) {
    			// Handle array to string conversion as needed
    			$translation = implode('', $translation);
    		}
    
    		if ( 'allow_html_tags' !== $encoding ) {
    			$translation = htmlspecialchars( htmlspecialchars_decode( $translation ) );
    		}

All known issues →