THE MOLITOR
Member
Posted 5 months ago #
Hi there,
I'm using the following code in my functions.php file that sets posts with a future publish date to the "published" status (instead of "scheduled").
Everything worked perfect until updating to WordPress 3.5. Does anybody know why?...
function setup_future_hook() {
// Replace native future_post function with replacement
remove_action('future_post', '_future_post_hook');
add_action('future_post', 'publish_future_post_now');
}
function publish_future_post_now($id) {
// Set new post's post_status to "publish" rather than "future."
wp_publish_post($id);
}
add_action('init', 'setup_future_hook');
Looking more in detail at http://wpseek.com/_future_post_hook/ it seems that you may need
function setup_future_hook() {
// Replace native future_post function with replacement
remove_action('future_post', '_future_post_hook');
add_action('future_post', 'publish_future_post_now');
}
function publish_future_post_now($deprecated,$id) {
// Set new post's post_status to "publish" rather than "future."
wp_publish_post($id);
}
add_action('init', 'setup_future_hook');
Interesting. wp_publish_post() used to do a direct database call. It was updated to use wp_update_post() in 3.5. The side effect is that it no longer forcibly publishes a post that is dated in the future. I am not sure whether pre-3.5, or post-3.5, should be considered expected behavior. Relevant Trac ticket, https://core.trac.wordpress.org/ticket/21963, and commit, https://core.trac.wordpress.org/changeset/21942.
Try this as a workaround:
remove_action('future_post', '_future_post_hook');
add_filter( 'wp_insert_post_data', 'nacin_do_not_set_posts_to_future' );
function nacin_do_not_set_posts_to_future( $data ) {
if ( $data['post_status'] == 'future' && $data['post_type'] == 'post' )
$data['post_status'] = 'publish';
return $data;
}
THE MOLITOR
Member
Posted 5 months ago #
Thanks a bunch Andrew Nacin! I've updated the repo with your version, which should be compatible with all WP versions.
http://wordpress.org/extend/plugins/the-future-is-now/
Scheduled posts regression is high WordPress 3.5 bug, correct on WordPress 3.5.1-beta1!
WP Missed Schedule correct exactly ticket #22944 and others related issues of WordPress since version 2.6 ;) ignored from core team ...
Upgrade to WordPress 3.5.1-beta1 or install my plugin WP Missed Schedule ;)
stephenmed
Member
Posted 2 months ago #
OMG!!! You don't know how long Ive been trying to fix this. Loaded the-future-is-now and it orked like a charm. Bought a template a week ago and haven't been able to get it to work. Support seemed lost so I guess they owe you a thanks too.