PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8
Advanced Custom Fields: Extended v0.8
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 / modules / dynamic-block-type.php
acf-extended / includes / modules Last commit date
form 6 years ago author.php 6 years ago autosync.php 6 years ago dev.php 6 years ago dynamic-block-type.php 6 years ago dynamic-form.php 6 years ago dynamic-options-page.php 6 years ago dynamic-post-type.php 6 years ago dynamic-taxonomy.php 6 years ago taxonomy.php 6 years ago
dynamic-block-type.php
1327 lines
1 <?php
2
3 if(!defined('ABSPATH'))
4 exit;
5
6 // Check setting
7 if(!acf_get_setting('acfe/modules/dynamic_block_types'))
8 return;
9
10 /**
11 * Require ACF Pro 5.8
12 */
13 if(version_compare(ACF_VERSION, '5.8', '<'))
14 return;
15
16 /**
17 * Register Dynamic Block Type
18 */
19 add_action('init', 'acfe_dbt_register');
20 function acfe_dbt_register(){
21
22 register_post_type('acfe-dbt', array(
23 'label' => 'Block Type',
24 'description' => 'Block Type',
25 'labels' => array(
26 'name' => 'Block Types',
27 'singular_name' => 'Block Type',
28 'menu_name' => 'Block Types',
29 'edit_item' => 'Edit Block Type',
30 'add_new_item' => 'New Block Type',
31 ),
32 'supports' => false,
33 'hierarchical' => false,
34 'public' => false,
35 'show_ui' => true,
36 'show_in_menu' => false,
37 'menu_icon' => 'dashicons-layout',
38 'show_in_admin_bar' => false,
39 'show_in_nav_menus' => false,
40 'can_export' => false,
41 'has_archive' => false,
42 'rewrite' => false,
43 'exclude_from_search' => true,
44 'publicly_queryable' => false,
45 'capabilities' => array(
46 'publish_posts' => acf_get_setting('capability'),
47 'edit_posts' => acf_get_setting('capability'),
48 'edit_others_posts' => acf_get_setting('capability'),
49 'delete_posts' => acf_get_setting('capability'),
50 'delete_others_posts' => acf_get_setting('capability'),
51 'read_private_posts' => acf_get_setting('capability'),
52 'edit_post' => acf_get_setting('capability'),
53 'delete_post' => acf_get_setting('capability'),
54 'read_post' => acf_get_setting('capability'),
55 )
56 ));
57
58 }
59
60 /**
61 * Dynamic Block Type Menu
62 */
63 add_action('admin_menu', 'acfe_dbt_menu');
64 function acfe_dbt_menu(){
65
66 if(!acf_get_setting('show_admin'))
67 return;
68
69 add_submenu_page('edit.php?post_type=acf-field-group', __('Block Types'), __('Block Types'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dbt');
70
71 }
72
73 /**
74 * Dynamic Block Type Menu: Parent Highlight
75 */
76 add_filter('parent_file', 'acfe_dbt_menu_parent_highlight');
77 function acfe_dbt_menu_parent_highlight($parent_file){
78
79 global $pagenow;
80 if($pagenow !== 'post.php' && $pagenow !== 'post-new.php')
81 return $parent_file;
82
83 $post_type = get_post_type();
84 if($post_type != 'acfe-dbt')
85 return $parent_file;
86
87 return 'edit.php?post_type=acf-field-group';
88
89 }
90
91 /**
92 * Dynamic Block Type Menu: Submenu Highlight
93 */
94 add_filter('submenu_file', 'acfe_dbt_menu_sub_highlight');
95 function acfe_dbt_menu_sub_highlight($submenu_file){
96
97 global $pagenow;
98 if($pagenow != 'post-new.php')
99 return $submenu_file;
100
101 $post_type = get_post_type();
102 if($post_type != 'acfe-dbt')
103 return $submenu_file;
104
105 return 'edit.php?post_type=acfe-dbt';
106
107 }
108
109 /**
110 * ACF Register Block Types
111 */
112 add_action('init', 'acfe_dbt_registers');
113 function acfe_dbt_registers(){
114
115 $dynamic_block_types = get_option('acfe_dynamic_block_types', array());
116 if(empty($dynamic_block_types))
117 return;
118
119 foreach($dynamic_block_types as $name => $register_args){
120
121 // Register: Execute
122 acf_register_block_type($register_args);
123
124 }
125
126 }
127
128 /**
129 * ACF Exclude Dynamic Options Page from available post types
130 */
131 add_filter('acf/get_post_types', 'acfe_dbt_exclude', 10, 2);
132 function acfe_dbt_exclude($post_types, $args){
133
134 if(empty($post_types))
135 return $post_types;
136
137 foreach($post_types as $k => $post_type){
138
139 if($post_type !== 'acfe-dbt')
140 continue;
141
142 unset($post_types[$k]);
143
144 }
145
146 return $post_types;
147
148 }
149
150 /**
151 * Dynamic Block Types Save
152 */
153 add_action('acf/save_post', 'acfe_dbt_filter_save', 20);
154 function acfe_dbt_filter_save($post_id){
155
156 if(get_post_type($post_id) != 'acfe-dbt')
157 return;
158
159 $title = get_field('title', $post_id);
160 $name = get_field('name', $post_id);
161
162 // Update post
163 wp_update_post(array(
164 'ID' => $post_id,
165 'post_title' => $title,
166 'post_name' => $name,
167 ));
168
169 // Register Args
170 $name = get_field('name', $post_id);
171 $title = get_field('title', $post_id);
172 $description = get_field('description', $post_id);
173 $category = get_field('category', $post_id);
174 $keywords = acf_decode_choices(get_field('keywords', $post_id), true);
175 $post_types = acf_get_array(get_field('post_types', $post_id));
176 $mode = get_field('mode', $post_id);
177 $align = get_field('align', $post_id);
178 $render_template = get_field('render_template', $post_id);
179 $render_callback = get_field('render_callback', $post_id);
180 $enqueue_style = get_field('enqueue_style', $post_id);
181 $enqueue_script = get_field('enqueue_script', $post_id);
182 $enqueue_assets = get_field('enqueue_assets', $post_id);
183
184 // Render Template
185 if(!empty($render_template))
186 $render_template = ACFE_THEME_PATH . '/' . $render_template;
187
188 // Enqueue Style
189 if(!empty($enqueue_style))
190 $enqueue_style = ACFE_THEME_URL . '/' . $enqueue_style;
191
192 // Enqueue Script
193 if(!empty($enqueue_script))
194 $enqueue_script = ACFE_THEME_URL . '/' . $enqueue_script;
195
196 // Register: Args
197 $register_args = array(
198 'name' => $name,
199 'title' => $title,
200 'description' => $description,
201 'category' => $category,
202 'keywords' => $keywords,
203 'post_types' => $post_types,
204 'mode' => $mode,
205 'align' => $align,
206 'render_template' => $render_template,
207 'render_callback' => $render_callback,
208 'enqueue_style' => $enqueue_style,
209 'enqueue_script' => $enqueue_script,
210 'enqueue_assets' => $enqueue_assets
211 );
212
213 // Align
214 if($align == 'none')
215 $register_args['align'] = '';
216
217 // Icon
218 $icon_type = get_field('icon_type', $post_id);
219
220 // Icon: Simple
221 if($icon_type == 'simple'){
222
223 $icon_text = get_field('icon_text', $post_id);
224
225 $register_args['icon'] = $icon_text;
226
227 }
228
229 // Icon: Colors
230 elseif($icon_type == 'colors'){
231
232 $icon_background = get_field('icon_background', $post_id);
233 $icon_foreground = get_field('icon_foreground', $post_id);
234 $icon_src = get_field('icon_src', $post_id);
235
236 $register_args['icon'] = array(
237 'background' => $icon_background,
238 'foreground' => $icon_foreground,
239 'src' => $icon_src,
240 );
241
242
243 }
244
245 // Supports: Align
246 $supports_align = get_field('supports_align', $post_id);
247 $supports_align_args = acf_decode_choices(get_field('supports_align_args', $post_id), true);
248
249 $register_args['supports']['align'] = false;
250 if(!empty($supports_align)){
251
252 $register_args['supports']['align'] = true;
253
254 if(!empty($supports_align_args))
255 $register_args['supports']['align'] = $supports_align_args;
256
257 }
258
259 // Supports: Mode
260 $supports_mode = get_field('supports_mode', $post_id);
261
262 $register_args['supports']['mode'] = false;
263 if(!empty($supports_mode))
264 $register_args['supports']['mode'] = true;
265
266 // Supports: Multiple
267 $supports_multiple = get_field('supports_multiple', $post_id);
268
269 $register_args['supports']['multiple'] = false;
270 if(!empty($supports_multiple))
271 $register_args['supports']['multiple'] = true;
272
273
274 // Get ACFE option
275 $option = get_option('acfe_dynamic_block_types', array());
276
277 // Create ACFE option
278 $option[$name] = $register_args;
279
280 // Sort keys ASC
281 ksort($option);
282
283 // Update ACFE option
284 update_option('acfe_dynamic_block_types', $option);
285
286 }
287
288 /**
289 * Dynamic Block Type Status Publish > Trash
290 */
291 add_action('publish_to_trash', 'acfe_dbt_filter_status_trash');
292 function acfe_dbt_filter_status_trash($post){
293
294 if(get_post_type($post->ID) != 'acfe-dbt')
295 return;
296
297 $post_id = $post->ID;
298 $name = get_field('name', $post_id);
299
300 // Get ACFE option
301 $option = get_option('acfe_dynamic_block_types', array());
302
303 // Check ACFE option
304 if(isset($option[$name]))
305 unset($option[$name]);
306
307 // Update ACFE option
308 update_option('acfe_dynamic_block_types', $option);
309
310 }
311
312 /**
313 * Dynamic Block Type Status Trash > Publish
314 */
315 add_action('trash_to_publish', 'acfe_dbt_filter_status_publish');
316 function acfe_dbt_filter_status_publish($post){
317
318 if(get_post_type($post->ID) != 'acfe-dbt')
319 return;
320
321 acfe_dop_filter_save($post->ID);
322
323 }
324
325 /**
326 * Dynamic Block Type Admin: List
327 */
328 add_action('pre_get_posts', 'acfe_dbt_admin_pre_get_posts');
329 function acfe_dbt_admin_pre_get_posts($query){
330
331 if(!is_admin() || !$query->is_main_query())
332 return;
333
334 global $pagenow;
335 if($pagenow != 'edit.php')
336 return;
337
338 $post_type = $query->get('post_type');
339 if($post_type != 'acfe-dbt')
340 return;
341
342 $query->set('orderby', 'name');
343 $query->set('order', 'ASC');
344
345 }
346
347 /**
348 * Dynamic Block Type Admin: Posts Per Page
349 */
350 add_filter('edit_posts_per_page', 'acfe_dbt_admin_ppp', 10, 2);
351 function acfe_dbt_admin_ppp($ppp, $post_type){
352
353 if($post_type != 'acfe-dbt')
354 return $ppp;
355
356 global $pagenow;
357 if($pagenow != 'edit.php')
358 return $ppp;
359
360 return 999;
361
362 }
363
364 /**
365 * Admin List Columns
366 */
367 add_filter('manage_edit-acfe-dbt_columns', 'acfe_dbt_admin_columns');
368 function acfe_dbt_admin_columns($columns){
369
370 if(isset($columns['date']))
371 unset($columns['date']);
372
373 $columns['name'] = __('Name');
374 $columns['category'] = __('Category');
375 $columns['post_types'] = __('Post Types');
376 $columns['render'] = __('Render');
377
378 return $columns;
379
380 }
381
382 /**
383 * Admin List Columns HTML
384 */
385 add_action('manage_acfe-dbt_posts_custom_column', 'acfe_dbt_admin_columns_html', 10, 2);
386 function acfe_dbt_admin_columns_html($column, $post_id){
387
388 // Name
389 if($column == 'name'){
390
391 echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . get_field('name', $post_id) . '</code>';
392
393 }
394
395 // Category
396 elseif($column == 'category'){
397
398 echo ucfirst(get_field('category', $post_id));
399
400 }
401
402 // Post Types
403 elseif($column == 'post_types'){
404
405 $post_types = get_field('post_types', $post_id);
406
407 if(empty($post_types)){
408 echo '';
409 return;
410 }
411
412 $post_types_names = array();
413 foreach($post_types as $post_type_slug){
414 $post_type_obj = get_post_type_object($post_type_slug);
415 $post_types_names[] = $post_type_obj->label;
416 }
417
418 if(empty($post_types_names)){
419 echo '';
420 return;
421 }
422
423 echo implode(', ', $post_types_names);
424
425 }
426
427 // Render
428 elseif($column == 'render'){
429
430 $render_template = get_field('render_template', $post_id);
431 $render_callback = get_field('render_callback', $post_id);
432
433 if(!empty($render_template)){
434
435 echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">/' . $render_template . '</code>';
436
437 }
438
439 elseif(!empty($render_callback)){
440
441 echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $render_callback . '</code>';
442
443 }
444
445 else{
446
447 echo '';
448
449 }
450
451 }
452
453 }
454
455 /**
456 * Admin List Row Actions
457 */
458 add_filter('post_row_actions','acfe_dbt_admin_row', 10, 2);
459 function acfe_dbt_admin_row($actions, $post){
460
461 if($post->post_type != 'acfe-dbt' || $post->post_status != 'publish')
462 return $actions;
463
464 $post_id = $post->ID;
465 $name = get_field('name', $post_id);
466
467 $actions['acfe_dpt_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dbt_export&keys=' . $name) . '">' . __('Json') . '</a>';
468
469 return $actions;
470
471 }
472
473 /**
474 * Admin Disable Name
475 */
476 add_filter('acf/prepare_field/key=field_acfe_dbt_name', 'acfe_dbt_admin_disable_name');
477 function acfe_dbt_admin_disable_name($field){
478
479 global $pagenow;
480 if($pagenow !== 'post.php')
481 return $field;
482
483 $field['disabled'] = true;
484
485 return $field;
486
487 }
488
489 add_action('load-post.php', 'acfe_dbt_load');
490 function acfe_dbt_load(){
491
492 // globals
493 global $typenow;
494
495 // Restrict
496 if($typenow !== 'acfe-dbt')
497 return;
498
499 add_action('add_meta_boxes', 'acfe_dbt_load_meta_boxes');
500
501 }
502
503 function acfe_dbt_load_meta_boxes(){
504
505 $name = get_field('name', get_the_ID());
506
507 $data = acf_get_field_groups(array(
508 'block' => 'acf/' . $name
509 ));
510
511 if(empty($data))
512 return;
513
514 add_meta_box(
515
516 // ID
517 'acfe-dbt-field-groups',
518
519 // Title
520 __('Field groups', 'acf'),
521
522 // Render
523 'acfe_dbt_load_meta_boxes_render',
524
525 // Screen
526 'acfe-dbt',
527
528 // Position
529 'normal',
530
531 // Priority
532 'default',
533
534 // Data
535 $data
536
537 );
538
539 }
540
541 function acfe_dbt_load_meta_boxes_render($array, $data){
542
543 $data = $data['args'];
544
545 foreach($data as $field_group){ ?>
546
547 <div class="acf-field">
548
549 <div class="acf-label">
550 <label for="acf-_post_title"><a href="<?php echo admin_url('post.php?post=' . $field_group['ID'] . '&action=edit'); ?>"><?php echo $field_group['title']; ?></a></label>
551 <p class="description"><?php echo $field_group['key']; ?></p>
552 </div>
553
554 <div class="acf-input">
555 <?php $fields = acf_get_fields($field_group); ?>
556
557 <?php if(!empty($fields)){ ?>
558
559 <table class="acf-table">
560 <thead>
561 <th class="acf-th" width="25%"><strong>Label</strong></th>
562 <th class="acf-th" width="25%"><strong>Name</strong></th>
563 <th class="acf-th" width="25%"><strong>Key</strong></th>
564 <th class="acf-th" width="25%"><strong>Type</strong></th>
565 </thead>
566
567 <tbody>
568 <?php
569
570 $array = array();
571 foreach($fields as $field){
572
573 acfe_dbt_get_fields_labels_recursive($array, $field);
574
575 }
576
577 foreach($array as $field_key => $field_label){
578
579 $field = acf_get_field($field_key);
580 $type = acf_get_field_type($field['type']);
581 $type_label = '-';
582 if(isset($type->label))
583 $type_label = $type->label;
584 ?>
585
586 <tr class="acf-row">
587 <td width="25%"><?php echo $field_label; ?></td>
588 <td width="25%"><?php echo $field['name']; ?></td>
589 <td width="25%"><code><?php echo $field_key; ?></code></td>
590 <td width="25%"><?php echo $type_label; ?></td>
591 </tr>
592
593 <?php } ?>
594 </tbody>
595 </table>
596
597 <?php } ?>
598 </div>
599
600 </div>
601
602 <?php } ?>
603
604 <script type="text/javascript">
605 if(typeof acf !== 'undefined'){
606
607 acf.newPostbox(<?php echo wp_json_encode(array(
608 'id' => 'acfe-dbt-field-groups',
609 'key' => '',
610 'style' => 'default',
611 'label' => 'left',
612 'edit' => false
613 )); ?>);
614
615 }
616 </script>
617 <?php
618
619 }
620
621 function acfe_dbt_get_fields_labels_recursive(&$array, $field){
622
623 $label = '';
624
625 $ancestors = isset($field['ancestors']) ? $field['ancestors'] : count(acf_get_field_ancestors($field));
626 $label = str_repeat('- ', $ancestors) . $label;
627
628 $label .= !empty($field['label']) ? $field['label'] : '(' . __('no label', 'acf') . ')';
629 $label .= $field['required'] ? ' <span class="acf-required">*</span>' : '';
630
631 $array[$field['key']] = $label;
632
633 if(isset($field['sub_fields']) && !empty($field['sub_fields'])){
634
635 foreach($field['sub_fields'] as $s_field){
636
637 acfe_dbt_get_fields_labels_recursive($array, $s_field);
638
639 }
640
641 }
642
643 }
644
645 /**
646 * Add Local Field Group
647 */
648 acf_add_local_field_group(array(
649 'key' => 'group_acfe_dynamic_block_type',
650 'title' => __('Dynamic Block Type', 'acfe'),
651
652 'location' => array(
653 array(
654 array(
655 'param' => 'post_type',
656 'operator' => '==',
657 'value' => 'acfe-dbt',
658 ),
659 ),
660 ),
661
662 'menu_order' => 0,
663 'position' => 'normal',
664 'style' => 'default',
665 'label_placement' => 'left',
666 'instruction_placement' => 'label',
667 'hide_on_screen' => '',
668 'active' => 1,
669 'description' => '',
670
671 'fields' => array(
672 array(
673 'key' => 'field_acfe_dbt_tab_general',
674 'label' => 'General',
675 'name' => '',
676 'type' => 'tab',
677 'instructions' => '',
678 'required' => 0,
679 'conditional_logic' => 0,
680 'wrapper' => array(
681 'width' => '',
682 'class' => '',
683 'id' => '',
684 ),
685 'acfe_validate' => '',
686 'acfe_update' => '',
687 'acfe_permissions' => '',
688 'placement' => 'top',
689 'endpoint' => 0,
690 ),
691 array(
692 'key' => 'field_acfe_dbt_title',
693 'label' => 'Title',
694 'name' => 'title',
695 'type' => 'text',
696 'instructions' => '(String) The display title for your block.',
697 'required' => 1,
698 'conditional_logic' => 0,
699 'wrapper' => array(
700 'width' => '',
701 'class' => '',
702 'id' => '',
703 ),
704 'acfe_validate' => '',
705 'acfe_update' => '',
706 'acfe_permissions' => '',
707 'default_value' => '',
708 'placeholder' => '',
709 'prepend' => '',
710 'append' => '',
711 'maxlength' => '',
712 ),
713 array(
714 'key' => 'field_acfe_dbt_name',
715 'label' => 'Name',
716 'name' => 'name',
717 'type' => 'acfe_slug',
718 'instructions' => '(String) A unique name that identifies the block (without namespace).<br />
719 Note: A block name can only contain lowercase alphanumeric characters and dashes, and must begin with a letter.',
720 'required' => 1,
721 'conditional_logic' => 0,
722 'wrapper' => array(
723 'width' => '',
724 'class' => '',
725 'id' => '',
726 ),
727 'acfe_validate' => '',
728 'acfe_update' => array(
729 '5cd2ca4caa18b' => array(
730 'acfe_update_function' => 'sanitize_title',
731 ),
732 ),
733 'acfe_permissions' => '',
734 'default_value' => '',
735 'placeholder' => '',
736 'prepend' => '',
737 'append' => '',
738 'maxlength' => '',
739 ),
740 array(
741 'key' => 'field_acfe_dbt_description',
742 'label' => 'Description',
743 'name' => 'description',
744 'type' => 'textarea',
745 'instructions' => '(String) (Optional) This is a short description for your block.',
746 'required' => 0,
747 'conditional_logic' => 0,
748 'wrapper' => array(
749 'width' => '',
750 'class' => '',
751 'id' => '',
752 ),
753 'acfe_validate' => '',
754 'acfe_update' => '',
755 'acfe_permissions' => '',
756 'default_value' => '',
757 'placeholder' => '',
758 'maxlength' => '',
759 'rows' => 3,
760 'new_lines' => '',
761 ),
762 array(
763 'key' => 'field_acfe_dbt_category',
764 'label' => 'Category',
765 'name' => 'category',
766 'type' => 'text',
767 'instructions' => '(String) Blocks are grouped into categories to help users browse and discover them. The core provided categories are [ common | formatting | layout | widgets | embed ]. Plugins and Themes can also register custom block categories.',
768 'required' => 0,
769 'conditional_logic' => 0,
770 'wrapper' => array(
771 'width' => '',
772 'class' => '',
773 'id' => '',
774 ),
775 'acfe_validate' => '',
776 'acfe_update' => '',
777 'acfe_permissions' => '',
778 'default_value' => 'common',
779 'placeholder' => '',
780 'prepend' => '',
781 'append' => '',
782 'maxlength' => '',
783 ),
784 array(
785 'key' => 'field_acfe_dbt_keywords',
786 'label' => 'Keywords',
787 'name' => 'keywords',
788 'type' => 'textarea',
789 'instructions' => '(Array) (Optional) An array of search terms to help user discover the block while searching.<br />
790 One line for each keyword. ie:<br /><br />
791 quote<br />
792 mention<br />
793 cite',
794 'required' => 0,
795 'conditional_logic' => 0,
796 'wrapper' => array(
797 'width' => '',
798 'class' => '',
799 'id' => '',
800 ),
801 'acfe_validate' => '',
802 'acfe_update' => '',
803 'acfe_permissions' => '',
804 'default_value' => '',
805 'placeholder' => '',
806 'maxlength' => '',
807 'rows' => '',
808 'new_lines' => '',
809 ),
810 array(
811 'key' => 'field_acfe_dbt_post_types',
812 'label' => 'Post types',
813 'name' => 'post_types',
814 'type' => 'acfe_post_types',
815 'instructions' => '(Array) (Optional) An array of post types to restrict this block type to.',
816 'required' => 0,
817 'conditional_logic' => 0,
818 'wrapper' => array(
819 'width' => '',
820 'class' => '',
821 'id' => '',
822 ),
823 'acfe_validate' => '',
824 'acfe_update' => '',
825 'acfe_permissions' => '',
826 'field_type' => 'checkbox',
827 'return_format' => 'name',
828 ),
829 array(
830 'key' => 'field_acfe_dbt_mode',
831 'label' => 'Mode',
832 'name' => 'mode',
833 'type' => 'select',
834 'instructions' => '(String) (Optional) The display mode for your block. Available settings are “auto”, “preview” and “edit”. Defaults to “auto”.<br /><br />
835 auto: Preview is shown by default but changes to edit form when block is selected.<br />
836 preview: Preview is always shown. Edit form appears in sidebar when block is selected.<br />
837 edit: Edit form is always shown.<br /><br />
838
839 Note. When in “preview” or “edit” modes, an icon will appear in the block toolbar to toggle between modes.',
840 'required' => 0,
841 'conditional_logic' => 0,
842 'wrapper' => array(
843 'width' => '',
844 'class' => '',
845 'id' => '',
846 ),
847 'acfe_validate' => '',
848 'acfe_update' => '',
849 'acfe_permissions' => '',
850 'choices' => array(
851 'auto' => 'Auto',
852 'preview' => 'Preview',
853 'edit' => 'Edit',
854 ),
855 'default_value' => array(
856 0 => 'auto',
857 ),
858 'allow_null' => 0,
859 'multiple' => 0,
860 'ui' => 0,
861 'return_format' => 'value',
862 'ajax' => 0,
863 'placeholder' => '',
864 ),
865 array(
866 'key' => 'field_acfe_dbt_align',
867 'label' => 'Align',
868 'name' => 'align',
869 'type' => 'select',
870 'instructions' => '(String) (Optional) The default block alignment. Available settings are “left”, “center”, “right”, “wide” and “full”. Defaults to an empty string.',
871 'required' => 0,
872 'conditional_logic' => 0,
873 'wrapper' => array(
874 'width' => '',
875 'class' => '',
876 'id' => '',
877 ),
878 'acfe_validate' => '',
879 'acfe_update' => '',
880 'acfe_permissions' => '',
881 'choices' => array(
882 'none' => 'None',
883 'left' => 'Left',
884 'center' => 'Center',
885 'right' => 'Right',
886 'wide' => 'Wide',
887 'full' => 'Full',
888 ),
889 'default_value' => array(
890 ),
891 'allow_null' => 0,
892 'multiple' => 0,
893 'ui' => 0,
894 'return_format' => 'value',
895 'ajax' => 0,
896 'placeholder' => '',
897 ),
898 array(
899 'key' => 'field_acfe_dbt_tab_icon',
900 'label' => 'Icon',
901 'name' => '',
902 'type' => 'tab',
903 'instructions' => '',
904 'required' => 0,
905 'conditional_logic' => 0,
906 'wrapper' => array(
907 'width' => '',
908 'class' => '',
909 'id' => '',
910 ),
911 'acfe_validate' => '',
912 'acfe_update' => '',
913 'acfe_permissions' => '',
914 'placement' => 'top',
915 'endpoint' => 0,
916 ),
917 array(
918 'key' => 'field_acfe_dbt_icon_type',
919 'label' => 'Icon Type',
920 'name' => 'icon_type',
921 'type' => 'select',
922 'instructions' => 'Simple: Specify a Dashicons class or SVG path<br />
923 Colors: Specify colors & Dashicons class',
924 'required' => 0,
925 'conditional_logic' => 0,
926 'wrapper' => array(
927 'width' => '',
928 'class' => '',
929 'id' => '',
930 ),
931 'acfe_validate' => '',
932 'acfe_update' => '',
933 'acfe_permissions' => '',
934 'choices' => array(
935 'simple' => 'Simple',
936 'colors' => 'Colors',
937 ),
938 'default_value' => array(
939 ),
940 'allow_null' => 0,
941 'multiple' => 0,
942 'ui' => 0,
943 'return_format' => 'value',
944 'ajax' => 0,
945 'placeholder' => '',
946 ),
947 array(
948 'key' => 'field_acfe_dbt_icon_text',
949 'label' => 'Icon',
950 'name' => 'icon_text',
951 'type' => 'text',
952 'instructions' => '(String) (Optional) An icon property can be specified to make it easier to identify a block. These can be any of WordPress’ Dashicons, or a custom svg element.',
953 'required' => 0,
954 'conditional_logic' => array(
955 array(
956 array(
957 'field' => 'field_acfe_dbt_icon_type',
958 'operator' => '==',
959 'value' => 'simple',
960 ),
961 ),
962 ),
963 'wrapper' => array(
964 'width' => '',
965 'class' => '',
966 'id' => '',
967 ),
968 'acfe_validate' => '',
969 'acfe_update' => '',
970 'acfe_permissions' => '',
971 'default_value' => '',
972 'placeholder' => '',
973 'prepend' => '',
974 'append' => '',
975 'maxlength' => '',
976 ),
977 array(
978 'key' => 'field_acfe_dbt_icon_background',
979 'label' => 'Icon background',
980 'name' => 'icon_background',
981 'type' => 'color_picker',
982 'instructions' => 'Specifying a background color to appear with the icon e.g.: in the inserter.',
983 'required' => 0,
984 'conditional_logic' => array(
985 array(
986 array(
987 'field' => 'field_acfe_dbt_icon_type',
988 'operator' => '==',
989 'value' => 'colors',
990 ),
991 ),
992 ),
993 'wrapper' => array(
994 'width' => '',
995 'class' => '',
996 'id' => '',
997 ),
998 'acfe_validate' => '',
999 'acfe_update' => '',
1000 'acfe_permissions' => '',
1001 'default_value' => '',
1002 ),
1003 array(
1004 'key' => 'field_acfe_dbt_icon_foreground',
1005 'label' => 'Icon foreground',
1006 'name' => 'icon_foreground',
1007 'type' => 'color_picker',
1008 'instructions' => 'Specifying a color for the icon (optional: if not set, a readable color will be automatically defined)',
1009 'required' => 0,
1010 'conditional_logic' => array(
1011 array(
1012 array(
1013 'field' => 'field_acfe_dbt_icon_type',
1014 'operator' => '==',
1015 'value' => 'colors',
1016 ),
1017 ),
1018 ),
1019 'wrapper' => array(
1020 'width' => '',
1021 'class' => '',
1022 'id' => '',
1023 ),
1024 'acfe_validate' => '',
1025 'acfe_update' => '',
1026 'acfe_permissions' => '',
1027 'default_value' => '',
1028 ),
1029 array(
1030 'key' => 'field_acfe_dbt_icon_src',
1031 'label' => 'Icon src',
1032 'name' => 'icon_src',
1033 'type' => 'text',
1034 'instructions' => 'Specifying a dashicon for the block',
1035 'required' => 0,
1036 'conditional_logic' => array(
1037 array(
1038 array(
1039 'field' => 'field_acfe_dbt_icon_type',
1040 'operator' => '==',
1041 'value' => 'colors',
1042 ),
1043 ),
1044 ),
1045 'wrapper' => array(
1046 'width' => '',
1047 'class' => '',
1048 'id' => '',
1049 ),
1050 'acfe_validate' => '',
1051 'acfe_update' => '',
1052 'acfe_permissions' => '',
1053 'default_value' => '',
1054 'placeholder' => '',
1055 'prepend' => '',
1056 'append' => '',
1057 'maxlength' => '',
1058 ),
1059 array(
1060 'key' => 'field_acfe_dbt_tab_render',
1061 'label' => 'Render',
1062 'name' => '',
1063 'type' => 'tab',
1064 'instructions' => '',
1065 'required' => 0,
1066 'conditional_logic' => 0,
1067 'wrapper' => array(
1068 'width' => '',
1069 'class' => '',
1070 'id' => '',
1071 ),
1072 'acfe_validate' => '',
1073 'acfe_update' => '',
1074 'acfe_permissions' => '',
1075 'placement' => 'top',
1076 'endpoint' => 0,
1077 ),
1078 array(
1079 'key' => 'field_acfe_dbt_render_template',
1080 'label' => 'Render template',
1081 'name' => 'render_template',
1082 'type' => 'text',
1083 'instructions' => '(String) The path to a template file used to render the block HTML. This can either be a relative path to a file within the active theme or a full path to any file.',
1084 'required' => 0,
1085 'conditional_logic' => 0,
1086 'wrapper' => array(
1087 'width' => '',
1088 'class' => '',
1089 'id' => '',
1090 ),
1091 'acfe_validate' => '',
1092 'acfe_update' => '',
1093 'acfe_permissions' => '',
1094 'default_value' => '',
1095 'placeholder' => '',
1096 'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
1097 'append' => '',
1098 'maxlength' => '',
1099 ),
1100 array(
1101 'key' => 'field_acfe_dbt_render_callback',
1102 'label' => 'Render callback',
1103 'name' => 'render_callback',
1104 'type' => 'text',
1105 'instructions' => '(Callable) (Optional) Instead of providing a render_template, a callback function name may be specified to output the block’s HTML.',
1106 'required' => 0,
1107 'conditional_logic' => 0,
1108 'wrapper' => array(
1109 'width' => '',
1110 'class' => '',
1111 'id' => '',
1112 ),
1113 'acfe_validate' => '',
1114 'acfe_update' => '',
1115 'acfe_permissions' => '',
1116 'default_value' => '',
1117 'placeholder' => '',
1118 'prepend' => '',
1119 'append' => '',
1120 'maxlength' => '',
1121 ),
1122 array(
1123 'key' => 'field_acfe_dbt_tab_enqueue',
1124 'label' => 'Enqueue',
1125 'name' => '',
1126 'type' => 'tab',
1127 'instructions' => '',
1128 'required' => 0,
1129 'conditional_logic' => 0,
1130 'wrapper' => array(
1131 'width' => '',
1132 'class' => '',
1133 'id' => '',
1134 ),
1135 'acfe_validate' => '',
1136 'acfe_update' => '',
1137 'acfe_permissions' => '',
1138 'placement' => 'top',
1139 'endpoint' => 0,
1140 ),
1141 array(
1142 'key' => 'field_acfe_dbt_enqueue_style',
1143 'label' => 'Enqueue style',
1144 'name' => 'enqueue_style',
1145 'type' => 'text',
1146 'instructions' => '(String) (Optional) The url to a .css file to be enqueued whenever your block is displayed (front-end and back-end).',
1147 'required' => 0,
1148 'conditional_logic' => 0,
1149 'wrapper' => array(
1150 'width' => '',
1151 'class' => '',
1152 'id' => '',
1153 ),
1154 'acfe_validate' => '',
1155 'acfe_update' => '',
1156 'acfe_permissions' => '',
1157 'default_value' => '',
1158 'placeholder' => '',
1159 'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
1160 'append' => '',
1161 'maxlength' => '',
1162 ),
1163 array(
1164 'key' => 'field_acfe_dbt_enqueue_script',
1165 'label' => 'Enqueue script',
1166 'name' => 'enqueue_script',
1167 'type' => 'text',
1168 'instructions' => '(String) (Optional) The url to a .js file to be enqueued whenever your block is displayed (front-end and back-end).',
1169 'required' => 0,
1170 'conditional_logic' => 0,
1171 'wrapper' => array(
1172 'width' => '',
1173 'class' => '',
1174 'id' => '',
1175 ),
1176 'acfe_validate' => '',
1177 'acfe_update' => '',
1178 'acfe_permissions' => '',
1179 'default_value' => '',
1180 'placeholder' => '',
1181 'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
1182 'append' => '',
1183 'maxlength' => '',
1184 ),
1185 array(
1186 'key' => 'field_acfe_dbt_enqueue_assets',
1187 'label' => 'Enqueue assets',
1188 'name' => 'enqueue_assets',
1189 'type' => 'text',
1190 'instructions' => '(Callable) (Optional) A callback function that runs whenever your block is displayed (front-end and back-end) and enqueues scripts and/or styles.',
1191 'required' => 0,
1192 'conditional_logic' => 0,
1193 'wrapper' => array(
1194 'width' => '',
1195 'class' => '',
1196 'id' => '',
1197 ),
1198 'acfe_validate' => '',
1199 'acfe_update' => '',
1200 'acfe_permissions' => '',
1201 'default_value' => '',
1202 'placeholder' => '',
1203 'prepend' => '',
1204 'append' => '',
1205 'maxlength' => '',
1206 ),
1207 array(
1208 'key' => 'field_acfe_dbt_tab_supports',
1209 'label' => 'Supports',
1210 'name' => '',
1211 'type' => 'tab',
1212 'instructions' => '',
1213 'required' => 0,
1214 'conditional_logic' => 0,
1215 'wrapper' => array(
1216 'width' => '',
1217 'class' => '',
1218 'id' => '',
1219 ),
1220 'acfe_validate' => '',
1221 'acfe_update' => '',
1222 'acfe_permissions' => '',
1223 'placement' => 'top',
1224 'endpoint' => 0,
1225 ),
1226 array(
1227 'key' => 'field_acfe_dbt_supports_align',
1228 'label' => 'Align',
1229 'name' => 'supports_align',
1230 'type' => 'true_false',
1231 'instructions' => 'This property adds block controls which allow the user to change the block’s alignment. Defaults to true. Set to false to hide the alignment toolbar. Set to an array of specific alignment names to customize the toolbar.',
1232 'required' => 0,
1233 'conditional_logic' => 0,
1234 'wrapper' => array(
1235 'width' => '',
1236 'class' => '',
1237 'id' => '',
1238 ),
1239 'acfe_validate' => '',
1240 'acfe_update' => '',
1241 'acfe_permissions' => '',
1242 'message' => '',
1243 'default_value' => 1,
1244 'ui' => 1,
1245 'ui_on_text' => 'True',
1246 'ui_off_text' => 'False',
1247 ),
1248 array(
1249 'key' => 'field_acfe_dbt_supports_align_args',
1250 'label' => 'Align arguments',
1251 'name' => 'supports_align_args',
1252 'type' => 'textarea',
1253 'instructions' => 'Set to an array of specific alignment names to customize the toolbar.<br />
1254 One line for each name. ie:<br /><br />
1255 left<br />
1256 right<br />
1257 full',
1258 'required' => 0,
1259 'conditional_logic' => array(
1260 array(
1261 array(
1262 'field' => 'field_acfe_dbt_supports_align',
1263 'operator' => '==',
1264 'value' => '1',
1265 ),
1266 ),
1267 ),
1268 'wrapper' => array(
1269 'width' => '',
1270 'class' => '',
1271 'id' => '',
1272 ),
1273 'acfe_validate' => '',
1274 'acfe_update' => '',
1275 'acfe_permissions' => '',
1276 'default_value' => '',
1277 'placeholder' => '',
1278 'maxlength' => '',
1279 'rows' => '',
1280 'new_lines' => '',
1281 ),
1282 array(
1283 'key' => 'field_acfe_dbt_supports_mode',
1284 'label' => 'Mode',
1285 'name' => 'supports_mode',
1286 'type' => 'true_false',
1287 'instructions' => 'This property allows the user to toggle between edit and preview modes via a button. Defaults to true.',
1288 'required' => 0,
1289 'conditional_logic' => 0,
1290 'wrapper' => array(
1291 'width' => '',
1292 'class' => '',
1293 'id' => '',
1294 ),
1295 'acfe_validate' => '',
1296 'acfe_update' => '',
1297 'acfe_permissions' => '',
1298 'message' => '',
1299 'default_value' => 1,
1300 'ui' => 1,
1301 'ui_on_text' => 'True',
1302 'ui_off_text' => 'False',
1303 ),
1304 array(
1305 'key' => 'field_acfe_dbt_supports_multiple',
1306 'label' => 'Multiple',
1307 'name' => 'supports_multiple',
1308 'type' => 'true_false',
1309 'instructions' => 'This property allows the block to be added multiple times. Defaults to true.',
1310 'required' => 0,
1311 'conditional_logic' => 0,
1312 'wrapper' => array(
1313 'width' => '',
1314 'class' => '',
1315 'id' => '',
1316 ),
1317 'acfe_validate' => '',
1318 'acfe_update' => '',
1319 'acfe_permissions' => '',
1320 'message' => '',
1321 'default_value' => 1,
1322 'ui' => 1,
1323 'ui_on_text' => 'True',
1324 'ui_off_text' => 'False',
1325 ),
1326 ),
1327 ));