<?php

namespace LinkFiliate\Core;

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

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

/**
 * This class is responsible for the functionality after uninstall plugin
 */
class Uninstall
{
	/**
	 * Entry point for uninstall
	 *
	 * @return void
	 */
	public static function run()
	{
		self::uninstall_tables();
		self::remove_data();
	}

	/**
	 * Uninstall custom tables
	 *
	 * @return void
	 */
	private static function uninstall_tables()
	{
		global $wpdb;

		$allowed = [
			$wpdb->prefix . 'linkfiliate_campaigns',
			$wpdb->prefix . 'linkfiliate_categories',
			$wpdb->prefix . 'linkfiliate_settings',
			$wpdb->prefix . 'linkfiliate_integrations',
			$wpdb->prefix . 'linkfiliate_clicks',

		];

		foreach ($allowed as $table_name) {
			$wpdb->query($wpdb->prepare("DROP TABLE IF EXISTS %i", $table_name));
		}
	}

	/**
	 * Delete Data From options
	 *
	 * @return void
	 */
	private static function remove_data()
	{
		// delete_option('');

	}
}
