list-screens-sidebar.php
6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
use AC\ListScreen;
use AC\View;
use ACP\RequestHandler\ListScreenCreate;
if ( ! defined('ABSPATH')) {
exit;
}
?>
<div class="sidebox layouts" data-type="<?= $this->list_screen->get_key() ?>">
<div class="header">
<h3>
<span class="header-content"><?php
_e('Table Views', 'codepress-admin-columns'); ?></span>
<a class="button add-new">
<span class="add"><?= esc_html(__('+ Add view', 'codepress-admin-columns')) ?></span>
<span class="close"><?= esc_html(__('Cancel', 'codepress-admin-columns')) ?></span>
</a>
</h3>
</div>
<?php
$view = new View([
'list_screen' => $this->list_screen,
]);
$view->set_template('admin/create-list-screen');
echo $view->render();
if ($this->list_screens->count() > 1) : ?>
<div class="layouts__items">
<?php
foreach ($this->list_screens as $list_screen) : ?>
<?php
/** @var ListScreen $list_screen */ ?>
<?php
$is_current = $this->list_screen->get_layout_id() == $list_screen->get_layout_id(); ?>
<?php
$onclick = apply_filters('ac/delete_confirmation', true) ? ' onclick="return confirm(\'' . esc_attr(
addslashes(
sprintf(
__(
"Warning! The %s columns data will be deleted. This cannot be undone. 'OK' to delete, 'Cancel' to stop",
'codepress-admin-columns'
),
"'" . $list_screen->get_label() . "'"
)
)
) . '\');"' : ''; ?>
<?php
$class = [];
if ($is_current) {
$class[] = '-current';
}
if ($list_screen->is_read_only()) {
$class[] = '-read_only';
}
?>
<div class="layouts__item <?= esc_attr(implode(' ', $class)); ?>" data-screen="<?= esc_attr(
$list_screen->get_layout_id()
); ?>">
<div class="layouts__item__move">
<span class="cpacicon-move"></span>
</div>
<div class="layouts__item__title">
<?php
$title = esc_html($list_screen->get_title() ?: $list_screen->get_label());
$title = sprintf('<span data-label>%s</span>', $title);
if ( ! $is_current) {
echo ac_helper()->html->link(
(string)$list_screen->get_editor_url(),
$title,
['class' => 'select']
);
} else {
echo $title;
}
$description = [];
$roles = $list_screen->get_preference('roles');
$users = $list_screen->get_preference('users');
if ($roles) {
if (1 === count($roles)) {
$_roles = get_editable_roles();
$role = $roles[0];
$description[] = isset($_roles[$role]) ? $_roles[$role]['name'] : $role;
} else {
$description[] = __('Roles', 'codepress-admin-columns');
}
}
if ($users) {
if (1 === count($users)) {
$user = get_userdata($users[0]);
if ($user instanceof WP_User) {
$user_name = ucfirst(ac_helper()->user->get_display_name($user, 'first_last_name'));
if ( ! $user_name) {
$user_name = __('User', 'codepress-admin-columns');
}
$description[] = $user_name;
}
} else {
$description[] = __('Users');
}
}
$description = implode(' & ', array_filter($description));
if ($description) {
printf(
'<span class="layouts__item__permissions">%s</span>',
ac_helper()->html->tooltip(
ac_helper()->icon->dashicon(['icon' => 'admin-users', 'class' => 'gray']),
$description
)
);
}
?>
<small class="layouts__item__id"><?= sprintf(
'%s: %s',
__('ID', 'codepress-admin-columns'),
$list_screen->get_layout_id()
); ?></small>
</div>
<div class="layouts__item__extra">
<div class="layouts__item__state">
<?php
if ($list_screen->is_read_only()): ?>
<div class="layouts__item__state__readonly">
<?= ac_helper()->html->tooltip(
ac_helper()->icon->dashicon(['icon' => 'lock', 'class' => 'gray']),
__('Read Only', 'codepress-admin-columns')
); ?>
</div>
<?php
endif; ?>
</div>
<div class="layouts__item__actions">
<?php
if ( ! $list_screen->is_read_only()): ?>
<form method="post" class="delete">
<?= (new \ACP\Nonce\LayoutNonce())->create_field() ?>
<input type="hidden" name="<?= ListScreenCreate::PARAM_ACTION; ?>" value="<?= ListScreenCreate::PARAM_DELETE_LIST; ?>">
<input type="hidden" name="ac_delete_layout_id" value="<?= esc_attr(
$list_screen->get_layout_id()
); ?>">
<input type="hidden" name="list_screen" value="<?= esc_attr(
$list_screen->get_key()
); ?>">
<input type="submit" class="delete" value="<?= esc_attr(
__('Delete', 'codepress-admin-columns')
); ?>"<?= $onclick; ?>/>
</form>
<?php
endif; ?>
</div>
</div>
</div>
<?php
endforeach; ?>
</div>
<?php
endif; ?>
</div>