rest_handle_deprecated_function

函数
rest_handle_deprecated_function ( $function, $replacement, $version )
参数
  • (string) $function The function that was called.
    Required:
  • (string) $replacement The function that should have been called.
    Required:
  • (string) $version Version.
    Required:
定义位置
相关方法
rest_handle_deprecated_argument_deprecated_function_deprecated_file_deprecated_argumentrest_handle_options_request
引入
4.4.0
弃用
-

rest_handle_deprecated_function: 这个函数用于处理REST API端点中调用的弃用函数。它接受两个参数,第一个是函数名称,第二个是该函数被弃用的版本。它产生一个警告信息,告知开发者该函数已被弃用。

处理_deprecated_function()的错误。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 ) );
}
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 ) ); }
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 ) );
}

常见问题

FAQs
查看更多 >