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/FrontendFormManager.php +121 -83 2.10.02.15.3 View file →
@@ -112,13 +112,16 @@
112 112 $msg = !empty($isRestricted) ? $isRestricted[0] : '';
113 113 return $formViewer->getConversationalView($hasFile, $msg);
114 114 }
115 115
116 - private function checkEmptySubmission($data, $file)
116 + public function checkEmptySubmission($data, $file)
117 117 {
118 118 $formFields = $this->getFields();
119 119 foreach ($formFields as $key => $field) {
120 120 $fieldType = $field['type'];
121 + if ('button' === $fieldType) {
122 + continue;
123 + }
121 124 $fileUploadFieldTypes = ['file-up', 'advanced-file-up'];
122 125 if ('decision-box' === $fieldType) {
123 126 continue;
124 127 }
@@ -184,10 +187,12 @@
184 187 {
185 188 $this->fieldNameReplaceOfPost();
186 189
187 190 $validated = $this->beforeSubmittedValidate();
191 + $validated = apply_filters('bitform_filter_form_validation', $validated, $this->_form_id);
188 192
189 193 if (true === $validated) {
194 + do_action('bitform_validation_success', $this->_form_id);
190 195 unset($_POST['hidden_fields']);
191 196
192 197 $redirectPage = '';
193 198 $regSuccMsg = '';
@@ -199,13 +204,17 @@
199 204
200 205 if (true === $existAuthFilter) {
201 206 $result = apply_filters('bf_wp_user_auth', $existAuth[0], $_POST, $parameter);
202 207
208 + $result = apply_filters('bitform_filter_wp_user_auth_response', $result, $_POST, $parameter);
209 +
210 + do_action('bitform_wp_user_auth_response', $result, $_POST, $parameter);
211 +
203 212 if (isset($result['auth_type']) && 'register' === $result['auth_type']) {
204 213 if (!$result['success']) {
205 214 return new WP_Error('errors', __($result['message'], 'bit-form'));
206 215 } elseif (isset($result['success'])) {
207 - $redirectPage = $result['redirect_url'];
216 + $redirectPage = $result['redirectPage'];
208 217 $regSuccMsg = $result['message'];
209 218 $newNonce = wp_create_nonce('bitforms_' . $this->_form_id);
210 219 }
211 220 } else {
@@ -270,8 +279,9 @@
270 279 }
271 280 if (!empty($regSuccMsg) && isset($saveResponse['dflt_message'])) {
272 281 $saveResponse['message'] = $regSuccMsg;
273 282 }
283 +
274 284 $saveResponse = IntegrationHandler::maybeSetCronForIntegration($saveResponse, 'create');
275 285 $entryId = $saveResponse['entry_id'];
276 286
277 287 $responseMsg = is_array($saveResponse) && !empty($saveResponse) ? $saveResponse : __('Form Submitted Successfully', 'bit-form');
@@ -289,14 +299,17 @@
289 299 public function handleUpdateEntry()
290 300 {
291 301 $this->fieldNameReplaceOfPost();
292 302 $validated = $this->beforeSubmittedValidate();
303 + $validated = apply_filters('bitform_filter_form_validation', $validated, $this->_form_id);
293 304
294 305 $entryID = $_REQUEST['entryID'];
306 + $GLOBALS['bf_entry_id'] = $entryID;
295 307 if (is_null($entryID)) {
296 308 return new WP_Error('empty_form', __('Entries id is invalid', 'bit-form'));
297 309 }
298 310 if (true === $validated) {
311 + do_action('bitform_validation_success', $this->_form_id);
299 312 unset($_POST['hidden_fields'], $_POST['entryID']);
300 313
301 314 $redirectPage = '';
302 315 $regSuccMsg = '';
@@ -312,9 +325,9 @@
312 325 if (isset($result['auth_type']) && 'register' === $result['auth_type']) {
313 326 if (!$result['success']) {
314 327 return new WP_Error('errors', __($result['message'], 'bit-form'));
315 328 } elseif (isset($result['success'])) {
316 - $redirectPage = $result['redirect_url'];
329 + $redirectPage = $result['redirectPage'];
317 330 $regSuccMsg = $result['message'];
318 331 $newNonce = wp_create_nonce('bitforms_' . $this->_form_id);
319 332 }
320 333 } else {
@@ -410,94 +423,20 @@
410 423 }
411 424 if ($this->isTrappedInHoneypot()) {
412 425 return new WP_Error('spam_detection', __('Token verification failed', 'bit-form'));
413 426 }
414 - $captchaSettings = $this->getCaptchaSettings();
415 - $captchaV3Settings = $this->getCaptchaV3Settings();
416 - if ($captchaSettings || $captchaV3Settings) {
417 - $token = $_POST['g-recaptcha-response'];
418 - if (!isset($_POST['g-recaptcha-response'])) {
419 - return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
420 - }
421 - $integrationHandler = new IntegrationHandler(0);
422 - $allFormIntegrations = $integrationHandler->getAllIntegration('app', $captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3');
423 - if (!is_wp_error($allFormIntegrations)) {
424 - foreach ($allFormIntegrations as $integration) {
425 - if (!is_null($integration->integration_type) && $integration->integration_type === ($captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3')) {
426 - $integrationDetails = json_decode($integration->integration_details);
427 - $integrationDetails->id = $integration->id;
428 - $reCAPTCHA = $integrationDetails;
429 - }
430 - }
431 - }
432 - if (!empty($reCAPTCHA->secretKey)) {
433 - $gRecaptchaResponse = HttpHelper::post(
434 - 'https://www.google.com/recaptcha/api/siteverify',
435 - ['secret' => $reCAPTCHA->secretKey, 'response' => $token]
436 - );
437 - $isgReCaptchaVerified = false;
438 - if (!is_wp_error($gRecaptchaResponse)) {
439 - if (
440 - $captchaV3Settings
441 - && !empty($gRecaptchaResponse->score)
442 - && ((float) $gRecaptchaResponse->score < (float) $captchaV3Settings->score)
443 - ) {
444 - wp_send_json_error(
445 - __(
446 - $captchaV3Settings->message,
447 - 'bit-form'
448 - )
449 - );
450 - }
427 + $formCurrentStep = isset($_POST['form-current-step']) ? $_POST['form-current-step'] : null;
451 428
452 - $isgReCaptchaVerified = $gRecaptchaResponse->success;
453 - }
454 - if (!$isgReCaptchaVerified) {
455 - return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
456 - }
457 - }
429 + if (is_wp_error($this->verifyGRecaptcha())) {
430 + return $this->verifyGRecaptcha();
458 431 }
459 432
460 433 /* Implement Turnstile Captcha start */
461 - $turnstileSetting = $this->getTurnstileSettings();
462 - if ($turnstileSetting) {
463 - if (!isset($_POST['cf-turnstile-response'])) {
464 - return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
465 - }
466 - $token = $_POST['cf-turnstile-response'];
467 - $turnstileCaptcha = null;
468 - $integrationHandler = new IntegrationHandler(0);
469 - $turnstileIntegration = $integrationHandler->getAllIntegration('app', 'turnstileCaptcha')[0];
470 - if (!is_wp_error($turnstileIntegration && !is_null($turnstileIntegration->integration_type))) {
471 - $turnstileCaptcha = json_decode($turnstileIntegration->integration_details);
472 - // $integrationDetails->id = $turnstileIntegration->id;
473 - // $turnstileCaptcha = $integrationDetails;
474 - }
475 - if (!is_null($turnstileCaptcha)) {
476 - $isTurnstileCaptchaVerified = false;
477 - $turnstileRecaptchaResponse = HttpHelper::post(
478 - 'https://challenges.cloudflare.com/turnstile/v0/siteverify',
479 - ['secret' => $turnstileCaptcha->secretKey, 'response' => $token]
480 - );
481 - if (!is_wp_error($turnstileRecaptchaResponse)) {
482 - if (!$turnstileRecaptchaResponse->success) {
483 - wp_send_json_error(
484 - __(
485 - 'Cloudflare Turnstile Validation Error: ' . implode(', ', $turnstileRecaptchaResponse->{'error-codes'}),
486 - 'bit-form'
487 - )
488 - );
489 - }
490 -
491 - $isTurnstileCaptchaVerified = $turnstileRecaptchaResponse->success;
492 - }
493 - if (!$isTurnstileCaptchaVerified) {
494 - return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
495 - }
496 - }
434 + if (is_wp_error($this->verifyTurnstileCaptcha())) {
435 + return $this->verifyTurnstileCaptcha();
497 436 }
437 + /* Implement Turnstile Captcha end */
498 438
499 - /* Implement Turnstile Captcha end */
500 439 $existAuth = (new IntegrationHandler($this->_form_id))->getAllIntegration('wp_user_auth', 'wp_auth', 1);
501 440
502 441 // check if user is already logged in and form has auth integration
503 442 do_action('bitform_checked_exist_auth', $this->_form_id, $existAuth);
@@ -567,8 +506,98 @@
567 506 return new WP_Error('token_expired', __('Token expired', 'bit-form'));
568 507 }
569 508 }
570 509
510 + private function verifyGRecaptcha()
511 + {
512 + $captchaSettings = $this->getCaptchaSettings();
513 + $captchaV3Settings = $this->getCaptchaV3Settings();
514 + if ($captchaSettings || $captchaV3Settings) {
515 + $token = $_POST['g-recaptcha-response'];
516 + if (!isset($_POST['g-recaptcha-response'])) {
517 + return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
518 + }
519 + $integrationHandler = new IntegrationHandler(0);
520 + $allFormIntegrations = $integrationHandler->getAllIntegration('app', $captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3');
521 + if (!is_wp_error($allFormIntegrations)) {
522 + foreach ($allFormIntegrations as $integration) {
523 + if (!is_null($integration->integration_type) && $integration->integration_type === ($captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3')) {
524 + $integrationDetails = json_decode($integration->integration_details);
525 + $integrationDetails->id = $integration->id;
526 + $reCAPTCHA = $integrationDetails;
527 + }
528 + }
529 + }
530 + if (!empty($reCAPTCHA->secretKey)) {
531 + $gRecaptchaResponse = HttpHelper::post(
532 + 'https://www.google.com/recaptcha/api/siteverify',
533 + ['secret' => $reCAPTCHA->secretKey, 'response' => $token]
534 + );
535 + $isgReCaptchaVerified = false;
536 + if (!is_wp_error($gRecaptchaResponse)) {
537 + if (
538 + $captchaV3Settings
539 + && !empty($gRecaptchaResponse->score)
540 + && ((float) $gRecaptchaResponse->score < (float) $captchaV3Settings->score)
541 + ) {
542 + wp_send_json_error(
543 + __(
544 + $captchaV3Settings->message,
545 + 'bit-form'
546 + )
547 + );
548 + }
549 +
550 + $isgReCaptchaVerified = $gRecaptchaResponse->success;
551 + }
552 + if (!$isgReCaptchaVerified) {
553 + return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
554 + }
555 + }
556 + }
557 + }
558 +
559 + private function verifyTurnstileCaptcha()
560 + {
561 + $turnstileSetting = $this->getTurnstileSettings();
562 + if ($turnstileSetting) {
563 + if (!isset($_POST['cf-turnstile-response'])) {
564 + return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
565 + }
566 + $token = $_POST['cf-turnstile-response'];
567 + $turnstileCaptcha = null;
568 + $integrationHandler = new IntegrationHandler(0);
569 + $turnstileIntegration = $integrationHandler->getAllIntegration('app', 'turnstileCaptcha')[0];
570 + if (!is_wp_error($turnstileIntegration && !is_null($turnstileIntegration->integration_type))) {
571 + $turnstileCaptcha = json_decode($turnstileIntegration->integration_details);
572 + // $integrationDetails->id = $turnstileIntegration->id;
573 + // $turnstileCaptcha = $integrationDetails;
574 + }
575 + if (!is_null($turnstileCaptcha)) {
576 + $isTurnstileCaptchaVerified = false;
577 + $turnstileRecaptchaResponse = HttpHelper::post(
578 + 'https://challenges.cloudflare.com/turnstile/v0/siteverify',
579 + ['secret' => $turnstileCaptcha->secretKey, 'response' => $token]
580 + );
581 + if (!is_wp_error($turnstileRecaptchaResponse)) {
582 + if (!$turnstileRecaptchaResponse->success) {
583 + wp_send_json_error(
584 + __(
585 + 'Cloudflare Turnstile Validation Error: ' . implode(', ', $turnstileRecaptchaResponse->{'error-codes'}),
586 + 'bit-form'
587 + )
588 + );
589 + }
590 +
591 + $isTurnstileCaptchaVerified = $turnstileRecaptchaResponse->success;
592 + }
593 + if (!$isTurnstileCaptchaVerified) {
594 + return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
595 + }
596 + }
597 + }
598 + }
599 +
571 600 public function verifySubmissionNonce()
572 601 {
573 602 if (!isset($_POST['t_identity']) && !isset($_POST['csrf'])) {
574 603 return false;
@@ -879,8 +908,17 @@
879 908 $msg = '<div class="bf-form-msg active warning">' . wp_kses_post($msg) . '</div>';
880 909 }
881 910 return $msg;
882 911 }
912 + }
913 +
914 + public function getFormAbandonmentSettings()
915 + {
916 + if (class_exists('\BitCode\BitFormPro\Admin\FormSettings\FormAbandonment')) {
917 + $formAbandonmentSettings = FormAbandonment::getFormAbandonmentSettings($this->form_id);
918 + return $formAbandonmentSettings;
919 + }
920 + return null;
883 921 }
884 922
885 923 private function messageMarkup($msg)
886 924 {