Last active
December 15, 2015 19:19
-
-
Save kasparsd/5310953 to your computer and use it in GitHub Desktop.
Enable post_type support for Automatic Post Scheduler plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Called from $time_of_post = aps_get_nearest_open_time( $data ); | |
function aps_get_nearest_open_time( $data ) { | |
// get furthest scheduled post | |
$post = get_posts( array( | |
'numberposts' => 1, | |
'post_status' => 'future', | |
'post_type' => $data['post_type'] | |
) ); | |
// if no scheduled posts, get furthest published post | |
if( empty( $post ) ) | |
$post = get_posts( array( | |
'posts_per_page' => 1, | |
'post_type' => $data['post_type'] | |
) ); | |
$post = array_pop( $post ); | |
return strtotime( $post->post_date ) + aps_get_interval(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment