filtrdynamicznyod 4.7.0
rest_pre_insert_{$this->post_type}
Args 2Plik wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Opis — z kodu źródłowego
Filters a post before it is inserted via the REST API.
The dynamic portion of the hook name, $this->post_type, refers to the post type slug.
Possible hook names include:
rest_pre_insert_postrest_pre_insert_pagerest_pre_insert_attachment
Hook dynamiczny — możliwe nazwy
rest_pre_insert_attachmentrest_pre_insert_pagerest_pre_insert_postParametry
| Parametr | Typ | Opis |
|---|---|---|
$prepared_post | \stdClass | An object representing a single post prepared for inserting or updating the database. |
$request | \WP_REST_Request | Request object. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_pre_insert_{$this->post_type}', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_pre_insert_{$this->post_type}', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}Popularne w tej kategorii