WPML
상태
해결됨
보고된 제품
WPML Multilingual for CF7 1.2.1
해결된 버전
Contact Form 7 Multilingual 1.2.2
관련 플러그인/테마
Contact Form 7
주제 태그
Compatibility

문제 개요

Contact Form 7 플러그인과 do_shortcode() PHP 메서드를 사용하여 양식을 추가할 때, 양식이 예상대로 번역되어 표시되지 않습니다.

임시 해결 방법

진행하기 전에 반드시 사이트의 전체 백업을 완료했는지 확인하세요.


  • …/wp-content/plugins/contact-form-7-multilingual/classes/shortcodes.php 파일을 여세요.

  • 21번째 줄을 찾으세요.

  • 다음 코드를:
    	public function translate_shortcode_form_id( $atts ) {
    		$form = null;
    
    		if ( ! empty( $atts['id'] ) ) {
    			$form = wpcf7_contact_form( (int) $atts['id'] );
    		}
    
    		if ( ! $form && ! empty( $atts['title'] ) ) {
    			$form = wpcf7_get_contact_form_by_title( trim( $atts['title'] ) );
    			unset( $atts['title'] );
    		}
    
    		if ( $form ) {
    			$atts['id'] = apply_filters( 'wpml_object_id', $form->id(), Constants::POST_TYPE, true );
    		}
    
    		return $atts;
    	}


  • 다음과 같이 변경하세요:
    	public function translate_shortcode_form_id( $atts ) {
    		$form = null;
    
    		if ( ! empty( $atts['id'] ) && is_numeric($atts['id']) ) {
    			$form = wpcf7_contact_form( (int) $atts['id'] );
    		}
    
    		if ( ! $form && ! empty( $atts['title'] ) ) {
    			$form = wpcf7_get_contact_form_by_title( trim( $atts['title'] ) );
    			unset( $atts['title'] );
    		}
    		if ($form == null){
    			$form = wpcf7_get_contact_form_by_hash( $atts['id']);
    		}
    		if ( $form ) {
    			$atts['id'] = apply_filters( 'wpml_object_id', $form->id(), Constants::POST_TYPE, true );
    		}
    
    		return $atts;
    	}

알려진 모든 문제 →