PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.2
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 2.10.2 All 137 releases
bit-form / includes / Frontend / FormEntryView.php

FormEntryView.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.1.2, at includes/Frontend/FormEntryView.php

47 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend;
4
5 use BitCode\BitForm\Core\Util\Render;
6 use BitCode\BitForm\Frontend\Form\FrontendFormHandler;
7
8 class FormEntryView
9 {
10 public static function preview()
11 {
12 if (!(current_user_can('manage_options') || current_user_can('manage_bitform') || current_user_can('bitform_entry_edit'))) {
13 auth_redirect();
14 return;
15 }
16 // Read-only: REQUEST_URI and query params used for view dispatch. Capability check enforced above (line 12).
17 $requestUri = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : '';
18 $uri = explode('/', $requestUri);
19
20 $formID = isset($_REQUEST['formId']) ? intval(sanitize_text_field(wp_unslash($_REQUEST['formId']))) : null;
21 $entryID = isset($_REQUEST['entryId']) ? intval(sanitize_text_field(wp_unslash($_REQUEST['entryId']))) : null;
22
23 if (!is_array($formID) && !is_array($entryID) && is_numeric($formID) && is_numeric($entryID)) {
24 // $formID = $uri[count($uri) - 2];
25 // $entryID = $uri[count($uri) - 1];
26 $attr = ['form_id' => $formID, 'entry_id' => $entryID, 'form_preview' => true];
27
28 $frontendFormHandler = new FrontendFormHandler();
29 $formViewObject = $frontendFormHandler->handleFrontendRenderRequest($attr);
30 if ('string' === gettype($formViewObject)) {
31 Render::view('views/form-not-found');
32 exit;
33 }
34
35 $formHTML = $formViewObject->html;
36 $font = $formViewObject->font;
37 $bfGlobals = $formViewObject->bfGlobals;
38 $formContent = isset($formViewObject->formContent) ? $formViewObject->formContent : null;
39
40 set_transient('bitform_form_preview', true);
41 $frontendFormHandler->generateJs($formID, $entryID);
42 $title = 'BitForm Entry edit';
43 Render::view('views/entry-edit-page', compact('formID', 'title', 'formHTML', 'font', 'bfGlobals', 'formContent'));
44 }
45 }
46 }
47