PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.18 1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 All 42 releases
← All changes | includes/widgets/contact-form.php +1125 -1961 1.0.7 → 1.3.17 View file →
@@ -1,10 +1,13 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements;
3 4
4 5 use UiCoreElements\Helper;
5 6 use UiCoreElements\Utils\Contact_Form_Service;
6 7 use UiCoreElements\Utils\Form_Component;
8 +use UiCoreElements\Utils\Newsletter_Services;
9 +
7 10 use Elementor\Controls_Manager;
8 11 use Elementor\Icons_Manager;
9 12 use Elementor\Utils;
10 13 use Elementor\Repeater;
@@ -22,30 +25,35 @@
22 25 * @author Lucas Marini Falbo <[email protected]>
23 26 * @since 1.0.5
24 27 */
25 28
26 -class ContactForm extends UiCoreWidget {
29 +class ContactForm extends UiCoreWidget
30 +{
27 31
28 32 use Form_Component;
29 33
30 - public function get_name() {
31 - return 'uicore-contact-form';
32 - }
34 + public function get_name()
35 + {
36 + return 'uicore-contact-form';
37 + }
33 38
34 - public function get_title() {
35 - return __( 'Contact Form', 'uicore-elements' );
36 - }
39 + public function get_title()
40 + {
41 + return __('Contact Form', 'uicore-elements');
42 + }
37 43
38 - public function get_icon() {
39 - return 'eicon-form-horizontal ui-e-widget';
40 - }
44 + public function get_icon()
45 + {
46 + return 'eicon-form-horizontal ui-e-widget';
47 + }
41 48 public function get_categories()
42 49 {
43 50 return ['uicore'];
44 51 }
45 - public function get_keywords() {
46 - return [ 'form', 'forms', 'contact', 'mail', 'send', 'field', 'button', 'recaptcha', ];
47 - }
52 + public function get_keywords()
53 + {
54 + return ['form', 'forms', 'contact', 'mail', 'send', 'field', 'button', 'recaptcha',];
55 + }
48 56 public function get_styles()
49 57 {
50 58 return ['contact-form'];
51 59 }
@@ -60,21 +68,26 @@
60 68 'custom_condition' => $this->check_recaptcha_version('v3')
61 69 ],
62 70 'repeater-custom-key' => [
63 71 'custom_condition' => $this->is_edit_mode()
64 - ]
72 + ]
65 73 ];
66 74 }
75 + public function has_widget_inner_wrapper(): bool
76 + {
77 + // TODO: remove after Optmized Markup experiment is merged to the core
78 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');;
79 + }
67 80 function check_recaptcha_version($version)
68 81 {
69 82
70 - if($this->is_edit_mode()){
83 + if ($this->is_edit_mode()) {
71 84 return true;
72 85 }
73 86 $settings = $this->get_settings_for_display();
74 87 foreach ($settings['form_fields'] as $field) {
75 88 $version_to_check = $version === 'v2' ? 'recaptcha' : 'recaptcha_v3';
76 - if($field['field_type'] === $version_to_check){
89 + if ($field['field_type'] === $version_to_check) {
77 90 return true;
78 91 }
79 92 }
80 93 return false;
@@ -79,854 +92,692 @@
79 92 }
80 93 return false;
81 94 }
82 95
83 - // Helper Functions
84 - function get_field_types()
96 + // Helper Functions
97 + function get_field_types()
85 98 {
86 99 return [
87 - 'text' => esc_html__( 'Text', 'uicore-elements' ),
88 - 'email' => esc_html__( 'Email', 'uicore-elements' ),
89 - 'textarea' => esc_html__( 'Textarea', 'uicore-elements' ),
90 - 'url' => esc_html__( 'URL', 'uicore-elements' ),
91 - 'tel' => esc_html__( 'Tel', 'uicore-elements' ),
92 - 'radio' => esc_html__( 'Radio', 'uicore-elements' ),
93 - 'select' => esc_html__( 'Select', 'uicore-elements' ),
94 - 'checkbox' => esc_html__( 'Checkbox', 'uicore-elements' ),
95 - 'acceptance' => esc_html__( 'Acceptance', 'uicore-elements' ),
96 - 'number' => esc_html__( 'Number', 'uicore-elements' ),
97 - 'date' => esc_html__( 'Date', 'uicore-elements' ),
98 - 'time' => esc_html__( 'Time', 'uicore-elements' ),
99 - 'file' => esc_html__( 'File Upload', 'uicore-elements' ),
100 - 'password' => esc_html__( 'Password', 'uicore-elements' ),
101 - 'address' => esc_html__( 'Honeypot', 'uicore-elements' ),
102 - 'recaptcha' => esc_html__( 'reCAPTCHA', 'uicore-elements' ),
103 - 'recaptcha_v3' => esc_html__( 'reCAPTCHA V3', 'uicore-elements' ),
104 - 'html' => esc_html__( 'HTML', 'uicore-elements' ),
105 - 'hidden' => esc_html__( 'Hidden', 'uicore-elements' ),
106 - ];
100 + 'text' => esc_html__('Text', 'uicore-elements'),
101 + 'email' => esc_html__('Email', 'uicore-elements'),
102 + 'textarea' => esc_html__('Textarea', 'uicore-elements'),
103 + 'url' => esc_html__('URL', 'uicore-elements'),
104 + 'tel' => esc_html__('Tel', 'uicore-elements'),
105 + 'radio' => esc_html__('Radio', 'uicore-elements'),
106 + 'select' => esc_html__('Select', 'uicore-elements'),
107 + 'checkbox' => esc_html__('Checkbox', 'uicore-elements'),
108 + 'acceptance' => esc_html__('Acceptance', 'uicore-elements'),
109 + 'number' => esc_html__('Number', 'uicore-elements'),
110 + 'date' => esc_html__('Date', 'uicore-elements'),
111 + 'time' => esc_html__('Time', 'uicore-elements'),
112 + 'file' => esc_html__('File Upload', 'uicore-elements'),
113 + 'password' => esc_html__('Password', 'uicore-elements'),
114 + 'address' => esc_html__('Honeypot', 'uicore-elements'),
115 + 'recaptcha' => esc_html__('reCAPTCHA', 'uicore-elements'),
116 + 'recaptcha_v3' => esc_html__('reCAPTCHA V3', 'uicore-elements'),
117 + 'html' => esc_html__('HTML', 'uicore-elements'),
118 + 'hidden' => esc_html__('Hidden', 'uicore-elements'),
119 + ];
107 120 }
108 121
109 - function get_attribute_name( $item ) {
110 - return "form_fields[{$item['custom_id']}]";
111 - }
112 - function get_attribute_id( $item ) {
113 - return 'form-field-' . $item['custom_id'];
114 - }
115 - function add_required_attribute( $element ) {
116 - $this->add_render_attribute( $element, 'required', 'required' );
117 - $this->add_render_attribute( $element, 'aria-required', 'true' );
118 - }
122 + function get_attribute_name($item)
123 + {
124 + return "form_fields[{$item['custom_id']}]";
125 + }
126 + function get_attribute_id($item)
127 + {
128 + return 'form-field-' . $item['custom_id'];
129 + }
130 + function add_required_attribute($element, $js_verication = false)
131 + {
119 132
120 - // Control Render Functions
121 - function register_submit_email_controls($instance, $slug = '') {
122 - $instance->add_control(
123 - 'email_to' . $slug,
124 - [
125 - 'label' => esc_html__( 'To', 'uicore-elements' ),
126 - 'type' => Controls_Manager::TEXT,
127 - 'default' => get_option( 'admin_email' ),
128 - 'ai' => [
129 - 'active' => false,
130 - ],
131 - 'placeholder' => get_option( 'admin_email' ),
132 - 'label_block' => true,
133 - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
134 - 'render_type' => 'none',
135 - 'dynamic' => [
136 - 'active' => true,
137 - ],
138 - ]
139 - );
133 + // Used for elements (eg: checkbox) that aren't natively supported by the browsers validations
134 + if ($js_verication) {
135 + $this->add_render_attribute($element, 'data-ui-e-required', 'true');
136 + return;
137 + }
140 138
141 - /* translators: %s: Site title. */
142 - $default_message = sprintf( html_entity_decode( esc_html__( 'New message from "%s"', 'uicore-elements' ) ), get_option( 'blogname' ) );
139 + // Default method
140 + $this->add_render_attribute($element, 'required', 'required');
141 + $this->add_render_attribute($element, 'aria-required', 'true');
142 + }
143 143
144 - $instance->add_control(
145 - 'email_subject' . $slug,
146 - [
147 - 'label' => esc_html__( 'Subject', 'uicore-elements' ),
148 - 'type' => Controls_Manager::TEXT,
149 - 'default' => $default_message,
150 - 'ai' => [
151 - 'active' => false,
152 - ],
153 - 'placeholder' => $default_message,
154 - 'label_block' => true,
155 - 'render_type' => 'none',
156 - 'dynamic' => [
157 - 'active' => true,
158 - ],
159 - ]
160 - );
161 -
162 - $instance->add_control(
163 - 'email_content' . $slug,
164 - [
165 - 'label' => esc_html__( 'Message', 'uicore-elements' ),
166 - 'type' => Controls_Manager::TEXTAREA,
167 - 'default' => '[all-fields]',
168 - 'ai' => [
169 - 'active' => false,
170 - ],
171 - 'placeholder' => '[all-fields]',
172 - 'description' => sprintf(
173 - /* translators: %s: The [all-fields] shortcode. */
174 - esc_html__( 'By default, all form fields are sent via %s shortcode. To customize sent fields, copy the shortcode that appears inside each field and paste it above.', 'uicore-elements' ),
175 - '<code>[all-fields]</code>'
176 - ),
177 - 'render_type' => 'none',
178 - 'dynamic' => [
179 - 'active' => true,
180 - ],
181 - ]
182 - );
183 -
184 - $site_domain = Helper::get_site_domain();
185 -
186 - $instance->add_control(
187 - 'email_from' . $slug,
188 - [
189 - 'label' => esc_html__( 'From Email', 'uicore-elements' ),
190 - 'type' => Controls_Manager::TEXT,
191 - 'default' => 'email@' . $site_domain,
192 - 'ai' => [
193 - 'active' => false,
194 - ],
195 - 'render_type' => 'none',
196 - 'dynamic' => [
197 - 'active' => true,
198 - ],
199 - ]
200 - );
201 -
202 - $instance->add_control(
203 - 'email_from_name' . $slug,
204 - [
205 - 'label' => esc_html__( 'From Name', 'uicore-elements' ),
206 - 'type' => Controls_Manager::TEXT,
207 - 'default' => get_bloginfo( 'name' ),
208 - 'ai' => [
209 - 'active' => false,
210 - ],
211 - 'render_type' => 'none',
212 - 'dynamic' => [
213 - 'active' => true,
214 - ],
215 - ]
216 - );
217 -
218 - $instance->add_control(
219 - 'email_reply_to' . $slug,
220 - [
221 - 'label' => esc_html__( 'Reply-To', 'uicore-elements' ),
222 - 'type' => Controls_Manager::TEXT,
223 - 'options' => [
224 - '' => '',
225 - ],
226 - 'default' => 'noreply@' . Helper::get_site_domain(),
227 - 'render_type' => 'none',
228 - ]
229 - );
230 -
231 - $instance->add_control(
232 - 'email_to_cc' . $slug,
233 - [
234 - 'label' => esc_html__( 'Cc', 'uicore-elements' ),
235 - 'type' => Controls_Manager::TEXT,
236 - 'default' => '',
237 - 'ai' => [
238 - 'active' => false,
239 - ],
240 - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
241 - 'render_type' => 'none',
242 - 'dynamic' => [
243 - 'active' => true,
244 - ],
245 - ]
246 - );
247 -
248 - $instance->add_control(
249 - 'email_to_bcc' . $slug,
250 - [
251 - 'label' => esc_html__( 'Bcc', 'uicore-elements' ),
252 - 'type' => Controls_Manager::TEXT,
253 - 'default' => '',
254 - 'ai' => [
255 - 'active' => false,
256 - ],
257 - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
258 - 'render_type' => 'none',
259 - 'dynamic' => [
260 - 'active' => true,
261 - ],
262 - ]
263 - );
264 -
265 - $instance->add_control(
266 - 'form_metadata' . $slug,
267 - [
268 - 'label' => esc_html__( 'Meta Data', 'uicore-elements' ),
269 - 'type' => Controls_Manager::SELECT2,
270 - 'multiple' => true,
271 - 'label_block' => true,
272 - 'separator' => 'before',
273 - 'default' => [
274 - 'date',
275 - 'time',
276 - 'page_url',
277 - 'user_agent',
278 - 'remote_ip',
279 - ],
280 - 'options' => [
281 - 'date' => esc_html__( 'Date', 'uicore-elements' ),
282 - 'time' => esc_html__( 'Time', 'uicore-elements' ),
283 - 'page_url' => esc_html__( 'Page URL', 'uicore-elements' ),
284 - 'user_agent' => esc_html__( 'User Agent', 'uicore-elements' ),
285 - 'remote_ip' => esc_html__( 'Remote IP', 'uicore-elements' ),
286 - ],
287 - 'render_type' => 'none',
288 - ]
289 - );
290 -
291 - $instance->add_control(
292 - 'email_content_type' . $slug,
293 - [
294 - 'label' => esc_html__( 'Send As', 'uicore-elements' ),
295 - 'type' => Controls_Manager::SELECT,
296 - 'default' => 'html',
297 - 'render_type' => 'none',
298 - 'options' => [
299 - 'html' => esc_html__( 'HTML', 'uicore-elements' ),
300 - 'plain' => esc_html__( 'Plain', 'uicore-elements' ),
301 - ],
302 - ]
303 - );
304 - }
305 -
306 144 // Field Render Functions
307 - function build_honeypot_field( $item, $item_index ) {
308 - $this->add_render_attribute( 'honeypot' . $item_index, [
309 - 'class' => [
310 - 'ui-e-field',
145 + function build_honeypot_field($item, $item_index)
146 + {
147 + $this->add_render_attribute('honeypot' . $item_index, [
148 + 'class' => [
149 + 'ui-e-field',
311 150 'ui-e-h-p',
312 - esc_attr( $item['css_classes'] ),
313 - ],
314 - 'name' => 'ui-e-h-p',
315 - 'id' => 'ui-e-h-p',
316 - ] );
151 + esc_attr($item['css_classes']),
152 + ],
153 + 'name' => 'ui-e-h-p',
154 + 'id' => 'ui-e-h-p',
155 + 'autocomplete' => 'off',
156 + ]);
317 157
318 - if ( $item['placeholder'] ) {
319 - $this->add_render_attribute( 'honeypot' . $item_index, 'placeholder', $item['placeholder'] );
320 - }
158 + if ($item['placeholder']) {
159 + $this->add_render_attribute('honeypot' . $item_index, 'placeholder', $item['placeholder']);
160 + }
321 161
322 - if ( $item['required'] ) {
323 - $this->add_required_attribute( 'honeypot' . $item_index );
324 - }
162 + if ($item['required']) {
163 + $this->add_required_attribute('honeypot' . $item_index);
164 + }
325 165
326 - $value = empty( $item['field_value'] ) ? '' : $item['field_value'];
166 + $value = empty($item['field_value']) ? '' : $item['field_value'];
327 167
328 - return '<input ' . $this->get_render_attribute_string( 'honeypot' . $item_index ) . ' tabindex="-1">' . $value . '</input>';
329 - }
330 - function build_textarea_field( $item, $item_index ) {
331 - $this->add_render_attribute( 'textarea' . $item_index, [
332 - 'class' => [
333 - 'ui-e-field',
334 - esc_attr( $item['css_classes'] ),
335 - ],
336 - 'name' => $this->get_attribute_name( $item ),
337 - 'id' => $this->get_attribute_id( $item ),
338 - 'rows' => $item['rows'],
339 - ] );
168 + return '<input ' . $this->get_render_attribute_string('honeypot' . $item_index) . ' tabindex="-1">' . $value . '</input>';
169 + }
170 + function build_textarea_field($item, $item_index)
171 + {
172 + $this->add_render_attribute('textarea' . $item_index, [
173 + 'class' => [
174 + 'ui-e-field',
175 + esc_attr($item['css_classes']),
176 + ],
177 + 'name' => $this->get_attribute_name($item),
178 + 'id' => $this->get_attribute_id($item),
179 + 'rows' => $item['rows'],
180 + ]);
340 181
341 - if ( $item['placeholder'] ) {
342 - $this->add_render_attribute( 'textarea' . $item_index, 'placeholder', $item['placeholder'] );
343 - }
182 + if ($item['placeholder']) {
183 + $this->add_render_attribute('textarea' . $item_index, 'placeholder', $item['placeholder']);
184 + }
344 185
345 - if ( $item['required'] ) {
346 - $this->add_required_attribute( 'textarea' . $item_index );
347 - }
186 + if ($item['required']) {
187 + $this->add_required_attribute('textarea' . $item_index);
188 + }
348 189
349 - $value = empty( $item['field_value'] ) ? '' : $item['field_value'];
190 + $value = empty($item['field_value']) ? '' : $item['field_value'];
350 191
351 - return '<textarea ' . $this->get_render_attribute_string( 'textarea' . $item_index ) . '>' . $value . '</textarea>';
352 - }
353 - function build_select_field( $item, $i ) {
354 - $this->add_render_attribute(
355 - [
356 - 'select-wrapper' . $i => [
357 - 'class' => [
358 - 'ui-e-field',
359 - 'ui-e-field-select',
192 + return '<textarea ' . $this->get_render_attribute_string('textarea' . $item_index) . '>' . $value . '</textarea>';
193 + }
194 + function build_select_field($item, $i)
195 + {
196 + $this->add_render_attribute(
197 + [
198 + 'select-wrapper' . $i => [
199 + 'class' => [
200 + 'ui-e-field',
201 + 'ui-e-field-select',
360 202 'ui-e-field-subgroup',
361 - esc_attr( $item['css_classes'] ),
362 - ],
363 - ],
364 - 'select' . $i => [
365 - 'name' => $this->get_attribute_name( $item ) . ( ! empty( $item['allow_multiple'] ) ? '[]' : '' ),
366 - 'id' => $this->get_attribute_id( $item ),
367 - 'class' => [
368 - 'ui-e-field-textual',
369 - ],
370 - ],
371 - ]
372 - );
203 + esc_attr($item['css_classes']),
204 + ],
205 + ],
206 + 'select' . $i => [
207 + 'name' => $this->get_attribute_name($item) . (! empty($item['allow_multiple']) ? '[]' : ''),
208 + 'id' => $this->get_attribute_id($item),
209 + 'class' => [
210 + 'ui-e-field-textual',
211 + ],
212 + ],
213 + ]
214 + );
373 215
374 - if ( $item['required'] ) {
375 - $this->add_required_attribute( 'select' . $i );
376 - }
216 + if ($item['required']) {
217 + $this->add_required_attribute('select' . $i);
218 + }
377 219
378 - if ( $item['allow_multiple'] ) {
379 - $this->add_render_attribute( 'select' . $i, 'multiple' );
380 - if ( ! empty( $item['select_size'] ) ) {
381 - $this->add_render_attribute( 'select' . $i, 'size', $item['select_size'] );
382 - }
383 - }
220 + if ($item['allow_multiple']) {
221 + $this->add_render_attribute('select' . $i, 'multiple');
222 + if (! empty($item['select_size'])) {
223 + $this->add_render_attribute('select' . $i, 'size', $item['select_size']);
224 + }
225 + }
384 226
385 - $options = preg_split( "/\\r\\n|\\r|\\n/", $item['field_options'] );
227 + $options = preg_split("/\\r\\n|\\r|\\n/", $item['field_options']);
386 228
387 - if ( ! $options ) {
388 - return '';
389 - }
229 + if (! $options) {
230 + return '';
231 + }
390 232
391 - ob_start();
392 - ?>
393 - <div <?php $this->print_render_attribute_string( 'select-wrapper' . $i ); ?>>
394 - <select <?php $this->print_render_attribute_string( 'select' . $i ); ?>>
395 - <?php
396 - foreach ( $options as $key => $option ) {
397 - $option_id = $item['custom_id'] . $key;
398 - $option_value = esc_attr( $option );
399 - $option_label = esc_html( $option );
233 + ob_start();
234 +?>
235 + <div <?php $this->print_render_attribute_string('select-wrapper' . $i); ?>>
236 + <select <?php $this->print_render_attribute_string('select' . $i); ?>>
237 + <?php
238 + foreach ($options as $key => $option) {
239 + $option_id = $item['custom_id'] . $key;
240 + $option_value = esc_attr($option);
241 + $option_label = esc_html($option);
400 242
401 - if ( false !== strpos( $option, '|' ) ) {
402 - list( $label, $value ) = explode( '|', $option );
403 - $option_value = esc_attr( $value );
404 - $option_label = esc_html( $label );
405 - }
243 + if (false !== strpos($option, '|')) {
244 + list($label, $value) = explode('|', $option);
245 + $option_value = esc_attr($value);
246 + $option_label = esc_html($label);
247 + }
406 248
407 - $this->add_render_attribute( $option_id, 'value', $option_value );
249 + $this->add_render_attribute($option_id, 'value', $option_value);
408 250
409 - // Support multiple selected values
410 - if ( ! empty( $item['field_value'] ) && in_array( $option_value, explode( ',', $item['field_value'] ) ) ) {
411 - $this->add_render_attribute( $option_id, 'selected', 'selected' );
412 - } ?>
413 - <option <?php $this->print_render_attribute_string( $option_id ); ?>><?php
414 - // PHPCS - $option_label is already escaped
415 - echo $option_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></option>
416 - <?php } ?>
417 - </select>
418 - </div>
419 - <?php
251 + // Support multiple selected values
252 + if (! empty($item['field_value']) && in_array($option_value, explode(',', $item['field_value']))) {
253 + $this->add_render_attribute($option_id, 'selected', 'selected');
254 + } ?>
255 + <option <?php $this->print_render_attribute_string($option_id); ?>><?php
256 + // PHPCS - $option_label is already escaped
257 + echo $option_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
258 + ?></option>
259 + <?php } ?>
260 + </select>
261 + </div>
262 + <?php
420 263
421 - $select = ob_get_clean();
422 - return $select;
423 - }
424 - function build_radio_checkbox_field( $item, $item_index, $type ) {
425 - $options = preg_split( "/\\r\\n|\\r|\\n/", $item['field_options'] );
426 - $html = '';
427 - if ( $options ) {
428 - $html .= '<div class="ui-e-field-subgroup ' . esc_attr( $item['css_classes'] ) . ' ' . $item['inline_list'] . '">';
429 - foreach ( $options as $key => $option ) {
430 - $element_id = $item['custom_id'] . $key;
431 - $html_id = $this->get_attribute_id( $item ) . '-' . $key;
432 - $option_label = $option;
433 - $option_value = $option;
434 - if ( false !== strpos( $option, '|' ) ) {
435 - list( $option_label, $option_value ) = explode( '|', $option );
436 - }
264 + $select = ob_get_clean();
265 + return $select;
266 + }
267 + function build_radio_checkbox_field($item, $item_index, $type)
268 + {
269 + $options = preg_split("/\\r\\n|\\r|\\n/", $item['field_options']);
270 + $html = '';
271 + if ($options) {
272 + $html .= '<div class="ui-e-field-subgroup ' . esc_attr($item['css_classes']) . ' ' . $item['inline_list'] . '">';
273 + foreach ($options as $key => $option) {
274 + $element_id = $item['custom_id'] . $key;
275 + $html_id = $this->get_attribute_id($item) . '-' . $key;
276 + $option_label = $option;
277 + $option_value = $option;
278 + if (false !== strpos($option, '|')) {
279 + list($option_label, $option_value) = explode('|', $option);
280 + }
437 281
438 - $this->add_render_attribute(
439 - $element_id,
440 - [
441 - 'type' => $type,
442 - 'value' => $option_value,
443 - 'id' => $html_id,
444 - 'name' => $this->get_attribute_name( $item ) . ( ( 'checkbox' === $type && count( $options ) > 1 ) ? '[]' : '' ),
445 - ]
446 - );
282 + $this->add_render_attribute(
283 + $element_id,
284 + [
285 + 'type' => $type,
286 + 'value' => $option_value,
287 + 'id' => $html_id,
288 + 'name' => $this->get_attribute_name($item) . (('checkbox' === $type && count($options) > 1) ? '[]' : ''),
289 + ]
290 + );
447 291
448 - if ( ! empty( $item['field_value'] ) && $option_value === $item['field_value'] ) {
449 - $this->add_render_attribute( $element_id, 'checked', 'checked' );
450 - }
292 + if ($item['required']) {
293 + $this->add_required_attribute($element_id, true);
294 + }
451 295
452 - if ( $item['required'] && 'radio' === $type ) {
453 - $this->add_required_attribute( $element_id );
454 - }
296 + if (! empty($item['field_value']) && $option_value === $item['field_value']) {
297 + $this->add_render_attribute($element_id, 'checked', 'checked');
298 + }
455 299
456 - $html .= '<span class="ui-e-field-option"><input ' . $this->get_render_attribute_string( $element_id ) . '> <label for="' . $html_id . '">' . $option_label . '</label></span>';
457 - }
458 - $html .= '</div>';
459 - }
300 + if ($item['required'] && 'radio' === $type) {
301 + $this->add_required_attribute($element_id);
302 + }
460 303
461 - return $html;
462 - }
463 - function build_acceptance_field($item, $item_index) {
464 - $text = '';
465 - $this->add_render_attribute( 'input' . $item_index, 'class', 'ui-e-acceptance-field' );
466 - $this->add_render_attribute( 'input' . $item_index, 'type', 'checkbox', true );
304 + $html .= '<span class="ui-e-field-option"><input ' . $this->get_render_attribute_string($element_id) . '> <label for="' . $html_id . '">' . $option_label . '</label></span>';
305 + }
306 + $html .= '</div>';
307 + }
467 308
468 - if ( ! empty( $item['acceptance_text'] ) ) {
469 - $text = '<label for="' . $this->get_attribute_id( $item ) . '">' . $item['acceptance_text'] . '</label>';
470 - }
309 + return $html;
310 + }
311 + function build_acceptance_field($item, $item_index)
312 + {
313 + $text = '';
314 + $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-acceptance-field');
315 + $this->add_render_attribute('input' . $item_index, 'type', 'checkbox', true);
471 316
472 - if ( ! empty( $item['checked_by_default'] ) ) {
473 - $this->add_render_attribute( 'input' . $item_index, 'checked', 'checked' );
474 - }
317 + if (! empty($item['acceptance_text'])) {
318 + $text = '<label for="' . $this->get_attribute_id($item) . '">' . $item['acceptance_text'] . '</label>';
319 + }
475 320
476 - ?>
477 - <div class="ui-e-field-subgroup <?php echo esc_attr( $item['css_classes'] );?>">
478 - <input <?php $this->print_render_attribute_string( 'input' . $item_index ); ?>>
479 - <?php // PHPCS - the variables $text is safe.
480 - echo $text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
481 - </div>
482 - <?php
483 - }
484 - function form_fields_render_attributes( $i, $instance, $item ) {
485 - $this->add_render_attribute(
486 - [
487 - 'field-group' . $i => [
488 - 'class' => [
489 - 'ui-e-field-type-' . $item['field_type'],
490 - 'ui-e-field-group',
491 - 'elementor-column',
492 - 'ui-e-field-group-' . $item['custom_id'],
493 - ],
494 - ],
495 - 'input' . $i => [
496 - 'type' => $item['field_type'],
497 - 'name' => $this->get_attribute_name( $item ),
498 - 'id' => $this->get_attribute_id( $item ),
499 - 'class' => [
500 - 'ui-e-field',
501 - empty( $item['css_classes'] ) ? '' : esc_attr( $item['css_classes'] ),
502 - ],
503 - ],
504 - 'label' . $i => [
505 - 'for' => $this->get_attribute_id( $item ),
506 - 'class' => 'ui-e-label',
507 - ],
508 - ]
509 - );
321 + if (! empty($item['checked_by_default'])) {
322 + $this->add_render_attribute('input' . $item_index, 'checked', 'checked');
323 + }
510 324
511 - if ( empty( $item['width'] ) ) {
512 - $item['width'] = '100';
513 - }
325 + ?>
326 + <div class="ui-e-field-subgroup <?php echo esc_attr($item['css_classes']); ?>">
327 + <input <?php $this->print_render_attribute_string('input' . $item_index); ?>>
328 + <?php // PHPCS - the variables $text is safe.
329 + echo $text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
330 + ?>
331 + </div>
332 + <?php
333 + }
334 + function form_fields_render_attributes($i, $instance, $item)
335 + {
336 + $this->add_render_attribute(
337 + [
338 + 'field-group' . $i => [
339 + 'class' => [
340 + 'ui-e-field-type-' . $item['field_type'],
341 + 'ui-e-field-group',
342 + 'elementor-column',
343 + 'ui-e-field-group-' . $item['custom_id'],
344 + ],
345 + ],
346 + 'input' . $i => [
347 + 'type' => $item['field_type'],
348 + 'name' => $this->get_attribute_name($item),
349 + 'id' => $this->get_attribute_id($item),
350 + 'class' => [
351 + 'ui-e-field',
352 + empty($item['css_classes']) ? '' : esc_attr($item['css_classes']),
353 + ],
354 + ],
355 + 'label' . $i => [
356 + 'for' => $this->get_attribute_id($item),
357 + 'class' => 'ui-e-label',
358 + ],
359 + ]
360 + );
514 361
515 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-col-' . $item['width'] );
362 + if (empty($item['width'])) {
363 + $item['width'] = '100';
364 + }
516 365
517 - if ( ! empty( $item['width_tablet'] ) ) {
518 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-md-' . $item['width_tablet'] );
519 - }
366 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-col-' . $item['width']);
520 367
521 - if ( $item['allow_multiple'] ) {
522 - $this->add_render_attribute( 'field-group' . $i, 'class', 'ui-e-field-type-' . $item['field_type'] . '-multiple' );
523 - }
368 + if (! empty($item['width_tablet'])) {
369 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-md-' . $item['width_tablet']);
370 + }
524 371
525 - if ( ! empty( $item['width_mobile'] ) ) {
526 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-sm-' . $item['width_mobile'] );
527 - }
372 + if ($item['allow_multiple']) {
373 + $this->add_render_attribute('field-group' . $i, 'class', 'ui-e-field-type-' . $item['field_type'] . '-multiple');
374 + }
528 375
529 - // Allow zero as placeholder.
530 - if ( ! Utils::is_empty( $item['placeholder'] ) ) {
531 - $this->add_render_attribute( 'input' . $i, 'placeholder', $item['placeholder'] );
532 - }
376 + if (! empty($item['width_mobile'])) {
377 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-sm-' . $item['width_mobile']);
378 + }
533 379
534 - if ( ! empty( $item['field_value'] ) ) {
535 - $this->add_render_attribute( 'input' . $i, 'value', $item['field_value'] );
536 - }
380 + // Allow zero as placeholder.
381 + if (! Utils::is_empty($item['placeholder'])) {
382 + $this->add_render_attribute('input' . $i, 'placeholder', $item['placeholder']);
383 + }
537 384
538 - if ( ! $instance['show_labels'] ) {
539 - $this->add_render_attribute( 'label' . $i, 'class', 'elementor-screen-only' );
540 - }
385 + if (! empty($item['field_value'])) {
386 + $this->add_render_attribute('input' . $i, 'value', $item['field_value']);
387 + }
541 388
542 - if ( ! empty( $item['required'] ) ) {
543 - $class = '';
544 - if ( ! empty( $instance['mark_required'] ) ) {
545 - $class .= ' ui-e-required';
546 - }
547 - $this->add_render_attribute( 'field-group' . $i, 'class', $class );
548 - $this->add_required_attribute( 'input' . $i );
549 - }
550 - }
389 + if (! $instance['show_labels']) {
390 + $this->add_render_attribute('label' . $i, 'class', 'elementor-screen-only');
391 + }
551 392
552 - protected function register_controls() {
393 + if (! empty($item['required'])) {
394 + $class = '';
395 + if (! empty($instance['mark_required'])) {
396 + $class .= ' ui-e-required';
397 + }
398 + $this->add_render_attribute('field-group' . $i, 'class', $class);
399 + $this->add_required_attribute('input' . $i);
400 + }
401 + }
553 402
403 + protected function register_controls()
404 + {
405 +
554 406 // Content Controls
555 407 // Repeater Controls used by `form_fields` control
556 408 $repeater = new Repeater();
557 - $repeater->start_controls_tabs( 'form_fields_tabs' );
409 + $repeater->start_controls_tabs('form_fields_tabs');
558 410
559 - $repeater->start_controls_tab(
560 - 'form_fields_content_tab',
561 - [
562 - 'label' => esc_html__( 'Content', 'uicore-elements' ),
563 - ]
564 - );
411 + $repeater->start_controls_tab(
412 + 'form_fields_content_tab',
413 + [
414 + 'label' => esc_html__('Content', 'uicore-elements'),
415 + ]
416 + );
565 417
566 - $repeater->add_control(
567 - 'field_type',
568 - [
569 - 'label' => esc_html__( 'Type', 'uicore-elements' ),
570 - 'type' => Controls_Manager::SELECT,
571 - 'options' => $this->get_field_types(),
572 - 'default' => 'text',
573 - ]
574 - );
575 - $repeater->add_control(
576 - 'field_label',
577 - [
578 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
579 - 'type' => Controls_Manager::TEXT,
580 - 'default' => '',
581 - 'dynamic' => [
582 - 'active' => true,
583 - ],
584 - ]
585 - );
586 - $repeater->add_control(
587 - 'placeholder',
588 - [
589 - 'label' => esc_html__( 'Placeholder', 'uicore-elements' ),
590 - 'type' => Controls_Manager::TEXT,
591 - 'default' => '',
592 - 'conditions' => [
593 - 'terms' => [
594 - [
595 - 'name' => 'field_type',
596 - 'operator' => 'in',
597 - 'value' => [
598 - 'tel',
599 - 'text',
600 - 'email',
601 - 'textarea',
602 - 'number',
603 - 'url',
604 - 'password',
605 - ],
606 - ],
418 + $repeater->add_control(
419 + 'field_type',
420 + [
421 + 'label' => esc_html__('Type', 'uicore-elements'),
422 + 'type' => Controls_Manager::SELECT,
423 + 'options' => $this->get_field_types(),
424 + 'default' => 'text',
425 + ]
426 + );
427 + $repeater->add_control(
428 + 'field_label',
429 + [
430 + 'label' => esc_html__('Label', 'uicore-elements'),
431 + 'type' => Controls_Manager::TEXT,
432 + 'default' => '',
433 + 'dynamic' => [
434 + 'active' => true,
435 + ],
436 + ]
437 + );
438 + $repeater->add_control(
439 + 'placeholder',
440 + [
441 + 'label' => esc_html__('Placeholder', 'uicore-elements'),
442 + 'type' => Controls_Manager::TEXT,
443 + 'default' => '',
444 + 'conditions' => [
445 + 'terms' => [
446 + [
447 + 'name' => 'field_type',
448 + 'operator' => 'in',
449 + 'value' => [
450 + 'tel',
451 + 'text',
452 + 'email',
453 + 'textarea',
454 + 'number',
455 + 'url',
456 + 'password',
607 457 ],
608 458 ],
609 - 'dynamic' => [
610 - 'active' => true,
611 - ],
612 - ]
613 - );
614 - $repeater->add_control(
615 - 'required',
616 - [
617 - 'label' => esc_html__( 'Required', 'uicore-elements' ),
618 - 'type' => Controls_Manager::SWITCHER,
619 - 'return_value' => 'true',
620 - 'default' => '',
621 - 'conditions' => [
622 - 'terms' => [
623 - [
624 - 'name' => 'field_type',
625 - 'operator' => '!in',
626 - 'value' => [
627 - 'checkbox',
628 - 'recaptcha',
629 - 'recaptcha_v3',
630 - 'hidden',
631 - 'html',
632 - ],
633 - ],
459 + ],
460 + ],
461 + 'dynamic' => [
462 + 'active' => true,
463 + ],
464 + ]
465 + );
466 + $repeater->add_control(
467 + 'required',
468 + [
469 + 'label' => esc_html__('Required', 'uicore-elements'),
470 + 'type' => Controls_Manager::SWITCHER,
471 + 'return_value' => 'true',
472 + 'default' => '',
473 + 'conditions' => [
474 + 'terms' => [
475 + [
476 + 'name' => 'field_type',
477 + 'operator' => '!in',
478 + 'value' => [
479 + 'recaptcha',
480 + 'recaptcha_v3',
481 + 'hidden',
482 + 'html',
634 483 ],
635 484 ],
636 - ]
637 - );
638 - $repeater->add_control(
639 - 'field_options',
640 - [
641 - 'label' => esc_html__( 'Options', 'uicore-elements' ),
642 - 'type' => Controls_Manager::TEXTAREA,
643 - 'default' => '',
644 - 'description' => esc_html__( 'Enter each option in a separate line. To differentiate between label and value, separate them with a pipe char ("|"). For example: First Name|f_name', 'uicore-elements' ),
645 - 'conditions' => [
646 - 'terms' => [
647 - [
648 - 'name' => 'field_type',
649 - 'operator' => 'in',
650 - 'value' => [
651 - 'select',
652 - 'checkbox',
653 - 'radio',
654 - ],
655 - ],
485 + ],
486 + ],
487 + ]
488 + );
489 + $repeater->add_control(
490 + 'field_options',
491 + [
492 + 'label' => esc_html__('Options', 'uicore-elements'),
493 + 'type' => Controls_Manager::TEXTAREA,
494 + 'default' => '',
495 + 'description' => esc_html__('Enter each option in a separate line. To differentiate between label and value, separate them with a pipe char ("|"). For example: First Name|f_name', 'uicore-elements'),
496 + 'conditions' => [
497 + 'terms' => [
498 + [
499 + 'name' => 'field_type',
500 + 'operator' => 'in',
501 + 'value' => [
502 + 'select',
503 + 'checkbox',
504 + 'radio',
656 505 ],
657 506 ],
658 - ]
659 - );
660 - $repeater->add_control(
661 - 'allow_multiple',
662 - [
663 - 'label' => esc_html__( 'Multiple Selection', 'uicore-elements' ),
664 - 'type' => Controls_Manager::SWITCHER,
665 - 'return_value' => 'true',
666 - 'conditions' => [
667 - 'terms' => [
668 - [
669 - 'name' => 'field_type',
670 - 'value' => 'select',
671 - ],
672 - ],
507 + ],
508 + ],
509 + ]
510 + );
511 + $repeater->add_control(
512 + 'allow_multiple',
513 + [
514 + 'label' => esc_html__('Multiple Selection', 'uicore-elements'),
515 + 'type' => Controls_Manager::SWITCHER,
516 + 'return_value' => 'true',
517 + 'conditions' => [
518 + 'terms' => [
519 + [
520 + 'name' => 'field_type',
521 + 'value' => 'select',
673 522 ],
674 - ]
675 - );
676 - $repeater->add_control(
677 - 'select_size',
678 - [
679 - 'label' => esc_html__( 'Rows', 'uicore-elements' ),
680 - 'type' => Controls_Manager::NUMBER,
681 - 'min' => 2,
682 - 'step' => 1,
683 - 'conditions' => [
684 - 'terms' => [
685 - [
686 - 'name' => 'field_type',
687 - 'value' => 'select',
688 - ],
689 - [
690 - 'name' => 'allow_multiple',
691 - 'value' => 'true',
692 - ],
693 - ],
523 + ],
524 + ],
525 + ]
526 + );
527 + $repeater->add_control(
528 + 'select_size',
529 + [
530 + 'label' => esc_html__('Rows', 'uicore-elements'),
531 + 'type' => Controls_Manager::NUMBER,
532 + 'min' => 2,
533 + 'step' => 1,
534 + 'conditions' => [
535 + 'terms' => [
536 + [
537 + 'name' => 'field_type',
538 + 'value' => 'select',
694 539 ],
695 - ]
696 - );
697 - $repeater->add_control(
698 - 'inline_list',
699 - [
700 - 'label' => esc_html__( 'Inline List', 'uicore-elements' ),
701 - 'type' => Controls_Manager::SWITCHER,
702 - 'return_value' => 'ui-e-subgroup-inline',
703 - 'default' => '',
704 - 'conditions' => [
705 - 'terms' => [
706 - [
707 - 'name' => 'field_type',
708 - 'operator' => 'in',
709 - 'value' => [
710 - 'checkbox',
711 - 'radio',
712 - ],
713 - ],
714 - ],
540 + [
541 + 'name' => 'allow_multiple',
542 + 'value' => 'true',
715 543 ],
716 - ]
717 - );
718 - $repeater->add_control(
719 - 'field_html',
720 - [
721 - 'label' => esc_html__( 'HTML', 'uicore-elements' ),
722 - 'type' => Controls_Manager::TEXTAREA,
723 - 'dynamic' => [
724 - 'active' => true,
725 - ],
726 - 'conditions' => [
727 - 'terms' => [
728 - [
729 - 'name' => 'field_type',
730 - 'value' => 'html',
731 - ],
544 + ],
545 + ],
546 + ]
547 + );
548 + $repeater->add_control(
549 + 'inline_list',
550 + [
551 + 'label' => esc_html__('Inline List', 'uicore-elements'),
552 + 'type' => Controls_Manager::SWITCHER,
553 + 'return_value' => 'ui-e-subgroup-inline',
554 + 'default' => '',
555 + 'conditions' => [
556 + 'terms' => [
557 + [
558 + 'name' => 'field_type',
559 + 'operator' => 'in',
560 + 'value' => [
561 + 'checkbox',
562 + 'radio',
732 563 ],
733 564 ],
734 - ]
735 - );
736 - $repeater->add_control(
737 - 'acceptance_text',
738 - [
739 - 'label' => esc_html__( 'Acceptance Text', 'uicore-elements' ),
740 - 'type' => Controls_Manager::TEXTAREA,
741 - 'condition' => [
742 - 'field_type' => 'acceptance',
743 - ],
744 - ],
745 - );
746 - $repeater->add_control(
747 - 'checked_by_default',
748 - [
749 - 'label' => esc_html__( 'Checked by Default', 'uicore-elements' ),
750 - 'type' => Controls_Manager::SWITCHER,
751 - 'condition' => [
752 - 'field_type' => 'acceptance',
753 - ],
754 - ],
755 - );
756 - $repeater->add_responsive_control(
757 - 'width',
758 - [
759 - 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
760 - 'type' => Controls_Manager::SELECT,
761 - 'options' => [
762 - '' => esc_html__( 'Default', 'uicore-elements' ),
763 - '100' => '100%',
764 - '80' => '80%',
765 - '75' => '75%',
766 - '70' => '70%',
767 - '66' => '66%',
768 - '60' => '60%',
769 - '50' => '50%',
770 - '40' => '40%',
771 - '33' => '33%',
772 - '30' => '30%',
773 - '25' => '25%',
774 - '20' => '20%',
565 + ],
566 + ],
567 + ]
568 + );
569 + $repeater->add_control(
570 + 'field_html',
571 + [
572 + 'label' => esc_html__('HTML', 'uicore-elements'),
573 + 'type' => Controls_Manager::TEXTAREA,
574 + 'dynamic' => [
575 + 'active' => true,
576 + ],
577 + 'conditions' => [
578 + 'terms' => [
579 + [
580 + 'name' => 'field_type',
581 + 'value' => 'html',
775 582 ],
776 - 'default' => '100',
777 - 'conditions' => [
778 - 'terms' => [
779 - [
780 - 'name' => 'field_type',
781 - 'operator' => '!in',
782 - 'value' => [
783 - 'hidden',
784 - 'recaptcha',
785 - 'recaptcha_v3'
786 - ],
787 - ],
583 + ],
584 + ],
585 + ]
586 + );
587 + $repeater->add_control(
588 + 'acceptance_text',
589 + [
590 + 'label' => esc_html__('Acceptance Text', 'uicore-elements'),
591 + 'type' => Controls_Manager::TEXTAREA,
592 + 'condition' => [
593 + 'field_type' => 'acceptance',
594 + ],
595 + ],
596 + );
597 + $repeater->add_control(
598 + 'checked_by_default',
599 + [
600 + 'label' => esc_html__('Checked by Default', 'uicore-elements'),
601 + 'type' => Controls_Manager::SWITCHER,
602 + 'condition' => [
603 + 'field_type' => 'acceptance',
604 + ],
605 + ],
606 + );
607 + $repeater->add_responsive_control(
608 + 'width',
609 + [
610 + 'label' => esc_html__('Column Width', 'uicore-elements'),
611 + 'type' => Controls_Manager::SELECT,
612 + 'options' => [
613 + '' => esc_html__('Default', 'uicore-elements'),
614 + '100' => '100%',
615 + '80' => '80%',
616 + '75' => '75%',
617 + '70' => '70%',
618 + '66' => '66%',
619 + '60' => '60%',
620 + '50' => '50%',
621 + '40' => '40%',
622 + '33' => '33%',
623 + '30' => '30%',
624 + '25' => '25%',
625 + '20' => '20%',
626 + ],
627 + 'default' => '100',
628 + 'conditions' => [
629 + 'terms' => [
630 + [
631 + 'name' => 'field_type',
632 + 'operator' => '!in',
633 + 'value' => [
634 + 'hidden',
635 + 'recaptcha',
636 + 'recaptcha_v3'
788 637 ],
789 638 ],
790 - ]
791 - );
792 - $repeater->add_control(
793 - 'rows',
794 - [
795 - 'label' => esc_html__( 'Rows', 'uicore-elements' ),
796 - 'type' => Controls_Manager::NUMBER,
797 - 'default' => 4,
798 - 'conditions' => [
799 - 'terms' => [
800 - [
801 - 'name' => 'field_type',
802 - 'value' => 'textarea',
803 - ],
804 - ],
639 + ],
640 + ],
641 + ]
642 + );
643 + $repeater->add_control(
644 + 'rows',
645 + [
646 + 'label' => esc_html__('Rows', 'uicore-elements'),
647 + 'type' => Controls_Manager::NUMBER,
648 + 'default' => 4,
649 + 'conditions' => [
650 + 'terms' => [
651 + [
652 + 'name' => 'field_type',
653 + 'value' => 'textarea',
805 654 ],
806 - ]
807 - );
808 - $repeater->add_control(
809 - 'recaptcha_hide',
810 - [
811 - 'label' => esc_html__( 'Badge', 'uicore-elements' ),
812 - 'type' => Controls_Manager::SELECT,
813 - 'default' => 'hidden',
814 - 'options' => [
815 - 'hidden' => esc_html__( 'Hidden', 'uicore-elements' ),
816 - 'visible' => esc_html__( 'Visible', 'uicore-elements' )
817 - ],
818 - 'condition' => [
819 - 'field_type' => 'recaptcha_v3',
820 - ],
821 - 'selectors' => [
822 - '.grecaptcha-badge' => 'visibility: {{VALUE}};',
823 - ],
824 - ]
825 - );
826 - $recaptcha_keys = (!get_option('uicore_elements_recaptcha_secret_key') && !get_option('uicore_elements_recaptcha_site_key')) ? true : false; // Check if recaptcha API keys were set
827 - $repeater->add_control(
828 - 'recaptcha_warning',
829 - [
830 - 'type' => Controls_Manager::ALERT,
831 - 'alert_type' => 'warning',
832 - 'dismissible' => false,
833 - 'heading' => esc_html__("You haven't set your reCAPTCHA API keys yet.", 'uicore-elements'),
834 - 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements' )),
835 - 'condition' => [
836 - 'field_type' => $recaptcha_keys ? ['recaptcha', 'recaptcha_v3'] : [],
837 - ]
838 - ]
839 - );
655 + ],
656 + ],
657 + ]
658 + );
659 + $repeater->add_control(
660 + 'recaptcha_hide',
661 + [
662 + 'label' => esc_html__('Badge', 'uicore-elements'),
663 + 'type' => Controls_Manager::SELECT,
664 + 'default' => 'hidden',
665 + 'options' => [
666 + 'hidden' => esc_html__('Hidden', 'uicore-elements'),
667 + 'visible' => esc_html__('Visible', 'uicore-elements')
668 + ],
669 + 'condition' => [
670 + 'field_type' => 'recaptcha_v3',
671 + ],
672 + 'selectors' => [
673 + '.grecaptcha-badge' => 'visibility: {{VALUE}};',
674 + ],
675 + ]
676 + );
677 + $recaptcha_keys = (!get_option('uicore_elements_recaptcha_secret_key') && !get_option('uicore_elements_recaptcha_site_key')) ? true : false; // Check if recaptcha API keys were set
678 + $repeater->add_control(
679 + 'recaptcha_warning',
680 + [
681 + 'type' => Controls_Manager::ALERT,
682 + 'alert_type' => 'warning',
683 + 'dismissible' => false,
684 + 'heading' => esc_html__("You haven't set your reCAPTCHA API keys yet.", 'uicore-elements'),
685 + 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements')),
686 + 'condition' => [
687 + 'field_type' => $recaptcha_keys ? ['recaptcha', 'recaptcha_v3'] : [],
688 + ]
689 + ]
690 + );
840 691
841 - $repeater->end_controls_tab();
692 + $repeater->end_controls_tab();
842 693
843 - $repeater->start_controls_tab(
844 - 'form_fields_advanced_tab',
845 - [
846 - 'label' => esc_html__( 'Advanced', 'uicore-elements' ),
847 - 'condition' => [
848 - 'field_type!' => ['html', 'address' ],
849 - ],
850 - ]
851 - );
694 + $repeater->start_controls_tab(
695 + 'form_fields_advanced_tab',
696 + [
697 + 'label' => esc_html__('Advanced', 'uicore-elements'),
698 + 'condition' => [
699 + 'field_type!' => ['html', 'address'],
700 + ],
701 + ]
702 + );
852 703
853 - $repeater->add_control(
854 - 'field_value',
855 - [
856 - 'label' => esc_html__( 'Default Value', 'uicore-elements' ),
857 - 'type' => Controls_Manager::TEXT,
858 - 'default' => '',
859 - 'dynamic' => [
860 - 'active' => true,
861 - ],
862 - 'ai' => [
863 - 'active' => false,
864 - ],
865 - 'conditions' => [
866 - 'terms' => [
867 - [
868 - 'name' => 'field_type',
869 - 'operator' => 'in',
870 - 'value' => [
871 - 'text',
872 - 'email',
873 - 'textarea',
874 - 'url',
875 - 'tel',
876 - 'radio',
877 - 'select',
878 - 'number',
879 - 'date',
880 - 'time',
881 - 'hidden',
882 - ],
883 - ],
704 + $repeater->add_control(
705 + 'field_value',
706 + [
707 + 'label' => esc_html__('Default Value', 'uicore-elements'),
708 + 'type' => Controls_Manager::TEXT,
709 + 'default' => '',
710 + 'dynamic' => [
711 + 'active' => true,
712 + ],
713 + 'ai' => [
714 + 'active' => false,
715 + ],
716 + 'conditions' => [
717 + 'terms' => [
718 + [
719 + 'name' => 'field_type',
720 + 'operator' => 'in',
721 + 'value' => [
722 + 'text',
723 + 'email',
724 + 'textarea',
725 + 'url',
726 + 'tel',
727 + 'radio',
728 + 'select',
729 + 'number',
730 + 'date',
731 + 'time',
732 + 'hidden',
884 733 ],
885 734 ],
886 - ]
887 - );
888 - $repeater->add_control(
889 - 'custom_id',
890 - [
891 - 'label' => esc_html__( 'ID', 'uicore-elements' ),
892 - 'type' => Controls_Manager::TEXT,
893 - 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere in this form. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ),
894 - 'render_type' => 'none',
895 - 'required' => true,
896 - 'dynamic' => [
897 - 'active' => true,
898 - ],
899 - 'ai' => [
900 - 'active' => false,
901 - ],
902 - ]
903 - );
904 - $repeater->add_control(
905 - 'css_classes',
906 - [
907 - 'label' => esc_html__( 'Custom Class', 'uicore-elements' ),
908 - 'type' => Controls_Manager::TEXT,
909 - 'default' => '',
910 - 'ai' => [
911 - 'active' => false,
912 - ],
913 - 'placeholder' => esc_html__( 'e.g: my-class', 'uicore-elements' ),
914 - ]
915 - );
916 - $shortcode_template = '{{ view.container.settings.get( \'custom_id\' ) }}';
917 - $repeater->add_control(
918 - 'shortcode',
919 - [
920 - 'label' => esc_html__( 'Shortcode', 'uicore-elements' ),
921 - 'type' => Controls_Manager::RAW_HTML,
922 - 'classes' => 'forms-field-shortcode',
923 - 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="' . $shortcode_template . '"]\' readonly />',
924 - 'label_block' => false,
925 - ]
926 - );
735 + ],
736 + ],
737 + ]
738 + );
739 + $repeater->add_control(
740 + 'custom_id',
741 + [
742 + 'label' => esc_html__('ID', 'uicore-elements'),
743 + 'type' => Controls_Manager::TEXT,
744 + 'description' => esc_html__('Please make sure the ID is unique and not used elsewhere in this form. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements'),
745 + 'render_type' => 'none',
746 + 'required' => true,
747 + 'dynamic' => [
748 + 'active' => true,
749 + ],
750 + 'ai' => [
751 + 'active' => false,
752 + ],
753 + ]
754 + );
755 + $repeater->add_control(
756 + 'css_classes',
757 + [
758 + 'label' => esc_html__('Custom Class', 'uicore-elements'),
759 + 'type' => Controls_Manager::TEXT,
760 + 'default' => '',
761 + 'ai' => [
762 + 'active' => false,
763 + ],
764 + 'placeholder' => esc_html__('e.g: my-class', 'uicore-elements'),
765 + ]
766 + );
767 + $shortcode_template = '{{ view.container.settings.get( \'custom_id\' ) }}';
768 + $repeater->add_control(
769 + 'shortcode',
770 + [
771 + 'label' => esc_html__('Shortcode', 'uicore-elements'),
772 + 'type' => Controls_Manager::RAW_HTML,
773 + 'classes' => 'forms-field-shortcode',
774 + 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="' . $shortcode_template . '"]\' readonly />',
775 + 'label_block' => false,
776 + ]
777 + );
927 778
928 - $repeater->end_controls_tab();
779 + $repeater->end_controls_tab();
929 780
930 781 $repeater->end_controls_tabs();
931 782
932 783 $this->start_controls_section(
@@ -931,267 +782,243 @@
931 782
932 783 $this->start_controls_section(
933 784 'section_form_fields',
934 785 [
935 - 'label' => esc_html__( 'Form Fields', 'uicore-elements' ),
786 + 'label' => esc_html__('Form Fields', 'uicore-elements'),
936 787 ]
937 788 );
938 789
939 790
940 - $this->add_control(
941 - 'form_name',
942 - [
943 - 'label' => esc_html__( 'Form Name', 'uicore-elements' ),
944 - 'type' => Controls_Manager::TEXT,
945 - 'default' => esc_html__( 'New Form', 'uicore-elements' ),
946 - 'placeholder' => esc_html__( 'Form Name', 'uicore-elements' ),
947 - ]
948 - );
949 - $this->add_control(
950 - 'form_fields',
951 - [
952 - 'type' => Controls_Manager::REPEATER,
953 - 'fields' => $repeater->get_controls(),
954 - 'default' => [
955 - [
956 - 'custom_id' => 'name',
957 - 'field_type' => 'text',
958 - 'field_label' => esc_html__( 'Name', 'uicore-elements' ),
959 - 'placeholder' => esc_html__( 'Name', 'uicore-elements' ),
960 - 'width' => '100',
961 - 'dynamic' => [
962 - 'active' => true,
963 - ],
791 + $this->add_control(
792 + 'form_name',
793 + [
794 + 'label' => esc_html__('Form Name', 'uicore-elements'),
795 + 'type' => Controls_Manager::TEXT,
796 + 'default' => esc_html__('New Form', 'uicore-elements'),
797 + 'placeholder' => esc_html__('Form Name', 'uicore-elements'),
798 + ]
799 + );
800 + $this->add_control(
801 + 'form_fields',
802 + [
803 + 'type' => Controls_Manager::REPEATER,
804 + 'fields' => $repeater->get_controls(),
805 + 'default' => [
806 + [
807 + 'custom_id' => 'name',
808 + 'field_type' => 'text',
809 + 'field_label' => esc_html__('Name', 'uicore-elements'),
810 + 'placeholder' => esc_html__('Name', 'uicore-elements'),
811 + 'width' => '100',
812 + 'dynamic' => [
813 + 'active' => true,
964 814 ],
965 - [
966 - 'custom_id' => 'email',
967 - 'field_type' => 'email',
968 - 'required' => 'true',
969 - 'field_label' => esc_html__( 'Email', 'uicore-elements' ),
970 - 'placeholder' => esc_html__( 'Email', 'uicore-elements' ),
971 - 'width' => '100',
972 - ],
973 - [
974 - 'custom_id' => 'address',
975 - 'field_type' => 'address',
976 - 'field_label' => esc_html__( 'address (honeypot)', 'uicore-elements' ),
977 - 'placeholder' => esc_html__( 'address', 'uicore-elements' ),
978 - 'width' => '100',
979 - ],
980 - [
981 - 'custom_id' => 'message',
982 - 'field_type' => 'textarea',
983 - 'field_label' => esc_html__( 'Message', 'uicore-elements' ),
984 - 'placeholder' => esc_html__( 'Message', 'uicore-elements' ),
985 - 'width' => '100',
986 - ],
987 815 ],
988 - 'title_field' => '{{{ field_label }}}',
989 - ]
990 - );
991 - $this->add_control(
992 - 'show_labels',
993 - [
994 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
995 - 'type' => Controls_Manager::SWITCHER,
996 - 'label_on' => esc_html__( 'Show', 'uicore-elements' ),
997 - 'label_off' => esc_html__( 'Hide', 'uicore-elements' ),
998 - 'return_value' => 'true',
999 - 'default' => 'true',
1000 - 'separator' => 'before',
1001 - ]
1002 - );
1003 - $this->add_control(
1004 - 'mark_required',
1005 - [
1006 - 'label' => esc_html__( 'Required Mark', 'uicore-elements' ),
1007 - 'type' => Controls_Manager::SWITCHER,
1008 - 'label_on' => esc_html__( 'Show', 'uicore-elements' ),
1009 - 'label_off' => esc_html__( 'Hide', 'uicore-elements' ),
1010 - 'default' => '',
1011 - 'render_type' => 'template',
1012 - 'condition' => [
1013 - 'show_labels!' => '',
816 + [
817 + 'custom_id' => 'email',
818 + 'field_type' => 'email',
819 + 'required' => 'true',
820 + 'field_label' => esc_html__('Email', 'uicore-elements'),
821 + 'placeholder' => esc_html__('Email', 'uicore-elements'),
822 + 'width' => '100',
1014 823 ],
1015 - ]
1016 - );
824 + [
825 + 'custom_id' => 'address',
826 + 'field_type' => 'address',
827 + 'field_label' => esc_html__('address (honeypot)', 'uicore-elements'),
828 + 'placeholder' => esc_html__('address', 'uicore-elements'),
829 + 'width' => '100',
830 + ],
831 + [
832 + 'custom_id' => 'message',
833 + 'field_type' => 'textarea',
834 + 'field_label' => esc_html__('Message', 'uicore-elements'),
835 + 'placeholder' => esc_html__('Message', 'uicore-elements'),
836 + 'width' => '100',
837 + ],
838 + ],
839 + 'title_field' => '{{{ field_label }}}',
840 + ]
841 + );
842 + $this->add_control(
843 + 'show_labels',
844 + [
845 + 'label' => esc_html__('Label', 'uicore-elements'),
846 + 'type' => Controls_Manager::SWITCHER,
847 + 'label_on' => esc_html__('Show', 'uicore-elements'),
848 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
849 + 'return_value' => 'true',
850 + 'default' => 'true',
851 + 'separator' => 'before',
852 + ]
853 + );
854 + $this->add_control(
855 + 'mark_required',
856 + [
857 + 'label' => esc_html__('Required Mark', 'uicore-elements'),
858 + 'type' => Controls_Manager::SWITCHER,
859 + 'label_on' => esc_html__('Show', 'uicore-elements'),
860 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
861 + 'default' => '',
862 + 'render_type' => 'template',
863 + 'condition' => [
864 + 'show_labels!' => '',
865 + ],
866 + ]
867 + );
1017 868
1018 869 $this->end_controls_section();
1019 870
1020 - $this->start_controls_section(
871 + $this->start_controls_section(
1021 872 'section_buttons',
1022 873 [
1023 - 'label' => esc_html__( 'Button', 'uicore-elements' ),
874 + 'label' => esc_html__('Button', 'uicore-elements'),
1024 875 ]
1025 876 );
1026 877
1027 - $this->add_responsive_control(
1028 - 'button_width',
1029 - [
1030 - 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
1031 - 'type' => Controls_Manager::SELECT,
1032 - 'options' => [
1033 - '' => esc_html__( 'Default', 'uicore-elements' ),
1034 - '100' => '100%',
1035 - '80' => '80%',
1036 - '75' => '75%',
1037 - '70' => '70%',
1038 - '66' => '66%',
1039 - '60' => '60%',
1040 - '50' => '50%',
1041 - '40' => '40%',
1042 - '33' => '33%',
1043 - '30' => '30%',
1044 - '25' => '25%',
1045 - '20' => '20%',
878 + $this->add_responsive_control(
879 + 'button_width',
880 + [
881 + 'label' => esc_html__('Column Width', 'uicore-elements'),
882 + 'type' => Controls_Manager::SELECT,
883 + 'options' => [
884 + '' => esc_html__('Default', 'uicore-elements'),
885 + '100' => '100%',
886 + '80' => '80%',
887 + '75' => '75%',
888 + '70' => '70%',
889 + '66' => '66%',
890 + '60' => '60%',
891 + '50' => '50%',
892 + '40' => '40%',
893 + '33' => '33%',
894 + '30' => '30%',
895 + '25' => '25%',
896 + '20' => '20%',
897 + ],
898 + 'default' => '100',
899 + ]
900 + );
901 + $this->add_responsive_control(
902 + 'button_align',
903 + [
904 + 'label' => esc_html__('Alignment', 'uicore-elements'),
905 + 'type' => Controls_Manager::CHOOSE,
906 + 'options' => [
907 + 'left' => [
908 + 'title' => esc_html__('Left', 'uicore-elements'),
909 + 'icon' => 'eicon-text-align-left',
1046 910 ],
1047 - 'default' => '100',
1048 - ]
1049 - );
1050 - $this->add_responsive_control(
1051 - 'button_align',
1052 - [
1053 - 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
1054 - 'type' => Controls_Manager::CHOOSE,
1055 - 'options' => [
1056 - 'left' => [
1057 - 'title' => esc_html__( 'Left', 'uicore-elements' ),
1058 - 'icon' => 'eicon-text-align-left',
1059 - ],
1060 - 'center' => [
1061 - 'title' => esc_html__( 'Center', 'uicore-elements' ),
1062 - 'icon' => 'eicon-text-align-center',
1063 - ],
1064 - 'right' => [
1065 - 'title' => esc_html__( 'Right', 'uicore-elements' ),
1066 - 'icon' => 'eicon-text-align-right',
1067 - ],
1068 - 'stretch' => [
1069 - 'title' => esc_html__( 'Justified', 'uicore-elements' ),
1070 - 'icon' => 'eicon-text-align-justify',
1071 - ],
911 + 'center' => [
912 + 'title' => esc_html__('Center', 'uicore-elements'),
913 + 'icon' => 'eicon-text-align-center',
1072 914 ],
1073 - 'default' => 'stretch',
1074 - 'prefix_class' => 'ui-e-submit-align-',
1075 - ]
1076 - );
1077 - $this->add_control(
1078 - 'button_text',
1079 - [
1080 - 'label' => esc_html__( 'Submit', 'uicore-elements' ),
1081 - 'type' => Controls_Manager::TEXT,
1082 - 'default' => esc_html__( 'Send', 'uicore-elements' ),
1083 - 'placeholder' => esc_html__( 'Send', 'uicore-elements' ),
1084 - 'dynamic' => [
1085 - 'active' => true,
915 + 'right' => [
916 + 'title' => esc_html__('Right', 'uicore-elements'),
917 + 'icon' => 'eicon-text-align-right',
1086 918 ],
1087 - 'ai' => [
1088 - 'active' => false,
919 + 'stretch' => [
920 + 'title' => esc_html__('Justified', 'uicore-elements'),
921 + 'icon' => 'eicon-text-align-justify',
1089 922 ],
1090 - ]
1091 - );
1092 - $this->add_control(
1093 - 'selected_button_icon',
1094 - [
1095 - 'label' => esc_html__( 'Icon', 'uicore-elements' ),
1096 - 'type' => Controls_Manager::ICONS,
1097 - 'skin' => 'inline',
1098 - 'label_block' => false,
1099 - ]
1100 - );
1101 - $this->add_control(
1102 - 'button_icon_align',
1103 - [
1104 - 'label' => esc_html__( 'Icon Position', 'uicore-elements' ),
1105 - 'type' => Controls_Manager::SELECT,
1106 - 'default' => 'left',
1107 - 'options' => [
1108 - 'left' => esc_html__( 'Before', 'uicore-elements' ),
1109 - 'right' => esc_html__( 'After', 'uicore-elements' ),
923 + ],
924 + 'default' => 'stretch',
925 + 'prefix_class' => 'ui-e-submit-align-%s-',
926 + ]
927 + );
928 + $this->add_control(
929 + 'button_text',
930 + [
931 + 'label' => esc_html__('Submit', 'uicore-elements'),
932 + 'type' => Controls_Manager::TEXT,
933 + 'default' => esc_html__('Send', 'uicore-elements'),
934 + 'placeholder' => esc_html__('Send', 'uicore-elements'),
935 + 'dynamic' => [
936 + 'active' => true,
937 + ],
938 + 'ai' => [
939 + 'active' => false,
940 + ],
941 + ]
942 + );
943 + $this->add_control(
944 + 'selected_button_icon',
945 + [
946 + 'label' => esc_html__('Icon', 'uicore-elements'),
947 + 'type' => Controls_Manager::ICONS,
948 + 'skin' => 'inline',
949 + 'label_block' => false,
950 + ]
951 + );
952 + $this->add_control(
953 + 'button_icon_align',
954 + [
955 + 'label' => esc_html__('Icon Position', 'uicore-elements'),
956 + 'type' => Controls_Manager::SELECT,
957 + 'default' => 'left',
958 + 'options' => [
959 + 'left' => esc_html__('Before', 'uicore-elements'),
960 + 'right' => esc_html__('After', 'uicore-elements'),
961 + ],
962 + 'condition' => [
963 + 'selected_button_icon[value]!' => '',
964 + ],
965 + ]
966 + );
967 + $this->add_control(
968 + 'button_icon_indent',
969 + [
970 + 'label' => esc_html__('Icon Spacing', 'uicore-elements'),
971 + 'type' => Controls_Manager::SLIDER,
972 + 'size_units' => ['px', 'em', 'rem', 'custom'],
973 + 'range' => [
974 + 'px' => [
975 + 'max' => 100,
1110 976 ],
1111 - 'condition' => [
1112 - 'selected_button_icon[value]!' => '',
977 + 'em' => [
978 + 'max' => 10,
1113 979 ],
1114 - ]
1115 - );
1116 - $this->add_control(
1117 - 'button_icon_indent',
1118 - [
1119 - 'label' => esc_html__( 'Icon Spacing', 'uicore-elements' ),
1120 - 'type' => Controls_Manager::SLIDER,
1121 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1122 - 'range' => [
1123 - 'px' => [
1124 - 'max' => 100,
1125 - ],
1126 - 'em' => [
1127 - 'max' => 10,
1128 - ],
1129 - 'rem' => [
1130 - 'max' => 10,
1131 - ],
980 + 'rem' => [
981 + 'max' => 10,
1132 982 ],
1133 - 'condition' => [
1134 - 'selected_button_icon[value]!' => '',
1135 - ],
1136 - 'selectors' => [
1137 - '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};',
1138 - '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};',
1139 - ],
1140 - ]
1141 - );
1142 - $this->add_control(
1143 - 'button_css_id',
1144 - [
1145 - 'label' => esc_html__( 'Button ID', 'uicore-elements' ),
1146 - 'type' => Controls_Manager::TEXT,
1147 - 'default' => '',
1148 - 'ai' => [
1149 - 'active' => false,
1150 - ],
1151 - 'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements' ),
1152 - 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ),
1153 - 'separator' => 'before',
1154 - 'dynamic' => [
1155 - 'active' => true,
1156 - ],
1157 - ]
1158 - );
1159 -
1160 -
1161 - $this->end_controls_section();
1162 -
1163 - $this->start_controls_section(
1164 - 'section_actions',
983 + ],
984 + 'condition' => [
985 + 'selected_button_icon[value]!' => '',
986 + ],
987 + 'selectors' => [
988 + '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};',
989 + '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};',
990 + ],
991 + ]
992 + );
993 + $this->add_control(
994 + 'button_css_id',
1165 995 [
1166 - 'label' => esc_html__( 'Actions After Submit', 'uicore-elements' ),
996 + 'label' => esc_html__('Button ID', 'uicore-elements'),
997 + 'type' => Controls_Manager::TEXT,
998 + 'default' => '',
999 + 'ai' => [
1000 + 'active' => false,
1001 + ],
1002 + 'title' => esc_html__('Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements'),
1003 + 'description' => esc_html__('Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements'),
1004 + 'separator' => 'before',
1005 + 'dynamic' => [
1006 + 'active' => true,
1007 + ],
1167 1008 ]
1168 1009 );
1169 1010
1170 - $this->add_control(
1171 - 'submit_actions',
1172 - [
1173 - 'label' => esc_html__( 'Submit Actions', 'uicore-elements' ),
1174 - 'type' => Controls_Manager::SELECT2,
1175 - 'label_block' => true,
1176 - 'multiple' => true,
1177 - 'options' => [
1178 - 'email' => esc_html__( 'Email', 'uicore-elements' ),
1179 - 'email_2' => esc_html__( 'Email 2', 'uicore-elements' ),
1180 - 'redirect' => esc_html__( 'Redirect', 'uicore-elements' ),
1181 - 'mailchimp' => esc_html__( 'MailChimp', 'uicore-elements' ),
1182 - ],
1183 - 'default' => [ 'email' ],
1184 - ]
1185 - );
1186 1011
1187 1012 $this->end_controls_section();
1188 1013
1014 + $this->TRAIT_register_submit_actions_controls(Contact_Form_Service::get_form_submit_options());
1015 +
1189 1016 // Submit sections
1190 1017 $this->start_controls_section(
1191 1018 'section_email',
1192 1019 [
1193 - 'label' => esc_html__( 'Email', 'uicore-elements' ),
1020 + 'label' => esc_html__('Email', 'uicore-elements'),
1194 1021 'condition' => [
1195 1022 'submit_actions' => 'email',
1196 1023 ],
1197 1024 ]
@@ -1196,9 +1023,9 @@
1196 1023 ],
1197 1024 ]
1198 1025 );
1199 1026
1200 - $this->register_submit_email_controls($this);
1027 + $this->TRAIT_register_submit_email_controls($this);
1201 1028
1202 1029 $this->end_controls_section();
1203 1030
1204 1031 $this->start_controls_section(
@@ -1203,9 +1030,9 @@
1203 1030
1204 1031 $this->start_controls_section(
1205 1032 'section_email_2',
1206 1033 [
1207 - 'label' => esc_html__( 'Email 2', 'uicore-elements' ),
1034 + 'label' => esc_html__('Email 2', 'uicore-elements'),
1208 1035 'condition' => [
1209 1036 'submit_actions' => 'email_2',
1210 1037 ],
1211 1038 ]
@@ -1210,969 +1037,291 @@
1210 1037 ],
1211 1038 ]
1212 1039 );
1213 1040
1214 - $this->register_submit_email_controls($this, '_2');
1041 + $this->TRAIT_register_submit_email_controls($this, '_2');
1215 1042
1216 1043 $this->end_controls_section();
1217 1044
1218 - $this->start_controls_section(
1219 - 'section_redirect',
1045 + $this->TRAIT_register_submit_redirect_controls();
1046 + $this->TRAIT_register_submit_popup_controls($this);
1047 + $this->TRAIT_register_submit_webhook_controls();
1048 + $this->TRAIT_register_submit_newsletter_services_controls(Newsletter_Services::get_services_list('keys'), true);
1049 + $default_messages = Contact_Form_Service::get_default_messages();
1050 + $this->TRAIT_register_additional_controls($default_messages);
1051 +
1052 + $this->TRAIT_register_all_form_style_controls();
1053 +
1054 + // Custom Fields additional Controls injection
1055 + $this->start_injection([
1056 + 'of' => 'redirect_message',
1057 + 'at' => 'before',
1058 + ]);
1059 + $this->add_control(
1060 + 'required_fields_message',
1220 1061 [
1221 - 'label' => esc_html__( 'Redirect', 'uicore-elements' ),
1222 - 'condition' => [
1223 - 'submit_actions' => 'redirect',
1062 + 'label' => esc_html__('Required Fields', 'uicore-elements'),
1063 + 'type' => Controls_Manager::TEXT,
1064 + 'default' => $default_messages['required'],
1065 + 'placeholder' => $default_messages['required'],
1066 + 'label_block' => true,
1067 + 'conditions' => [
1068 + 'terms' => [
1069 + [
1070 + 'name' => 'custom_messages',
1071 + 'operator' => '!=',
1072 + 'value' => '',
1073 + ],
1074 + ],
1224 1075 ],
1076 + 'render_type' => 'none',
1077 + 'dynamic' => [
1078 + 'active' => true,
1079 + ],
1225 1080 ]
1226 1081 );
1082 + $this->end_injection();
1227 1083
1228 - $this->add_control(
1229 - 'redirect_to',
1230 - [
1231 - 'label' => esc_html__( 'Redirect To', 'uicore-elements' ),
1232 - 'type' => Controls_Manager::TEXT,
1233 - 'placeholder' => esc_html__( 'https://your-link.com', 'uicore-elements' ),
1234 - 'ai' => [
1235 - 'active' => false,
1084 + // Specific Form style controls
1085 + $this->start_injection([
1086 + 'of' => 'form_styles_component_divider',
1087 + 'at' => 'after',
1088 + ]);
1089 +
1090 + $this->add_control(
1091 + 'heading_html',
1092 + [
1093 + 'label' => esc_html__('HTML Field', 'uicore-elements'),
1094 + 'type' => Controls_Manager::HEADING,
1095 + ]
1096 + );
1097 + $this->add_control(
1098 + 'html_spacing',
1099 + [
1100 + 'label' => esc_html__('Spacing', 'uicore-elements'),
1101 + 'type' => Controls_Manager::SLIDER,
1102 + 'size_units' => ['px', 'em', 'rem', 'custom'],
1103 + 'default' => [
1104 + 'size' => 0,
1105 + ],
1106 + 'range' => [
1107 + 'px' => [
1108 + 'max' => 60,
1236 1109 ],
1237 - 'dynamic' => [
1238 - 'active' => true,
1239 - 'categories' => [
1240 - 'url',
1241 - ],
1110 + 'em' => [
1111 + 'max' => 6,
1242 1112 ],
1243 - 'label_block' => true,
1244 - 'render_type' => 'none',
1245 - ]
1246 - );
1247 -
1248 - $this->end_controls_section();
1249 -
1250 - $this->start_controls_section(
1251 - 'mailchimp_redirect',
1113 + 'rem' => [
1114 + 'max' => 6,
1115 + ],
1116 + ],
1117 + 'selectors' => [
1118 + '{{WRAPPER}} .ui-e-field-type-html' => 'padding-bottom: {{SIZE}}{{UNIT}};',
1119 + ],
1120 + ]
1121 + );
1122 + $this->add_control(
1123 + 'html_color',
1252 1124 [
1253 - 'label' => esc_html__( 'Mailchimp', 'uicore-elements' ),
1254 - 'condition' => [
1255 - 'submit_actions' => 'mailchimp',
1125 + 'label' => esc_html__('Color', 'uicore-elements'),
1126 + 'type' => Controls_Manager::COLOR,
1127 + 'selectors' => [
1128 + '{{WRAPPER}} .ui-e-field-type-html' => 'color: {{VALUE}};',
1256 1129 ],
1257 1130 ]
1258 1131 );
1132 + $this->add_group_control(
1133 + Group_Control_Typography::get_type(),
1134 + [
1135 + 'name' => 'html_typography',
1136 + 'selector' => '{{WRAPPER}} .ui-e-field-type-html',
1137 + 'global' => [
1138 + 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1139 + ],
1140 + ]
1141 + );
1259 1142
1260 - $this->TRAIT_register_submit_mailchimp_controls($this, true);
1261 -
1262 - $this->end_controls_section();
1263 -
1264 - $default_messages = Contact_Form_Service::get_default_messages();
1265 - $this->start_controls_section(
1266 - 'section_form_options',
1143 + $this->add_control(
1144 + 'heading_file',
1267 1145 [
1268 - 'label' => esc_html__( 'Additional Options', 'uicore-elements' ),
1269 - 'tab' => Controls_Manager::TAB_CONTENT,
1146 + 'label' => esc_html__('Upload File Field', 'uicore-elements'),
1147 + 'type' => Controls_Manager::HEADING,
1148 + 'separator' => 'before',
1270 1149 ]
1271 1150 );
1151 + $this->add_control(
1152 + 'file_color',
1153 + [
1154 + 'label' => esc_html__('Color', 'uicore-elements'),
1155 + 'type' => Controls_Manager::COLOR,
1156 + 'selectors' => [
1157 + '{{WRAPPER}} .ui-e-field-type-file input.ui-e-field' => 'color: {{VALUE}};',
1158 + ],
1159 + 'default' => 'var(--e-global-color-uicore_body)',
1272 1160
1273 - $this->add_control(
1274 - 'form_id',
1275 - [
1276 - 'label' => esc_html__( 'Form ID', 'uicore-elements' ),
1277 - 'type' => Controls_Manager::TEXT,
1278 - 'ai' => [
1279 - 'active' => false,
1280 - ],
1281 - 'placeholder' => 'new_form_id',
1282 - 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ),
1283 - 'separator' => 'after',
1284 - 'dynamic' => [
1285 - 'active' => true,
1286 - ],
1287 - ]
1288 - );
1289 - $this->add_control(
1290 - 'form_validation',
1291 - [
1292 - 'label' => esc_html__( 'Form Validation', 'uicore-elements' ),
1293 - 'type' => Controls_Manager::SELECT,
1294 - 'options' => [
1295 - '' => esc_html__( 'Browser Default', 'uicore-elements' ),
1296 - 'no' => esc_html__( 'No validation', 'uicore-elements' ),
1297 - ],
1298 - 'default' => '',
1299 - ]
1300 - );
1301 - $this->add_control(
1302 - 'custom_messages',
1303 - [
1304 - 'label' => esc_html__( 'Custom Messages', 'uicore-elements' ),
1305 - 'type' => Controls_Manager::SWITCHER,
1306 - 'default' => '',
1307 - 'separator' => 'before',
1308 - 'render_type' => 'none',
1309 - ]
1310 - );
1311 - $this->add_control(
1312 - 'success_message',
1313 - [
1314 - 'label' => esc_html__( 'Success Message', 'uicore-elements' ),
1315 - 'type' => Controls_Manager::TEXT,
1316 - 'default' => $default_messages['success'],
1317 - 'placeholder' => $default_messages['success'],
1318 - 'label_block' => true,
1319 - 'condition' => [
1320 - 'custom_messages!' => '',
1321 - ],
1322 - 'render_type' => 'none',
1323 - 'dynamic' => [
1324 - 'active' => true,
1325 - ],
1326 - ]
1327 - );
1328 - $this->add_control(
1329 - 'error_message',
1330 - [
1331 - 'label' => esc_html__( 'Form Error', 'uicore-elements' ),
1332 - 'type' => Controls_Manager::TEXT,
1333 - 'default' => $default_messages['error'],
1334 - 'placeholder' => $default_messages['error'],
1335 - 'label_block' => true,
1336 - 'condition' => [
1337 - 'custom_messages!' => '',
1338 - ],
1339 - 'render_type' => 'none',
1340 - 'dynamic' => [
1341 - 'active' => true,
1342 - ],
1343 - ]
1344 - );
1345 - $this->add_control(
1346 - 'mail_error_message',
1347 - [
1348 - 'label' => esc_html__( 'Email Sending Error', 'uicore-elements' ),
1349 - 'type' => Controls_Manager::TEXT,
1350 - 'default' => $default_messages['mail_error'],
1351 - 'placeholder' => $default_messages['mail_error'],
1352 - 'label_block' => true,
1353 - 'condition' => [
1354 - 'custom_messages!' => '',
1355 - ],
1356 - 'render_type' => 'none',
1357 - 'dynamic' => [
1358 - 'active' => true,
1359 - ],
1360 - ]
1361 - );
1362 - $this->add_control(
1363 - 'redirect_message',
1364 - [
1365 - 'label' => esc_html__( 'Sucessfull Redirect', 'uicore-elements' ),
1366 - 'type' => Controls_Manager::TEXT,
1367 - 'default' => $default_messages['redirect'],
1368 - 'placeholder' => $default_messages['redirect'],
1369 - 'label_block' => true,
1370 - 'conditions' => [
1371 - 'terms' => [
1372 - [
1373 - 'name' => 'custom_messages',
1374 - 'operator' => '!=',
1375 - 'value' => '',
1376 - ],
1377 - [
1378 - 'name' => 'submit_actions',
1379 - 'operator' => 'contains',
1380 - 'value' => 'redirect',
1381 - ]
1382 - ],
1383 - ],
1384 - 'render_type' => 'none',
1385 - 'dynamic' => [
1386 - 'active' => true,
1387 - ],
1388 - ]
1389 - );
1390 -
1391 - $this->end_controls_section();
1392 -
1393 - $this->start_controls_section(
1394 - 'section_form_style',
1395 - [
1396 - 'label' => esc_html__( 'Form', 'uicore-elements' ),
1397 - 'tab' => Controls_Manager::TAB_STYLE,
1398 - ]
1399 - );
1400 -
1401 - $this->add_control(
1402 - 'column_gap',
1403 - [
1404 - 'label' => esc_html__( 'Columns Gap', 'uicore-elements' ),
1405 - 'type' => Controls_Manager::SLIDER,
1406 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1407 - 'default' => [
1408 - 'size' => 10,
1409 - ],
1410 - 'range' => [
1411 - 'px' => [
1412 - 'max' => 60,
1413 - ],
1414 - 'em' => [
1415 - 'max' => 6,
1416 - ],
1417 - 'rem' => [
1418 - 'max' => 6,
1419 - ],
1420 - ],
1421 - 'selectors' => [
1422 - '{{WRAPPER}} .ui-e-field-group' => 'padding-right: calc( {{SIZE}}{{UNIT}}/2 ); padding-left: calc( {{SIZE}}{{UNIT}}/2 );',
1423 - '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-left: calc( -{{SIZE}}{{UNIT}}/2 ); margin-right: calc( -{{SIZE}}{{UNIT}}/2 );',
1424 - ],
1425 - ]
1426 - );
1427 - $this->add_control(
1428 - 'row_gap',
1429 - [
1430 - 'label' => esc_html__( 'Rows Gap', 'uicore-elements' ),
1431 - 'type' => Controls_Manager::SLIDER,
1432 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1433 - 'default' => [
1434 - 'size' => 10,
1435 - ],
1436 - 'range' => [
1437 - 'px' => [
1438 - 'max' => 60,
1439 - ],
1440 - 'em' => [
1441 - 'max' => 6,
1442 - ],
1443 - 'rem' => [
1444 - 'max' => 6,
1445 - ],
1446 - ],
1447 - 'selectors' => [
1448 - '{{WRAPPER}} .ui-e-field-group' => 'margin-bottom: {{SIZE}}{{UNIT}};',
1449 - '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
1450 - ],
1451 - ]
1452 - );
1453 - $this->add_control(
1454 - 'heading_label',
1455 - [
1456 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
1457 - 'type' => Controls_Manager::HEADING,
1458 - 'separator' => 'before',
1459 - ]
1460 - );
1461 - $this->add_control(
1462 - 'label_spacing',
1463 - [
1464 - 'label' => esc_html__( 'Spacing', 'uicore-elements' ),
1465 - 'type' => Controls_Manager::SLIDER,
1466 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1467 - 'default' => [
1468 - 'size' => 0,
1469 - ],
1470 - 'range' => [
1471 - 'px' => [
1472 - 'max' => 60,
1473 - ],
1474 - 'em' => [
1475 - 'max' => 6,
1476 - ],
1477 - 'rem' => [
1478 - 'max' => 6,
1479 - ],
1480 - ],
1481 - 'selectors' => [
1482 - 'body {{WRAPPER}} .ui-e-field-group > label' => 'padding-bottom: {{SIZE}}{{UNIT}};',
1483 - ],
1484 - ]
1485 - );
1486 - $this->add_control(
1487 - 'label_color',
1488 - [
1489 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1490 - 'type' => Controls_Manager::COLOR,
1491 - 'selectors' => [
1492 - '{{WRAPPER}} .ui-e-field-group > label, {{WRAPPER}} .ui-e-field-subgroup label' => 'color: {{VALUE}};',
1493 - ],
1494 - 'global' => [
1495 - 'default' => Global_Colors::COLOR_TEXT,
1496 - ],
1497 - ]
1498 - );
1499 - $this->add_control(
1500 - 'mark_required_color',
1501 - [
1502 - 'label' => esc_html__( 'Mark Color', 'uicore-elements' ),
1503 - 'type' => Controls_Manager::COLOR,
1504 - 'default' => '',
1505 - 'selectors' => [
1506 - '{{WRAPPER}} .ui-e-required .ui-e-label:after' => 'color: {{COLOR}};',
1507 - ],
1508 - 'condition' => [
1509 - 'mark_required' => 'yes',
1510 - ],
1511 - ]
1512 - );
1513 - $this->add_group_control(
1514 - Group_Control_Typography::get_type(),
1515 - [
1516 - 'name' => 'label_typography',
1517 - 'selector' => '{{WRAPPER}} .ui-e-field-group > label',
1518 - 'global' => [
1519 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1520 - ],
1521 - ]
1522 - );
1523 - $this->add_control(
1524 - 'heading_html',
1525 - [
1526 - 'label' => esc_html__( 'HTML Field', 'uicore-elements' ),
1527 - 'type' => Controls_Manager::HEADING,
1528 - 'separator' => 'before',
1529 - ]
1530 - );
1531 - $this->add_control(
1532 - 'html_spacing',
1533 - [
1534 - 'label' => esc_html__( 'Spacing', 'uicore-elements' ),
1535 - 'type' => Controls_Manager::SLIDER,
1536 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1537 - 'default' => [
1538 - 'size' => 0,
1539 - ],
1540 - 'range' => [
1541 - 'px' => [
1542 - 'max' => 60,
1543 - ],
1544 - 'em' => [
1545 - 'max' => 6,
1546 - ],
1547 - 'rem' => [
1548 - 'max' => 6,
1549 - ],
1550 - ],
1551 - 'selectors' => [
1552 - '{{WRAPPER}} .ui-e-field-type-html' => 'padding-bottom: {{SIZE}}{{UNIT}};',
1553 - ],
1554 - ]
1555 - );
1556 - $this->add_control(
1557 - 'html_color',
1558 - [
1559 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
1560 - 'type' => Controls_Manager::COLOR,
1561 - 'selectors' => [
1562 - '{{WRAPPER}} .ui-e-field-type-html' => 'color: {{VALUE}};',
1563 - ],
1564 - 'global' => [
1565 - 'default' => Global_Colors::COLOR_TEXT,
1566 - ],
1567 - ]
1568 - );
1569 - $this->add_group_control(
1570 - Group_Control_Typography::get_type(),
1571 - [
1572 - 'name' => 'html_typography',
1573 - 'selector' => '{{WRAPPER}} .ui-e-field-type-html',
1574 - 'global' => [
1575 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1576 - ],
1577 - ]
1578 - );
1579 -
1580 - $this->end_controls_section();
1581 -
1582 - $this->start_controls_section(
1583 - 'section_field_style',
1584 - [
1585 - 'label' => esc_html__( 'Fields', 'uicore-elements' ),
1586 - 'tab' => Controls_Manager::TAB_STYLE,
1587 - ]
1588 - );
1589 -
1590 - $this->start_controls_tabs(
1591 - 'field_style_tabs'
1592 - );
1593 -
1594 - $this->start_controls_tab(
1595 - 'field_normal_tab',
1596 - [
1597 - 'label' => esc_html__( 'Normal', 'uicore-elements' ),
1598 - ]
1599 - );
1600 -
1601 - $this->add_group_control(
1602 - Group_Control_Typography::get_type(),
1603 - [
1604 - 'name' => 'field_typography',
1605 - 'selector' => '{{WRAPPER}} .ui-e-field-group .ui-e-field, {{WRAPPER}} .ui-e-field-subgroup label',
1606 - 'global' => [
1607 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1608 - ],
1609 - ]
1610 - );
1611 - $this->add_control(
1612 - 'field_text_color',
1613 - [
1614 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1615 - 'type' => Controls_Manager::COLOR,
1616 - 'selectors' => [
1617 - '{{WRAPPER}} .ui-e-field-group .ui-e-field' => 'color: {{VALUE}};',
1618 - ],
1619 - 'global' => [
1620 - 'default' => Global_Colors::COLOR_TEXT,
1621 - ],
1622 - ]
1623 - );
1624 - $this->add_control(
1625 - 'field_placeholder_color',
1626 - [
1627 - 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ),
1628 - 'type' => Controls_Manager::COLOR,
1629 - 'selectors' => [
1630 - '{{WRAPPER}} .ui-e-field-group .ui-e-field::placeholder' => 'color: {{VALUE}};',
1631 - ],
1632 - 'global' => [
1633 - 'default' => Global_Colors::COLOR_TEXT,
1634 - ],
1635 - ]
1636 - );
1637 - $this->add_control(
1638 - 'field_background_color',
1639 - [
1640 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1641 - 'type' => Controls_Manager::COLOR,
1642 - 'default' => '#ffffff',
1643 - 'selectors' => [
1644 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
1645 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'background-color: {{VALUE}};',
1646 - ],
1647 - ]
1648 - );
1649 - $this->add_group_control(
1650 - Group_Control_Border::get_type(),
1651 - [
1652 - 'name' => 'field_border',
1653 - 'selector' =>
1654 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select),
1655 - {{WRAPPER}} .ui-e-field-group .ui-e-field-select select',
1656 - ]
1657 - );
1658 -
1659 - $this->end_controls_tab();
1660 -
1661 - $this->start_controls_tab(
1662 - 'field_hover_tab',
1663 - [
1664 - 'label' => esc_html__( 'Hover', 'uicore-elements' ),
1665 - ]
1666 - );
1667 -
1668 - $this->add_control(
1669 - 'field_text_hover_color',
1670 - [
1671 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1672 - 'type' => Controls_Manager::COLOR,
1673 - 'selectors' => [
1674 - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field' => 'color: {{VALUE}};',
1675 - ],
1676 - 'global' => [
1677 - 'default' => Global_Colors::COLOR_TEXT,
1678 - ],
1679 - ]
1680 - );
1681 - $this->add_control(
1682 - 'field_placeholder_hover_color',
1683 - [
1684 - 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ),
1685 - 'type' => Controls_Manager::COLOR,
1686 - 'selectors' => [
1687 - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field::placeholder' => 'color: {{VALUE}};',
1688 - ],
1689 - 'global' => [
1690 - 'default' => Global_Colors::COLOR_TEXT,
1691 - ],
1692 - ]
1693 - );
1694 - $this->add_control(
1695 - 'field_background_hover_color',
1696 - [
1697 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1698 - 'type' => Controls_Manager::COLOR,
1699 - 'default' => '#ffffff',
1700 - 'selectors' => [
1701 - '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
1702 - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select' => 'background-color: {{VALUE}};',
1703 - ],
1704 - ]
1705 - );
1706 - $this->add_group_control(
1707 - Group_Control_Border::get_type(),
1708 - [
1709 - 'name' => 'field_hover_border',
1710 - 'selector' =>
1711 - '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select),
1712 - {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select',
1713 - ]
1714 - );
1715 -
1716 - $this->end_controls_tab();
1717 -
1718 - $this->start_controls_tab(
1719 - 'field_active_tab',
1720 - [
1721 - 'label' => esc_html__( 'Active', 'uicore-elements' ),
1722 - ]
1723 - );
1724 -
1725 - $this->add_control(
1726 - 'field_text_active_color',
1727 - [
1728 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1729 - 'type' => Controls_Manager::COLOR,
1730 - 'selectors' => [
1731 - '{{WRAPPER}} .ui-e-field-group .ui-e-field:focus' => 'color: {{VALUE}};',
1732 - ],
1733 - 'global' => [
1734 - 'default' => Global_Colors::COLOR_TEXT,
1735 - ],
1736 - ]
1737 - );
1738 - $this->add_control(
1739 - 'field_background_active_color',
1740 - [
1741 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1742 - 'type' => Controls_Manager::COLOR,
1743 - 'default' => '#ffffff',
1744 - 'selectors' => [
1745 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
1746 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select' => 'background-color: {{VALUE}};',
1747 - ],
1748 - ]
1749 - );
1750 - $this->add_group_control(
1751 - Group_Control_Border::get_type(),
1752 - [
1753 - 'name' => 'field_active_border',
1754 - 'selector' =>
1755 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select),
1756 - {{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select',
1757 - ]
1758 - );
1759 -
1760 - $this->end_controls_tab();
1761 -
1762 - $this->end_controls_tabs();
1763 -
1764 - $this->add_control(
1765 - 'field_border_radius',
1766 - [
1767 - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
1768 - 'type' => Controls_Manager::DIMENSIONS,
1769 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1770 - 'selectors' => [
1771 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1772 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1773 - ],
1774 - 'separator' => 'before'
1775 - ]
1776 - );
1777 - $this->add_control(
1778 - 'field_padding',
1779 - [
1780 - 'label' => esc_html__( 'Padding', 'uicore-elements' ),
1781 - 'type' => Controls_Manager::DIMENSIONS,
1782 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1783 - 'selectors' => [
1784 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1785 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1786 - ],
1787 - ]
1788 - );
1789 -
1790 - $this->end_controls_section();
1791 -
1792 - $this->start_controls_section(
1793 - 'section_button_style',
1794 - [
1795 - 'label' => esc_html__( 'Button', 'uicore-elements' ),
1796 - 'tab' => Controls_Manager::TAB_STYLE,
1797 - ]
1798 - );
1799 -
1800 - $this->add_group_control(
1801 - Group_Control_Typography::get_type(),
1802 - [
1803 - 'name' => 'button_typography',
1804 - 'global' => [
1805 - 'default' => Global_Typography::TYPOGRAPHY_ACCENT,
1806 - ],
1807 - 'selector' => '{{WRAPPER}} .elementor-button',
1808 - ]
1809 - );
1810 - $this->add_group_control(
1811 - Group_Control_Border::get_type(), [
1812 - 'name' => 'button_border',
1813 - 'selector' => '{{WRAPPER}} .elementor-button',
1814 - 'exclude' => [
1815 - 'color',
1816 - ],
1817 - ]
1818 - );
1819 -
1820 - $this->start_controls_tabs( 'tabs_button_style' );
1821 -
1822 - $this->start_controls_tab(
1823 - 'tab_button_normal',
1824 - [
1825 - 'label' => esc_html__( 'Normal', 'uicore-elements' ),
1826 - ]
1827 - );
1828 -
1829 - $this->add_control(
1830 - 'button_background_color',
1831 - [
1832 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1833 - 'type' => Controls_Manager::COLOR,
1834 - 'global' => [
1835 - 'default' => Global_Colors::COLOR_ACCENT,
1836 - ],
1837 - 'selectors' => [
1838 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'background-color: {{VALUE}};',
1839 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'background-color: {{VALUE}};',
1840 - ],
1841 - ]
1842 - );
1843 - $this->add_control(
1844 - 'button_text_color',
1845 - [
1846 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1847 - 'type' => Controls_Manager::COLOR,
1848 - 'default' => '#ffffff',
1849 - 'selectors' => [
1850 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'color: {{VALUE}};',
1851 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'color: {{VALUE}};',
1852 - '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'fill: {{VALUE}};',
1853 - ],
1854 - ]
1855 - );
1856 - $this->add_control(
1857 - 'button_border_color',
1858 - [
1859 - 'label' => esc_html__( 'Border Color', 'uicore-elements' ),
1860 - 'type' => Controls_Manager::COLOR,
1861 - 'default' => '',
1862 - 'selectors' => [
1863 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'border-color: {{VALUE}};',
1864 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'border-color: {{VALUE}};',
1865 - ],
1866 - 'condition' => [
1867 - 'button_border_border!' => '',
1868 - ],
1869 - ]
1870 - );
1871 -
1872 - $this->end_controls_tab();
1873 -
1874 - $this->start_controls_tab(
1875 - 'tab_button_hover',
1876 - [
1877 - 'label' => esc_html__( 'Hover', 'uicore-elements' ),
1878 - ]
1879 - );
1880 -
1881 - $this->add_control(
1882 - 'button_background_hover_color',
1883 - [
1884 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1885 - 'type' => Controls_Manager::COLOR,
1886 - 'default' => '',
1887 - 'selectors' => [
1888 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'background-color: {{VALUE}};',
1889 - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'background-color: {{VALUE}};',
1890 - ],
1891 - ]
1892 - );
1893 - $this->add_control(
1894 - 'button_hover_color',
1895 - [
1896 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1897 - 'type' => Controls_Manager::COLOR,
1898 - 'default' => '#ffffff',
1899 - 'selectors' => [
1900 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'color: {{VALUE}};',
1901 - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'color: {{VALUE}};',
1902 - '{{WRAPPER}} .elementor-button[type="submit"]:hover svg *' => 'fill: {{VALUE}};',
1903 - ],
1904 - ]
1905 - );
1906 - $this->add_control(
1907 - 'button_hover_border_color',
1908 - [
1909 - 'label' => esc_html__( 'Border Color', 'uicore-elements' ),
1910 - 'type' => Controls_Manager::COLOR,
1911 - 'default' => '',
1912 - 'selectors' => [
1913 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'border-color: {{VALUE}};',
1914 - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'border-color: {{VALUE}};',
1915 - ],
1916 - 'condition' => [
1917 - 'button_border_border!' => '',
1918 - ],
1919 - ]
1920 - );
1921 - $this->add_control(
1922 - 'hover_transition_duration',
1923 - [
1924 - 'label' => esc_html__( 'Transition Duration', 'uicore-elements' ),
1925 - 'type' => Controls_Manager::SLIDER,
1926 - 'size_units' => [ 's', 'ms', 'custom' ],
1927 - 'default' => [
1928 - 'unit' => 'ms',
1929 - ],
1930 - 'selectors' => [
1931 - '{{WRAPPER}} .e-form__buttons__wrapper__button-previous' => 'transition-duration: {{SIZE}}{{UNIT}};',
1932 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'transition-duration: {{SIZE}}{{UNIT}};',
1933 - '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'transition-duration: {{SIZE}}{{UNIT}};',
1934 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'transition-duration: {{SIZE}}{{UNIT}};',
1935 - ],
1936 - ]
1937 - );
1938 - $this->add_control(
1939 - 'button_hover_animation',
1940 - [
1941 - 'label' => esc_html__( 'Animation', 'uicore-elements' ),
1942 - 'type' => Controls_Manager::HOVER_ANIMATION,
1943 - ]
1944 - );
1945 -
1946 - $this->end_controls_tab();
1947 -
1948 - $this->end_controls_tabs();
1949 -
1950 - $this->add_control(
1951 - 'button_border_radius',
1952 - [
1953 - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
1954 - 'type' => Controls_Manager::DIMENSIONS,
1955 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1956 - 'selectors' => [
1957 - '{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1958 - ],
1959 - 'separator' => 'before',
1960 - ]
1961 - );
1962 -
1963 - $this->add_control(
1964 - 'button_text_padding',
1965 - [
1966 - 'label' => esc_html__( 'Text Padding', 'uicore-elements' ),
1967 - 'type' => Controls_Manager::DIMENSIONS,
1968 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1969 - 'selectors' => [
1970 - '{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1971 - ],
1972 - ]
1973 - );
1974 -
1975 - $this->end_controls_section();
1976 -
1977 - $this->start_controls_section(
1978 - 'section_messages_style',
1979 - [
1980 - 'label' => esc_html__( 'Messages', 'uicore-elements' ),
1981 - 'tab' => Controls_Manager::TAB_STYLE,
1982 - ]
1983 - );
1984 -
1985 - $this->add_control(
1986 - 'show_messages',
1987 - [
1988 - 'label' => esc_html__( 'Show/Hide messages', 'uicore-elements' ),
1989 - 'type' => Controls_Manager::BUTTON,
1990 - 'separator' => 'before',
1991 - 'text' => esc_html__( 'Toggle', 'uicore-elements' ),
1992 - 'event' => 'ui-e-form-show-messages',
1993 - ]
1994 - );
1995 - $this->add_group_control(
1996 - Group_Control_Typography::get_type(),
1997 - [
1998 - 'name' => 'message_typography',
1999 - 'global' => [
2000 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
2001 - ],
2002 - 'selector' => '{{WRAPPER}} .ui-e-message',
2003 - ]
2004 - );
2005 - $this->add_control(
2006 - 'success_message_color',
2007 - [
2008 - 'label' => esc_html__( 'Success Message Color', 'uicore-elements' ),
2009 - 'type' => Controls_Manager::COLOR,
2010 - 'default' => '#4CAF50',
2011 - 'selectors' => [
2012 - '{{WRAPPER}} .ui-e-message span.success' => 'color: {{COLOR}};',
2013 - ],
2014 - ]
2015 - );
2016 - $this->add_control(
2017 - 'error_message_color',
2018 - [
2019 - 'label' => esc_html__( 'Error Message Color', 'uicore-elements' ),
2020 - 'type' => Controls_Manager::COLOR,
2021 - 'default' => '#F44336',
2022 - 'selectors' => [
2023 - '{{WRAPPER}} .ui-e-message span.error' => 'color: {{COLOR}};',
2024 - ],
2025 - ]
2026 - );
2027 -
2028 - $this->end_controls_section();
2029 - }
1161 + ]
1162 + );
1163 + $this->end_injection();
1164 + }
2030 1165 function recaptcha_js()
2031 1166 {
2032 - ?>
1167 + ?>
2033 1168 <script>
2034 - window.uicore_elements_recaptcha = '<?php echo get_option('uicore_elements_recaptcha_site_key'); ?>';
1169 + window.uicore_elements_recaptcha = '<?php echo esc_html(get_option('uicore_elements_recaptcha_site_key')); ?>';
2035 1170 </script>
2036 - <?php
1171 + <?php
2037 1172 }
2038 1173
2039 - protected function render() {
1174 + protected function render()
1175 + {
2040 1176
2041 - $instance = $this->get_settings_for_display();
1177 + $instance = $this->get_settings_for_display();
2042 1178 $is_recaptcha_required = false;
2043 1179
1180 + // Save widget settings so form API can retrieve them
1181 + set_transient('ui_e_form_widget_settings_' . $this->get_id(), $instance, DAY_IN_SECONDS);
1182 +
2044 1183 // Render Form Atts
2045 - $this->add_render_attribute(
2046 - [
2047 - 'wrapper' => [
2048 - 'class' => [
2049 - 'ui-e-fields-wrp',
2050 - ],
2051 - ],
2052 - 'submit-group' => [
2053 - 'class' => [
2054 - 'ui-e-field-group',
2055 - 'elementor-column',
2056 - 'ui-e-field-type-submit',
2057 - ],
2058 - ],
2059 - 'button' => [
2060 - 'class' => 'elementor-button',
2061 - ],
2062 - 'icon-align' => [
2063 - 'class' => [
2064 - empty( $instance['button_icon_align'] ) ? '' : 'ui-e-icon ui-e-align-' . $instance['button_icon_align'],
2065 - ],
2066 - ],
2067 - ]
2068 - );
1184 + $this->add_render_attribute(
1185 + [
1186 + 'wrapper' => [
1187 + 'class' => [
1188 + 'ui-e-fields-wrp',
1189 + ],
1190 + ],
1191 + 'submit-group' => [
1192 + 'class' => [
1193 + 'ui-e-field-group',
1194 + 'elementor-column',
1195 + 'ui-e-field-type-submit',
1196 + ],
1197 + ],
1198 + 'button' => [
1199 + 'class' => 'elementor-button',
1200 + ],
1201 + 'icon-align' => [
1202 + 'class' => [
1203 + empty($instance['button_icon_align']) ? '' : 'ui-e-icon ui-e-align-' . $instance['button_icon_align'],
1204 + ],
1205 + ],
1206 + ]
1207 + );
2069 1208
2070 1209 // Fallback for empty control values
2071 - if ( empty( $instance['button_width'] ) ) {
2072 - $instance['button_width'] = '100';
2073 - }
1210 + if (empty($instance['button_width'])) {
1211 + $instance['button_width'] = '100';
1212 + }
2074 1213
2075 - // Button atts
2076 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-col-' . $instance['button_width'] . ' e-form__buttons' );
1214 + // Button atts
1215 + $this->add_render_attribute('submit-group', 'class', 'elementor-col-' . $instance['button_width'] . ' e-form__buttons');
2077 1216
2078 - if ( ! empty( $instance['button_width_tablet'] ) ) {
2079 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-md-' . $instance['button_width_tablet'] );
2080 - }
2081 - if ( ! empty( $instance['button_width_mobile'] ) ) {
2082 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-sm-' . $instance['button_width_mobile'] );
2083 - }
2084 - if ( $instance['button_hover_animation'] ) {
2085 - $this->add_render_attribute( 'button', 'class', 'elementor-animation-' . $instance['button_hover_animation'] );
2086 - }
1217 + if (! empty($instance['button_width_tablet'])) {
1218 + $this->add_render_attribute('submit-group', 'class', 'elementor-md-' . $instance['button_width_tablet']);
1219 + }
1220 + if (! empty($instance['button_width_mobile'])) {
1221 + $this->add_render_attribute('submit-group', 'class', 'elementor-sm-' . $instance['button_width_mobile']);
1222 + }
1223 + if ($instance['button_hover_animation']) {
1224 + $this->add_render_attribute('button', 'class', 'elementor-animation-' . $instance['button_hover_animation']);
1225 + }
2087 1226
2088 - // Form atts
2089 - if ( ! empty( $instance['form_id'] ) ) {
2090 - $this->add_render_attribute( 'form', 'id', $instance['form_id'] );
2091 - }
2092 - if ( ! empty( $instance['form_name'] ) ) {
2093 - $this->add_render_attribute( 'form', 'name', $instance['form_name'] );
2094 - }
2095 - if ( 'no' === $instance['form_validation'] ) {
2096 - $this->add_render_attribute( 'form', 'novalidate' );
2097 - }
2098 - if ( ! empty( $instance['button_css_id'] ) ) {
2099 - $this->add_render_attribute( 'button', 'id', $instance['button_css_id'] );
2100 - }
1227 + // Form atts
1228 + if (! empty($instance['form_id'])) {
1229 + $this->add_render_attribute('form', 'id', $instance['form_id']);
1230 + }
1231 + if (! empty($instance['form_name'])) {
1232 + $this->add_render_attribute('form', 'name', $instance['form_name']);
1233 + }
1234 + if ('no' === $instance['form_validation']) {
1235 + $this->add_render_attribute('form', 'novalidate');
1236 + }
1237 + if (! empty($instance['button_css_id'])) {
1238 + $this->add_render_attribute('button', 'id', $instance['button_css_id']);
1239 + }
2101 1240
2102 - $referer_title = trim( wp_title( '', false ) );
2103 - if ( ! $referer_title && is_home() ) {
2104 - $referer_title = get_option( 'blogname' );
2105 - }
1241 + $referer_title = trim(wp_title('', false));
1242 + if (! $referer_title && is_home()) {
1243 + $referer_title = get_option('blogname');
1244 + }
2106 1245
2107 - ?>
1246 + // Get default messages
1247 + $messages = Contact_Form_Service::get_default_messages();
2108 1248
2109 - <form class="ui-e-form" method="post" <?php $this->print_render_attribute_string( 'form' ); ?>>
1249 + // Set frontend validation message
1250 + $front_msg_required = isset($instance['required_fields_message'])
1251 + ? $instance['required_fields_message']
1252 + : $messages['required'];
1253 + ?>
2110 1254
2111 - <input type="hidden" name="post_id" value="<?php echo esc_attr( get_the_ID()); ?>"/>
1255 + <form class="ui-e-form" method="post" <?php $this->print_render_attribute_string('form'); ?>>
1256 +
1257 + <input type="hidden" name="post_id" value="<?php echo esc_attr(get_the_ID()); ?>" />
2112 1258 <input type="hidden" name="widget_type" value="contact-form">
2113 1259
2114 - <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
2115 - <?php
2116 - foreach ( $instance['form_fields'] as $item_index => $item ) :
2117 - $this->form_fields_render_attributes( $item_index, $instance, $item );
1260 + <input type="hidden" name="required_fields_message" value="<?php echo esc_html($front_msg_required); ?>">
2118 1261
2119 - $field_type = $item['field_type'];
1262 + <div <?php $this->print_render_attribute_string('wrapper'); ?>>
2120 1263
2121 - if( $field_type === 'recaptcha' || $field_type === 'recaptcha_v3' ){
1264 + <?php foreach ($instance['form_fields'] as $item_index => $item) :
1265 + $this->form_fields_render_attributes($item_index, $instance, $item);
1266 +
1267 + $field_type = $item['field_type'];
1268 +
1269 + if ($field_type === 'recaptcha' || $field_type === 'recaptcha_v3') {
2122 1270 $is_recaptcha_required = true;
2123 1271 }
2124 1272
2125 - $print_label = ! in_array( $item['field_type'], [ 'hidden', 'html' ], true );
2126 - ?>
1273 + $print_label = ! in_array($item['field_type'], ['hidden', 'html'], true);
1274 + ?>
2127 1275
2128 - <div <?php $this->print_render_attribute_string( 'field-group' . $item_index ); ?>>
2129 - <?php
2130 - // Print label (excepts if recaptcha)
2131 - if ( $print_label && $item['field_label'] && $item['field_type'] !== 'recaptcha' && $item['field_type'] !== 'recaptcha_v3' ){
2132 - ?>
2133 - <label <?php $this->print_render_attribute_string( 'label' . $item_index ); ?>>
2134 - <?php // PHPCS - the variable $item['field_label'] is safe.
2135 - echo $item['field_label']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
2136 - </label>
1276 + <div <?php $this->print_render_attribute_string('field-group' . $item_index); ?>>
1277 + <?php
1278 + // Print label (excepts if recaptcha)
1279 + if ($print_label && $item['field_label'] && $item['field_type'] !== 'recaptcha' && $item['field_type'] !== 'recaptcha_v3') {
1280 + ?>
1281 + <label <?php $this->print_render_attribute_string('label' . $item_index); ?>>
1282 + <?php // PHPCS - the variable $item['field_label'] is safe.
1283 + echo $item['field_label']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1284 + ?>
1285 + </label>
2137 1286 <?php
2138 1287 }
2139 1288
2140 - // Print field
2141 - switch ( $item['field_type'] ) :
2142 - case 'html':
2143 - echo do_shortcode( $item['field_html'] );
2144 - break;
1289 + // Print field
1290 + switch ($item['field_type']):
1291 + case 'html':
1292 + echo do_shortcode($item['field_html']);
1293 + break;
2145 1294
2146 - case 'textarea':
2147 - // PHPCS - the method build_textarea_field is safe.
2148 - echo $this->build_textarea_field( $item, $item_index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2149 - break;
1295 + case 'textarea':
1296 + // PHPCS - the method build_textarea_field is safe.
1297 + echo $this->build_textarea_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1298 + break;
2150 1299
2151 - case 'select':
2152 - // PHPCS - the method build_select_field is safe.
2153 - echo $this->build_select_field( $item, $item_index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2154 - break;
1300 + case 'select':
1301 + // PHPCS - the method build_select_field is safe.
1302 + echo $this->build_select_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1303 + break;
2155 1304
2156 - case 'acceptance':
2157 - // PHPCS - the method build_select_field is safe.
2158 - echo $this->build_acceptance_field( $item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2159 - break;
1305 + case 'acceptance':
1306 + // PHPCS - the method build_select_field is safe.
1307 + echo $this->build_acceptance_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1308 + break;
2160 1309
2161 - case 'radio':
2162 - case 'checkbox':
2163 - // PHPCS - the method build_radio_checkbox_field is safe.
2164 - echo $this->build_radio_checkbox_field( $item, $item_index, $item['field_type'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2165 - break;
1310 + case 'radio':
1311 + case 'checkbox':
1312 + // PHPCS - the method build_radio_checkbox_field is safe.
1313 + echo $this->build_radio_checkbox_field($item, $item_index, $item['field_type']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1314 + break;
2166 1315
2167 1316 case 'address': // is actually honeypot
2168 1317 // PHPCS - the method build_honeypot_field is safe.
2169 - echo $this->build_honeypot_field( $item, $item_index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1318 + echo $this->build_honeypot_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2170 1319 break;
2171 1320
2172 1321 case 'recaptcha':
2173 1322 // get widget ID
2174 - echo '<input type="hidden" name="recaptcha"/> <div id="ui-e-recaptcha-'.esc_attr($this->get_ID()).'"></div>';
1323 + echo '<input type="hidden" name="recaptcha"/> <div id="ui-e-recaptcha-' . esc_attr($this->get_ID()) . '"></div>';
2175 1324 break;
2176 1325
2177 1326 case 'recaptcha_v3':
2178 1327 echo '<input type="hidden" name="recaptcha_v3"/>';
@@ -2177,61 +1326,75 @@
2177 1326 case 'recaptcha_v3':
2178 1327 echo '<input type="hidden" name="recaptcha_v3"/>';
2179 1328 break;
2180 1329
2181 - // All other cases are covered by the add_render_atribute()
2182 - default:
2183 - $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-field-textual');
2184 - ?>
2185 - <input size="1" <?php $this->print_render_attribute_string( 'input' . $item_index ); ?>>
2186 - <?php
2187 - break;
1330 + // All other cases are covered by the add_render_atribute()
1331 + default:
1332 + $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-field-textual');
1333 + ?>
1334 + <input size="1" <?php $this->print_render_attribute_string('input' . $item_index); ?>>
1335 + <?php
1336 + break;
2188 1337
2189 - endswitch;
2190 - ?>
2191 - </div>
1338 + endswitch;
1339 + ?>
1340 + </div>
2192 1341
2193 - <?php endforeach; ?>
1342 + <?php endforeach; ?>
2194 1343
2195 - <div <?php $this->print_render_attribute_string( 'submit-group' ); ?>>
2196 - <button type="submit" <?php $this->print_render_attribute_string( 'button' ); ?>>
2197 - <span <?php $this->print_render_attribute_string( 'content-wrapper' ); ?>>
2198 - <?php if ( ! empty( $instance['button_icon'] ) || ! empty( $instance['selected_button_icon'] ) ) : ?>
2199 - <span <?php $this->print_render_attribute_string( 'icon-align' ); ?>>
2200 - <?php Icons_Manager::render_icon( $instance['selected_button_icon'], [ 'aria-hidden' => 'true' ] ); ?>
2201 - <?php if ( empty( $instance['button_text'] ) ) : ?>
2202 - <span class="elementor-screen-only"><?php echo esc_html__( 'Submit', 'uicore-elements' ); ?></span>
2203 - <?php endif; ?>
2204 - </span>
2205 - <?php endif; ?>
2206 - <?php if ( ! empty( $instance['button_text'] ) ) : ?>
2207 - <span class="ui-e-text"><?php $this->print_unescaped_setting( 'button_text' ); ?></span>
2208 - <?php endif; ?>
2209 - </span>
2210 - </button>
2211 - </div>
1344 + <div <?php $this->print_render_attribute_string('submit-group'); ?>>
1345 + <button type="submit" <?php $this->print_render_attribute_string('button'); ?>>
1346 + <span <?php $this->print_render_attribute_string('content-wrapper'); ?>>
1347 + <?php if (! empty($instance['button_icon']) || ! empty($instance['selected_button_icon'])) : ?>
1348 + <span <?php $this->print_render_attribute_string('icon-align'); ?>>
1349 + <?php Icons_Manager::render_icon($instance['selected_button_icon'], ['aria-hidden' => 'true']); ?>
1350 + <?php if (empty($instance['button_text'])) : ?>
1351 + <span class="elementor-screen-only"><?php echo esc_html__('Submit', 'uicore-elements'); ?></span>
1352 + <?php endif; ?>
1353 + </span>
1354 + <?php endif; ?>
1355 + <?php if (! empty($instance['button_text'])) : ?>
1356 + <span class="ui-e-text"><?php $this->print_unescaped_setting('button_text'); ?></span>
1357 + <?php endif; ?>
1358 + </span>
1359 + </button>
1360 + </div>
2212 1361
2213 - </div>
1362 + </div>
2214 1363
2215 1364 <div class="ui-e-message <?php echo $this->is_edit_mode() ? 'elementor-hidden' : ''; ?>">
2216 - <?php if($this->is_edit_mode()) :
1365 + <?php if ($this->is_edit_mode()) :
2217 1366 // Get custom messages if set, else use default
2218 - $messages = Contact_Form_Service::get_default_messages();
2219 - $success = isset($instance['success_message']) ? $instance['success_message'] : $messages['success'];
2220 - $error = isset($instance['error_message']) ? $instance['error_message'] : $messages['error'];
2221 - ?>
2222 - <span class="success"> <?php echo esc_html($success);?> </span> <br>
2223 - <span class="error"> <?php echo esc_html($error);?> </span>
2224 - <?php endif; ?>
1367 + $success = isset($instance['success_message'])
1368 + ? $instance['success_message']
1369 + : $messages['success'];
1370 + $error = isset($instance['error_message'])
1371 + ? $instance['error_message']
1372 + : $messages['error'];
1373 + ?>
1374 + <span class="success"> <?php echo esc_html($success); ?> </span> <br>
1375 + <span class="error"> <?php echo esc_html($error); ?> </span>
1376 + <?php endif; ?>
2225 1377 </div>
2226 - </form>
2227 - <?php
1378 + </form>
1379 + <?php
2228 1380
2229 1381 //add js to footer if recaptcha is enabled
2230 - if($is_recaptcha_required){
1382 + if ($is_recaptcha_required) {
2231 1383 add_action('wp_footer', [$this, 'recaptcha_js'], 999);
2232 1384 }
2233 - }
1385 +
1386 + // Add frontend validation messages to js var
1387 + ?>
1388 + <script>
1389 + window.ui_e_form_validation_messages = <?php echo json_encode([
1390 + 'required_fields' => esc_html($front_msg_required),
1391 + ]); ?>;
1392 + </script>
1393 +<?php
1394 + }
1395 +
1396 + /*
2234 1397 protected function content_template() {
2235 1398 ?>
2236 1399 <#
2237 1400 view.addRenderAttribute(
@@ -2454,6 +1617,7 @@
2454 1617 </div>
2455 1618 </form>
2456 1619 <?php
2457 1620 }
1621 + */
2458 1622 }
2459 -\Elementor\Plugin::instance()->widgets_manager->register(new ContactForm());
1623 +\Elementor\Plugin::instance()->widgets_manager->register(new ContactForm());