PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.9.2
Independent Analytics – WordPress Analytics Plugin v2.9.2
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / IAWP / Tables / Columns / Column.php
independent-analytics / IAWP / Tables / Columns Last commit date
Column.php 1 year ago
Column.php
153 lines
1 <?php
2
3 namespace IAWP\Tables\Columns;
4
5 use IAWP\Plugin_Group_Option;
6 use IAWP\Tables\Groups\Group;
7 /** @internal */
8 class Column implements Plugin_Group_Option
9 {
10 private $id;
11 private $name;
12 private $plugin_group;
13 private $plugin_group_header;
14 private $visible;
15 private $type;
16 private $exportable;
17 private $options;
18 private $filter_placeholder;
19 private $unavailable_for;
20 private $database_column;
21 private $is_nullable;
22 private $is_plugin_active;
23 private $requires_pro;
24 public function __construct($attributes)
25 {
26 $this->id = $attributes['id'];
27 $this->name = $attributes['name'];
28 $this->plugin_group = $attributes['plugin_group'] ?? 'general';
29 $this->plugin_group_header = $attributes['plugin_group_header'] ?? null;
30 $this->visible = $attributes['visible'] ?? \false;
31 $this->type = $attributes['type'];
32 $this->exportable = $attributes['exportable'] ?? \true;
33 $this->options = $attributes['options'] ?? [];
34 $this->filter_placeholder = $attributes['filter_placeholder'] ?? '';
35 $this->unavailable_for = $attributes['unavailable_for'] ?? [];
36 $this->database_column = $attributes['database_column'] ?? null;
37 $this->is_nullable = $attributes['is_nullable'] ?? \false;
38 $this->is_plugin_active = $attributes['is_subgroup_plugin_active'] ?? \true;
39 $this->requires_pro = $attributes['requires_pro'] ?? \false;
40 }
41 public function is_enabled() : bool
42 {
43 if ($this->requires_pro === \true && \IAWPSCOPED\iawp_is_free()) {
44 return \false;
45 }
46 return \true;
47 }
48 public function is_enabled_for_group(Group $group) : bool
49 {
50 return !\in_array($group->id(), $this->unavailable_for);
51 }
52 public function is_group_dependent() : bool
53 {
54 return \count($this->unavailable_for) > 0;
55 }
56 public function id() : string
57 {
58 return $this->id;
59 }
60 public function name() : string
61 {
62 return $this->name;
63 }
64 public function plugin_group() : string
65 {
66 return $this->plugin_group;
67 }
68 public function database_column() : string
69 {
70 return !\is_null($this->database_column) ? $this->database_column : $this->id;
71 }
72 public function is_group_plugin_enabled() : bool
73 {
74 switch ($this->plugin_group) {
75 case "ecommerce":
76 return \IAWPSCOPED\iawp()->is_ecommerce_support_enabled();
77 case "forms":
78 return \IAWPSCOPED\iawp()->is_form_submission_support_enabled();
79 default:
80 return \true;
81 }
82 }
83 public function is_subgroup_plugin_enabled() : bool
84 {
85 return $this->is_plugin_active;
86 }
87 public function is_visible() : bool
88 {
89 return $this->visible;
90 }
91 public function is_member_of_plugin_group(string $plugin_group) : bool
92 {
93 return $this->plugin_group === $plugin_group;
94 }
95 public function plugin_group_header() : ?string
96 {
97 return $this->plugin_group_header;
98 }
99 public function type() : string
100 {
101 return $this->type;
102 }
103 /**
104 * @return string[]
105 */
106 public function filter_operators() : array
107 {
108 switch ($this->type) {
109 case 'string':
110 return ['contains', 'exact'];
111 case 'date':
112 return ['before', 'after', 'on'];
113 case 'select':
114 return ['is', 'isnt'];
115 default:
116 // int
117 return ['greater', 'lesser', 'equal'];
118 }
119 }
120 public function is_valid_filter_operator(string $operator) : bool
121 {
122 return \in_array($operator, $this->filter_operators());
123 }
124 public function sort_direction() : string
125 {
126 $descending_types = ['int', 'date'];
127 return \in_array($this->type, $descending_types) ? 'desc' : 'asc';
128 }
129 public function set_visibility(bool $visible) : void
130 {
131 $this->visible = $visible;
132 }
133 public function exportable() : bool
134 {
135 return $this->exportable;
136 }
137 /**
138 * @return array List of possible options for this filter such as a list of authors or list of post categories
139 */
140 public function options() : array
141 {
142 return $this->options;
143 }
144 public function filter_placeholder() : string
145 {
146 return $this->filter_placeholder;
147 }
148 public function is_nullable() : bool
149 {
150 return $this->is_nullable;
151 }
152 }
153