delete( true ); } } } else { $this->delete_rows( $ids ); } delete_option( Options::WEBHOOK_IDS ); } /** * @param array $ids Topic => webhook id. */ protected function delete_rows( array $ids ): void { global $wpdb; foreach ( $ids as $id ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- WooCommerce may not be loaded. $wpdb->delete( $wpdb->prefix . 'wc_webhooks', array( 'webhook_id' => (int) $id ), array( '%d' ) ); wp_cache_delete( (int) $id, 'webhooks' ); } // WooCommerce's cached webhook id lists (WC_Webhook_Data_Store transient keys; verified against the // installed WooCommerce source: get_transient_key() joins 'woocommerce_webhook_ids_status_' with a key // from wc_get_webhook_statuses(), which is active|paused|disabled). foreach ( array( 'woocommerce_webhook_ids', 'woocommerce_webhook_ids_status_active', 'woocommerce_webhook_ids_status_paused', 'woocommerce_webhook_ids_status_disabled' ) as $transient ) { delete_transient( $transient ); } } }