Title: rest_handle_doing_it_wrong
Published: August 11, 2020
Last modified: May 20, 2026

---

# rest_handle_doing_it_wrong( string $function_name, string $message, string|null $version )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#wp--skip-link--target)

Handles _doing_it_wrong errors.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#parameters)󠁿

 `$function_name`stringrequired

The function that was called.

`$message`stringrequired

A message explaining what has been done incorrectly.

`$version`string|nullrequired

The version of WordPress where the message was added.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#source)󠁿

    ```php
    function rest_handle_doing_it_wrong( $function_name, $message, $version ) {
    	if ( ! WP_DEBUG || headers_sent() ) {
    		return;
    	}

    	if ( $version ) {
    		/* translators: Developer debugging message. 1: PHP function name, 2: WordPress version number, 3: Explanatory message. */
    		$string = __( '%1$s (since %2$s; %3$s)' );
    		$string = sprintf( $string, $function_name, $version, $message );
    	} else {
    		/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */
    		$string = __( '%1$s (%2$s)' );
    		$string = sprintf( $string, $function_name, $message );
    	}

    	header( sprintf( 'X-WP-DoingItWrong: %s', $string ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api.php#L762)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api.php#L762-L778)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#related)󠁿

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/rest_handle_doing_it_wrong/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Frest_handle_doing_it_wrong%2F)
before being able to contribute a note or feedback.