Skip to content

Commit 052f67d

Browse files
committed
Introduce _doing_it_wrong(). See #15824.
git-svn-id: https://develop.svn.wordpress.org/trunk@16939 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4904a25 commit 052f67d

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

wp-includes/functions.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4453,3 +4453,37 @@ function show_admin_bar( $show ) {
44534453
$show_admin_bar = (bool) $show;
44544454
}
44554455

4456+
/**
4457+
* Marks something as being incorrectly called.
4458+
*
4459+
* There is a hook doing_it_wrong_run that will be called that can be used
4460+
* to get the backtrace up to what file and function called the deprecated
4461+
* function.
4462+
*
4463+
* The current behavior is to trigger an user error if WP_DEBUG is true.
4464+
* *
4465+
* @package WordPress
4466+
* @subpackage Debug
4467+
* @since 3.1.0
4468+
* @access private
4469+
*
4470+
* @uses do_action() Calls 'doing_it_wrong_run' and passes the function arguments.
4471+
* @uses apply_filters() Calls 'doing_it_wrong_trigger_error' and expects boolean value of true to do
4472+
* trigger or false to not trigger error.
4473+
*
4474+
* @param string $function The function that was called
4475+
* @param string $message Optional. The function that should have been called
4476+
* @param string $version Optional. The version of WordPress that deprecated the function
4477+
*/
4478+
function _doing_it_wrong( $function, $message, $version = null ) {
4479+
4480+
do_action( 'doing_it_wrong_run', $function, $message, $version );
4481+
4482+
// Allow plugin to filter the output error trigger
4483+
if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
4484+
if ( is_null( $version ) )
4485+
trigger_error( sprintf( __('%1$s was called with an argument that is <strong>incorrect</strong> - %2$s'), $function, $message ) );
4486+
else
4487+
trigger_error( sprintf( __('%1$s was called with an argument that is <strong>incorrect</strong> since version %2$s - %3$s'), $function, $version, $message ) );
4488+
}
4489+
}

0 commit comments

Comments
 (0)