wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
check_and_publish_future_post › WordPress Function
Seit2.5.0
Veraltetn/v
› check_and_publish_future_post ( $post_id )
Parameter: |
|
Definiert in: |
|
Codex: |
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.Ähnliche Funktionen: get_others_unpublished_posts, wp_publish_post, _publish_post_hook, the_author_posts, user_can_delete_post
Quellcode
function check_and_publish_future_post( $post_id ) { $post = get_post( $post_id ); 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 ); }