list-screen-settings.php
6.86 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
use AC\Form\Element\Select;
use AC\Form\Element\Toggle;
use ACP\Bookmark\Setting\PreferredSegment;
use ACP\Sorting\Settings\ListScreen\PreferredSort;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<section class="ac-setbox ac-ls-settings ac-section" data-section="ls-settings">
<header class="ac-section__header">
<div class="ac-setbox__header__title"><?= esc_html__( 'Settings', 'codepress-admin-columns' ) ?>
<small>(<?= esc_html__( 'optional', 'codepress-admin-columns' ) ?>)</small>
</div>
</header>
<form data-form-part="preferences">
<div class="ac-setbox__row">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Conditionals', 'codepress-admin-columns' ) ?></label>
<small><?= esc_html__( 'Make this table view available only for specific users or roles.', 'codepress-admin-columns' ) ?></small>
</div>
<div class="ac-setbox__row__fields">
<div class="ac-setbox__row__fields__inner">
<fieldset>
<div class="row roles">
<label for="layout-roles-<?= esc_attr( $this->id ) ?>" class="screen-reader-text">
<?= esc_html__( 'Roles', 'codepress-admin-columns' ) ?>
<span>(<?= esc_html__( 'optional', 'codepress-admin-columns' ) ?>)</span>
</label>
<?php echo $this->select_roles; ?>
</div>
<div class="row users">
<label for="layout-users-<?= esc_attr( $this->id ) ?>" class="screen-reader-text">
<?= esc_html__( 'Users' ) ?>
<span>(<?= esc_html__( 'optional', 'codepress-admin-columns' ) ?>)</span>
</label>
<?= $this->select_users ?>
</div>
</fieldset>
</div>
</div>
</div>
<div class="ac-setbox__row" id="hide-on-screen">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Table Elements', 'codepress-admin-columns' ) ?></label>
<small><?= esc_html__( 'Show or hide elements from the table list screen.', 'codepress-admin-columns' ) ?></small>
</div>
<div class="ac-setbox__row__fields">
<div class="ac-setbox__row__fields__inner">
<div class="checkbox-labels checkbox-labels vertical">
<div data-component="acp-table-elements"></div>
</div>
</div>
</div>
</div>
<?php
$number_of_preferences = count( array_filter( [ $this->can_sort, $this->can_bookmark, $this->can_horizontal_scroll ] ) );
?>
<?php if ( $number_of_preferences > 0 ) : ?>
<div class="ac-setbox__row">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Preferences', 'codepress-admin-columns' ) ?></label>
<small><?= esc_html__( 'Set default settings that users will see when they visit the list table.', 'codepress-admin-columns' ) ?></small>
</div>
<div class="ac-setbox__row__fields -has-subsettings -subsetting-total-<?= $number_of_preferences ?>">
<?php if ( $this->can_horizontal_scroll ) : ?>
<?php
$pref_hs = $this->preferences['horizontal_scrolling'] ?? 'off';
?>
<div class="ac-setbox__row -sub -horizontal-scrolling">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Horizontal Scrolling', 'codepress-admin-columns' ) ?></label>
<?= $this->tooltip_hs->get_label() ?>
<?= $this->tooltip_hs->get_instructions() ?>
</div>
<div class="ac-setbox__row__fields">
<div class="ac-setbox__row__fields__inner">
<?php
$toggle = new Toggle( 'horizontal_scrolling', '', $pref_hs === 'on', 'on', 'off' );
echo $toggle->render();
?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $this->can_sort ) : ?>
<?php
$selected_order_by = $this->preferences[ PreferredSort::FIELD_SORTING ] ?? 0;
$selected_order = $this->preferences[ PreferredSort::FIELD_SORTING_ORDER ] ?? 'asc';
?>
<div class="ac-setbox__row -sub -sorting" data-setting="sorting-preference">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Sorting', 'codepress-admin-columns' ) ?></label>
</div>
<div class="ac-setbox__row__fields">
<div class="ac-setbox__row__fields__inner">
<div class="radio-labels radio-labels">
<?php
$select = new Select( PreferredSort::FIELD_SORTING, [
0 => __( 'Default' ),
] );
echo $select->set_attribute( 'data-sorting', $selected_order_by );
$select = new Select( PreferredSort::FIELD_SORTING_ORDER, [
'asc' => __( 'Ascending' ),
'desc' => __( 'Descending' ),
] );
echo $select->set_class( 'sorting_order' )->set_value( $selected_order );
?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $this->can_bookmark ) : ?>
<?php
$segments = $this->segments;
$selected_filter_segment = $this->preferences[ PreferredSegment::FIELD_SEGMENT ] ?? '';
?>
<div class="ac-setbox__row -sub -predefinedfilters" data-setting="filter-segment-preference">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Pre-applied Filters', 'codepress-admin-columns' ) ?></label>
<?= $this->tooltip_filters->get_label() ?>
<?= $this->tooltip_filters->get_instructions() ?>
</div>
<div class="ac-setbox__row__fields">
<div class="ac-setbox__row__fields__inner">
<?php if ( ! empty( $segments ) ): ?>
<?php
$select = new Select( PreferredSegment::FIELD_SEGMENT, [ '' => __( 'Default', 'codepress-admin-columns' ) ] + $segments );
echo $select->set_value( $selected_filter_segment );
?>
<?php else: ?>
<p class="ac-setbox__descriptive">
<?= esc_html__( "No public saved filters available.", 'codepress-admin-columns' ) ?>
</p>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $this->can_primary_column ) : ?>
<div class="ac-setbox__row -sub -primary-column">
<div class="ac-setbox__row__th">
<label><?= esc_html__( 'Primary Column', 'codepress-admin-columns' ) ?></label>
<?= $this->tooltip_primary_column->get_label() ?>
<?= $this->tooltip_primary_column->get_instructions() ?>
</div>
<div class="ac-setbox__row__fields">
<div class="ac-setbox__row__fields__inner">
<?php if ( $this->primary_columns ) : ?>
<div class="radio-labels radio-labels">
<?php
$select = new Select( 'primary_column', $this->primary_columns );
echo $select->set_class( 'primary_column' )->set_value( $this->primary_column );
?>
</div>
<?php else : ?>
<p class="ac-setbox__descriptive">
<?= esc_html__( "Remove actions column to change the primary column.", 'codepress-admin-columns' ) ?>
</p>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</form>
</section>