/** * Echoes the widget content. * Sub-classes can over-ride this method to generate their widget code * but it is best to override front_end(). * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance The settings for the particular instance of the widget. */ public function widget($args, $instance) { // prepare $instance values for complex fields if (!empty($this->complex_field_names)) { $instance = self::unwrap_complex_field_values($instance, $this->complex_field_names); } // prepare $instance values for association fields foreach ($instance as &$field_value) { $field_value = Helper::parse_relationship_field($field_value); } // output if ($this->print_wrappers) { echo $args['before_widget']; } $this->front_end($args, $instance); if ($this->print_wrappers) { echo $args['after_widget']; } }
/** * Parse groups of raw field data into the actual field hierarchy. * * @param array $group_rows Group rows */ public function process_loaded_values($group_rows) { $input_groups = array(); // Set default values $field_names = array(); foreach ($this->groups as $group) { $group_fields = $group->get_fields(); foreach ($group_fields as $field) { $field_names[] = $field->get_name(); $field->set_value($field->get_default_value()); } } if (empty($group_rows)) { return; } // load and parse values and group type foreach ($group_rows as $row) { if (!preg_match(Helper::get_complex_field_regex($this->name, array_keys($this->groups), $field_names), $row['field_key'], $field_name)) { continue; } $row['field_value'] = maybe_unserialize($row['field_value']); $input_groups[$field_name['index']]['type'] = $field_name['group']; if (!empty($field_name['trailing'])) { $input_groups[$field_name['index']][$field_name['key'] . '_' . $field_name['sub'] . '-' . $field_name['trailing']] = $row['field_value']; } else { if (!empty($field_name['sub'])) { $input_groups[$field_name['index']][$field_name['key']][$field_name['sub']] = $row['field_value']; } else { $input_groups[$field_name['index']][$field_name['key']] = $row['field_value']; } } } // create groups list with loaded fields ksort($input_groups); foreach ($input_groups as $index => $values) { $value_group = array('type' => $values['type']); $group_fields = $this->groups[$values['type']]->get_fields(); unset($values['type']); foreach ($group_fields as $field) { // set value from the group $tmp_field = clone $field; if (is_a($field, __NAMESPACE__ . '\\Complex_Field')) { $tmp_field->load_values_from_array($values); } else { $tmp_field->set_value_from_input($values); } $value_group[] = $tmp_field; } $this->values[] = $value_group; } }
function carbon_get_comment_meta($id, $name, $type = null) { return Helper::get_comment_meta($id, $name, $type); }