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 4 days ago Admin 4 days ago Ajax 4 days ago ApplyFilter 4 days ago Asset 4 days ago Capabilities 4 days ago Check 4 days ago Collection 4 days ago Column 4 days ago ColumnFactories 4 days ago ColumnFactory 4 days ago ColumnIterator 4 days ago ColumnRepository 4 days ago ColumnSize 4 days ago DI 4 days ago DefaultColumnHandler 4 days ago Deprecated 4 days ago Entity 4 days ago Exception 4 days ago Expression 4 days ago Form 4 days ago Formatter 4 days ago Helper 4 days ago Integration 4 days ago ListScreenRepository 4 days ago ListTable 4 days ago Message 4 days ago Meta 4 days ago Nonce 4 days ago Notice 4 days ago Plugin 4 days ago Preferences 4 days ago Promo 4 days ago Request 4 days ago RequestHandler 4 days ago Response 4 days ago Sanitize 4 days ago Service 4 days ago Setting 4 days ago Settings 4 days ago Storage 4 days ago Table 4 days ago TableIdsFactory 4 days ago TableScreen 4 days ago TableScreenFactory 4 days ago ThirdParty 4 days ago Type 4 days ago Value 4 days ago View 4 days ago Acf.php 4 days ago AdminColumns.php 4 days ago ArrayIterator.php 4 days ago Capabilities.php 4 days ago Collection.php 4 days ago CollectionFormatter.php 4 days ago Column.php 4 days ago ColumnCollection.php 4 days ago ColumnFactoryCollectionFactory.php 4 days ago ColumnFactoryDefinitionCollection.php 4 days ago ColumnGroups.php 4 days ago ColumnIterator.php 4 days ago ColumnNamesTrait.php 4 days ago ColumnRepository.php 4 days ago ColumnTypeRepository.php 4 days ago Config.php 4 days ago DateFormats.php 4 days ago DefaultColumnHandler.php 4 days ago Expirable.php 4 days ago Formatter.php 4 days ago FormatterCollection.php 4 days ago Helper.php 4 days ago ListScreen.php 4 days ago ListScreenCollection.php 4 days ago ListScreenRepository.php 4 days ago ListScreenRepositoryWritable.php 4 days ago ListTable.php 4 days ago ListTableFactory.php 4 days ago Loader.php 4 days ago Message.php 4 days ago MetaType.php 4 days ago Middleware.php 4 days ago OpCacheInvalidateTrait.php 4 days ago PluginActionLinks.php 4 days ago PluginActionUpgrade.php 4 days ago PostType.php 4 days ago PostTypeRepository.php 4 days ago Registerable.php 4 days ago Registry.php 4 days ago Renderable.php 4 days ago Request.php 4 days ago RequestAjaxHandler.php 4 days ago RequestAjaxHandlers.php 4 days ago RequestAjaxParser.php 4 days ago RequestHandler.php 4 days ago RequestHandlerFactory.php 4 days ago Screen.php 4 days ago Services.php 4 days ago TableIdsFactory.php 4 days ago TableScreen.php 4 days ago TableScreenFactory.php 4 days ago Taxonomy.php 4 days ago Transient.php 4 days ago TypedArrayIterator.php 4 days ago View.php 4 days ago WooCommerce.php 4 days ago WpListTableFactory.php 4 days 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