fix: apply the Snippets List Order setting again - #465
Closed
TallblokeUK wants to merge 2 commits into
Closed
Conversation
"Snippets List Order" in Settings had no effect: whichever of its five
options was chosen, the table opened in the same order.
The setting is still defined and still rendered, but nothing reads it.
Its only two references in the codebase are its default value and its
field definition. Until 3.10 the list table applied it directly, in
`class-list-table.php`:
$order = Settings\get_setting( 'general', 'list_order' );
Sorting moved to the column headings during the admin rewrite, and the
consumer went with the old table while the setting stayed in the UI.
The headings are the right mechanism now, so rather than restore a
parallel ordering system this maps the setting onto the table's opening
sort, which is what it describes itself as: "Default way to order
snippets on the All Snippets admin menu." `list_order` is localized,
mapped to a column and direction, and passed to `ListTable` as
`initialSort`. Clicking a heading overrides it for the rest of the
visit, exactly as it overrides any other starting order.
Removing the setting was the alternative. It would have been a visible
feature removal for anyone who has it configured, and the option is
carried in saved settings either way, so honouring it costs less than
taking it away.
Verified against a reproduction of the reported environment — WordPress
7.0.4, PHP 8.2.33, 3.10.0, 190 snippets. Before, every option produced
an identical list; after, "Name (Z-A)" inverts it. Covered by an e2e
test that fails without the change.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 27, 2026
sheabunge
reviewed
Aug 27, 2026
| selectAllControl?: boolean | ||
|
|
||
| /** Column and direction to sort by before the reader touches a heading. */ | ||
| initialSort?: { columnId: string, direction: ListTableSortDirection } |
Member
There was a problem hiding this comment.
I feel like this is better passed as separate values instead of an object?
| * setting still decides how the list opens; clicking a heading overrides it for | ||
| * the rest of the visit, as it does for any other starting order. | ||
| */ | ||
| const LIST_ORDER_SORTS: Record<string, { columnId: string, direction: ListTableSortDirection }> = { |
Member
There was a problem hiding this comment.
No need to encode a table – just partition on - and pass the first half as the column ID, the second as the direction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Reported from support: Settings → Snippets List Order has no effect. Whichever of its five options you pick, the All Snippets table opens in the same order.
Reproduced on two clean installs — WP 7.0.4 / PHP 8.2.33 and WP 7.1 / PHP 8.3.33.
Name (Z-A)should invert the list; nothing moved on either.Cause
The setting is still defined and still rendered, but nothing reads it. Its only two references in 3.10.0:
Until 3.10 the list table applied it directly:
Sorting moved to the column headings during the admin rewrite. The consumer went with the old table; the setting stayed in the UI, reading nothing.
Approach
The headings are the mechanism now, so this doesn't restore a parallel ordering system. It maps the setting onto the table's opening sort — which is what the setting describes itself as: "Default way to order snippets on the All Snippets admin menu."
list_orderis localized alongside the other manage datapriority/name/date, asc/desc)ListTableas a new optionalinitialSortClicking a heading overrides it for the rest of the visit, exactly as it overrides any other starting order. The
initialSortprop is optional, so no otherListTableconsumer changes behaviour.On removing it instead: that was the alternative, and it's defensible given headings supersede it. I didn't, because it's a visible feature removal for anyone who has it configured, and the value is carried in saved settings either way — honouring it costs less than taking it away. Easy to flip if you'd rather retire the setting.
Verification
Against a reproduction of the reported environment (WP 7.0.4, PHP 8.2.33, 3.10.0, 190 snippets):
list_orderpriority-ascname-descAn e2e test covers it and fails without the change. Full suite: 90 Playwright, 157 PHPUnit, 0 failures;
lint:jsandlint:stylesclean.Manage_Menu_Assets_Testpins the localized key list, so it gainslistOrder.Note
No changelog entry, consistent with #461, #462 and #463.
Fixes #474