\WP_CLI::error(__('Specify something to delete, or see the `cron-control-fixers` command to remove all data.','automattic-cron-control'));
}
/**
* Retrieve list of events, and related data, for a given request
*/
...
...
@@ -106,7 +129,7 @@ class Events extends \WP_CLI_Command {
$offset=absint(($page-1)*$limit);
// Query
$items=$wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS ID, post_content_filtered, post_date_gmt, post_modified_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY post_date ASC LIMIT %d,%d",\Automattic\WP\Cron_Control\Cron_Options_CPT::POST_TYPE,$post_status,$offset,$limit));
$items=$wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS ID, post_title, post_content_filtered, post_date_gmt, post_modified_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY post_date ASC LIMIT %d,%d",\Automattic\WP\Cron_Control\Cron_Options_CPT::POST_TYPE,$post_status,$offset,$limit));
// Bail if we don't get results
if(!is_array($items)){
...
...
@@ -242,6 +265,232 @@ class Events extends \WP_CLI_Command {
// Look up full object and confirm that the entry belongs to this plugin's CPT
global$wpdb;
$event_post=$wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type = %s AND ID = %d LIMIT 1",\Automattic\WP\Cron_Control\Cron_Options_CPT::POST_TYPE,$jid));
\WP_CLI::error(sprintf(__('Failed to delete event %d. Please confirm that the entry exists and that the ID is that of an event.','automattic-cron-control'),$jid));
\WP_CLI::line(sprintf(_n('Found one event to check','Found %s events to check',$events['total_items'],'automattic-cron-control'),number_format_i18n($events['total_items'])));
$search_progress=\WP_CLI\Utils\make_progress_bar(sprintf(__('Searching events for those with the action `%s`','automattic-cron-control'),$action),$events['total_items']);
\WP_CLI::error(sprintf(__('No events with action `%s` found','automattic-cron-control'),$action));
}
// List the items to remove
$total_to_delete=count($events_to_delete);
\WP_CLI::line(sprintf(_n('Found one event with action `%2$s`:','Found %1$s events with action `%2$s`:',$total_to_delete,'automattic-cron-control'),number_format_i18n($total_to_delete),$action));
\WP_CLI::warning(sprintf(__('Events are not displayed as there are more than %s to remove','automattic-cron-control'),number_format_i18n($assoc_args['limit'])));
}
\WP_CLI::line('');
\WP_CLI::confirm(_n('Are you sure you want to delete this event?','Are you sure you want to delete these events?',$total_to_delete,'automattic-cron-control'));
\WP_CLI::warning(sprintf(__('Expected to delete %1$s events, but could only delete %2$s events. It\'s likely that some events were executed while this command ran.','automattic-cron-control'),number_format_i18n($total_to_delete),number_format_i18n($events_deleted_count)));
}
// Limit just to failed deletes when many events are removed