# contact-forms/trunk/uninstall.php

Contact Forms by Cimatti, version trunk. 77 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/trunk/code/uninstall.php
- Raw: https://pluginprobe.com/plugins/contact-forms/trunk/raw/uninstall.php
- Modified: 2026-08-21T08:39:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/trunk/code/uninstall.php#L10-L20`.

```php
<?php
/**
 * Runs when the administrator deletes Contact Forms from the Plugins screen.
 *
 * It removes the plugin's data ONLY if the administrator asked for it in
 * Settings → Danger Zone. The default is to keep everything: deleting a plugin
 * is often a step in reinstalling or troubleshooting it, and years of
 * submissions must not disappear because of it. Without the opt-in this file
 * does nothing at all.
 *
 * WordPress includes this file with the plugin NOT loaded - no constants, no
 * classes, none of its functions exist - so everything needed is required here
 * explicitly. includes/data-deletion.php is written for exactly that: it
 * defines functions and registers no hooks.
 *
 * @since 2.3.0
 * @package Contact Forms by Cimatti
 */

// Refuse to run outside the uninstall routine WordPress calls this file from.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
  exit;
}

require_once __DIR__ . '/includes/data-deletion.php';

/**
 * Delete the data of the current site, if that site opted in.
 *
 * The preference, the options and the submission tables are all per-site, so on
 * a network each site answers for itself: one blog opting in never empties
 * another.
 *
 * @since 2.3.0
 */
function accua_forms_uninstall_current_site() {
  if ( ! accua_forms_delete_data_on_uninstall() ) {
    return;
  }

  _accua_forms_delete_all_plugin_data();

  // That routine ends by setting a short-lived flag which stops the schema
  // being recreated during the deactivation redirect. There is no next request
  // for this plugin here, so the flag would just be the one row left behind.
  delete_transient( '_accua_forms_data_deleted' );
}

if ( ! is_multisite() ) {
  accua_forms_uninstall_current_site();
  return;
}

// On a network, walk every site in batches rather than loading the whole list:
// get_sites() with no limit would hold every site of a large network in memory
// at once, and this runs during a single admin request.
$accua_forms_offset = 0;
$accua_forms_batch  = 100;

do {
  $accua_forms_site_ids = get_sites( array(
    'fields'     => 'ids',
    'number'     => $accua_forms_batch,
    'offset'     => $accua_forms_offset,
    'orderby'    => 'id',
    'network_id' => 0,
  ) );

  foreach ( $accua_forms_site_ids as $accua_forms_site_id ) {
    switch_to_blog( $accua_forms_site_id );
    accua_forms_uninstall_current_site();
    restore_current_blog();
  }

  $accua_forms_offset += $accua_forms_batch;
} while ( count( $accua_forms_site_ids ) === $accua_forms_batch );

```
