Skip to content

Script Loader: Enable wp_script_attributes filter in _print_scripts() - #11702

Closed
Sukhendu2002 wants to merge 8 commits into
WordPress:trunkfrom
Sukhendu2002:fix/64683-print-scripts-filters
Closed

Script Loader: Enable wp_script_attributes filter in _print_scripts()#11702
Sukhendu2002 wants to merge 8 commits into
WordPress:trunkfrom
Sukhendu2002:fix/64683-print-scripts-filters

Conversation

@Sukhendu2002

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/64683


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@Sukhendu2002
Sukhendu2002 marked this pull request as ready for review May 4, 2026 08:17
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sukhendu2002, wildworks, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment thread src/wp-includes/script-loader.php Outdated
@westonruter

Copy link
Copy Markdown
Member

I'll pick this up for 7.1 when trunk is unfrozen.

pento pushed a commit that referenced this pull request Jul 14, 2026
Replace the manually constructed `<script>` markup in `_print_scripts()` with `wp_print_inline_script_tag()` and `wp_print_script_tag()`. The merged inline script holding the concatenated `wp_localize_script()` data, and the `load-scripts.php` tag itself, are now passed through the `wp_inline_script_attributes` and `wp_script_attributes` filters, as every other script tag in core already is. Themes and plugins can therefore add attributes to them, such as the nonce needed to serve the admin under a Content-Security-Policy that disallows `unsafe-inline`.

The emitted markup is otherwise unchanged, aside from the attribute quoting and entity encoding applied by `WP_HTML_Tag_Processor`.

Developed in #11702.
Follow-up to r56687, r60719.

Props sukhendu2002, galaxor, wildworks, westonruter.
See #51407, #57548, #58664, #59446.
Fixes #64683.


git-svn-id: https://develop.svn.wordpress.org/trunk@62723 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jul 14, 2026
Replace the manually constructed `<script>` markup in `_print_scripts()` with `wp_print_inline_script_tag()` and `wp_print_script_tag()`. The merged inline script holding the concatenated `wp_localize_script()` data, and the `load-scripts.php` tag itself, are now passed through the `wp_inline_script_attributes` and `wp_script_attributes` filters, as every other script tag in core already is. Themes and plugins can therefore add attributes to them, such as the nonce needed to serve the admin under a Content-Security-Policy that disallows `unsafe-inline`.

The emitted markup is otherwise unchanged, aside from the attribute quoting and entity encoding applied by `WP_HTML_Tag_Processor`.

Developed in WordPress/wordpress-develop#11702.
Follow-up to r56687, r60719.

Props sukhendu2002, galaxor, wildworks, westonruter.
See #51407, #57548, #58664, #59446.
Fixes #64683.

Built from https://develop.svn.wordpress.org/trunk@62723


git-svn-id: http://core.svn.wordpress.org/trunk@62007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62723
GitHub commit: 93a95e7

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants