Automattic\WooCommerce\StoreApi

RoutesController::register_routes()protectedWC 1.0

Register defined list of routes with WordPress.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->register_routes( $version, $namespace );
$version(строка)
API Version being registered..
По умолчанию: 'v1'
$namespace(строка)
Overrides the default route namespace.
По умолчанию: 'wc/store/v1'

Код RoutesController::register_routes() WC 8.7.0

protected function register_routes( $version = 'v1', $namespace = 'wc/store/v1' ) {
	if ( ! isset( $this->routes[ $version ] ) ) {
		return;
	}
	$route_identifiers = array_keys( $this->routes[ $version ] );
	foreach ( $route_identifiers as $route ) {
		$route_instance = $this->get( $route, $version );
		$route_instance->set_namespace( $namespace );

		register_rest_route(
			$route_instance->get_namespace(),
			$route_instance->get_path(),
			$route_instance->get_args()
		);
	}
}