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/Admin/Form/AdminFormHandler.php +149 -231 3.1.02.15.3 View file →
@@ -26,9 +26,8 @@
26 26 use BitCode\BitForm\Core\Util\FileHandler;
27 27 use BitCode\BitForm\Core\Util\FormDuplicateHelper;
28 28 use BitCode\BitForm\Core\Util\HttpHelper;
29 29 use BitCode\BitForm\Core\Util\IpTool;
30 -use BitCode\BitForm\Core\Util\Log;
31 30 use BitCode\BitForm\Core\Util\Utilities;
32 31 use BitCode\BitForm\Core\WorkFlow\WorkFlow;
33 32 use BitCode\BitForm\Core\WorkFlow\WorkFlowHandler;
34 33 use WP_Error;
@@ -72,12 +71,14 @@
72 71 $this->createFormStylesDirIfNotExists();
73 72
74 73 if (
75 74 file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')
76 - && wp_is_writable(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')
75 + && is_writable(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')
77 76 ) {
78 - $filePath = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . $sheetName;
79 - return FileHandler::writeFile($filePath, $styles);
77 + $createStyleFile = fopen(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . $sheetName, 'w');
78 + fwrite($createStyleFile, $styles);
79 + fclose($createStyleFile);
80 + return true;
80 81 }
81 82 return false;
82 83 }
83 84
@@ -153,12 +154,14 @@
153 154 $this->createFormStylesDirIfNotExists();
154 155
155 156 if (
156 157 file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')
157 - && wp_is_writable(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')
158 + && is_writable(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')
158 159 ) {
159 - $filePath = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . $sheetName;
160 - return FileHandler::writeFile($filePath, $formStyle);
160 + $createStyleFile = fopen(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR . $sheetName, 'w');
161 + fwrite($createStyleFile, $formStyle);
162 + fclose($createStyleFile);
163 + return true;
161 164 }
162 165 return false;
163 166 }
164 167
@@ -192,8 +195,17 @@
192 195 if ($formManager->isExist()) {
193 196 return new WP_Error('empty_form', __('Error Occurred, Please Reload', 'bit-form'));
194 197 }
195 198
199 + if (!class_exists('BitCode\\BitFormPro\\Plugin')) {
200 + if (!empty($workFlows) && count($workFlows) > 2) {
201 + return new WP_Error(
202 + 'free_limit',
203 + __('You are allowed to add maximum 2 workflows ', 'bit-form')
204 + );
205 + }
206 + }
207 +
196 208 if (isset($post->formStyle) && $post->formStyle) {
197 209 $sheetName = 'bitform-' . $post->form_id . '.css';
198 210 $this->saveStyleSheet($post->formStyle, $sheetName);
199 211 }
@@ -199,14 +211,13 @@
199 211 }
200 212
201 213 if (isset($post->layoutChanged) && $post->layoutChanged) {
202 214 $sheetName = 'bitform-layout-' . $post->form_id . '.css';
203 - $rowHeight = (int) $post->rowHeight;
215 + $rowHeight = (int)$post->rowHeight;
204 216 $this->saveLayoutStyleSheet($post->layout, $sheetName, $rowHeight);
205 217 }
206 218
207 219 $fields = wp_unslash($post->fields);
208 - $fields = Helpers::replaceFieldsDefaultErrorMsg($fields);
209 220 // $fields = $post->fields;
210 221 $layout = wp_unslash($post->layout);
211 222 $nestedLayout = isset($post->nestedLayouts) ? wp_unslash($post->nestedLayouts) : (object) [];
212 223 $formInfo = wp_unslash($post->formInfo);
@@ -308,11 +319,10 @@
308 319 return $save_status;
309 320 } elseif (!$save_status) {
310 321 return false;
311 322 } else {
312 - FileHandler::createIndexFile(BITFORMS_UPLOAD_DIR . "/$save_status");
323 + wp_mkdir_p(BITFORMS_UPLOAD_DIR . "/$save_status");
313 324 $formID = $save_status;
314 - do_action('bitform_admin_form_changed');
315 325 $integartionIDForWorkflow = [];
316 326 // Confiramtion Message [start]
317 327 if (!empty($formSettings->confirmation->type->successMsg)) {
318 328 $successMessages = $formSettings->confirmation->type->successMsg;
@@ -335,10 +345,10 @@
335 345 'builderSettings' => $builderSettings
336 346 ];
337 347 $update_status = static::$formModel->update(
338 348 [
339 - 'builder_helper_state' => \wp_json_encode($builder_helper_state),
340 - 'atomic_class_map' => $atomic_class_map,
349 + 'builder_helper_state' => \wp_json_encode($builder_helper_state),
350 + 'atomic_class_map' => $atomic_class_map,
341 351 ],
342 352 [
343 353 'id' => $formID,
344 354 ]
@@ -410,16 +420,8 @@
410 420 $integartionIDForWorkflow[$integrationType][$integIdx] = $savedID;
411 421 }
412 422 }
413 423 }
414 - if (isset($formSettings->formAbandonment)) {
415 - $formAbandonment = $formSettings->formAbandonment;
416 -
417 - $integrationName = 'formAbandonment';
418 - $integrationType = 'formAbandonment';
419 - $abandonmentIntegDetails = wp_json_encode($formAbandonment);
420 - $integrationHandler->saveIntegration($integrationName, $integrationType, $abandonmentIntegDetails, 'formAbandonment');
421 - }
422 424 if (!empty($integrations)) {
423 425 foreach ($integrations as $singleIntegrationKey => $singleIntegrationDetail) {
424 426 $integrationName = $singleIntegrationDetail->name;
425 427 unset($singleIntegrationDetail->name);
@@ -457,9 +459,9 @@
457 459 // }
458 460 }
459 461 //wrokFlows [end]
460 462 $details = [
461 - 'report_name' => __('All Entries', 'bit-form'),
463 + 'report_name' => 'All Entries',
462 464 'hiddenColumns' => ['__user_id', '__user_ip', '__referer', '__user_device', '__created_at', '__updated_at'],
463 465 'pageSize' => 10,
464 466 'sortBy' => [],
465 467 'filters' => [],
@@ -519,14 +521,13 @@
519 521 if (property_exists($post, 'builderSettings')) {
520 522 $builder_helper_state->builderSettings = $post->builderSettings;
521 523 }
522 524 if (property_exists($post, 'atomicClassMap')) {
523 - $atomic_class_map = \wp_json_encode((object) $post->atomicClassMap);
525 + $atomic_class_map = \wp_json_encode((object)$post->atomicClassMap);
524 526 }
525 527
526 528 if (property_exists($post, 'fields') && null !== $post->fields && property_exists($post, 'layout') && $post->layout) {
527 529 $fields = wp_unslash($post->fields);
528 - $fields = Helpers::replaceFieldsDefaultErrorMsg($fields);
529 530 $layout = wp_unslash($post->layout);
530 531 $nestedLayout = wp_unslash($post->nestedLayouts);
531 532 $formInfo = wp_unslash($post->formInfo);
532 533 $formID = wp_unslash($post->id);
@@ -546,8 +547,17 @@
546 547 if (empty($fields) || empty($layout) || is_null($formID)) {
547 548 return new WP_Error('empty_form', 'Can not update empty form.');
548 549 }
549 550
551 + if (!class_exists('BitCode\\BitFormPro\\Plugin')) {
552 + if (count($workFlows) > 2) {
553 + return new WP_Error(
554 + 'free_limit',
555 + __('You are allowed to add maximum 2 workflows ', 'bit-form')
556 + );
557 + }
558 + }
559 +
550 560 $form_content = [
551 561 'fields' => $fields,
552 562 'layout' => $layout,
553 563 'nestedLayout' => $nestedLayout,
@@ -741,12 +751,12 @@
741 751
742 752 $fieldNames['__user_id'] = __('User', 'bit-form');
743 753 $fieldNames['__user_ip'] = __('IP address', 'bit-form');
744 754 // $fieldNames['__user_location'] = __('');
745 - $fieldNames['__referer'] = __('Refer URL', 'bit-form');
746 - $fieldNames['__user_device'] = __('Device', 'bit-form');
747 - $fieldNames['__created_at'] = __('Created Time', 'bit-form');
748 - $fieldNames['__updated_at'] = __('Modified Time', 'bit-form');
755 + $fieldNames['__referer'] = __('Refer URL');
756 + $fieldNames['__user_device'] = __('Device');
757 + $fieldNames['__created_at'] = __('Created Time');
758 + $fieldNames['__updated_at'] = __('Modified Time');
749 759
750 760 $reportIsDefault = null;
751 761 if (isset($form_content['report_id'])) {
752 762 $validDateReport = $reportsModel->validateReportFields($reports, $fieldNames);
@@ -798,9 +808,9 @@
798 808 'form_name' => $form_name,
799 809 'form_content' => $form_content,
800 810 'user_id' => $user_details['id'],
801 811 'user_ip' => $user_details['ip'],
802 - 'builder_helper_state' => \wp_json_encode((object) $builder_helper_state),
812 + 'builder_helper_state' => \wp_json_encode((object)$builder_helper_state),
803 813 'generated_script_page_ids' => \wp_json_encode((object) []),
804 814 'user_device' => $user_details['device'],
805 815 'updated_at' => $user_details['time'],
806 816 ];
@@ -806,16 +816,15 @@
806 816 ];
807 817 if (isset($atomic_class_map)) {
808 818 $updateData['atomic_class_map'] = $atomic_class_map;
809 819 }
810 - $formUpdateVersion = get_option('bitform_form_update_version');
820 + $formUpdateVersion = get_option('bit-form_form_update_version');
811 821 if (!$formUpdateVersion) {
812 822 $formUpdateVersion = 1;
813 823 } else {
814 824 $formUpdateVersion = (int) $formUpdateVersion + 1;
815 825 }
816 - update_option('bitform_form_update_version', $formUpdateVersion);
817 - do_action('bitform_admin_form_changed');
826 + update_option('bit-form_form_update_version', $formUpdateVersion);
818 827
819 828 $update_status = static::$formModel->update(
820 829 $updateData,
821 830 [
@@ -861,9 +870,8 @@
861 870 if (2 === $newData['reports']) {
862 871 $errorIN .= empty($errorIN) ? 'reports' : ', reports';
863 872 }
864 873 if (!empty($errorIN)) {
865 - /* translators: %s: comma-separated list of areas where error occurred */
866 874 $updated_data['message'] = sprintf(__('Error Occured in saving %s', 'bit-form'), $errorIN);
867 875 return new WP_Error('Form update Error.', $updated_data);
868 876 }
869 877 if (null !== $reportIsDefault) {
@@ -868,9 +876,9 @@
868 876 }
869 877 if (null !== $reportIsDefault) {
870 878 $updated_data['form_content']['is_default'] = $reportIsDefault;
871 879 }
872 - $updated_data['message'] = __('Form updated successfully.', 'bit-form');
880 + $updated_data['message'] = __('Form updated successfully.', 'bitform');
873 881 return $updated_data;
874 882 }
875 883 }
876 884
@@ -875,23 +883,23 @@
875 883 }
876 884
877 885 public function setEmptyMetaValue($fieldkeys)
878 886 {
887 + $sqlEscaped = array_map(function ($fld) {
888 + return "'" . esc_sql($fld) . "'";
889 + }, $fieldkeys);
890 + $deletedFldKey = implode(',', $sqlEscaped);
879 891 global $wpdb;
880 - // Placeholders and arguments built dynamically from $fieldkeys; count matches at runtime.
881 - $placeholders = implode(',', array_fill(0, \count($fieldkeys), '%s'));
882 - $wpdb->query($wpdb->prepare(
883 - "UPDATE `{$wpdb->prefix}bitforms_form_entrymeta` SET meta_value = %s WHERE meta_key IN ($placeholders)",
884 - '',
885 - ...$fieldkeys
886 - ));
892 + $tablename = $wpdb->prefix . 'bitforms_form_entrymeta';
893 + $sql = $wpdb->prepare("UPDATE $tablename SET meta_value = %s WHERE meta_key IN ( " . $deletedFldKey . ')', '');
894 + $wpdb->query($sql);
887 895 }
888 896
889 897 public function changeFormStatus($Request, $post)
890 898 {
891 899 if (isset($Request['status']) && $Request['id']) {
892 - $status = sanitize_text_field(wp_unslash($Request['status']));
893 - $id = absint(wp_unslash($Request['id']));
900 + $status = wp_unslash($Request['status']);
901 + $id = wp_unslash($Request['id']);
894 902 } else {
895 903 $status = wp_unslash($post->status);
896 904 $id = wp_unslash($post->id);
897 905 }
@@ -925,10 +933,10 @@
925 933
926 934 public function changeBulkFormStatus($Request, $post)
927 935 {
928 936 if (isset($Request['status']) && $Request['formID']) {
929 - $status = sanitize_text_field(wp_unslash($Request['status']));
930 - $formID = array_map('absint', wp_unslash($Request['formID']));
937 + $status = wp_unslash($Request['status']);
938 + $formID = wp_unslash($Request['formID']);
931 939 } else {
932 940 $status = wp_unslash($post->status);
933 941 $formID = wp_unslash($post->formID);
934 942 }
@@ -963,13 +971,9 @@
963 971 public function getAllForm()
964 972 {
965 973 global $wpdb;
966 974
967 - // Direct query: table name interpolation only (no user input). $wpdb->prepare() cannot parameterize table names.
968 - $allForms = $wpdb->get_results("SELECT forms.id,forms.entries as fm_entries,forms.form_name,forms.status,forms.views,forms.created_at,COUNT(entries.id) as entries
969 - FROM `{$wpdb->prefix}bitforms_form` as forms
970 - LEFT JOIN `{$wpdb->prefix}bitforms_form_entries` as entries ON forms.id = entries.form_id
971 - GROUP BY forms.id");
975 + $allForms = $wpdb->get_results("SELECT forms.id,forms.entries as fm_entries,forms.form_name,forms.status,forms.views,forms.created_at,COUNT(entries.id) as entries FROM `{$wpdb->prefix}bitforms_form` as forms LEFT JOIN `{$wpdb->prefix}bitforms_form_entries` as entries ON forms.id = entries.form_id GROUP BY forms.id");
972 976
973 977 if (is_wp_error($allForms)) {
974 978 return $allForms;
975 979 } elseif (!$allForms) {
@@ -980,10 +984,10 @@
980 984 }
981 985
982 986 public function getAForm($Request, $post)
983 987 {
984 - if (!empty($Request['id'])) {
985 - $formID = absint(wp_unslash($Request['id']));
988 + if (isset($Request['id'])) {
989 + $formID = wp_unslash($Request['id']);
986 990 } else {
987 991 $formID = wp_unslash($post->id);
988 992 }
989 993 // return $post->fields;
@@ -1085,22 +1089,8 @@
1085 1089 );
1086 1090 }
1087 1091 }
1088 1092 }
1089 -
1090 - // get form abandonment integration if exist
1091 - $formAbandonmentInteg = $integrationHandler->getAllIntegration('formAbandonment', 'formAbandonment');
1092 - if (!is_wp_error($formAbandonmentInteg) && !empty($formAbandonmentInteg)) {
1093 - $formAbandonmentInteg = $formAbandonmentInteg[0];
1094 - if (!empty($formAbandonmentInteg->integration_details)) {
1095 - $formAbandonment = json_decode($formAbandonmentInteg->integration_details);
1096 - } else {
1097 - $formAbandonment = (object) [];
1098 - }
1099 - } else {
1100 - $formAbandonment = (object) [];
1101 - }
1102 -
1103 1093 $settingsContent = [
1104 1094 'formName' => $formManager->getFormName(),
1105 1095 'theme' => isset($form_content->theme) ? $form_content->theme : 'default',
1106 1096 'formPermissions' => isset($form_content->formPermissions) ? $form_content->formPermissions : (object) [],
@@ -1163,24 +1153,8 @@
1163 1153 'pdfTem' => [],
1164 1154 ]
1165 1155 );
1166 1156 }
1167 -
1168 - if (!empty($formAbandonment)) {
1169 - $settingsContent = array_merge(
1170 - $settingsContent,
1171 - [
1172 - 'formAbandonment' => $formAbandonment,
1173 - ]
1174 - );
1175 - } else {
1176 - $settingsContent = array_merge(
1177 - $settingsContent,
1178 - [
1179 - 'formAbandonment' => (object) [],
1180 - ]
1181 - );
1182 - }
1183 1157 $formSettings = [
1184 1158 'formSettings' => $settingsContent,
1185 1159 ];
1186 1160 $data = [
@@ -1191,14 +1165,12 @@
1191 1165 'style' => $helper_states->style,
1192 1166 'themeVars' => $helper_states->themeVars,
1193 1167 'themeColors' => $helper_states->themeColors,
1194 1168 'builderSettings' => $helper_states->builderSettings,
1195 - 'customCode' => FrontEndScriptGenerator::getCustomCodes($formID),
1196 1169 'additional' => empty($form_content->additional) ? [
1197 1170 'enabled' => [
1198 1171 'blocked_ip' => false,
1199 1172 'restrict_form' => false,
1200 - 'onePerIp' => false,
1201 1173 ],
1202 1174 'settings' => [
1203 1175 'restrict_form' => [
1204 1176 'day' => [],
@@ -1213,8 +1185,9 @@
1213 1185 ],
1214 1186 'entry_limit' => null,
1215 1187 'blocked_ip' => [],
1216 1188 ],
1189 + 'onePerIp' => false,
1217 1190 ] : $form_content->additional,
1218 1191 'created_at' => $formManager->getFormMetaData()['created_at'],
1219 1192 'views' => $formManager->getFormMetaData()['views'],
1220 1193 'entries' => $formManager->getFormMetaData()['entries'],
@@ -1255,9 +1228,9 @@
1255 1228 } else {
1256 1229 $returnedReportData[$reportKey]->details = [];
1257 1230 }
1258 1231 if ('1' === (string) $reportData->isDefault) {
1259 - $returnedReportData[$reportKey]->details->report_name = __('All Entries', 'bit-form');
1232 + $returnedReportData[$reportKey]->details->report_name = 'All Entries';
1260 1233 }
1261 1234 }
1262 1235 $reports = ['reports' => $returnedReportData];
1263 1236 $data = array_merge($data, $reports);
@@ -1271,10 +1244,10 @@
1271 1244 }
1272 1245
1273 1246 public function getAFormV1($Request, $post)
1274 1247 {
1275 - if (!empty($Request['id'])) {
1276 - $formID = absint(wp_unslash($Request['id']));
1248 + if (isset($Request['id'])) {
1249 + $formID = wp_unslash($Request['id']);
1277 1250 } else {
1278 1251 $formID = wp_unslash($post->id);
1279 1252 }
1280 1253 // return $post->fields;
@@ -1294,32 +1267,32 @@
1294 1267 'workFlowExist' => $form_content->workFlowExist,
1295 1268 'report_id' => isset($form_content->report_id) ? $form_content->report_id : null
1296 1269 ];
1297 1270 $successMessageHandler
1298 - = new SuccessMessageHandler($formID);
1271 + = new SuccessMessageHandler($formID);
1299 1272 $successMessages = $successMessageHandler->getAllMessage();
1300 1273 if (!is_wp_error($successMessages)) {
1301 1274 foreach ($successMessages as $sucessMessagekey => $sucessMessagevalue) {
1302 1275 $allConfirmation['type']['successMsg'][$sucessMessagekey] =
1303 - [
1304 - 'id' => $sucessMessagevalue->id,
1305 - 'title' => $sucessMessagevalue->message_title,
1306 - 'msg' => $sucessMessagevalue->message_content,
1307 - ];
1276 + [
1277 + 'id' => $sucessMessagevalue->id,
1278 + 'title' => $sucessMessagevalue->message_title,
1279 + 'msg' => $sucessMessagevalue->message_content,
1280 + ];
1308 1281 }
1309 1282 }
1310 1283 $emailTemplateHandler
1311 - = new EmailTemplateHandler($formID);
1284 + = new EmailTemplateHandler($formID);
1312 1285 $emailTemplates = $emailTemplateHandler->getAllTemplate();
1313 1286 if (!is_wp_error($emailTemplates)) {
1314 1287 foreach ($emailTemplates as $emailTemplatekey => $emailTemplatevalue) {
1315 1288 $mailTem[] =
1316 - [
1317 - 'id' => $emailTemplatevalue->id,
1318 - 'title' => $emailTemplatevalue->title,
1319 - 'sub' => $emailTemplatevalue->sub,
1320 - 'body' => $emailTemplatevalue->body,
1321 - ];
1289 + [
1290 + 'id' => $emailTemplatevalue->id,
1291 + 'title' => $emailTemplatevalue->title,
1292 + 'sub' => $emailTemplatevalue->sub,
1293 + 'body' => $emailTemplatevalue->body,
1294 + ];
1322 1295 }
1323 1296 }
1324 1297 $integrationHandler = new IntegrationHandler($formID);
1325 1298 $formIntegrations = $integrationHandler->getAllIntegration('form');
@@ -1340,9 +1313,9 @@
1340 1313 ];
1341 1314 $integrationData = array_merge($integrationData, $integration_details);
1342 1315 }
1343 1316 $allConfirmation['type'][$integrationValue->integration_type][]
1344 - = $integrationData;
1317 + = $integrationData;
1345 1318 } else {
1346 1319 $integrationData = [
1347 1320 'id' => $integrationValue->id,
1348 1321 'name' => $integrationValue->integration_name,
@@ -1350,10 +1323,10 @@
1350 1323 ];
1351 1324 $integrations[] = array_merge(
1352 1325 $integrationData,
1353 1326 is_string($integrationValue->integration_details) ?
1354 - (array) json_decode($integrationValue->integration_details) :
1355 - $integrationValue->integration_details
1327 + (array) json_decode($integrationValue->integration_details) :
1328 + $integrationValue->integration_details
1356 1329 );
1357 1330 }
1358 1331 }
1359 1332 }
@@ -1413,9 +1386,8 @@
1413 1386 'additional' => empty($form_content->additional) ? [
1414 1387 'enabled' => [
1415 1388 'blocked_ip' => false,
1416 1389 'restrict_form' => false,
1417 - 'onePerIp' => false,
1418 1390 ],
1419 1391 'settings' => [
1420 1392 'restrict_form' => [
1421 1393 'day' => [],
@@ -1430,8 +1402,9 @@
1430 1402 ],
1431 1403 'entry_limit' => null,
1432 1404 'blocked_ip' => [],
1433 1405 ],
1406 + 'onePerIp' => false,
1434 1407 ] : $form_content->additional,
1435 1408 'created_at' => $formManager->getFormMetaData()['created_at'],
1436 1409 'views' => $formManager->getFormMetaData()['views'],
1437 1410 'entries' => $formManager->getFormMetaData()['entries'],
@@ -1472,9 +1445,9 @@
1472 1445 } else {
1473 1446 $returnedReportData[$reportKey]->details = [];
1474 1447 }
1475 1448 if ('1' === (string) $reportData->isDefault) {
1476 - $returnedReportData[$reportKey]->details->report_name = __('All Entries', 'bit-form');
1449 + $returnedReportData[$reportKey]->details->report_name = 'All Entries';
1477 1450 }
1478 1451 }
1479 1452 $reports = ['reports' => $returnedReportData];
1480 1453 $data = array_merge($data, $reports);
@@ -1488,10 +1461,10 @@
1488 1461 }
1489 1462
1490 1463 public function deleteAForm($Request, $post)
1491 1464 {
1492 - if (!empty($Request['id'])) {
1493 - $formID = absint(wp_unslash($Request['id']));
1465 + if (isset($Request['id'])) {
1466 + $formID = wp_unslash($Request['id']);
1494 1467 } else {
1495 1468 $formID = wp_unslash($post->id);
1496 1469 }
1497 1470 if (is_null($formID)) {
@@ -1506,9 +1479,8 @@
1506 1479 [
1507 1480 'id' => $formID,
1508 1481 ]
1509 1482 );
1510 - do_action('bitform_admin_form_changed');
1511 1483
1512 1484 $successMessageModel = new SuccessMessageModel();
1513 1485 $deleteMsgStatus = $successMessageModel->delete(['form_id' => $formID]);
1514 1486
@@ -1564,10 +1536,10 @@
1564 1536 }
1565 1537
1566 1538 public function deleteBlukForm($Request, $post)
1567 1539 {
1568 - if (!empty($Request['formID'])) {
1569 - $formID = array_map('absint', wp_unslash($Request['formID']));
1540 + if (isset($Request['formID'])) {
1541 + $formID = wp_unslash($Request['formID']);
1570 1542 } else {
1571 1543 $formID = wp_unslash($post->formID);
1572 1544 }
1573 1545
@@ -1594,9 +1566,8 @@
1594 1566 [
1595 1567 'id' => $formID,
1596 1568 ]
1597 1569 );
1598 - do_action('bitform_admin_form_changed');
1599 1570
1600 1571 if (is_wp_error($delete_status)) {
1601 1572 wp_send_json_error($delete_status->get_error_message(), 400);
1602 1573 }
@@ -1643,14 +1614,8 @@
1643 1614 ]
1644 1615 );
1645 1616 }
1646 1617
1647 - // delete entry log and details; table name interpolation only — $wpdb->prepare() parameterizes the form_id value.
1648 - $wpdb->query($wpdb->prepare(
1649 - "DELETE em, e FROM `{$prefix}bitforms_form_log_details` AS em JOIN `{$prefix}bitforms_form_entry_log` AS e ON em.log_id = e.id WHERE e.form_id = %d",
1650 - $formID
1651 - ));
1652 -
1653 1618 $fileHandler = new FileHandler();
1654 1619 foreach ($formID as $fId) {
1655 1620 if (file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $fId)) {
1656 1621 $fileHandler->rmrf(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $fId);
@@ -1697,15 +1662,21 @@
1697 1662 if (!is_wp_error($duplicateResponse) || (is_wp_error($duplicateResponse) && 'result_empty' === $duplicateResponse->get_error_code())) {
1698 1663 // duplicate stylesheet
1699 1664 $style_dir = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles' . DIRECTORY_SEPARATOR;
1700 1665 // layout style copy
1701 - $styleStr = FileHandler::readFile($style_dir . 'bitform-layout-' . $oldFormId . '.css');
1666 + $mainFormLayStyle = fopen($style_dir . 'bitform-layout-' . $oldFormId . '.css', 'r');
1667 + $styleStr = fread($mainFormLayStyle, filesize($style_dir . 'bitform-layout-' . $oldFormId . '.css'));
1702 1668 $newStyle = str_replace(".bf$oldFormId-", ".bf$newFormId-", $styleStr);
1703 - FileHandler::writeFile($style_dir . "bitform-layout-$newFormId.css", $newStyle);
1669 + $createStyleFile = fopen($style_dir . "bitform-layout-$newFormId.css", 'w');
1670 + fwrite($createStyleFile, $newStyle);
1671 + fclose($createStyleFile);
1704 1672 // style copy
1705 - $styleStr = FileHandler::readFile($style_dir . 'bitform-' . $oldFormId . '.css');
1673 + $mainFormStyle = fopen($style_dir . 'bitform-' . $oldFormId . '.css', 'r');
1674 + $styleStr = fread($mainFormStyle, filesize($style_dir . 'bitform-' . $oldFormId . '.css'));
1706 1675 $newStyle = str_replace("-$oldFormId", "-$newFormId", $styleStr);
1707 - FileHandler::writeFile($style_dir . "bitform-$newFormId.css", $newStyle);
1676 + $createStyleFile = fopen($style_dir . "bitform-$newFormId.css", 'w');
1677 + fwrite($createStyleFile, $newStyle);
1678 + fclose($createStyleFile);
1708 1679 $duplicatedForm = $this->getAForm(null, (object) ['id' => $newFormId]);
1709 1680 $duplicatedForm['message'] = __('Form duplicated successfully', 'bit-form');
1710 1681 return $duplicatedForm;
1711 1682 }
@@ -1718,15 +1689,15 @@
1718 1689 $newFormId = intval($post->newFormId);
1719 1690 if (!$oldFormId || empty($post->formDetail->fields) || empty($post->formDetail->layout)) {
1720 1691 return new WP_Error('invalid_form', __('Please import a valid json.', 'bit-form'));
1721 1692 }
1722 - $importtedForm = (array) $post->formDetail;
1693 + $importtedForm = (array)$post->formDetail;
1723 1694 $importtedForm['form_content']['fields'] = $importtedForm['fields'];
1724 1695 $importtedForm['form_content']['layout'] = $importtedForm['layout'];
1725 1696 $importtedForm['form_content']['nestedLayout'] = $importtedForm['nestedLayouts'];
1726 1697 $importtedForm['form_content']['formInfo'] = $importtedForm['formInfo'];
1727 1698 unset($importtedForm['fields'], $importtedForm['layout'], $importtedForm['nestedLayout'], $importtedForm['formInfo']);
1728 - $formData = FormDuplicateHelper::createReplica((array) $importtedForm, $oldFormId, $newFormId);
1699 + $formData = FormDuplicateHelper::createReplica((array)$importtedForm, $oldFormId, $newFormId);
1729 1700
1730 1701 if (!empty($importtedForm['rowHeight'])) {
1731 1702 $formData->rowHeight = $importtedForm['rowHeight'];
1732 1703 }
@@ -1813,9 +1784,9 @@
1813 1784 return new WP_Error('empty_form', __('Form does not exists.', 'bit-form'));
1814 1785 }
1815 1786
1816 1787 $newFormId = $oldFormId;
1817 - $duplicatedForm = $this->getAForm($Request, (object) ['id' => $oldFormId]);
1788 + $duplicatedForm = $this->getAForm($Request, (object)['id' => $oldFormId]);
1818 1789 $formData = FormDuplicateHelper::createReplica($duplicatedForm, $oldFormId, $newFormId);
1819 1790 // for custom css
1820 1791 $customCssPath = 'form-styles/bitform-custom-' . $newFormId . '.css';
1821 1792 $cssPath = Helpers::generatePathDirOrFile($customCssPath);
@@ -1835,10 +1806,10 @@
1835 1806 }
1836 1807
1837 1808 public function getFormEntryLabelAndCount($Request, $post)
1838 1809 {
1839 - if (!empty($Request['id'])) {
1840 - $id = absint(wp_unslash($Request['id']));
1810 + if (isset($Request['id'])) {
1811 + $id = wp_unslash($Request['id']);
1841 1812 } else {
1842 1813 $id = wp_unslash($post->id);
1843 1814 }
1844 1815 if (is_null($id)) {
@@ -1893,15 +1864,14 @@
1893 1864 }
1894 1865
1895 1866 public function getFormEntry($Request, $post)
1896 1867 {
1897 - if (!empty($Request['id'])) {
1898 - $id = absint(wp_unslash($Request['id']));
1868 + if (isset($Request['id'])) {
1869 + $id = wp_unslash($Request['id']);
1899 1870 $offset = isset($Request['offset']) ?
1900 1871 wp_unslash($Request['offset']) : 0;
1901 1872 $pageSize = isset($Request['pageSize']) ?
1902 1873 wp_unslash($Request['pageSize']) : 10;
1903 - $queryCondition = isset($Request['queryCondition']) ? wp_unslash($Request['queryCondition']) : ['form_id' => $id];
1904 1874 } else {
1905 1875 $id = wp_unslash($post->id);
1906 1876 $conditions = isset($post->conditions) ? wp_unslash($post->conditions) : [];
1907 1877 $dateBetweenFilter = isset($post->entriesFilterByDate) ? wp_unslash($post->entriesFilterByDate) : [];
@@ -1910,9 +1880,8 @@
1910 1880 $filters = isset($post->filters) ? wp_unslash($post->filters) : null;
1911 1881 $globalFilter = isset($post->globalFilter) ? wp_unslash($post->globalFilter) : null;
1912 1882 $pageSize = isset($post->pageSize) ?
1913 1883 wp_unslash($post->pageSize) : 10;
1914 - $queryCondition = isset($post->queryCondition) ? wp_unslash($post->queryCondition) : ['form_id' => $id];
1915 1884 }
1916 1885 if (is_null($id)) {
1917 1886 return new WP_Error('empty_form', __('Form id is empty.', 'bit-form'));
1918 1887 }
@@ -1919,12 +1888,15 @@
1919 1888 $formManager = new AdminFormManager($id);
1920 1889 if (!$formManager->isExist()) {
1921 1890 return new WP_Error('empty_form', __('Form does not exists', 'bit-form'));
1922 1891 }
1892 +
1923 1893 $formEntry = new FormEntryModel();
1924 1894 $entries = $formEntry->get(
1925 1895 'id',
1926 - $queryCondition,
1896 + [
1897 + 'form_id' => $id,
1898 + ],
1927 1899 null,
1928 1900 null,
1929 1901 'created_at',
1930 1902 'DESC'
@@ -1963,14 +1935,10 @@
1963 1935 $entryMeta = new FormEntryMetaModel();
1964 1936 // $formEntry = new FormEntryModel();
1965 1937
1966 1938 $entries = $entryMeta->getSingleEntryMeta($formFields, $entryId);
1939 + return $entries[0];
1967 1940
1968 - if (!is_wp_error($entries)) {
1969 - return $entries[0];
1970 - }
1971 - return new WP_Error('entry_not_fonud', __('Entry Not Found!', 'bit-form'));
1972 -
1973 1941 // $customFieldHandler = new CustomFieldHandler();
1974 1942 // $formEntries = $customFieldHandler->updatedEntries($formEntries, $fieldDetails);
1975 1943 // return $formEntries;
1976 1944 }
@@ -1976,10 +1944,10 @@
1976 1944 }
1977 1945
1978 1946 public function getEntriesForReport($Request, $post)
1979 1947 {
1980 - if (!empty($Request['id'])) {
1981 - $id = absint(wp_unslash($Request['id']));
1948 + if (isset($Request['id'])) {
1949 + $id = wp_unslash($Request['id']);
1982 1950 $offset = isset($Request['offset']) ?
1983 1951 wp_unslash($Request['offset']) : null;
1984 1952 $pageSize = isset($Request['pageSize']) ?
1985 1953 wp_unslash($Request['pageSize']) : null;
@@ -2040,9 +2008,8 @@
2040 2008 {
2041 2009 $formId = wp_unslash($post->formId);
2042 2010 $fileFormate = isset($post->fileFormate) ? wp_unslash($post->fileFormate) : null;
2043 2011 $limit = isset($post->limit) ? wp_unslash($post->limit) : null;
2044 - $entryCondition = isset($post->filter) ? wp_unslash($post->filter) : null;
2045 2012 $sortBy = isset($post->sort) ? wp_unslash($post->sort) : 'ASC';
2046 2013 $sortByField = isset($post->sortField) ? wp_unslash($post->sortField) : 'bitforms_form_entry_id';
2047 2014 $formFields = json_decode($post->selectedField);
2048 2015 if (is_null($formId)) {
@@ -2075,17 +2042,17 @@
2075 2042 return $entries;
2076 2043 }
2077 2044 $entryMeta = new FormEntryMetaModel();
2078 2045 $filter = [];
2079 - $formEntries = $entryMeta->getExportEntry($formFields, $entries, $formId, $fieldLabels, $limit, $sortBy, $sortByField, $offset, $entryCondition);
2046 + $formEntries = $entryMeta->getExportEntry($formFields, $entries, $formId, $fieldLabels, $limit, $sortBy, $sortByField);
2080 2047 return $formEntries;
2081 2048 }
2082 2049
2083 2050 public function deleteBlukFormEntries($Request, $post)
2084 2051 {
2085 - if (!empty($Request['formID'])) {
2086 - $formID = absint(wp_unslash($Request['formID']));
2087 - $entries = array_map('absint', wp_unslash($Request['entries']));
2052 + if (isset($Request['formID'])) {
2053 + $formID = wp_unslash($Request['formID']);
2054 + $entries = wp_unslash($Request['entries']);
2088 2055 } else {
2089 2056 $formID = wp_unslash($post->formID);
2090 2057 $entries = wp_unslash($post->entries);
2091 2058 }
@@ -2105,18 +2072,16 @@
2105 2072 if (!$formManager->isExist()) {
2106 2073 return new WP_Error('empty_form', __('Form does not exist.', 'bit-form'));
2107 2074 }
2108 2075 $workFlowRunHelper = new WorkFlow($formID);
2109 -
2110 2076 $workFlowreturnedOnDelete = $workFlowRunHelper->executeOnDelete(
2111 2077 $formManager,
2112 2078 $formID,
2113 2079 $entries
2114 2080 );
2115 -
2116 2081 if (isset($workFlowreturnedOnDelete['entries'])) {
2117 2082 if (0 === count($workFlowreturnedOnDelete['entries'])) {
2118 - return ['message' => __('Entry Deletetion prevented by workflow', 'bit-form')];
2083 + return ['message' => __('Entry Deletetion prevented by workflow', 'bit-form')];
2119 2084 } elseif (count($workFlowreturnedOnDelete['entries']) === count($entries)) {
2120 2085 $message = __('Entry Deleted successfully', 'bit-form');
2121 2086 } else {
2122 2087 $result['prevented'] = array_diff($entries, $workFlowreturnedOnDelete['entries']);
@@ -2137,9 +2102,9 @@
2137 2102 );
2138 2103 if (file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID)) {
2139 2104 $fileHandler = new FileHandler();
2140 2105 foreach ($entries as $enrtyKey => $entryID) {
2141 - $fileEntries = $fileHandler->getEntriesFileUploadDir($formID, $entryID);
2106 + $fileEntries = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID;
2142 2107 if (file_exists($fileEntries)) {
2143 2108 $fileHandler->rmrf($fileEntries);
2144 2109 }
2145 2110 }
@@ -2158,11 +2123,11 @@
2158 2123 }
2159 2124
2160 2125 public function duplicateFormEntry($Request, $post)
2161 2126 {
2162 - if (!empty($Request['formID'])) {
2163 - $formID = absint(wp_unslash($Request['formID']));
2164 - $entries = array_map('absint', wp_unslash($Request['entries']));
2127 + if (isset($Request['formID'])) {
2128 + $formID = wp_unslash($Request['formID']);
2129 + $entries = wp_unslash($Request['entries']);
2165 2130 } else {
2166 2131 $formID = wp_unslash($post->formID);
2167 2132 $entries = wp_unslash($post->entries);
2168 2133 }
@@ -2211,12 +2176,12 @@
2211 2176 );
2212 2177 if ($duplicate_status) {
2213 2178 $result['details'][$entryID] = $duplicatedEntryId;
2214 2179 $duplicate_count = $duplicate_count + 1;
2215 - if (file_exists(FileHandler::getEntriesFileUploadDir($formID, $entryID))) {
2180 + if (file_exists(BITFORMS_UPLOAD_DIR . "/$formID/$entryID")) {
2216 2181 $fileHandler->cpyr(
2217 - FileHandler::getEntriesFileUploadDir($formID, $entryID),
2218 - FileHandler::getEntriesFileUploadDir($formID, $duplicatedEntryId)
2182 + BITFORMS_UPLOAD_DIR . "/$formID/$entryID",
2183 + BITFORMS_UPLOAD_DIR . "/$formID/$duplicatedEntryId"
2219 2184 );
2220 2185 }
2221 2186 }
2222 2187 }
@@ -2233,11 +2198,11 @@
2233 2198 }
2234 2199
2235 2200 public function editFormEntry($Request, $post)
2236 2201 {
2237 - if (!empty($Request['formID'])) {
2238 - $formID = absint(wp_unslash($Request['formID']));
2239 - $entryID = absint(wp_unslash($Request['entryID']));
2202 + if (isset($Request['formID'])) {
2203 + $formID = wp_unslash($Request['formID']);
2204 + $entryID = wp_unslash($Request['entryID']);
2240 2205 } else {
2241 2206 $formID = wp_unslash($post->formID);
2242 2207 $entryID = wp_unslash($post->entryID);
2243 2208 }
@@ -2312,16 +2277,15 @@
2312 2277
2313 2278 public function updateFormEntry($Request, $post)
2314 2279 {
2315 2280 if (isset($Request['formID'], $Request['entryID'])) {
2316 - $formID = absint(wp_unslash($Request['formID']));
2317 - $entryID = absint(wp_unslash($Request['entryID']));
2281 + $formID = wp_unslash($Request['formID']);
2282 + $entryID = wp_unslash($Request['entryID']);
2318 2283 unset($Request['action'], $Request['formID'], $Request['entryID']);
2319 2284 }
2320 2285 $formManager = new AdminFormManager($formID);
2321 2286 $formManager->fieldNameReplaceOfPost();
2322 - // Called from AdminAjax handler; nonce already verified at AJAX entry before dispatch.
2323 - $updatedValue = is_array($post) ? $post : wp_unslash($_POST);
2287 + $updatedValue = wp_unslash($_POST);
2324 2288
2325 2289 if (is_null($updatedValue) || !is_array($updatedValue)) {
2326 2290 return new WP_Error('empty_data', __('Failed to update, Data is empty.', 'bit-form'));
2327 2291 }
@@ -2337,11 +2301,11 @@
2337 2301 }
2338 2302
2339 2303 public function getLogHistory($Request, $post)
2340 2304 {
2341 - if (!empty($Request['formID'])) {
2342 - $formID = absint(wp_unslash($Request['formID']));
2343 - $entryID = absint(wp_unslash($Request['entryID']));
2305 + if (isset($Request['formID'])) {
2306 + $formID = wp_unslash($Request['formID']);
2307 + $entryID = wp_unslash($Request['entryID']);
2344 2308 } else {
2345 2309 $formID = wp_unslash($post->formID);
2346 2310 $entryID = wp_unslash($post->entryID);
2347 2311 }
@@ -2361,10 +2325,10 @@
2361 2325 }
2362 2326
2363 2327 public function importDataStore($Request, $post)
2364 2328 {
2365 - if (!empty($Request['formID'])) {
2366 - $formID = absint(wp_unslash($Request['formID']));
2329 + if (isset($Request['formID'])) {
2330 + $formID = wp_unslash($Request['formID']);
2367 2331 } else {
2368 2332 $formID = wp_unslash($post->formID);
2369 2333 }
2370 2334 if (is_null($formID)) {
@@ -2376,14 +2340,10 @@
2376 2340 {
2377 2341 $pages = get_pages(['post_status' => 'publish', 'sort_column' => 'post_date', 'sort_order' => 'desc']);
2378 2342 $allPages = [];
2379 2343 foreach ($pages as $pageKey => $pageDetails) {
2380 - // $allPages[$pageKey]['title'] = $pageDetails->post_title;
2381 - // $allPages[$pageKey]['url'] = get_page_link($pageDetails->ID);
2382 - $allPages[] = (object) [
2383 - 'title' => $pageDetails->post_title,
2384 - 'url' => get_page_link($pageDetails->ID)
2385 - ];
2344 + $allPages[$pageKey]['title'] = $pageDetails->post_title;
2345 + $allPages[$pageKey]['url'] = get_page_link($pageDetails->ID);
2386 2346 }
2387 2347 return $allPages;
2388 2348 }
2389 2349
@@ -2388,11 +2348,11 @@
2388 2348 }
2389 2349
2390 2350 public function deleteAIntegration($Request, $post)
2391 2351 {
2392 - if (!empty($Request['formID']) && !empty($Request['id'])) {
2393 - $formID = absint(json_decode(wp_unslash($Request['formID'])));
2394 - $id = absint(wp_unslash($Request['id']));
2352 + if (isset($Request['formID']) && $Request['id']) {
2353 + $formID = json_decode(wp_unslash($Request['formID']));
2354 + $id = wp_unslash($Request['id']);
2395 2355 } else {
2396 2356 $formID = wp_unslash($post->formID);
2397 2357 $id = wp_unslash($post->id);
2398 2358 }
@@ -2412,11 +2372,11 @@
2412 2372 }
2413 2373
2414 2374 public function deleteSuccessMessage($Request, $post)
2415 2375 {
2416 - if (!empty($Request['formID']) && !empty($Request['id'])) {
2417 - $formID = absint(json_decode(wp_unslash($Request['formID'])));
2418 - $id = absint(wp_unslash($Request['id']));
2376 + if (isset($Request['formID']) && $Request['id']) {
2377 + $formID = json_decode(wp_unslash($Request['formID']));
2378 + $id = wp_unslash($Request['id']);
2419 2379 } else {
2420 2380 $formID = wp_unslash($post->formID);
2421 2381 $id = wp_unslash($post->id);
2422 2382 }
@@ -2435,11 +2395,11 @@
2435 2395 }
2436 2396
2437 2397 public function deleteAWorkflow($Request, $post)
2438 2398 {
2439 - if (!empty($Request['formID']) && !empty($Request['id'])) {
2440 - $formID = absint(json_decode(wp_unslash($Request['formID'])));
2441 - $id = absint(wp_unslash($Request['id']));
2399 + if (isset($Request['formID']) && $Request['id']) {
2400 + $formID = json_decode(wp_unslash($Request['formID']));
2401 + $id = wp_unslash($Request['id']);
2442 2402 } else {
2443 2403 $formID = wp_unslash($post->formID);
2444 2404 $id = wp_unslash($post->id);
2445 2405 }
@@ -2457,11 +2417,11 @@
2457 2417 }
2458 2418
2459 2419 public function deleteAMailTemplate($Request, $post)
2460 2420 {
2461 - if (!empty($Request['formID']) && !empty($Request['id'])) {
2462 - $formID = absint(json_decode(wp_unslash($Request['formID'])));
2463 - $id = absint(wp_unslash($Request['id']));
2421 + if (isset($Request['formID']) && $Request['id']) {
2422 + $formID = json_decode(wp_unslash($Request['formID']));
2423 + $id = wp_unslash($Request['id']);
2464 2424 } else {
2465 2425 $formID = wp_unslash($post->formID);
2466 2426 $id = wp_unslash($post->id);
2467 2427 }
@@ -2479,11 +2439,11 @@
2479 2439 }
2480 2440
2481 2441 public function duplicateAMailTemplate($Request, $post)
2482 2442 {
2483 - if (!empty($Request['formID']) && !empty($Request['id'])) {
2484 - $formID = absint(json_decode(wp_unslash($Request['formID'])));
2485 - $id = absint(wp_unslash($Request['id']));
2443 + if (isset($Request['formID']) && $Request['id']) {
2444 + $formID = json_decode(wp_unslash($Request['formID']));
2445 + $id = wp_unslash($Request['id']);
2486 2446 } else {
2487 2447 $formID = wp_unslash($post->formID);
2488 2448 $id = wp_unslash($post->id);
2489 2449 }
@@ -2642,9 +2602,9 @@
2642 2602 $paySetting = json_decode($paySetting);
2643 2603 }
2644 2604
2645 2605 $canSave = null;
2646 - switch ($paySetting->type) {
2606 + switch($paySetting->type) {
2647 2607 case 'PayPal':
2648 2608 $canSave = $this->addWebhookToPaypal($paySetting);
2649 2609 break;
2650 2610 case 'Razorpay':
@@ -2745,16 +2705,15 @@
2745 2705 }
2746 2706 }
2747 2707
2748 2708 $data = [
2749 - 'enabled_events[]' => 'payment_intent.succeeded',
2750 - 'url' => $webhook_url,
2709 + 'enabled_events[]' => 'payment_intent.succeeded',
2710 + 'url' => $webhook_url,
2751 2711 ];
2752 2712
2753 2713 if (!$webhook_already_exist) {
2754 2714 $webhook_response = HttpHelper::post($create_webhook_url, $data, $headers);
2755 2715 if (is_wp_error($webhook_response) || (isset($webhook_response->error) && $webhook_response->error)) {
2756 - Log::debug_log(['Stripe webhook creation failed' => $webhook_response]);
2757 2716 return null;
2758 2717 }
2759 2718 }
2760 2719 return true;
@@ -2794,49 +2753,8 @@
2794 2753 } elseif (!$update_status) {
2795 2754 return new WP_Error('empty_form', __('Form update failed.', 'bit-form'));
2796 2755 } else {
2797 2756 return true;
2798 - }
2799 - }
2800 -
2801 - public function replaceAllFormsErrorMessagesByGlobalMessages()
2802 - {
2803 - try {
2804 - $formModel = new FormModel();
2805 - $allForms = $formModel->get(['id', 'form_content']);
2806 -
2807 - foreach ($allForms as $form) {
2808 - // Decode form_content JSON to stdClass
2809 - $formContent = \json_decode($form->form_content);
2810 - $fields = $formContent->fields ?? null;
2811 - // If decode fails, skip to next
2812 - if (!$fields) {
2813 - Log::debug_log("Form ID {$form->id}: invalid JSON in form_content");
2814 - continue;
2815 - }
2816 -
2817 - // Replace default error messages using your helper
2818 - $updatedFields = Helpers::replaceFieldsDefaultErrorMsg($fields);
2819 -
2820 - $formContent->fields = $updatedFields;
2821 - // Encode back to JSON
2822 - $updatedContent = \json_encode($formContent);
2823 -
2824 - if (false === $updatedContent) {
2825 - Log::debug_log("Form ID {$form->id}: JSON encoding failed");
2826 - continue;
2827 - }
2828 - // Update form content in DB
2829 - $formModel->update(
2830 - ['form_content' => $updatedContent], // data to update
2831 - ['id' => $form->id] // condition for update
2832 - );
2833 - }
2834 - } catch (\Exception $e) {
2835 - Log::debug_log([
2836 - 'message' => 'Error in updateAllFormsErrorMessagesWithGlobalMessages',
2837 - 'error' => $e->getMessage(),
2838 - ]);
2839 2757 }
2840 2758 }
2841 2759
2842 2760 public function updateSuccessMessageClassName($str, $msgIdx, $msgId)