#14740 closed defect (bug) (fixed)
'taxonomy_template' Filter Name Clash
Reported by: | CharlesClarkson | Owned by: | |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
Both get_the_taxonomies() and get_taxonomy_template() use a filter named 'taxonomy_template' for two different reasons.
In get_the_taxonomies() the filter holds a format for use with printf(), sprintf() and vprintf().
In get_taxonomy_template() the filter holds a template file name for use with include().
One of these template should probably be renamed. get_the_taxonomies() is the newer function (since 3.0.0).
Tested on WordPress 3.0.1.
I was able to avoid the clash by delaying the start of my filter function, but I'm not sure that will work in every case.
Attachments (3)
Change History (18)
#1
@
14 years ago
- Keywords has-patch commit added; filters taxonomy_template taxonomy removed
- Milestone changed from Awaiting Review to 3.1
#2
@
14 years ago
- Keywords commit removed
OR, the format could be passed to get_the_taxonomies() as a parameter.
#4
@
14 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
We don't need another function argument here.
Why not a better filter name.
#5
@
14 years ago
Because it's much easier to pass an extra argument than to add a callback to a filter.
#6
@
14 years ago
Aren't template tags all about ease of use?
Which is better:
function alter_taxonomy_format() { return '%s -- %l'; } add_filter('taxonomy_format', 'alter_taxonomy_format'); the_taxonomies(); remove_filter('taxonomy_format', 'alter_taxonomy_format');
or:
the_taxonomies(array('template' => '%s -- %l'));
I really don't see why a filter was chosen in the first place.
#7
@
14 years ago
For one, I haven't a clue what %l
is. (It's an L, not a 1.) It's not a standard sprintf() notation, and I'm just for the first time discovering wp_sprintf(). I won't even get into how disjointed that function looks.
Template tags are about ease of use. That also means deciding on new function arguments (which you chose) versus wp_parse_args (which you used in your example) versus a filter (which would probably be better here, because it's such a narrow use case).
It's not like this template tag has another 15 arguments. It has one, $post. Doesn't get easier to use than that :-)
#10
@
14 years ago
Yes, see args.14740.diff
#11
follow-up:
↓ 12
@
14 years ago
Would like to see get_the_taxonomies( $post = null, $args = array() )
.
#12
in reply to:
↑ 11
@
14 years ago
Replying to nacin:
Would like to see
get_the_taxonomies( $post = null, $args = array() )
.
Here you go: http://core.trac.wordpress.org/attachment/ticket/14740/alt.14740.diff
#13
@
14 years ago
- Milestone changed from 3.1 to Future Release
Punting all tickets that are not regressions in 3.1.
The one in get_the_taxonomies() should be renamed to taxonomy_format. See 14740.diff