#36399 closed enhancement (fixed)
Change function signature of `wp_count_terms()` to be compliant with recent `get_terms()` changes
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Taxonomy | Keywords: | has-patch has-unit-tests has-dev-note |
Focuses: | Cc: |
Description
In #35495 the $taxonomy
parameter of get_terms()
was made optional, thus changing the function signature to the first parameter being the $args
array where the taxonomy (if needed) could then be added to.
This ticket is about changing the signature of wp_count_terms()
in a similar manner. This will bring more consistency and it will also allow to count all terms entirely (if no taxonomy is provided).
Attachments (1)
Change History (12)
#4
@
9 years ago
- Summary changed from Change function signature of `wp_count_terms()` to be comliant with recent `get_terms()` changes to Change function signature of `wp_count_terms()` to be compliant with recent `get_terms()` changes
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
5 years ago
This ticket was mentioned in PR #450 on WordPress/wordpress-develop by felixarntz.
5 years ago
#6
- Keywords has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/36399
#7
@
5 years ago
- Milestone set to 5.6
- Owner set to flixos90
- Status changed from new to assigned
I've opened a pull-request with an updated version of this change. It also includes:
- tests to cover both new and legacy usage of
wp_count_terms()
- all references in core code have been updated to use new signature
As originally planned, because this function is widely used and there is no actual drawback to use the old signature, legacy usage shouldn't trigger a deprecated notice (similar like with get_terms()
). Yet, proceeding with this change makes sense for consistency and to make it obvious that wp_count_terms()
can also count all terms, not only terms of certain taxonomies.
#10
@
4 years ago
- Keywords needs-dev-note added
Let's call this out in the miscellaneous dev note, noting the new, preferred signature.
36399.diff is a patch for this. Specifically we need to determine if the check for
$do_legacy_args
is safe enough here. As an alternative, we could create a new internal function like_get_terms_defaults()
which would allow us to do the same kind of verification as inget_terms()
.