-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathac-search-options.php
More file actions
37 lines (32 loc) · 880 Bytes
/
ac-search-options.php
File metadata and controls
37 lines (32 loc) · 880 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
31
32
33
34
35
36
37
<?php
/**
* Hook to alter the options returned for the dropdown in Smart Filtering
*/
/**
* Example usage options hook
*/
add_filter(
'ac/search/select/options',
static function (array $options, AC\Column\Context $column, AC\ListScreen $list_screen) {
return $options;
},
10,
3
);
/**
* Example: Alter the label for the dropdown in the Smart Filtering select field
*/
add_filter('ac/search/select/options', static function (array $options, AC\Column\Context $column) {
if ( ! $column instanceof AC\Column\CustomFieldContext) {
return $options;
}
if ($column->get_meta_key() !== 'custom_text_field') {
return $options;
}
foreach ($options as &$option) {
if (is_numeric($option['text'])) {
$option['text'] = 'User ID: ' . $option['text'];
}
}
return $options;
}, 10, 2);