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