PluginProbe
Extendify / 0.11.1
Extendify v0.11.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / app / Insights.php

Insights.php in Extendify 0.11.1, at app/Insights.php

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Insights setup
4 */
5
6 namespace Extendify;
7
8 /**
9 * Controller for handling various Insights related things.
10 */
11 class Insights
12 {
13
14 /**
15 * An array of active tests. 'A' should be the control.
16 * For weighted tests, try ['A', 'A', 'A', 'A', 'B']
17 *
18 * @var array
19 */
20 protected $activeTests = [
21 'remove-dont-see-inputs' => [
22 'A',
23 'B',
24 ],
25 ];
26
27 /**
28 * Process the readme file to get version and name
29 *
30 * @return void
31 */
32 public function __construct()
33 {
34 $this->setUpActiveTests();
35 }
36
37 /**
38 * Returns the active tests for the user, and sets up tests as needed.
39 *
40 * @return void
41 */
42 public function setUpActiveTests()
43 {
44 // Make sure that the active tests are set.
45 $currentTests = \get_option('extendify_active_tests', []);
46 $newTests = array_map(function ($test) {
47 // Pick from value randomly.
48 return $test[array_rand($test)];
49 }, array_diff_key($this->activeTests, $currentTests));
50 $testsCombined = array_merge($currentTests, $newTests);
51 if ($newTests) {
52 \update_option('extendify_active_tests', $testsCombined);
53 }
54 }
55 }
56