Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Last active December 15, 2015 19:19
Show Gist options
  • Save kasparsd/5310953 to your computer and use it in GitHub Desktop.
Save kasparsd/5310953 to your computer and use it in GitHub Desktop.
Enable post_type support for Automatic Post Scheduler plugin
<?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