PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.14.2
Independent Analytics – WordPress Analytics Plugin v2.14.2
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 6 months ago
Column.php
175 lines
1 <?php
2
3 namespace IAWP\Tables\Columns;
4
5 use IAWP\ColumnOptions\Options;
6 use IAWP\Plugin_Group_Option;
7 use IAWP\Tables\Groups\Group;
8 /** @internal */
9 class Column implements Plugin_Group_Option
10 {
11 private $id;
12 private $name;
13 private $plugin_group;
14 private $plugin_group_header;
15 private $visible;
16 private $can_be_filtered;
17 private $type;
18 private $exportable;
19 private ?Options $options;
20 private $filter_placeholder;
21 private $unavailable_for;
22 private $separate_database_column;
23 private $separate_filter_column;
24 private $is_nullable;
25 private $is_plugin_active;
26 private $requires_pro;
27 private $aggregatable;
28 private $is_concrete_column;
29 public function __construct($attributes)
30 {
31 $this->id = $attributes['id'];
32 $this->name = $attributes['name'];
33 $this->plugin_group = $attributes['plugin_group'] ?? 'general';
34 $this->plugin_group_header = $attributes['plugin_group_header'] ?? null;
35 $this->visible = $attributes['visible'] ?? \false;
36 $this->can_be_filtered = $attributes['can_be_filtered'] ?? \true;
37 $this->type = $attributes['type'];
38 $this->exportable = $attributes['exportable'] ?? \true;
39 $this->options = $attributes['options'] ?? null;
40 $this->filter_placeholder = $attributes['filter_placeholder'] ?? '';
41 $this->unavailable_for = $attributes['unavailable_for'] ?? [];
42 $this->separate_database_column = $attributes['separate_database_column'] ?? null;
43 $this->separate_filter_column = $attributes['separate_filter_column'] ?? null;
44 $this->is_nullable = $attributes['is_nullable'] ?? \false;
45 $this->is_plugin_active = $attributes['is_subgroup_plugin_active'] ?? \true;
46 $this->requires_pro = $attributes['requires_pro'] ?? \false;
47 $this->aggregatable = $attributes['aggregatable'] ?? \false;
48 $this->is_concrete_column = $attributes['is_concrete_column'] ?? \false;
49 }
50 public function is_enabled() : bool
51 {
52 if ($this->requires_pro === \true && \IAWPSCOPED\iawp_is_free()) {
53 return \false;
54 }
55 return \true;
56 }
57 public function aggregatable() : bool
58 {
59 return $this->aggregatable;
60 }
61 public function is_enabled_for_group(Group $group) : bool
62 {
63 return !\in_array($group->id(), $this->unavailable_for);
64 }
65 public function is_group_dependent() : bool
66 {
67 return \count($this->unavailable_for) > 0;
68 }
69 public function id() : string
70 {
71 return $this->id;
72 }
73 public function separate_database_column() : ?string
74 {
75 return $this->separate_database_column;
76 }
77 public function separate_filter_column() : ?string
78 {
79 return $this->separate_filter_column;
80 }
81 public function name() : string
82 {
83 return $this->name;
84 }
85 public function plugin_group() : string
86 {
87 return $this->plugin_group;
88 }
89 public function is_group_plugin_enabled() : bool
90 {
91 switch ($this->plugin_group) {
92 case "ecommerce":
93 return \IAWPSCOPED\iawp()->is_ecommerce_support_enabled();
94 case "forms":
95 return \IAWPSCOPED\iawp()->is_form_submission_support_enabled();
96 default:
97 return \true;
98 }
99 }
100 public function is_subgroup_plugin_enabled() : bool
101 {
102 return $this->is_plugin_active;
103 }
104 public function is_visible() : bool
105 {
106 return $this->visible;
107 }
108 public function can_be_filtered() : bool
109 {
110 return $this->can_be_filtered;
111 }
112 public function is_member_of_plugin_group(string $plugin_group) : bool
113 {
114 return $this->plugin_group === $plugin_group;
115 }
116 public function plugin_group_header() : ?string
117 {
118 return $this->plugin_group_header;
119 }
120 public function type() : string
121 {
122 return $this->type;
123 }
124 /**
125 * @return string[]
126 */
127 public function filter_operators() : array
128 {
129 switch ($this->type) {
130 case 'string':
131 return ['contains', 'exact'];
132 case 'date':
133 return ['before', 'after', 'on'];
134 case 'select':
135 return ['is', 'isnt'];
136 default:
137 // int
138 return ['greater', 'lesser', 'equal'];
139 }
140 }
141 public function is_valid_filter_operator(string $operator) : bool
142 {
143 return \in_array($operator, $this->filter_operators());
144 }
145 public function sort_direction() : string
146 {
147 $descending_types = ['int', 'date'];
148 return \in_array($this->type, $descending_types) ? 'desc' : 'asc';
149 }
150 public function set_visibility(bool $visible) : void
151 {
152 $this->visible = $visible;
153 }
154 public function exportable() : bool
155 {
156 return $this->exportable;
157 }
158 public function options() : ?Options
159 {
160 return $this->options;
161 }
162 public function filter_placeholder() : string
163 {
164 return $this->filter_placeholder;
165 }
166 public function is_nullable() : bool
167 {
168 return $this->is_nullable;
169 }
170 public function is_concrete_column() : bool
171 {
172 return $this->is_concrete_column;
173 }
174 }
175