| @@ -21,15 +21,16 @@ | ||
| 21 | 21 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 22 | 22 | use BitCode\BitForm\Core\Messages\EmailTemplateHandler; |
| 23 | 23 | use BitCode\BitForm\Core\Messages\PdfTemplateHandler; |
| 24 | 24 | use BitCode\BitForm\Core\Messages\SuccessMessageHandler; |
| 25 | +use BitCode\BitForm\Core\Migration\MigrationHelper; | |
| 25 | 26 | use BitCode\BitForm\Core\Util\FileHandler; |
| 26 | 27 | use BitCode\BitForm\Core\Util\FormDuplicateHelper; |
| 27 | 28 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 28 | 29 | use BitCode\BitForm\Core\Util\IpTool; |
| 30 | +use BitCode\BitForm\Core\Util\Utilities; | |
| 29 | 31 | use BitCode\BitForm\Core\WorkFlow\WorkFlow; |
| 30 | 32 | use BitCode\BitForm\Core\WorkFlow\WorkFlowHandler; |
| 31 | -use BitCode\BitFormPro\Admin\AppSetting\Pdf; | |
| 32 | 33 | use WP_Error; |
| 33 | 34 | |
| 34 | 35 | class AdminFormHandler |
| 35 | 36 | { |
| @@ -176,9 +177,9 @@ | ||
| 176 | 177 | |
| 177 | 178 | private function pdfFontDownload($fontName) |
| 178 | 179 | { |
| 179 | 180 | if (class_exists('\BitCode\BitFormPro\Admin\AppSetting\Pdf')) { |
| 180 | - Pdf::getInstance()->fontsDownload($fontName); | |
| 181 | + \BitCode\BitFormPro\Admin\AppSetting\Pdf::getInstance()->fontsDownload($fontName); | |
| 181 | 182 | } |
| 182 | 183 | return false; |
| 183 | 184 | } |
| 184 | 185 | |
| @@ -217,11 +218,12 @@ | ||
| 217 | 218 | |
| 218 | 219 | $fields = wp_unslash($post->fields); |
| 219 | 220 | // $fields = $post->fields; |
| 220 | 221 | $layout = wp_unslash($post->layout); |
| 221 | - $nestedLayout = isset($post->nestedLayout) ? wp_unslash($post->nestedLayout) : (object) []; | |
| 222 | + $nestedLayout = isset($post->nestedLayouts) ? wp_unslash($post->nestedLayouts) : (object) []; | |
| 222 | 223 | $formInfo = wp_unslash($post->formInfo); |
| 223 | 224 | $form_name = wp_unslash($post->form_name); |
| 225 | + $form_name = strlen($form_name) > 50 ? substr($form_name, 0, 50) : $form_name; | |
| 224 | 226 | $formSettings = (object) wp_unslash($post->formSettings); |
| 225 | 227 | $atomic_class_map = isset($post->atomicClassMap) ? wp_unslash($post->atomicClassMap) : []; |
| 226 | 228 | $breakpointSize = wp_unslash($post->breakpointSize); |
| 227 | 229 | $style = $post->style; |
| @@ -235,8 +237,9 @@ | ||
| 235 | 237 | |
| 236 | 238 | $mailTem = $formSettings->mailTem; |
| 237 | 239 | $pdfTem = $formSettings->pdfTem; |
| 238 | 240 | $integrations = $formSettings->integrations; |
| 241 | + $formPermissions = $formSettings->formPermissions; | |
| 239 | 242 | |
| 240 | 243 | $user_details = static::$ipTool->getUserDetail(); |
| 241 | 244 | if (empty($fields) || empty($layout)) { |
| 242 | 245 | return new WP_Error( |
| @@ -263,8 +266,12 @@ | ||
| 263 | 266 | if (!empty($formSettings->theme)) { |
| 264 | 267 | $form_content = array_merge($form_content, ['theme' => $formSettings->theme]); |
| 265 | 268 | } |
| 266 | 269 | |
| 270 | + if (!empty($formSettings->formPermissions)) { | |
| 271 | + $form_content = array_merge($form_content, ['formPermissions' => $formSettings->formPermissions]); | |
| 272 | + } | |
| 273 | + | |
| 267 | 274 | if (!empty($additional)) { |
| 268 | 275 | $form_content = array_merge($form_content, ['additional' => $additional]); |
| 269 | 276 | } |
| 270 | 277 | if (!empty($workFlows)) { |
| @@ -365,24 +372,33 @@ | ||
| 365 | 372 | } |
| 366 | 373 | } |
| 367 | 374 | } |
| 368 | 375 | // Email Template [end] */ |
| 369 | - // if (!empty($pdfTem)) { | |
| 370 | - // $pdfTemplateHandler = new PdfTemplateHandler($formID); | |
| 371 | - // foreach ($pdfTem as $templateKey => $templateDetail) { | |
| 372 | - // $savedID = $pdfTemplateHandler->save($templateDetail); | |
| 373 | 376 | |
| 374 | - // $pdfSetting = $templateDetail->setting; | |
| 377 | + // PDF Template [start] | |
| 378 | + if (!empty($pdfTem)) { | |
| 379 | + $pdfTemplateHandler = new PdfTemplateHandler($formID); | |
| 380 | + $workFlowString = ''; | |
| 381 | + if (!empty($workFlows)) { | |
| 382 | + $workFlowString = wp_json_encode($workFlows); | |
| 383 | + } | |
| 384 | + foreach ($pdfTem as $templateDetail) { | |
| 385 | + $savedID = $pdfTemplateHandler->save($templateDetail); | |
| 375 | 386 | |
| 376 | - // if( isset($pdfSetting->font->name) && !empty($pdfSetting->font->name)) { | |
| 377 | - // $this->pdfFontDownload($pdfSetting->font->name); | |
| 378 | - // } | |
| 379 | - // // if ($savedID) { | |
| 380 | - // // $tempIdx = empty($templateDetail->id) ? $templateKey : wp_json_encode(['id' => $templateDetail->id]); | |
| 381 | - // // $integartionIDForWorkflow['mailNotify'][$tempIdx] = $savedID; | |
| 382 | - // // } | |
| 383 | - // } | |
| 384 | - // } | |
| 387 | + $pdfSetting = $templateDetail->setting; | |
| 388 | + | |
| 389 | + if (isset($pdfSetting->font->name) && !empty($pdfSetting->font->name)) { | |
| 390 | + $this->pdfFontDownload($pdfSetting->font->name); | |
| 391 | + } | |
| 392 | + if (!empty($workFlowString)) { | |
| 393 | + $workFlowString = str_replace('"pdfId":"{\"id\":\"' . $templateDetail->id . '\"}"', '"pdfId":"{\"id\":\"' . $savedID . '\"}"', $workFlowString); | |
| 394 | + } | |
| 395 | + } | |
| 396 | + if (!empty($workFlowString) && !empty($workFlows)) { | |
| 397 | + $workFlows = json_decode($workFlowString); | |
| 398 | + } | |
| 399 | + } | |
| 400 | + // PDF Template [end] */ | |
| 385 | 401 | //Integration [start] */ |
| 386 | 402 | $integrationHandler = new IntegrationHandler($formID, $user_details); |
| 387 | 403 | if (!empty($formSettings->confirmation->type)) { |
| 388 | 404 | $allIntegrations = $formSettings->confirmation->type; |
| @@ -557,8 +573,12 @@ | ||
| 557 | 573 | } */ |
| 558 | 574 | if (!empty($formSettings->theme)) { |
| 559 | 575 | $form_content = array_merge($form_content, ['theme' => $formSettings->theme]); |
| 560 | 576 | } |
| 577 | + | |
| 578 | + if (!empty($formSettings->formPermissions)) { | |
| 579 | + $form_content = array_merge($form_content, ['formPermissions' => $formSettings->formPermissions]); | |
| 580 | + } | |
| 561 | 581 | if (!empty($additional)) { |
| 562 | 582 | $form_content = array_merge($form_content, ['additional' => $additional]); |
| 563 | 583 | } |
| 564 | 584 | $integartionIDForWorkflow = []; |
| @@ -566,8 +586,9 @@ | ||
| 566 | 586 | $newData['integation'] = 0; |
| 567 | 587 | $newData['mailTemplate'] = 0; |
| 568 | 588 | $newData['workflow'] = 0; |
| 569 | 589 | $newData['reports'] = 0; |
| 590 | + $newData['pdfTemplate'] = 0; | |
| 570 | 591 | // Confiramtion Message [start] |
| 571 | 592 | if (!empty($formSettings->confirmation->type->successMsg)) { |
| 572 | 593 | $successMessages = $formSettings->confirmation->type->successMsg; |
| 573 | 594 | $successMessageHandler |
| @@ -701,8 +722,9 @@ | ||
| 701 | 722 | } |
| 702 | 723 | if ('oninput' === $workFlow->action_type || ('always' === $workFlow->action_type && 'cond' === $workFlow->action_behaviour)) { |
| 703 | 724 | $workFlowExist['oninput'] = true; |
| 704 | 725 | } |
| 726 | + // $integartionIDForWorkflow = apply_filters('bitform_filter_integration_id', $workFlow, $formID, $index); | |
| 705 | 727 | if (empty($workFlow->id)) { |
| 706 | 728 | $savedID = $workFlowHandler->saveworkFlow($workFlow, $integartionIDForWorkflow, $index); |
| 707 | 729 | if (is_wp_error($savedID) && 'result_empty' !== $savedID->get_error_code()) { |
| 708 | 730 | $newData['workflow'] = 2; |
| @@ -820,9 +842,9 @@ | ||
| 820 | 842 | } |
| 821 | 843 | |
| 822 | 844 | $updated_data = $this->getAForm(['id' => $formID], null); |
| 823 | 845 | |
| 824 | - if (0 === $newData['settingConfiramation'] && 0 === $newData['mailTemplate'] && 0 === $newData['integation']) { | |
| 846 | + if (0 === $newData['settingConfiramation'] && 0 === $newData['mailTemplate'] && 0 === $newData['integation'] && 0 === $newData['pdfTemplate']) { | |
| 825 | 847 | unset($updated_data['formSettings']); |
| 826 | 848 | } |
| 827 | 849 | if (0 === $newData['integation']) { |
| 828 | 850 | unset($updated_data['integrations']); |
| @@ -834,13 +856,13 @@ | ||
| 834 | 856 | unset($updated_data['mailTem']); |
| 835 | 857 | } elseif (2 === $newData['mailTemplate']) { |
| 836 | 858 | $errorIN .= empty($errorIN) ? 'mailTemplate' : ', mailTemplate'; |
| 837 | 859 | } |
| 838 | - // if (0 === $newData['pdfTemplate']) { | |
| 839 | - // unset($updated_data['pdfTem']); | |
| 840 | - // } elseif (2 === $newData['pdfTemplate']) { | |
| 841 | - // $errorIN .= empty($errorIN) ? 'pdfTemplate' : ', pdfTemplate'; | |
| 842 | - // } | |
| 860 | + if (0 === $newData['pdfTemplate']) { | |
| 861 | + unset($updated_data['pdfTem']); | |
| 862 | + } elseif (2 === $newData['pdfTemplate']) { | |
| 863 | + $errorIN .= empty($errorIN) ? 'pdfTemplate' : ', pdfTemplate'; | |
| 864 | + } | |
| 843 | 865 | if (0 === $newData['workflow']) { |
| 844 | 866 | unset($updated_data['workFlows']); |
| 845 | 867 | } elseif (2 === $newData['workflow']) { |
| 846 | 868 | $errorIN .= empty($errorIN) ? 'workflow' : ', workflow'; |
| @@ -1068,10 +1090,11 @@ | ||
| 1068 | 1090 | } |
| 1069 | 1091 | } |
| 1070 | 1092 | } |
| 1071 | 1093 | $settingsContent = [ |
| 1072 | - 'formName' => $formManager->getFormName(), | |
| 1073 | - 'theme' => isset($form_content->theme) ? $form_content->theme : 'default', | |
| 1094 | + 'formName' => $formManager->getFormName(), | |
| 1095 | + 'theme' => isset($form_content->theme) ? $form_content->theme : 'default', | |
| 1096 | + 'formPermissions' => isset($form_content->formPermissions) ? $form_content->formPermissions : (object) [], | |
| 1074 | 1097 | // 'submitBtn' => $form_content->buttons, |
| 1075 | 1098 | ]; |
| 1076 | 1099 | |
| 1077 | 1100 | if (!empty($allConfirmation)) { |
| @@ -1219,8 +1242,225 @@ | ||
| 1219 | 1242 | return $data; |
| 1220 | 1243 | } |
| 1221 | 1244 | } |
| 1222 | 1245 | |
| 1246 | + public function getAFormV1($Request, $post) | |
| 1247 | + { | |
| 1248 | + if (isset($Request['id'])) { | |
| 1249 | + $formID = wp_unslash($Request['id']); | |
| 1250 | + } else { | |
| 1251 | + $formID = wp_unslash($post->id); | |
| 1252 | + } | |
| 1253 | + // return $post->fields; | |
| 1254 | + if (is_null($formID)) { | |
| 1255 | + return new WP_Error('empty_form', __('Form id is empty.', 'bit-form')); | |
| 1256 | + } | |
| 1257 | + $formManager = new AdminFormManager($formID); | |
| 1258 | + if (!$formManager->isExist()) { | |
| 1259 | + return new WP_Error('not_exists', __('Form is not exists.', 'bit-form')); | |
| 1260 | + } | |
| 1261 | + $form_content = $formManager->getFormContent(); | |
| 1262 | + if ($formManager->isExist()) { | |
| 1263 | + $form_content_arr = [ | |
| 1264 | + 'layout' => $form_content->layout, | |
| 1265 | + 'fields' => $form_content->fields, | |
| 1266 | + 'form_name' => $formManager->getFormName(), | |
| 1267 | + 'workFlowExist' => $form_content->workFlowExist, | |
| 1268 | + 'report_id' => isset($form_content->report_id) ? $form_content->report_id : null | |
| 1269 | + ]; | |
| 1270 | + $successMessageHandler | |
| 1271 | + = new SuccessMessageHandler($formID); | |
| 1272 | + $successMessages = $successMessageHandler->getAllMessage(); | |
| 1273 | + if (!is_wp_error($successMessages)) { | |
| 1274 | + foreach ($successMessages as $sucessMessagekey => $sucessMessagevalue) { | |
| 1275 | + $allConfirmation['type']['successMsg'][$sucessMessagekey] = | |
| 1276 | + [ | |
| 1277 | + 'id' => $sucessMessagevalue->id, | |
| 1278 | + 'title' => $sucessMessagevalue->message_title, | |
| 1279 | + 'msg' => $sucessMessagevalue->message_content, | |
| 1280 | + ]; | |
| 1281 | + } | |
| 1282 | + } | |
| 1283 | + $emailTemplateHandler | |
| 1284 | + = new EmailTemplateHandler($formID); | |
| 1285 | + $emailTemplates = $emailTemplateHandler->getAllTemplate(); | |
| 1286 | + if (!is_wp_error($emailTemplates)) { | |
| 1287 | + foreach ($emailTemplates as $emailTemplatekey => $emailTemplatevalue) { | |
| 1288 | + $mailTem[] = | |
| 1289 | + [ | |
| 1290 | + 'id' => $emailTemplatevalue->id, | |
| 1291 | + 'title' => $emailTemplatevalue->title, | |
| 1292 | + 'sub' => $emailTemplatevalue->sub, | |
| 1293 | + 'body' => $emailTemplatevalue->body, | |
| 1294 | + ]; | |
| 1295 | + } | |
| 1296 | + } | |
| 1297 | + $integrationHandler = new IntegrationHandler($formID); | |
| 1298 | + $formIntegrations = $integrationHandler->getAllIntegration('form'); | |
| 1299 | + if (!is_wp_error($formIntegrations)) { | |
| 1300 | + foreach ($formIntegrations as $integrationkey => $integrationValue) { | |
| 1301 | + if ('redirectPage' === $integrationValue->integration_type || 'webHooks' === $integrationValue->integration_type) { | |
| 1302 | + $integrationData = [ | |
| 1303 | + 'id' => $integrationValue->id, | |
| 1304 | + 'title' => $integrationValue->integration_name, | |
| 1305 | + ]; | |
| 1306 | + if (!empty($integrationValue->integration_details)) { | |
| 1307 | + // var_dump(json_decode($integrationValue->integration_details)); | |
| 1308 | + $integration_details = (array) json_decode($integrationValue->integration_details); | |
| 1309 | + $integrationData = array_merge($integration_details, $integrationData); | |
| 1310 | + } else { | |
| 1311 | + $integration_details = [ | |
| 1312 | + 'url' => '', | |
| 1313 | + ]; | |
| 1314 | + $integrationData = array_merge($integrationData, $integration_details); | |
| 1315 | + } | |
| 1316 | + $allConfirmation['type'][$integrationValue->integration_type][] | |
| 1317 | + = $integrationData; | |
| 1318 | + } else { | |
| 1319 | + $integrationData = [ | |
| 1320 | + 'id' => $integrationValue->id, | |
| 1321 | + 'name' => $integrationValue->integration_name, | |
| 1322 | + 'type' => $integrationValue->integration_type, | |
| 1323 | + ]; | |
| 1324 | + $integrations[] = array_merge( | |
| 1325 | + $integrationData, | |
| 1326 | + is_string($integrationValue->integration_details) ? | |
| 1327 | + (array) json_decode($integrationValue->integration_details) : | |
| 1328 | + $integrationValue->integration_details | |
| 1329 | + ); | |
| 1330 | + } | |
| 1331 | + } | |
| 1332 | + } | |
| 1333 | + $settingsContent = [ | |
| 1334 | + 'formName' => $formManager->getFormName(), | |
| 1335 | + 'theme' => $form_content->theme, | |
| 1336 | + // 'submitBtn' => $form_content->buttons, | |
| 1337 | + ]; | |
| 1338 | + | |
| 1339 | + if (!empty($allConfirmation)) { | |
| 1340 | + $confirmation = [ | |
| 1341 | + 'confirmation' => $allConfirmation, | |
| 1342 | + ]; | |
| 1343 | + } else { | |
| 1344 | + $confirmation = [ | |
| 1345 | + 'confirmation' => ['type' => []], | |
| 1346 | + ]; | |
| 1347 | + } | |
| 1348 | + $settingsContent = array_merge($settingsContent, $confirmation); | |
| 1349 | + if (!empty($integrations)) { | |
| 1350 | + $settingsContent = array_merge( | |
| 1351 | + $settingsContent, | |
| 1352 | + [ | |
| 1353 | + 'integrations' => $integrations, | |
| 1354 | + ] | |
| 1355 | + ); | |
| 1356 | + } else { | |
| 1357 | + $settingsContent = array_merge( | |
| 1358 | + $settingsContent, | |
| 1359 | + [ | |
| 1360 | + 'integrations' => [] | |
| 1361 | + ] | |
| 1362 | + ); | |
| 1363 | + } | |
| 1364 | + if (!empty($mailTem)) { | |
| 1365 | + $settingsContent = array_merge( | |
| 1366 | + $settingsContent, | |
| 1367 | + [ | |
| 1368 | + 'mailTem' => $mailTem, | |
| 1369 | + ] | |
| 1370 | + ); | |
| 1371 | + } else { | |
| 1372 | + $settingsContent = array_merge( | |
| 1373 | + $settingsContent, | |
| 1374 | + [ | |
| 1375 | + 'mailTem' => [] | |
| 1376 | + ] | |
| 1377 | + ); | |
| 1378 | + } | |
| 1379 | + $formSettings = [ | |
| 1380 | + 'formSettings' => $settingsContent, | |
| 1381 | + ]; | |
| 1382 | + $data = [ | |
| 1383 | + 'id' => $formID, | |
| 1384 | + 'form_name' => $formManager->getFormName(), | |
| 1385 | + 'form_content' => $form_content_arr, | |
| 1386 | + 'additional' => empty($form_content->additional) ? [ | |
| 1387 | + 'enabled' => [ | |
| 1388 | + 'blocked_ip' => false, | |
| 1389 | + 'restrict_form' => false, | |
| 1390 | + ], | |
| 1391 | + 'settings' => [ | |
| 1392 | + 'restrict_form' => [ | |
| 1393 | + 'day' => [], | |
| 1394 | + 'date' => [ | |
| 1395 | + 'from' => null, | |
| 1396 | + 'to' => null, | |
| 1397 | + ], | |
| 1398 | + 'time' => [ | |
| 1399 | + 'from' => null, | |
| 1400 | + 'to' => null, | |
| 1401 | + ], | |
| 1402 | + ], | |
| 1403 | + 'entry_limit' => null, | |
| 1404 | + 'blocked_ip' => [], | |
| 1405 | + ], | |
| 1406 | + 'onePerIp' => false, | |
| 1407 | + ] : $form_content->additional, | |
| 1408 | + 'created_at' => $formManager->getFormMetaData()['created_at'], | |
| 1409 | + 'views' => $formManager->getFormMetaData()['views'], | |
| 1410 | + 'entries' => $formManager->getFormMetaData()['entries'], | |
| 1411 | + 'status' => $formManager->getFormMetaData()['status'], | |
| 1412 | + ]; | |
| 1413 | + $data = array_merge($data, $formSettings); | |
| 1414 | + $workFlowHandler = new WorkFlowHandler($formID); | |
| 1415 | + $workFlows = ['workFlows' => $workFlowHandler->getAllworkFlowV1()]; | |
| 1416 | + $data = array_merge($data, $workFlows); | |
| 1417 | + $reportsModel = new ReportsModel(); | |
| 1418 | + $returnedReportData = $reportsModel->get( | |
| 1419 | + [ | |
| 1420 | + 'id', | |
| 1421 | + 'details', | |
| 1422 | + 'isDefault', | |
| 1423 | + 'type', | |
| 1424 | + ], | |
| 1425 | + [ | |
| 1426 | + 'category' => 'form', | |
| 1427 | + 'context' => $formID, | |
| 1428 | + ] | |
| 1429 | + ); | |
| 1430 | + | |
| 1431 | + if (!is_wp_error($returnedReportData)) { | |
| 1432 | + $fieldNames = []; | |
| 1433 | + foreach ($formManager->getFieldLabel() as $key => $field) { | |
| 1434 | + $fieldNames[$field['key']] = isset($field->lbl) ? $field->lbl : ''; | |
| 1435 | + } | |
| 1436 | + if ($formManager->isGCLIDEnabled()) { | |
| 1437 | + $fieldNames['GCLID'] = 'GCLID'; | |
| 1438 | + } | |
| 1439 | + foreach ($returnedReportData as $reportKey => $reportData) { | |
| 1440 | + $reportDetails = $reportsModel->validateReportFields($reportData, $fieldNames); | |
| 1441 | + if (!empty($reportDetails) && is_string($reportDetails)) { | |
| 1442 | + $returnedReportData[$reportKey]->details = json_decode($reportDetails); | |
| 1443 | + } elseif (!empty($reportDetails)) { | |
| 1444 | + $returnedReportData[$reportKey]->details = $reportDetails; | |
| 1445 | + } else { | |
| 1446 | + $returnedReportData[$reportKey]->details = []; | |
| 1447 | + } | |
| 1448 | + if ('1' === (string) $reportData->isDefault) { | |
| 1449 | + $returnedReportData[$reportKey]->details->report_name = 'All Entries'; | |
| 1450 | + } | |
| 1451 | + } | |
| 1452 | + $reports = ['reports' => $returnedReportData]; | |
| 1453 | + $data = array_merge($data, $reports); | |
| 1454 | + } | |
| 1455 | + | |
| 1456 | + $formFields = $formManager->getFieldLabel(); | |
| 1457 | + $data = array_merge($data, ['Labels' => $formFields]); | |
| 1458 | + | |
| 1459 | + return $data; | |
| 1460 | + } | |
| 1461 | + } | |
| 1462 | + | |
| 1223 | 1463 | public function deleteAForm($Request, $post) |
| 1224 | 1464 | { |
| 1225 | 1465 | if (isset($Request['id'])) { |
| 1226 | 1466 | $formID = wp_unslash($Request['id']); |
| @@ -1229,8 +1469,13 @@ | ||
| 1229 | 1469 | } |
| 1230 | 1470 | if (is_null($formID)) { |
| 1231 | 1471 | return new WP_Error('empty_form', __('Form id is empty.', 'bit-form')); |
| 1232 | 1472 | } |
| 1473 | + | |
| 1474 | + if (!filter_var($formID, FILTER_VALIDATE_INT)) { | |
| 1475 | + return new WP_Error('invalid_form', __('Form id is invalid.', 'bit-form')); | |
| 1476 | + } | |
| 1477 | + | |
| 1233 | 1478 | $delete_status = static::$formModel->delete( |
| 1234 | 1479 | [ |
| 1235 | 1480 | 'id' => $formID, |
| 1236 | 1481 | ] |
| @@ -1235,14 +1480,12 @@ | ||
| 1235 | 1480 | 'id' => $formID, |
| 1236 | 1481 | ] |
| 1237 | 1482 | ); |
| 1238 | 1483 | |
| 1239 | - $successMessageModel | |
| 1240 | - = new SuccessMessageModel(); | |
| 1484 | + $successMessageModel = new SuccessMessageModel(); | |
| 1241 | 1485 | $deleteMsgStatus = $successMessageModel->delete(['form_id' => $formID]); |
| 1242 | 1486 | |
| 1243 | - $emailTemplateModel | |
| 1244 | - = new EmailTemplateModel(); | |
| 1487 | + $emailTemplateModel = new EmailTemplateModel(); | |
| 1245 | 1488 | $deleteTemplateStatus = $emailTemplateModel->delete(['form_id' => $formID]); |
| 1246 | 1489 | |
| 1247 | 1490 | $pdfTemplateModel = new PdfTemplateModel(); |
| 1248 | 1491 | $deletePdfTemplateStatus = $pdfTemplateModel->delete(['form_id' => $formID]); |
| @@ -1259,22 +1502,11 @@ | ||
| 1259 | 1502 | $formEntryModel = new FormEntryModel(); |
| 1260 | 1503 | $returnedEntries = $formEntryModel->get('id', ['form_id' => $formID]); |
| 1261 | 1504 | $entries = []; |
| 1262 | 1505 | |
| 1263 | - if (!is_wp_error($returnedEntries)) { | |
| 1264 | - foreach ($returnedEntries as $entryKey => $entryInfo) { | |
| 1265 | - $entries[] = $entryInfo->id; | |
| 1266 | - } | |
| 1267 | - global $wpdb; | |
| 1268 | - $prefix = $wpdb->prefix; | |
| 1269 | - if (count($entries) > 0) { | |
| 1270 | - $deleteEntriesStatus = $formEntryModel->bulkDelete( | |
| 1271 | - [ | |
| 1272 | - "`{$prefix}bitforms_form_entries`.`id`" => $entries, | |
| 1273 | - "`{$prefix}bitforms_form_entries`.`form_id`" => $formID, | |
| 1274 | - ] | |
| 1275 | - ); | |
| 1276 | - } | |
| 1506 | + // checked namespace exist | |
| 1507 | + if (class_exists('\BitCode\BitFormPro\Admin\BfTable\Table')) { | |
| 1508 | + \BitCode\BitFormPro\Admin\BfTable\Table::deleteTableByFormId($formID); | |
| 1277 | 1509 | } |
| 1278 | 1510 | |
| 1279 | 1511 | $fileHandler = new FileHandler(); |
| 1280 | 1512 | if (file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID)) { |
| @@ -1282,23 +1514,25 @@ | ||
| 1282 | 1514 | } |
| 1283 | 1515 | if (file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID)) { |
| 1284 | 1516 | $fileHandler->rmrf(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID); |
| 1285 | 1517 | } |
| 1286 | - if (file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-' . $formID . '.css')) { | |
| 1287 | - unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-' . $formID . '.css'); | |
| 1288 | - } | |
| 1289 | - if (file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-layout-' . $formID . '.css')) { | |
| 1290 | - unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-layout-' . $formID . '.css'); | |
| 1291 | - } | |
| 1292 | - if (file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-custom-' . $formID . '.css')) { | |
| 1293 | - unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-custom-' . $formID . '.css'); | |
| 1294 | - } | |
| 1295 | - if (file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-scripts' . DIRECTORY_SEPARATOR . 'bitform-custom-' . $formID . '.js')) { | |
| 1296 | - unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-scripts' . DIRECTORY_SEPARATOR . 'bitform-custom-' . $formID . '.js'); | |
| 1297 | - } | |
| 1298 | - if (file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-conversational-' . $formID . '.css')) { | |
| 1299 | - unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-conversational-' . $formID . '.css'); | |
| 1300 | - } | |
| 1518 | + $formStylePath = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles'; | |
| 1519 | + | |
| 1520 | + $formCssPath = $formStylePath . DIRECTORY_SEPARATOR . 'bitform-' . $formID . '.css'; | |
| 1521 | + FileHandler::deleteIsFileExists($formCssPath); | |
| 1522 | + | |
| 1523 | + $layoutCssPath = $formStylePath . DIRECTORY_SEPARATOR . 'bitform-layout-' . $formID . '.css'; | |
| 1524 | + FileHandler::deleteIsFileExists($layoutCssPath); | |
| 1525 | + | |
| 1526 | + $customCssPath = $formStylePath . DIRECTORY_SEPARATOR . 'bitform-custom-' . $formID . '.css'; | |
| 1527 | + FileHandler::deleteIsFileExists($customCssPath); | |
| 1528 | + | |
| 1529 | + $customJSPath = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-scripts' . DIRECTORY_SEPARATOR . 'bitform-custom-' . $formID . '.js'; | |
| 1530 | + FileHandler::deleteIsFileExists($customJSPath); | |
| 1531 | + | |
| 1532 | + $conversationCssPath = $formStylePath . DIRECTORY_SEPARATOR . 'bitform-conversational-' . $formID . '.css'; | |
| 1533 | + FileHandler::deleteIsFileExists($conversationCssPath); | |
| 1534 | + | |
| 1301 | 1535 | return is_wp_error($delete_status) ? $delete_status : __('Form deleted successfully.', 'bit-form'); |
| 1302 | 1536 | } |
| 1303 | 1537 | |
| 1304 | 1538 | public function deleteBlukForm($Request, $post) |
| @@ -1307,20 +1541,27 @@ | ||
| 1307 | 1541 | $formID = wp_unslash($Request['formID']); |
| 1308 | 1542 | } else { |
| 1309 | 1543 | $formID = wp_unslash($post->formID); |
| 1310 | 1544 | } |
| 1545 | + | |
| 1311 | 1546 | if (is_null($formID) || !is_array($formID)) { |
| 1312 | 1547 | return new WP_Error('empty_form', __('Form id is empty.', 'bit-form')); |
| 1313 | 1548 | } |
| 1549 | + | |
| 1550 | + if (!Helpers::checkIsIntArr($formID)) { | |
| 1551 | + return new WP_Error('invalid_form', __('Form id is invalid', 'bit-form')); | |
| 1552 | + } | |
| 1553 | + | |
| 1314 | 1554 | $cssPath = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR; |
| 1315 | 1555 | foreach ($formID as $id) { |
| 1316 | - unlink($cssPath . 'bitform-' . $id . '.css'); | |
| 1317 | - if (file_exists($cssPath . 'bitform-layout-' . $id . '.css')) { | |
| 1318 | - unlink($cssPath . 'bitform-layout-' . $id . '.css'); | |
| 1319 | - } | |
| 1320 | - if (file_exists($cssPath . 'bitform-' . $id . '-formid' . '.css')) { | |
| 1321 | - unlink($cssPath . 'bitform-' . $id . '-formid' . '.css'); | |
| 1322 | - } | |
| 1556 | + $formCssPath = $cssPath . 'bitform-' . $id . '.css'; | |
| 1557 | + FileHandler::deleteIsFileExists($formCssPath); | |
| 1558 | + | |
| 1559 | + $layoutPath = $cssPath . 'bitform-layout-' . $id . '.css'; | |
| 1560 | + FileHandler::deleteIsFileExists($layoutPath); | |
| 1561 | + | |
| 1562 | + $bitformCustomPath = $cssPath . 'bitform-' . $id . '-formid' . '.css'; | |
| 1563 | + FileHandler::deleteIsFileExists($bitformCustomPath); | |
| 1323 | 1564 | } |
| 1324 | 1565 | $delete_status = static::$formModel->bulkDelete( |
| 1325 | 1566 | [ |
| 1326 | 1567 | 'id' => $formID, |
| @@ -1325,16 +1566,23 @@ | ||
| 1325 | 1566 | [ |
| 1326 | 1567 | 'id' => $formID, |
| 1327 | 1568 | ] |
| 1328 | 1569 | ); |
| 1570 | + | |
| 1571 | + if (is_wp_error($delete_status)) { | |
| 1572 | + wp_send_json_error($delete_status->get_error_message(), 400); | |
| 1573 | + } | |
| 1574 | + | |
| 1329 | 1575 | $successMessageModel |
| 1330 | 1576 | = new SuccessMessageModel(); |
| 1331 | 1577 | $deleteMsgStatus = $successMessageModel->bulkDelete(['form_id' => $formID]); |
| 1332 | 1578 | |
| 1333 | - $emailTemplateModel | |
| 1334 | - = new EmailTemplateModel(); | |
| 1579 | + $emailTemplateModel = new EmailTemplateModel(); | |
| 1335 | 1580 | $deleteTemplateStatus = $emailTemplateModel->bulkDelete(['form_id' => $formID]); |
| 1336 | 1581 | |
| 1582 | + $pdfTemplateModel = new PdfTemplateModel(); | |
| 1583 | + $deletePdfTemplateStatus = $pdfTemplateModel->bulkDelete(['form_id' => $formID]); | |
| 1584 | + | |
| 1337 | 1585 | $integrationModel = new IntegrationModel(); |
| 1338 | 1586 | $deleteIntegrationStatus = $integrationModel->bulkDelete(['form_id' => $formID]); |
| 1339 | 1587 | |
| 1340 | 1588 | $workFlowModel = new WorkFlowModel(); |
| @@ -1344,8 +1592,13 @@ | ||
| 1344 | 1592 | $deleteReportStatus = $reportsModel->bulkDelete(['context' => $formID]); |
| 1345 | 1593 | |
| 1346 | 1594 | $formEntryModel = new FormEntryModel(); |
| 1347 | 1595 | $returnedEntries = $formEntryModel->get('id', ['form_id' => $formID]); |
| 1596 | + | |
| 1597 | + if (class_exists('\BitCode\BitFormPro\Admin\BfTable\Table')) { | |
| 1598 | + \BitCode\BitFormPro\Admin\BfTable\Table::deleteTableByBulkFormId($formID); | |
| 1599 | + } | |
| 1600 | + | |
| 1348 | 1601 | $entries = []; |
| 1349 | 1602 | foreach ($returnedEntries as $entryKey => $entryInfo) { |
| 1350 | 1603 | if (!empty($entryInfo->id)) { |
| 1351 | 1604 | $entries[] = $entryInfo->id; |
| @@ -1366,11 +1619,8 @@ | ||
| 1366 | 1619 | foreach ($formID as $fId) { |
| 1367 | 1620 | if (file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $fId)) { |
| 1368 | 1621 | $fileHandler->rmrf(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $fId); |
| 1369 | 1622 | } |
| 1370 | - | |
| 1371 | - // unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-' . $fId . '.css'); | |
| 1372 | - // unlink(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . 'bitform-layout-' . $fId . '.css'); | |
| 1373 | 1623 | } |
| 1374 | 1624 | |
| 1375 | 1625 | return is_wp_error($delete_status) ? $delete_status : __('Forms deleted successfully.', 'bit-form'); |
| 1376 | 1626 | } |
| @@ -1442,9 +1692,9 @@ | ||
| 1442 | 1692 | } |
| 1443 | 1693 | $importtedForm = (array)$post->formDetail; |
| 1444 | 1694 | $importtedForm['form_content']['fields'] = $importtedForm['fields']; |
| 1445 | 1695 | $importtedForm['form_content']['layout'] = $importtedForm['layout']; |
| 1446 | - $importtedForm['form_content']['nestedLayout'] = $importtedForm['nestedLayout']; | |
| 1696 | + $importtedForm['form_content']['nestedLayout'] = $importtedForm['nestedLayouts']; | |
| 1447 | 1697 | $importtedForm['form_content']['formInfo'] = $importtedForm['formInfo']; |
| 1448 | 1698 | unset($importtedForm['fields'], $importtedForm['layout'], $importtedForm['nestedLayout'], $importtedForm['formInfo']); |
| 1449 | 1699 | $formData = FormDuplicateHelper::createReplica((array)$importtedForm, $oldFormId, $newFormId); |
| 1450 | 1700 | |
| @@ -1457,10 +1707,29 @@ | ||
| 1457 | 1707 | $formData->layoutChanged = '-'; |
| 1458 | 1708 | } |
| 1459 | 1709 | $importResponse = $this->createNewForm(null, $formData); |
| 1460 | 1710 | |
| 1711 | + $customCode = []; | |
| 1712 | + // add custom js | |
| 1713 | + if (!empty($formData->customCode->customJs)) { | |
| 1714 | + $customJsPath = 'form-scripts'; | |
| 1715 | + $fileName = 'bitform-custom-' . $newFormId . '.js'; | |
| 1716 | + $customCode['JavaScript'] = $formData->customCode->customJs; | |
| 1717 | + Helpers::saveFile($customJsPath, $fileName, $formData->customCode->customJs, 'w'); | |
| 1718 | + } | |
| 1719 | + // add custom css | |
| 1720 | + if (!empty($formData->customCode->customCss)) { | |
| 1721 | + $customCssPath = 'form-styles'; | |
| 1722 | + $fileName = 'bitform-custom-' . $newFormId . '.css'; | |
| 1723 | + $customCode['CSS'] = $formData->customCode->customCss; | |
| 1724 | + Helpers::saveFile($customCssPath, $fileName, $formData->customCode->customCss, 'w'); | |
| 1725 | + } | |
| 1726 | + if (!is_wp_error($importResponse)) { | |
| 1727 | + $importResponse['customCode'] = $customCode; | |
| 1728 | + } | |
| 1461 | 1729 | if (!is_wp_error($importResponse) || (is_wp_error($importResponse) && 'result_empty' === $importResponse->get_error_code())) { |
| 1462 | 1730 | $responseData = $this->getAForm(null, (object) ['id' => $newFormId]); |
| 1731 | + $responseData['customCode'] = $customCode; | |
| 1463 | 1732 | $responseData['message'] = __('Form imported successfully.', 'bit-form'); |
| 1464 | 1733 | return $responseData; |
| 1465 | 1734 | } |
| 1466 | 1735 | return $importResponse; |
| @@ -1653,8 +1922,28 @@ | ||
| 1653 | 1922 | $formEntries = $customFieldHandler->updatedEntries($formEntries, $fieldDetails); |
| 1654 | 1923 | return $formEntries; |
| 1655 | 1924 | } |
| 1656 | 1925 | |
| 1926 | + public function getSingleEntry($formId, $entryId) | |
| 1927 | + { | |
| 1928 | + $formManager = new AdminFormManager($formId); | |
| 1929 | + if (!$formManager->isExist()) { | |
| 1930 | + return new WP_Error('empty_form', __('Form does not exists', 'bit-form')); | |
| 1931 | + } | |
| 1932 | + | |
| 1933 | + $formFields = $formManager->getFieldLabel(true); | |
| 1934 | + $fieldDetails = $formManager->getFields(); | |
| 1935 | + $entryMeta = new FormEntryMetaModel(); | |
| 1936 | + // $formEntry = new FormEntryModel(); | |
| 1937 | + | |
| 1938 | + $entries = $entryMeta->getSingleEntryMeta($formFields, $entryId); | |
| 1939 | + return $entries[0]; | |
| 1940 | + | |
| 1941 | + // $customFieldHandler = new CustomFieldHandler(); | |
| 1942 | + // $formEntries = $customFieldHandler->updatedEntries($formEntries, $fieldDetails); | |
| 1943 | + // return $formEntries; | |
| 1944 | + } | |
| 1945 | + | |
| 1657 | 1946 | public function getEntriesForReport($Request, $post) |
| 1658 | 1947 | { |
| 1659 | 1948 | if (isset($Request['id'])) { |
| 1660 | 1949 | $id = wp_unslash($Request['id']); |
| @@ -1769,8 +2058,17 @@ | ||
| 1769 | 2058 | } |
| 1770 | 2059 | if (is_null($formID) || !is_array($entries) || 0 === count($entries)) { |
| 1771 | 2060 | return new WP_Error('empty_form', __('Invalid Form ID or Entries ID.', 'bit-form')); |
| 1772 | 2061 | } |
| 2062 | + | |
| 2063 | + if (!filter_var($formID, FILTER_VALIDATE_INT)) { | |
| 2064 | + return new WP_Error('invalid_form', __('Form id is invalid.', 'bit-form')); | |
| 2065 | + } | |
| 2066 | + | |
| 2067 | + if (!Helpers::checkIsIntArr($entries)) { | |
| 2068 | + return new WP_Error('invalid_entries', __('Entries id is invalid', 'bit-form')); | |
| 2069 | + } | |
| 2070 | + | |
| 1773 | 2071 | $formManager = new AdminFormManager($formID); |
| 1774 | 2072 | if (!$formManager->isExist()) { |
| 1775 | 2073 | return new WP_Error('empty_form', __('Form does not exist.', 'bit-form')); |
| 1776 | 2074 | } |
| @@ -1836,8 +2134,16 @@ | ||
| 1836 | 2134 | if (is_null($formID) || !is_array($entries) || empty($entries)) { |
| 1837 | 2135 | return new WP_Error('empty_form', __('Form id or entries id is invalid', 'bit-form')); |
| 1838 | 2136 | } |
| 1839 | 2137 | |
| 2138 | + if (!filter_var($formID, FILTER_VALIDATE_INT)) { | |
| 2139 | + return new WP_Error('invalid_form', __('Form id is invalid', 'bit-form')); | |
| 2140 | + } | |
| 2141 | + | |
| 2142 | + if (!Helpers::checkIsIntArr($entries)) { | |
| 2143 | + return new WP_Error('invalid_entries', __('Entries id is invalid', 'bit-form')); | |
| 2144 | + } | |
| 2145 | + | |
| 1840 | 2146 | $formManager = new AdminFormManager($formID); |
| 1841 | 2147 | if (!$formManager->isExist()) { |
| 1842 | 2148 | return new WP_Error('empty_form', __('Form does not exist', 'bit-form')); |
| 1843 | 2149 | } |
| @@ -2143,8 +2449,17 @@ | ||
| 2143 | 2449 | } |
| 2144 | 2450 | if (empty($formID) || empty($id)) { |
| 2145 | 2451 | return new WP_Error('empty_form', 'Invalid Form ID or Email Template ID.'); |
| 2146 | 2452 | } |
| 2453 | + | |
| 2454 | + if (false === filter_var($id, FILTER_VALIDATE_INT)) { | |
| 2455 | + return new WP_Error('empty_form', 'Invalid Email Template ID.'); | |
| 2456 | + } | |
| 2457 | + | |
| 2458 | + if (false === filter_var($formID, FILTER_VALIDATE_INT)) { | |
| 2459 | + return new WP_Error('empty_form', 'Invalid Form ID.'); | |
| 2460 | + } | |
| 2461 | + | |
| 2147 | 2462 | $emailTemplateHandler = new EmailTemplateHandler($formID); |
| 2148 | 2463 | $duplicate_status = $emailTemplateHandler->duplicateTemplate($id); |
| 2149 | 2464 | if (is_wp_error($duplicate_status)) { |
| 2150 | 2465 | return $duplicate_status; |
| @@ -2285,22 +2600,34 @@ | ||
| 2285 | 2600 | } |
| 2286 | 2601 | if (is_string($paySetting)) { |
| 2287 | 2602 | $paySetting = json_decode($paySetting); |
| 2288 | 2603 | } |
| 2604 | + | |
| 2289 | 2605 | $canSave = null; |
| 2290 | - | |
| 2291 | - if ('PayPal' === $paySetting->type) { | |
| 2292 | - $canSave = $this->addWebhookToPaypal($paySetting); | |
| 2293 | - } elseif ('Razorpay' === $paySetting->type) { | |
| 2294 | - $canSave = true; | |
| 2295 | - } elseif ('Stripe' === $paySetting->type) { | |
| 2296 | - $canSave = $this->addWebhookToStripe($paySetting); | |
| 2606 | + switch($paySetting->type) { | |
| 2607 | + case 'PayPal': | |
| 2608 | + $canSave = $this->addWebhookToPaypal($paySetting); | |
| 2609 | + break; | |
| 2610 | + case 'Razorpay': | |
| 2611 | + $canSave = true; | |
| 2612 | + break; | |
| 2613 | + case 'Stripe': | |
| 2614 | + $canSave = $this->addWebhookToStripe($paySetting); | |
| 2615 | + break; | |
| 2616 | + case 'Mollie': | |
| 2617 | + $canSave = true; | |
| 2618 | + break; | |
| 2619 | + default: | |
| 2620 | + $canSave = null; | |
| 2297 | 2621 | } |
| 2298 | 2622 | if (is_null($canSave)) { |
| 2299 | 2623 | return new WP_Error('stripe', __('Please re-check your Client ID & Secret', 'bit-form')); |
| 2300 | 2624 | } |
| 2301 | - $integrationID = $paySetting->id; | |
| 2302 | - unset($paySetting->id); | |
| 2625 | + $integrationID = null; | |
| 2626 | + if (isset($paySetting->id)) { | |
| 2627 | + $integrationID = $paySetting->id; | |
| 2628 | + unset($paySetting->id); | |
| 2629 | + } | |
| 2303 | 2630 | $integrationName = $paySetting->name; |
| 2304 | 2631 | $integrationType = 'payments'; |
| 2305 | 2632 | $paySetting = wp_json_encode($paySetting); |
| 2306 | 2633 | $integrationDetails = $paySetting; |
| @@ -2433,6 +2760,25 @@ | ||
| 2433 | 2760 | public function updateSuccessMessageClassName($str, $msgIdx, $msgId) |
| 2434 | 2761 | { |
| 2435 | 2762 | $TEMP_CONF_ID = '_tmp_' . $msgIdx . '_conf_id'; |
| 2436 | 2763 | return str_replace($TEMP_CONF_ID, $msgId, $str); |
| 2764 | + } | |
| 2765 | + | |
| 2766 | + public function startMigrationProcess() | |
| 2767 | + { | |
| 2768 | + Utilities::duplicateDbTable('form', 'form_v1'); | |
| 2769 | + Utilities::duplicateDbTable('workflows', 'workflows_v1'); | |
| 2770 | + Utilities::duplicateDbTable('success_messages', 'success_messages_v1'); | |
| 2771 | + MigrationHelper::duplicateV1StyleFiles(); | |
| 2772 | + $all_forms = $this->getAllForm(); | |
| 2773 | + $v1FormContents = []; | |
| 2774 | + $defaultStyleClass = MigrationHelper::getBitformDefaultStyleClass(); | |
| 2775 | + foreach ($all_forms as $form) { | |
| 2776 | + $formContents = $this->getAFormV1(['id' => $form->id], ['id' => $form->id]); | |
| 2777 | + $v1FormContents[] = $formContents; | |
| 2778 | + FrontEndScriptGenerator::saveCssFile("{$form->id}", $defaultStyleClass); | |
| 2779 | + FrontEndScriptGenerator::saveCssFile("{$form->id}-formid", $defaultStyleClass); | |
| 2780 | + } | |
| 2781 | + set_transient('bitforms_v1_form_contents', $v1FormContents); | |
| 2782 | + update_option('bitforms_migrating_to_v2', true); | |
| 2437 | 2783 | } |
| 2438 | 2784 | } |