woocommerce_hydration_dispatch_request
Similar to WP core's rest_dispatch_request this allows plugin to override hydrating the request. Allows backward compatibility with the rest_dispatch_request by providing the same arguments.
Использование
add_filter( 'woocommerce_hydration_dispatch_request', 'wp_kama_woocommerce_hydration_dispatch_request_filter', 10, 4 ); /** * Function for `woocommerce_hydration_dispatch_request` filter-hook. * * @param mixed $hydration_result Result of the hydration. If not null, this will be used as the response. * @param WP_REST_Request $request Request used to generate the response. * @param string $path Request path matched for the request.. * @param array $handler Route handler used for the request. * * @return mixed */ function wp_kama_woocommerce_hydration_dispatch_request_filter( $hydration_result, $request, $path, $handler ){ // filter... return $hydration_result; }
- $hydration_result(разное)
- Result of the hydration. If not null, this will be used as the response.
- $request(WP_REST_Request)
- Request used to generate the response.
- $path(строка)
- Request path matched for the request..
- $handler(массив)
- Route handler used for the request.
Список изменений
С версии 8.9.0 | Введена. |
Где вызывается хук
woocommerce_hydration_dispatch_request
woocommerce/src/Blocks/Domain/Services/Hydration.php 150
$hydration_result = apply_filters( 'woocommerce_hydration_dispatch_request', null, $request, $path, $handler );