[wp-trac] [WordPress Trac] #13592: script_loader_src and style_loader_tag filters

WordPress Trac noreply at wordpress.org
Sun Nov 9 22:16:16 UTC 2014


#13592: script_loader_src and style_loader_tag filters
---------------------------+------------------
 Reporter:  olivM          |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  4.1
Component:  Script Loader  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:
---------------------------+------------------

Comment (by spacedmonkey):

 Replying to [comment:21 ocean90]:
 > For `style_loader_tag` we have this:
 >
 > {{{
 > apply_filters(
 >       'style_loader_tag',
 >       "<link rel='$rel' id='$handle-css' $title href='$href'
 type='text/css' media='$media' />\n",
 >       $handle
 > );
 > }}}
 >
 > So you can filter the entire HTML link tag. But
 [attachment:13592.4.diff] allows only to filter the script part without
 the src. That looks confusing to me.
 > We should either filter the entire HTML script tag or rename the filter
 to something else.
 >
 >
 >
 >

 I disagree, if you wish to modify the src tag, make the filter take 2
 params which will get the src. Then when you filter the script tag, just
 don't return a string with %s in it.

 One of the uses I filter to add a async attribute script tag in the way
 you suggest, you would have to do a string replace like
 str_replace('<script ','<script async', $script); This is not a clear as
 filter the markup of the tag.

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


More information about the wp-trac mailing list