-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathac-export-column-disable.php
43 lines (35 loc) · 1.27 KB
/
ac-export-column-disable.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
<?php
/**
* You can deactivate specific columns from exporting by using the `ac/export/column/disable` hook
*/
/**
* Disable a specific column for export based on its name.
* Custom columns have a random generated name, so be aware of that!
*/
function acp_export_disable_export_for_title_column(bool $is_disabled, AC\Column $column): bool
{
if ($column->get_name() === 'title') {
return true;
}
return $is_disabled;
}
add_filter('ac/export/column/disable', 'acp_export_disable_export_for_title_column', 10, 2);
/**
* Example for disabling specific columns based on the class.
* This Example also shows some additional conditionals that can be used for the Custom Field column
*/
function acp_export_disable_export_for_custom_field_column(bool $is_disabled, AC\Column $column): bool
{
if ($column instanceof AC\Column\CustomField) {
// Additionally check for meta key to enable / disable specific columns
if ('your_custom_field_key' === $column->get_meta_key()) {
return false;
}
if ('date' === $column->get_field_type()) {
return false;
}
return true;
}
return $is_disabled;
}
add_filter('ac/export/column/disable', 'acp_export_disable_export_for_custom_field_column', 10, 2);