[wp-trac] [WordPress Trac] #43248: wp_localize_script() and ultimately print_extra_script() not using script_loader_tag filter

WordPress Trac noreply at wordpress.org
Wed Feb 7 17:08:09 UTC 2018


#43248: wp_localize_script() and ultimately print_extra_script() not using
script_loader_tag filter
---------------------------+------------------------------
 Reporter:  csmillie       |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Script Loader  |     Version:  4.9.4
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:  javascript
---------------------------+------------------------------

Comment (by csmillie):

 Thanks for the prompt feedback.

 You are correct the original filter defines the last parameter as a URL
 but I think using the JS output is consistent with the context and use
 case for the tag.

 The filter allows adjustments to the tag surrounding the URL ( in the
 original definition ) or JS output ( as I've used ).  This seems to be a
 natural extension to me but could be breaking as you point out.

 I'm unclear if a new filter should be defined or the existing filter (
 script_loader_tag ) should be re-defined/updated to note this change?

 Thanks again.

 Replying to [comment:1 ocean90]:
 > Hello @csmillie, welcome to WordPress Trac!
 >
 > Thanks for your request. It looks like your proposed change wouldn't be
 backward compatible because current plugins expect a URL for the `$src`
 argument and not raw JavaScript. Maybe it should be left empty instead.
 What do you think? And what's your use case for the filter at this place?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43248#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list