Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




check_and_publish_future_post [ WordPress Function ]

check_and_publish_future_post ( $post_id )
Parameters:
  • (int) $post_id Post ID.
Returns:
  • (null) Nothing is returned. Which can mean that no action is required or post was published.
Defined at:



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.

Source


<?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' );

    if ( 
$time time() ) { // Uh oh, someone jumped the gun!
        
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;
    }

    return 
wp_publish_post($post_id);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics