<?php

declare(strict_types=1);

namespace SiteFort\Modules\Multisite;

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

use SiteFort\Includes\Interfaces\Module;
use SiteFort\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(
            'SiteFort Network',
            'SiteFort',
            'manage_network_options',
            'sitefort-network',
            [ $this, 'render_network_page' ],
            'dashicons-shield-alt',
            81
        );
    }

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