<?php

namespace Waypoint\Agent;

use Waypoint\Agent\Acf\Loader;
use Waypoint\Agent\Admin\Settings;
use Waypoint\Agent\Admin\Settings_Page;
use Waypoint\Agent\Base\Thing;
use Waypoint\Agent\Cli\Rotate_Key;
use Waypoint\Agent\Compat\Wpo_Bypass;
use Waypoint\Agent\Integrations\Rank_Math;
use Waypoint\Agent\Monitor\Registration;
use Waypoint\Agent\Rest\Router;
use Waypoint\Agent\Setup\Default_Content;
use Waypoint\Agent\Setup\Disable_Comments;

class Plugin extends Thing {

	public function attach_hooks(): void {
		// Always-on: core plugin infrastructure.
		$things = [
			new Wpo_Bypass(),
			new Registration(),
			new Router(),
			new Loader(),
			new Settings_Page(),
		];

		// Optional: gated by settings (default all on).
		if ( Settings::get( 'disable_comments' ) ) {
			$things[] = new Disable_Comments();
		}
		if ( Settings::get( 'default_content_cleanup' ) ) {
			$things[] = new Default_Content();
		}
		if ( Settings::get( 'rank_math' ) ) {
			$things[] = new Rank_Math();
		}

		if ( defined( 'WP_CLI' ) && WP_CLI ) {
			$things[] = new Rotate_Key();
		}

		foreach ( $things as $thing ) {
			$thing->attach_hooks();
		}
	}
}
