<?php

declare(strict_types=1);

namespace SecurWP\Modules\Multisite;

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

use SecurWP\Includes\Interfaces\Module;
use SecurWP\Includes\Module_Loader;

class Multisite implements Module {
    private string $plugin_name;
    private string $version;

    public function __construct( string $plugin_name, string $version ) {
        $this->plugin_name = $plugin_name;
        $this->version     = $version;
    }

    public function initialize( Module_Loader $loader ): void {
        if ( ! is_multisite() ) return;

        $api = new MultisiteApi();
        $loader->add_action( 'rest_api_init', $api, 'register_routes' );
        $loader->add_action( 'network_admin_menu', $this, 'add_network_menu' );
    }

    public function add_network_menu(): void {
        add_menu_page(
            'SecurWP Network',
            'SecurWP',
            'manage_network_options',
            'securwp-network',
            [ $this, 'render_network_page' ],
            'dashicons-shield-alt',
            6
        );
    }

    public function render_network_page(): void {
        echo '<div class="wrap"><div id="securwp-admin-app"></div></div>';
    }
}
