[wp-trac] [WordPress Trac] #16245: remove_filter makes filters applied after that useless
WordPress Trac
wp-trac at lists.automattic.com
Sat Jan 15 20:51:31 UTC 2011
#16245: remove_filter makes filters applied after that useless
--------------------------+------------------------------
Reporter: oddoneout | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 3.0.4
Severity: major | Resolution:
Keywords: |
--------------------------+------------------------------
Changes (by scribu):
* severity: normal => major
Old description:
> Here's some codes:
>
> {{{
> function run_once() {
> remove_filter( 'foobar', 'run_once' );
> return 'test';
> }
> add_filter( 'foobar', 'run_once' );
>
> add_filter( 'foobar', function($test) {return 'test again';}, 11 );
>
> echo apply_filters( 'foobar', '', 'huh' );
> }}}
>
> The result of this is 'test' instead of 'test again'. This might happen
> with remove_action, I haven't tested that function though.
New description:
Here's some codes:
{{{
function run_once() {
remove_filter( current_filter(), __FUNCTION__ );
return 'test';
}
add_filter( 'foobar', 'run_once' );
function another_filter() {
return 'test again';
}
add_filter( 'foobar', 'another_filter', 11 );
echo apply_filters( 'foobar', '' );
}}}
The result of this is 'test' instead of 'test again'. This might happen
with remove_action, I haven't tested that function though.
--
Comment:
Reproduced with r17312.
Cleaned up the example code slightly.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16245#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list