-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathacp-editing-view.php
71 lines (59 loc) · 2.07 KB
/
acp-editing-view.php
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
<?php
/**
* Change the behavior of the editable for a specific column.
*/
/**
* Usage
*
* @param ACP\Editing\View|false $view
* @param AC\Column $column
* @param string $context "single" or "bulk"
* @param ACP\Editing\Service $service
*
* @return ACP\Editing\View|false
*/
function acp_editing_view_example_usage($view, AC\Column $column, $context, ACP\Editing\Service $service)
{
return $view;
}
add_filter('acp/editing/view', 'acp_editing_view_example_usage', 10, 4);
// Or anonymous function
add_filter('acp/editing/view', function ($view, AC\Column $column, $context, ACP\Editing\Service $service) {
return $view;
}, 10, 4);
/**
* 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
*
* @param ACP\Editing\View|false $view
* @param AC\Column $column
* @param string $context "single" or "bulk"
* @param ACP\Editing\Service $service
*
* @return ACP\Editing\View|false
*/
function acp_editing_view_enable_bulk_for_slug($view, AC\Column $column, $context, ACP\Editing\Service $service)
{
if ($column instanceof AC\Column\Post\Slug && 'bulk' === $context) {
$view = $service->get_view('single');
}
return $view;
}
add_filter('acp/editing/view', 'acp_editing_view_enable_bulk_for_slug', 10, 4);
function acp_editing_view_custom_select($view, AC\Column $column, $context, ACP\Editing\Service $service)
{
if ($column instanceof AC\Column\CustomField && $column->get_meta_key() === 'your-meta-key') {
$view = new ACP\Editing\View\Select([
'value' => 'Label',
'value2' => 'Label 2',
]);
}
return $view;
}
add_filter('acp/editing/view', 'acp_editing_view_custom_select', 10, 4);
// Change the color palette for every color editable
add_filter('acp/editing/view', function ($view) {
if ($view instanceof ACP\Editing\View\Color) {
$view->set_palletes(['#fe3d6c', '#02abab', '#ffee85', '#242830', '#3D4350', '#CACED9']);
}
return $view;
});