[wp-trac] [WordPress Trac] #33369: Cannot intelligently target using the `get_terms_args` filter
WordPress Trac
noreply at wordpress.org
Wed Aug 26 02:12:54 UTC 2015
#33369: Cannot intelligently target using the `get_terms_args` filter
-----------------------------------+------------------------------
Reporter: johnjamesjacoby | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 2.2
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses:
-----------------------------------+------------------------------
Comment (by boonebgorges):
If I'm understanding knutsp's concern correctly, I think the concern is
somewhat misplaced. Filters like 'get_terms_args' mean that it's *already*
possible for plugins to modify the args that you pass to the function,
whether you pass them explicitly or implicitly (by relying on defaults).
Passing the pristine `$args` to the filter only provides additional info
to the plugin developer. Granted, the specific example that
johnjamesjacoby used in the original description may be what's scaring
you. In real life, it'd be the callbacks responsibility to do something
like this:
{{{
function wp33369_filter_get_terms_args( $args, $taxonomies, $original_args
) {
// Only override the value of 'orderby' if it was explicitly passed.
if ( isset( $original_args['orderby'] ) && 'id' !==
$original_args['orderby'] ) {
$args['orderby'] = 'id';
}
return $args;
}
add_filter( 'get_terms_args', 'wp33369_filter_get_terms_args', 10, 3 );
}}}
It may sometimes be appropriate for a plugin to override the implicit
defaults, and it may sometimes be inappropriate for it to do so. It's up
to the plugin developer to decide.
In any case, I think the suggestion of passing the pristine arguments to
the filters is a reasonable one. To reduce the churn of changing the
variable name in a hundred places, [attachment:33369.diff] copies the
explicits args to `$_args`. johnjamesjacoby, does this capture the spirit
of what you're asking for?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33369#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list