-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix: Update Raw <script>
tags with wp_inline_script_tag()
for bundled themes.
#9416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
…ction definition for backward compatibility
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the requested changes?
* @since 5.7.0 | ||
* | ||
* @param string $data Data for script tag: JavaScript, importmap, speculationrules, etc. | ||
* @param array $attributes Optional. Key-value pairs representing `<script>` tag attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add a breathing space between 2 doc annotations. @param and @return
.
* @since 5.7.0 | ||
* | ||
* @param string $data Data for script tag: JavaScript, importmap, speculationrules, etc. | ||
* @param array $attributes Optional. Key-value pairs representing `<script>` tag attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes here.
Trac Ticket: Core-63806
This pull request updates all inline script outputs in the bundled themes to use WordPress’s script helper functions, specifically
wp_print_inline_script_tag()
, in place of manually constructed<script>
tags.✅ Why This Matters
As of #59446, WordPress Core has adopted the use of
wp_get_script_tag()
,wp_get_inline_script_tag()
, andwp_print_inline_script_tag()
to eliminate manually constructed<script>
tags. This change was made to:However, many default and third-party themes still use raw
<script>
tags, which prevents them from fully benefiting from these improvements.🛠 What’s Changed
'<script>...</script>'
with calls towp_print_inline_script_tag()
.🔙 Backward Compatibility
Since these helper functions were introduced in WordPress 5.7+, this PR also includes polyfill definitions in functions.php to ensure compatibility with earlier WordPress versions.
The polyfills conditionally define
wp_print_inline_script_tag()
andwp_get_inline_script_tag()
functions only if they don’t already exist, making it safe for all supported versions.