Skip to content

Commit

Permalink
Delete and deactivate Woo Webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
NickGreen committed Apr 8, 2024
1 parent 41d25c5 commit 97a6b73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions includes/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ function delete_users_and_orders() {
$wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_api_keys" );
}

// Delete Woo webhooks
$table_name = $wpdb->prefix . 'wc_webhooks';
if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) === $table_name ) {
$wpdb->query( "DELETE FROM {$wpdb->prefix}wc_webhooks" );
}

// Delete renewal scheduled actions
$table_name = $wpdb->prefix . 'actionscheduler_logs'; // check if table exists before purging
if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) === $table_name ) {
Expand Down
13 changes: 13 additions & 0 deletions includes/scrub-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,18 @@ function( $v ) use ( $modules_to_disable ) {
}
}

// Disable all Woo Webhooks
if ( class_exists( 'WooCommerce' ) ) {
$webhooks = wc_get_webhooks( array( 'status' => 'active' ) );

if ( ! empty( $webhooks ) ) {
foreach ( $webhooks as $webhook_id ) {
$webhook = new WC_Webhook( $webhook_id );
$webhook->set_status( 'disabled' );
$webhook->save();
}
}
}

update_option( 'safety_net_options_scrubbed', true );
}

0 comments on commit 97a6b73

Please sign in to comment.