function create_field($field) { // Find custom widget field group $field_group_class = new acf_field_group(); $field_groups = $field_group_class->get_field_groups(array()); $group = false; foreach ($field_groups as $field_group) { if ($field_group['title'] === $this->_custom_widget_title) { $group = $field_group; break; } } // Get Field Data $field_functions = new acf_field_functions(); $group = $field_functions->load_field(false, CUSTOM_WIDGETS_FIELD_KEY, $group['id']); // Check if the group was found if (!$group) { echo 'No custom widgets group found.'; return false; } // Get template data $widgets = $group['layouts']; $templates = $this->get_page_templates(); // Display relationship container ob_start(); require_once get_template_directory() . '/fields/templates/widget_template_relationship.php'; $template = ob_get_contents(); ob_end_clean(); echo $template; }
function create_options($field) { // defaults $field = array_merge($this->defaults, $field); // key is needed in the field names to correctly save the data $key = $field['name']; $value = isset($field['field_group']) ? $field['field_group'] : NULL; $field_groups = acf_field_group::get_field_groups(array()); $field_group_choices = array(); foreach ($field_groups as $field_group) { // we *don't* want to include this field group, that'd cause an infinite loop if (isset($_GET['post']) && $_GET['post'] == $field_group['id']) { continue; } $field_group_choices[$field_group['id']] = $field_group['title']; } // Create Field Options HTML ?> <tr class="field_option field_option_<?php echo $this->name; ?> "> <td class="label"> <label>Field Group</label> <p class="description">Select a field group in which to inherit fields from</p> </td> <td> <?php do_action('acf/create_field', array('type' => 'select', 'name' => 'fields[' . $key . '][field_group_id]', 'required' => TRUE, 'choices' => $field_group_choices, 'value' => $field['field_group_id'])); ?> </td> </tr> <?php }