Skip to content

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

Open
poligilad-auto wants to merge 1 commit into
WordPress:trunkfrom
poligilad-auto:poligilad-auto/metabox-reordering-toggle
Open

Administration: Add box reordering toggle to Screen Options.#12180
poligilad-auto wants to merge 1 commit into
WordPress:trunkfrom
poligilad-auto:poligilad-auto/metabox-reordering-toggle

Conversation

@poligilad-auto

@poligilad-auto poligilad-auto commented Jun 15, 2026

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/50699

Summary

  • Adds a Screen Options setting for enabling or disabling box reordering.
  • Stores the setting as one global per-user preference, while keeping box reordering enabled by default for discoverability and backwards compatibility.
  • Disables drag-and-drop sorting and hides move controls/drop zones when reordering is disabled.
  • Updates the Screen Options copy so “Screen elements” focuses on showing, hiding, expanding, and collapsing boxes.
  • Places the new “Enable box reordering” checkbox under “Additional settings” so the UI stays compact across Dashboard, Classic Editor, and plugin screens using meta boxes.
Re-ordering 2 - before Re-ordering 3 - after

Context

This follows the later direction discussed in #50699: adding a Screen Options control that can enable/disable meta box moving globally, while keeping reordering enabled by default.

A related ticket, #65463, was closed so the discussion can continue on #50699.

The dashboard meta box visual refinements have been split into a separate PR: #12339

Testing

  • npm run test:php -- --filter Tests_Admin_IncludesScreen
  • npm run test:php -- --group ajax --filter Tests_Ajax_wpAjaxMetaBoxReordering
  • node --check src/js/_enqueues/admin/postbox.js && node --check src/js/_enqueues/admin/common.js
  • git diff --check

@github-actions

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions

github-actions Bot commented Jun 15, 2026

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, tyxla.

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

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

@poligilad-auto poligilad-auto force-pushed the poligilad-auto/metabox-reordering-toggle branch from 058d66e to 58411d2 Compare June 15, 2026 18:48
@poligilad-auto poligilad-auto force-pushed the poligilad-auto/metabox-reordering-toggle branch from 58411d2 to 9db7284 Compare June 24, 2026 06:55

@tyxla tyxla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the work here @poligilad-auto!

I believe this can be simplified a bit in a few places:

  • The filters seem unnecessary for a first pass
  • The per-user + per-screen granularity of the new toggle seems like too much and more likely to add more work to users to toggle it everywhere; I'd rather be fine with one global one per user to start with.
  • There are some unrelated CSS changes that can be proposed and landed separately.

Also I have a few concistency concerns:

  • We mix positive with negative logic and it makes things difficult to read and reason about
  • We use different naming schemes of the same concept, would make sense to use a single one to make it clearer that the different pieces are from the same feature

Comment thread src/js/_enqueues/admin/postbox.js Outdated
postboxWithinSortablesIndex = postboxesWithinSortables.index( postbox ),
firstOrLastPositionMessage;

if ( false === postboxes.reorderingEnabled ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see in some places the logic is positive (reordering enabled) in some it's negative (reordering disabled). Would make sense to be consistent there.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Standardized this around a positive metaBoxReorderingEnabled state in JS and meta_box_reordering for the stored option. The disabled body class remains as the UI/CSS hook.

Comment thread src/wp-admin/includes/screen.php Outdated
Comment on lines +207 to +215
if ( null === $screen ) {
$screen = get_current_screen();
} elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}

if ( ! $screen instanceof WP_Screen ) {
return true;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function seems to be doing too much. Why does it care about the screen if this is stored in a user option?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Simplified this. The helper now reads the global per-user meta_box_reordering option and no longer accepts or inspects the screen.

Comment thread src/wp-admin/includes/screen.php Outdated
* @param bool $enabled Whether meta box reordering is enabled.
* @param WP_Screen $screen WP_Screen object of the current screen.
*/
return (bool) apply_filters( 'meta_box_reordering_enabled', $enabled, $screen );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe the filter is unnecessary for a first pass. If someone really needs to filter this, they could use the get_user_option_metaboxreorder_{$screen->id} filter

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed this filter. With the setting now stored as meta_box_reordering, the existing get_user_option_meta_box_reordering path can cover filtering if that is needed later.

Comment thread src/wp-admin/includes/screen.php Outdated
return true;
}

