Skip to content

enhancement(term-cleanup): add sort by name - #1307

Open
faisalahammad wants to merge 1 commit into
10up:developfrom
faisalahammad:enhancement/913-sort-terms
Open

faisalahammad wants to merge 1 commit into
10up:developfrom
faisalahammad:enhancement/913-sort-terms

Conversation

@faisalahammad

Copy link
Copy Markdown

Description of the Change

Tools > Term Cleanup always lists terms by usage. With a long list it is hard to find or compare terms by name.

This adds a dropdown above the table with two options: "Sort by most used" (default, same as before) and "Sort by name (A-Z)".

Before:

'orderby' => 'count',
'order'   => 'DESC',

After:

'orderby' => $by_name ? 'name' : 'count',
'order'   => $by_name ? 'ASC' : 'DESC',
  • Merge, Skip and search keep the chosen sort.
  • Only name is accepted from the request, anything else falls back to most used.
  • The dropdown wrapper does not use the core actions class, because core hides it on small screens.
  • I used a dropdown and not sortable column headers, because the usage count is shown inside the term column, so one header cannot offer both orders.
  • Known limit: changing the sort on page 2 or later keeps the same page number.
Before After
Before After

Closes #913

How to test the Change

  1. Enable Term Cleanup, set up an embeddings provider and select Tags.
  2. Create a few similar tags and use them on a different number of posts, then go to Tools > Term Cleanup and click "Find similar tags".
  3. The list shows the most used tags first.
  4. Pick "Sort by name (A-Z)" and click "Sort". The "Tag" column is in A to Z order.
  5. Click "Skip" or "Merge and keep this" on a row. The list stays sorted by name.
  6. Search for a tag. The results stay sorted by name.
  7. Pick "Sort by most used" and click "Sort". The first order is back.

Tested locally on WP 7.1.5 and PHP 8.3: full PHPUnit suite (239 tests, no failures, WooCommerce not active), PHPStan, and PHPCS on the changed files. Also checked by hand with a built zip.

Changelog Entry

Added - Option to sort the Term Cleanup list by name.

Credits

Props @faisalahammad

Checklist:

- Add a sort dropdown to the similar terms table.
- Keep most used as the default order.
- Keep the chosen sort after Merge and Skip.
- Add integration tests for the new sort.

Long lists are hard to check when they are only ordered by usage.

Fixes 10up#913
@faisalahammad
faisalahammad requested review from a team, dkotter and jeffpaul as code owners December 3, 2026 09:38

This branch has not been deployed

No deployments
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.

Term Cleanup: UX - An option to sort the terms alphabeticall

1 participant