| @@ -6,10 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Admin\Form; |
| 9 | 9 | |
| 10 | -class CustomFieldHandler { | |
| 11 | - public function updatedEntries($formEntries, $fieldDetails) { | |
| 10 | +class CustomFieldHandler | |
| 11 | +{ | |
| 12 | + public function updatedEntries($formEntries, $fieldDetails) | |
| 13 | + { | |
| 12 | 14 | foreach ($formEntries['entries'] as $index => $entry) { |
| 13 | 15 | foreach ($fieldDetails as $field) { |
| 14 | 16 | $fieldKey = $field['key']; |
| 15 | 17 | if (isset($field['customType']) && !empty($entry->$fieldKey) && !empty($field['customType']->hiddenValue)) { |
| @@ -50,9 +52,10 @@ | ||
| 50 | 52 | } |
| 51 | 53 | return $formEntries; |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | - public function updatedData($form_fields, $toUpdateValues) { | |
| 56 | + public function updatedData($form_fields, $toUpdateValues) | |
| 57 | + { | |
| 55 | 58 | foreach ($form_fields as $field) { |
| 56 | 59 | if (isset($field['customType']) && !empty($toUpdateValues[$field['key']])) { |
| 57 | 60 | if (isset($field['customType']->hiddenValue)) { |
| 58 | 61 | $hiddenvalue = $field['customType']->hiddenValue; |
| @@ -89,9 +92,10 @@ | ||
| 89 | 92 | } |
| 90 | 93 | return $toUpdateValues; |
| 91 | 94 | } |
| 92 | 95 | |
| 93 | - public function getPostFieldValue($type, $fieldValue, $mul, $hiddenvalue) { | |
| 96 | + public function getPostFieldValue($type, $fieldValue, $mul, $hiddenvalue) | |
| 97 | + { | |
| 94 | 98 | $value = ''; |
| 95 | 99 | |
| 96 | 100 | if ('select' === $type) { |
| 97 | 101 | if (true === $mul) { |
| @@ -117,9 +121,9 @@ | ||
| 117 | 121 | if (false !== $exists) { |
| 118 | 122 | $multipleValues[] = $exists->$hiddenvalue; |
| 119 | 123 | } |
| 120 | 124 | } |
| 121 | - $value = json_encode($multipleValues); | |
| 125 | + $value = wp_json_encode($multipleValues); | |
| 122 | 126 | } else { |
| 123 | 127 | $exists = get_post($fieldValue); |
| 124 | 128 | if (false !== $exists) { |
| 125 | 129 | $value = $exists->$hiddenvalue; |
| @@ -128,9 +132,10 @@ | ||
| 128 | 132 | } |
| 129 | 133 | return $value; |
| 130 | 134 | } |
| 131 | 135 | |
| 132 | - public function getUserFieldValue($type, $fieldValue, $mul, $hiddenvalue) { | |
| 136 | + public function getUserFieldValue($type, $fieldValue, $mul, $hiddenvalue) | |
| 137 | + { | |
| 133 | 138 | $value = ''; |
| 134 | 139 | if ('select' === $type) { |
| 135 | 140 | if (true === $mul) { |
| 136 | 141 | $multipleValue = []; |
| @@ -155,9 +160,9 @@ | ||
| 155 | 160 | if (false !== $exists) { |
| 156 | 161 | $multipleValues[] = $exists->data->$hiddenvalue; |
| 157 | 162 | } |
| 158 | 163 | } |
| 159 | - $value = json_encode($multipleValues); | |
| 164 | + $value = wp_json_encode($multipleValues); | |
| 160 | 165 | } else { |
| 161 | 166 | $exists = get_user_by('ID', $fieldValue); |
| 162 | 167 | if (false !== $exists) { |
| 163 | 168 | $value = $exists->data->$hiddenvalue; |
| @@ -166,9 +171,10 @@ | ||
| 166 | 171 | } |
| 167 | 172 | return $value; |
| 168 | 173 | } |
| 169 | 174 | |
| 170 | - public function getTermFieldValue($type, $fieldValue, $mul, $hiddenvalue) { | |
| 175 | + public function getTermFieldValue($type, $fieldValue, $mul, $hiddenvalue) | |
| 176 | + { | |
| 171 | 177 | $value = ''; |
| 172 | 178 | if ('select' === $type) { |
| 173 | 179 | if (true === $mul) { |
| 174 | 180 | $multipleValue = []; |
| @@ -193,9 +199,9 @@ | ||
| 193 | 199 | if (false !== $exists) { |
| 194 | 200 | $multipleValues[] = $exists->$hiddenvalue; |
| 195 | 201 | } |
| 196 | 202 | } |
| 197 | - $value = json_encode($multipleValues); | |
| 203 | + $value = wp_json_encode($multipleValues); | |
| 198 | 204 | } else { |
| 199 | 205 | $exists = get_term_by('term_taxonomy_id', $fieldValue); |
| 200 | 206 | if (false !== $exists) { |
| 201 | 207 | $value = $exists->$hiddenvalue; |