[wp-trac] [WordPress Trac] #34183: Add context to `doing_it_wrong_trigger_error` filter
WordPress Trac
noreply at wordpress.org
Wed Oct 7 07:00:28 UTC 2015
#34183: Add context to `doing_it_wrong_trigger_error` filter
--------------------------+-----------------------------
Reporter: dd32 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
At present the `doing_it_wrong_trigger_error` filter is a boolean on-off
switch for `_doing_it_wrong()`'s `trigger_error()` call.
The `doing_it_wrong_run` action is available to catch all of the
`_doing_it_wrong()`s but there's no easy way to disable a ''single''
`_doing_it_wrong` notice.
The following code can be used to conditionally disable it:
{{{
add_action( 'doing_it_wrong_run', '_abc_maybe_cancel_notice', 10, 2 );
function _abc_maybe_cancel_notice( $function, $message ) {
if ( WP_DEBUG && 'specific _doing_it_wrong message' == $message )
{
add_filter( 'doing_it_wrong_trigger_error',
'_abc_cancel_notice' );
}
}
function _abc_cancel_notice() {
remove_filter( 'doing_it_wrong_trigger_error',
'_abc_cancel_notice' );
return false;
}
}}}
It would be far simpler if the same context were passed to both filters.
I'm on the fence here - Either you're interested in the notices, or you're
not.. but at the same time, sometimes you're using a library (such as
HyperDB) which triggers the notices and you just want silence again..
Any thoughts?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34183>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list