PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.12.2
Independent Analytics – WordPress Analytics Plugin v2.12.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 1 year ago
Column.php
159 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 private $aggregatable;
25 public function __construct($attributes)
26 {
27 $this->id = $attributes['id'];
28 $this->name = $attributes['name'];
29 $this->plugin_group = $attributes['plugin_group'] ?? 'general';
30 $this->plugin_group_header = $attributes['plugin_group_header'] ?? null;
31 $this->visible = $attributes['visible'] ?? \false;
32 $this->type = $attributes['type'];
33 $this->exportable = $attributes['exportable'] ?? \true;
34 $this->options = $attributes['options'] ?? [];
35 $this->filter_placeholder = $attributes['filter_placeholder'] ?? '';
36 $this->unavailable_for = $attributes['unavailable_for'] ?? [];
37 $this->database_column = $attributes['database_column'] ?? null;
38 $this->is_nullable = $attributes['is_nullable'] ?? \false;
39 $this->is_plugin_active = $attributes['is_subgroup_plugin_active'] ?? \true;
40 $this->requires_pro = $attributes['requires_pro'] ?? \false;
41 $this->aggregatable = $attributes['aggregatable'] ?? \false;
42 }
43 public function is_enabled() : bool
44 {
45 if ($this->requires_pro === \true && \IAWPSCOPED\iawp_is_free()) {
46 return \false;
47 }
48 return \true;
49 }
50 public function aggregatable() : bool
51 {
52 return $this->aggregatable;
53 }
54 public function is_enabled_for_group(Group $group) : bool
55 {
56 return !\in_array($group->id(), $this->unavailable_for);
57 }
58 public function is_group_dependent() : bool
59 {
60 return \count($this->unavailable_for) > 0;
61 }
62 public function id() : string
63 {
64 return $this->id;
65 }
66 public function name() : string
67 {
68 return $this->name;
69 }
70 public function plugin_group() : string
71 {
72 return $this->plugin_group;
73 }
74 public function database_column() : string
75 {
76 return !\is_null($this->database_column) ? $this->database_column : $this->id;
77 }
78 public function is_group_plugin_enabled() : bool
79 {
80 switch ($this->plugin_group) {
81 case "ecommerce":
82 return \IAWPSCOPED\iawp()->is_ecommerce_support_enabled();
83 case "forms":
84 return \IAWPSCOPED\iawp()->is_form_submission_support_enabled();
85 default:
86 return \true;
87 }
88 }
89 public function is_subgroup_plugin_enabled() : bool
90 {
91 return $this->is_plugin_active;
92 }
93 public function is_visible() : bool
94 {
95 return $this->visible;
96 }
97 public function is_member_of_plugin_group(string $plugin_group) : bool
98 {
99 return $this->plugin_group === $plugin_group;
100 }
101 public function plugin_group_header() : ?string
102 {
103 return $this->plugin_group_header;
104 }
105 public function type() : string
106 {
107 return $this->type;
108 }
109 /**
110 * @return string[]
111 */
112 public function filter_operators() : array
113 {
114 switch ($this->type) {
115 case 'string':
116 return ['contains', 'exact'];
117 case 'date':
118 return ['before', 'after', 'on'];
119 case 'select':
120 return ['is', 'isnt'];
121 default:
122 // int
123 return ['greater', 'lesser', 'equal'];
124 }
125 }
126 public function is_valid_filter_operator(string $operator) : bool
127 {
128 return \in_array($operator, $this->filter_operators());
129 }
130 public function sort_direction() : string
131 {
132 $descending_types = ['int', 'date'];
133 return \in_array($this->type, $descending_types) ? 'desc' : 'asc';
134 }
135 public function set_visibility(bool $visible) : void
136 {
137 $this->visible = $visible;
138 }
139 public function exportable() : bool
140 {
141 return $this->exportable;
142 }
143 /**
144 * @return array List of possible options for this filter such as a list of authors or list of post categories
145 */
146 public function options() : array
147 {
148 return $this->options;
149 }
150 public function filter_placeholder() : string
151 {
152 return $this->filter_placeholder;
153 }
154 public function is_nullable() : bool
155 {
156 return $this->is_nullable;
157 }
158 }
159