当前位置: 首页>>代码示例>>PHP>>正文


PHP acf_Field::update_value方法代码示例

本文整理汇总了PHP中acf_Field::update_value方法的典型用法代码示例。如果您正苦于以下问题:PHP acf_Field::update_value方法的具体用法?PHP acf_Field::update_value怎么用?PHP acf_Field::update_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在acf_Field的用法示例。


在下文中一共展示了acf_Field::update_value方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: floatval

 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);
 }
开发者ID:mpaskew,项目名称:isc-dev,代码行数:11,代码来源:number.php

示例2:

 function update_value($post_id, $field, $value)
 {
     // do stuff with value
     // save value
     parent::update_value($post_id, $field, $value);
 }
开发者ID:hubdotcom,项目名称:User-Field-ACF-Add-on,代码行数:6,代码来源:users_field.php

示例3: unset

 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);
 }
开发者ID:agentfitz,项目名称:thb,代码行数:27,代码来源:repeater.php

示例4: array

 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);
 }
开发者ID:sriram911,项目名称:pls,代码行数:31,代码来源:flexible_content.php

示例5: strtotime

 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);
 }
开发者ID:andresagraf,项目名称:summitmutual2016,代码行数:12,代码来源:date_time_picker-v3.php

示例6: array

 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);
 }
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:46,代码来源:flexible_content.php

示例7: update_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);
 }
开发者ID:radist2s,项目名称:acf-taxonomy-field,代码行数:20,代码来源:taxonomy-field.php

示例8: isset

 /**
  * 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);
 }
开发者ID:netconstructor,项目名称:simple-acf-time-field,代码行数:21,代码来源:simple_acf_time_field.class.php

示例9: unset

 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);
 }
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:39,代码来源:repeater.php

示例10: update_value

 /**
  * (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);
 }
开发者ID:Calraiser,项目名称:flux,代码行数:20,代码来源:taxonomy-field.php

示例11: update_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);
 }
开发者ID:raulmelo,项目名称:booblog,代码行数:19,代码来源:nggallery-field-v3.php

示例12: floatval

 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);
 }
开发者ID:warruda,项目名称:portalsaudecrianca,代码行数:8,代码来源:paypal_item-v3.php


注:本文中的acf_Field::update_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。