PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.1
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
bit-form / includes / Frontend / Form / View / Theme / Fields / TitleField.php

TitleField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.1.1, at includes/Frontend/Form/View/Theme/Fields/TitleField.php

120 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend\Form\View\Theme\Fields;
4
5 use BitCode\BitForm\Core\Util\FieldValueHandler;
6
7 class TitleField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 {
11 return self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
12 }
13
14 private static function titleGenerator($tag, $text, $cls, $preIcn, $sufIcn, $fk, $field, $form_atomic_Cls_map)
15 {
16 $text = FieldValueHandler::replaceSmartTagWithValue($text);
17 $fieldHelpers = new ClassicFieldHelpers($field, $fk, $form_atomic_Cls_map);
18
19 $allowedTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'div'];
20 $tag = is_string($tag) ? strtolower($tag) : '';
21 if (!in_array($tag, $allowedTags, true)) {
22 $tag = 'h2';
23 }
24
25 return sprintf(
26 ' <%1$s class="%2$s %3$s">
27 %4$s
28 %5$s
29 %6$s
30 </%1$s>',
31 $tag,
32 $fieldHelpers->getAtomicCls($cls),
33 $fieldHelpers->getCustomClasses($cls),
34 $preIcn,
35 $fieldHelpers->kses_post($text),
36 $sufIcn
37 );
38 }
39
40 private static function iconImg($field, $object, $element, $fieldHelpers, $alt, $fk)
41 {
42 return sprintf(
43 '<img
44 %1$s
45 class="%2$s %3$s"
46 src="%4$s"
47 alt="%5$s"
48 />',
49 $fieldHelpers->getCustomAttributes($element),
50 $fieldHelpers->getAtomicCls($element),
51 $fieldHelpers->getCustomClasses($element),
52 $fieldHelpers->esc_url($field->$object),
53 $fieldHelpers->esc_attr($alt)
54 );
55 }
56
57 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
58 {
59 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
60
61 $logo = $fieldHelpers->icon('logo', 'logo');
62 $titleHide = '';
63 $subtitleHide = '';
64
65 $titlePreIcn = '';
66 $titleSufIcn = '';
67 $subTitlPreIcn = '';
68 $subTitlSufIcn = '';
69
70 if (property_exists($field, 'titlePreIcn')) {
71 $titlePreIcn = self::iconImg($field, 'titlePreIcn', 'title-pre-i', $fieldHelpers, 'Title Prefix Icon', $rowID);
72 }
73
74 if (property_exists($field, 'titleSufIcn')) {
75 $titleSufIcn = self::iconImg($field, 'titleSufIcn', 'title-suf-i', $fieldHelpers, 'Title Suffix Icon', $rowID);
76 }
77
78 if (property_exists($field, 'subTitlPreIcn')) {
79 $subTitlPreIcn = self::iconImg($field, 'subTitlPreIcn', 'sub-titl-pre-i', $fieldHelpers, 'Subtitle Prefix Icon', $rowID);
80 }
81
82 if (property_exists($field, 'subTitlSufIcn')) {
83 $subTitlSufIcn = self::iconImg($field, 'subTitlSufIcn', 'sub-titl-suf-i', $fieldHelpers, 'Subtitle Suffix Icon', $rowID);
84 }
85
86 if (property_exists($field, 'titleHide') && !$field->titleHide) {
87 $titleHide = self::titleGenerator($field->titleTag, $field->title, 'title', $titlePreIcn, $titleSufIcn, $rowID, $field, $form_atomic_Cls_map);
88 }
89
90 if (property_exists($field, 'subtitleHide') && !$field->subtitleHide) {
91 $subtitleHide = self::titleGenerator($field->subTitleTag, $field->subtitle, 'sub-titl', $subTitlPreIcn, $subTitlSufIcn, $rowID, $field, $form_atomic_Cls_map);
92 }
93
94 return sprintf(
95 '<div
96 %1$s
97 class="%2$s %3$s"
98 >
99 %4$s
100 <div
101 %5$s
102 class="%6$s %7$s"
103 >
104 %8$s
105 %9$s
106 </div>
107 </div>',
108 $fieldHelpers->getCustomAttributes('fld-wrp'),
109 $fieldHelpers->getAtomicCls('fld-wrp'),
110 $fieldHelpers->getCustomClasses('fld-wrp'),
111 $logo,
112 $fieldHelpers->getCustomAttributes('titl-wrp'),
113 $fieldHelpers->getAtomicCls('titl-wrp'),
114 $fieldHelpers->getCustomClasses('titl-wrp'),
115 $titleHide,
116 $subtitleHide
117 );
118 }
119 }
120