providers = array_merge( array( new Event_Tickets_Provider( $sync_service ), new WooCommerce_Provider( $sync_service ), ), $form_sources ); foreach ( $this->providers as $provider ) { if ( $provider->is_available() ) { $provider->register_hooks(); } } add_action( self::retry_cron_hook(), array( $this, 'process_retry_queue' ) ); if ( Retry_Queue::using_action_scheduler() ) { add_action( Retry_Queue::AS_HOOK, array( $this, 'process_retry_queue_row' ) ); } if ( is_admin() ) { new Admin_Page( $this->providers ); Forms_Page::register(); Other_Forms_Page::register( $form_sources ); add_action( 'wp_dashboard_setup', array( Dashboard_Widget::class, 'register' ) ); } } public static function retry_cron_hook() { return Retry_Queue::CRON_HOOK; } public function process_retry_queue() { Retry_Queue::process_due( new Sync_Service( Api_Client::from_settings() ) ); } public function process_retry_queue_row( $row_id ) { Retry_Queue::process_row( $row_id, new Sync_Service( Api_Client::from_settings() ) ); } /** @return Integration_Provider_Interface[] */ public function get_providers() { return $this->providers; } /** * Runs once on activation. Creates this plugin's own tables (never * touches WordPress core tables or another plugin's data) and * schedules the retry-queue cron. Capability-gated by WordPress itself * (register_activation_hook only ever fires for a user who already * has activate_plugins). */ public static function activate() { Logger::create_table(); Retry_Queue::create_table(); Retry_Queue::schedule_cron(); } /** * Deactivation only stops the retry-queue cron - settings, logs, and * queued retries are preserved, so re-activating resumes cleanly. * Data is only removed on uninstall (see uninstall.php), a separate, * more deliberate action. */ public static function deactivate() { Retry_Queue::unschedule_cron(); } }