- Status
- Waiting for author
- Type
- Bug
- Reported for
- Complianz | GDPR/CCPA Cookie Consent 7.5.0
- Related plugin/theme
- Complianz | GDPR/CCPA Cookie Consent
- Topic tags
- Compatibility
Overview of the issue
When you use Complianz | GDPR/CCPA Cookie Consent on a site whose default language is not English, some plugin strings are registered in WPML → String Translation with English as the source language.
Complianz registers some of its cookie banner strings after WordPress translates them. On a Spanish site, the default string Accept is saved as Aceptar, and Complianz registers Aceptar without a source language. WPML then treats the string as English.
This affects the cookie banner strings and the strings that Complianz registers through its own cmplz_register_translation() helper. The cookie database of the plugin is not affected, because that code registers the English values.
Workaround
Make a full backup of your site before you continue.
The first part changes the plugin code, so Complianz registers its strings with the site language. The line numbers are from Complianz 7.5.5. Apply the change again after every Complianz update, until the plugin ships the fix.
- Open the …/wp-content/plugins/complianz-gdpr/cookiebanner/class-cookiebanner.php file.
- Look for lines 491 and 494.
- Replace:
icl_register_string( 'complianz', $fieldname . $key, $string ); do_action( 'wpml_register_single_string', 'complianz', $fieldname, $string ); - With:
$lang = apply_filters( 'wpml_default_language', null ); icl_register_string( 'complianz', $fieldname . $key, $string, false, $lang ); do_action( 'wpml_register_single_string', 'complianz', $fieldname . $key, $string, false, $lang ); - Open the …/wp-content/plugins/complianz-gdpr/functions.php file. It registers the document titles, the URLs and the settings in the cmplz_register_translation() function.
- Look for lines 2255 and 2258.
- Replace:
icl_register_string( 'complianz', $fieldname, $string ); do_action( 'wpml_register_single_string', 'complianz', $fieldname, $string ); - With:
$lang = apply_filters( 'wpml_default_language', null ); icl_register_string( 'complianz', $fieldname, $string, false, $lang ); do_action( 'wpml_register_single_string', 'complianz', $fieldname, $string, false, $lang ); - Save the banner again in Complianz → Cookie banner, so the plugin registers the strings with the site language.
The code change only helps new strings. The strings that Complianz already registered keep English as their source language, so correct them by hand:
- Go to WPML → String Translation.
- In Select strings within domain, choose the complianz domain.
- Select the strings that show the wrong language.
- Open Change the language of selected strings at the bottom of the page.
- Choose the real language of the strings, for example Spanish, and apply the change.
- Translate the strings into your secondary languages.