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/Frontend/Form/FrontendFormHandler.php +51 -155 3.1.12.15.3 View file →
@@ -1,13 +1,8 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Frontend\Form;
4 4
5 -if (!defined('ABSPATH')) {
6 - exit;
7 -}
8 -
9 -use BitCode\BitForm\Admin\Form\AdminFormHandler;
10 5 use BitCode\BitForm\Admin\Form\FrontEndScriptGenerator;
11 6 use BitCode\BitForm\Admin\Form\Helpers;
12 7 use BitCode\BitForm\Core\Database\FormEntryMetaModel;
13 8 use BitCode\BitForm\Core\Database\FormModel;
@@ -12,16 +7,15 @@
12 7 use BitCode\BitForm\Core\Database\FormEntryMetaModel;
13 8 use BitCode\BitForm\Core\Database\FormModel;
14 9 use BitCode\BitForm\Core\Form\FormManager;
15 10 use BitCode\BitForm\Core\Integration\IntegrationHandler;
16 -use BitCode\BitForm\Core\Util\EscapingHelper;
17 11 use BitCode\BitForm\Core\Util\FieldValueHandler;
18 12 use BitCode\BitForm\Core\Util\FileDownloadProvider;
19 13 use BitCode\BitForm\Core\Util\FrontendHelpers;
20 14 use BitCode\BitForm\Core\Util\SmartTags;
21 -use BitCode\BitForm\Core\Util\SmartTagRegistry;
15 +use BitCode\BitForm\Core\Util\Utilities;
22 16 use BitCode\BitForm\Core\WorkFlow\WorkFlow;
23 -use Error;
17 +use BitCode\BitFormPro\Admin\FormSettings\FormAbandonment;
24 18
25 19 final class FrontendFormHandler
26 20 {
27 21 public function __construct()
@@ -55,9 +49,9 @@
55 49 }
56 50
57 51 private function getJSFileSrc($postId)
58 52 {
59 - $formUpdateVersion = get_option('bitform_form_update_version');
53 + $formUpdateVersion = get_option('bit-form_form_update_version');
60 54 $formScriptSrc = BITFORMS_UPLOAD_BASE_URL . "/form-scripts/$postId/bitform-js-$postId.js?bfv=$formUpdateVersion";
61 55
62 56 return $formScriptSrc;
63 57 }
@@ -83,12 +77,12 @@
83 77 $formIDs = [];
84 78 $previewMode = 'classic';
85 79 $postId = '';
86 80
87 - $formUpdateVersion = get_option('bitform_form_update_version');
81 + $formUpdateVersion = get_option('bit-form_form_update_version');
88 82 if ($formID) {
89 83 $formIDs[] = $formID;
90 - $FrontendFormManager = FrontendFormManager::getInstance($formID, 1);
84 + $FrontendFormManager = new FrontendFormManager($formID, 1);
91 85 $formInfo = $FrontendFormManager->getFormInfo();
92 86 $FormIdentifier = esc_js($FrontendFormManager->getFormIdentifier());
93 87 $formContent = $FrontendFormManager->getFormContentWithValue($this->getValuesFromQueryParams());
94 88 $formContent->formId = $formID;
@@ -130,9 +124,9 @@
130 124 return;
131 125 }
132 126 foreach ($bfFrontendFormIds as $index => $formId) {
133 127 $shortCodeCounter = $index + 1;
134 - $FrontendFormManager = FrontendFormManager::getInstance($formId, $shortCodeCounter);
128 + $FrontendFormManager = new FrontendFormManager($formId, $shortCodeCounter);
135 129 $formInfo = $FrontendFormManager->getFormInfo();
136 130 $FormIdentifier = esc_js($FrontendFormManager->getFormIdentifier());
137 131 $formContent = $FrontendFormManager->getFormContentWithValue($this->getValuesFromQueryParams());
138 132 $formContent->formId = $formId;
@@ -155,11 +149,8 @@
155 149 return;
156 150 }
157 151
158 152 $frontendScriptGenObj->generateJsFile($formContents, $allFields, $contentIds, $postId, $formIDs, $previewMode);
159 - if ('preview' === $previewMode) {
160 - return;
161 - }
162 153 wp_enqueue_script('bit-form-all-script-test', $this->getJSFileSrc($postId), [], $formUpdateVersion, true);
163 154 }
164 155
165 156 private function deleteUnusedFormPageIds($postId, $formIDs)
@@ -187,15 +178,15 @@
187 178 $formModel->update(['generated_script_page_ids' => wp_json_encode($generatedScriptPageIdsDecoded)], ['id' => $formId]);
188 179 }
189 180 }
190 181 if ($regenerateScriptFlag) {
191 - $formUpdateVersion = get_option('bitform_form_update_version');
182 + $formUpdateVersion = get_option('bit-form_form_update_version');
192 183 if (!$formUpdateVersion) {
193 184 $formUpdateVersion = 1;
194 185 } else {
195 186 $formUpdateVersion = (int) $formUpdateVersion + 1;
196 187 }
197 - update_option('bitform_form_update_version', $formUpdateVersion);
188 + update_option('bit-form_form_update_version', $formUpdateVersion);
198 189 }
199 190 return $regenerateScriptFlag;
200 191 }
201 192
@@ -208,9 +199,9 @@
208 199 $postId = $post->ID;
209 200 $regenerateScriptFlag = false;
210 201 $formModel = new FormModel();
211 202 foreach ($formsIds as $formId) {
212 - $formInstance = FormManager::getInstance($formId);
203 + $formInstance = new FormManager($formId);
213 204 if (!$formInstance->isExist()) {
214 205 continue;
215 206 }
216 207 $generatedPages = $formInstance->getFormData('generated_script_page_ids');
@@ -240,11 +231,10 @@
240 231
241 232 private function addInlineScript($code, $handle = '', $position = 'after')
242 233 {
243 234 $scriptHandle = !empty($handle) ? $handle : 'bf-inline-script';
244 - $formUpdateVersion = get_option('bitform_form_update_version');
245 235 if (!wp_script_is($scriptHandle)) {
246 - wp_register_script($scriptHandle, '', [], $formUpdateVersion, true);
236 + wp_register_script($scriptHandle, '', [], '', true);
247 237 wp_enqueue_script($scriptHandle);
248 238 }
249 239 wp_add_inline_script($scriptHandle, $code, $position);
250 240 }
@@ -251,11 +241,10 @@
251 241
252 242 private function addInlineStyle($code, $handle = '')
253 243 {
254 244 $styleHandle = !empty($handle) ? $handle : 'bf-inline-style';
255 - $formUpdateVersion = get_option('bitform_form_update_version');
256 245 if (!wp_style_is($styleHandle)) {
257 - wp_register_style($styleHandle, '', [], $formUpdateVersion);
246 + wp_register_style($styleHandle, '', [], '', true);
258 247 wp_enqueue_style($styleHandle);
259 248 }
260 249 wp_add_inline_style($styleHandle, $code);
261 250 }
@@ -283,9 +272,9 @@
283 272 }
284 273
285 274 private function executeOnUserInput($formID, $shortCodeCounter, $fields)
286 275 {
287 - $FrontendFormManager = FrontendFormManager::getInstance($formID, $shortCodeCounter);
276 + $FrontendFormManager = new FrontendFormManager($formID, $shortCodeCounter);
288 277 $previousValue = $this->getValuesFromQueryParams();
289 278 $formContent = $FrontendFormManager->getFormContentWithValue($previousValue);
290 279 $customCodesExist = strpos(FrontEndScriptGenerator::getCustomCodes($formID)['JavaScript'], 'bfVars');
291 280 if ($customCodesExist || (!empty($formContent->workFlowExist) && !empty($formContent->workFlowExist->oninput))) {
@@ -295,12 +284,11 @@
295 284 }
296 285
297 286 private function getValuesFromQueryParams()
298 287 {
299 - // Read-only: query string parsed to pre-fill form fields. Values are sanitized per field before use.
300 288 $queryParamsValue = [];
301 289 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
302 - $reqField = sanitize_text_field(wp_unslash($_SERVER['QUERY_STRING']));
290 + $reqField = $_SERVER['QUERY_STRING'];
303 291 foreach (explode('&', $reqField) as $keyValue) {
304 292 // $pattern = '/([a-zA-Z0-9])([a-zA-Z])\=+/';
305 293 $pattern = '/([^.]+)=(.*?)([^.]+)/';
306 294 $matches = preg_match($pattern, $keyValue, $matchFormat);
@@ -327,11 +315,10 @@
327 315 $formID = intval($atts['form_id']);
328 316 }
329 317 if (isset($atts['entry_id'])) {
330 318 $entryId = intval($atts['entry_id']);
331 - // Read-only: entry ID from query string for shortcode render. No state mutation.
332 - } elseif (isset($_GET['bf_entry_id']) && !is_array($_GET['bf_entry_id'])) {
333 - $entryId = intval(sanitize_text_field(wp_unslash($_GET['bf_entry_id'])));
319 + } elseif (isset($_GET['bf_entry_id'])) {
320 + $entryId = $_GET['bf_entry_id'];
334 321 } else {
335 322 $entryId = false;
336 323 }
337 324 if (isset($atts['id'])) {
@@ -343,22 +330,24 @@
343 330 return __('Form ID cannot be empty', 'bit-form');
344 331 }
345 332
346 333 if (!$this->isExist($formID)) {
347 - /* translators: %s: form ID */
348 334 return sprintf(__('#%s no. Form doesn\'t exists', 'bit-form'), $formID);
349 335 }
350 336
351 - // Add-ons may detect whether the current visitor is resuming an abandoned entry.
352 - $isAbandoned = (bool) apply_filters('bitform_is_abandoned_entry', false, $formID, $entryId, $atts);
337 + // check for abandoned form entry id
338 + $isAbandoned = false;
339 + if (empty($entryId) && Utilities::isPro() && class_exists('\BitCode\BitFormPro\Admin\FormSettings\FormAbandonment')) {
340 + $FormAbandonment = new FormAbandonment($formID);
341 + $isAbandoned = $FormAbandonment->checkAbandonedFormEntryId();
342 + }
353 343
354 344 FrontendHelpers::setBfFrontendFormIds($formID);
355 345 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
356 346 $shortCodeCounter = count($bfFrontendFormIds);
357 - $FrontendFormManager = FrontendFormManager::getInstance($formID, $shortCodeCounter);
347 + $FrontendFormManager = new FrontendFormManager($formID, $shortCodeCounter);
358 348
359 349 if (!$FrontendFormManager->checkStatus()) {
360 - /* translators: %s: form ID */
361 350 return sprintf(__('#%s no. Form is not active', 'bit-form'), $formID);
362 351 }
363 352 ob_start();
364 353 $this->loadAssets($formID, $formType);
@@ -368,11 +357,10 @@
368 357 if ($font && !$formPreview) {
369 358 wp_enqueue_style('bf-google-font', $font, '1.0.0', true);
370 359 }
371 360
372 - // Read-only: password reset token from URL for display-time validation. No state written until form is submitted.
373 361 if (!empty($_GET['token']) && !empty($_GET['id'])) {
374 - $this->validPassowordResetToken(sanitize_text_field(wp_unslash($_GET['token'])), sanitize_text_field(wp_unslash($_GET['id'])), $formID);
362 + $this->validPassowordResetToken($_GET['token'], $_GET['id'], $formID);
375 363 }
376 364
377 365 $previousValue = $this->getValuesFromQueryParams();
378 366 $errorMessages = []; // delete
@@ -389,20 +377,13 @@
389 377 $buttons = !empty($formContent->buttons) ? $formContent->buttons : '';
390 378 $additional = $formContent->additional;
391 379
392 380 // $workFlowRunType = $entryId ? 'edit' : 'create';
393 - if ($entryId && (FrontendHelpers::is_current_user_can_access($formID, 'entryEditAccess'))) {
381 + if ($entryId && (get_current_user_id() || is_admin())) {
382 + // return sprintf(__('Sorry!, You cannot edit #%s no form.', 'bit-form'), $formID);
394 383 $workFlowRunType = 'edit';
395 - $adminFormHandler = new AdminFormHandler();
396 - $getEntry = $adminFormHandler->getSingleEntry($formID, $entryId);
397 - if (FrontendHelpers::is_current_user_can_access($formID, 'entryEditAccess', '', $getEntry->__user_id)) {
398 - $fields = $this->setFieldsValue($fields, $formID, $entryId);
399 - } elseif (!$isAbandoned) {
400 - $entryId = false;
401 - $workFlowRunType = 'create';
402 - }
384 + $fields = $this->setFieldsValue($fields, $formID, $entryId);
403 385 } else {
404 - $entryId = false;
405 386 $workFlowRunType = 'create';
406 387 }
407 388
408 389 // if ($entryId) {
@@ -415,11 +396,11 @@
415 396 do_action('bitform_onload_fields', $fields, $formID);
416 397 $workFlowreturnedOnUserInput = $this->executeOnUserInput($formID, $shortCodeCounter, $fields);
417 398
418 399 // test for form before remove
419 - $noLabelFieldTypes = ['decision-box', 'gdpr', 'html', 'shortcode', 'button', 'paypal', 'razorpay', 'recaptcha', 'turnstile', 'hcaptcha', 'stripe', 'spacer'];
400 + $noLabel = ['decision-box', 'html', 'shortcode', 'button', 'paypal', 'razorpay', 'recaptcha'];
420 401 foreach ($fields as $fldKey => $field) {
421 - if (!in_array($field->typ, $noLabelFieldTypes) && isset($field->lbl)) {
402 + if (!in_array($field->typ, $noLabel) && isset($field->lbl)) {
422 403 $lblReplaceToBackslash = str_replace('$_bf_$', '\\', $field->lbl);
423 404 $fields->{$fldKey}->lbl = FieldValueHandler::replaceSmartTagWithValue($lblReplaceToBackslash);
424 405 }
425 406 }
@@ -425,9 +406,9 @@
425 406 }
426 407 $fieldsKey = $FrontendFormManager->getFieldsKey();
427 408
428 409 $captchaV3Settings = $FrontendFormManager->getCaptchaV3Settings();
429 - if ($FrontendFormManager->getCaptchaSettings() || $captchaV3Settings || $FrontendFormManager->getTurnstileSettings() || $FrontendFormManager->isFieldTypeExist('hcaptcha')) {
410 + if ($FrontendFormManager->getCaptchaSettings() || $captchaV3Settings || $FrontendFormManager->getTurnstileSettings()) {
430 411 $integrationHandler = new IntegrationHandler(0);
431 412 $allFormIntegrations = $integrationHandler->getAllIntegration('app');
432 413 if (!is_wp_error($allFormIntegrations)) {
433 414 foreach ($allFormIntegrations as $integration) {
@@ -450,17 +431,8 @@
450 431 $integrationDetails = json_decode($integration->integration_details);
451 432 $turnstileSiteKey = $integrationDetails->siteKey;
452 433 }
453 434
454 - if (
455 - $FrontendFormManager->isFieldTypeExist('hcaptcha')
456 - && !is_null($integration->integration_type)
457 - && 'hcaptcha' === $integration->integration_type
458 - ) {
459 - $integrationDetails = json_decode($integration->integration_details);
460 - $hCaptchaSiteKey = $integrationDetails->siteKey;
461 - }
462 -
463 435 if ($captchaV3Settings) {
464 436 if (!is_null($integration->integration_type) && 'gReCaptchaV3' === $integration->integration_type) {
465 437 $integrationDetails = json_decode($integration->integration_details);
466 438 $integrationDetails->id = $integration->id;
@@ -474,11 +446,9 @@
474 446
475 447 if ($captchaV3Settings && !empty($reCAPTCHA->siteKey)) {
476 448 // DANGER: no matter what, DONT CHANGE THE SCRIPT ID OF THIS SCRIPT
477 449 $scriptId = BITFORMS_PREFIX . 'recaptcha';
478 - // External Google reCAPTCHA script; version managed by URL query param. Loaded in header because
479 - // standalone form views do not render wp_footer(), making footer enqueue unreliable.
480 - wp_enqueue_script($scriptId, "https://www.google.com/recaptcha/api.js?render={$reCAPTCHA->siteKey}", [], null, false);
450 + wp_enqueue_script($scriptId, "https://www.google.com/recaptcha/api.js?render={$reCAPTCHA->siteKey}");
481 451 }
482 452
483 453 $configs = [
484 454 'bf_separator' => BITFORMS_BF_SEPARATOR,
@@ -531,14 +501,13 @@
531 501 'appID' => "bitforms_{$formID}",
532 502 'GCLID' => $FrontendFormManager->isGCLIDEnabled(),
533 503 'assetUrl' => BITFORMS_ASSET_URI,
534 504 'onfieldCondition' => !empty($workFlowreturnedOnUserInput['onfield_input_conditions']) ? $workFlowreturnedOnUserInput['onfield_input_conditions'] : false,
535 - 'smartTags' => $this->buildFrontendSmartTags($formID, $workFlowreturnedOnUserInput, $fields),
505 + 'smartTags' => SmartTags::smartTags(SmartTags::getPostUserData()),
536 506 'paymentCallbackUrl' => get_rest_url() . 'bitform/v1/payments/razorpay',
537 507 'gRecaptchaSiteKey' => !empty($reCAPTCHA->siteKey) ? $reCAPTCHA->siteKey : null,
538 508 'gRecaptchaVersion' => !empty($reCAPTCHAVersion) ? $reCAPTCHAVersion : null,
539 - 'turnstileSiteKey' => !empty($turnstileSiteKey) ? $turnstileSiteKey : null,
540 - 'hCaptchaSiteKey' => !empty($hCaptchaSiteKey) ? $hCaptchaSiteKey : null,
509 + 'turnstileSiteKey' => !empty($turnstileSiteKey) ? $turnstileSiteKey : null
541 510 ];
542 511
543 512 if ($entryId) {
544 513 $bitFormFrontArr['entryId'] = $entryId;
@@ -555,9 +524,8 @@
555 524 }
556 525 }
557 526
558 527 $formInfo = $FrontendFormManager->getFormInfo();
559 - $bitFormFrontArr['formName'] = $formInfo->formName ?? '';
560 528 if (is_array($layout) && count($layout) > 1) {
561 529 $multiStepSettings = isset($formInfo->multiStepSettings) ? $formInfo->multiStepSettings : null;
562 530 $newTempSettings = (object) [
563 531 'validateOnStepChange' => isset($multiStepSettings->validateOnStepChange) ? $multiStepSettings->validateOnStepChange : false,
@@ -583,24 +551,27 @@
583 551 'formAbandonment' => $formAbandonmentSettings
584 552 ];
585 553 }
586 554
555 + $bitFormsFront = apply_filters(
556 + 'bitforms_localized_script',
557 + $bitFormFrontArr
558 + );
559 +
587 560 $layout = wp_json_encode($layout);
588 561 $buttons = wp_json_encode($buttons);
589 562 $frontArr = wp_json_encode($bitFormFrontArr);
590 563
591 - $bfGlobals = sprintf('
564 + $bfGlobals = <<<BFGLOBALS
592 565 if(!window.bf_globals) {
593 566 window.bf_globals = {}
594 - } if(!window.bf_globals.%1$s) {
595 - window.bf_globals.%1$s = {}
567 + } if(!window.bf_globals.{$FormIdentifier}) {
568 + window.bf_globals.{$FormIdentifier} = {}
596 569 }
597 - if(document.getElementById("%1$s")) {
598 - window.bf_globals.%1$s = {
599 - ...window.bf_globals.%1$s,
600 - ...%2$s
601 - };
602 - }', $FormIdentifier, $frontArr);
570 + if(document.getElementById('{$FormIdentifier}')) {
571 + window.bf_globals.{$FormIdentifier} = {...window.bf_globals.{$FormIdentifier}, ...{$frontArr}};
572 + }
573 +BFGLOBALS;
603 574
604 575 if ('conversational' === $formType
605 576 && isset($formContent->formInfo->conversationalSettings->enable)
606 577 && $formContent->formInfo->conversationalSettings->enable) {
@@ -615,87 +586,17 @@
615 586 $formViewObject = new \stdClass();
616 587 $formViewObject->html = $html;
617 588 $formViewObject->font = $font;
618 589 $formViewObject->bfGlobals = $bfGlobals;
619 - $formViewObject->formContent = $formContent;
620 590 return $formViewObject;
621 591 }
622 -
623 - $bfGlobalsHandle = 'bitform-bf-globals-' . sanitize_key($FormIdentifier);
624 - $this->addInlineScript($bfGlobals, $bfGlobalsHandle, 'after');
625 - $this->emitShowPickerBridge();
626 -
627 - echo wp_kses(trim($html), EscapingHelper::getFormAllowedHtml($formContent));
592 + $html .= <<<BFGLOBALSSCRIPT
593 + <script id="bit-form-bf-globals-{$FormIdentifier}">{$bfGlobals}</script>
594 +BFGLOBALSSCRIPT;
595 + echo trim($html);
628 596 return ob_get_clean();
629 597 }
630 598
631 - /**
632 - * Build the smart-tag map exposed to the browser in window.bf_globals[formId].smartTags.
633 - *
634 - * Security: the legacy code shipped the ENTIRE ~43-tag map to every visitor, leaking
635 - * PII (admin/user/author email) and freezing per-visitor request data (IP, time,
636 - * browser, referer) into cacheable HTML. We now emit ONLY tags that are (a) actually
637 - * referenced by this form's client-evaluated surfaces — conditional logic, payment
638 - * notes, admin custom JS — AND (b) flagged frontend-safe in the registry (static/post
639 - * context only). Sensitive (identity) and request/visitor tags are never emitted; they
640 - * resolve server-side at submit time instead.
641 - *
642 - * @param int|string $formID
643 - * @param mixed $workflowConditions on-field input conditions (client-evaluated)
644 - * @param mixed $fields form fields object (carries payment notes, etc.)
645 - * @return array<string,string>
646 - */
647 - private function buildFrontendSmartTags($formID, $workflowConditions, $fields)
648 - {
649 - // Haystack = only surfaces the browser actually evaluates against smartTags.
650 - $haystack = wp_json_encode($workflowConditions) . ' ' . wp_json_encode($fields);
651 - $customJs = FrontEndScriptGenerator::getCustomCodes($formID)['JavaScript'];
652 - if (is_string($customJs) && '' !== $customJs) {
653 - $haystack .= ' ' . $customJs;
654 - }
655 -
656 - $ctx = SmartTags::getPostUserData();
657 - $frontendSmartTags = [];
658 - $referenced = [];
659 - foreach (SmartTags::smartTagFieldKeys() as $key) {
660 - if (!SmartTagRegistry::isFrontendExposable($key)) {
661 - continue; // identity / request / param tags never travel to the browser
662 - }
663 - // Match '${' . key prefix so keys containing spaces/slashes/commas are handled.
664 - if (false !== strpos($haystack, '${' . $key)) {
665 - $referenced[] = $key;
666 - $frontendSmartTags[$key] = SmartTagRegistry::resolve($key, $ctx);
667 - }
668 - }
669 -
670 - /**
671 - * Escape hatch: a site that genuinely needs an extra tag client-side can opt it
672 - * back in explicitly here, rather than core shipping everything by default.
673 - *
674 - * @param array<string,string> $frontendSmartTags resolved frontend-safe smart tags
675 - * @param int|string $formID
676 - * @param string[] $referenced keys detected in client surfaces
677 - */
678 - return apply_filters('bitform_frontend_smarttags', $frontendSmartTags, $formID, $referenced);
679 - }
680 -
681 - /**
682 - * Delegated listener that opens the native picker on date/time inputs marked
683 - * with data-bf-show-picker. Replaces the legacy hardcoded onclick attribute.
684 - * Registered as inline script once per request via wp_add_inline_script so
685 - * the markup never travels through wp_kses().
686 - */
687 - private function emitShowPickerBridge()
688 - {
689 - static $emitted = false;
690 - if ($emitted) {
691 - return;
692 - }
693 - $emitted = true;
694 - $code = 'if(!window.__bfShowPickerBound){window.__bfShowPickerBound=true;document.addEventListener("click",function(e){var t=e.target;if(t&&t.matches&&t.matches("input[data-bf-show-picker=\"1\"]")&&typeof t.showPicker==="function"){try{t.showPicker();}catch(_){}}});}';
695 - $this->addInlineScript($code, 'bitform-show-picker-bridge', 'after');
696 - }
697 -
698 599 private function isExist($formID)
699 600 {
700 601 $formModel = new FormModel();
701 602 $form = $formModel->get(
@@ -713,9 +614,8 @@
713 614 }
714 615
715 616 private function getFieldsValue($formID, $entryID)
716 617 {
717 - $FrontendFormManager = FrontendFormManager::getInstance($formID, 1);
718 618 $formEntryModel = new FormEntryMetaModel();
719 619 $metaValues = $formEntryModel->get(
720 620 [
721 621 'meta_key',
@@ -724,9 +624,8 @@
724 624 [
725 625 'bitforms_form_entry_id' => $entryID,
726 626 ]
727 627 );
728 - $formFields = $FrontendFormManager->getFields();
729 628 $fldsData = (object) [];
730 629 if (!is_wp_error($metaValues)) {
731 630 foreach ($metaValues as $metaValue) {
732 631 $metaKey = $metaValue->meta_key;
@@ -744,11 +643,8 @@
744 643 if (!isset($fldsData->{$metaKey})) {
745 644 $fldsData->{$metaKey} = '';
746 645 }
747 646 $fldsData->{$metaKey} = $metaVal;
748 - if (isset($formFields[$metaKey]['type']) && in_array($formFields[$metaKey]['type'], ['file-up', 'advanced-file-up'])) {
749 - $fldsData->{$metaKey} = $metaValue->meta_value;
750 - }
751 647 }
752 648 }
753 649
754 650 return $fldsData;
@@ -816,9 +712,9 @@
816 712 $newFormId = $formID . '-formid';
817 713 } else {
818 714 $newFormId = $formID;
819 715 }
820 - $formUpdateVersion = get_option('bitform_form_update_version');
716 + $formUpdateVersion = get_option('bit-form_form_update_version');
821 717 if (!wp_style_is('bitform-style-' . $newFormId) && is_readable(BITFORMS_CONTENT_DIR . '/form-styles/bitform-' . $newFormId . '.css')) {
822 718 wp_enqueue_style(
823 719 'bitform-style-' . $newFormId,
824 720 BITFORMS_UPLOAD_BASE_URL . "/form-styles/bitform-{$newFormId}.css",
@@ -826,9 +722,9 @@
826 722 $formUpdateVersion
827 723 );
828 724 if ($isPageBuilder) {
829 725 $formStyle = file_get_contents(BITFORMS_CONTENT_DIR . '/form-styles/bitform-' . $newFormId . '.css');
830 - echo '<style id="bitform-style-' . esc_attr((string) $newFormId) . '">' . wp_kses($formStyle, []) . '</style>';
726 + echo sprintf("<style id='bitform-style-{$newFormId}'>%s</style>", $formStyle);
831 727 }
832 728 }
833 729 if (!wp_style_is('bitform-style-custom-' . $formID) && is_readable(BITFORMS_CONTENT_DIR . '/form-styles/bitform-custom-' . $formID . '.css')) {
834 730 wp_enqueue_style(
@@ -838,9 +734,9 @@
838 734 $formUpdateVersion
839 735 );
840 736 if ($isPageBuilder) {
841 737 $formStyle = file_get_contents(BITFORMS_CONTENT_DIR . '/form-styles/bitform-custom-' . $formID . '.css');
842 - echo '<style id="bitform-style-custom-' . esc_attr((string) $formID) . '">' . wp_kses($formStyle, []) . '</style>';
738 + echo sprintf("<style id='bitform-style-custom-{$formID}'>%s</style>", $formStyle);
843 739 }
844 740 }
845 741 // load conversational form css
846 742 if ('conversational' === $fromType) {