PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
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
← All changes | app/Services/FormBuilder/Components/SelectCountry.php +60 -28 3.6.656.2.14 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2
3 3 namespace FluentForm\App\Services\FormBuilder\Components;
4 4
5 -use FluentForm\App;
6 5 use FluentForm\App\Helpers\Helper;
7 6 use FluentForm\Framework\Helpers\ArrayHelper;
8 7
9 8 class SelectCountry extends BaseComponent
@@ -9,29 +8,41 @@
9 8 class SelectCountry extends BaseComponent
10 9 {
11 10 /**
12 11 * Compile and echo the html element
13 - * @param array $data [element data]
14 - * @param stdClass $form [Form Object]
15 - * @return viod
12 + *
13 + * @param array $data [element data]
14 + * @param \stdClass $form [Form Object]
15 + *
16 + * @return void
16 17 */
17 18 public function compile($data, $form)
18 19 {
19 20 $elementName = $data['element'];
20 - $data = apply_filters('fluenform_rendering_field_data_' . $elementName, $data, $form);
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);
21 32
22 33 $data = $this->loadCountries($data);
23 - $defaultValues = (array)$this->extractValueFromAttributes($data);
24 - $data['attributes']['class'] = trim('ff-el-form-control ' . $data['attributes']['class']);
34 + $defaultValues = (array) $this->extractValueFromAttributes($data);
35 + $data['attributes']['class'] = trim('ff-el-form-control ' . ArrayHelper::get($data, 'attributes.class', ''));
25 36 $data['attributes']['id'] = $this->makeElementId($data, $form);
26 - $isSearchable = ArrayHelper::get ($data,'settings.enable_select_2');
27 - if($isSearchable == 'yes'){
37 + $isSearchable = ArrayHelper::get($data, 'settings.enable_select_2');
38 + if ('yes' == $isSearchable) {
28 39 wp_enqueue_script('choices');
29 40 wp_enqueue_style('ff_choices');
30 41 $data['attributes']['class'] .= ' ff_has_multi_select';
31 42 }
32 43
33 - if ($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
44 + if ($tabIndex = Helper::getNextTabIndex()) {
34 45 $data['attributes']['tabindex'] = $tabIndex;
35 46 }
36 47
37 48 $placeholder = ArrayHelper::get($data, 'attributes.placeholder');
@@ -37,18 +48,25 @@
37 48 $placeholder = ArrayHelper::get($data, 'attributes.placeholder');
38 49
39 50 $activeList = ArrayHelper::get($data, 'settings.country_list.active_list');
40 51
41 - $elMarkup = "<select " . $this->buildAttributes($data['attributes']) . "><option value=''>" . $placeholder . "</option>";
52 + $ariaRequired = 'false';
53 + if (ArrayHelper::get($data, 'settings.validation_rules.required.value')) {
54 + $ariaRequired = 'true';
55 + }
42 56
43 - if ($activeList == 'priority_based') {
57 + $elMarkup = '<select ' . $this->buildAttributes($data['attributes']) . "aria-invalid='false' aria-required=$ariaRequired><option value=''>" . wp_strip_all_tags($placeholder) . '</option>';
58 +
59 + if ('priority_based' == $activeList) {
44 60 $selectCountries = ArrayHelper::get($data, 'settings.country_list.priority_based', []);
45 61 $priorityCountries = $this->getSelectedCountries($selectCountries);
46 62 $primaryListLabel = ArrayHelper::get($data, 'settings.primary_label');
47 63 $otherListLabel = ArrayHelper::get($data, 'settings.other_label');
48 - $elMarkup .= '<optgroup label="' . $primaryListLabel . '">';
64 + // SECURITY (FINDING-12): esc_attr (not just strip_all_tags, which leaves quotes) the
65 + // optgroup labels before interpolating them into the double-quoted label attribute.
66 + $elMarkup .= '<optgroup label="' . esc_attr($primaryListLabel) . '">';
49 67 $elMarkup .= $this->buildOptions($priorityCountries, $defaultValues);
50 - $elMarkup .= '</optgroup><optgroup label="' . $otherListLabel . '">';
68 + $elMarkup .= '</optgroup><optgroup label="' . esc_attr($otherListLabel) . '">';
51 69 $elMarkup .= $this->buildOptions($data['options'], $defaultValues);
52 70 $elMarkup .= '</optgroup>';
53 71 } else {
54 72 $elMarkup .= $this->buildOptions($data['options'], $defaultValues);
@@ -53,32 +71,46 @@
53 71 } else {
54 72 $elMarkup .= $this->buildOptions($data['options'], $defaultValues);
55 73 }
56 74
57 - $elMarkup .= "</select>";
75 + $elMarkup .= '</select>';
58 76
59 77 $html = $this->buildElementMarkup($elMarkup, $data, $form);
60 - echo apply_filters('fluenform_rendering_field_html_' . $elementName, $html, $data, $form);
78 +
79 + $html = apply_filters_deprecated(
80 + 'fluentform_rendering_field_html_' . $elementName,
81 + [
82 + $html,
83 + $data,
84 + $form
85 + ],
86 + FLUENTFORM_FRAMEWORK_UPGRADE,
87 + 'fluentform/rendering_field_html_' . $elementName,
88 + 'Use fluentform/rendering_field_html_' . $elementName . ' instead of fluentform_rendering_field_html_' . $elementName
89 + );
90 +
91 + $this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form);
61 92 }
62 -
63 93 /**
64 94 * Load countt list from file
95 + *
65 96 * @param array $data
97 + *
66 98 * @return array
67 99 */
68 - protected function loadCountries($data)
100 + public function loadCountries($data)
69 101 {
70 - $app = App::make();
71 - $data['options'] = array();
102 + $app = wpFluentForm();
103 + $data['options'] = [];
72 104 $activeList = ArrayHelper::get($data, 'settings.country_list.active_list');
73 - $countries = $app->load($app->appPath('Services/FormBuilder/CountryNames.php'));
105 + $countries = getFluentFormCountryList();
74 106
75 - if ($activeList == 'visible_list') {
107 + if ('visible_list' == $activeList) {
76 108 $selectCountries = ArrayHelper::get($data, 'settings.country_list.' . $activeList, []);
77 109 foreach ($selectCountries as $value) {
78 110 $data['options'][$value] = $countries[$value];
79 111 }
80 - } elseif ($activeList == 'hidden_list' || $activeList == 'priority_based') {
112 + } elseif ('hidden_list' == $activeList || 'priority_based' == $activeList) {
81 113 $data['options'] = $countries;
82 114 $selectCountries = ArrayHelper::get($data, 'settings.country_list.' . $activeList, []);
83 115 foreach ($selectCountries as $value) {
84 116 unset($data['options'][$value]);
@@ -97,9 +129,11 @@
97 129 }
98 130
99 131 /**
100 132 * Build options for country list/select
133 + *
101 134 * @param array $options
135 + *
102 136 * @return string/html [compiled options]
103 137 */
104 138 protected function buildOptions($options, $defaultValues = [])
105 139 {
@@ -109,18 +143,17 @@
109 143 $selected = 'selected';
110 144 } else {
111 145 $selected = '';
112 146 }
113 - $opts .= "<option value='{$value}' {$selected}>{$label}</option>";
147 + $opts .= "<option value='" . esc_attr($value) . "' {$selected}>" . esc_attr($label) . '</option>';
114 148 }
115 149 return $opts;
116 150 }
117 151
118 - protected function getSelectedCountries($keys = [])
152 + public function getSelectedCountries($keys = [])
119 153 {
120 - $app = App::make();
121 154 $options = [];
122 - $countries = $app->load($app->appPath('Services/FormBuilder/CountryNames.php'));
155 + $countries = getFluentFormCountryList();
123 156 foreach ($keys as $value) {
124 157 $options[$value] = $countries[$value];
125 158 }
126 159
@@ -127,6 +160,5 @@
127 160 $options = array_flip($options);
128 161 ksort($options);
129 162 return array_flip($options);
130 163 }
131 -
132 164 }