Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14740 closed defect (bug) (fixed)

'taxonomy_template' Filter Name Clash

Reported by: charlesclarkson's profile CharlesClarkson Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch
Focuses: Cc:


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)

14740.diff (474 bytes) - added by scribu 14 years ago.
args.14740.diff (1.4 KB) - added by scribu 14 years ago.
alt.14740.diff (1.1 KB) - added by scribu 14 years ago.

Download all attachments as: .zip

Change History (18)

14 years ago

#1 @scribu
14 years ago

  • Keywords has-patch commit added; filters taxonomy_template taxonomy removed
  • Milestone changed from Awaiting Review to 3.1

The one in get_the_taxonomies() should be renamed to taxonomy_format. See 14740.diff

#2 @scribu
14 years ago

  • Keywords commit removed

OR, the format could be passed to get_the_taxonomies() as a parameter.

#3 @scribu
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [16665]) Get rid of misplaced 'taxonomy_template' filter. Fixes #14740

#4 @nacin
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 @scribu
14 years ago

Because it's much easier to pass an extra argument than to add a callback to a filter.

#6 @scribu
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');
remove_filter('taxonomy_format', 'alter_taxonomy_format');


the_taxonomies(array('template' => '%s -- %l'));

I really don't see why a filter was chosen in the first place.

#7 @nacin
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 :-)

#8 @scribu
14 years ago

get_the_taxonomies() has one. the_taxonomies() has 4.

#9 @nacin
14 years ago

Can we use an $args at least?

14 years ago

#11 follow-up: @nacin
14 years ago

Would like to see get_the_taxonomies( $post = null, $args = array() ).

14 years ago

#12 in reply to: ↑ 11 @scribu
14 years ago

Replying to nacin:

Would like to see get_the_taxonomies( $post = null, $args = array() ).

Here you go:

#13 @ryan
14 years ago

  • Milestone changed from 3.1 to Future Release

Punting all tickets that are not regressions in 3.1.

#14 @nacin
14 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [17028]) Make get_the_taxonomies() take an array of arguments. props scribu, fixes #14740.

#15 @nacin
14 years ago

  • Milestone changed from Future Release to 3.1
Note: See TracTickets for help on using tickets.