Opened 5 months ago
Last modified 5 months ago
#65070 new enhancement
Move inline JS from admin_head hooks in options screens into options.js
| Reported by: | anukasha | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | javascript, administration |
Description
src/wp-admin/includes/options.php contains three functions that print inline <script> blocks via admin_head hooks:
- options_discussion_add_js() — hooked in options-discussion.php
- options_general_add_js() — hooked in options-general.php
- options_reading_add_js() — hooked in options-reading.php
These should be migrated into src/js/_enqueues/admin/options.js, which was introduced in https://github.com/WordPress/wordpress-develop/pull/10927 as the central enqueued JS file for options screens.
Attachments (1)
Change History (6)
#1
@
5 months ago
- Focuses javascript administration added
- Keywords has-patch added; needs-patch removed
This ticket was mentioned in PR #11572 on WordPress/wordpress-develop by @wpdevsxyz.
5 months ago
#2
This pull request is for code review only.
Trac ticket: https://core.trac.wordpress.org/ticket/65070
Summary:
- Moves inline JS from admin_head hooks for options screens into options.js
- Centralizes the behavior in the enqueued JS file
- Deprecates the old inline JS hook functions
@wpdevsxyz commented on PR #11572:
5 months ago
#3
Fixed backward compatibility issue raised in review — deprecated
functions now call wp_enqueue_script('options') (and
wp_localize_script() for options_general_add_js) so external
callers continue to work while still triggering the deprecation notice.
@mukesh27 commented on PR #11572:
5 months ago
#4
Thanks for the PR!
Make sure to add details which AI agent you use for the PR?
@wpdevsxyz commented on PR #11572:
5 months ago
#5
Thanks for the feedback!
The code changes were made manually. I used Claude as an AI assistant to help understand the codebase and plan the approach, but all the actual code was written and reviewed by me.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This patch moves the three inline <script> blocks from admin_head hooks into
a new enqueued file: src/js/_enqueues/admin/options.js.
Changes: