rest_handle_deprecated_function

Handles _deprecated_function() errors.

Description

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

Parameters (3)

0. $function (string)
The function that was called.
1. $replacement (string)
The function that should have been called.
2. $version (string)
The version.

Usage

  1. if ( !function_exists( 'rest_handle_deprecated_function' ) ) { 
  2. require_once ABSPATH . WPINC . '/rest-api.php'; 
  3.  
  4. // The function that was called. 
  5. $function = ''; 
  6.  
  7. // The function that should have been called. 
  8. $replacement = ''; 
  9.  
  10. // The version. 
  11. $version = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = rest_handle_deprecated_function($function, $replacement, $version); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/rest-api.php  
  1. function rest_handle_deprecated_function( $function, $replacement, $version ) { 
  2. if ( ! empty( $replacement ) ) { 
  3. /** translators: 1: function name, 2: WordPress version number, 3: new function name */ 
  4. $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement ); 
  5. } else { 
  6. /** translators: 1: function name, 2: WordPress version number */ 
  7. $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version ); 
  8.  
  9. header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) );