PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Migration/MigrationHelper.php +84 -10 2.02.15.3 View file →
@@ -1,10 +1,12 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Core\Migration;
4 4
5 -class MigrationHelper {
6 - public static function setNestedProperty(&$rootObj, $properties, $value) {
5 +class MigrationHelper
6 +{
7 + public static function setNestedProperty(&$rootObj, $properties, $value)
8 + {
7 9 $firstProperty = array_shift($properties);
8 10 $current = &$rootObj;
9 11
10 12 if (is_object($current)) {
@@ -27,9 +29,10 @@
27 29 }
28 30 }
29 31 }
30 32
31 - public static function getNestedPropertyValue($rootObj, $properties) {
33 + public static function getNestedPropertyValue($rootObj, $properties)
34 + {
32 35 $firstProperty = array_shift($properties);
33 36 $current = $rootObj;
34 37 if (is_object($current) && count($properties) > 0) {
35 38 return self::getNestedPropertyValue($current->$firstProperty, $properties);
@@ -41,9 +44,10 @@
41 44 return array_key_exists($firstProperty, $current) ? $current[$firstProperty] : null;
42 45 }
43 46 }
44 47
45 - public static function optionListConvert($optionList) {
48 + public static function optionListConvert($optionList)
49 + {
46 50 $newOptionList = [];
47 51 foreach ($optionList as $option) {
48 52 $newOpt = (object)[];
49 53 if (isset($option->label)) {
@@ -62,9 +66,10 @@
62 66 }
63 67 return $newOptionList;
64 68 }
65 69
66 - public static function convertFields($fieldsArray) {
70 + public static function convertFields($fieldsArray)
71 + {
67 72 $conversionFormate = new FieldsConversionFormate();
68 73 $newFieldsArray = [];
69 74
70 75 foreach ($fieldsArray as $fieldKey => $field) {
@@ -120,9 +125,10 @@
120 125
121 126 return $newFieldsArray;
122 127 }
123 128
124 - public static function convertLayout($layoutObj) {
129 + public static function convertLayout($layoutObj)
130 + {
125 131 $newLayoutArray = [];
126 132
127 133 foreach ($layoutObj as $breakdownSize => $layoutArr) {
128 134 // v1 width variation
@@ -146,9 +152,10 @@
146 152 }
147 153 return $newLayoutArray;
148 154 }
149 155
150 - public static function convertSuccessMessage($successMessageArr) {
156 + public static function convertSuccessMessage($successMessageArr)
157 + {
151 158 $newSuccessMessageArr = [];
152 159
153 160 // this config is set as snackbar in bottom right corner
154 161 $defaultMessageConfig = [
@@ -188,11 +195,40 @@
188 195 }
189 196 return $newSuccessMessageArr;
190 197 }
191 198
192 - public static function recursiveDeleteFiles($src) {
199 + public static function convertWebHooksToIntegrations($formSettingsV1)
200 + {
201 + $webHooks = $formSettingsV1->confirmation->type->webHooks;
202 + $integrations = $formSettingsV1->integrations;
203 + foreach ($webHooks as $webHook) {
204 + $webHook->type = 'Web Hooks';
205 + $webHook->name = $webHook->title;
206 + $integrations[] = $webHook;
207 + }
208 + return $integrations;
209 + }
210 +
211 + public static function duplicateV1StyleFiles()
212 + {
213 + $source = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles';
214 + $destination = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1';
215 + if (!file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1')) {
216 + wp_mkdir_p(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1');
217 + }
218 + self::recursiveCopyFiles($source, $destination);
219 + self::recursiveDeleteFiles($source);
220 + }
221 +
222 + public static function getBitformDefaultStyleClass()
223 + {
224 + return self::arrayToCssString(BitformDefaultStyle::commonStyleClasses());
225 + }
226 +
227 + public static function recursiveDeleteFiles($src)
228 + {
193 229 if (is_file($src)) {
194 - return unlink($src);
230 + return wp_delete_file($src);
195 231 } elseif (is_dir($src)) {
196 232 $scan = glob(rtrim($src, '/') . '/*');
197 233 foreach ($scan as $path) {
198 234 self::recursiveDeleteFiles($path);
@@ -199,9 +235,10 @@
199 235 }
200 236 }
201 237 }
202 238
203 - public static function recursiveCopyFiles($src, $dst) {
239 + public static function recursiveCopyFiles($src, $dst)
240 + {
204 241 if (is_file($src) && !is_dir($dst)) {
205 242 return copy($src, $dst);
206 243 } elseif (is_dir($src)) {
207 244 $scan = glob(rtrim($src, '/') . '/*');
@@ -208,6 +245,43 @@
208 245 foreach ($scan as $path) {
209 246 self::recursiveCopyFiles($path, $dst . '/' . basename($path));
210 247 }
211 248 }
249 + }
250 +
251 + public static function arrayToCssString($array)
252 + {
253 + $cssString = '';
254 +
255 + foreach ($array as $selector => $properties) {
256 + $cssString .= $selector . ' {';
257 +
258 + foreach ($properties as $property => $value) {
259 + $cssString .= $property . ': ' . $value . '; ';
260 + }
261 +
262 + // Remove the trailing space and add closing brace
263 + $cssString = rtrim($cssString, ' ') . '}';
264 + }
265 +
266 + return $cssString;
267 + }
268 +
269 + public static function formatFormData($formData)
270 + {
271 + $newFormData = json_decode(wp_json_encode($formData));
272 +
273 + $formContent = json_decode(wp_json_encode($formData->form_content));
274 +
275 + $newFormData->fields = $formContent->fields;
276 + $newFormData->layout = $formContent->layout;
277 + $newFormData->nestedLayouts = $formContent->nestedLayout;
278 + $newFormData->formInfo = $formContent->formInfo;
279 +
280 + if (is_array($formData->reports) && count($formData->reports) > 0) {
281 + $newFormData->currentReport = $formData->reports[0];
282 + $newFormData->report_id = $formData->reports[0]->id;
283 + }
284 +
285 + return $newFormData;
212 286 }
213 287 }