public function each_repeater_fields($id, $name, $value, $fields, $counter) { $opt = array(); foreach ($fields as $key => $set) { $defaults = array('title' => esc_html__("Title", "caviar"), 'options' => array(), 'args' => array(), 'type' => 'text', 'taxonomy' => 'category'); $set = wp_parse_args($set, $defaults); $type = $set['type']; $field_name = $name . '[' . $counter . ']' . '[' . $key . ']'; $basicField = Basic_Fields::getInstance(); switch ($type) { case 'text': case 'textarea': $opt[] = $basicField->{$type}($set['title'], $id, array("echo" => false, "class" => "widefat repeatedField", "value" => $value[$key], "name" => $field_name)); break; case 'upload': $opt[] = $this->{$type}($set['title'], $counter, array("echo" => false, "class" => "widefat repeatedField", "value" => $value[$key], "name" => $field_name, 'data_parent' => $id), null); break; case 'radioimage': case 'radiopill': $opt[] = $this->{$type}($set['title'], $id, array("echo" => false, "class" => "widefat repeatedField", "value" => $value[$key], "name" => $field_name), $set['options']); break; case 'select': case 'checkbox': case 'radio': $opt[] = $basicField->{$type}($set['title'], $id, array("echo" => false, "class" => "widefat repeatedField", "value" => $value[$key], "name" => $field_name), $set['options']); break; } } return implode(" ", $opt); }
* @param array $options List of slect options * @return string Field markup */ public function radio($title, $id, $args = array(), $options = array()) { $this->title = $title; $this->id = $id; $this->args = $args; /* Make $args array key into variable */ extract($this->args); /* Validation for every control attributes must have value */ $control_id = self::must_exists($id, "id='{$id}'", ''); $control_name = self::must_exists($name, 'name="' . $name . '"', 'name="' . $id . '"'); $control_value = self::must_exists($value, "value='{$value}'", ''); $control_label = self::must_exists($title, "<label class='control-label' for='{$id}'>{$title}</label>", ''); $control_info = self::must_exists($info, "<span class='control-info'>{$info}</span>", ''); $before_control = self::must_exists($before_control, $before_control, "<div class='widget-separator'>"); $after_control = self::must_exists($after_control, $after_control, "</div>"); $control_attr = self::each_attr($attr); /* Print markup before control*/ $input = $before_control . $control_label . "<div class='radio-wrapper widefat {$class}' {$control_id} >" . self::each_radio($control_name, $options, $value, $control_attr) . "</div>" . $control_info . $after_control; /* Echo field or return the markup */ if ($echo === false) { return $input; } else { echo $input; } } } Basic_Fields::getInstance(); }