wp_get_script_tag() and wp_get_inline_script_tag()#591
wp_get_script_tag() and wp_get_inline_script_tag()#591enricocarraro wants to merge 4 commits intoWordPress:masterfrom
Conversation
edc4bb2 to
adabbf6
Compare
|
@enricocarraro Thank you for working on this! I left a few comments and questions. It would be good explain what the filters do in their inline docs, and also to add a test that covers the Since this is a bit complex to use it will definitely need a "Dev Note" that explains how the API can be used, including stuff like this: https://github.com/WordPress/wordpress-develop/pull/498/files#r499066268. Would you say merging this PR fixes https://core.trac.wordpress.org/ticket/39941? |
|
@adamsilverstein thank you for taking the time to look at this.
I will shortly add tests to cover
Will look into it.
I wouldn't say so; "allowing a Content-Security-Policy without unsafe-inline" would require all script tags to have a nonce, and not having inline event handlers and javascript: URIs. |
00059ca to
89cb5b0
Compare
felixarntz
left a comment
There was a problem hiding this comment.
Looks solid overall, I've added some feedback.
89cb5b0 to
7c71cda
Compare
|
Thanks, @felixarntz. |
4ec95bd to
bf697d7
Compare
6795413 to
65ed818
Compare
|
Thanks for suggesting the changes @ocean90. |
65ed818 to
cbb262d
Compare
cbb262d to
6762f5b
Compare
|
Closed with changeset https://core.trac.wordpress.org/changeset/50167 |
I introduced two new functions that print
<script>tags and enable attribute injection:wp_print_script_tagandwp_get_script_tag: for script tags that load JavaScript files through the src attribute;wp_print_inline_script_tagandwp_get_inline_script_tag: for inline scripts.All these functions filter the attributes passed to them through
wp_script_attributesso that plugins can change script attributes in a controlled manner.Instead of directly printing
<script>tags, these functions should be used to ensure that every<script>tag is controllable.Trac ticket: https://core.trac.wordpress.org/ticket/39941