rest_handle_deprecated_argument() WordPress Function

The rest_handle_deprecated_argument() function is used to gracefully handle deprecated arguments in WordPress REST API requests. This function should be used whenever an argument is deprecated and replaced with a new one. deprecated The deprecated argument is the old argument that is being deprecated. This argument is no longer used and will be removed in a future version of WordPress. replacement The replacement argument is the new argument that should be used in its place. This argument should be used in all future REST API requests. This function allows for a smooth transition when an argument is deprecated and replaced with a new one. It is important to note that this function should only be used for deprecated arguments, and not for any other purpose.

rest_handle_deprecated_argument( string $function, string $message, string $version ) #

Handles _deprecated_argument() errors.


Parameters

$function

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

$message

(string)(Required)A message regarding the change.

$version

(string)(Required)Version.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_handle_deprecated_argument( $function, $message, $version ) {
	if ( ! WP_DEBUG || headers_sent() ) {
		return;
	}
	if ( $message ) {
		/* translators: 1: Function name, 2: WordPress version number, 3: Error message. */
		$string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
	} else {
		/* translators: 1: Function name, 2: WordPress version number. */
		$string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
	}

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


Top ↑

Changelog

Changelog
VersionDescription
4.4.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