wp_xmlrpc_server::addTwoNumbers( int[] $args ): int|IXR_Error

In this article

Tests XMLRPC API by adding two numbers for client.

Parameters

$argsint[]required
Method arguments. Note: arguments must be ordered as documented.
  • 0 int
    A number to add.
  • 1 int
    A second number to add.

Return

int|IXR_Error Sum of the two given numbers.

Source

public function addTwoNumbers( $args ) {
	if ( ! is_array( $args ) || count( $args ) !== 2 || ! is_int( $args[0] ) || ! is_int( $args[1] ) ) {
		$this->error = new IXR_Error( 400, __( 'Invalid arguments passed to this XML-RPC method. Requires two integers.' ) );
		return $this->error;
	}

	$number1 = $args[0];
	$number2 = $args[1];
	return $number1 + $number2;
}

Changelog

VersionDescription
1.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.