Automattic\WooCommerce\StoreApi\Schemas

ExtendSchema::get_update_callback()publicWC 1.0

Get callback for a specific endpoint and namespace.

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

Хуков нет.

Возвращает

callable. The callback registered by the extension.

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

$ExtendSchema = new ExtendSchema();
$ExtendSchema->get_update_callback( $namespace );
$namespace(строка) (обязательный)
The namespace to get callbacks for.

Код ExtendSchema::get_update_callback() WC 8.7.0

public function get_update_callback( $namespace ) {
	if ( ! is_string( $namespace ) ) {
		throw new \Exception( 'You must provide a plugin namespace when extending a Store REST endpoint.' );
	}

	if ( ! array_key_exists( $namespace, $this->callback_methods ) ) {
		throw new \Exception( sprintf( 'There is no such namespace registered: %1$s.', $namespace ) );
	}

	if ( ! array_key_exists( 'callback', $this->callback_methods[ $namespace ] ) || ! is_callable( $this->callback_methods[ $namespace ]['callback'] ) ) {
		throw new \Exception( sprintf( 'There is no valid callback registered for: %1$s.', $namespace ) );
	}

	return $this->callback_methods[ $namespace ]['callback'];
}