PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | views/conversational-form.php +28 -208 3.3.1 → 2.15.3 View file →
@@ -1,51 +1,8 @@
1 1 <?php
2 -
3 -// This file is included via Render::view() using extract(); all variables below are in the calling method's local scope, not global namespace.
4 -
5 -use BitCode\BitForm\Core\Util\EscapingHelper;
6 -
7 -if (!defined('ABSPATH')) {
2 +if (!defined('ABSPATH') && !defined('BITFORMS_ASSET_URI')) {
8 3 exit;
9 4 }
10 -if (!defined('BITFORMS_ASSET_URI')) {
11 - exit;
12 -}
13 -
14 -$formUpdateVersion = get_option('bitform_form_update_version');
15 -$formIdSafe = sanitize_key((string) $formID);
16 -
17 -$baseCSSPath = "/form-styles/bitform-{$formID}.css";
18 -$baseConversationalCSSPath = "/form-styles/bitform-conversational-{$formID}.css";
19 -$customCSSPath = "/form-styles/bitform-custom-{$formID}.css";
20 -$standaloneCSSPath = "/form-styles/bitform-standalone-{$formID}.css";
21 -
22 -wp_register_style('bitform-conversational-base-' . $formIdSafe, BITFORMS_UPLOAD_BASE_URL . $baseCSSPath, [], $formUpdateVersion);
23 -wp_register_style('bitform-conversational-' . $formIdSafe, BITFORMS_UPLOAD_BASE_URL . $baseConversationalCSSPath, [], $formUpdateVersion);
24 -wp_enqueue_style('bitform-conversational-base-' . $formIdSafe);
25 -wp_enqueue_style('bitform-conversational-' . $formIdSafe);
26 -
27 -if (file_exists(BITFORMS_CONTENT_DIR . $customCSSPath)) {
28 - wp_register_style('bitform-conversational-custom-' . $formIdSafe, BITFORMS_UPLOAD_BASE_URL . $customCSSPath, [], $formUpdateVersion);
29 - wp_enqueue_style('bitform-conversational-custom-' . $formIdSafe);
30 -}
31 -
32 -if (file_exists(BITFORMS_CONTENT_DIR . $standaloneCSSPath)) {
33 - wp_register_style('bitform-conversational-standalone-' . $formIdSafe, BITFORMS_UPLOAD_BASE_URL . $standaloneCSSPath, [], $formUpdateVersion);
34 - wp_enqueue_style('bitform-conversational-standalone-' . $formIdSafe);
35 -}
36 -
37 -if (isset($font) && '' !== $font) {
38 - wp_register_style('bitform-conversational-font-' . $formIdSafe, $font, [], $formUpdateVersion);
39 - wp_enqueue_style('bitform-conversational-font-' . $formIdSafe);
40 -}
41 -
42 -$conversationalJsPath = BITFORMS_UPLOAD_BASE_URL . '/form-scripts/bitform-conversational-' . $formID . '.js';
43 -wp_register_script('bitform-conversational-' . $formIdSafe, $conversationalJsPath, [], $formUpdateVersion, true);
44 -wp_enqueue_script('bitform-conversational-' . $formIdSafe);
45 -if (isset($bfGlobals) && '' !== $bfGlobals) {
46 - wp_add_inline_script('bitform-conversational-' . $formIdSafe, (string) $bfGlobals, 'before');
47 -}
48 5 ?>
49 6
50 7 <!DOCTYPE html>
51 8 <html lang="en">
@@ -71,179 +28,42 @@
71 28 width: 100%;
72 29 }
73 30 }
74 31 </style>
32 + <?php
33 + $baseCSSPath = "/form-styles/bitform-{$formID}.css";
34 +$baseConversationalCSSPath = "/form-styles/bitform-conversational-{$formID}.css";
35 +$customCSSPath = "/form-styles/bitform-custom-{$formID}.css";
36 +$standaloneCSSPath = "/form-styles/bitform-standalone-{$formID}.css";
37 +?>
38 + <link rel="stylesheet" href="<?php echo esc_url(BITFORMS_UPLOAD_BASE_URL . $baseCSSPath) ?>" />
39 + <link rel="stylesheet" href="<?php echo esc_url(BITFORMS_UPLOAD_BASE_URL . $baseConversationalCSSPath) ?>" />
40 +
41 + <?php if (file_exists(BITFORMS_CONTENT_DIR . $customCSSPath)) : ?>
42 + <link rel="stylesheet" href="<?php echo esc_url(BITFORMS_UPLOAD_BASE_URL . $customCSSPath) ?>" />
43 + <?php endif; ?>
44 +
45 + <?php if (file_exists(BITFORMS_CONTENT_DIR . $standaloneCSSPath)) : ?>
46 + <link rel="stylesheet" href="<?php echo esc_url(BITFORMS_UPLOAD_BASE_URL . $standaloneCSSPath) ?>" />
47 + <?php endif; ?>
48 +
75 49 <?php if (isset($font) && '' !== $font) : ?>
76 50 <link rel="preconnect" href="https://fonts.googleapis.com">
77 51 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
52 + <link rel="stylesheet" href="<?php echo esc_url($font) ?>" />
78 53 <?php endif; ?>
79 - <?php
80 - wp_enqueue_emoji_styles();
81 - wp_print_styles();
82 - ?>
54 +
83 55 </head>
84 56
85 57 <body class="bit-conversational-form">
58 + <?php echo $formHTML?>
59 + <script>
86 60 <?php
87 - // Fallback config for when an optimizer defers or drops the inline script.
88 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built by buildFormConfigTag(), JSON_HEX_* escaped.
89 - echo isset($configTag) ? $configTag : '';
90 - ?>
91 - <?php echo wp_kses($formHTML, EscapingHelper::getFormAllowedHtml(isset($formContent) ? $formContent : null)); ?>
92 - <?php if (!empty($isPreview)) : ?>
93 - <style>.bc-live-hidden { display: none !important; }</style>
94 - <script>window.bf_preview_mode = true;</script>
95 - <?php endif; ?>
96 - <?php wp_print_scripts(); ?>
97 - <?php if (!empty($isPreview)) : ?>
98 - <script>
99 - (function() {
100 - var FID = <?php echo (int) $formID; ?>;
101 - var pfx = 'bc' + FID + '-';
102 -
103 - function q(sel) { return document.querySelector('.' + pfx + sel); }
104 - function qa(sel) { return document.querySelectorAll('.' + pfx + sel); }
105 - function toggle(el, show) { if (el) el.classList.toggle('bc-live-hidden', !show); }
106 - function setTxt(el, val) { if (el && val !== undefined && val !== null) el.textContent = val; }
107 -
108 - var LAYOUT_CLASSES = ['normal-layout', 'compact-left-layout', 'compact-right-layout', 'padding-left-layout', 'padding-right-layout', 'centered-card-layout'];
109 -
110 - function applyLiveSettings(settings) {
111 - var nav = settings.navigationSettings || {};
112 - var stl = settings.stepListObject || {};
113 - var all = stl.allSteps || {};
114 -
115 - // Visibility toggles
116 - toggle(q('nav-wrpr'), nav.show !== false);
117 - toggle(q('progress-lbl-wrpr'), !!nav.showProgressLabel);
118 - toggle(q('progress-bar-wrpr'), !!nav.showProgressBar);
119 - toggle(q('branding-wrpr'), nav.showBranding !== false);
120 - toggle(q('nav-btn-wrpr'), !!nav.showNavigateBtn);
121 -
122 - // Welcome page text content
123 - var wp = stl.welcomePage || {};
124 - var titleEl = document.querySelector('.' + pfx + 'welcome-title h2');
125 - setTxt(titleEl, wp.title);
126 - // Welcome page rich content (everything between title and button wrapper)
127 - var welcomeContentEl = q('welcome-content');
128 - if (welcomeContentEl && wp.content !== undefined) {
129 - // Find the text node area — insert content after title, before button wrapper
130 - var btnWrpr = welcomeContentEl.querySelector('.' + pfx + 'step-btn-wrpr');
131 - var titleWrpr = welcomeContentEl.querySelector('.' + pfx + 'welcome-title');
132 - // Remove existing text nodes / content nodes between title and button
133 - var children = Array.from(welcomeContentEl.childNodes);
134 - children.forEach(function(node) {
135 - if (node !== titleWrpr && node !== btnWrpr) {
136 - welcomeContentEl.removeChild(node);
137 - }
138 - });
139 - var tempDiv = document.createElement('div');
140 - tempDiv.innerHTML = wp.content || '';
141 - var frag = document.createDocumentFragment();
142 - while (tempDiv.firstChild) frag.appendChild(tempDiv.firstChild);
143 - welcomeContentEl.insertBefore(frag, btnWrpr);
144 - }
145 -
146 - // Per-step: button text, hints, layout, image, background
147 - var wrappers = qa('step-wrapper');
148 - var fieldKeys = Object.keys(stl).filter(function(k) { return k !== 'allSteps' && k !== 'welcomePage'; });
149 - var welcomeOffset = (wp.enable) ? 1 : 0;
150 -
151 - Array.prototype.forEach.call(wrappers, function(wrapper, idx) {
152 - var isWelcome = wrapper.classList.contains(pfx + 'welcome');
153 - var cfg = isWelcome ? wp : (stl[fieldKeys[idx - welcomeOffset]] || {});
154 -
155 - // Button text (start button on welcome, ok button on steps)
156 - if (isWelcome) {
157 - var startBtn = wrapper.querySelector('.' + pfx + 'start-btn');
158 - if (startBtn) {
159 - // preserve icon elements, update only text node
160 - var textNode = Array.from(startBtn.childNodes).find(function(n) { return n.nodeType === 3 && n.textContent.trim(); });
161 - if (textNode) textNode.textContent = '\n ' + (cfg.btnTxt || all.btnTxt || 'Start') + '\n ';
162 - }
163 - } else {
164 - var btnEl = wrapper.querySelector('.' + pfx + 'btn-ok');
165 - if (btnEl) {
166 - var textNode = Array.from(btnEl.childNodes).find(function(n) { return n.nodeType === 3 && n.textContent.trim(); });
167 - if (textNode) textNode.textContent = '\n ' + (cfg.btnTxt || all.btnTxt || 'OK') + '\n ';
168 - }
169 - }
170 -
171 - // Step hints — rendered as HTML (same as PHP frontend output).
172 - var hintsEl = wrapper.querySelector('.' + pfx + 'step-hints');
173 - var hintsVal = cfg.stepHints !== undefined ? cfg.stepHints : all.stepHints;
174 - if (hintsEl && hintsVal !== undefined && hintsVal !== null) hintsEl.innerHTML = hintsVal;
175 -
176 - // Layout class
177 - var layout = cfg.layout || all.layout || 'normal-layout';
178 - LAYOUT_CLASSES.forEach(function(c) { wrapper.classList.remove(c); });
179 - wrapper.classList.add(layout);
180 -
181 - // Layout image
182 - var imgEl = wrapper.querySelector('.' + pfx + 'step-img');
183 - if (imgEl) imgEl.src = cfg.layoutImage || all.layoutImage || '';
184 -
185 - // Show/hide image container based on layout
186 - var imgCntnr = wrapper.querySelector('.' + pfx + 'step-img-cntnr');
187 - if (imgCntnr) imgCntnr.style.display = (layout === 'normal-layout' || layout === 'centered-card-layout') ? 'none' : '';
188 -
189 - // Step background — Floating Card redirects to card element; others apply to wrapper.
190 - var bg = cfg.background || all.background || '';
191 - var bgColor = typeof bg === 'object' ? (bg['background-color'] || '') : bg;
192 - var cardEl = wrapper.querySelector('.' + pfx + 'step-content');
193 - var isRealColor = bgColor && bgColor !== 'transparent';
194 - if (layout === 'centered-card-layout') {
195 - wrapper.style.removeProperty('background');
196 - wrapper.style.removeProperty('background-color');
197 - if (cardEl) {
198 - // Only override CSS white fallback when user has a real color set.
199 - if (isRealColor) cardEl.style.setProperty('background-color', bgColor, 'important');
200 - else cardEl.style.removeProperty('background-color');
201 - }
202 - } else {
203 - if (cardEl) cardEl.style.removeProperty('background-color');
204 - if (isRealColor) wrapper.style.setProperty('background-color', bgColor, 'important');
205 - else wrapper.style.removeProperty('background-color');
206 - }
207 - });
208 - }
209 -
210 - var BF_ALLOWED_ORIGIN = <?php
211 - $bfParsed = wp_parse_url(get_site_url());
212 - $bfOrigin = $bfParsed['scheme'] . '://' . $bfParsed['host'];
213 - if (!empty($bfParsed['port'])) $bfOrigin .= ':' . $bfParsed['port'];
214 - echo wp_json_encode($bfOrigin);
215 - ?>;
216 - window.addEventListener('message', function(e) {
217 - if (!e.origin || e.origin !== BF_ALLOWED_ORIGIN) return;
218 - var d = e.data;
219 - if (!d || !d.__bf) return;
220 -
221 - if (d.type === 'bf:css') {
222 - var el = document.getElementById('bf-live-preview-css');
223 - if (!el) {
224 - el = document.createElement('style');
225 - el.id = 'bf-live-preview-css';
226 - document.head.appendChild(el);
227 - }
228 - el.textContent = d.css;
229 - }
230 -
231 - if (d.type === 'bf:settings') {
232 - applyLiveSettings(d.settings);
233 - }
234 -
235 - if (d.type === 'bf:navigate') {
236 - var contentIds = Object.keys(window.bf_globals || {});
237 - for (var i = 0; i < contentIds.length; i++) {
238 - var g = window.bf_globals[contentIds[i]];
239 - var inst = g && g.inits && g.inits.conversational_form;
240 - if (inst && typeof inst.goToStep === 'function') { inst.goToStep(d.stepIndex); break; }
241 - }
242 - }
243 - });
244 - })();
61 +echo $bfGlobals;
62 +$jsPath = BITFORMS_UPLOAD_BASE_URL . '/form-scripts/bitform-conversational-' . $formID . '.js';
63 +?>;
245 64 </script>
246 - <?php endif; ?>
65 + <script src="<?php echo esc_url($jsPath) ?>">
66 + </script>
247 67 </body>
248 68
249 -</html>
69 +</html>