Repository navigation
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. |
joedolson
left a comment
There was a problem hiding this comment.
A handful of minor questions/suggestions.
|
I've pushed fixes to address my review questions. |
afercia
left a comment
There was a problem hiding this comment.
I left some comments.
I'll also comment on the ticket about the scope of this change.
| /** | ||
| * Checks whether meta box reordering is enabled. | ||
| * | ||
| * @since 7.1.0 |
There was a problem hiding this comment.
This should be updated to 7.2.0
| /** | ||
| * Enables or disables the meta box reordering UI. | ||
| * | ||
| * @since 7.1.0 |
There was a problem hiding this comment.
This should be updated to 7.2.0
| setMetaBoxReordering: function( enabled ) { | ||
| var $sortables = $( '.meta-box-sortables' ); | ||
|
|
||
| this.metaBoxReorderingEnabled = !! enabled; |
There was a problem hiding this comment.
Why coercing to boolean with !!? it is already a booleanand the callers always pass a boolean
| /** | ||
| * Saves the meta box reordering setting to the server. | ||
| * | ||
| * @since 7.1.0 |
| * | ||
| * @since 7.1.0 | ||
| * | ||
| * @memberof postboxes |
| /** | ||
| * Gets the option to enable or disable meta box reordering. | ||
| * | ||
| * @since 7.1.0 |
| * @return string Meta box reordering option markup. | ||
| */ | ||
| private function get_meta_box_reordering_option() { | ||
| return '<label for="meta-box-reordering">' |
There was a problem hiding this comment.
Same as above: this should be refactored to not wrap the input.
There was a problem hiding this comment.
Refactored in 947e54a, same as above.
| /** | ||
| * Determines whether to show the meta box reordering option. | ||
| * | ||
| * @since 7.1.0 |
| } | ||
|
|
||
| /** | ||
| * Determines whether to show the meta box reordering option. |
There was a problem hiding this comment.
I find the description and name of this method a little confusing. This is not what the code does. it checks whether there are meta boxes for this screen. It does not 'Show' or 'Determine whether to show'.
There was a problem hiding this comment.
Agreed. Renamed to has_meta_boxes() with the description "Checks whether the screen has meta boxes." in 947e54a.
| /** | ||
| * Determines whether meta box reordering is enabled. | ||
| * | ||
| * @since 7.1.0 |
|
Posting a video recording here, s it exceeds the upload max size for Trac. Comment on the Trac ticket. Screen.Recording.2026-10-07.at.10.35.06.mov |
| <?php _e( 'Some screen elements can be shown or hidden by using the checkboxes.' ); ?> | ||
| <?php _e( 'Expand or collapse the elements by clicking on their headings, and arrange them by dragging their headings or by clicking on the up and down arrows.' ); ?> | ||
| <?php if ( $this->show_meta_box_reordering_options() ) : ?> | ||
| <?php _e( 'Use the setting below to control whether boxes can be rearranged.' ); ?> |
There was a problem hiding this comment.
Terminology: the term 'boxes' is obscure for users. I think we should use 'screen elements' as in the introduction paragraph. When rephrased, the tests should be updated.
There was a problem hiding this comment.
Agreed, updated to "Use the setting below to control whether screen elements can be rearranged." in 947e54a. Tests updated too.
There was a problem hiding this comment.
"screen elements" feels like a meaningless set of terms to me, but I do agree that it's at least consistent.
| private function get_meta_box_reordering_option() { | ||
| return '<label for="meta-box-reordering">' | ||
| . '<input class="meta-box-reordering-toggle" name="meta-box-reordering" type="checkbox" id="meta-box-reordering" value="enabled" ' . checked( wp_is_meta_box_reordering_enabled(), true, false ) . ' /> ' | ||
| . __( 'Allow boxes to be rearranged' ) |
There was a problem hiding this comment.
Terminology: the term 'boxes' is obscure for users. I think we should use 'screen elements' as in the introduction paragraph. When rephrased, the tests should be updated.
There was a problem hiding this comment.
Agreed, the label is now "Allow screen elements to be rearranged" in 947e54a. Tests updated too.
|
Note that some styles added in this commit fb107a4 Also, the PR needs to be rebased first as there is a merge conflict related to those styles. |
- Update `@since` tags to 7.2.0. - Always build a single "Additional settings" fieldset, and drop the redundant Screen Options visibility check. - Use separate `label` and `input` elements instead of wrapping labels. - Use "screen elements" instead of "boxes" in user-facing text. - Announce whether rearranging was enabled or disabled. - Rename `show_meta_box_reordering_options()` to `has_meta_boxes()`. - Restore the "Additional settings" top margin dropped in a merge, and remove the unneeded paragraph and legend styles. - Add tests for the shared fieldset and for screens without meta boxes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@joedolson @afercia, I've addressed your feedback in 947e54a. Could you take another look? |
|
Thanks for the updates, @poligilad-auto! With these changes, I think this is workable. |
In most cases, changing the order and position of dashboard or post meta boxes is an occasional need. When it's not needed, the extra two controls for every meta box create a high number of extra tab stops and a busy design. The drag and drop can result in accidental moves and difficulty scrolling on mobile devices due to accidental touch effects. Add a screen option that allows users to disable moving meta boxes, disabling mover buttons and drag and drop behavior. The setting is defaulted to enable moving meta boxes, so there is no change in the default experience for users. Developed in #12627. Props azaozz, pbiron, afercia, johnbillion, hellofromtonya, helen, knutsp, johnjamesjacoby, garrett-eclipse, margaretschneider, johnstonphilip, hedgefield, sanketparmar, poligilad, sabernhardt, tyxla, jillq, sarahricker, ryokuhi, poena, abrain, SergeyBiryukov, joedolson. Fixes #50699, #51419. git-svn-id: https://develop.svn.wordpress.org/trunk@64301 602fd350-edb4-49c9-b593-d223f7449a82
In most cases, changing the order and position of dashboard or post meta boxes is an occasional need. When it's not needed, the extra two controls for every meta box create a high number of extra tab stops and a busy design. The drag and drop can result in accidental moves and difficulty scrolling on mobile devices due to accidental touch effects. Add a screen option that allows users to disable moving meta boxes, disabling mover buttons and drag and drop behavior. The setting is defaulted to enable moving meta boxes, so there is no change in the default experience for users. Developed in WordPress/wordpress-develop#12627. Props azaozz, pbiron, afercia, johnbillion, hellofromtonya, helen, knutsp, johnjamesjacoby, garrett-eclipse, margaretschneider, johnstonphilip, hedgefield, sanketparmar, poligilad, sabernhardt, tyxla, jillq, sarahricker, ryokuhi, poena, abrain, SergeyBiryukov, joedolson. Fixes #50699, #51419. Built from https://develop.svn.wordpress.org/trunk@64301 git-svn-id: http://core.svn.wordpress.org/trunk@63451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.