Administration: Add box reordering toggle to Screen Options.#12627
Administration: Add box reordering toggle to Screen Options.#12627j111q wants to merge 3 commits 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.
Pull request overview
This PR introduces a new Screen Options setting that lets users enable/disable meta box (postbox) reordering across wp-admin screens that support meta boxes. It wires the preference through wp-admin rendering, JS behaviors (drag-and-drop and keyboard move controls), and an authenticated Ajax endpoint, with PHPUnit coverage for both the Ajax persistence and Screen Options rendering.
Changes:
- Add a “Enable box reordering” checkbox under “Additional settings” in Screen Options when a screen has meta boxes, and display supporting guidance text.
- Persist the preference as a per-user setting via a new
meta-box-reorderingAjax action and apply it via an admin body class. - Update admin JS/CSS to disable sortable behavior and hide keyboard move controls/drop zones when reordering is disabled, plus add tests for the new behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/phpunit/tests/ajax/wpAjaxMetaBoxReordering.php | Adds Ajax test coverage to verify the user option is saved correctly. |
| tests/phpunit/tests/admin/includesScreen.php | Adds tests for default enabled behavior and Screen Options rendering logic. |
| tests/phpunit/includes/testcase-ajax.php | Whitelists the new Ajax action for the Ajax test harness. |
| src/wp-admin/includes/screen.php | Introduces wp_is_meta_box_reordering_enabled() helper for reading the preference. |
| src/wp-admin/includes/class-wp-screen.php | Renders the new Screen Options toggle and related guidance; adjusts “Additional settings” markup handling. |
| src/wp-admin/includes/ajax-actions.php | Adds wp_ajax_meta_box_reordering() endpoint to store the preference. |
| src/wp-admin/css/dashboard.css | Hides dashboard empty drop containers when reordering is disabled. |
| src/wp-admin/css/common.css | Adds styling for additional settings fieldset and hides move controls when reordering is disabled. |
| src/wp-admin/admin-header.php | Applies meta-box-reordering-disabled body class based on the preference. |
| src/wp-admin/admin-ajax.php | Registers meta-box-reordering as a core POST Ajax action. |
| src/js/_enqueues/admin/postbox.js | Adds UI logic to enable/disable reordering, persist state, and gate keyboard move behavior. |
| src/js/_enqueues/admin/common.js | Prevents responsive sortable toggling from being triggered by the new checkbox; disables sortables when reordering is disabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
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. |
Trac ticket: https://core.trac.wordpress.org/ticket/50699
This continues #12180, originally authored by @poligilad-auto. Poli’s original feature commit is preserved in this branch; I’m carrying the existing work and review feedback forward while Poli is away.
Summary
Screenshot
Review follow-up
Compatibility
AI assistance
Codex was used to inspect the existing feedback, implement revisions, add tests, and draft this description. I manually verified the user-facing behavior, and the automated checks listed below were run. I do not independently have the technical expertise to validate every code change, so this draft is seeking human developer review before it is considered ready.
Testing
npm run test:php -- --filter Tests_Admin_IncludesScreen tests/phpunit/tests/admin/includesScreen.phpnpm run test:php -- --group ajax --filter Tests_Ajax_wpAjaxMetaBoxReorderingnpx grunt jshint:core --file=src/js/_enqueues/admin/postbox.jsnpx grunt jshint:core --file=src/js/_enqueues/admin/common.jsnpm run build:devgit diff --checkManually verified on the Dashboard that disabling the setting disables drag-and-drop, hides both keyboard move controls, and that re-enabling it restores both interaction methods.