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的错误。

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
查看更多 >