WordPress.org

Make WordPress Core

Changeset 16939


Ignore:
Timestamp:
12/15/10 11:29:50 (6 years ago)
Author:
westi
Message:

Introduce _doing_it_wrong(). See #15824.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r16904 r16939  
    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 */ 
     4478function _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} 
Note: See TracChangeset for help on using the changeset viewer.