* @link https://www.fireplugins.com * @copyright Copyright © 2022 FirePlugins All Rights Reserved * @license GNU GPLv3 or later */ namespace FireBox\Core\Admin; if (!defined('ABSPATH')) { exit; // Exit if accessed directly. } require_once FBOX_PLUGIN_DIR . '/Inc/Framework/Inc/Admin/Includes/Uninstall.php'; class PluginUninstall extends \Uninstall { /** * Runs once we uninstall the plugin. * * @return void */ public function start() { if (!$settings = get_option('firebox_settings')) { return; } if (isset($settings['keep_data_on_uninstall']) && $settings['keep_data_on_uninstall'] == '1') { return; } // remove all db tables $this->pluginUninstall(); // de-register post type unregister_post_type('firebox'); // remove all custom post types data $items = get_posts(['post_type' => 'firebox', 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids']); if ($items) { foreach ($items as $item) { wp_delete_post($item, true); } } // remove all options delete_option('firebox_version'); delete_option('firebox_settings'); } }