<?php

namespace Devnet\PingVid\Includes;


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


class Uninstaller
{
    public static function cleanup()
    {
        $options = get_option('devnet_pingvid_general');

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

        if ($delete_plugin_data) {

            $all_plugins = get_plugins();

            $plugin_slug = 'pingvid';

            $pph_plugin = [$plugin_slug . '/' . $plugin_slug . '.php', $plugin_slug . '-pro/' . $plugin_slug . '.php',];

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

                self::delete_options();
            }
        }
    }

    public static function delete_options()
    {

        delete_option('devnet_pingvid_general');
        delete_option('devnet_pingvid_display');
    }
}
