- Statut
- Résolu
- Signalé pour
- WPML Multilingual CMS 4.5.8
- Résolu dans
- 4.5.9
Aperçu de l’anomalie
Dans certains environnements d’hébergement, vous remarquerez que les feuilles de style de WPML ne se chargent pas correctement. Si vous consultez la console du navigateur, vous constaterez que les feuilles de style pointent vers le dossier /ontent/ au lieu de /wp-content/. Par exemple :
https://domain.com/ontent/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal/style.css?ver=1
Solution de contournement
Faites une sauvegarde complète de votre site avant de continuer.
- Ouvrez le fichier /wp-content/plugins/sitepress-multilingual-cms/classes/class-wpml-file.php.
- Cherchez la ligne 66 :
- Remplacez :
public function get_uri_from_path( $path ) { $base = null; if ( $this->wp_api->defined( 'WP_CONTENT_DIR' ) && $this->wp_api->defined( 'WP_CONTENT_URL' ) ) { $base_path = $this->fix_dir_separator( $this->wp_api->constant( 'WP_CONTENT_DIR' ) ); if ( 0 === strpos( $path, $base_path ) ) { $base = array( 'path' => $base_path, 'uri' => $this->wp_api->constant( 'WP_CONTENT_URL' ), ); } } if ( ! $base ) { $base = array( 'path' => $this->wp_api->constant( 'ABSPATH' ), 'uri' => site_url(), ); } $base['uri'] = preg_replace( '/(^https?:)/', '', $base['uri'] ); $relative_path = substr( $path, strlen( $base['path'] ) ); $relative_path = str_replace( array( '/', '' ), '/', $relative_path ); $relative_path = ltrim( $relative_path, '/' ); return trailingslashit( $base['uri'] ) . $relative_path; } - Par :
public function get_uri_from_path( $path ) { $base = null; if ( $this->wp_api->defined( 'WP_CONTENT_DIR' ) && $this->wp_api->defined( 'WP_CONTENT_URL' ) ) { $base_path = $this->fix_dir_separator( $this->wp_api->constant( 'WP_CONTENT_DIR' ) ); if ( 0 === strpos( $path, $base_path ) ) { $base = array( 'path' => $base_path, 'uri' => $this->wp_api->constant( 'WP_CONTENT_URL' ), ); } } if ( ! $base ) { $base = array( 'path' => $this->wp_api->constant( 'ABSPATH' ), 'uri' => site_url(), ); if ( 0 !== strpos( $path, $base_path )) { $search = (WPML_PLUGIN_PATH); $pathexplode = explode($this->wp_api->constant( 'DIRECTORY_SEPARATOR' ), WPML_PLUGIN_PATH); $pathexplode = array_slice($pathexplode, -3, 3, false); $replace = $pathexplode[0] .$this->wp_api->constant( 'DIRECTORY_SEPARATOR' ) . $pathexplode[1].$this->wp_api->constant( 'DIRECTORY_SEPARATOR' ).WPML_PLUGIN_FOLDER; $base["path"] = str_replace ($replace, "", $search); } } $base['uri'] = preg_replace( '/(^https?:)/', '', $base['uri'] ); $relative_path = substr( $path, strlen( $base['path'] ) ); $relative_path = str_replace( array( '/', '\' ), '/', $relative_path ); $relative_path = ltrim( $relative_path, '/' ); return trailingslashit( $base['uri'] ) . $relative_path; }