HEX
Server: LiteSpeed
System: Linux starfruit.7ho.st 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64
User: edtir (1699)
PHP: 7.4.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/edtir/public_html/nabilico.ir/wp-content/plugins/wp-network-guard/includes/Installer.php
<?php
namespace WNG;

defined('ABSPATH') || exit;

final class Installer {

    public static function activate(): void {
        // Ensure Settings class is available during activation.
        if (!class_exists('WNG\\Core\\Settings')) {
            require_once WNG_DIR . 'includes/Core/Settings.php';
        }

        self::create_tables();

        if (!wp_next_scheduled('wng_outbox_worker_tick')) {
            wp_schedule_event(time() + 120, 'wng_minute', 'wng_outbox_worker_tick');
        }

        if (!get_option(\WNG\Core\Settings::OPTION_KEY)) {
            update_option(\WNG\Core\Settings::OPTION_KEY, \WNG\Core\Settings::defaults(), false);
        }
    }

    public static function deactivate(): void {
        $ts = wp_next_scheduled('wng_outbox_worker_tick');
        if ($ts) {
            wp_unschedule_event($ts, 'wng_outbox_worker_tick');
        }

        // If Action Scheduler is present, try to unschedule our hook.
        if (function_exists('as_unschedule_all_actions')) {
            as_unschedule_all_actions('wng_as_outbox_tick', [], 'wng');
        }
    }

    private static function create_tables(): void {
        global $wpdb;
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';

        $table = $wpdb->prefix . 'wng_outbox';
        $charset = $wpdb->get_charset_collate();

        $sql = "CREATE TABLE {$table} (
            id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
            type VARCHAR(50) NOT NULL,
            method VARCHAR(10) NOT NULL DEFAULT 'GET',
            url TEXT NOT NULL,
            headers LONGTEXT NULL,
            body LONGTEXT NULL,
            args LONGTEXT NULL,
            status VARCHAR(20) NOT NULL DEFAULT 'pending',
            attempts INT UNSIGNED NOT NULL DEFAULT 0,
            available_at DATETIME NOT NULL,
            last_error TEXT NULL,
            created_at DATETIME NOT NULL,
            updated_at DATETIME NOT NULL,
            PRIMARY KEY (id),
            KEY status_available (status, available_at)
        ) {$charset};";

        dbDelta($sql);
    }
}