| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
use BitCode\BitForm\Frontend\CustomRoutes; |
| 8 |
use BitCode\BitForm\Frontend\FormEntryView; |
| 9 |
use BitCode\BitForm\Frontend\StandaloneFormView; |
| 10 |
|
| 11 |
$bitforms_routes = new CustomRoutes(); |
| 12 |
// $bitforms_routes->add('bitform-form-view/([0-9]+)/?', [StandaloneFormView::class, 'preview']); |
| 13 |
// $bitforms_routes->add('bitform-form-entry-edit/([0-9]+)/?([0-9]+)/?', [FormEntryView::class, 'preview']); |
| 14 |
|
| 15 |
// if (class_exists('\BitCode\BitFormPro\Admin\DownloadFile')) { |
| 16 |
// $routes->add('bitform-download-file', [\BitCode\BitFormPro\Admin\DownloadFile::class, 'download']); // for all users |
| 17 |
// $routes->add('bitform-download-pdf', [\BitCode\BitFormPro\Admin\DownloadFile::class, 'adminDownloadPDF']); // for admin users |
| 18 |
// } |
| 19 |
|
| 20 |
add_action('template_redirect', function () { |
| 21 |
// form preview |
| 22 |
// url structure = siteurl/?bitform-form-view=2 |
| 23 |
if (isset($_REQUEST['bitform-form-view'])) { |
| 24 |
StandaloneFormView::preview(); |
| 25 |
exit; |
| 26 |
} |
| 27 |
|
| 28 |
// form entry edit |
| 29 |
// url structure = siteurl/?bitform-form-entry-edit=1&formid=3&entryid=23 |
| 30 |
if (isset($_REQUEST['bitform-form-entry-edit'], $_REQUEST['formId'], $_REQUEST['entryId']) && 1 === intval(sanitize_text_field(wp_unslash($_REQUEST['bitform-form-entry-edit'])))) { |
| 31 |
FormEntryView::preview(); |
| 32 |
exit; |
| 33 |
} |
| 34 |
|
| 35 |
//pdf file preview |
| 36 |
//url structure = siteurl/?bitform-download-pdf=1&formID=1&pdftemp=1&entryId=35 |
| 37 |
if ( |
| 38 |
(isset($_REQUEST['bitform-download-pdf'], $_REQUEST['formID'], $_REQUEST['pdftemp'],$_REQUEST['entryId']) || |
| 39 |
isset($_REQUEST['bitform-download-file'], $_REQUEST['token'])) |
| 40 |
&& class_exists('\BitCode\BitFormPro\Admin\DownloadFile')) { |
| 41 |
// admin download pdf |
| 42 |
if (1 === intval(sanitize_text_field(wp_unslash($_REQUEST['bitform-download-pdf']))) && !isset($_REQUEST['bitform-download-file'])) { |
| 43 |
\BitCode\BitFormPro\Admin\DownloadFile::adminDownloadPDF(); |
| 44 |
exit; |
| 45 |
} |
| 46 |
|
| 47 |
// all user |
| 48 |
if (1 === intval(sanitize_text_field(wp_unslash($_REQUEST['bitform-download-file']))) && !isset($_REQUEST['bitform-download-pdf'])) { |
| 49 |
\BitCode\BitFormPro\Admin\DownloadFile::download(); |
| 50 |
exit; |
| 51 |
} |
| 52 |
} |
| 53 |
}); |
| 54 |
|