forked from codepress/admin-columns-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acp-resize_columns-active.php
48 lines (42 loc) · 1.27 KB
/
acp-resize_columns-active.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
<?php
/**
* This hooks allows you to set the availability of the Width Resizer feature per list screen
*/
/**
* @param bool $is_active
* @param AC\ListScreen $list_screen
*
* @return bool
*/
function acp_resize_columns_active( $is_active, AC\ListScreen $list_screen ) {
return $is_active;
}
add_filter( 'acp/resize_columns/active', 'acp_resize_columns_active', 10, 2 );
// Anonymous function
add_filter( 'acp/resize_columns/active', function ( $is_active, AC\ListScreen $list_screen ) {
return $is_active;
}, 10, 2 );
/**
* Disable Column Resizer for a specific List Screen (meta type)
*/
add_filter( 'acp/resize_columns/active', function ( $is_active, AC\ListScreen $list_screen ) {
switch ( true ) {
case $list_screen instanceof AC\ListScreen\Post:
return true;
case $list_screen instanceof AC\ListScreen\User:
return false;
case $list_screen instanceof AC\ListScreen\Media:
return false;
case $list_screen instanceof ACP\ListScreen\Taxonomy:
return true;
default:
return $is_active;
}
}, 10, 2 );
/**
* Only enable the column resizer for Admin Columns Pro managers (administrators)
*/
add_filter( 'acp/resize_columns/active', function ( ) {
$user = wp_get_current_user();
return $user && ! $user->has_cap( 'manage_admin_columns' );
}, 10 );