Opened 9 years ago
Closed 9 years ago
#40481 closed defect (bug) (fixed)
Inline docs for wp_get_post_tags() and wp_get_post_terms() don't reflect possible return values
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.8 | Priority: | normal |
| Severity: | normal | Version: | 4.7.3 |
| Component: | Taxonomy | Keywords: | has-patch |
| Focuses: | docs | Cc: |
Description
It looks like the inline documentation for both wp_get_post_tags() and wp_get_post_terms() are missing possible return values, and some information on the nature of the possible return values.
wp_get_post_tags() has the following as the inline doc comment for the return value:
array List of post tags.
However, it might not return an array and while "list of post tags" is correct, that isn't entirely useful. The function will return an array of WP_Term objects, which is important information for a developer wanting to use the function.
And while wp_get_post_tags() sets the $taxonomy parameter when calling wp_get_post_terms() it's possible to remove that taxonomy, making it possible for wp_get_post_tags() to return a WP_Error object.
Similarly, wp_get_post_terms() uses "List of post terms or empty array" in it's inline docs on the return value. More useful is to know that it returns an array of WP_Term objects.
Attachments (1)
Change History (5)
#3
@
9 years ago
While you're in there, I suggest updating the $args description for wp_get_post_categories(), wp_get_post_tags(), and wp_get_post_terms() to be both accurate and identical since they all refer to the same thing. Perhaps something like
@param array|string $args Optional. Array of term query parameters. Default empty. See WP_Term_Query::__construct() for supported arguments.
Improves inline documentation by accounting for possible return values and expanding information on nature of array returned.