#24656 closed enhancement (fixed)
Tag Cloud generation return object for manipulation
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Taxonomy | Keywords: | needs-patch good-first-bug dev-feedback |
Focuses: | Cc: |
Description
"wp_generate_tag_cloud" and "wp_tag_cloud" functions in "/wp-includes/category-template.php" only return html or an array of html links as a result.
To manipulate the result you must use filters which on certain cases are not the most efficient way to do it.
I´ve attached a patch to include a new format in the args array as "object". This will create an object with enough data on it so that it can be manipulated accordingly.
ps. first time submiter.
Attachments (3)
Change History (12)
#3
follow-ups:
↓ 4
↓ 5
@
10 years ago
- Keywords needs-patch needs-unit-tests good-first-bug added; needs-refresh removed
- Milestone changed from Awaiting Review to Future Release
#4
in reply to:
↑ 3
@
10 years ago
- Keywords dev-feedback added; needs-unit-tests removed
Replying to boonebgorges:
I'd like basic test coverage for
wp_generate_tag_cloud()
before making these changes.
I've added some initial tests and would love any feedback or comments!
#5
in reply to:
↑ 3
@
10 years ago
@boonebgorges:
In this patch I implemented your suggestions regarding using arrays for the tag data as well as splitting the foreach loop.
If we're going to pass structured data around, let's do it in arrays rather than objects. This is more in keeping with practice throughout WP.
I'm not sure I see the value in *returning* structured data from the function. The purpose of the function is to generate markup; changing it to return structured data in an arbitrary format suggests the need for another function. That being said, I don't think another function is really necessary. How about this: Break the
foreach ( $tags as $key => $tag )
loop into two loops.
ysalame - Thanks for the patch, and sorry for the lack of feedback. Having better control over the customizability of tag cloud markup is a good idea.
If we're going to pass structured data around, let's do it in arrays rather than objects. This is more in keeping with practice throughout WP.
I'm not sure I see the value in *returning* structured data from the function. The purpose of the function is to generate markup; changing it to return structured data in an arbitrary format suggests the need for another function. That being said, I don't think another function is really necessary. How about this: Break the
foreach ( $tags as $key => $tag )
loop into two loops. The first one would assemble an array of structured data:Then pass it through a filter before creating the anchor tags:
This way, we don't have to maintain a new function return value, but you get full customizability.
I'd like basic test coverage for
wp_generate_tag_cloud()
before making these changes.