add_field_advanced_settings($fields); // Remove acfe_form }else{ $this->add_field_advanced_settings($fields, false); } } /* * Add Field Advanced Settings */ function add_field_advanced_settings($fields, $add = true){ if(empty($fields)) return; foreach($fields as $field){ // bypass clone if($field['type'] === 'clone') continue; // Group / Clone if(isset($field['sub_fields']) && !empty($field['sub_fields'])){ $this->add_field_advanced_settings($field['sub_fields'], $add); } // Flexible Content elseif(isset($field['layouts']) && !empty($field['layouts'])){ foreach($field['layouts'] as $layout){ if(isset($layout['sub_fields']) && !empty($layout['sub_fields'])){ $this->add_field_advanced_settings($layout['sub_fields'], $add); } } } // Add if($add){ if(acf_maybe_get($field, 'acfe_form')) continue; $field['acfe_form'] = true; // Remove }else{ if(!acf_maybe_get($field, 'acfe_form')) continue; acfe_unset($field, 'acfe_form'); acfe_unset($field, 'acfe_settings'); acfe_unset($field, 'acfe_validate'); } acf_update_field($field); } } /* * Advanced Settings */ function render_field_group_advanced_settings($field_group){ // Form settings acf_render_field_wrap(array( 'label' => __('Advanced settings'), 'name' => 'acfe_form', 'prefix' => 'acf_field_group', 'type' => 'true_false', 'ui' => 1, 'instructions' => __('Enable advanced fields settings & validation'), 'value' => (isset($field_group['acfe_form'])) ? $field_group['acfe_form'] : '', 'required' => false, 'wrapper' => array( 'data-after' => 'active' ) )); } /** * Metabox */ function render_field_group_settings(){ add_meta_box('acf-field-group-acfe', __('Field group', 'acf'), array($this, 'render_field_group_setting_metabox'), 'acf-field-group', 'normal'); add_meta_box('acf-field-group-acfe-side', __('Advanced Settings', 'acfe'), array($this, 'render_field_group_setting_sidebar_metabox'), 'acf-field-group', 'side'); } function render_field_group_setting_metabox(){ global $field_group; // Meta acf_render_field_wrap(array( 'label' => __('Custom meta data'), 'name' => 'acfe_meta', 'key' => 'acfe_meta', 'instructions' => __('Add custom meta data to the field group.'), 'prefix' => 'acf_field_group', 'type' => 'repeater', 'button_label' => __('+ Meta'), 'required' => false, 'layout' => 'table', 'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(), 'sub_fields' => array( array( 'ID' => false, 'label' => __('Key'), 'name' => 'acfe_meta_key', 'key' => 'acfe_meta_key', 'prefix' => '', '_name' => '', '_prepare' => '', 'type' => 'text', 'instructions' => false, 'required' => false, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), ), array( 'ID' => false, 'label' => __('Value'), 'name' => 'acfe_meta_value', 'key' => 'acfe_meta_value', 'prefix' => '', '_name' => '', '_prepare' => '', 'type' => 'text', 'instructions' => false, 'required' => false, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), ), ) )); // Data acf_render_field_wrap(array( 'label' => __('Field group data'), 'instructions' => __('View raw field group data, for development use'), 'type' => 'acfe_dynamic_message', 'name' => 'acfe_data', 'prefix' => 'acf_field_group', 'value' => $field_group['key'], )); // Note acf_render_field_wrap(array( 'label' => __('Note'), 'name' => 'acfe_note', 'prefix' => 'acf_field_group', 'type' => 'textarea', 'instructions' => __('Add personal note. Only visible to administrators'), 'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '', 'required' => false, )); ?> __('Display title', 'acfe'), 'instructions' => __('Render this title on edit post screen', 'acfe'), 'type' => 'text', 'name' => 'acfe_display_title', 'prefix' => 'acf_field_group', 'value' => acf_maybe_get($field_group, 'acfe_display_title'), 'placeholder' => '', 'prepend' => '', 'append' => '' )); /* * Sync available */ if(acfe_is_sync_available($field_group)){ $json_already_active = 0; if(in_array('json', acf_maybe_get($field_group, 'acfe_autosync', array()))) $json_already_active = 1; ?>
acf_get_instance('ACFE_Field_Groups')->get_php_data($field_group), 'json' => acf_get_instance('ACFE_Field_Groups')->get_json_data($field_group), ); acf_disable_filter('local'); /* * AutoSync: Values */ $acfe_autosync = (array) acf_maybe_get($field_group, 'acfe_autosync'); // Json if($json_file){ if(!in_array('json', $acfe_autosync)){ $acfe_autosync[] = 'json'; } } // PHP if($php_file){ if(!in_array('php', $acfe_autosync)){ $acfe_autosync[] = 'php'; } } /* * AutoSync: Choices */ $choices = array( 'php' => 'PHP', 'json' => 'Json', ); global $pagenow; foreach($data as $type => $info){ $wrapper = array( 'class' => 'acf-js-tooltip', 'title' => $info['file'], ); if($info['class']){ $wrapper['class'] .= ' ' . $info['class']; } if($info['message']){ $wrapper['title'] = $info['message']; } $icons = array(); if($info['warning'] && $pagenow !== 'post-new.php') $icons[] = ''; ob_start(); ?> > __('Auto Sync'), 'instructions' => '', 'type' => 'checkbox', 'name' => 'acfe_autosync', 'prefix' => 'acf_field_group', 'value' => $acfe_autosync, 'choices' => array( 'php' => $choices['php'], 'json' => $choices['json'], ) )); /* * Permissions */ acf_render_field_wrap(array( 'label' => __('Permissions'), 'name' => 'acfe_permissions', 'prefix' => 'acf_field_group', 'type' => 'checkbox', 'instructions' => __('Select user roles that are allowed to view and edit this field group in post edition'), 'required' => false, 'default_value' => false, 'choices' => acfe_get_roles(), 'value' => acf_maybe_get($field_group, 'acfe_permissions', array()), 'layout' => 'vertical' )); ?> post_type !== 'acf-field-group') return; global $field_group; ?>
' . print_r($field_group, true) . '
' . print_r($field_group_raw, true) . '