Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

Tagged: 

This topic contains 9 replies, has 0 voices.

Last updated by Dražen 1 week, 6 days ago.

Assisted by: Dražen.

Author Posts
March 11, 2026 at 10:23 am #17888218

Philip

Hello,

We are encountering a JavaScript error in the WordPress admin that appears to be caused by the ACFML (Advanced Custom Fields Multilingual) plugin.

On the page edit screen in the admin, the browser console shows the following error:

ReferenceError: Can't find variable: wp

From what we can see, ACFML attempts to call wp.data.dispatch() to display a notice, but the global wp object is not yet defined at that moment. This leads to the console error.

Temporary workaround

As a temporary workaround, we implemented a small polyfill in our theme (functions.php) that prevents the error by defining a minimal wp.data.dispatch() until the real wp.data becomes available.

Example of the workaround:

add_action( 'wp_loaded', 'vogelwarte_fix_acfml_notice', 100 );

function vogelwarte_fix_acfml_notice() {
if ( ! class_exists( '\ACFML\Post\MixedFieldGroupModesHooks' ) ) {
return;
}

add_action( 'wp_print_scripts', 'vogelwarte_acfml_polyfill', 1 );
}

function vogelwarte_acfml_polyfill() {
?>

if ( typeof wp === 'undefined' ) {
window.wp = {};
}

if ( typeof wp.data === 'undefined' ) {
window.wp.data = {
dispatch: function(store) {
return {
createNotice: function(type, message, options) {
document.addEventListener('DOMContentLoaded', function() {
if (window.wp && window.wp.data && window.wp.data.dispatch) {
window.wp.data.dispatch(store).createNotice(type, message, options);
}
});
}
};
}
};
}

<?php
}

This removes the console error, but it is clearly only a workaround and ideally should be handled inside the plugin.

Could you please investigate why ACFML triggers wp.data.dispatch() before the wp object is available and provide a proper fix?

Environment:
WordPress: 6.9.1
PHP: 8.3.29

WPML plugins:
WPML Multilingual CMS 4.9.2
WPML String Translation 3.5.1
WPML Media Translation 3.1.0
WPML SEO 2.2.5

ACF plugin:
Advanced Custom Fields Multilingual 2.2.1

Thank you!

March 13, 2026 at 7:09 am #17894386

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thank you for the report.

Would it be possible to check if this issue can also be seen on the staging site we created in the other ticket? If yes, please let me know where exactly we can reproduce it.

Additionally, does the issue still happens in a minimal setup (only WPML and ACF + WP default theme) I have set it like that already on staging site, so it would be easier to confirm as custom coded theme are a bit out of scope of our support.

Please let me know.

Regards,
Drazen

March 13, 2026 at 12:11 pm #17895439

Philip

Hi Drazen,

Feel free to reproduce on that environment, yes.

URL: hidden link
Screenshot: hidden link

This is from where error is coming: wp-content/plugins/acfml/classes/Post/MixedFieldGroupModesHooks.php
Screenshot: hidden link

Please let me know.

March 13, 2026 at 12:32 pm #17895512

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thank you for sharing the staging access and details.

Before we investigate the code further, could we please first try the step I mentioned in the other ticket as well? Since you are using Expert mode, please review the ACF field translation settings and make sure they follow the recommended configuration:

- https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/

After reviewing and adjusting the settings, if the issue still happens please let me know and I will continue to check this aswell.

Regards,
Drazen

March 15, 2026 at 3:57 pm #17898346

Philip

Hello Dražen,

Thank you for your reply.

We have reviewed the ACF translation preferences as suggested and verified that the fields follow the recommended configuration.

However, this check did not reveal any changes in behavior. The issue still persists and the same error appears in the console when attempting to save the translated content.

URL: hidden link
Screenshot: hidden link

This is from where error is coming: wp-content/plugins/acfml/classes/Post/MixedFieldGroupModesHooks.php
Screenshot: hidden link

Thank you for your help.

March 16, 2026 at 6:57 am #17898745

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thank you for the update and for sharing the details.

I checked the page from my side and at the moment I’m not seeing the same. I also switched the editor to the WordPress editor, which is the correct approach when editing translated content manually and saving it.

Could you please check again on your side and confirm if the error is still appearing?

If possible, please share if I need to do anything else other then Save FR draft and enable logs and show all message / errors in browser console.

Kind regards,
Dražen

Edit-Page-“Sperlinge”-‹-Schweizerische-Vogelwarte-—-WordPress-03-16-2026_07_40_AM.jpg
March 16, 2026 at 9:27 pm #17901777

Philip

Hi Drazen,

Thanks for your message.

You can clearly see the error by visiting this page and checking the browser console:
hidden link
hidden link

This is where the error appears to be coming from:
wp-content/plugins/acfml/classes/Post/MixedFieldGroupModesHooks.php
hidden link
hidden link

Please let me know your thoughts.

March 17, 2026 at 6:45 am #17902391

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thank you very much for the detailed information and screenshots.

I was able to reproduce the issue on a clean WordPress installation when using the Classic Editor plugin. The issue does not occur when using the default Gutenberg editor.

I have escalated this to our development team for further review, and it should be addressed in one of the upcoming WPML releases.

Thank you for your patience and for helping us identify this.

Regards,
Dražen

March 17, 2026 at 12:37 pm #17904596

Philip

Hi Dražen,

Thank you for the update and for escalating this to your development team.

From my side, everything looks clear. Please let me know if you need anything else from my side, otherwise I believe we can proceed with the fix on your end.

Thanks again, looking forward to the upcoming release.

March 17, 2026 at 12:47 pm #17904674

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you!

At this point, no further input is needed from your side. I’ll keep you updated as soon as I have any news, progress, or a possible workaround to share.

Thanks again for your patience.

Kind regards,
Dražen