탐색 건너뛰기

Open

Reported for: WPML Multilingual CMS 4.6.13

Topic Tags: ATE, Compatibility

Overview of the issue

When translating pages created with Elementor using WPML’s Advanced Translation Editor (ATE), characters like < (less than) or > (greater than) are stripped out or incorrectly interpreted as HTML tags.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open …/wp-content/plugins/sitepress-multilingual-cms/classes/xliff/class-wpml-tm-xliff-writer.php file.
  • Look for line 407.
  • Replace:
    	private function remove_line_breaks_inside_tags( $string ) {
    		return preg_replace_callback( '/(<[^>]*>)/m', array( $this, 'remove_line_breaks_inside_tag_callback' ), $string );
    	}
    
    	/**
    	 * @param array $matches
    	 *
    	 * @return string
    	 */
    	private function remove_line_breaks_inside_tag_callback( array $matches ) {
    		$tag_string = preg_replace( '/([\nr\t ]+)/', ' ', $matches[0] );
    		$tag_string = preg_replace( '/(<[\s]+)/', '<', $tag_string );
    		return preg_replace( '/([\s]+>)/', '>', $tag_string );
    	}
    
  • With:
    	private function remove_line_breaks_inside_tags( $string ) {
    	    // Match only valid HTML tags (opening, closing, or self-closing)
    	    return preg_replace_callback( '/(<\/?[a-zA-Z][^<>]*>)/m', array( $this, 'remove_line_breaks_inside_tag_callback' ), $string );
    	}
    
    	/**
    	 * @param array $matches
    	 *
    	 * @return string
    	 */
    	private function remove_line_breaks_inside_tag_callback( array $matches ) {
    	    // Remove unnecessary spaces and line breaks inside valid HTML tags
    	    $tag_string = preg_replace( '/([\nr\t ]+)/', ' ', $matches[0] );
    	    $tag_string = preg_replace( '/(<[\s]+)/', '<', $tag_string );
    	    return preg_replace( '/([\s]+>)/', '>', $tag_string );
    	}
    

답장을 남겨주세요

주제를 유지하고 다른 사람을 존중하십시오. 이 게시물과 관련 없는 문제에 대한 도움이 필요한 경우 지원 포럼을 사용하여 채팅을 시작하거나 티켓을 제출하십시오.

다음 태그를 사용할 수 있습니다.
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>