- 状态
- 已解决
- 解决于
- 4.5.0
- 相关插件/主题
- Houzez
问题概述
Houzez 主题使用其自身的自定义函数来调用其主题选项。如果您网站的默认语言不是英语,此函数将与 WPML 发生冲突。导致的结果是,翻译将不会在前端显示,并且在管理后台中将恢复为默认语言。
临时解决方法
在继续操作之前,请对您的网站进行完整备份。
- 打开 /wpml-string-translation/inc/admin-texts/wpml-admin-texts.class.php。
- 找到第 198 行。
- 将:
function icl_st_set_admin_options_filters() { $option_names = $this->getOptionNames(); foreach ( $option_names as $option_key => $option ) { if ( $this->is_blacklisted( $option_key ) ) { unset( $option_names[ $option_key ] ); update_option( '_icl_admin_option_names', $option_names ); } elseif ( $option_key != 'theme' && $option_key != 'plugin' ) { // theme and plugin are an obsolete format before 3.2 add_filter( 'option_' . $option_key, array( $this, 'icl_st_translate_admin_string' ) ); add_action( 'update_option_' . $option_key, array( $this, 'on_update_original_value' ), 10, 3 ); } } } - 替换为:
function icl_st_set_admin_options_filters() { $option_names = $this->getOptionNames(); $isAdmin = is_admin() && ! wpml_is_ajax(); foreach ( $option_names as $option_key => $option ) { if ( $this->is_blacklisted( $option_key ) ) { unset( $option_names[ $option_key ] ); update_option( '_icl_admin_option_names', $option_names ); } elseif ( $option_key != 'theme' && $option_key != 'plugin' ) { // theme and plugin are an obsolete format before 3.2 /** * We don't want to translate admin strings in admin panel because it causes a lot of confusion * when a value is displayed inside the form input. **/ if ( ! $isAdmin ) { add_filter( 'option_' . $option_key, array( $this, 'icl_st_translate_admin_string' ) ); } add_action( 'update_option_' . $option_key, array( $this, 'on_update_original_value' ), 10, 3 ); } } }
后续步骤
此问题将在 WPML 4.5 版本(2021年9月底)发布时得到解决。