private function wrap_upload($field_name, $desc) { $upload_button = html('input', array('class' => 'upload_button button', 'rel' => $field_name, 'type' => 'button', 'value' => __('Upload Image', APP_TD))); $clear_button = html('input', array('class' => 'delete_button button', 'rel' => $field_name, 'type' => 'button', 'value' => __('Clear Image', APP_TD))); $preview = html('div', array('id' => $field_name . '_image', 'class' => 'upload_image_preview'), html('img', array('src' => scbForms::get_value($field_name, $this->options->get())))); return $upload_button . ' ' . $clear_button . $desc . $preview; }
/** * Collect metadata from all boxes. */ function save_post($post_id, $post) { if ('revision' == $post->post_type || defined('DOING_AJAX')) { return; } if (isset($_POST['p2p_connections'])) { // Loop through the hidden fields instead of through $_POST['p2p_meta'] because empty checkboxes send no data. foreach ($_POST['p2p_connections'] as $p2p_id) { $data = scbForms::get_value(array('p2p_meta', $p2p_id), $_POST, array()); $connection = p2p_get_connection($p2p_id); if (!$connection) { continue; } $fields = p2p_type($connection->p2p_type)->fields; foreach ($fields as $key => &$field) { $field['name'] = $key; } $data = scbForms::validate_post_data($fields, $data); scbForms::update_meta($fields, $data, $p2p_id, 'p2p'); } } // Ordering if (isset($_POST['p2p_order'])) { foreach ($_POST['p2p_order'] as $key => $list) { foreach ($list as $i => $p2p_id) { p2p_update_meta($p2p_id, $key, $i); } } } }
function input($args) { $value = scbForms::get_value($args['name'], $this->data); if (!empty($this->prefix)) { $args['name'] = array_merge($this->prefix, (array) $args['name']); } return scbForms::input_with_value($args, $value); }
function input($args) { $default = isset($args['default']) ? $args['default'] : null; $value = scbForms::get_value($args['name'], $this->data, $default); if (!empty($this->prefix)) { $args['name'] = array_merge($this->prefix, (array) $args['name']); } return scbForms::input_with_value($args, $value); }
/** * Get default values for one or all fields. * * @param string|array $field (optional) The field to get. * * @return mixed Whatever is in those fields. */ public function get_defaults($field = null) { return scbForms::get_value($field, $this->defaults); }
/** * Collect metadata from all boxes. */ static function save_post($post_id, $post) { if ('revision' == $post->post_type || defined('DOING_AJAX')) { return; } // Custom fields if (isset($_POST['p2p_types'])) { foreach ($_POST['p2p_types'] as $p2p_type) { $ctype = p2p_type($p2p_type); if (!$ctype) { continue; } foreach ($ctype->get_connections($post_id) as $p2p_id => $item_id) { $data = scbForms::get_value(array('p2p_meta', $p2p_id), $_POST, array()); foreach (self::$box_args[$p2p_type]->fields as $key => $field_args) { if ('checkbox' == $field_args['type']) { $new_values = scbForms::get_value($key, $data, array()); $old_values = p2p_get_meta($p2p_id, $key); foreach (array_diff($new_values, $old_values) as $value) { p2p_add_meta($p2p_id, $key, $value); } foreach (array_diff($old_values, $new_values) as $value) { p2p_delete_meta($p2p_id, $key, $value); } } else { p2p_update_meta($p2p_id, $key, $data[$key]); } } } } } // Ordering if (isset($_POST['p2p_order'])) { foreach ($_POST['p2p_order'] as $key => $list) { foreach ($list as $i => $p2p_id) { p2p_update_meta($p2p_id, $key, $i); } } } }
function input($args) { $value = scbForms::get_value($args['name'], $this->data); if (!is_null($value)) { switch ($args['type']) { case 'select': case 'radio': $args['selected'] = $value; break; case 'checkbox': if (is_array($value)) { $args['checked'] = $value; } else { $args['checked'] = $value || isset($args['value']) && $value == $args['value']; } break; default: $args['value'] = $value; } } if (!empty($this->prefix)) { $args['name'] = array_merge($this->prefix, (array) $args['name']); } return scbForms::input($args); }