46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Plugin uninstall handler.
|
|
*
|
|
* WordPress runs this file when the plugin is deleted from the Plugins screen.
|
|
* Data is only deleted when the administrator has explicitly opted in by enabling
|
|
* the "Delete all plugin data on uninstall" option in the plugin settings.
|
|
* By default all data is preserved so that re-activating the plugin restores
|
|
* the previous state without any additional configuration.
|
|
*
|
|
* @package WPVulnerability
|
|
*
|
|
* @since 4.3.4
|
|
*/
|
|
|
|
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
|
|
|
|
// Resolve the opt-in preference.
|
|
$wpvulnerability_config = is_multisite()
|
|
? get_site_option( 'wpvulnerability-config', array() )
|
|
: get_option( 'wpvulnerability-config', array() );
|
|
|
|
$wpvulnerability_delete_on_uninstall = is_array( $wpvulnerability_config ) && ! empty( $wpvulnerability_config['delete_on_uninstall'] );
|
|
|
|
if ( ! $wpvulnerability_delete_on_uninstall ) {
|
|
// User did not opt in — preserve all data (default behaviour).
|
|
return;
|
|
}
|
|
|
|
// User opted in: load the uninstall routine from the main plugin file.
|
|
// The main plugin file is not loaded during uninstall, so the constants that
|
|
// wpvulnerability-run.php references at the top level must be defined here first
|
|
// to avoid a fatal "Undefined constant" error (see wpvulnerability-run.php top-level add_filter).
|
|
if ( ! defined( 'WPVULNERABILITY_PLUGIN_PATH' ) ) {
|
|
define( 'WPVULNERABILITY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
|
}
|
|
if ( ! defined( 'WPVULNERABILITY_PLUGIN_BASE' ) ) {
|
|
define( 'WPVULNERABILITY_PLUGIN_BASE', plugin_basename( WPVULNERABILITY_PLUGIN_PATH . 'wpvulnerability.php' ) );
|
|
}
|
|
|
|
require_once WPVULNERABILITY_PLUGIN_PATH . 'wpvulnerability-run.php';
|
|
require_once WPVULNERABILITY_PLUGIN_PATH . 'wpvulnerability-general.php';
|
|
|
|
if ( function_exists( 'wpvulnerability_uninstall' ) ) {
|
|
wpvulnerability_uninstall();
|
|
}
|