[wp-trac] [WordPress Trac] #45076: Category counter is not updated
WordPress Trac
noreply at wordpress.org
Sun Dec 9 21:13:46 UTC 2018
#45076: Category counter is not updated
-------------------------------------------------+-------------------------
Reporter: mukesh27 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Taxonomy | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-testing has- | Focuses:
screenshots dev-feedback | administration
-------------------------------------------------+-------------------------
Comment (by strangerstudios):
I've confirmed that the item count (for total cats, not posts per cat)
does NOT update when adding a new category. It also doesn't update when
deleting a category.
Tested in WordPress 5.0
This is because the form submission is handled by AJAX. The AJAX response
does not include the count or JS code to update it.
Here is the AJAX handler in PHP:
https://github.com/WordPress/WordPress/blob/5.0-branch/wp-admin/includes
/ajax-actions.php#L877-L930
Here is the JS that kicks off and processes that response:
https://github.com/WordPress/WordPress/blob/5.0-branch/wp-
admin/js/tags.js#L89-L146
We could update the wp_ajax_add_tag() function in ajax-actions.php to
query for the count of categories and return that in the AJAX response.
Then update tags.js to process that to update the counts on the screen.
Alternatively, we could just update the JS to increment or decrement the
items number when a category is added or removed. I think this would be
good enough even if it would be incorrect when multiple admins are
updating categories from different screens.
This is also fairly minor and may not be worth fixing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45076#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list