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


PHP PodsForm::prepare方法代码示例

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


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

示例1: save_pod_item


//.........这里部分代码省略.........
                 }
                 if (0 < $pick_limit && !empty($value)) {
                     $value = array_slice($value, 0, $pick_limit);
                 }
                 // Don't save an empty array, just make it an empty string
                 if (empty($value)) {
                     $value = '';
                 } elseif (is_array($value)) {
                     // If there's just one item, don't save as an array, save the string
                     if (1 == $pick_limit || 1 == count($value)) {
                         $value = implode('', $value);
                     } elseif ('table' == pods_var('storage', $pod)) {
                         $value = version_compare(PHP_VERSION, '5.4.0', '>=') ? json_encode($value, JSON_UNESCAPED_UNICODE) : json_encode($value);
                     }
                 }
             }
             // Prepare all table / meta data
             if (!in_array($type, $tableless_field_types) || $simple) {
                 if (in_array($type, $repeatable_field_types) && 1 == pods_var($type . '_repeatable', $field_data, 0)) {
                     // Don't save an empty array, just make it an empty string
                     if (empty($value)) {
                         $value = '';
                     } elseif (is_array($value)) {
                         // If there's just one item, don't save as an array, save the string
                         if (1 == count($value)) {
                             $value = implode('', $value);
                         } elseif ('table' == pods_var('storage', $pod)) {
                             $value = version_compare(PHP_VERSION, '5.4.0', '>=') ? json_encode($value, JSON_UNESCAPED_UNICODE) : json_encode($value);
                         }
                     }
                 }
                 $table_data[$field] = str_replace(array('{prefix}', '@wp_'), array('{/prefix/}', '{prefix}'), $value);
                 // Fix for pods_query
                 $table_formats[] = PodsForm::prepare($type, $options);
                 $object_meta[$field] = $value;
             } else {
                 // Convert values from a comma-separated string into an array
                 if (!is_array($value)) {
                     $value = explode(',', $value);
                 }
                 $rel_fields[$type][$field] = $value;
                 $rel_field_ids[] = $field_data['id'];
             }
         }
     }
     if ('post_type' == $pod['type']) {
         $post_type = $pod['name'];
         if (!empty($pod['object'])) {
             $post_type = $pod['object'];
         }
         $object_data['post_type'] = $post_type;
     }
     if (('meta' == $pod['storage'] || 'settings' == $pod['type']) && !in_array($pod['type'], array('taxonomy', 'pod', 'table', ''))) {
         if ($allow_custom_fields && !empty($custom_data)) {
             $object_meta = array_merge($custom_data, $object_meta);
         }
         $fields_to_send = array_flip(array_keys($object_meta));
         foreach ($fields_to_send as $field => $field_data) {
             if (isset($object_fields[$field])) {
                 $field_data = $object_fields[$field];
             } elseif (isset($fields[$field])) {
                 $field_data = $fields[$field];
             } else {
                 unset($fields_to_send[$field]);
             }
             $fields_to_send[$field] = $field_data;
开发者ID:satokora,项目名称:IT354Project,代码行数:67,代码来源:PodsAPI.php


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