芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/fluentform/app/Services/FormBuilder/Components/Select.php
makeElementId($data, $form); $isMulti = 'yes' == ArrayHelper::get($data, 'settings.enable_select_2'); if (ArrayHelper::get($data['attributes'], 'multiple')) { $data['attributes']['name'] = $data['attributes']['name'] . '[]'; wp_enqueue_script('choices'); wp_enqueue_style('ff_choices'); $data['attributes']['class'] .= ' ff_has_multi_select'; } elseif ($isMulti) { wp_enqueue_script('choices'); wp_enqueue_style('ff_choices'); $data['attributes']['class'] .= ' ff_has_multi_select'; } if ($maxSelection = ArrayHelper::get($data, 'settings.max_selection')) { $data['attributes']['data-max_selected_options'] = $maxSelection; } $data['attributes']['data-calc_value'] = 0; if (! isset($data['attributes']['class'])) { $data['attributes']['class'] = ''; } $data['attributes']['class'] = trim('ff-el-form-control ' . $data['attributes']['class']); if ($tabIndex = Helper::getNextTabIndex()) { $data['attributes']['tabindex'] = $tabIndex; } $defaultValues = (array) $this->extractValueFromAttributes($data); if ($dynamicValues = $this->extractDynamicValues($data, $form)) { $defaultValues = $dynamicValues; } $atts = $this->buildAttributes($data['attributes']); $options = $this->buildOptions($data, $defaultValues); $ariaRequired = 'false'; if (ArrayHelper::get($data, 'settings.validation_rules.required.value')) { $ariaRequired = 'true'; } $elMarkup = '
' . $options . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts, $options are escaped before being passed in. $html = $this->buildElementMarkup($elMarkup, $data, $form); $html = apply_filters_deprecated( 'fluentform_rendering_field_html_' . $elementName, [ $html, $data, $form ], FLUENTFORM_FRAMEWORK_UPGRADE, 'fluentform/rendering_field_html_' . $elementName, 'Use fluentform/rendering_field_html_' . $elementName . ' instead of fluentform_rendering_field_html_' . $elementName ); $this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form); } /** * Build options for select * * @param array $options * * @return string/html [compiled options] */ protected function buildOptions($data, $defaultValues) { if (! $formattedOptions = ArrayHelper::get($data, 'settings.advanced_options')) { $options = ArrayHelper::get($data, 'options', []); $formattedOptions = []; foreach ($options as $value => $label) { $formattedOptions[] = [ 'label' => $label, 'value' => $value, 'calc_value' => '', ]; } } if ('yes' == ArrayHelper::get($data, 'settings.randomize_options')) { shuffle($formattedOptions); } $opts = ''; if (! empty($data['settings']['placeholder'])) { $opts .= '
' . wp_strip_all_tags($data['settings']['placeholder']) . '
'; } elseif (! empty($data['attributes']['placeholder'])) { $opts .= '
' . wp_strip_all_tags($data['attributes']['placeholder']) . '
'; } foreach ($formattedOptions as $option) { if (in_array($option['value'], $defaultValues)) { $selected = 'selected'; } else { $selected = ''; } $atts = [ 'data-calc_value' => ArrayHelper::get($option, 'calc_value'), 'data-custom-properties' => ArrayHelper::get($option, 'calc_value'), 'value' => ArrayHelper::get($option, 'value'), 'disabled' => ArrayHelper::get($option, 'disabled') ? 'disabled' : '' ]; $opts .= '
buildAttributes($atts) . " {$selected}>" . wp_strip_all_tags($option['label']) . '
'; } return $opts; } }