WPML
Status
Gelöst
Gemeldet für
WPML Multilingual for CF7 1.2.1
Gelöst in
Contact Form 7 Multilingual 1.2.2
Zugehöriges Plugin/Theme
Contact Form 7
Themen-Tags
Compatibility

Übersicht über das Problem

Beim Hinzufügen von Formularen mit dem Plugin Contact Form 7 und der PHP-Methode do_shortcode() erscheinen die Formulare nicht wie erwartet übersetzt.

Problemumgehung

Bitte vergewissern Sie sich, dass Sie über ein vollständiges Backup Ihrer Website verfügen, bevor Sie fortfahren.


  • Öffnen Sie die Datei …/wp-content/plugins/contact-form-7-multilingual/classes/shortcodes.php.

  • Suchen Sie nach Zeile 21.

  • Ersetzen Sie:
    	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;
    	}


  • Durch:
    	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;
    	}

Alle bekannten Probleme →