| @@ -8,22 +8,14 @@ | ||
| 8 | 8 | class FormEntryView |
| 9 | 9 | { |
| 10 | 10 | public static function preview() |
| 11 | 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'])) : ''; | |
| 12 | + $requestUri = $_SERVER['REQUEST_URI']; | |
| 18 | 13 | $uri = explode('/', $requestUri); |
| 19 | 14 | |
| 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]; | |
| 15 | + if (is_array($uri) && count($uri) > 0) { | |
| 16 | + $formID = $uri[count($uri) - 2]; | |
| 17 | + $entryID = $uri[count($uri) - 1]; | |
| 26 | 18 | $attr = ['form_id' => $formID, 'entry_id' => $entryID, 'form_preview' => true]; |
| 27 | 19 | |
| 28 | 20 | $frontendFormHandler = new FrontendFormHandler(); |
| 29 | 21 | $formViewObject = $frontendFormHandler->handleFrontendRenderRequest($attr); |
| @@ -34,13 +26,13 @@ | ||
| 34 | 26 | |
| 35 | 27 | $formHTML = $formViewObject->html; |
| 36 | 28 | $font = $formViewObject->font; |
| 37 | 29 | $bfGlobals = $formViewObject->bfGlobals; |
| 38 | - $formContent = isset($formViewObject->formContent) ? $formViewObject->formContent : null; | |
| 39 | - | |
| 30 | + | |
| 40 | 31 | set_transient('bitform_form_preview', true); |
| 41 | 32 | $frontendFormHandler->generateJs($formID, $entryID); |
| 42 | 33 | $title = 'BitForm Entry edit'; |
| 43 | - Render::view('views/entry-edit-page', compact('formID', 'title', 'formHTML', 'font', 'bfGlobals', 'formContent')); | |
| 34 | + Render::view('views/entry-edit-page', compact('formID', 'title', 'formHTML', 'font', 'bfGlobals')); | |
| 35 | + | |
| 44 | 36 | } |
| 45 | 37 | } |
| 46 | 38 | } |