-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathac-column-template.php
More file actions
executable file
·46 lines (39 loc) · 1.57 KB
/
ac-column-template.php
File metadata and controls
executable file
·46 lines (39 loc) · 1.57 KB
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
/**
* Plugin Name: Admin Columns - COLUMN_LABEL
* Plugin URI: https://admincolumns.com
* Description: COLUMN_LABEL column for Admin Columns Pro
* Version: 1.0
* Requires PHP: 7.2
*/
const AC_CT_FILE = __FILE__;
add_filter('ac/column/types', 'acp_my_custom_column', 10, 2);
function acp_my_custom_column(array $factories, AC\TableScreen $table_screen)
{
// Require the necessary files for the column or use an autoloader instead
require_once __DIR__ . '/classes/Column/Column.php';
require_once __DIR__ . '/classes/Column/Editing.php';
require_once __DIR__ . '/classes/Column/Export.php';
require_once __DIR__ . '/classes/Column/Sorting.php';
require_once __DIR__ . '/classes/Column/Search.php';
// Example #1 - for any custom post type
if ($table_screen instanceof AC\PostType) {
$factories[] = AcColumnTemplate\Column\Column::class;
}
// Example #2 - for the custom post type 'page'
if ('page' === (string)$table_screen->get_id()) {
// Register Column Factory
// $factories[] = AcColumnTemplate\Column\Column::class;
}
// Example #3 - Check for different table screens based on instance type
switch (true) {
case $table_screen instanceof AC\TableScreen\Post:
case $table_screen instanceof AC\TableScreen\User:
case $table_screen instanceof AC\TableScreen\Media:
case $table_screen instanceof ACP\TableScreen\Taxonomy:
// Register Column Factory
// $factories[] = AcColumnTemplate\Column\Column::class;
break;
}
return $factories;
}