Administration: Add box reordering toggle to Screen Options.#12180
Administration: Add box reordering toggle to Screen Options.#12180poligilad-auto wants to merge 1 commit into
Conversation
|
Hi there! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to 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 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. |
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. |
058d66e to
58411d2
Compare
58411d2 to
9db7284
Compare
tyxla
left a comment
There was a problem hiding this comment.
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-screengranularity 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
| postboxWithinSortablesIndex = postboxesWithinSortables.index( postbox ), | ||
| firstOrLastPositionMessage; | ||
|
|
||
| if ( false === postboxes.reorderingEnabled ) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| if ( null === $screen ) { | ||
| $screen = get_current_screen(); | ||
| } elseif ( is_string( $screen ) ) { | ||
| $screen = convert_to_screen( $screen ); | ||
| } | ||
|
|
||
| if ( ! $screen instanceof WP_Screen ) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
This function seems to be doing too much. Why does it care about the screen if this is stored in a user option?
There was a problem hiding this comment.
Simplified this. The helper now reads the global per-user meta_box_reordering option and no longer accepts or inspects the screen.
| * @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 ); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| return true; | ||
| } | ||
|
|
||
| $setting = get_user_option( "metaboxreorder_{$screen->id}" ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
Removed this filter as well. The control is now shown when the current screen has meta boxes.
| } | ||
| } | ||
|
|
||
| .js.metabox-reordering-disabled #dashboard-widgets .postbox-container .empty-container { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Why is that needed? Seems unrelated
There was a problem hiding this comment.
Removed from this PR. The dashboard visual refinements are now proposed separately in #12339.
| .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; | ||
| } |
There was a problem hiding this comment.
Removed from this PR. The remaining CSS is limited to the Additional settings section introduced by this patch.
9db7284 to
dc1d55f
Compare
dc1d55f to
6cf7d60
Compare
6cf7d60 to
170cc4a
Compare
|
@tyxla Thanks so much for the review! I’ve updated the PR based on the feedback:
I also opened a separate PR for the dashboard meta box visual refinements here: 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:
|
Trac ticket: https://core.trac.wordpress.org/ticket/50699
Summary
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