Visão geral do problema
Ao usar o tema Houzez com o WPML e a Tradução de Strings, os textos traduzidos nas Opções do tema podem mudar para outro idioma do site depois que você salvar as opções, mesmo quando o idioma correto estiver selecionado no painel. Os textos que você não alterou nesse salvamento são substituídos por sua tradução em outro idioma.
Solução alternativa
Antes de começar, faça um backup completo do seu site e banco de dados.
Passo 1 – Restaurar os textos no idioma padrão das opções do tema
- Adicione este código ao arquivo functions.php do seu tema:
PHP
// WPML workaround for compsupp-8287 if ( ! function_exists( 'compsupp8287_restore_houzez_options' ) ) { function compsupp8287_restore_houzez_options() { if ( ! isset( $_GET['compsupp8287_fix'] ) || ! current_user_can( 'manage_options' ) ) { return; } global $wpdb; $default_language = apply_filters( 'wpml_default_language', null ); $rows = $wpdb->get_results( $wpdb->prepare( "SELECT s.id, s.name, s.value AS current_value, t.value AS correct_value FROM {$wpdb->prefix}icl_strings s JOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id AND t.language = %s WHERE s.context = 'admin_texts_houzez_options' AND s.value <> t.value", $default_language ) ); if ( empty( $rows ) ) { wp_die( 'No corrupted fields found. Nothing to fix.' ); } $raw_option = $wpdb->get_var( "SELECT option_value FROM {$wpdb->options} WHERE option_name = 'houzez_options'" ); $options = maybe_unserialize( $raw_option ); if ( ! is_array( $options ) ) { wp_die( 'Could not read houzez_options. No changes made.' ); } $changed = 0; foreach ( $rows as $row ) { if ( ! preg_match( '/^[houzez_options](.+)$/', $row->name, $m ) ) { continue; } $field = $m[1]; if ( ( $options[ $field ] ?? null ) !== $row->correct_value ) { $options[ $field ] = $row->correct_value; $changed++; } $wpdb->update( "{$wpdb->prefix}icl_strings", array( 'value' => $row->correct_value ), array( 'id' => $row->id ) ); } update_option( 'houzez_options', $options ); delete_option( 'houzez_options-transients' ); wp_die( 'Restored ' . $changed . ' field(s). You may now remove this code from functions.php.' ); } add_action( 'init', 'compsupp8287_restore_houzez_options' ); }
- Enquanto estiver conectado como administrador, abra sua página inicial com
?compsupp8287_fix=1no final do URL (por exemplo,https://example.com/?compsupp8287_fix=1). Aguarde até que uma mensagem de confirmação seja exibida. - Remova o código deste passo do functions.php.
Passo 2 – Evitar o problema nos próximos salvamentos
- Adicione este código ao arquivo functions.php do seu tema e mantenha-o:
PHP
// WPML workaround for compsupp-8287 // Prevents Theme Options translations from being overwritten with the wrong language on save. if ( ! function_exists( 'compsupp8287_skip_houzez_options_translation_filter' ) ) { function compsupp8287_skip_houzez_options_translation_filter( $skip, $option_key ) { if ( 'houzez_options' !== $option_key ) { return $skip; } $is_redux_save_action = isset( $_REQUEST['action'] ) && 'houzez_options_ajax_save' === $_REQUEST['action']; if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && $is_redux_save_action ) { return true; } return $skip; } add_filter( 'wpml_skip_admin_options_filters', 'compsupp8287_skip_houzez_options_translation_filter', 10, 2 ); }