| @@ -164,9 +164,9 @@ | ||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $value = empty($item['field_value']) ? '' : $item['field_value']; |
| 167 | 167 | |
| 168 | - return '<input ' . $this->get_render_attribute_string('honeypot' . $item_index) . ' tabindex="-1">' . esc_html($value) . '</input>'; | |
| 168 | + return '<input ' . $this->get_render_attribute_string('honeypot' . $item_index) . ' tabindex="-1">' . $value . '</input>'; | |
| 169 | 169 | } |
| 170 | 170 | function build_textarea_field($item, $item_index) |
| 171 | 171 | { |
| 172 | 172 | $this->add_render_attribute('textarea' . $item_index, [ |
| @@ -188,9 +188,9 @@ | ||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $value = empty($item['field_value']) ? '' : $item['field_value']; |
| 191 | 191 | |
| 192 | - return '<textarea ' . $this->get_render_attribute_string('textarea' . $item_index) . '>' . esc_textarea($value) . '</textarea>'; | |
| 192 | + return '<textarea ' . $this->get_render_attribute_string('textarea' . $item_index) . '>' . $value . '</textarea>'; | |
| 193 | 193 | } |
| 194 | 194 | function build_select_field($item, $i) |
| 195 | 195 | { |
| 196 | 196 | $this->add_render_attribute( |
| @@ -268,9 +268,9 @@ | ||
| 268 | 268 | { |
| 269 | 269 | $options = preg_split("/\\r\\n|\\r|\\n/", $item['field_options']); |
| 270 | 270 | $html = ''; |
| 271 | 271 | if ($options) { |
| 272 | - $html .= '<div class="ui-e-field-subgroup ' . esc_attr($item['css_classes']) . ' ' . esc_attr($item['inline_list']) . '">'; | |
| 272 | + $html .= '<div class="ui-e-field-subgroup ' . esc_attr($item['css_classes']) . ' ' . $item['inline_list'] . '">'; | |
| 273 | 273 | foreach ($options as $key => $option) { |
| 274 | 274 | $element_id = $item['custom_id'] . $key; |
| 275 | 275 | $html_id = $this->get_attribute_id($item) . '-' . $key; |
| 276 | 276 | $option_label = $option; |
| @@ -300,13 +300,9 @@ | ||
| 300 | 300 | if ($item['required'] && 'radio' === $type) { |
| 301 | 301 | $this->add_required_attribute($element_id); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - $html .= '<span class="ui-e-field-option">'; | |
| 305 | - $html .= '<input ' . $this->get_render_attribute_string($element_id) . '>'; | |
| 306 | - $html .= '<label for="' . $html_id . '">'; | |
| 307 | - $html .= esc_html($option_label); | |
| 308 | - $html .= '</label></span>'; | |
| 304 | + $html .= '<span class="ui-e-field-option"><input ' . $this->get_render_attribute_string($element_id) . '> <label for="' . $html_id . '">' . $option_label . '</label></span>'; | |
| 309 | 305 | } |
| 310 | 306 | $html .= '</div>'; |
| 311 | 307 | } |
| 312 | 308 | |
| @@ -318,9 +314,9 @@ | ||
| 318 | 314 | $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-acceptance-field'); |
| 319 | 315 | $this->add_render_attribute('input' . $item_index, 'type', 'checkbox', true); |
| 320 | 316 | |
| 321 | 317 | if (! empty($item['acceptance_text'])) { |
| 322 | - $text = '<label for="' . $this->get_attribute_id($item) . '">' . Helper::esc_string($item['acceptance_text']) . '</label>'; | |
| 318 | + $text = '<label for="' . $this->get_attribute_id($item) . '">' . $item['acceptance_text'] . '</label>'; | |
| 323 | 319 | } |
| 324 | 320 | |
| 325 | 321 | if (! empty($item['checked_by_default'])) { |
| 326 | 322 | $this->add_render_attribute('input' . $item_index, 'checked', 'checked'); |
| @@ -839,9 +835,9 @@ | ||
| 839 | 835 | 'placeholder' => esc_html__('Message', 'uicore-elements'), |
| 840 | 836 | 'width' => '100', |
| 841 | 837 | ], |
| 842 | 838 | ], |
| 843 | - 'title_field' => '{{ field_label }}', | |
| 839 | + 'title_field' => '{{{ field_label }}}', | |
| 844 | 840 | ] |
| 845 | 841 | ); |
| 846 | 842 | $this->add_control( |
| 847 | 843 | 'show_labels', |
| @@ -1283,9 +1279,9 @@ | ||
| 1283 | 1279 | if ($print_label && $item['field_label'] && $item['field_type'] !== 'recaptcha' && $item['field_type'] !== 'recaptcha_v3') { |
| 1284 | 1280 | ?> |
| 1285 | 1281 | <label <?php $this->print_render_attribute_string('label' . $item_index); ?>> |
| 1286 | 1282 | <?php // PHPCS - the variable $item['field_label'] is safe. |
| 1287 | - echo Helper::esc_string($item['field_label']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1283 | + echo $item['field_label']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1288 | 1284 | ?> |
| 1289 | 1285 | </label> |
| 1290 | 1286 | <?php |
| 1291 | 1287 | } |
| @@ -1292,9 +1288,9 @@ | ||
| 1292 | 1288 | |
| 1293 | 1289 | // Print field |
| 1294 | 1290 | switch ($item['field_type']): |
| 1295 | 1291 | case 'html': |
| 1296 | - echo wp_kses_post(do_shortcode($item['field_html'])); | |
| 1292 | + echo do_shortcode($item['field_html']); | |
| 1297 | 1293 | break; |
| 1298 | 1294 | |
| 1299 | 1295 | case 'textarea': |
| 1300 | 1296 | // PHPCS - the method build_textarea_field is safe. |
| @@ -1307,9 +1303,9 @@ | ||
| 1307 | 1303 | break; |
| 1308 | 1304 | |
| 1309 | 1305 | case 'acceptance': |
| 1310 | 1306 | // PHPCS - the method build_select_field is safe. |
| 1311 | - $this->build_acceptance_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1307 | + echo $this->build_acceptance_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1312 | 1308 | break; |
| 1313 | 1309 | |
| 1314 | 1310 | case 'radio': |
| 1315 | 1311 | case 'checkbox': |
| @@ -1395,6 +1391,233 @@ | ||
| 1395 | 1391 | ]); ?>; |
| 1396 | 1392 | </script> |
| 1397 | 1393 | <?php |
| 1398 | 1394 | } |
| 1395 | + | |
| 1396 | + /* | |
| 1397 | + protected function content_template() { | |
| 1398 | + ?> | |
| 1399 | + <# | |
| 1400 | + view.addRenderAttribute( | |
| 1401 | + 'form', | |
| 1402 | + { | |
| 1403 | + 'id': settings.form_id, | |
| 1404 | + 'name': settings.form_name, | |
| 1405 | + } | |
| 1406 | + ); | |
| 1407 | + if ( 'no' === settings.form_validation ) { | |
| 1408 | + view.addRenderAttribute( 'form', 'novalidate' ); | |
| 1409 | + } | |
| 1410 | + #> | |
| 1411 | + <form class="ui-e-form" {{{ view.getRenderAttributeString( 'form' ) }}}> | |
| 1412 | + <div class="ui-e-fields-wrp"> | |
| 1413 | + <# | |
| 1414 | + for ( var i in settings.form_fields ) { | |
| 1415 | + var item = settings.form_fields[ i ]; | |
| 1416 | + item.field_type = _.escape( item.field_type ); | |
| 1417 | + item.field_value = _.escape( item.field_value ); | |
| 1418 | + | |
| 1419 | + var options = item.field_options ? item.field_options.split( '\n' ) : [], | |
| 1420 | + itemClasses = _.escape( item.css_classes ), | |
| 1421 | + labelVisibility = '', | |
| 1422 | + placeholder = '', | |
| 1423 | + required = '', | |
| 1424 | + checked_by_default = '', | |
| 1425 | + inputField = '', | |
| 1426 | + multiple = '', | |
| 1427 | + fieldGroupClasses = 'ui-e-field-group elementor-column ui-e-field-type-' + item.field_type, | |
| 1428 | + printLabel = settings.show_labels && ! [ 'hidden', 'html', 'recaptcha', 'recaptcha_v3' ].includes( item.field_type ); | |
| 1429 | + | |
| 1430 | + fieldGroupClasses += ' elementor-col-' + ( ( '' !== item.width ) ? item.width : '100' ); | |
| 1431 | + | |
| 1432 | + if ( item.width_tablet ) { | |
| 1433 | + fieldGroupClasses += ' elementor-md-' + item.width_tablet; | |
| 1434 | + } | |
| 1435 | + | |
| 1436 | + if ( item.width_mobile ) { | |
| 1437 | + fieldGroupClasses += ' elementor-sm-' + item.width_mobile; | |
| 1438 | + } | |
| 1439 | + | |
| 1440 | + if ( item.required ) { | |
| 1441 | + required = 'required'; | |
| 1442 | + fieldGroupClasses += ' ui-e-field-required'; | |
| 1443 | + | |
| 1444 | + if ( settings.mark_required ) { | |
| 1445 | + fieldGroupClasses += ' ui-e-required'; | |
| 1446 | + } | |
| 1447 | + } | |
| 1448 | + | |
| 1449 | + if ( item.placeholder ) { | |
| 1450 | + placeholder = 'placeholder="' + _.escape( item.placeholder ) + '"'; | |
| 1451 | + } | |
| 1452 | + | |
| 1453 | + if ( item.allow_multiple ) { | |
| 1454 | + multiple = ' multiple'; | |
| 1455 | + fieldGroupClasses += ' ui-e-field-type-' + item.field_type + '-multiple'; | |
| 1456 | + } | |
| 1457 | + | |
| 1458 | + switch ( item.field_type ) { | |
| 1459 | + case 'html': | |
| 1460 | + inputField = item.field_html; | |
| 1461 | + break; | |
| 1462 | + | |
| 1463 | + case 'textarea': | |
| 1464 | + 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>'; | |
| 1465 | + break; | |
| 1466 | + | |
| 1467 | + case 'select': | |
| 1468 | + if ( options ) { | |
| 1469 | + var size = ''; | |
| 1470 | + if ( item.allow_multiple && item.select_size ) { | |
| 1471 | + size = ' size="' + item.select_size + '"'; | |
| 1472 | + } | |
| 1473 | + inputField = '<div class="ui-e-field ui-e-field-select ui-e-field-subgroup' + itemClasses + '">'; | |
| 1474 | + inputField += '<select class="ui-e-field-textual" name="form_field_' + i + '" id="form_field_' + i + '" ' + required + multiple + size + ' >'; | |
| 1475 | + for ( var x in options ) { | |
| 1476 | + var option_value = options[ x ]; | |
| 1477 | + var option_label = options[ x ]; | |
| 1478 | + var option_id = 'form_field_option' + i + x; | |
| 1479 | + | |
| 1480 | + if ( options[ x ].indexOf( '|' ) > -1 ) { | |
| 1481 | + var label_value = options[ x ].split( '|' ); | |
| 1482 | + option_label = label_value[0]; | |
| 1483 | + option_value = label_value[1]; | |
| 1484 | + } | |
| 1485 | + | |
| 1486 | + view.addRenderAttribute( option_id, 'value', option_value ); | |
| 1487 | + if ( item.field_value.split( ',' ) .indexOf( option_value ) ) { | |
| 1488 | + view.addRenderAttribute( option_id, 'selected', 'selected' ); | |
| 1489 | + } | |
| 1490 | + inputField += '<option ' + view.getRenderAttributeString( option_id ) + '>' + option_label + '</option>'; | |
| 1491 | + } | |
| 1492 | + inputField += '</select></div>'; | |
| 1493 | + } | |
| 1494 | + break; | |
| 1495 | + | |
| 1496 | + case 'radio': | |
| 1497 | + case 'checkbox': | |
| 1498 | + if ( options ) { | |
| 1499 | + var multiple = ''; | |
| 1500 | + | |
| 1501 | + if ( 'checkbox' === item.field_type && options.length > 1 ) { | |
| 1502 | + multiple = '[]'; | |
| 1503 | + } | |
| 1504 | + | |
| 1505 | + inputField = '<div class="ui-e-field-subgroup ' + itemClasses + ' ' + _.escape( item.inline_list ) + '">'; | |
| 1506 | + | |
| 1507 | + for ( var x in options ) { | |
| 1508 | + var option_value = options[ x ]; | |
| 1509 | + var option_label = options[ x ]; | |
| 1510 | + var option_id = 'form_field_' + item.field_type + i + x; | |
| 1511 | + if ( options[x].indexOf( '|' ) > -1 ) { | |
| 1512 | + var label_value = options[x].split( '|' ); | |
| 1513 | + option_label = label_value[0]; | |
| 1514 | + option_value = label_value[1]; | |
| 1515 | + } | |
| 1516 | + | |
| 1517 | + view.addRenderAttribute( option_id, { | |
| 1518 | + value: option_value, | |
| 1519 | + type: item.field_type, | |
| 1520 | + id: 'form_field_' + i + '-' + x, | |
| 1521 | + name: 'form_field_' + i + multiple | |
| 1522 | + } ); | |
| 1523 | + | |
| 1524 | + if ( option_value === item.field_value ) { | |
| 1525 | + view.addRenderAttribute( option_id, 'checked', 'checked' ); | |
| 1526 | + } | |
| 1527 | + | |
| 1528 | + inputField += '<span class="ui-e-field-option"><input ' + view.getRenderAttributeString( option_id ) + ' ' + required + '> '; | |
| 1529 | + inputField += '<label for="form_field_' + i + '-' + x + '">' + option_label + '</label></span>'; | |
| 1530 | + | |
| 1531 | + } | |
| 1532 | + | |
| 1533 | + inputField += '</div>'; | |
| 1534 | + } | |
| 1535 | + break; | |
| 1536 | + | |
| 1537 | + case 'acceptance' : | |
| 1538 | + var checked = ''; | |
| 1539 | + if(item.checked_by_default == 'yes') { | |
| 1540 | + checked = ' checked'; | |
| 1541 | + } | |
| 1542 | + inputField += '<div class="ui-e-field-subgroup">'; | |
| 1543 | + inputField += '<input type="checkbox" class="ui-e-field ui-e-acceptance-field" name="form_field_' + i + '" id="form_field_' + i + '" ' + required + checked + '>'; | |
| 1544 | + inputField += '<label for="form_field_' + i + '">' + item.acceptance_text + '</label>'; | |
| 1545 | + inputField += '</div>'; | |
| 1546 | + break; | |
| 1547 | + | |
| 1548 | + case 'recaptcha' : | |
| 1549 | + case 'recaptcha_v3' : | |
| 1550 | + inputField = '<input type="hidden" name="recaptcha"/> <div id="ui-e-recaptcha"></div>'; | |
| 1551 | + break; | |
| 1552 | + | |
| 1553 | + default: | |
| 1554 | + itemClasses = 'ui-e-field-textual ' + itemClasses; | |
| 1555 | + 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 + ' >'; | |
| 1556 | + break; | |
| 1557 | + } | |
| 1558 | + | |
| 1559 | + if ( inputField ) { | |
| 1560 | + #> | |
| 1561 | + <div class="{{ fieldGroupClasses }}"> | |
| 1562 | + | |
| 1563 | + <# if ( printLabel && item.field_label ) { #> | |
| 1564 | + <label class="ui-e-field-label" for="form_field_{{ i }}" {{{ labelVisibility }}}>{{{ item.field_label }}}</label> | |
| 1565 | + <# } #> | |
| 1566 | + | |
| 1567 | + {{{ inputField }}} | |
| 1568 | + </div> | |
| 1569 | + <# | |
| 1570 | + } | |
| 1571 | + } | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + var buttonClasses = 'ui-e-field-group elementor-column ui-e-field-type-submit e-form__buttons'; | |
| 1575 | + | |
| 1576 | + buttonClasses += ' elementor-col-' + ( ( '' !== settings.button_width ) ? settings.button_width : '100' ); | |
| 1577 | + | |
| 1578 | + if ( settings.button_width_tablet ) { | |
| 1579 | + buttonClasses += ' elementor-md-' + settings.button_width_tablet; | |
| 1580 | + } | |
| 1581 | + | |
| 1582 | + if ( settings.button_width_mobile ) { | |
| 1583 | + buttonClasses += ' elementor-sm-' + settings.button_width_mobile; | |
| 1584 | + } | |
| 1585 | + | |
| 1586 | + var iconHTML = elementor.helpers.renderIcon( view, settings.selected_button_icon, { 'aria-hidden': true }, 'i' , 'object' ) | |
| 1587 | + #> | |
| 1588 | + | |
| 1589 | + <div class="{{ buttonClasses }}"> | |
| 1590 | + <button id="{{ settings.button_css_id }}" type="submit" class="elementor-button elementor-animation-{{ settings.button_hover_animation }}"> | |
| 1591 | + <span> | |
| 1592 | + <# if ( settings.button_icon || settings.selected_button_icon ) { #> | |
| 1593 | + <span class="ui-e-icon ui-e-align-{{ settings.button_icon_align }}"> | |
| 1594 | + <# if ( iconHTML && iconHTML.rendered && ( ! settings.button_icon ) ) { #> | |
| 1595 | + {{{ iconHTML.value }}} | |
| 1596 | + <# } else { #> | |
| 1597 | + <i class="{{ settings.button_icon }}" aria-hidden="true"></i> | |
| 1598 | + <# } #> | |
| 1599 | + <span class="elementor-screen-only"><?php echo esc_html__( 'Submit', 'uicore-elements' ); ?></span> | |
| 1600 | + </span> | |
| 1601 | + <# } #> | |
| 1602 | + | |
| 1603 | + <# if ( settings.button_text ) { #> | |
| 1604 | + <span class="ui-e-text">{{{ settings.button_text }}}</span> | |
| 1605 | + <# } #> | |
| 1606 | + </span> | |
| 1607 | + </button> | |
| 1608 | + </div> | |
| 1609 | + </div> | |
| 1610 | + <div class="ui-e-message elementor-hidden"> | |
| 1611 | + <# | |
| 1612 | + const success = settings.success_message; | |
| 1613 | + const error = settings.error_message; | |
| 1614 | + #> | |
| 1615 | + <span class="success">{{{ success }}}</span> <br> | |
| 1616 | + <span class="error">{{{ error }}}</span> | |
| 1617 | + </div> | |
| 1618 | + </form> | |
| 1619 | + <?php | |
| 1620 | + } | |
| 1621 | + */ | |
| 1399 | 1622 | } |
| 1400 | 1623 | \Elementor\Plugin::instance()->widgets_manager->register(new ContactForm()); |