Home / APIs / _doing_it_wrong() – Mark something as being incorrectly called.

You appear to be a bot. Output may be restricted

Description

Mark something as being incorrectly called.

There is a hook doing_it_wrong_run that will be called that can be used to get the backtrace up to what file and function called the deprecated function. The current behavior is to trigger a user error if WP_DEBUG is true.

Usage

_doing_it_wrong( $function, $message, $version );

Parameters

$function
( string ) required – The function that was called.
$message
( string ) required – A message explaining what has been done incorrectly.
$version
( string ) required – The version of WordPress where the message was added.

Returns

void

Source

File name: wordpress/wp-includes/functions.php
Lines: 1 to 47 of 47

function _doing_it_wrong( $function, $message, $version ) {

  
/**
 * Fires when the given function is being used incorrectly.
 *
 * @since 3.1.0
 *
 * @param string $function The function that was called.
 * @param string $message  A message explaining what has been done incorrectly.
 * @param string $version  The version of WordPress where the message was added.
 */
  do_action( 'doing_it_wrong_run', $function, $message, $version );

  
/**
 * Filters whether to trigger an error for _doing_it_wrong() calls.
 *
 * @since 3.1.0
 *
 * @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
 */
  if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
    if ( function_exists( '__' ) ) {
      if ( is_null( $version ) ) {
        $version = '';
      } else {
        /* translators: %s: version number */
        $version = sprintf( __( '(This message was added in version %s.)' ), $version );
      }
      /* translators: %s: Codex URL */
      $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
        __( 'https://codex.wordpress.org/Debugging_in_WordPress' )
      );
      /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message */
      trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
    } else {
      if ( is_null( $version ) ) {
        $version = '';
      } else {
        $version = sprintf( '(This message was added in version %s.)', $version );
      }
      $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.',
        'https://codex.wordpress.org/Debugging_in_WordPress'
      );
      trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
    }
  }
}
 

 View on GitHub View on Trac

Published: 12th March 2017 | Last updated: 12th March 2017

Information

Function name: _doing_it_wrong
Plugin ref: WordPress
Version: 5.0.3
Sourcefile: wp-includes/functions.php
File ref: wp-includes/functions.php
API type: private
Deprecated?: No
API Letters: _,D,I,W

  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Files
  • Hooks
  • Classes
  • Sites
  • Sitemap
  • Blog
WooCommerce a2z WooCommerce a2z
WooCommerce

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins