- 状态
- 等待作者
- 主题标签
- Compatibility
问题概述
当将 eRecht24 legal texts for WordPress 与 WPML 一起使用时,通过 eRecht24 简码或 Elementor 小工具添加的法律文本可能会以错误的语言显示。发生这种情况是因为需要在 eRecht24 简码或小工具设置中设置语言。
此处未使用 WPML 语言,因此您可能需要手动编辑翻译,以在简码或小工具中选择正确的语言。
临时解决方法
请在继续操作前,确保为您的网站创建完整的网站备份。
- 将以下代码添加到主题的 functions.php 文件中。
// WPML - Workaround for compsupp-8368 use the shortcode_atts_{$shortcode} filter to change 'lang' to the current language or fallback to English
add_filter( 'shortcode_atts_erecht24', function ( $out, $pairs, $atts, $shortcode ) {
if ( ! class_exists( 'SitePress' ) ) {
return $out;
}
$current_lang = apply_filters( 'wpml_current_language', null );
$out['lang'] = in_array( $current_lang, array( 'de', 'en' ), true ) ? $current_lang : 'en';
return $out;
}, 10, 4 );