-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathacp-horizontal_scrolling-enable.php
60 lines (48 loc) · 1.63 KB
/
acp-horizontal_scrolling-enable.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
<?php
/**
* This hooks allows you to enable or disable the Horizontal Scrolling feature per list screen
*/
function acp_horizontal_scrolling_enable(bool $enabled, AC\ListScreen $list_screen): bool
{
return $enabled;
}
add_filter('acp/horizontal_scrolling/enable', 'acp_horizontal_scrolling_enable', 10, 2);
// Anonymous function
add_filter('acp/horizontal_scrolling/enable', function ($enabled, AC\ListScreen $list_screen) {
return $enabled;
}, 10, 2);
/**
* Enabled horizontal scrolling for every admin for every list screen
*/
add_filter('acp/horizontal_scrolling/enable', function () {
$user = wp_get_current_user();
return $user && ! $user->has_cap('manage_admin_columns');
});
/**
* Enabled horizontal scrolling for every list screen with more than 10 columns
*/
add_filter('acp/horizontal_scrolling/enable', function (bool $enabled, AC\ListScreen $list_screen): bool {
if ($list_screen->get_columns()->count() > 10) {
return true;
}
return $enabled;
}, 10, 2);
/**
* Set horizontal scrolling based on different ListScreen properties
*/
add_filter('acp/horizontal_scrolling/enable', function (bool $enabled, AC\ListScreen $list_screen): bool {
// Check for specific post type
if ('page' === $list_screen->get_post_type()) {
$enabled = false;
}
$list_id = $list_screen->get_id();
// Check for specific ListScreen ID
if ($list_id->equals(new AC\Type\ListScreenId('620f70285d50d'))) {
$enabled = false;
}
// The above check equals the following example
if ('620f70285d50d' === (string)$list_id) {
$enabled = false;
}
return $enabled;
}, 10, 2);