PluginProbe
Advanced Custom Fields: Extended / 0.8.5
Advanced Custom Fields: Extended v0.8.5
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 All 92 releases
acf-extended / includes / field-groups / field-groups-local.php
field-groups-local.php
198 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH'))
4 exit;
5
6 add_filter('views_edit-acf-field-group', 'acfe_field_groups_third_party_views', 99);
7 function acfe_field_groups_third_party_views($views){
8
9 // Total
10 $total = count(acfe_get_third_party_field_groups());
11
12 // Bail early if empty
13 if($total === 0)
14 return $views;
15
16 // Class
17 $class = '';
18
19 // active
20 if(acf_maybe_get_GET('post_status') === 'acfe-local'){
21
22 // actions
23 add_action('admin_footer', 'acfe_field_groups_third_party_footer', 5);
24
25 // set active class
26 $class = ' class="current"';
27
28 // global
29 global $wp_list_table;
30
31 // update pagination
32 $wp_list_table->set_pagination_args(array(
33 'total_items' => $total,
34 'total_pages' => 1,
35 'per_page' => $total
36 ));
37
38 }
39
40 // add view
41 $views['acfe-local'] = '<a' . $class . ' href="' . admin_url('edit.php?post_type=acf-field-group&post_status=acfe-local') . '">' . __('Local', 'acfe') . ' <span class="count">(' . $total . ')</span></a>';
42
43 // return
44 return $views;
45
46 }
47
48 function acfe_field_groups_third_party_footer(){
49
50 // vars
51 $i = -1;
52 $columns = array(
53 'acfe-source',
54 'acfe-count',
55 'acfe-locations',
56 'acfe-local'
57 );
58
59 ?>
60 <script type="text/html" id="tmpl-acfe-local-tbody">
61 <?php
62
63 foreach(acfe_get_third_party_field_groups() as $field_group ):
64
65 // vars
66 $i++;
67 $key = $field_group['key'];
68 $title = $field_group['title'];
69 $local = $field_group['local'];
70
71 ?>
72 <tr <?php if($i%2 == 0): ?>class="alternate"<?php endif; ?>>
73 <td class="post-title page-title column-title">
74 <strong>
75 <span class="row-title"><?php echo esc_html($title); ?></span>
76 </strong>
77 <div class="row-actions">
78
79 <span>
80 <a href="<?php echo add_query_arg(array('action' => 'php', 'keys' => $key), acf_get_admin_tool_url('acfe-fg-local')); ?>">PHP</a> |
81 </span>
82
83 <span>
84 <a href="<?php echo add_query_arg(array('action' => 'json', 'keys' => $key), acf_get_admin_tool_url('acfe-fg-local')); ?>">Json</a> |
85 </span>
86
87 <span>
88 <a href="<?php echo add_query_arg(array('action' => 'sync', 'keys' => $key), acf_get_admin_tool_url('acfe-fg-local')); ?>">Sync</a> |
89 </span>
90
91 <span class="acfe-key">
92 <span style="color:#555;">
93 <code style="font-size: 12px;"><?php echo esc_html($key); ?></code>
94 </span>
95 </span>
96
97 </div>
98 </td>
99 <?php foreach($columns as $column): ?>
100 <td class="column-<?php echo esc_attr($column); ?>">
101 <?php echo acfe_field_groups_column_html($column, $key); ?>
102 </td>
103 <?php endforeach; ?>
104 </tr>
105 <?php endforeach; ?>
106 </script>
107
108 <script type="text/javascript">
109 (function($){
110
111 // update table HTML
112 $('#the-list').html($('#tmpl-acfe-local-tbody').html());
113
114 })(jQuery);
115 </script>
116 <?php
117
118 }
119
120 function acfe_get_third_party_field_groups(){
121
122 $get_local_field_groups = acf_get_local_field_groups();
123 if(empty($get_local_field_groups))
124 return array();
125
126 $locals = array();
127
128 foreach($get_local_field_groups as $field_group){
129
130 // Exclude ACFE Field Groups
131
132 if(!acfe_is_super_dev()){
133
134 if(stripos($field_group['key'], 'group_acfe_') === 0)
135 continue;
136
137 }
138
139
140 $locals[] = $field_group;
141
142 }
143
144 // Bail early if no local fields
145 if(empty($locals))
146 return $locals;
147
148 // Get DB field groups
149 $get_db_field_groups = acfe_get_db_field_groups();
150
151 // Bail early if no DB field groups
152 if(empty($get_db_field_groups))
153 return $locals;
154
155 foreach($get_db_field_groups as $field_group){
156
157 foreach($locals as $k => $local){
158
159 if($local['key'] === $field_group['key'])
160 unset($locals[$k]);
161
162 }
163
164 }
165
166 return $locals;
167
168 }
169
170 function acfe_get_db_field_groups(){
171
172 acf_disable_filters();
173
174 $get_db_field_groups = acf_get_field_groups();
175
176 acf_enable_filters();
177
178 return $get_db_field_groups;
179
180 }
181
182 add_filter('bulk_actions-edit-acf-field-group', function($actions){
183
184 if(acf_maybe_get_GET('post_status') === 'acfe-local')
185 return array();
186
187 return $actions;
188
189 }, 99);
190
191 add_filter('manage_edit-acf-field-group_sortable_columns', function($sortable_columns){
192
193 if(acf_maybe_get_GET('post_status') === 'acfe-local')
194 return array();
195
196 return $sortable_columns;
197
198 }, 99);