<?php

namespace ProudNerds;

use ProudNerds\Core\Capabilities;
use ProudNerds\Helpers\Cli;
use ProudNerds\Package\EnvironmentSwitcher;
use Roots\WPConfig\Config;

class Theme
{
    use Trait\Singleton;

    private function __construct()
    {
        // Initialize the environment switcher package
        EnvironmentSwitcher::init();

        // Restrict access to certain functionality when in production
        Capabilities::init();

        // Timber initialization
        Core\TimberLoader::init();

        // Register navigation menu locations for the theme
        Admin\Menus::init();

        // Remove comment functionality
        Admin\Comments::init();

        // Add favicon to the admin area
        Admin\Favicon::init();

        // Add custom help tabs
        Admin\HelpTabs::init();

        // Remove admin menu items
        Admin\AdminMenu::init();

        // Remove block styles
        Block\Styles::init();

        // Load cleaner functionality
        Core\Cleaner::init();

        // Component functions
        Components\ComponentSettings::init();

        // Force these plugins to activate
        Plugins\Activator::activate([
            'advanced-custom-fields-pro/acf.php',
            'wordpress-seo/wp-seo.php',
            'pn-login-screen/pn-login-screen.php',
        ]);

        // Plugin specific functionality
        Plugins\ACF::init();
        Plugins\Yoast::init();
        Plugins\NelioABTesting::init();

        // Local plugin specific functionality
        Plugins\LocalACF::init();
        Plugins\LocalTimber::init();
        Plugins\Timmy::init();

        // Load helper functionality
        Helpers\TwigExtension::init();

        // Load Gutenberg functionality
        if (Config::get('USE_GUTENBERG')) {
            Block\Theme::init();
        }

        // Load theme components
        Components\Theme::init();

        // Theme functionality
        Core\Theme::init();

        // Custom post types
        PostTypes\Example::init();

        if (Cli::isWpCli()) {
            // Initialize the block installer
            Block\Installer::init();

            // CLI commands to install blocks
            Components\ComponentCliCommands::init();
        }

        // Helpers for block
        Helpers\BlockHooks::init();

        // Load Vite assets
        Assets\Vite::init();

        // Add common hooks
        Common\Filters::init();
        Common\Actions::init();

        // Block login on different environments
        Admin\Login::init();

        // Enable image optimization
        Assets\ImageOptimizer::init();
    }
}
