[wp-trac] [WordPress Trac] #45008: Inconsistent use of 'script_loader_src' and 'style_loader_src' filters when performing concatenation

WordPress Trac noreply at wordpress.org
Thu Sep 27 09:21:24 UTC 2018


#45008: Inconsistent use of 'script_loader_src' and 'style_loader_src' filters when
performing concatenation
---------------------------+-----------------------------
 Reporter:  dimadin        |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  2.8
 Severity:  normal         |   Keywords:  has-patch
  Focuses:                 |
---------------------------+-----------------------------
 When in admin, scripts and styles from default directories (in other
 words, from `/wp-includes` and `/wp-admin`) will by default be
 concatenated.

 But, there is inconsistency in how `script_loader_src` and
 `style_loader_src` filters are used in that case.

 `style_loader_src` is [https://core.trac.wordpress.org/browser/trunk/src
 /wp-includes/class.wp-styles.php?rev=43564#L162 not used] when doing
 concatenation. It receives only full URL of style and is used only in
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class.wp-
 styles.php?rev=43564#L329 that case].

 `script_loader_src` is used twice.
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class.wp-
 scripts.php?rev=43583#L332 One case] is the same as for
 `style_loader_src`: only for final, full URL of script. But in
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class.wp-
 scripts.php?rev=43583#L279 second case], it is used when doing
 concatenation. It is not only inconsistent with its first usage or usage
 of `style_loader_src`, it also doesn't really makes sense. It filters path
 relative to root, not final URL, and result of that filtering is only used
 when checking if source is in default directories and nowhere else. I
 don't see what it can really do.

 This second case was introduced in [10357] by @azaozz. Before that, filter
 [https://core.trac.wordpress.org/browser/trunk/wp-includes/class.wp-
 scripts.php?rev=10356#L73 was used] the same way it is used now for the
 other case. In that same changeset, concatenation was also added for
 styles, but counterpart filter
 [https://core.trac.wordpress.org/changeset/10357#file7 was not added].

 I propose that we remove second case of `script_loader_src`, used when
 doing script concatenation.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45008>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list