akcjadynamicznyod 2.3.0
{$new_status}_{$post->post_type}
Args 3Plik wp-includes/post.php
Opis — z kodu źródłowego
Fires when a post is transitioned from one status to another.
The dynamic portions of the hook name, $new_status and $post->post_type, refer to the new post status and post type, respectively.
Possible hook names include:
draft_postfuture_postpending_postprivate_postpublish_posttrash_postdraft_pagefuture_pagepending_pageprivate_pagepublish_pagetrash_pagepublish_attachmenttrash_attachmentPlease note: When this action is hooked using a particular post status (like 'publish', aspublish_{$post->post_type}), it will fire both when a post is first transitioned to that status from something else, as well as upon subsequent post updates (old and new status are both the same). Therefore, if you are looking to only fire a callback when a post is first transitioned to a status, use the {@see 'transition_post_status'} hook instead.
Hook dynamiczny — możliwe nazwy
draft_pagedraft_postfuture_pagefuture_postpending_pagepending_postprivate_pageprivate_postpublish_attachmentpublish_pagepublish_posttrash_attachmenttrash_pagetrash_postParametry
| Parametr | Typ | Opis |
|---|---|---|
$post_id | int | Post ID. |
$post | \WP_Post | Post object. |
$old_status | string | Old post status. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_action( '{$new_status}_{$post->post_type}', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_action( '{$new_status}_{$post->post_type}', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}Popularne w tej kategorii