PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/fields/FrmFieldGdpr.php +22 -7 6.25.1 → trunk View file →
@@ -9,8 +9,9 @@
9 9 class FrmFieldGdpr extends FrmFieldType {
10 10
11 11 /**
12 12 * @since 6.19
13 + *
13 14 * @var string
14 15 */
15 16 protected $type = 'gdpr';
16 17
@@ -15,8 +16,9 @@
15 16 protected $type = 'gdpr';
16 17
17 18 /**
18 19 * @since 6.19
20 + *
19 21 * @var bool
20 22 */
21 23 protected $has_for_label = false;
22 24
@@ -21,8 +23,9 @@
21 23 protected $has_for_label = false;
22 24
23 25 /**
24 26 * @since 6.19
27 + *
25 28 * @var string
26 29 */
27 30 const VIEW_PATH = '/classes/views/frm-fields/front-end/gdpr/gdpr-field.php';
28 31
@@ -29,8 +32,9 @@
29 32 /**
30 33 * Get the new field defaults.
31 34 *
32 35 * @since 6.19
36 + *
33 37 * @return array
34 38 */
35 39 public function get_new_field_defaults() {
36 40 if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
@@ -57,8 +61,9 @@
57 61 /**
58 62 * Get the field settings for the field type.
59 63 *
60 64 * @since 6.19
65 + *
61 66 * @return bool[]
62 67 */
63 68 protected function field_settings_for_type() {
64 69 if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
@@ -90,8 +95,9 @@
90 95 /**
91 96 * Show the primary options for the field.
92 97 *
93 98 * @since 6.19
99 + *
94 100 * @param array $args The arguments.
95 101 */
96 102 public function show_primary_options( $args ) {
97 103 if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
@@ -96,8 +102,9 @@
96 102 public function show_primary_options( $args ) {
97 103 if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
98 104 return;
99 105 }
106 +
100 107 $field = $args['field'];
101 108 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/gdpr/primary-options.php';
102 109 }
103 110
@@ -111,8 +118,9 @@
111 118 /**
112 119 * Gets extra field options.
113 120 *
114 121 * @since 6.19
122 + *
115 123 * @return string[]
116 124 */
117 125 protected function extra_field_opts() {
118 126 return array(
@@ -123,8 +131,9 @@
123 131 /**
124 132 * Include the form builder file.
125 133 *
126 134 * @since 6.19
135 + *
127 136 * @return string
128 137 */
129 138 protected function include_form_builder_file() {
130 139 return FrmAppHelper::plugin_path() . self::VIEW_PATH;
@@ -133,8 +142,9 @@
133 142 /**
134 143 * Include the front form file.
135 144 *
136 145 * @since 6.19
146 + *
137 147 * @return string
138 148 */
139 149 protected function include_front_form_file() {
140 150 return FrmAppHelper::plugin_path() . self::VIEW_PATH;
@@ -146,8 +156,9 @@
146 156 * @since 6.19
147 157 *
148 158 * @param array $args The arguments.
149 159 * @param string $html The HTML.
160 + *
150 161 * @return string
151 162 */
152 163 protected function before_replace_html_shortcodes( $args, $html ) {
153 164 if ( FrmFieldGdprHelper::hide_gdpr_field() && ! current_user_can( 'frm_edit_forms' ) ) {
@@ -161,20 +172,23 @@
161 172 *
162 173 * @since 6.20
163 174 *
164 175 * @param array $args
176 + *
165 177 * @return array
166 178 */
167 179 public function validate( $args ) {
168 180 $errors = parent::validate( $args );
169 181
170 - if ( ! $errors && ! FrmFieldGdprHelper::hide_gdpr_field() ) {
171 - $required = FrmField::get_option( $this->field, 'required' );
182 + if ( $errors || FrmFieldGdprHelper::hide_gdpr_field() ) {
183 + return $errors;
184 + }
172 185
173 - if ( ! $required && empty( $args['value'] ) ) {
174 - $frm_settings = FrmAppHelper::get_settings();
175 - $errors[ 'field' . $args['id'] ] = str_replace( '[field_name]', is_object( $this->field ) ? $this->field->name : $this->field['name'], $frm_settings->blank_msg );
176 - }
186 + $required = FrmField::get_option( $this->field, 'required' );
187 +
188 + if ( ! $required && empty( $args['value'] ) ) {
189 + $frm_settings = FrmAppHelper::get_settings();
190 + $errors[ 'field' . $args['id'] ] = str_replace( '[field_name]', is_object( $this->field ) ? $this->field->name : $this->field['name'], $frm_settings->blank_msg );
177 191 }
178 192
179 193 return $errors;
180 194 }
@@ -185,13 +199,14 @@
185 199 * @since 6.20
186 200 *
187 201 * @param bool $required
188 202 * @param array $field
203 + *
189 204 * @return bool
190 205 */
191 206 public static function force_required_field( $required, $field ) {
192 207 if ( ! $required && 'gdpr' === $field['type'] && ! FrmFieldGdprHelper::hide_gdpr_field() ) {
193 - $required = true;
208 + return true;
194 209 }
195 210
196 211 return $required;
197 212 }