PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.13
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.13
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / FormBuilder / Components / TermsAndConditions.php

TermsAndConditions.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.13, at app/Services/FormBuilder/Components/TermsAndConditions.php

109 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Services\FormBuilder\Components;
4
5 use FluentForm\App\Helpers\Helper;
6 use FluentForm\Framework\Helpers\ArrayHelper;
7
8 class TermsAndConditions extends BaseComponent
9 {
10 /**
11 * Compile and echo the html element
12 *
13 * @param array $data [element data]
14 * @param \stdClass $form [Form Object]
15 *
16 * @return void
17 */
18 public function compile($data, $form)
19 {
20 $elementName = $data['element'];
21 $data = apply_filters_deprecated(
22 'fluentform_rendering_field_data_' . $elementName,
23 [
24 $data,
25 $form
26 ],
27 FLUENTFORM_FRAMEWORK_UPGRADE,
28 'fluentform/rendering_field_data_' . $elementName,
29 'Use fluentform/rendering_field_data_' . $elementName . ' instead of fluentform_rendering_field_data_' . $elementName
30 );
31 $data = apply_filters('fluentform/rendering_field_data_' . $elementName, $data, $form);
32
33 $hasConditions = $this->hasConditions($data) ? 'has-conditions ' : '';
34
35 $cls = trim(
36 $this->getDefaultContainerClass()
37 . ' ' . @$data['settings']['container_class']
38 . ' ' . $hasConditions
39 . ' ff-el-input--content'
40 );
41
42 $uniqueId = $this->getUniqueId($data['attributes']['name']);
43
44 $data['attributes']['id'] = $uniqueId;
45 $data['attributes']['class'] = trim(
46 'ff-el-form-check-input ' .
47 ArrayHelper::get($data, 'attributes.class', '')
48 );
49
50 if ($tabIndex = Helper::getNextTabIndex()) {
51 $data['attributes']['tabindex'] = $tabIndex;
52 }
53
54 $atts = $this->buildAttributes($data['attributes']);
55 $checkbox = '';
56
57 $ariaRequired = 'false';
58 if (ArrayHelper::get($data, 'settings.validation_rules.required.value')) {
59 $ariaRequired = 'true';
60 }
61
62 if ($data['settings']['has_checkbox']) {
63 $checkbox = "<span class='ff_tc_checkbox'><input {$atts} value='on' aria-invalid='false' aria-required={$ariaRequired}></span>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in.
64 }
65
66 $link_count = substr_count($data['settings']['tnc_html'], '<a ');
67 if($link_count > 0){
68 $ariaLabel = sprintf(
69 /* translators: 1: Terms title or HTML label, 2: Number of links in the terms text. */
70 esc_html(_n(
71 'Terms and Conditions: %1$s Contains %2$d link. Use tab navigation to review.',
72 'Terms and Conditions: %1$s Contains %2$d links. Use tab navigation to review.',
73 $link_count,
74 'fluentform'
75 )),
76 $data['settings']['tnc_html'],
77 $link_count
78 );
79 }else{
80 $ariaLabel = wp_strip_all_tags($data['settings']['tnc_html']);
81 }
82
83
84 $ariaLabel = wp_strip_all_tags($ariaLabel);
85 $ariaLabel = esc_attr($ariaLabel);
86 $html = "<div class='" . esc_attr($cls) . "'>";
87 $html .= "<div class='ff-el-form-check ff-el-tc'>";
88 $html .= "<label aria-label='{$ariaLabel}' class='ff-el-form-check-label ff_tc_label' for={$uniqueId}>";
89 $html .= "{$checkbox} <div class='ff_t_c'>" . fluentform_sanitize_html($data['settings']['tnc_html']) . '</div>';
90 $html .= '</label>';
91 $html .= '</div>';
92 $html .= '</div>';
93
94 $html = apply_filters_deprecated(
95 'fluentform_rendering_field_html_' . $elementName,
96 [
97 $html,
98 $data,
99 $form
100 ],
101 FLUENTFORM_FRAMEWORK_UPGRADE,
102 'fluentform/rendering_field_html_' . $elementName,
103 'Use fluentform/rendering_field_html_' . $elementName . ' instead of fluentform_rendering_field_html_' . $elementName
104 );
105
106 $this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form);
107 }
108 }
109