Repository navigation
Administration: Use script helpers for misc.php inline JS - #16305
shail-mehta wants to merge 1 commit into
Conversation
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.
🟢 Approval recommended
No active review issues block the migration of the three inline scripts in misc.php to WordPress’s script-tag helper.
No open issues 🎉
What changed in this PR
Migrates the three remaining raw inline script blocks in misc.php to WordPress’s wp_print_inline_script_tag() helper, supporting the work tracked in Trac #66856 without changing their JavaScript logic.
Changes:
- Routes
_wpColorSchemeoutput through the helper while preserving JSON encoding. - Converts canonical URL and back-button reload scripts to nowdoc strings.
- Preserves the canonical link markup.
| File | Description |
|---|---|
src/wp-admin/includes/misc.php |
Uses the inline script helper for color-scheme settings, canonical URL cleanup, and back-button reload behavior. |
Review effort: Balanced
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
mukeshpanchal27
left a comment
There was a problem hiding this comment.
LGTM. The replaceState script still prints right after the canonical link, and the color scheme data keeps the JSON flags.
What
Trac ticket: #66856
Migrates the three items in
src/wp-admin/includes/misc.phpoff raw script tags:wp_color_scheme_settings()wp_admin_canonical_url()wp_page_reload_on_back_button_js()Why
#66856 lists these under remaining raw script tags.
wp_print_inline_script_tag()is required when removing that markup.How
wp_color_scheme_settings(): echoedvar _wpColorScheme = …now goes throughwp_print_inline_script_tag(). Stillwp_json_encode(). No nowdoc; the ticket says a nowdoc adds little for this kind of data export.wp_admin_canonical_url(): keep the canonical<link>; print thehistory.replaceStateJS as a<<<'JS'nowdoc. Unchanged except indentation.wp_page_reload_on_back_button_js(): same nowdoc pattern. Unchanged except indentation.Testing Instructions
php -l src/wp-admin/includes/misc.php_wpColorSchemeis still set; menu icons still follow the color scheme.settings-updated=true), the address bar is cleaned and the canonical link is still present.Use of AI Tools