{$new_status}_{$post->post_type}
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
do_action( "{$new_status}_{$post->post_type}", int $post_id, WP_Post $post, string $old_status )
Описание
Динамические части имени хука, $new_status и $post->post_type, соответствуют новому статусу записи и типу записи соответственно.
Возможные имена хуков:
draft_post
future_post
pending_post
private_post
publish_post
trash_post
draft_page
future_page
pending_page
private_page
publish_page
trash_page
publish_attachment
trash_attachment
Обратите внимание: когда это действие подключается к определённому статусу записи (например, 'publish', как publish_{$post->post_type}), оно срабатывает как при первом переходе записи в этот статус из другого, так и при последующих обновлениях записи (когда старый и новый статус совпадают).
Поэтому, если нужно вызвать функцию обратного вызова только при первом переходе записи в статус, используйте вместо этого хук 'transition_post_status'.
Оригинал (английский)
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_attachment
Please note: When this action is hooked using a particular post status (like ‘publish’, as publish_{$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 ‘transition_post_status’ hook instead.
Динамические части имени
{$new_status}- Динамические части имени хука, $new_status и $post->post_type, соответствуют новому статусу записи и типу записи соответственно.
{$post->post_type}- Динамическая часть имени хука.
Параметры
$post_id
int
обязательный
$post
WP_Post
обязательный
$old_status
string
обязательный
Исходный код
wp-includes/post.php:5883
do_action( "{$new_status}_{$post->post_type}", $post->ID, $post, $old_status );
История изменений
| Версия | Описание |
|---|---|
| 5.9.0 | Added $old_status parameter. |
| 2.3.0 | Introduced. |

