wp_publish_post example

$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 );
}

/** * Uses wp_checkdate to return a valid Gregorian-calendar value for post_date. * If post_date is not provided, this first checks post_date_gmt if provided, * then falls back to use the current time. * * For back-compat purposes in wp_insert_post, an empty post_date and an invalid * post_date_gmt will continue to return '1970-01-01 00:00:00' rather than false. * * @since 5.7.0 * * @param string $post_date The date in mysql format. * @param string $post_date_gmt The GMT date in mysql format. * @return string|false A valid Gregorian-calendar date string, or false on failure. */
Home | Imprint | This part of the site doesn't use cookies.