<?php

namespace PWH_DCFH\App\Base;

use PWH_DCFH\App\Admin\Migration\PWH_DCFH_Options_Migration;

if (!defined('ABSPATH')) {
    exit;
}
if (!class_exists('PWH_DCFH_Activate')) {
    class PWH_DCFH_Activate
    {
        /**
         * Process Actions When Plugin Activates
         */
        public static function activate($network_wide)
        {
            PWH_DCFH_Plugin_Requirements_Check::instance()->check();
            if (function_exists('is_multisite') && is_multisite() && $network_wide) {
                $sites = get_sites(); // default count is 100
                foreach ($sites as $site) {
                    switch_to_blog($site->blog_id);
                    self::do_it();
                    restore_current_blog();
                }
            } else {

                self::do_it();
            }
        }

        /**
         * Do IT
         * @return void
         */
        private static function do_it()
        {
            PWH_DCFH_Options_Migration::instance()->add_options();
            pwh_dcfh_file_helpers()::create_dir(path_join('pwh-dcfh-uploads', 'tmp'));
        }
    }
}