函数原型
check_and_publish_future_post( int|WP_Post $post )
函数描述
Publishes future post and make sure post ID has future post status.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Required - Post ID or post object.
函数返回值
无
函数位置
File: wp-includes/post.php.
函数源码
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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |

