check_and_publish_future_post()
最后更新于:2021-11-25 20:28:59
check_and_publish_future_post( int|GC_Post$post_id)Publish future post and make sure post ID has future post status.
参数
- $post_id
-
(int|GC_Post) (Required) Post ID or post object.
源文件
文件: gc-includes/post.php
function check_and_publish_future_post( $post_id ) {
$post = get_post( $post_id );
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() ) {
gc_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // Clear anything else in the system.
gc_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
return;
}
// gc_publish_post() returns no meaningful value.
gc_publish_post( $post_id );
}