-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Partial term counts: don't affect other objects when preventing double counting. #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial term counts: don't affect other objects when preventing double counting. #664
Conversation
peterwilsoncc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notes to self...
Could be a problem if a taxonomy is registered for two primitive object types, eg register_taxonomy( 'pwcc', [ 'post', 'user' ], $args ), but it's a little out of warranty as there is no way of knowing if the relationship refers to post 1, or user 1.
| * | ||
| * @param bool $new_setting The new setting for preventing term counts. | ||
| * @param int $object_id The ID of the object. | ||
| * @param string $object_type Optional. Type of object: post, comment, term, user or site. Default post. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param string $object_type Optional. Type of object: post, comment, term, user or site. Default post. | |
| * @param string $object_type Optional. Type of object primitive: post, comment, term, user or site. Default post. |
| if ( array_filter( $object_types, 'post_type_exists' ) !== $object_types ) { | ||
| // This taxonomy applies to non-posts, count changes now. | ||
| $do_recount = ! _wp_prevent_term_counting(); | ||
| $do_recount = ! _wp_prevent_term_counting( $object_id, reset( $object_types ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good here to make sure it's using the correct primitive.
Indeed, we can't do that for the exact reason that you exposed. In Polylang I had this need (define a taxonomy 'language' for posts and terms). Due to the fact that we cannot tell if the relationship refers to posts or terms or anything else, I needed to register 2 taxonomies, one for posts, one for terms. |
Trac ticket: https://core.trac.wordpress.org/ticket/51630
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.