rest_format_combining_operation_error() WordPress Function

The rest_format_combining_operation_error function is used to return an error message when two or more format strings are combined. This function is used internally by the WordPress REST API and is not intended for use in themes or plugins.

rest_format_combining_operation_error( string $param, array $error ) #

Formats a combining operation error into a WP_Error object.


Parameters

$param

(string)(Required)The parameter name.

$error

(array)(Required)The error details.


Top ↑

Return

(WP_Error)


Top ↑

Source

File: wp-includes/rest-api.php

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 )
	);
}


Top ↑

Changelog

Changelog
VersionDescription
5.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More