WPML
상태
해결됨
보고된 제품
WPML Multilingual CMS 4.5.8
해결된 버전
4.5.9

문제 개요

특정 호스팅 환경에서는 WPML의 스타일시트가 올바르게 로드되지 않는 것을 확인할 수 있습니다. 브라우저 콘솔을 확인하면 스타일시트가 /wp-content/ 대신 /ontent/ 폴더를 가리키는 것을 확인할 수 있습니다. 예를 들면 다음과 같습니다.

https://domain.com/ontent/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal/style.css?ver=1

임시 해결 방법

진행하기 전에 사이트의 전체 백업을 수행하세요.

  1. /wp-content/plugins/sitepress-multilingual-cms/classes/class-wpml-file.php 파일을 여세요.
  2. 66번째 줄을 찾으세요:
  3. 다음 내용을:
    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;
    }
  4. 다음과 같이 변경하세요:
    	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;
    	}

알려진 모든 문제 →