I’m trying to figure out why future_to_publish
will not work. Here is a list of what I have checked to work:
draft_to_publish
future_post
publish_post
transition_post_status
(works draft to future, but not future to publish)
I can’t seem to figure out the problem. I’ll include the test code I’m using below:
function on_post_scheduled( $ID, $post ) {
$fp = fopen( get_template_directory() . "/files/foo.php", 'r+' );
if ( flock( $fp, LOCK_EX ) ) {
ftruncate( $fp, 0 );
fwrite( $fp, "future post published" . mt_rand( 0, 255 ) );
fflush( $fp );
flock( $fp, LOCK_UN );
}
}
add_action( 'future_to_publish', 'on_post_scheduled', 10, 2 );
add_action( 'new_to_publish', 'on_post_scheduled', 10, 2);
add_action( 'draft_to_publish', 'on_post_scheduled', 10, 2);