-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathac-editing-custom-field-post_types.php
More file actions
55 lines (49 loc) · 1.36 KB
/
ac-editing-custom-field-post_types.php
File metadata and controls
55 lines (49 loc) · 1.36 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
47
48
49
50
51
52
53
54
55
<?php
/**
* The filter `ac/editing/custom_field/post_types` allows you to set which post types are available in the editing dropdown in the custom field
* By default the array is empty, which means all post types are available.
*/
function ac_set_post_types_for_editing(
array $post_types,
AC\Config $config,
AC\Type\TableScreenContext $table_screen_context
): array {
// Change the rendered column value
// $value = 'new value';
return $post_types;
}
add_filter('ac/editing/custom_field/post_types', 'ac_set_post_types_for_editing', 10, 3);
/**
* Shorter notation
*/
add_filter(
'ac/editing/custom_field/post_types',
static function (
array $post_types,
AC\Setting\Config $config,
AC\Type\TableScreenContext $table_screen_context
): array {
return $post_types;
},
10,
3
);
/**
* Set post types based on a custom field column
*/
add_filter(
'ac/editing/custom_field/post_types',
static function (
array $post_types,
AC\Setting\Config $config,
AC\Type\TableScreenContext $table_screen_context
): array {
// Check the custom field for a specific meta_key
if ('custom_meta_key' === $config->get('field', '')) {
$post_types = ['post', 'page']; // Only show post and page types
}
return $post_types;
},
10,
3
);