rest_handle_doing_it_wrong() WordPress Function

The rest_handle_doing_it_wrong() function is used to log an error when a plugin or theme is using the REST API incorrectly. This can be useful for debugging purposes.

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

Handles _doing_it_wrong errors.


Parameters

$function

(string)(Required)The function that was called.

$message

(string)(Required)A message explaining what has been done incorrectly.

$version

(string|null)(Required)The version of WordPress where the message was added.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_handle_doing_it_wrong( $function, $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, $version, $message );
	} else {
		/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */
		$string = __( '%1$s (%2$s)' );
		$string = sprintf( $string, $function, $message );
	}

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


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More