функция
since 2.5.0
check_and_publish_future_post()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
check_and_publish_future_post( int|WP_Post $post )
Описание
Вызывается событием планировщика задач 'publish_future_post'. Эта защита не даёт планировщику публиковать черновики и т.п.
Оригинал (английский)
Invoked by cron ‘publish_future_post’ event. This safeguard prevents cron from publishing drafts, etc.
Параметры
$post
int|WP_Post
обязательный
Идентификатор записи или объект записи.
Исходный код
wp-includes/post.php:5385
function check_and_publish_future_post( $post ) {
$post = get_post( $post );
if ( ! $post ) {
return;
}
if ( 'future' !== $post->post_status ) {
return;
}
$time = strtotime( $post->post_date_gmt . ' GMT' );
// Uh oh, someone jumped the gun!
if ( $time > time() ) {
wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) ); // Clear anything else in the system.
wp_schedule_single_event( $time, 'publish_future_post', array( $post->ID ) );
return;
}
// wp_publish_post() returns no meaningful value.
wp_publish_post( $post->ID );
}
История изменений
| Версия | Описание |
|---|---|
| 2.5.0 | Introduced. |

