- Status
- Gelöst
- Gemeldet für
- WPML Multilingual CMS 4.5.8
- Gelöst in
- 4.5.9
Übersicht über das Problem
In bestimmten Hosting-Umgebungen werden Sie feststellen, dass die Stylesheets von WPML nicht korrekt geladen werden. Wenn Sie die Browser-Konsole prüfen, werden Sie feststellen, dass die Stylesheets auf den Ordner /ontent/ statt auf /wp-content/ verweisen. Zum Beispiel:
https://domain.com/ontent/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal/style.css?ver=1
Problemumgehung
Erstellen Sie ein vollständiges Backup Ihrer Website, bevor Sie fortfahren.
- Öffnen Sie die Datei /wp-content/plugins/sitepress-multilingual-cms/classes/class-wpml-file.php.
- Suchen Sie nach Zeile 66:
- Ersetzen Sie:
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; } - Durch:
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; }