<?php

/**
 * Aviso en la desactivación del plugin.
 * copyright Simple Direct Plugins - support@simpledirectplugins.com
 *
 * @author 			Simple Direct Plugins
 * @link			https://simpledirectplugins.com
 * @since 			3.0.0
 * @package 		SCOSWoo
 *
 */

defined ('ABSPATH') or exit;

if (!class_exists ('SCOS_Deactivation')) :

	Class SCOS_Deactivation {

		public function __construct () {

			add_action ('admin_enqueue_scripts', [$this, 'deactivation_warning'], 10);
			}

		public function deactivation_warning () {

			if (!$screen = get_current_screen())
				return false;

			if ('plugins' !== $screen->id)
				return;

			$texts = [
				'question'	=> esc_html__('Are you sure?', 'sdp-custom-order-status-for-woocommerce'),
				'warning'	=> esc_html__("Deactivating the plugin will cause orders with a status created by it not to appear in the orders list screen (they will be displayed again when the plugin is reactivated).\n\nMake sure there are no orders left in a custom status, and if there are, change them to one of WooCommerce’s default order statuses.", 'sdp-custom-order-status-for-woocommerce'),
				'yes'		=> esc_html__('Deactivate', 'sdp-custom-order-status-for-woocommerce'),
				'no'		=> esc_html__('Keep activated', 'sdp-custom-order-status-for-woocommerce'),
				'success'	=> esc_html__('Deactivating plugin...', 'sdp-custom-order-status-for-woocommerce'),
				'complete'	=> esc_html__('Plugin deactivated, please wait for the page to reload...', 'sdp-custom-order-status-for-woocommerce'),
				];

			wp_enqueue_style ('sweetalert2', SCOS_ASSETS . 'css/sweetalert2.min.css', [], '11.26.24');
			wp_enqueue_script ('sweetalert2', SCOS_ASSETS . 'js/sweetalert2.min.js', [], '11.26.24', true);
			wp_enqueue_script ('scos-deactivation', SCOS_ASSETS . 'js/deactivation.min.js', ['jquery', 'sweetalert2'], '1.2', true);
			wp_localize_script ('scos-deactivation', 'scos_texts', $texts);
			}

		}

endif;