Waiting for author
Overview of the issue
When using eRecht24 legal texts for WordPress with WPML, legal texts added via the eRecht24 shortcode or Elementor widget might display in the wrong language. This can happen because the language needs to be set in the eRecht24 shortcode or widget settings.
WPML languages are not used here, so you might need to manually edit your translation to select the correct language in the shortcode or widget.
Workaround
Please, make sure of having a full site backup of your site before proceeding.
- Add the following code to your theme’s functions.php file.
// WPML - Workaround for compsupp-8368 use the shortcode_atts_{$shortcode} filter to change 'lang' to the current language or fallback to English
add_filter( 'shortcode_atts_erecht24', function ( $out, $pairs, $atts, $shortcode ) {
if ( ! class_exists( 'SitePress' ) ) {
return $out;
}
$current_lang = apply_filters( 'wpml_current_language', null );
$out['lang'] = in_array( $current_lang, array( 'de', 'en' ), true ) ? $current_lang : 'en';
return $out;
}, 10, 4 );