_formId = $formId; $this->_conversationalSettings = $conversationalSettings; $this->_stepListObject = $this->_conversationalSettings->stepListObject; } public function getWelcomePageView() { $welcomePageSettings = $this->getMergedStepSettings('welcomePage'); $welcomeTitle = ''; $welcomePageMarkup = ''; $buttonMarkup = ''; if (!$welcomePageSettings->enable) { return ''; } if (!empty($welcomePageSettings->title)) { $welcomeTitle = '
' . "\n" . '

' . $this->escHtml($welcomePageSettings->title) . '

' . "\n" . '
'; } $startBtnPreIcn = $this->conversationalSettingsIcon($welcomePageSettings, 'startBtnPreIcn', 'btn-pre-icon', 'Start Button Pre Icon'); $startBtnSufIcn = $this->conversationalSettingsIcon($welcomePageSettings, 'startBtnSufIcn', 'btn-suf-icon', 'Start Button Suf Icon'); $startBtnText = $this->escHtml(!empty($welcomePageSettings->btnTxt) ? $welcomePageSettings->btnTxt : 'Start'); $stepHints = !empty($welcomePageSettings->stepHints) ? $this->ksesPost($welcomePageSettings->stepHints) : ''; $welcomeContent = !empty($welcomePageSettings->content) ? $this->ksesPost($welcomePageSettings->content) : ''; $buttonMarkup = '
' . "\n" . '
' . "\n" . '
' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . $stepHints . "\n" . ' ' . "\n" . '
' . "\n" . '
' . "\n" . '
'; $welcomePageMarkup = '
' . "\n" . ' ' . $welcomeTitle . "\n" . ' ' . $welcomeContent . "\n" . ' ' . $buttonMarkup . "\n" . '
'; $imageContent = $this->conversationalSettingsIcon($welcomePageSettings, 'layoutImage', 'step-img', 'Background Image'); $welcomeLayout = $welcomePageSettings->layout; $welcomeLayoutClsNames = "bc{$this->_formId}-welcome $welcomeLayout"; return $this->getStepLayout($this->_formId, $imageContent, $welcomePageMarkup, $welcomeLayout, $welcomeLayoutClsNames); } public function getNavigationView() { $navigationSettings = $this->_conversationalSettings->navigationSettings; $formId = $this->_formId; $progressLabelMarkup = ''; $progressBarMarkup = ''; $progressMarkup = ''; $brandingMarkup = ''; $navBtnMarkup = ''; $isPreview = self::$_isPreviewMode; if ($navigationSettings->showProgressLabel || $isPreview) { $hiddenCls = ($isPreview && !$navigationSettings->showProgressLabel) ? ' bc-live-hidden' : ''; $progressLabelMarkup = '
' . "\n" . ' ' . "\n" . ' ' . $this->escHtml($navigationSettings->progressLabel) . "\n" . ' ' . "\n" . '
'; } if ($navigationSettings->showProgressBar || $isPreview) { $hiddenCls = ($isPreview && !$navigationSettings->showProgressBar) ? ' bc-live-hidden' : ''; $progressBarMarkup = '
' . "\n" . '
' . "\n" . '
' . "\n" . '
' . "\n" . '
'; } if ($navigationSettings->showProgressBar || $navigationSettings->showProgressLabel || $isPreview) { $progressMarkup = '
' . "\n" . '
' . "\n" . ' ' . $progressLabelMarkup . "\n" . ' ' . $progressBarMarkup . "\n" . '
' . "\n" . '
'; } if ($navigationSettings->showBranding || $isPreview) { $hiddenCls = ($isPreview && !$navigationSettings->showBranding) ? ' bc-live-hidden' : ''; $brandingMarkup = '
' . "\n" . '
' . "\n" . '
' . "\n" . ' Powered by BitForm' . "\n" . '
' . "\n" . '
' . "\n" . '
'; } if ($navigationSettings->showNavigateBtn || $isPreview) { $hiddenCls = ($isPreview && !$navigationSettings->showNavigateBtn) ? ' bc-live-hidden' : ''; $navBtnMarkup = '
' . "\n" . '
' . "\n" . ' ' . "\n" . ' ' . "\n" . '
' . "\n" . '
'; } $navBtnContainer = ''; if ($navigationSettings->showNavigateBtn || $isPreview) { $navBtnContainer = '
' . "\n" . ' ' . $navBtnMarkup . "\n" . '
'; } if ($navigationSettings->show || $isPreview) { $hiddenCls = ($isPreview && !$navigationSettings->show) ? ' bc-live-hidden' : ''; return '
' . "\n" . '
' . "\n" . ' ' . $progressMarkup . "\n" . ' ' . $navBtnContainer . "\n" . '
' . "\n" . ' ' . $brandingMarkup . "\n" . '
'; } return ''; } public function getStepButtonsView($fieldData, $stepSettings) { $formId = $this->_formId; $isFieldRequired = !empty($fieldData->valid->req) && $fieldData->valid->req; $btnTxt = $this->escHtml($isFieldRequired ? $stepSettings->nextBtnTxt : $stepSettings->btnTxt); $btnPreIcn = $this->conversationalSettingsIcon($stepSettings, 'btnPreIcn', 'btn-pre-icon', 'Button Prefix Icon'); $btnSufIcn = $this->conversationalSettingsIcon($stepSettings, 'btnSufIcn', 'btn-suf-icon', 'Button Suffix Icon'); $hiddenClass = $isFieldRequired ? 'bc-grid-hide' : ''; $stepHints = !empty($stepSettings->stepHints) ? $this->ksesPost($stepSettings->stepHints) : ''; $dataBtnTxt = esc_attr(!empty($stepSettings->btnTxt) ? $stepSettings->btnTxt : 'Skip'); $dataNextBtnTxt = esc_attr(!empty($stepSettings->nextBtnTxt) ? $stepSettings->nextBtnTxt : 'Next'); $btnWrapperMarkup = '
' . "\n" . '
' . "\n" . '
' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . $stepHints . "\n" . ' ' . "\n" . '
' . "\n" . '
' . "\n" . '
'; return $btnWrapperMarkup; } public static function getStepLayout($formID, $imageContent, $fieldContent, $layoutName, $layoutClassNames = '') { $stepWrapperClass = esc_attr('bc' . $formID . '-step-wrapper bc' . $formID . '-step bc-step-deactive ' . $layoutClassNames); $imageContentWrapper = '
' . "\n" . ' ' . "\n" . ' ' . $imageContent . "\n" . ' ' . "\n" . '
'; $noImageLayouts = ['normal-layout', 'centered-card-layout']; $imageContentWrapper = in_array($layoutName, $noImageLayouts, true) ? '' : $imageContentWrapper; return '
' . "\n" . '
' . "\n" . ' ' . $imageContentWrapper . "\n" . '
' . "\n" . ' ' . $fieldContent . "\n" . '
' . "\n" . '
' . "\n" . '
'; } public function conversationalSettingsIcon($data, $icnPropName, $element, $alt = 'Image') { if (Helpers::property_exists_nested($data, $icnPropName, '', 1)) { $url = esc_url($data->$icnPropName); $class = esc_attr('bc' . $this->_formId . '-' . $element); $alt = esc_attr($alt); return ' '; } return ''; } public function filterConversationalAllowedFields($layout, $fields) { $ignoreFields = $this::getConversationalIgnoredFields(); $newLayouts = (object) ['lg' => []]; foreach ($layout->lg as $row) { if (!in_array($fields->{$row->i}->typ, $ignoreFields)) { $newLayouts->lg[] = $row; } } return $newLayouts; } public static function getConversationalIgnoredFields() { return [ 'button', 'divider', 'spacer', 'title', 'html', 'shortcode', 'recaptcha', 'turnstile', 'hcaptcha', 'image', 'stripe', 'paypal', 'razorpay', ]; } public function getMergedStepSettings($stepPropertyName) { $allStepsSettings = $this->_stepListObject->allSteps; $stepSettings = !empty($this->_stepListObject->{$stepPropertyName}) ? $this->_stepListObject->{$stepPropertyName} : (object) []; $mergedSettings = (object) array_merge((array) $allStepsSettings, (array) $stepSettings); return $mergedSettings; } private function escHtml($value) { return esc_html((string) $value); } private function ksesPost($value) { return wp_kses_post((string) $value); } }