return$wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY %s %s LIMIT %d,%d;",$args['post_type'],$args['post_status'],$orderby,$args['order'],$offset,$args['posts_per_page']),'OBJECT');
if(isset($args['paged'])){
$paged=max(0,$args['paged']-1);
$offset=$paged*$args['posts_per_page'];
}else{
$offset=0;
}
return$wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY %s %s LIMIT %d,%d;",$args['post_type'],$args['post_status'],$orderby,$args['order'],$offset,$args['posts_per_page']),'OBJECT');
}
/**
...
...
@@ -241,57 +236,69 @@ class Cron_Options_CPT extends Singleton {
}
/**
* Create a job post, respecting whether or not Core is ready for CPTs
* Create a post object for a given event
*
* `wp_insert_post()` can't be called as early as we need, in part because of the capabilities checks Core performs
* Can't call `wp_insert_post()` because `wp_unique_post_slug()` breaks the plugin's expectations
* Also doesn't call `wp_insert_post()` because this function is needed before post types and capabilities are ready.
@@ -135,20 +135,14 @@ class Events extends Singleton {
returnnew\WP_Error('no-free-threads',sprintf(__('No resources available to run the job with action action `%1$s` and arguments `%2$s`.','automattic-cron-control'),$event['action'],maybe_serialize($event['args'])),array('status'=>429,));
}
// Mark the event completed, and reschedule if desired
@@ -164,6 +158,51 @@ class Events extends Singleton {
'message'=>sprintf(__('Job with action `%1$s` and arguments `%2$s` completed in %3$d seconds.','automattic-cron-control'),$event['action'],maybe_serialize($event['args']),$time_end-$time_start),
);
}
/**
* Mark an event completed, and reschedule when requested
*/
privatefunctionupdate_event_record($event){
if(false!==$event['schedule']){
// Re-implements much of the logic from `wp_reschedule_event()`