settings = new Settings(); $this->state = new State(); $this->transport = new Transport( $this->settings ); $this->engine = new Sync_Engine( $this->settings, $this->transport, $this->state ); $this->admin = new Admin( $this->settings, $this->state, $this->engine ); $this->rest = new REST_Controller( $this->settings, $this->engine ); $this->cron = new Cron( $this->settings ); $this->register_hooks(); } /** * Returns the singleton instance of the Plugin class. * * @return self */ public static function instance(): self { if ( ! self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Registers hooks for admin, REST controller, cron, and sync engine. * * @return void */ public function register_hooks(): void { $this->admin->hooks(); $this->rest->hooks(); $this->cron->hooks(); $this->engine->hooks(); } /** * Handles plugin activation tasks such as setting defaults and configuring cron. * * @return void */ public static function activate(): void { $settings = new Settings(); $settings->ensure_defaults(); Cron::configure( true, $settings->get( 'sync_interval' ) ); } /** * Handles plugin deactivation tasks such as clearing scheduled cron events. * * @return void */ public static function deactivate(): void { Cron::clear_event(); } }