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