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