Make sure post has future status before publishing from cron. Props hailin. fixes #5801
git-svn-id: http://svn.automattic.com/wordpress/trunk@6985 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
038910ae4e
commit
b49ff57e63
|
@ -160,7 +160,7 @@ add_filter('atom_service_url','atom_service_url_filter');
|
||||||
add_action('wp_head', 'rsd_link');
|
add_action('wp_head', 'rsd_link');
|
||||||
add_action('wp_head', 'wlwmanifest_link');
|
add_action('wp_head', 'wlwmanifest_link');
|
||||||
add_action('wp_head', 'locale_stylesheet');
|
add_action('wp_head', 'locale_stylesheet');
|
||||||
add_action('publish_future_post', 'wp_publish_post', 10, 1);
|
add_action('publish_future_post', 'check_and_publish_future_post', 10, 1);
|
||||||
add_action('wp_head', 'noindex', 1);
|
add_action('wp_head', 'noindex', 1);
|
||||||
add_action('wp_head', 'wp_print_scripts');
|
add_action('wp_head', 'wp_print_scripts');
|
||||||
add_action('wp_head', 'wp_generator');
|
add_action('wp_head', 'wp_generator');
|
||||||
|
|
|
@ -1393,6 +1393,34 @@ function wp_publish_post($post_id) {
|
||||||
do_action('wp_insert_post', $post_id, $post);
|
do_action('wp_insert_post', $post_id, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check_and_publish_future_post() - check to make sure post has correct status before
|
||||||
|
* passing it on to be published. Invoked by cron 'publish_future_post' event
|
||||||
|
* This safeguard prevents cron from publishing drafts, etc.
|
||||||
|
*
|
||||||
|
* {@internal Missing Long Description}}
|
||||||
|
*
|
||||||
|
* @package WordPress
|
||||||
|
* @subpackage Post
|
||||||
|
* @since 2.5
|
||||||
|
* @uses $wpdb
|
||||||
|
*
|
||||||
|
* @param int $post_id Post ID
|
||||||
|
* @return int|null {@internal Missing Description}}
|
||||||
|
*/
|
||||||
|
function check_and_publish_future_post($post_id) {
|
||||||
|
|
||||||
|
$post = get_post($post_id);
|
||||||
|
|
||||||
|
if ( empty($post) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( 'future' != $post->post_status )
|
||||||
|
return;
|
||||||
|
|
||||||
|
return wp_publish_post($post_id);
|
||||||
|
}
|
||||||
|
|
||||||
function wp_add_post_tags($post_id = 0, $tags = '') {
|
function wp_add_post_tags($post_id = 0, $tags = '') {
|
||||||
return wp_set_post_tags($post_id, $tags, true);
|
return wp_set_post_tags($post_id, $tags, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue