filtrod 4.4.0
rest_pre_dispatch
Opis — z kodu źródłowego
Filters the pre-calculated result of a REST API dispatch request.
Allow hijacking the request before dispatching by returning a non-empty. The returned value will be used to serve the request instead.
Parametry
| Parametr | Typ | Opis |
|---|---|---|
$result | mixed | Response to replace the requested version with. Can be anything a normal endpoint can return, or null to not hijack the request. |
$server | \WP_REST_Server | Server instance. |
$request | \WP_REST_Request | Request used to generate the response. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_pre_dispatch', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_pre_dispatch', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}Popularne w tej kategorii