/** * Generate the corresponding HTML for a field. * * @param array $args * * @return string */ protected function _render_specific($args) { $args = wp_parse_args($args, array('text' => false, 'extra' => array())); $options = array(); if (false !== $args['text']) { $options[] = array('value' => '', 'selected' => $args['selected'] === array('foo'), 'title' => $args['text']); } foreach ($args['choices'] as $value => $title) { $value = (string) $value; $options[] = array('value' => $value, 'selected' => $value == $args['selected'], 'title' => $title); } $opts = ''; foreach ($options as $option) { $opts .= Util::html('option', array('value' => $option['value'], 'selected' => $option['selected']), $option['title']); } $args['extra']['name'] = $args['name']; $input = Util::html('select', $args['extra'], $opts); return FormField::add_label($input, $args['desc'], $args['desc_pos']); }
/** * Wraps a content in a table row. * * @param string $title * @param string $content * * @return string */ public static function row_wrap($title, $content) { return Util::html('tr', Util::html("th scope='row'", $title), Util::html('td', $content)); }
/** * Returns table row. * * @param array $row * @param array $formdata * @param array $errors (optional) * * @return string */ public function table_row($row, $formdata, $errors = array()) { $input = FormBuilder::input($row, $formdata); // If row has an error, highlight it $style = in_array($row['name'], $errors) ? 'style="background-color: #FFCCCC"' : ''; return Util::html('tr', Util::html("th {$style} scope='row'", $row['title']), Util::html("td {$style}", $input)); }
/** * Wraps a form field in a label, and position field description. * * @param string $input * @param string $desc * @param string $desc_pos * * @return string */ protected static function add_label($input, $desc, $desc_pos) { return Util::html('label', self::add_desc($input, $desc, $desc_pos)) . "\n"; }
/** * Wraps a string in a <style> tag. * * @param string $string * * @return string */ public function css_wrap($string) { return Util::html("style type='text/css'", $string); }