- 状态
- 已解决
- 报告针对
- WPML Multilingual CMS 4.6.6
- 相关插件/主题
- Divi
- 主题标签
- ATE, Compatibility
问题概述
使用 Divi 主题时,您会注意到,当使用 WPML 翻译包含撇号的按钮文本时,撇号会显示为 HTML 实体。
临时解决方法
在继续操作之前,请确保对您的站点进行了完整备份。
- 将以下代码添加到主题的 functions.php 文件中:
// WPML workaround for compsupp-7001 add_filter('do_shortcode_tag', 'wpml_compsupp7001_decode_et_pb_button_text', 10, 4); function wpml_compsupp7001_decode_et_pb_button_text($output, $tag, $attr, $m) { if ( class_exists('Sitepress') && 'et_pb_button' === $tag && isset($attr['button_text'])) { // Decode both the ampersand and the apostrophe $output = html_entity_decode($output, ENT_QUOTES, 'UTF-8'); } return $output; }
请注意,如果您使用的是滑块按钮,您将需要使用以下代码行:
if ( class_exists('Sitepress') && 'et_pb_slide' === $tag && isset($attr['button_text'])) {而不是:
if ( class_exists('Sitepress') && 'et_pb_button' === $tag && isset($attr['button_text'])) {
如果您使用的是手风琴项,您将需要使用以下代码行:
if ( class_exists('Sitepress') && 'et_pb_accordion_item' === $tag && isset($attr['title'])) {而不是:
if ( class_exists('Sitepress') && 'et_pb_button' === $tag && isset($attr['button_text'])) {
