check_and_publish_future_post() - WordPress 函数参考中文文档

返回介绍

check_and_publish_future_post()

发布于 2017-09-10 字数1721 浏览 1086 评论 0

check_and_publish_future_post( int|WP_Post $post_id )

Publish future post and make sure post ID has future post status.


描述

Invoked by cron ‘publish_future_post’ event. This safeguard prevents cron from publishing drafts, etc.


参数

$post_id

(int|WP_Post)
(Required)
Post ID or post object.


源代码

File: wp-includes/post.php

function check_and_publish_future_post( $post_id ) {
	$post = get_post($post_id);

	if ( empty($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 描述
2.5.0 Introduced.

相关函数

Uses

  • wp-includes/cron.php:
    wp_clear_scheduled_hook()
  • wp-includes/cron.php:
    wp_schedule_single_event()
  • wp-includes/post.php:
    wp_publish_post()
  • wp-includes/post.php:
    get_post()

User Contributed Notes

上一篇:check_ajax_referer()

下一篇:check_column()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!