ID, $field['id'], true);
// Get data to display in field
if (isset($option)) {
$data = $option;
}
} else {
// Get saved option
$option_name .= $field['id'];
$option = get_option($option_name);
// Get data to display in field
if (isset($option)) {
$data = $option;
}
}
// Show default data if no option saved and default is supplied
if ($data === false && isset($field['default'])) {
$data = $field['default'];
} elseif ($data === false) {
$data = '';
}
$html = '';
switch ($field['type']) {
case 'text':
case 'url':
case 'email':
$html .= '' . "\n";
break;
case 'password':
case 'number':
case 'hidden':
$min = '';
if (isset($field['min'])) {
$min = ' min="' . esc_attr($field['min']) . '"';
}
$max = '';
if (isset($field['max'])) {
$max = ' max="' . esc_attr($field['max']) . '"';
}
$html .= '' . "\n";
break;
case 'text_secret':
$html .= '' . "\n";
break;
case 'textarea':
//var_dump($field);exit;
$html .= '
' . "\n";
// wp_editor( $data, esc_attr($field['id']), esc_attr($option_name) );
break;
case 'checkbox':
$checked = '';
if ($data && 'on' == $data) {
$checked = 'checked="checked"';
}
$html .= '' . "\n";
break;
case 'checkbox_multi':
foreach ($field['options'] as $k => $v) {
$checked = false;
if (in_array($k, (array) $data)) {
$checked = true;
}
$html .= '
' . $this->display_field($field, $post, false) . '
' . "\n"; echo $field; } /** * Save metabox fields * @param integer $post_id Post ID * @return void */ public function save_meta_boxes($post_id = 0) { if (!$post_id) { return; } $post_type = get_post_type($post_id); $fields = apply_filters($post_type . '_custom_fields', array(), $post_type); if (!is_array($fields) || 0 == count($fields)) { return; } foreach ($fields as $field) { if (isset($_REQUEST[$field['id']])) { update_post_meta($post_id, $field['id'], $this->validate_field(wc_clean($_REQUEST[$field['id']]), $field['type'])); } else { update_post_meta($post_id, $field['id'], ''); } } } }