- Status
- Resolved
- Reported for
- WPML Multilingual for CF7 1.2.1
- Resolved in
- Contact Form 7 Multilingual 1.2.2
- Related plugin/theme
- Contact Form 7
- Topic tags
- Compatibility
Overview of the issue
When adding forms using Contact Form 7 plugin and the do_shortcode() PHP method, the forms do not appear translated as expected.
Workaround
Please, make sure of having a full backup of your site before proceeding.
- Open …/wp-content/plugins/contact-form-7-multilingual/classes/shortcodes.php file.
- Look for line 21.
- Replace:
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; } - For:
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; }