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
檢視更多 >