$setting = get_user_option( "metaboxreorder_{$screen->id}" );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing about our "per-user and per-screen" approach here: it could be tedious and might not serve all use cases. A user who wants reordering off must toggle it separately on the dashboard, every post-type edit screen, nav-menus, etc. There's no site-wide or "everywhere" option.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed this to one global per-user option. Disabling reordering now applies consistently across screens that use meta boxes.

* @param bool $show_reorder_option Whether to show the option.
* @param WP_Screen $screen WP_Screen object.
*/
return (bool) apply_filters( 'screen_options_show_meta_box_reorder', $show_reorder_option, $this );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need this filter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed this filter as well. The control is now shown when the current screen has meta boxes.

Comment thread src/wp-admin/css/dashboard.css Outdated
}
}

.js.metabox-reordering-disabled #dashboard-widgets .postbox-container .empty-container {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR introduces every spelling of the concept at once: meta key metaboxreorder_, body classes metabox-reordering-*, action/input meta-box-reorder, class meta-box-reorder-tog, function wp_is_meta_box_reordering_enabled, JS prop reorderingEnabled. It's hard to grep and read. We might want to standardize.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Standardized naming across PHP, JS, CSS, AJAX, and tests around meta_box_reordering / meta-box-reordering.

}

#dashboard-widgets .postbox-container .empty-container {
outline: 2px dashed rgb(0, 0, 0, 0.15);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is that needed? Seems unrelated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed from this PR. The dashboard visual refinements are now proposed separately in #12339.

Comment thread src/wp-admin/css/common.css Outdated
Comment on lines +3363 to +3368
.postbox .handle-order-lower:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
border-radius: 4px;
/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems unrelated as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed from this PR. The remaining CSS is limited to the Additional settings section introduced by this patch.

@poligilad-auto poligilad-auto force-pushed the poligilad-auto/metabox-reordering-toggle branch from 9db7284 to dc1d55f Compare June 27, 2026 14:54
@poligilad-auto poligilad-auto force-pushed the poligilad-auto/metabox-reordering-toggle branch from dc1d55f to 6cf7d60 Compare June 27, 2026 15:03
@poligilad-auto poligilad-auto force-pushed the poligilad-auto/metabox-reordering-toggle branch from 6cf7d60 to 170cc4a Compare June 27, 2026 19:20
@poligilad-auto

Copy link
Copy Markdown
Author

@tyxla Thanks so much for the review!

I’ve updated the PR based on the feedback:

  • Removed the custom filters from the first pass.
  • Changed the setting from per-user/per-screen to one global per-user preference: meta_box_reordering.
  • Simplified the helper so it no longer receives or checks the current screen.
  • Standardized naming across PHP, JS, CSS, AJAX, and tests around meta_box_reordering / meta-box-reordering.
  • Cleaned up the positive/negative state handling so the JS uses a positive enabled state, with the disabled body class only used for the UI/CSS state.
  • Removed the unrelated dashboard/control visual changes from this PR.

I also opened a separate PR for the dashboard meta box visual refinements here:
#12339

One additional copy/layout change: the new checkbox now appears under “Additional settings” as “Enable box reordering,” instead of adding a separate “Reordering” section. This keeps the Screen Options UI more compact and also works better on screens like the Classic Editor and WooCommerce product editor, where other additional settings may already appear.

Latest local checks:

  • php -l src/wp-admin/includes/class-wp-screen.php
  • php -l tests/phpunit/tests/admin/includesScreen.php
  • php vendor/bin/phpcs --standard=phpcs.xml.dist src/wp-admin/includes/class-wp-screen.php tests/phpunit/tests/admin/includesScreen.php
  • php vendor/bin/phpunit --filter Tests_Admin_IncludesScreen tests/phpunit/tests/admin/includesScreen.php
  • git diff --check

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.

2 participants