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;
    	}

すべての既知の問題 →