PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / ListScreen.php
codepress-admin-columns / classes Last commit date
Acf 1 day ago Admin 1 day ago Ajax 1 day ago ApplyFilter 1 day ago Asset 1 day ago Capabilities 1 day ago Check 1 day ago Collection 1 day ago Column 1 day ago ColumnFactories 1 day ago ColumnFactory 1 day ago ColumnIterator 1 day ago ColumnRepository 1 day ago ColumnSize 1 day ago DI 1 day ago DefaultColumnHandler 1 day ago Deprecated 1 day ago Entity 1 day ago Exception 1 day ago Expression 1 day ago Form 1 day ago Formatter 1 day ago Helper 1 day ago Integration 1 day ago ListScreenRepository 1 day ago ListTable 1 day ago Message 1 day ago Meta 1 day ago Nonce 1 day ago Notice 1 day ago Plugin 1 day ago Preferences 1 day ago Promo 1 day ago Request 1 day ago RequestHandler 1 day ago Response 1 day ago Sanitize 1 day ago Service 1 day ago Setting 1 day ago Settings 1 day ago Storage 1 day ago Table 1 day ago TableIdsFactory 1 day ago TableScreen 1 day ago TableScreenFactory 1 day ago ThirdParty 1 day ago Type 1 day ago Value 1 day ago View 1 day ago Acf.php 1 day ago AdminColumns.php 1 day ago ArrayIterator.php 1 day ago Capabilities.php 1 day ago Collection.php 1 day ago CollectionFormatter.php 1 day ago Column.php 1 day ago ColumnCollection.php 1 day ago ColumnFactoryCollectionFactory.php 1 day ago ColumnFactoryDefinitionCollection.php 1 day ago ColumnGroups.php 1 day ago ColumnIterator.php 1 day ago ColumnNamesTrait.php 1 day ago ColumnRepository.php 1 day ago ColumnTypeRepository.php 1 day ago Config.php 1 day ago DateFormats.php 1 day ago DefaultColumnHandler.php 1 day ago Expirable.php 1 day ago Formatter.php 1 day ago FormatterCollection.php 1 day ago Helper.php 1 day ago ListScreen.php 1 day ago ListScreenCollection.php 1 day ago ListScreenRepository.php 1 day ago ListScreenRepositoryWritable.php 1 day ago ListTable.php 1 day ago ListTableFactory.php 1 day ago Loader.php 1 day ago Message.php 1 day ago MetaType.php 1 day ago Middleware.php 1 day ago OpCacheInvalidateTrait.php 1 day ago PluginActionLinks.php 1 day ago PluginActionUpgrade.php 1 day ago PostType.php 1 day ago PostTypeRepository.php 1 day ago Registerable.php 1 day ago Registry.php 1 day ago Renderable.php 1 day ago Request.php 1 day ago RequestAjaxHandler.php 1 day ago RequestAjaxHandlers.php 1 day ago RequestAjaxParser.php 1 day ago RequestHandler.php 1 day ago RequestHandlerFactory.php 1 day ago Screen.php 1 day ago Services.php 1 day ago TableIdsFactory.php 1 day ago TableScreen.php 1 day ago TableScreenFactory.php 1 day ago Taxonomy.php 1 day ago Transient.php 1 day ago TypedArrayIterator.php 1 day ago View.php 1 day ago WooCommerce.php 1 day ago WpListTableFactory.php 1 day ago
ListScreen.php
431 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC;
6
7 use AC\Type\ColumnId;
8 use AC\Type\EditorUrlFactory;
9 use AC\Type\ListScreenId;
10 use AC\Type\ListScreenStatus;
11 use AC\Type\TableId;
12 use AC\Type\Uri;
13 use ACP\ConditionalFormat\RulesCollection;
14 use ACP\Search\SegmentCollection;
15 use DateTime;
16 use WP_User;
17
18 final class ListScreen
19 {
20 private ListScreenId $id;
21
22 private string $title;
23
24 private TableScreen $table_screen;
25
26 private ColumnIterator $columns;
27
28 private array $preferences;
29
30 private DateTime $updated;
31
32 private bool $read_only = false;
33
34 private ListScreenStatus $status;
35
36 private ?SegmentCollection $segments;
37
38 private ?RulesCollection $conditional_format;
39
40 public function __construct(
41 ListScreenId $id,
42 string $title,
43 TableScreen $table_screen,
44 ?ColumnIterator $columns = null,
45 array $preferences = [],
46 ?ListScreenStatus $status = null,
47 ?DateTime $updated = null,
48 ?SegmentCollection $segments = null,
49 ?RulesCollection $conditional_format = null
50 ) {
51 $this->id = $id;
52 $this->title = $title;
53 $this->table_screen = $table_screen;
54 $this->columns = $columns ?? new ColumnCollection();
55 $this->preferences = $preferences;
56 $this->status = $status ?? new ListScreenStatus();
57 $this->updated = $updated ?? new DateTime();
58 $this->segments = $segments;
59 $this->conditional_format = $conditional_format;
60 }
61
62 public function get_id(): ListScreenId
63 {
64 return $this->id;
65 }
66
67 public function set_id(ListScreenId $id): void
68 {
69 $this->id = $id;
70 }
71
72 public function set_title(string $title): void
73 {
74 $this->title = $title;
75 }
76
77 public function set_table_screen(TableScreen $table_screen): void
78 {
79 $this->table_screen = $table_screen;
80 }
81
82 public function get_title(): string
83 {
84 return $this->title;
85 }
86
87 public function get_column(ColumnId $id): ?Column
88 {
89 foreach ($this->columns as $column) {
90 if ($column->get_id()->equals($id)) {
91 return $column;
92 }
93 }
94
95 return null;
96 }
97
98 public function get_columns(): ColumnIterator
99 {
100 return $this->columns;
101 }
102
103 public function set_columns(ColumnCollection $columns): void
104 {
105 $this->columns = $columns;
106 }
107
108 public function get_preferences(): array
109 {
110 return $this->preferences;
111 }
112
113 public function set_segments(SegmentCollection $segments): void
114 {
115 $this->segments = $segments;
116 }
117
118 public function get_segments(): SegmentCollection
119 {
120 if (! $this->segments) {
121 $this->segments = new SegmentCollection();
122 }
123
124 return $this->segments;
125 }
126
127 public function set_conditional_format(RulesCollection $rules_collection): void
128 {
129 $this->conditional_format = $rules_collection;
130 }
131
132 public function get_conditional_format(): RulesCollection
133 {
134 if (! $this->conditional_format) {
135 $this->conditional_format = new RulesCollection();
136 }
137
138 return $this->conditional_format;
139 }
140
141 public function get_updated(): DateTime
142 {
143 return $this->updated;
144 }
145
146 public function is_read_only(): bool
147 {
148 return $this->read_only;
149 }
150
151 public function set_read_only(bool $read_only): void
152 {
153 $this->read_only = $read_only;
154 }
155
156 public function get_table_id(): TableId
157 {
158 return $this->table_screen->get_id();
159 }
160
161 public function get_label(): ?string
162 {
163 return $this->table_screen->get_labels()->get_plural();
164 }
165
166 public function get_meta_type(): string
167 {
168 return $this->table_screen instanceof TableScreen\MetaType
169 ? (string)$this->table_screen->get_meta_type()
170 : '';
171 }
172
173 public function get_screen_id(): string
174 {
175 return $this->table_screen->get_screen_id();
176 }
177
178 public function get_post_type(): ?string
179 {
180 return $this->table_screen instanceof PostType
181 ? (string)$this->table_screen->get_post_type()
182 : null;
183 }
184
185 public function get_table_screen(): TableScreen
186 {
187 return $this->table_screen;
188 }
189
190 public function get_table_url(): Uri
191 {
192 return $this->table_screen
193 ->get_url()
194 ->with_arg('layout', (string)$this->id);
195 }
196
197 public function get_editor_url(): Uri
198 {
199 return EditorUrlFactory::create(
200 $this->get_table_id(),
201 $this->table_screen->is_network(),
202 $this->id
203 );
204 }
205
206 public function is_user_allowed(WP_User $user): bool
207 {
208 return user_can($user, Capabilities::MANAGE) || $this->is_user_assigned($user);
209 }
210
211 public function is_user_assigned(WP_User $user): bool
212 {
213 $user_ids = $this->get_preference('users');
214 $roles = $this->get_preference('roles');
215
216 $user_ids = is_array($user_ids)
217 ? array_filter(array_map('intval', $user_ids))
218 : [];
219
220 $roles = is_array($roles)
221 ? array_filter(array_map('strval', $roles))
222 : [];
223
224 if (! $user_ids && ! $roles) {
225 return true;
226 }
227
228 foreach ($roles as $role) {
229 if ($user->has_cap($role)) {
230 return true;
231 }
232 }
233
234 return in_array($user->ID, $user_ids, true);
235 }
236
237 public function set_preferences(array $preferences): void
238 {
239 $this->preferences = $preferences;
240 }
241
242 public function get_preference(string $key)
243 {
244 return $this->preferences[$key] ?? null;
245 }
246
247 public function set_preference(string $key, $value): void
248 {
249 $this->preferences[$key] = $value;
250 }
251
252 public function get_status(): ListScreenStatus
253 {
254 return $this->status;
255 }
256
257 public function set_status(ListScreenStatus $status): void
258 {
259 $this->status = $status;
260 }
261
262 /**
263 * @deprecated 7.0
264 */
265 public function get_singular_label(): string
266 {
267 _deprecated_function(__METHOD__, '7.0', 'AC\ListScreen::get_table()->get_labels->get_singular()');
268
269 return $this->table_screen->get_labels()->get_singular();
270 }
271
272 /**
273 * @deprecated 7.0
274 */
275 public function get_layout_id(): string
276 {
277 _deprecated_function(__METHOD__, '7.0', 'AC\ListScreen::get_id()');
278
279 return (string)$this->id;
280 }
281
282 /**
283 * @deprecated 7.0
284 */
285 public function get_column_by_name(string $name): ?Column
286 {
287 _deprecated_function(__METHOD__, '7.0', 'AC\ListScreen::get_column()');
288
289 return $this->get_column(new ColumnId($name));
290 }
291
292 /**
293 * @deprecated 7.0
294 */
295 public function get_screen_link(): string
296 {
297 _deprecated_function(__METHOD__, '4.6.5', 'AC\ListScreen::get_table_url()');
298
299 return (string)$this->get_table_url();
300 }
301
302 /**
303 * @deprecated 7.0
304 */
305 public function get_edit_link(): string
306 {
307 _deprecated_function(__METHOD__, '4.6.5', 'AC\ListScreen::get_editor_url()');
308
309 return (string)$this->get_editor_url();
310 }
311
312 /**
313 * @deprecated 7.0
314 */
315 protected function set_meta_type(): void
316 {
317 _deprecated_function(__METHOD__, '7.0');
318 }
319
320 /**
321 * @deprecated 7.0
322 */
323 public function deregister_column(): void
324 {
325 _deprecated_function(__METHOD__, '7.0');
326 }
327
328 /**
329 * @deprecated 7.0
330 */
331 public function set_layout_id(string $layout_id): void
332 {
333 _deprecated_function(__METHOD__, '7.0', 'AC\ListScreen::set_id()');
334
335 if (ListScreenId::is_valid_id($layout_id)) {
336 $this->id = new ListScreenId($layout_id);
337 }
338 }
339
340 /**
341 * @deprecated 7.0
342 */
343 protected function set_label(): void
344 {
345 _deprecated_function(__METHOD__, '7.0');
346 }
347
348 /**
349 * @deprecated 7.0
350 */
351 protected function register_column_types_from_list(): void
352 {
353 _deprecated_function(__METHOD__, '7.0', 'AC\TableScreen::set_column_type()');
354 }
355
356 /**
357 * @deprecated 7.0
358 */
359 public function deregister_column_type(): void
360 {
361 _deprecated_function(__METHOD__, '7.0');
362 }
363
364 /**
365 * @deprecated 7.0
366 */
367 public function register_column_type(): void
368 {
369 _deprecated_function(__METHOD__, '7.0', 'AC\TableScreen::set_column_type()');
370 }
371
372 /**
373 * @deprecated 7.0
374 */
375 public function get_original_columns(): array
376 {
377 _deprecated_function(__METHOD__, '7.0');
378
379 return [];
380 }
381
382 /**
383 * @deprecated 7.0
384 */
385 public function get_group(): string
386 {
387 _deprecated_function(__METHOD__, '7.0');
388
389 return '';
390 }
391
392 /**
393 * @deprecated 7.0
394 */
395
396 public function has_id(): bool
397 {
398 _deprecated_function(__METHOD__, '7.0');
399
400 return true;
401 }
402
403 /**
404 * @deprecated 7.0
405 */
406 public function get_storage_key(): string
407 {
408 _deprecated_function(__METHOD__, '7.0');
409
410 return $this->get_table_id() . $this->id;
411 }
412
413 /**
414 * @deprecated 7.0
415 */
416 public function get_settings(): array
417 {
418 _deprecated_function(__METHOD__, '7.0');
419
420 return [];
421 }
422
423 public function get_key(): TableId
424 {
425 _deprecated_function(__METHOD__, '7.0', 'AC\ListScreen::get_table_id()');
426
427 return $this->get_table_id();
428 }
429
430 }
431