<?php

namespace Devnet\EBC\Includes;


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


class Uninstaller
{

    /**	
     * @since    1.0.0
     */
    public static function cleanup()
    {
        $options = get_option('devnet_ebc_general');

        $delete_plugin_data = $options['delete_plugin_data'] ?? false;

        if ($delete_plugin_data) {

            $all_plugins = get_plugins();

            $ebc_slug = 'easy-booking-calendar';

            $ebc_plugin = [$ebc_slug . '/' . $ebc_slug . '.php', $ebc_slug . '-pro/' . $ebc_slug . '.php',];

            // Ensure no data has ben deleted if both plugins are installed.
            if (!isset($all_plugins[$ebc_plugin[0]], $all_plugins[$ebc_plugin[1]])) {

                self::delete_options();
            }
        }
    }

    /**	
     * @since    1.0.0
     */
    public static function delete_options()
    {
        delete_option('devnet_ebc_general');
        delete_option('devnet_ebc_calendar');
        delete_option('devnet_ebc_product');
    }
}
