user_options = $user_options; $this->analytics = $analytics; $transients = new Transients( $context ); $new_badge_events_sync = new Conversion_Reporting_New_Badge_Events_Sync( $transients ); $this->events_sync = new Conversion_Reporting_Events_Sync( $settings, $transients, $this->analytics, $new_badge_events_sync ); $this->cron = new Conversion_Reporting_Cron( fn() => $this->cron_callback() ); } /** * Registers functionality through WordPress hooks. * * @since 1.135.0 */ public function register() { $this->cron->register(); add_action( 'load-toplevel_page_googlesitekit-dashboard', fn () => $this->on_dashboard_load() ); } /** * Handles the googlesitekit-dashboard page load callback. * * @since 1.135.0 */ protected function on_dashboard_load() { $this->cron->maybe_schedule_cron(); } /** * Handles the cron callback. * * @since 1.135.0 */ protected function cron_callback() { $owner_id = $this->analytics->get_owner_id(); $restore_user = $this->user_options->switch_user( $owner_id ); $this->events_sync->sync_detected_events(); $restore_user(); } }