| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Services\FormBuilder\Components; |
| 4 |
|
| 5 |
use FluentForm\Framework\Helpers\ArrayHelper; |
| 6 |
|
| 7 |
class SectionBreak extends BaseComponent |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Compile and echo the html element |
| 11 |
* |
| 12 |
* @param array $data [element data] |
| 13 |
* @param \stdClass $form [Form Object] |
| 14 |
* |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
public function compile($data, $form) |
| 18 |
{ |
| 19 |
$elementName = $data['element']; |
| 20 |
$data = apply_filters_deprecated( |
| 21 |
'fluentform_rendering_field_data_' . $elementName, |
| 22 |
[ |
| 23 |
$data, |
| 24 |
$form |
| 25 |
], |
| 26 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 27 |
'fluentform/rendering_field_data_' . $elementName, |
| 28 |
'Use fluentform/rendering_field_data_' . $elementName . ' instead of fluentform_rendering_field_data_' . $elementName |
| 29 |
); |
| 30 |
$data = apply_filters('fluentform/rendering_field_data_' . $elementName, $data, $form); |
| 31 |
|
| 32 |
$alignment = ArrayHelper::get($data, 'settings.align'); |
| 33 |
if ($alignment) { |
| 34 |
$data['attributes']['class'] .= ' ff_' . $alignment; |
| 35 |
} |
| 36 |
|
| 37 |
$hasConditions = $this->hasConditions($data) ? 'has-conditions ' : ''; |
| 38 |
$cls = trim($this->getDefaultContainerClass() . ' ' . $hasConditions); |
| 39 |
$data['attributes']['class'] = $cls . ' ff-el-section-break ' . $data['attributes']['class']; |
| 40 |
$data['attributes']['class'] = trim($data['attributes']['class']); |
| 41 |
$atts = $this->buildAttributes( |
| 42 |
ArrayHelper::except($data['attributes'], 'name') |
| 43 |
); |
| 44 |
$html = "<div {$atts}>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in. |
| 45 |
$html .= "<h3 class='ff-el-section-title'>" . fluentform_sanitize_html($data['settings']['label']) . '</h3>'; |
| 46 |
$html .= "<div class='ff-section_break_desk'>" . fluentform_sanitize_html($data['settings']['description']) . '</div>'; |
| 47 |
$html .= '<hr />'; |
| 48 |
$html .= '</div>'; |
| 49 |
|
| 50 |
$html = apply_filters_deprecated( |
| 51 |
'fluentform_rendering_field_html_' . $elementName, |
| 52 |
[ |
| 53 |
$html, |
| 54 |
$data, |
| 55 |
$form |
| 56 |
], |
| 57 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 58 |
'fluentform/rendering_field_html_' . $elementName, |
| 59 |
'Use fluentform/rendering_field_html_' . $elementName . ' instead of fluentform_rendering_field_html_' . $elementName |
| 60 |
); |
| 61 |
|
| 62 |
$this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form); |
| 63 |
} |
| 64 |
} |
| 65 |
|