PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8
Advanced Custom Fields: Extended v0.8
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 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / field-groups / field-groups.php
acf-extended / includes / field-groups Last commit date
field-group-category.php 6 years ago field-group.php 6 years ago field-groups-third-party.php 6 years ago field-groups.php 6 years ago
field-groups.php
473 lines
1 <?php
2
3 if(!defined('ABSPATH'))
4 exit;
5
6 /**
7 * Display Title (post states)
8 */
9 add_filter('display_post_states', 'acfe_field_groups_states', 10, 2);
10 function acfe_field_groups_states($states, $post){
11
12 if(!acf_is_screen('edit-acf-field-group'))
13 return $states;
14
15 if(get_post_type($post->ID) != 'acf-field-group')
16 return $states;
17
18 $field_group = acf_get_field_group($post->ID);
19
20 if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
21 return $states;
22
23 $states[] = $field_group['acfe_display_title'];
24
25 return $states;
26
27 }
28
29 /**
30 * Table Columns
31 */
32 add_filter('manage_edit-acf-field-group_columns', 'acfe_field_groups_column', 999);
33 function acfe_field_groups_column($columns){
34
35 // Locations
36 $columns['acfe-locations'] = __('Locations');
37
38 // Load
39 $columns['acfe-local'] = __('Load');
40
41 // PHP sync
42 if(acf_get_setting('acfe/php'))
43 $columns['acfe-autosync-php'] = __('PHP sync');
44
45 // Json sync
46 if(acf_get_setting('json'))
47 $columns['acfe-autosync-json'] = __('Json sync');
48
49 // Fix 'Sync' screen columns
50 if(acf_maybe_get_GET('post_status') === 'sync'){
51
52 unset($columns['acf-field-group-category']);
53
54 unset($columns['acfe-locations']);
55 unset($columns['acfe-local']);
56
57 if(isset($columns['acfe-autosync-php']))
58 unset($columns['acfe-autosync-php']);
59
60 if(isset($columns['acfe-autosync-json']))
61 unset($columns['acfe-autosync-json']);
62
63 }
64
65 // Fix 'Third party' screen columns
66 elseif(acf_maybe_get_GET('post_status') === 'acfe-third-party'){
67
68 $columns = array(
69 'title' => __('Title', 'acf'),
70 'acfe-source' => __('Source', 'acf'),
71 'acf-fg-count' => __('Fields', 'acf'),
72 'acfe-locations' => __('Locations', 'acf'),
73 'acfe-local' => __('Load', 'acf'),
74 );
75
76 }
77
78 // Remove 'Field Group Category' column if there is no terms
79 $categories = get_terms(array(
80 'taxonomy' => 'acf-field-group-category',
81 'hide_empty' => false,
82 ));
83
84 if(empty($categories) && isset($columns['acf-field-group-category']))
85 unset($columns['acf-field-group-category']);
86
87 return $columns;
88
89 }
90
91 /**
92 * Table Columns HTML
93 */
94 add_action('manage_acf-field-group_posts_custom_column', 'acfe_field_groups_column_html', 10, 2);
95 function acfe_field_groups_column_html($column, $post_id){
96
97 /**
98 * Count
99 */
100 if($column === 'acfe-count'){
101
102 $field_group = acf_get_field_group($post_id);
103 echo esc_html(acf_get_field_count($field_group));
104
105 }
106
107 /**
108 * Count
109 */
110 elseif($column === 'acfe-source'){
111
112 $field_group = acf_get_field_group($post_id);
113
114 // ACF Extended
115 if(strpos($post_id, 'group_acfe_') === 0){
116
117 echo 'ACF Extended';
118
119 }
120
121 // Advanced Forms
122 elseif($post_id === 'group_form_settings' || $post_id === 'group_entry_data'){
123
124 echo 'Advanced Forms';
125
126 }
127
128 else{
129
130 echo '<span style="color:#aaa;">'; _e('Unknown', 'acf'); echo '</span>';
131
132 }
133
134 }
135
136 /**
137 * Locations
138 */
139 elseif($column === 'acfe-locations'){
140
141 $field_group = acf_get_field_group($post_id);
142 $choices = acf_get_location_rule_types();
143
144 if(!isset($field_group['location']) || empty($field_group['location']) ||empty($choices))
145 return;
146
147 $final = array();
148
149 $icon_default = 'admin-generic';
150
151 $icons = array(
152 'edit' => array(
153 'post_type',
154 'post_template',
155 'post_status',
156 'post_format',
157 'post',
158 ),
159 'media-default' => array(
160 'page_template',
161 'page_type',
162 'page_parent',
163 'page',
164 ),
165 'admin-users' => array(
166 'current_user',
167 'user_form',
168 ),
169 'welcome-widgets-menus' => array(
170 'widget',
171 'nav_menu',
172 'nav_menu_item',
173 ),
174 'category' => array(
175 'taxonomy',
176 'post_category',
177 'post_taxonomy',
178 ),
179 'admin-comments' => array(
180 'comment',
181 ),
182 'paperclip' => array(
183 'attachment',
184 ),
185 'admin-settings' => array(
186 'options_page',
187 ),
188 'businessman' => array(
189 'current_user_role',
190 'user_role',
191 ),
192 );
193
194 foreach($choices as $key => $sub_choices){
195
196 foreach($sub_choices as $choice_slug => $choice_name){
197
198 $final_icon = $icon_default;
199 foreach($icons as $icon => $icon_slugs){
200 foreach($icon_slugs as $icon_slug){
201 if($choice_slug != $icon_slug)
202 continue;
203
204 $final_icon = $icon;
205 break(2);
206 }
207 }
208
209 $final[$choice_slug] = array(
210 'name' => $choice_name,
211 'icon' => $final_icon
212 );
213
214 }
215
216 }
217
218
219
220 $html = array();
221 foreach($field_group['location'] as $or){
222
223 foreach($or as $and){
224
225 if(!isset($final[$and['param']])|| !isset($and['value']))
226 continue;
227
228 $final_name = $and['value'];
229 $values = acf_get_location_rule_values($and);
230
231 if(!empty($values) && is_array($values)){
232
233 foreach($values as $value_slug => $value_name){
234
235 if($and['value'] != $value_slug)
236 continue;
237
238 if(is_array($value_name) && isset($value_name[$and['value']])){
239
240 $final_name = $value_name[$and['value']];
241
242 }else{
243
244 $final_name = $value_name;
245
246 }
247
248 break;
249
250 }
251
252 }
253
254 $name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' = ' . $final_name . '"></span>';
255 if($and['operator'] === '!=')
256 $name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' != ' . $final_name . '" style="color:#ccc;"></span>';
257
258 $html[] = $name;
259
260 }
261
262 }
263
264 echo implode(' ', $html);
265
266 }
267
268 /**
269 * Load
270 */
271 elseif($column === 'acfe-local'){
272
273 if(!$field_group = acf_get_field_group($post_id))
274 return;
275
276 $local_field_group = acf_get_local_field_group($field_group['key']);
277 $local_field_group_type = acf_maybe_get($local_field_group, 'local', false);
278
279 if($local_field_group_type === 'php'){
280
281 echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">php</span>';
282
283 return;
284
285 }
286
287 elseif($local_field_group_type === 'json'){
288
289 echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">json</span>';
290
291 return;
292
293 }
294
295 else{
296
297 echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is not registered locally">DB</span>';
298
299 return;
300
301 }
302
303 }
304
305 /**
306 * PHP sync
307 */
308 elseif($column === 'acfe-autosync-php'){
309
310 if(!$field_group = acf_get_field_group($post_id))
311 return;
312
313 if(!acfe_has_field_group_autosync($field_group, 'php')){
314
315 echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
316
317 if(acfe_has_field_group_autosync_file($field_group, 'php')){
318 echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Field group: ' . $field_group['key'] . ' is registered via a third-party PHP code"></span>';
319 }
320
321 return;
322
323 }
324
325 if(!acf_get_setting('acfe/php_found')){
326
327 echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
328
329 echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acfe-php\' was not found in your theme.<br />You must create it to activate this setting"></span>';
330
331 }
332
333 elseif(!acfe_has_field_group_autosync_file($field_group, 'php')){
334
335 echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
336 echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Local file ' . $field_group['key'] . '.php will be created upon update"></span>';
337
338 }
339
340 else{
341
342 echo '<span class="dashicons dashicons-yes"></span>';
343
344 }
345
346 }
347
348 /**
349 * Json sync
350 */
351 elseif($column === 'acfe-autosync-json'){
352
353 if(!$field_group = acf_get_field_group($post_id))
354 return;
355
356 if(acfe_has_field_group_autosync_file($field_group, 'json')){
357
358 echo '<span class="dashicons dashicons-yes"></span>';
359
360 }
361
362 else{
363
364 if(!acfe_has_field_group_autosync($field_group, 'json')){
365
366 echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
367
368 }else{
369
370 echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
371
372 if(!acfe_folder_exists('acf-json')){
373
374 echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acf-json\' was not found in your theme.<br />You must create it to activate this setting"></span>';
375
376 }
377
378 else{
379
380 echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Local file ' . $field_group['key'] . '.json will be created upon update."></span>';
381
382 }
383
384
385
386 }
387
388 }
389
390 }
391 }
392
393 /**
394 * Table Row Actions
395 */
396 add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2);
397 function hwk_post_type_exemple_row_actions($actions, $post){
398
399 if(!isset($post->post_type) || $post->post_type != 'acf-field-group')
400 return $actions;
401
402 $field_group = acf_get_field_group($post->ID);
403
404 $actions['acfe-export-php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&keys=' . $field_group['key']) . '">PHP</a>';
405 $actions['acfe-export-json'] = '<span class="acfe-form" data-action="'.admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export').'"><input type="hidden" name="_acf_nonce" value="' . wp_create_nonce('export') . '" /><input type="hidden" name="action" value="download" /><input type="hidden" name="keys" value="' . $field_group['key'] . '" /><a href="#">Json</a></span>';
406 //$actions['acfe-id'] = '<span style="color:#555;">ID: ' . $field_group['ID'] . '</span>';
407 $actions['acfe-key'] = '<span style="color:#555;"><code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $field_group['key'] . '</code></span>';
408
409 return $actions;
410
411 }
412
413 /**
414 * Sidebar
415 */
416 add_action('current_screen', function(){
417
418 if(!acf_is_screen('edit-acf-field-group'))
419 return;
420
421 add_action('admin_footer', function(){
422 ?>
423
424 <!-- ACFE: Label -->
425 <script type="text/html" id="tmpl-acfe-label">
426 <span style="word-wrap: break-word;padding: 2px 6px;margin-left:1px;border-radius:2px;background:#ca4a1f;color: #fff; font-size: 14px;vertical-align: text-bottom;font-style: italic;">Extended</span>
427 </script>
428
429 <!-- ACFE: Debug -->
430 <script type="text/html" id="tmpl-acfe-debug">
431 <div class="acf-box">
432 </div>
433 </script>
434
435 <script type="text/javascript">
436 (function($){
437
438 // ACFE: Label
439 $('.acf-column-2 > .acf-box > .inner > h2').append($('#tmpl-acfe-label').html());
440
441 // ACFE: Debug
442 //$('#posts-filter').append($('#tmpl-acfe-debug').html());
443
444
445 // Fix no field groups found
446 $('#the-list tr.no-items td').attr('colspan', 9);
447
448 // ACFE: Table Row Actions - Export Wrap Form
449 $('.acfe-export-json .acfe-form').each(function(k, v){
450 $(this).wrapAll('<form action="' + $(this).attr('data-action') + '" method="post" style="display:inline;"></form>');
451 });
452
453 // ACFE: Table Row Actions - Export Submit Form
454 $('.acfe-export-json a').click(function(e){
455 e.preventDefault();
456 $(this).closest('form').submit();
457 });
458 })(jQuery);
459 </script>
460 <?php
461 });
462
463 });
464
465 /**
466 * Hooks: Posts per page
467 */
468 add_filter('edit_acf-field-group_per_page', 'acfe_field_groups_posts_per_page');
469 function acfe_field_groups_posts_per_page(){
470
471 return 999;
472
473 }