transition_post_status хук-событиеWP 2.3.0

Fires when a post is transitioned from one status to another.

Использование

add_action( 'transition_post_status', 'wp_kama_transition_post_status_action', 10, 3 );

/**
 * Function for `transition_post_status` action-hook.
 * 
 * @param string  $new_status New post status.
 * @param string  $old_status Old post status.
 * @param WP_Post $post       Post object.
 *
 * @return void
 */
function wp_kama_transition_post_status_action( $new_status, $old_status, $post ){

	// action...
}
$new_status(строка)
New post status.
$old_status(строка)
Old post status.
$post(WP_Post)
Post object.

Список изменений

С версии 2.3.0 Введена.

Где вызывается хук

wp_transition_post_status()
transition_post_status
wp-includes/post.php 5347
do_action( 'transition_post_status', $new_status, $old_status, $post );

Где используется хук в WordPress

wp-includes/blocks/calendar.php 152
add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 );
wp-includes/default-filters.php 413
add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
wp-includes/default-filters.php 414
add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 );
wp-includes/default-filters.php 437
add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 );
wp-includes/default-filters.php 522
add_action( 'transition_post_status', '_wp_customize_publish_changeset', 10, 3 );
wp-includes/default-filters.php 525
add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 );
wp-includes/default-filters.php 534
add_action( 'transition_post_status', '__clear_multi_author_cache' );
wp-includes/ms-default-filters.php 80
add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
wp-includes/ms-default-filters.php 81
add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );