Problem using wp.i18n in frontend scripts
-
Good morning,
I have a problem of conflicts between plugins.
Both of those plugins, load some front end javascript involving jquery (in $deps, they have both “$deps = array (‘jquery’, ‘wp-i18n’)” in wp_enqueue_script.
The first line of those scripts are:'use strict'; // i18n support const { __, _x, _n, _nx } = wp.i18n;
The scripts are:
https://plugins.svn.wordpress.org/perfecty-push-notifications/tags/1.0.7/public/js/perfecty-push-public.js and it is enqued in footer here: https://plugins.trac.wordpress.org/browser/perfecty-push-notifications/tags/1.0.7/public/class-perfecty-push-public.php#L70
and
https://plugins.svn.wordpress.org/campi-moduli-italiani/tags/1.2.2/modules/comune/js/ajax.js
and it is registered with $in_footer=false here: https://plugins.trac.wordpress.org/browser/campi-moduli-italiani/tags/1.2.2/modules/comune/class-gcmi-comune.php#L317The problem is that on pages loading both of them, I got a console error:
Uncaught SyntaxError: redeclaration of const __
(triggered by the ajax.js)
I have tried to substitute in both of them the first lines with:'use strict'; // i18n support if (typeof __ !== undefined) { const { __, _x, _n, _nx } = wp.i18n; }
but now I got:
Uncaught ReferenceError: __ is not defined
I think I have followed instructions in https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/, so I don’t understand how to address the issue.
- The topic ‘Problem using wp.i18n in frontend scripts’ is closed to new replies.