PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Services/Preview/PreviewService.php +8 -7 0.1.2 → 1.5 View file →
@@ -1,16 +1,12 @@
1 1 <?php
2 2
3 3 namespace IvyForms\Services\Preview;
4 4
5 -// phpcs:disable PSR1.Files.SideEffects
6 -if (!defined('ABSPATH')) {
7 - exit; // Exit if accessed directly
8 -}
9 -
10 5 use IvyForms\Common\Exceptions\ForbiddenException;
11 6 use IvyForms\Common\Sanitizer\Sanitizer;
12 7 use IvyForms\Services\API\IvyFormsAPI;
8 +use IvyForms\Services\Permissions\IvyFormsAccess;
13 9 use stdClass;
14 10 use WP_Post;
15 11
16 12 /**
@@ -44,8 +40,11 @@
44 40 {
45 41 $this->formId = $formId;
46 42 }
47 43
44 + /**
45 + * @throws ForbiddenException
46 + */
48 47 public function __construct()
49 48 {
50 49 if ($this->isPreview()) {
51 50 $this->init();
@@ -50,12 +49,14 @@
50 49 if ($this->isPreview()) {
51 50 $this->init();
52 51 }
53 52 }
53 +
54 54 /**
55 55 * Initialize the preview service
56 56 *
57 57 * This function sets up the necessary hooks and filters for the preview functionality.
58 + * @throws ForbiddenException
58 59 */
59 60 public function init(): void
60 61 {
61 62 $this->checkFormId();
@@ -102,9 +103,9 @@
102 103 403
103 104 );
104 105 }
105 106
106 - if (!current_user_can('manage_options')) {
107 + if (!IvyFormsAccess::canAccessFormPreview()) {
107 108 wp_die(
108 109 esc_html__('Sorry, you are not allowed to visit this preview form as this user.', 'ivyforms'),
109 110 esc_html__('You need a higher level of permission.', 'ivyforms'),
110 111 403
@@ -135,9 +136,9 @@
135 136 {
136 137 global $wp, $wp_query;
137 138
138 139 // Set post ID
139 - $postId = -1;
140 + $postId = 0;
140 141
141 142 // Post constructor
142 143 $post = new stdClass();
143 144 $post->ID = $postId;