Skip to content

Administration: Add box reordering toggle to Screen Options.#12627

Open
j111q wants to merge 3 commits into
WordPress:trunkfrom
j111q:agent/meta-box-reordering-toggle
Open

Administration: Add box reordering toggle to Screen Options.#12627
j111q wants to merge 3 commits into
WordPress:trunkfrom
j111q:agent/meta-box-reordering-toggle

Conversation

@j111q

@j111q j111q commented Jul 21, 2026

Copy link
Copy Markdown

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

  • Adds a Screen Options setting for enabling or disabling box reordering.
  • Stores the setting as one per-user preference shared across screens on the current site and keeps reordering enabled by default.
  • Disables drag-and-drop sorting and hides the keyboard move controls and drop zones when reordering is disabled.
  • Places the “Allow boxes to be rearranged” checkbox under “Additional settings” on screens that support meta boxes.

Screenshot

Screenshot 2026-07-22 at 1 05 54 PM

Review follow-up

  • Uses the absence of the disabled body class to represent the enabled state.
  • Leaves hidden move controls to CSS instead of changing their accessibility attributes in JavaScript.
  • Preserves the existing Screen Options guidance and adds a separate sentence explaining the new setting.
  • Uses the user option API consistently when saving and reading the per-user, per-site preference.
  • Avoids duplicate sortable updates when the checkbox changes.
  • Preserves the legacy hidden editor-expand fieldset when a post screen has no meta boxes.
  • Replaces the unused rendering helper test with coverage through the real Screen Options rendering path.

Compatibility

  • Reordering remains enabled by default.
  • Existing meta box markup and keyboard controls remain unchanged while reordering is enabled.
  • The preference applies across screens on the current site for each user, matching the direction confirmed on the Trac ticket.

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.php
  • npm run test:php -- --group ajax --filter Tests_Ajax_wpAjaxMetaBoxReordering
  • npx grunt jshint:core --file=src/js/_enqueues/admin/postbox.js
  • npx grunt jshint:core --file=src/js/_enqueues/admin/common.js
  • PHPCS on all eight touched PHP and PHPUnit files.
  • npm run build:dev
  • git diff --check

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

Copilot AI review requested due to automatic review settings July 21, 2026 13:54
@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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-reordering Ajax 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.

Comment thread src/wp-admin/includes/ajax-actions.php
Comment thread src/js/_enqueues/admin/postbox.js
Copilot AI review requested due to automatic review settings July 22, 2026 05:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread src/wp-admin/includes/ajax-actions.php
Comment thread tests/phpunit/tests/admin/includesScreen.php
@j111q
j111q marked this pull request as ready for review July 22, 2026 05:25
@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 poligilad, jillq.

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

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.

3 participants