-
Notifications
You must be signed in to change notification settings - Fork 57
/
acf-extended-admin-columns.php
69 lines (65 loc) · 1.75 KB
/
acf-extended-admin-columns.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
function acf_field_group_columns($columns) {
$columns['menu_order'] = __('Menu Order');
$columns['location'] = __('Location Rules');
return $columns;
}
add_filter('manage_edit-acf-field-group_columns', 'acf_field_group_columns', 20);
function acf_field_group_columns_content($column, $post_id) {
$post = get_post($post_id);
switch ($column) {
case 'menu_order':
echo $post->menu_order;
break;
case 'location':
$details = unserialize($post->post_content);
$location = $details['location'];
if (is_array($location) && count($location)) {
echo '<pre>';
$or_count = 1;
foreach ($location as $or) {
$and_count = 1;
foreach ($or as $and) {
if ($and_count == 1) {
echo ' ';
}
echo $and['param'],' ',$and['operator'],' ',$and['value'];
if ($and_count < count($or)) {
echo "\r\n",'<strong>AND </strong>';
}
$and_count++;
}
if ($or_count < count($location)) {
echo "\r\n\r\n",'<strong>OR</strong>',"\r\n";
}
$or_count++;
}
echo '</pre>';
}
break;
} // end switch
}
add_action('manage_acf-field-group_posts_custom_column', 'acf_field_group_columns_content', 10, 2 );
// some css to pretty up the new columns
add_action('admin_head', 'admin_acf_columns_css');
function admin_acf_columns_css() {
?>
<style type="text/css">
#acf-field-group-wrap .wp-list-table .column-menu_order {
width: 10%;
}
.widefat td.column-location {
padding: 0;
}
.widefat td.column-location pre {
margin: 0;
padding: 8px 10px;
border-top: 1px solid #CCC;
}
.widefat tbody tr:first-child td.column-location pre {
border-top: none;
}
</style>
<?php
}
?>