- Estado
- Esperando al autor
- Plugin/tema relacionado
- Dokan
- Etiquetas de temática
- Compatibility
Resumen del problema
Al usar Dokan con WPML configurado en el modo un dominio diferente por idioma, el selector de idiomas puede generar URL no válidas que contienen un prefijo de dominio adicional. Por ejemplo, cambiar al francés podría dar como resultado una URL como «https://domain.com/fr/https://domain.fr/» en lugar de la correcta «https://domain.fr».
Solución alternativa
Por favor, asegúrese de tener una copia de seguridad completa de su sitio antes de continuar.
- Abra el archivo …/wp-content/plugins/dokan-wpml/dokan-wpml.php.
- Busque la línea 1871.
- Reemplace:
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; }
- Por:
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; }
- Guarde el archivo y borre la caché de su sitio