rest_format_combining_operation_error

函式
rest_format_combining_operation_error ( $param, $error )
引數
  • (string) $param The parameter name.
    Required:
  • (array) $error The error details.
    Required:
返回值
  • (WP_Error)
定義位置
相關方法
rest_get_combining_operation_errorpost_format_meta_boxrest_find_matching_pattern_property_schemaget_comments_pagination_arrowrest_find_one_matching_schema
引入
5.6.0
棄用
-

rest_format_combining_operation_error: 這個函式用於格式化包含組合操作(如allOf、anyOf或oneOf)的模式的錯誤資訊,該操作未能驗證。它接收一個錯誤資訊的陣列,並返回一個格式化的錯誤資訊。

將一個組合操作錯誤形成一個WP_Error物件。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function rest_format_combining_operation_error( $param, $error ) {
$position = $error['index'];
$reason = $error['error_object']->get_error_message();
if ( isset( $error['schema']['title'] ) ) {
$title = $error['schema']['title'];
return new WP_Error(
'rest_no_matching_schema',
/* translators: 1: Parameter, 2: Schema title, 3: Reason. */
sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ),
array( 'position' => $position )
);
}
return new WP_Error(
'rest_no_matching_schema',
/* translators: 1: Parameter, 2: Reason. */
sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ),
array( 'position' => $position )
);
}
function rest_format_combining_operation_error( $param, $error ) { $position = $error['index']; $reason = $error['error_object']->get_error_message(); if ( isset( $error['schema']['title'] ) ) { $title = $error['schema']['title']; return new WP_Error( 'rest_no_matching_schema', /* translators: 1: Parameter, 2: Schema title, 3: Reason. */ sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ), array( 'position' => $position ) ); } return new WP_Error( 'rest_no_matching_schema', /* translators: 1: Parameter, 2: Reason. */ sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ), array( 'position' => $position ) ); }
function rest_format_combining_operation_error( $param, $error ) {
	$position = $error['index'];
	$reason   = $error['error_object']->get_error_message();

	if ( isset( $error['schema']['title'] ) ) {
		$title = $error['schema']['title'];

		return new WP_Error(
			'rest_no_matching_schema',
			/* translators: 1: Parameter, 2: Schema title, 3: Reason. */
			sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ),
			array( 'position' => $position )
		);
	}

	return new WP_Error(
		'rest_no_matching_schema',
		/* translators: 1: Parameter, 2: Reason. */
		sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ),
		array( 'position' => $position )
	);
}

常見問題

FAQs
檢視更多 >