setUpActiveTests(); $this->filterExternalInsights(); } /** * Returns the active tests for the user, and sets up tests as needed. * * @return void */ public function setUpActiveTests() { // Make sure that the active tests are set. $currentTests = \get_option('extendify_active_tests', []); $newTests = array_map(function ($test) { // Pick from value randomly. return $test[array_rand($test)]; }, array_diff_key($this->activeTests, $currentTests)); $testsCombined = array_merge($currentTests, $newTests); if ($newTests) { \update_option('extendify_active_tests', Sanitizer::sanitizeArray($testsCombined)); } } /** * Add additional data to the opt-in insights * * @return void */ public function filterExternalInsights() { add_filter('extendify_insights_data', function ($data) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents $readme = file_get_contents(EXTENDIFY_PATH . 'readme.txt'); preg_match('/Stable tag: ([0-9.:]+)/', $readme, $version); $insights = array_merge($data, [ 'launch' => defined('EXTENDIFY_SHOW_ONBOARDING') && constant('EXTENDIFY_SHOW_ONBOARDING'), 'launchRedirectedAt' => \get_option('extendify_attempted_redirect', null), 'launchLoadedAt' => \get_option('extendify_launch_loaded', null), 'partner' => defined('EXTENDIFY_PARTNER_ID') ? constant('EXTENDIFY_PARTNER_ID') : null, 'siteCreatedAt' => \get_user_option('user_registered', 1), 'assistRouterData' => \get_option('extendify_assist_router', null), 'libraryData' => \get_option('extendify_library_site_data', null), 'draftSettingsData' => \get_option('extendify_draft_settings', null), 'activity' => \get_option('extendify_shared_activity', null), 'extendifyVersion' => ($version[1] ?? null), ]); return $insights; }); } }