PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.3
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.3
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 / FluentConversational / Classes / Elements / WelcomeScreen.php

WelcomeScreen.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.3, at app/Services/FluentConversational/Classes/Elements/WelcomeScreen.php

149 lines 5.1 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\FluentConversational\Classes\Elements;
4
5 defined('ABSPATH') or die;
6
7 use FluentForm\App\Services\FormBuilder\BaseFieldManager;
8 use FluentForm\Framework\Helpers\ArrayHelper;
9
10 class WelcomeScreen extends BaseFieldManager
11 {
12 public function __construct()
13 {
14 parent::__construct(
15 'welcome_screen',
16 'Welcome Screen',
17 ['welcome', 'screen', 'content'],
18 'general'
19 );
20
21 add_filter('fluentform/conversational_editor_elements', [$this, 'pushConversationalComponent'], 10, 1);
22 }
23
24 public function getComponent()
25 {
26 return []; // we don't this in normal forms
27 }
28
29 public function pushConversationalComponent($components)
30 {
31 $components['advanced'][] = [
32 'index' => 50,
33 'element' => 'welcome_screen',
34 'attributes' => [],
35 'settings' => [
36 'label' => __('Welcome Heading', 'fluentform'),
37 'description' => __('Sub Heading', 'fluentform'),
38 'align' => 'center',
39 'conditional_logics' => [],
40 'button_style' => 'default',
41 'button_size' => 'md',
42 'container_class' => '',
43 'current_state' => 'normal_styles',
44 'background_color' => 'rgb(64, 158, 255)',
45 'color' => 'rgb(255, 255, 255)',
46 'hover_styles' => (object) [
47 'backgroundColor' => '#ffffff',
48 'borderColor' => '#1a7efb',
49 'color' => '#1a7efb',
50 'borderRadius' => '',
51 'minWidth' => '',
52 ],
53 'normal_styles' => (object) [
54 'backgroundColor' => '#1a7efb',
55 'borderColor' => '#1a7efb',
56 'color' => '#ffffff',
57 'borderRadius' => '',
58 'minWidth' => '',
59 ],
60 'button_ui' => (object) [
61 'text' => 'Start Here',
62 'type' => 'default',
63 ],
64 ],
65 'editor_options' => [
66 'title' => __('Welcome Screen', 'fluentform'),
67 'icon_class' => 'dashicons dashicons-align-wide',
68 'template' => 'welcomeScreen',
69 ],
70 'style_pref' => [
71 'layout' => 'default',
72 'media' => '',
73 'brightness' => 0,
74 'alt_text' => '',
75 'media_x_position' => 50,
76 'media_y_position' => 50,
77 ],
78 ];
79
80 return $components;
81 }
82
83 public function getGeneralEditorElements()
84 {
85 return [
86 'label',
87 'description',
88 'align',
89 'btn_text',
90 'button_ui',
91 ];
92 }
93
94 public function getAdvancedEditorElements()
95 {
96 return [
97 'button_style',
98 'button_size',
99 ];
100 }
101
102 public function pushFormInputType($types)
103 {
104 return $types;
105 }
106
107 public function render($data, $form)
108 {
109 $elementName = $data['element'];
110
111 $app = wpFluentForm();
112
113 $data = apply_filters_deprecated(
114 'fluentform_rendering_field_data_' . $elementName,
115 [
116 $data,
117 $form
118 ],
119 FLUENTFORM_FRAMEWORK_UPGRADE,
120 'fluentform/rendering_field_data_' . $elementName,
121 'Use fluentform/rendering_field_data_' . $elementName . ' instead of fluentform_rendering_field_data_' . $elementName
122 );
123
124 $data = $app->applyFilters('fluentform/rendering_field_data_' . $elementName, $data, $form);
125
126 $alignment = ArrayHelper::get($data, 'settings.align');
127 if ($alignment) {
128 if (empty($data['attributes']['class'])) {
129 $data['attributes']['class'] = '';
130 }
131 $data['attributes']['class'] .= ' ff_' . $alignment;
132 }
133
134 $hasConditions = $this->hasConditions($data) ? 'has-conditions ' : '';
135 $cls = trim($this->getDefaultContainerClass() . ' ' . $hasConditions);
136 $data['attributes']['class'] = $cls . ' ff-el-section-break ' . $data['attributes']['class'];
137 $data['attributes']['class'] = trim($data['attributes']['class']);
138 $atts = $this->buildAttributes(
139 ArrayHelper::except($data['attributes'], 'name')
140 );
141 $html = "<div {$atts}>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in.
142 $html .= "<h3 class='ff-el-section-title'>" . fluentform_sanitize_html($data['settings']['label']) . '</h3>';
143 $html .= "<div class='ff-section_break_desk'>" . fluentform_sanitize_html($data['settings']['description']) . '</div>';
144 $html .= '</div>';
145
146 $this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form);
147 }
148 }
149