get_pages(); $more_fields = $mf0->get_boxes(); switch ($_GET['action']) { case 'delete_box' : $boxes = $mf0->get_boxes('i'); $ok = $mfo->condition(($box = attribute_escape($_GET['box'])), __('Error! Something strange happened.', 'more-fields')); $ok = $mfo->condition(($name = $boxes[$box]['name']), __('Your are trying to delete a box that doesn\'t exist.', 'more-fields')); if ($ok) { unset($boxes[$box]); update_option('more_fields_boxes', $boxes); $mfo->condition(false, __('Box deleted!', 'more-fields'), 'notification'); } $_GET['action'] = ''; break; case 'delete_field' : $boxes = $mf0->get_boxes('i'); $ret = $mfo->options_validate_field_input_get(__('delete', 'more-fields')); //); if ($ret['ok']) { unset($boxes[$ret['box']]['field'][$ret['index']]); $new = array(); foreach ($boxes[$ret['box']]['field'] as $field ) array_push($new, $field); $boxes[$ret['box']]['field'] = $new; update_option('more_fields_boxes', $boxes); $mfo->condition(false, __('Deleted!', 'more-fields'), 'notification'); } $_GET['action'] = 'edit_box'; break; case 'move_up_field': $mfo->options_move_field ( true ); break; case 'move_down_field' : $mfo->options_move_field ( false ); break; } switch (attribute_escape($_POST['post_action'])) { case 'save_box': $boxes = $mf0->get_boxes(''); $ok = $mfo->condition(($name = attribute_escape($_POST['name'])), __('The box must have a name!', 'more-fields')); // $ok = mf_condition(($name == 'Post'), __('The box must have a name!', 'more-fields')); $name_old = attribute_escape($_POST['name_old']); if ($name != $name_old) $ok = $mfo->condition((!array_key_exists($name, $boxes)), __('A box with that name already exists!', 'more-fields')); if ($name_old) $nochange = $mfo->condition(($name_old == $name), __('You changed the name of the box!', 'more-fields'), 'warning'); // else $ok = mf_condition(($boxes[$name] != ''), __('The already key exists!', 'more-fields')); if ($ok) { // if (!is_array($boxes)) $boxes = array(); if (!$nochange) { $ok = $mfo->condition(($name != 'Page'), __('The page type Page is protected!', 'more-fields')); $ok = $mfo->condition(($name != 'Post'), __('The page type Post is protected!', 'more-fields')); if ($ok) { $old = $boxes[$name_old]; $boxes[$name] = $old; unset($boxes[$name_old]); } } if ($ok) { $boxes[$name]['name'] = $name; $boxes[$name]['position'] = attribute_escape($_POST['position']); update_option('more_fields_boxes', $boxes); $mfo->condition(false, str_replace('%s', "$name", __('Box %s was saved!', 'more-fields')), 'notification'); $_GET['box'] = $name; } } break; case 'save_field': $boxes = $mf0->get_boxes('i'); $ok = $mfo->condition(($box = attribute_escape($_POST['box'])), __('Hang on, someting strange happend!', 'more-fields')); $ok = $mfo->condition(($key = attribute_escape($_POST['key'])), __('You must specify a key for the field!', 'more-fields')); // print_r($_POST); if ($key_old = attribute_escape($_POST['key_old'])) $nochange = $mfo->condition(($key_old == $key), __('You changed the name of the field!', 'more-fields'), 'warning'); foreach($boxes as $b) { if (!is_array($b['field'])) continue; foreach ($b['field'] as $field) { $key = (!$nochange) ? $key : $key_old; // If the field is new if (!$key_old) $ok = $mfo->condition(($field['key'] != $key), __('The key your are trying to create already exists in the box called', 'more-fields') . ' ' . $b['name'] . '.'); // If the name changed if (!$nochange) $ok = $mfo->condition(($field['key'] != $key), __('The key your are renaming to already exists', 'more-fields')); } } $v = ($nochange) ? $key : $key_old; $post_index = attribute_escape($_POST['index']); $index = ($boxes[$box]['field'][$post_index]['key'] == $v) ? $post_index : count($boxes[$box]['field']); if ($index == '') $index = 0; if (!$key_old) $index = count($boxes[$box]['field']); if ($ok) { $boxes[$box]['field'][$index]['key'] = $key; $boxes[$box]['field'][$index]['title'] = attribute_escape($_POST['title']); $boxes[$box]['field'][$index]['slug'] = $mfo->slugize(attribute_escape($_POST['slug'])); $boxes[$box]['field'][$index]['type'] = attribute_escape($_POST['type']); $boxes[$box]['field'][$index]['select_values'] = attribute_escape($_POST['select_values']); update_option('more_fields_boxes', $boxes); // Generate the rewrite rules for this field $mf0->generate_rewrite_rules(); $mf0->flush_rewrite_rules(); $mfo->condition(false, __('Field was saved!', 'more-fields'), 'notification'); } break; case 'delete_box': $boxes = get_option('more_fields_boxes'); if (!is_array($boxes)) $boxes = array(); $ok = $mfo->condition(($box = attribute_escape($_GET['box'])), __('Error! Something strange happened.', 'more-fields')); $ok = $mfo->condition(($name = $boxes[$box]['name']), __('Your are trying to delete a box that doesn\'t exist', 'more-fields')); if ($ok) { unset($boxes[$box]); update_option('more_fields_boxes', $boxes); } break; case 'delete_field' : $boxes = get_option('more_fields_boxes'); if (!is_array($boxes)) $boxes = array(); $ok = $mfo->condition(($box = $_POST['box']), __('Error! Something strange happened.', 'more-fields')); $ok = $mfo->condition(($field = $_POST['field']), __('Error! Something strange happened.', 'more-fields')); $ok = $mfo->condition((in_array($field, $more_fields[$box]['fields'])), __('Your are trying to delete a field that doesn\'t exist', 'more-fields')); if ($ok) { $id = array_search($field, $more_fields[$box]['field']); unset($boxes[$box]['field'][$id]); update_option('more_fields_boxes', $boxes); } break; case 'edit_field' : $boxes = get_option('more_fields_boxes'); if (!is_array($boxes)) $boxes = array(); $ok = $mfo->condition(($box = $_POST['box']), __('Error! Something strange happened.', 'more-fields')); $ok = $mfo->condition(($field = $_POST['field']), __('Error! Something strange happened.', 'more-fields')); $ok = $mfo->condition((in_array($field, $more_fields[$box]['fields'])), __('Your are trying to delete a field that doesn\'t exist', 'more-fields')); if ($ok) { } } $action = attribute_escape($_GET['action']); if (!$action) : ?>

>
There are no boxes defined - set some up, it is easy!
| -

get_boxes('i'); $field = $more_fields[$box]; $nav = ($a = $field['name']) ? $a : __('New box', 'more-fields'); ?>

More Fields >

Box title
Position

field_types as $f0) if (sanitize_title($f0->title) == $f['type']) $type = $f0->title; $box = urlencode(attribute_escape($_GET['box'])); $edit_link = "options-general.php?page=more-fields.php&action=edit_field&tab=boxes&box=" . ($box) . "&field=$fnbr&key="; $edit_link .= urlencode($f['key']); $delete_link = str_replace('edit_', 'delete_', $edit_link); $move_up_link = str_replace('edit_', 'move_up_', $edit_link); $move_down_link = str_replace('edit_', 'move_down_', $edit_link); ?> > '; ?>
Edit | Delete | |
' . __('There are no fields in this box.', 'more-fields') . '

get_boxes('i'); $key = attribute_escape($_GET['key']); $box = attribute_escape($_GET['box']); $index = attribute_escape($_GET['field']); if ($boxes[$box]['field'][$index]['key'] == $key) $field = $boxes[$box]['field'][$index]; else $field = array(); $nav = ($a = $field['title']) ? $a : __('New Field', 'more-fields'); ?>

> >


Separate values with comma (,). Preceed default value by a *. E.g: red, *green, blue