forked from codepress/admin-columns-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacp-table-column_order-active.php
More file actions
30 lines (28 loc) · 976 Bytes
/
acp-table-column_order-active.php
File metadata and controls
30 lines (28 loc) · 976 Bytes
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
<?php
/**
* The filter `acp/table/column_order/active` allows you to toggle the column order feature programmatically for the provided list screen
*/
/**
* @param bool $active The column value that is displayed within a cell on the list table
* @param AC\ListScreen $list_screen Post ID, User ID, Comment ID, Attachement ID or Term ID
*
* @return bool
*/
add_filter( 'acp/table/column_order/active', function ( $active, AC\ListScreen $list_screen ) {
return $active;
}, 10, 2 );
/**
* Example for specific list screen checks
*/
add_filter( 'acp/table/column_order/active', function ( $active, AC\ListScreen $list_screen ) {
switch ( true ) {
case $list_screen instanceof AC\ListScreen\User:
// Disable for user list table
return false;
case $list_screen instanceof AC\ListScreen\Post:
// Only enable for posts, disable for other post types
return $list_screen->get_post_type() === 'post';
default:
return $active;
}
}, 10, 2 );