Skip to content

Upgrade/Install: Use wp_print_inline_script_tag() in Bulk_Upgrader_Skin. - #13492

Open
haritpanchal wants to merge 1 commit into
WordPress:trunkfrom
haritpanchal:fix/59446-bulk-upgrader-skin-inline-scripts
Open

Upgrade/Install: Use wp_print_inline_script_tag() in Bulk_Upgrader_Skin.#13492
haritpanchal wants to merge 1 commit into
WordPress:trunkfrom
haritpanchal:fix/59446-bulk-upgrader-skin-inline-scripts

Conversation

@haritpanchal

Copy link
Copy Markdown

Continues the migration away from manually constructed SCRIPT markup begun in [63481] and [63545]. The four raw one-liner script tags in Bulk_Upgrader_Skin::error(), ::before(), and ::after() now print through wp_print_inline_script_tag(), so wp_inline_script_attributes can attach a per-request nonce to these as well — one more step toward an admin Content-Security-Policy opt-in.

The dynamic jQuery selector is now passed through wp_json_encode() with JSON_HEX_TAG | JSON_UNESCAPED_SLASHES instead of being built via esc_js() string concatenation, consistent with the fix applied to similar call sites in [63481]: esc_js() runs the value through _wp_specialchars(), which isn't needed here since the value lands inside a JS string literal, not an HTML attribute.

Behavior is unchanged — output was compared before/after with a manual smoke test of all three methods.

Testing instructions

  1. Go to Plugins → Add New, install/update a plugin, or use Dashboard → Updates to bulk-update plugins/themes.
  2. Confirm the spinner and progress states still toggle correctly during and after the bulk update.
  3. npm run test:php -- --group upgrade passes (183 tests).
  4. vendor/bin/phpcs --standard=phpcs.xml.dist src/wp-admin/includes/class-bulk-upgrader-skin.php is clean.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Identifying the unconverted call sites, drafting the wp_print_inline_script_tag() replacement, and running the coding-standards/PHPUnit/manual smoke checks. I reviewed the diff and test output before opening this PR.

Continuing the migration away from manually constructed SCRIPT markup,
the four raw one-liner script tags in Bulk_Upgrader_Skin::error(),
::before(), and ::after() now print through wp_print_inline_script_tag(),
so wp_inline_script_attributes can attach a per-request nonce to these
as in the other admin screens already migrated.

The dynamic jQuery selector is now passed through wp_json_encode() with
JSON_HEX_TAG | JSON_UNESCAPED_SLASHES instead of esc_js() string
concatenation, consistent with the fix applied to similar call sites in
[63481]: esc_js() runs the value through _wp_specialchars(), which is
unnecessary here since the value is placed inside a JS string literal
rather than HTML attribute context.

See #59446.
@github-actions

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 haritpanchal.

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

@github-actions

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.

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.

1 participant