function update_value($post_id, $field, $value) { // remove ',' $value = str_replace(',', '', $value); // convert to float. This removes any chars $value = floatval($value); // convert back to string. This alows decimals to save $value = (string) $value; // update value parent::update_value($post_id, $field, $value); }
function update_value($post_id, $field, $value) { // do stuff with value // save value parent::update_value($post_id, $field, $value); }
function update_value($post_id, $field, $value) { $total = 0; if ($value) { // remove dummy field unset($value[999]); $i = -1; // loop through rows foreach ($value as $row) { $i++; // increase total $total++; // loop through sub fields foreach ($field['sub_fields'] as $sub_field) { // get sub field data $v = isset($row[$sub_field['key']]) ? $row[$sub_field['key']] : ''; // add to parent value //$parent_value[$i][$sub_field['name']] = $v; // update full name $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name']; // save sub field value $this->parent->update_value($post_id, $sub_field, $v); } } } parent::update_value($post_id, $field, $total); }
function update_value($post_id, $field, $value) { $sub_fields = array(); foreach ($field['layouts'] as $layout) { foreach ($layout['sub_fields'] as $sub_field) { $sub_fields[$sub_field['key']] = $sub_field; } } $total = array(); if ($value) { // remove dummy field unset($value['acfcloneindex']); $i = -1; // loop through rows foreach ($value as $row) { $i++; // increase total $total[] = $row['acf_fc_layout']; unset($row['acf_fc_layout']); // loop through sub fields foreach ($row as $field_key => $value) { $sub_field = $sub_fields[$field_key]; // update full name $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name']; // save sub field value $this->parent->update_value($post_id, $sub_field, $value); } } } parent::update_value($post_id, $field, $total); }
function update_value($post_id, $field, $value) { $field = array_merge($this->defaults, $field); if ($value != '' && $field['save_as_timestamp'] == 'true') { if (preg_match('/^dd?\\//', $field['date_format'])) { //if start with dd/ or d/ (not supported by strtotime()) $value = str_replace('/', '-', $value); } $value = strtotime($value); } parent::update_value($post_id, $field, $value); }
function update_value($post_id, $field, $value) { $sub_fields = array(); foreach ($field['layouts'] as $layout) { foreach ($layout['sub_fields'] as $sub_field) { $sub_fields[$sub_field['key']] = $sub_field; } } $total = array(); if ($value) { // remove dummy field unset($value['acfcloneindex']); $i = -1; // loop through rows foreach ($value as $row) { $i++; // increase total $total[] = $row['acf_fc_layout']; unset($row['acf_fc_layout']); // loop through sub fields foreach ($row as $field_key => $v) { $sub_field = $sub_fields[$field_key]; // update full name $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name']; // save sub field value $this->parent->update_value($post_id, $sub_field, $v); } } } /* * Remove Old Data * * @credit: http://support.advancedcustomfields.com/discussion/1994/deleting-single-repeater-fields-does-not-remove-entry-from-database */ $old_total = parent::get_value($post_id, $field); $old_total = count($old_total); $new_total = count($total); if ($old_total > $new_total) { foreach ($sub_fields as $sub_field) { for ($j = $new_total; $j < $old_total; $j++) { parent::delete_value($post_id, $field['name'] . '_' . $j . '_' . $sub_field['name']); } } } parent::update_value($post_id, $field, $total); }
function update_value($post_id, $field, $value) { // Note: This function can be removed if not used // do stuff with value // save value parent::update_value($post_id, $field, $value); }
/** * (non-PHPdoc) * @see acf_Field::update_value() */ public function update_value($post_id, $field, $value) { $this->set_field_defaults($field); if ($field['set_post_terms']) { $terms = array(); foreach ((array) $value as $item) { if (intval($item) > 0) { $terms[] = intval($item); } else { $terms[] = strval($item); } } $value = wp_set_object_terms($post_id, $terms, $field['taxonomy'], false); } parent::update_value($post_id, $field, $value); }
/** * Process the post edit submit * * Convert the various fields into a single value (minutes since the start of the day) to save to the database. */ function update_value($post_id, $field, $value) { $field['24_hour'] = isset($field['24_hour']) ? $field['24_hour'] : false; // do stuff with value // Convert the parts into minutes since the start of the day if ($field['24_hour']) { $val = $value['hour'] * 60 + $value['minute']; } else { $val = $value['hour'] % 12 * 60 + $value['minute']; if ($value['meridiem'] == 'pm') { $val += 12 * 30; } } // save value parent::update_value($post_id, $field, $val); }
function update_value($post_id, $field, $value) { $total = 0; if ($value) { // remove dummy field unset($value['acfcloneindex']); $i = -1; // loop through rows foreach ($value as $row) { $i++; // increase total $total++; // loop through sub fields foreach ($field['sub_fields'] as $sub_field) { // get sub field data $v = isset($row[$sub_field['key']]) ? $row[$sub_field['key']] : ''; // update full name $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name']; // save sub field value $this->parent->update_value($post_id, $sub_field, $v); } } } /* * Remove Old Data * * @credit: http://support.advancedcustomfields.com/discussion/1994/deleting-single-repeater-fields-does-not-remove-entry-from-database */ $old_total = (int) parent::get_value($post_id, $field); if ($old_total > $total) { foreach ($field['sub_fields'] as $sub_field) { for ($j = $total; $j < $old_total; $j++) { parent::delete_value($post_id, $field['name'] . '_' . $j . '_' . $sub_field['name']); } } } // update repeater count parent::update_value($post_id, $field, $total); }
/** * (non-PHPdoc) * @see acf_Field::update_value() */ public function update_value($post_id, $field, $value) { $this->set_field_defaults($field); if (in_array($field[self::FIELD_SET_TERMS], array(self::SET_TERMS_APPEND, self::SET_TERMS_OVERRIDE))) { $terms = array(); foreach ((array) $value as $item) { if (intval($item) > 0) { $terms[] = intval($item); } else { $terms[] = strval($item); } } wp_set_object_terms($post_id, $terms, $field[self::FIELD_TAXONOMY], $field[self::FIELD_SET_TERMS] == self::SET_TERMS_APPEND); } parent::update_value($post_id, $field, $value); }
/** * (non-PHPdoc) * @see acf_Field::update_value() */ public function update_value($post_id, $field, $value) { $field = array_merge($this->defaults, $field); foreach ($value as $key => $item) { $items = explode(',', $item); foreach ($items as $item) { if (is_numeric($item)) { $values[$key]['ngg_id'] = intval($item); } else { $values[$key]['ngg_form'] = strval($item); } } } parent::update_value($post_id, $field, $values); }
function update_value($post_id, $field, $value) { // making sure value is a number / converting number with two decimal places at all times. $value['price'] = floatval($value['price']); $value['price'] = number_format($value['price'], 2, '.', ''); // save value parent::update_value($post_id, $field, $value); }