#59886 closed defect (bug) (wontfix)
enqueue scripts is html encoding the resulting string
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.4 |
Component: | General | Keywords: | needs-patch |
Focuses: | Cc: |
Description
<?php add_filter('clean_url', function ($url) { if (strpos($url, 'spektrix-component-loader') === false) { // not our file return $url; } return "$url' async data-components='spektrix-login-status,spektrix-donate,spektrix-merchandise,spektrix-memberships,spektrix-basket-summary,spektrix-gift-vouchers"; }, 11, 1); wp_enqueue_script('webcomponents-spektrix', 'https://webcomponents.spektrix.com/stable/spektrix-component-loader.js');
causes things to be encoded in the url
this worked in prev versions
wp 6.4.1
Change History (5)
#2
@
18 months ago
ah, yes, that iw what I am attempting to do
it was a kind-of hacky fix to begin with, but at the time the only one i could find
I will update my code accordingly
Thank-you
#3
@
18 months ago
Glad that was it @probed. Note that while it worked before, it shouldn't have 😅 because escaping out of the URL isn't something we want to do. The code I shared should work on WordPress 6.2 or newer. If you want to support older versions you'll need to modify the HTML at your own risk.
https://developer.wordpress.org/reference/classes/wp_html_tag_processor/
Note: See
TracTickets for help on using
tickets.
@probed what are you trying to accomplish here? it looks like you're attempting to add additional HTML attributes to the
SCRIPT
element by breaking out of the URL. is that the case?if that's the case, I might recommend using the script_loader_tag filter instead.