public final function _convergeControlData() { $control_objects = array(); $defaults = array(); foreach ($this->legacy_controls as $item) { $name = $item['name']; $config = array('type' => $item['controlType'], 'ui' => array(), 'options' => $item['options'], 'suggest' => $item['defaultValue']); if (!is_null($item['controlTitle'])) { $config['ui']['title'] = $item['controlTitle']; } if (!is_null($item['controlTooltip'])) { $config['ui']['tooltip'] = $item['controlTooltip']; } $control = Cornerstone_Control::factory($name, $config); if (is_wp_error($control)) { trigger_error('Failed to create Cornerstone_Control: ' . $control->get_error_message(), E_USER_WARNING); continue; } // Factory can send back an array, but we don't need to add that support for legacy elements if (is_array($control)) { trigger_error('Failed to create Cornerstone_Control: Old element version does not support groups. ' . $name, E_USER_WARNING); } else { $defaults[$control->name] = $control->transformSuggestion($item['defaultValue']); $control_objects[] = $control; } } $control_models = array(); foreach ($control_objects as $control) { $control_models[] = $control->model_data(); } return array('controls' => $control_models, 'defaults' => $defaults); }
public static final function factory($controls = array(), $common_controls = false, $uncontrolled = array()) { if (!is_array($controls)) { return false; } if (is_array($common_controls)) { $controls = self::remap_common_controls($controls, $common_controls); } $control_list = array(); foreach ($controls as $name => $config) { $control = Cornerstone_Control::factory($name, $config); if (is_wp_error($control)) { trigger_error('Failed to create Cornerstone_Control: ' . $control->get_error_message(), E_USER_WARNING); continue; } // Allow factory to send back a group of controls, or a single control if (is_array($control)) { $control_list = array_merge($control_list, $control); } else { $control_list[] = $control; } } return new self($control_list, $uncontrolled); }