<?php
/**
 * Plugin uninstall handler.
 *
 * @package SubmissionInbox
 */

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}

require_once __DIR__ . '/includes/Settings/SettingsRepository.php';
require_once __DIR__ . '/includes/Database.php';
require_once __DIR__ . '/includes/Retention/RetentionService.php';

$subin_settings = get_option( SUBIN_SettingsRepository::OPTION_KEY, array() );

if ( is_array( $subin_settings ) && ! empty( $subin_settings['delete_data_on_uninstall'] ) ) {
	SUBIN_Database::drop_tables();
	delete_option( SUBIN_SettingsRepository::OPTION_KEY );
	delete_option( SUBIN_Database::OPTION_KEY );
}

\SUBIN\Retention\RetentionService::unschedule();
