Repository navigation
Bulk Edit: Allow removing Uncategorized and reset category states - #16090
AbdiTolesa wants to merge 2 commits into
Conversation
`inlineEditPost.setBulk()` set category checkboxes to checked or indeterminate but never cleared them. Reopening Bulk Edit without a page reload kept categories checked from the previous selection, so saving assigned those categories (typically "Uncategorized") to posts that were not in them. Category states and the hidden `indeterminate_post_category[]` inputs are now reset before the new states are computed. The checkbox selectors are scoped to the Bulk Edit row so they no longer change the Quick Edit form, and the change and click handlers are namespaced so they are not bound again on every open. Props abditolessa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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. |
When the selected posts are only in the default category and it is unchecked in Bulk Edit, `wp_insert_post()` assigned the default category again, so it could not be removed. `bulk_edit_posts()` now removes the categories of a post whose category list ends up empty, provided the user can assign categories. Props abditolessa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Trac ticket: https://core.trac.wordpress.org/ticket/59374
What
Bulk Edit doesn't reliably remove "Uncategorized". There are two separate causes:
wp_insert_post()assigns the default category again, so it can't be removed.Why it happens
inlineEditPost.setBulk()insrc/js/_enqueues/admin/inline-edit-post.jsonly ever sets checkboxes to checked or indeterminate. It never clears them, andrevert()doesn't reset them. Its selector also matched the Quick Edit form, and itschange/clickhandlers were bound again on every open.post_category[]value of0. When no real category is left for a post,wp_insert_post()falls back todefault_categoryfor posts of typepost.Change
JS,
setBulk():checked,indeterminate,aria-label) and remove leftover hiddenindeterminate_post_category[]inputs before computing the new states.#bulk-editso the Quick Edit form is no longer affected.change/clickhandlers (.inlineEditPost) and unbind them before binding again.PHP,
bulk_edit_posts():wp_set_object_terms()after the post is updated, instead of letting the default category be reassigned. This matches the block editor, which allows a post to have no categories.Tests
New PHPUnit tests in
tests/phpunit/tests/admin/includesPost.php:Testing instructions
Stale states:
No categories left:
Existing behaviour still works:
🤖 Generated with Claude Code