rest_handle_doing_it_wrong

函式
rest_handle_doing_it_wrong ( $function, $message, $version )
引數
  • (string) $function The function that was called.
    Required:
  • (string) $message A message explaining what has been done incorrectly.
    Required:
  • (string|null) $version The version of WordPress where the message was added.
    Required:
定義位置
相關方法
_doing_it_wrongrest_handle_options_requestrest_handle_deprecated_functionregister_and_do_post_meta_boxesrest_handle_deprecated_argument
引入
5.5.0
棄用
-

rest_handle_doing_it_wrong: 這個函式用於處理由”做錯了”的開發者產生的錯誤。它接受三個引數,第一個是被錯誤呼叫的函式或方法名稱,第二個是解釋錯誤的訊息,第三個是錯誤用法被棄用的版本。

處理_doing_it_wrong的錯誤。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function rest_handle_doing_it_wrong( $function, $message, $version ) {
if ( ! WP_DEBUG || headers_sent() ) {
return;
}
if ( $version ) {
/* translators: Developer debugging message. 1: PHP function name, 2: WordPress version number, 3: Explanatory message. */
$string = __( '%1$s (since %2$s; %3$s)' );
$string = sprintf( $string, $function, $version, $message );
} else {
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */
$string = __( '%1$s (%2$s)' );
$string = sprintf( $string, $function, $message );
}
header( sprintf( 'X-WP-DoingItWrong: %s', $string ) );
}
function rest_handle_doing_it_wrong( $function, $message, $version ) { if ( ! WP_DEBUG || headers_sent() ) { return; } if ( $version ) { /* translators: Developer debugging message. 1: PHP function name, 2: WordPress version number, 3: Explanatory message. */ $string = __( '%1$s (since %2$s; %3$s)' ); $string = sprintf( $string, $function, $version, $message ); } else { /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */ $string = __( '%1$s (%2$s)' ); $string = sprintf( $string, $function, $message ); } header( sprintf( 'X-WP-DoingItWrong: %s', $string ) ); }
function rest_handle_doing_it_wrong( $function, $message, $version ) {
	if ( ! WP_DEBUG || headers_sent() ) {
		return;
	}

	if ( $version ) {
		/* translators: Developer debugging message. 1: PHP function name, 2: WordPress version number, 3: Explanatory message. */
		$string = __( '%1$s (since %2$s; %3$s)' );
		$string = sprintf( $string, $function, $version, $message );
	} else {
		/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */
		$string = __( '%1$s (%2$s)' );
		$string = sprintf( $string, $function, $message );
	}

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

常見問題

FAQs
檢視更多 >