WPML

问题概述

Houzez 主题使用其自身的自定义函数来调用其主题选项。如果您网站的默认语言不是英语,此函数将与 WPML 发生冲突。导致的结果是,翻译将不会在前端显示,并且在管理后台中将恢复为默认语言。

临时解决方法

这个问题已修复。 更新到最新版本即可在您的站点上解决此问题,因此,只有当您暂时无法更新时,才需要此临时解决方法。

在继续操作之前,请对您的网站进行完整备份。

  1. 打开 /wpml-string-translation/inc/admin-texts/wpml-admin-texts.class.php。
  2. 找到第 198 行。
  3. 将:
    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 );
    		}
    	}
    }
  4. 替换为:
    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月底)发布时得到解决。

所有已知问题

仍然遇到此问题?

如果更新无法解决问题,请提出支持问题,我们将与您一起排查。