[wp-trac] [WordPress Trac] #29918: Allow script localization to be set on wp_register_script
WordPress Trac
noreply at wordpress.org
Fri Oct 10 11:19:50 UTC 2014
#29918: Allow script localization to be set on wp_register_script
-----------------------------+-----------------------------
Reporter: jadpm | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: 4.0
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
Not sure if that has been asked before, could not find it.
Let script_a.js be a script that needs some localization. Let script_b.js
be a script that has script_a.js as a dependency. We can register both of
them with the right dependency settings, and enqueue just script_b.js.
This will enqueue script_a.js, but we have no way of localizing it. The
only way to do so is to enqueue script_a.js manually, making the
dependency feature useless.
The goal should be to have the localization data ready on enqueue time, no
matter whether the script is being used as a dependency or not. As you can
add multiple localizations to the same script, this should not break
existing calls to wp_localize_script.
I see that the registering of both styles and scripts is handled by the
same base method WP_Dependencies::add, so this might not be as simple as
to add another parameter to wp_register_script. Anyhow, this would be a
very nice feature.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29918>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list