- Stato
- In attesa dell’autore
- Plugin/tema correlato
- Dokan
- Tag dell’argomento
- Compatibility
Panoramica del problema
Quando utilizzi Dokan con WPML configurato nella modalità Un dominio diverso per lingua, il selettore di lingua potrebbe generare URL non validi contenenti un prefisso di dominio aggiuntivo. Ad esempio, passare al francese potrebbe generare un URL come “https://domain.com/fr/https://domain.fr/” invece di quello corretto “https://domain.fr”.
Soluzione alternativa
Assicurati di avere un backup completo del tuo sito prima di procedere.
- Apri il file …/wp-content/plugins/dokan-wpml/dokan-wpml.php.
- Cerca la riga 1871.
- Sostituisci:
public function filter_language_switcher_url( $url, $lang ) { $lang_code = $lang['code'] ?? ''; if ( empty( $url ) || empty( $lang_code ) ) { return $url; } // Get home URL without WPML modifications. $this->disable_url_translation(); $home_url = home_url(); $this->enable_url_translation(); $default_language_code = wpml_get_default_language(); $language_negotiation_type = (int) apply_filters( 'wpml_setting', 1, 'language_negotiation_type' ); $is_parameter_based = ( WPML_LANGUAGE_NEGOTIATION_TYPE_PARAMETER === $language_negotiation_type ); if ( ! $is_parameter_based && $default_language_code !== $lang_code ) { $base_url = trailingslashit( $home_url ) . $lang_code; } else { $base_url = $home_url; }
- Con:
public function filter_language_switcher_url( $url, $lang ) { $lang_code = $lang['code'] ?? ''; if ( empty( $url ) || empty( $lang_code ) ) { return $url; } $language_negotiation_type = (int) apply_filters( 'wpml_setting', 1, 'language_negotiation_type' ); if ( WPML_LANGUAGE_NEGOTIATION_TYPE_DOMAIN === $language_negotiation_type ) { return $url; } $this->disable_url_translation(); $home_url = home_url(); $this->enable_url_translation(); $default_language_code = wpml_get_default_language(); $is_parameter_based = ( WPML_LANGUAGE_NEGOTIATION_TYPE_PARAMETER === $language_negotiation_type ); if ( ! $is_parameter_based && $default_language_code !== $lang_code ) { $base_url = trailingslashit( $home_url ) . $lang_code; } else { $base_url = $home_url; }
- Salva il file e svuota la cache del tuo sito