register_options(); $this->register_retry(); $this->register_schedulers(); $this->register_ondemand_jobs(); $this->register_cli(); $this->register_webhooks(); $this->register_rest_api(); $this->register_admin(); } private function register_options(): void { update_option( 'market_sync_saas_base_url', MARKET_SYNC_SAAS_BASE_URL, false ); update_option( 'market_sync_plugin_client_key', MARKET_SYNC_PLUGIN_CLIENT_KEY, false ); try { Cron\Catalog_Export_State::ensure_initialized(); } catch ( \Throwable $exception ) { Logging\Log_Helper::by_area( Logging\Log_Helper::LOG_CATALOG_EXPORT )->error( 'Catalog export lifecycle could not be initialized.', [ 'reason' => $exception->getMessage() ] ); } } private function register_retry(): void { Retry\Retry_Manager::get_instance()->register_hooks(); } private function register_schedulers(): void { $scheduler = new Scheduler(); $scheduler->register_hooks(); $scheduler->register_schedules(); } private function register_ondemand_jobs(): void { Orders\Order_Import_Job::register_hooks(); } private function register_cli(): void { if ( ! defined( 'WP_CLI' ) || ! constant( 'WP_CLI' ) ) { return; } require_once MARKET_SYNC_PLUGIN_DIR . 'includes/cli/class-catalog-command.php'; require_once MARKET_SYNC_PLUGIN_DIR . 'includes/cli/class-orders-command.php'; WP_CLI::add_command( 'market-sync catalog', CLI\Catalog_Command::class ); WP_CLI::add_command( 'market-sync orders', CLI\Orders_Command::class ); } private function register_webhooks(): void { $manager = new Webhooks\Webhook_Manager( new Webhooks\Webhook_Sender( Authenticator::get_instance() ), new Webhooks\Webhook_Topic_Registry() ); $manager->register_hooks(); } private function register_rest_api(): void { $api = new Rest\Admin_API( Authenticator::get_instance() ); $api->register_hooks(); } private function register_admin(): void { if ( ! is_admin() ) { return; } // No handshake is started here. Contacting the SaaS requires an explicit // user action (the Connect button), per WordPress.org guideline 7. require_once MARKET_SYNC_PLUGIN_DIR . 'includes/admin/class-settings-page.php'; new Admin\Settings_Page(); } }