rest_handle_deprecated_function() WordPress Function

The rest_handle_deprecated_function() function is used to handle deprecated WordPress REST API functions. This function is called by the deprecated_function() function. The function takes two arguments: the function name and an array of replacement functions. The deprecated function is called with the first function in the replacement array. If that function is not callable, the next function in the array is called, and so on. If no replacement function is callable, or if the replacement function does not return a WP_REST_Response object, then a WP_Error object is returned.

rest_handle_deprecated_function( string $function, string $replacement, string $version ) #

Handles _deprecated_function() errors.


Parameters

$function

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

$replacement

(string)(Required)The function that should have been called.

$version

(string)(Required)Version.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_handle_deprecated_function( $function, $replacement, $version ) {
	if ( ! WP_DEBUG || headers_sent() ) {
		return;
	}
	if ( ! empty( $replacement ) ) {
		/* translators: 1: Function name, 2: WordPress version number, 3: New function name. */
		$string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement );
	} 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-DeprecatedFunction: %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