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