Last active
November 20, 2023 08:01
-
-
Save jessepearson/5ad64cceb2dff2ef72b72b98d1cdfd32 to your computer and use it in GitHub Desktop.
Revisions
-
jessepearson revised this gist
May 17, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ <?php // Do not copy this line. /** * Will clear out all the specified completed scheduled actions, 5000 at a time. */ -
jessepearson renamed this gist
May 17, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jessepearson created this gist
May 17, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ /** * Will clear out all the specified completed scheduled actions, 5000 at a time. */ function clear_woocommerce_scheduled_actions_20200609() { global $wpdb; $limit = 5000; $actions_table = $wpdb->prefix . 'actionscheduler_actions'; $logs_table = $wpdb->prefix . 'actionscheduler_logs'; $actions_query = sprintf( " SELECT action_id FROM %s WHERE status = 'complete' LIMIT %s ", $actions_table, $limit ); $action_ids = $wpdb->get_col( $actions_query ); $ids = implode( ',', array_map( 'absint', $action_ids ) ); if ( ! empty( $ids ) ) { $deleted_logs = $wpdb->query( "DELETE FROM $logs_table WHERE action_id IN ($ids)" ); $deleted_actions = $wpdb->query( "DELETE FROM $actions_table WHERE action_id IN ($ids)" ); } } add_action( 'action_scheduler_run_queue', 'clear_woocommerce_scheduled_actions_20200609', 999 );