PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V3.3.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV3.3.2
V3.3.2 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 All 139 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 V3.3.2, at includes/Frontend/Form/View/Theme/Fields/TitleField.php

123 lines 3.9 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 // the title is a flex container, so loose text and inline tags would each become a flex
26 // item and lose the spaces between them; one span keeps the text a single flex item
27 return sprintf(
28 ' <%1$s class="%2$s %3$s">
29 %4$s
30 <span class="%7$s">%5$s</span>
31 %6$s
32 </%1$s>',
33 $tag,
34 $fieldHelpers->getAtomicCls($cls),
35 $fieldHelpers->getCustomClasses($cls),
36 $preIcn,
37 $fieldHelpers->kses_post($text),
38 $sufIcn,
39 $fieldHelpers->getAtomicCls("{$cls}-txt")
40 );
41 }
42
43 private static function iconImg($field, $object, $element, $fieldHelpers, $alt, $fk)
44 {
45 return sprintf(
46 '<img
47 %1$s
48 class="%2$s %3$s"
49 src="%4$s"
50 alt="%5$s"
51 />',
52 $fieldHelpers->getCustomAttributes($element),
53 $fieldHelpers->getAtomicCls($element),
54 $fieldHelpers->getCustomClasses($element),
55 $fieldHelpers->esc_url($field->$object),
56 $fieldHelpers->esc_attr($alt)
57 );
58 }
59
60 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
61 {
62 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
63
64 $logo = $fieldHelpers->icon('logo', 'logo');
65 $titleHide = '';
66 $subtitleHide = '';
67
68 $titlePreIcn = '';
69 $titleSufIcn = '';
70 $subTitlPreIcn = '';
71 $subTitlSufIcn = '';
72
73 if (property_exists($field, 'titlePreIcn')) {
74 $titlePreIcn = self::iconImg($field, 'titlePreIcn', 'title-pre-i', $fieldHelpers, 'Title Prefix Icon', $rowID);
75 }
76
77 if (property_exists($field, 'titleSufIcn')) {
78 $titleSufIcn = self::iconImg($field, 'titleSufIcn', 'title-suf-i', $fieldHelpers, 'Title Suffix Icon', $rowID);
79 }
80
81 if (property_exists($field, 'subTitlPreIcn')) {
82 $subTitlPreIcn = self::iconImg($field, 'subTitlPreIcn', 'sub-titl-pre-i', $fieldHelpers, 'Subtitle Prefix Icon', $rowID);
83 }
84
85 if (property_exists($field, 'subTitlSufIcn')) {
86 $subTitlSufIcn = self::iconImg($field, 'subTitlSufIcn', 'sub-titl-suf-i', $fieldHelpers, 'Subtitle Suffix Icon', $rowID);
87 }
88
89 if (property_exists($field, 'titleHide') && !$field->titleHide) {
90 $titleHide = self::titleGenerator($field->titleTag, $field->title, 'title', $titlePreIcn, $titleSufIcn, $rowID, $field, $form_atomic_Cls_map);
91 }
92
93 if (property_exists($field, 'subtitleHide') && !$field->subtitleHide) {
94 $subtitleHide = self::titleGenerator($field->subTitleTag, $field->subtitle, 'sub-titl', $subTitlPreIcn, $subTitlSufIcn, $rowID, $field, $form_atomic_Cls_map);
95 }
96
97 return sprintf(
98 '<div
99 %1$s
100 class="%2$s %3$s"
101 >
102 %4$s
103 <div
104 %5$s
105 class="%6$s %7$s"
106 >
107 %8$s
108 %9$s
109 </div>
110 </div>',
111 $fieldHelpers->getCustomAttributes('fld-wrp'),
112 $fieldHelpers->getAtomicCls('fld-wrp'),
113 $fieldHelpers->getCustomClasses('fld-wrp'),
114 $logo,
115 $fieldHelpers->getCustomAttributes('titl-wrp'),
116 $fieldHelpers->getAtomicCls('titl-wrp'),
117 $fieldHelpers->getCustomClasses('titl-wrp'),
118 $titleHide,
119 $subtitleHide
120 );
121 }
122 }
123