PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 4.7.7
Admin Columns v4.7.7
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 / Controller / ColumnRequest.php
codepress-admin-columns / classes / Controller Last commit date
ColumnRequest 2 years ago ListScreen 2 years ago Middleware 2 years ago AjaxColumnModalValue.php 2 years ago AjaxColumnRequest.php 2 years ago AjaxColumnValue.php 2 years ago AjaxGeneralOptions.php 2 years ago AjaxRequestCustomFieldKeys.php 2 years ago AjaxScreenOptions.php 2 years ago ColumnRequest.php 2 years ago DefaultColumns.php 2 years ago ListScreenRestoreColumns.php 2 years ago RestoreSettingsRequest.php 2 years ago TableListScreenSetter.php 2 years ago
ColumnRequest.php
81 lines
1 <?php
2
3 namespace AC\Controller;
4
5 use AC;
6 use AC\Column;
7 use AC\Column\Placeholder;
8 use AC\ListScreen;
9 use AC\Request;
10 use AC\View;
11
12 abstract class ColumnRequest
13 {
14
15 private $list_screen_factory;
16
17 public function __construct(AC\ListScreenFactory $list_screen_factory)
18 {
19 $this->list_screen_factory = $list_screen_factory;
20 }
21
22 abstract protected function get_column(Request $request, ListScreen $list_screen): ?Column;
23
24 public function request(Request $request): void
25 {
26 $list_key = (string)$request->get('list_screen');
27
28 if ( ! $this->list_screen_factory->can_create($list_key)) {
29 exit;
30 }
31
32 $list_screen = $this->list_screen_factory->create($list_key);
33
34 $column = $this->get_column($request, $list_screen);
35
36 if ( ! $column) {
37 wp_send_json_error([
38 'type' => 'message',
39 'error' => sprintf(
40 __('Please visit the %s screen once to load all available columns', 'codepress-admin-columns'),
41 ac_helper()->html->link((string)$list_screen->get_table_url(), $list_screen->get_label())
42 ),
43 ]);
44 }
45
46 $current_original_columns = (array)json_decode($request->get('current_original_columns', ''), true);
47
48 // Not cloneable message
49 if (in_array($column->get_type(), $current_original_columns, true)) {
50 wp_send_json_error([
51 'type' => 'message',
52 'error' => sprintf(
53 __('%s column is already present and can not be duplicated.', 'codepress-admin-columns'),
54 '<strong>' . $column->get_label() . '</strong>'
55 ),
56 ]);
57 }
58
59 // Placeholder message
60 if ($column instanceof Placeholder) {
61 wp_send_json_error([
62 'type' => 'message',
63 'error' => $column->get_message(),
64 ]);
65 }
66
67 wp_send_json_success($this->render_column($column));
68 }
69
70 private function render_column(Column $column): string
71 {
72 $view = new View([
73 'column' => $column,
74 ]);
75
76 $view->set_template('admin/edit-column');
77
78 return $view->render();
79 }
80
81 }