- 状态
- 已由作者解决
- 相关插件/主题
- Hestia Pro
- 主题标签
- Compatibility
问题概述
当您使用 Hestia Pro 主题在“自定义”部分添加客户感言时,它们会在 WPML > 字符串翻译页面中合并显示为一个大字符串,导致难以单独进行翻译。
临时解决方法
在继续操作之前,请确保对您的站点进行了完整备份。
- 将以下代码片段添加到主题的 functions.php 文件中:
// WPML Workaround for compsupp-6971 function wpml_compsupp6971_translate_strings_from_hestia($original_value, $domain) { if( class_exists('Sitepress') ){ $string = $original_value; $textdomain = 'hestia-pro'; $string_name = $domain.': '.substr($string, 0, 20); $wpml_default_lang = apply_filters('wpml_default_language', NULL ); $wpml_current_lang = apply_filters( 'wpml_current_language', NULL ); if ($wpml_default_lang == $wpml_current_lang ) { do_action( 'wpml_register_single_string', $textdomain, $string_name, $string ); } // Apply the translation to the string $wpml_translation = apply_filters('wpml_translate_single_string', $string , $textdomain, $string_name); return $wpml_translation; } return $original_value; } add_filter( 'hestia_translate_single_string', 'wpml_compsupp6971_translate_strings_from_hestia', 11, 2 ); - 在前端访问该页面以注册字符串。
- 前往 WPML > 字符串翻译页面并翻译字符串