WP HOOKS
filtrod 4.4.0

rest_pre_dispatch

Args 3Plik wp-includes/rest-api/class-wp-rest-server.phpDokumentacja WP ↗

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

ParametrTypOpis
$resultmixedResponse to replace the requested version with. Can be anything a normal endpoint can return, or null to not hijack the request.
$server\WP_REST_ServerServer instance.
$request\WP_REST_RequestRequest 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
}

Popularne w tej kategorii