Automattic\WooCommerce\StoreApi\Schemas

ExtendSchema::register_update_callback()publicWC 1.0

Add callback functions that can be executed by the cart/extensions endpoint.

{} Это метод класса: ExtendSchema{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$ExtendSchema = new ExtendSchema();
$ExtendSchema->register_update_callback( $args );
$args(массив) (обязательный)

An array of elements that make up the callback configuration.

  • namespace(строка)
    Required. Plugin namespace.

  • callback(callable)
    Required. The function/callable to execute.

Код ExtendSchema::register_update_callback() WC 6.7.0

public function register_update_callback( $args ) {
	$args = wp_parse_args(
		$args,
		[
			'namespace' => '',
			'callback'  => null,
		]
	);

	if ( ! is_string( $args['namespace'] ) || empty( $args['namespace'] ) ) {
		throw new \Exception( 'You must provide a plugin namespace when extending a Store REST endpoint.' );
	}

	if ( ! is_callable( $args['callback'] ) ) {
		throw new \Exception( 'There is no valid callback supplied to register_update_callback.' );
	}

	$this->callback_methods[ $args['namespace'] ] = $args;
}