public function metabox_edit($post, $metabox) { wp_nonce_field(MI_PREFIX . 'meta_box', MI_PREFIX . 'meta_box_nonce'); $html .= ' <input type="hidden" name="metabox[]" id="metabox[]" value="' . $metabox['id'] . '"> <table class="form-table"> <tbody> '; $mi_forms = new MI_Forms(); foreach ($metabox['args']['fields'] as $id => $field) { $form = $mi_forms->field($id, $field, get_post_meta($post->ID, MI_PREFIX . $id, true)); $html .= ' <tr> <th scope="row"><label for="' . $form->name . '">' . $form->label . '</label></th> <td> '; $html .= $form->field; $html .= $form->desc ? '<p class="description">' . $form->desc . '</p>' : ''; $html .= ' </td> </tr> '; } $html .= ' </tbody> </table> '; echo $html; }
public function form($inst) { $fields = array($this->get_field_name('text') => array('name' => 'text', 'type' => 'text', 'label' => 'Text', 'desc' => 'Campo de Texto'), $this->get_field_name('textarea') => array('name' => 'textarea', 'type' => 'textarea', 'label' => 'Textarea', 'desc' => 'Campo Textarea', 'required' => true), $this->get_field_name('date') => array('name' => 'date', 'type' => 'date', 'label' => 'Date', 'desc' => 'Campo Data', 'required' => true), $this->get_field_name('select') => array('name' => 'select', 'type' => 'select', 'label' => 'Select', 'desc' => 'Campo Select', 'required' => true, 'opt' => array('1' => 'Value 1', '2' => 'Value 2')), $this->get_field_name('multiple') => array('name' => 'multiple', 'type' => 'select', 'label' => 'Select', 'desc' => 'Campo Multiple', 'required' => true, 'multiple' => true, 'opt' => array('1' => 'Value 1', '2' => 'Value 2')), $this->get_field_name('radio') => array('name' => 'radio', 'type' => 'radio', 'label' => 'Radio', 'desc' => 'Campo Radio', 'opt' => array('1' => 'Value 1', '2' => 'Valu 2')), $this->get_field_name('checkbox') => array('name' => 'checkbox', 'type' => 'checkbox', 'label' => 'Checkbox', 'desc' => 'Campo Checkbox', 'opt' => array('1' => 'Value 1', '2' => 'Value 2')), $this->get_field_name('number') => array('name' => 'number', 'type' => 'number', 'label' => 'Number', 'desc' => 'Campo Number', 'required' => true, 'min' => '1', 'max' => '10'), $this->get_field_name('file') => array('name' => 'file', 'type' => 'file', 'label' => 'File', 'desc' => 'Campo File')); $mi_forms = new MI_Forms(); foreach ($fields as $id => $field) { $form = $mi_forms->field($id, $field, stripslashes($inst[$field['name']])); $html .= ' <p> <label for="' . $form->name . '">' . $form->label . '</label> ' . $form->field . ' '; $html .= $form->desc ? '<i class="description">' . $form->desc . '</i>' : ''; $html .= ' </p> '; } echo $html; }