-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathac-editing-view.php
More file actions
81 lines (70 loc) · 1.91 KB
/
ac-editing-view.php
File metadata and controls
81 lines (70 loc) · 1.91 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
<?php
/**
* Change the behavior of the editable for a specific column.
*/
/**
* Usage
*
* @param ACP\Editing\View|null $view
* @param AC\Column\Context $column
* @param string $editing_context "single" or "bulk"
* @param ACP\Editing\Service $service
* @param AC\TableScreen $table
*
* @return ACP\Editing\View|null
*/
function ac_editing_view_example_usage(
?ACP\Editing\View $view,
AC\Column\Context $column,
string $editing_context,
ACP\Editing\Service $service,
AC\TableScreen $table
): ?ACP\Editing\View {
return $view;
}
add_filter('ac/editing/view', 'ac_editing_view_example_usage', 10, 5);
// Or anonymous function
add_filter(
'ac/editing/view',
static function (
$view,
AC\Column\Context $column,
string $edit_context,
ACP\Editing\Service $service,
AC\TableScreen $table
) {
return $view;
},
10,
5
);
/**
* Example that enabled bulk editing for the Slug column that is disabled by default. It returns the view that is normally used for inline editing
*/
function ac_editing_view_enable_bulk_for_slug(
$view,
AC\Column\Context $column,
string $edit_context,
ACP\Editing\Service $service
) {
if ($column->get_type() === 'column-slug' && 'bulk' === $edit_context) {
$view = $service->get_view('single');
}
return $view;
}
add_filter('ac/editing/view', 'ac_editing_view_enable_bulk_for_slug', 10, 4);
function ac_editing_view_custom_select(
$view,
AC\Column\Context $column,
string $edit_context,
ACP\Editing\Service $service
) {
if ($column->get_type() === 'column-meta' && $column->get('field') === 'your-meta-key') {
$view = new ACP\Editing\View\Select([
'value' => 'Label',
'value2' => 'Label 2',
]);
}
return $view;
}
add_filter('ac/editing/view', 'ac_editing_view_custom_select', 10, 4);