问题概述
您可能会遇到这样的问题:在使用 WPML 和 Divi 主题 将翻译完成至 100% 后,页面未被标记为已翻译。此外,可能会记录以下错误:
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
临时解决方法
此问题已在 WPML 4.7 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。
在继续操作前,请确保拥有完整的站点备份。
- 打开 …/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Shared/st/strategy/shortcode/class-wpml-pb-update-shortcodes-in-content.php 文件。
- 找到第 206 行。
- 替换:
if ( 'allow_html_tags' !== $encoding ) { $translation = htmlspecialchars( htmlspecialchars_decode( $translation ) ); } - 替换为:
// 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 ) ); }