This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing a JavaScript error in the WordPress admin related to the ACFML (Advanced Custom Fields Multilingual) plugin, where the browser console shows a 'ReferenceError: Can't find variable: wp', this is due to ACFML attempting to call wp.data.dispatch() before the wp object is defined.
Solution:
As a temporary workaround, you can implement a polyfill in your theme's functions.php file. Here's how:
add_action( 'wp_loaded', 'your_custom_fix_acfml_notice', 100 );<br />function your_custom_fix_acfml_notice() {<br /> if ( ! class_exists( '\ACFML\Post\MixedFieldGroupModesHooks' ) ) {<br /> return;<br /> }<br /> add_action( 'wp_print_scripts', 'your_acfml_polyfill', 1 );<br />}<br />function your_acfml_polyfill() {<br /> ?><br /> if ( typeof wp === 'undefined' ) {<br /> window.wp = {};<br /> }<br /> if ( typeof wp.data === 'undefined' ) {<br /> window.wp.data = {<br /> dispatch: function(store) {<br /> return {<br /> createNotice: function(type, message, options) {<br /> document.addEventListener('DOMContentLoaded', function() {<br /> if (window.wp && window.wp.data && window.wp.data.dispatch) {<br /> window.wp.data.dispatch(store).createNotice(type, message, options);<br /> }<br /> });<br /> }<br /> };<br /> }<br /> };<br /> }<br /> <?php<br />}<br />This workaround prevents the error until the real wp.data becomes available. However, this is only a temporary solution. We have escalated this issue to our development team, and it should be addressed in the upcoming ACFML release 3.0.0.
Please note that this solution might be irrelevant if it's outdated or not applicable to your case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum.
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.
This topic contains 25 replies, has 0 voices.
Last updated by 2 weeks, 6 days ago.
Assisted by: Dražen.

