[wp-trac] [WordPress Trac] #14671: Deprecate the "accepted args" argument in add_filter() and add_action()
WordPress Trac
noreply at wordpress.org
Fri Dec 8 12:05:29 UTC 2017
#14671: Deprecate the "accepted args" argument in add_filter() and add_action()
------------------------------------+----------------------
Reporter: markjaquith | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Plugins | Version:
Severity: normal | Resolution: wontfix
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+----------------------
Changes (by johnbillion):
* status: new => closed
* resolution: => wontfix
* milestone: Future Release =>
Comment:
I think the point has passed where it's possible to make this change. Core
was probably already past that point when this ticket was opened seven
years ago.
I know that in the past I've written functions that accept more than one
parameter, but only receive one parameter when they're used as a filter or
action callback. One that comes to mind is a `$force` flag for deletion.
Example:
{{{
function trash_connected_item( $term_id, $force_delete = false ) {
if ( $force_delete ) {
// delete connected term
} else {
// trash connected term
}
}
add_action( 'delete_term', 'trash_connected_item' );
}}}
This code would break with any of the proposed patches above, because the
second parameter from the `delete_term` filter (`$tt_id`) would be passed
as the `$force_delete` parameter and act as a truthy value.
Feel free to re-open if there's a way this can be worked around.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/14671#comment:44>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list