Skip to content

Commit

Permalink
Merge pull request mailchimp#487 from woocommerce/issue_485
Browse files Browse the repository at this point in the history
restore action handling to WC status, use data store to delete actions
  • Loading branch information
rrennick authored Mar 13, 2020
2 parents 59dbd87 + 45d7de5 commit ab32ca6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
22 changes: 19 additions & 3 deletions classes/ActionScheduler_AdminView.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated {

private static $screen_id = 'tools_page_action-scheduler';

/** @var ActionScheduler_ListTable */
protected $list_table;

/**
* @return ActionScheduler_AdminView
* @codeCoverageIgnore
Expand Down Expand Up @@ -82,18 +85,31 @@ public function register_menu() {
* Triggers processing of any pending actions.
*/
public function process_admin_ui() {
$table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
$table->process_actions();
$this->get_list_table();
}

/**
* Renders the Admin UI
*/
public function render_admin_ui() {
$table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
$table = $this->get_list_table();
$table->display_page();
}

/**
* Get the admin UI object and process any requested actions.
*
* @return ActionScheduler_ListTable
*/
protected function get_list_table() {
if ( null === $this->list_table ) {
$this->list_table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
$this->list_table->process_actions();
}

return $this->list_table;
}

/**
* Provide more information about the screen and its data in the help tab.
*/
Expand Down
10 changes: 5 additions & 5 deletions classes/abstracts/ActionScheduler_Abstract_ListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ protected function process_bulk_action() {
global $wpdb;
// Detect when a bulk action is being triggered.
$action = $this->current_action();

if ( ! $action ) {
return;
}
Expand All @@ -161,13 +160,14 @@ protected function process_bulk_action() {
}

/**
* Default code for deleting entries. We trust ids_sql because it is
* Default code for deleting entries.
* validated already by process_bulk_action()
*/
protected function bulk_delete( array $ids, $ids_sql ) {
global $wpdb;

$wpdb->query( "DELETE FROM {$this->table_name} WHERE {$this->ID} IN $ids_sql" );
$store = ActionScheduler::store();
foreach ( $ids as $action_id ) {
$store->delete( $action_id );
}
}

/**
Expand Down

0 comments on commit ab32ca6

Please sign in to comment.