forked from codepress/admin-columns-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacp-editing-view.php
46 lines (39 loc) · 1.36 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
<?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 );