當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。