PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / utils / class-form-helper.php

class-form-helper.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/utils/class-form-helper.php

181 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore
2
3 /**
4 * Video class
5 *
6 * @package opitn/inludes/uitls
7 */
8
9 namespace OPTN\Includes\Utils;
10
11 /**
12 * Video
13 */
14 class FormHelper {
15 /**
16 * Get checkbox html
17 *
18 * @param object $field field data.
19 * @return string
20 */
21 private static function get_text_html( $field ) {
22
23 ob_start();
24 ?>
25 <div class="optn-block-form-input" id="<?php echo 'optn-field-' . esc_attr( $field->id ); ?>">
26
27 <label class="optn-block-form-input-label" for="<?php echo esc_attr( $field->name ); ?>">
28 <?php echo esc_html( $field->label ); ?>
29 </label>
30
31 <div class="optn-block-form-input-wrapper">
32 <input
33 class="optn-block-form-input-input"
34 name="<?php echo esc_attr( $field->name ); ?>"
35 placeholder="<?php echo esc_attr( $field->placeholder ); ?>"
36 type="<?php echo esc_attr( $field->inputType ); // phpcs:ignore ?>"
37 <?php echo $field->required ? 'required' : ''; ?>
38 />
39
40 <?php if ( ! empty( $field->message ) ) : ?>
41
42 <div class="optn-block-form-input-msg">
43 <?php echo esc_html( $field->message ); ?>
44 </div>
45
46 <?php endif; ?>
47 </div>
48
49 </div>
50 <?php
51
52 return ob_get_clean();
53 }
54
55 /**
56 * Get checkbox html
57 *
58 * @param object $field field data.
59 * @return string
60 */
61 private static function get_checkbox_html( $field ) {
62
63 ob_start();
64 ?>
65 <div
66 class="optn-block-form-input optn-block-form-input-checkbox"
67 id="<?php echo 'optn-field-' . esc_attr( $field->id ); ?>"
68 >
69
70 <div class="optn-block-form-input-checkbox">
71 <input
72 name="<?php echo esc_attr( $field->name ); ?>"
73 type="<?php echo esc_attr( $field->inputType ); // phpcs:ignore ?>"
74 <?php echo $field->required ? 'required' : ''; ?>
75 />
76
77 <label for="<?php echo esc_attr( $field->name ); ?>">
78 <?php echo wp_kses_post( $field->label ); ?>
79 </label>
80 </div>
81
82 <?php if ( ! empty( $field->message ) ) : ?>
83 <div class="optn-block-form-input-msg">
84 <?php echo esc_html( $field->message ); ?>
85 </div>
86 <?php endif; ?>
87
88 </div>
89 <?php
90
91 return ob_get_clean();
92 }
93
94 /**
95 * Extract the Vimeo video ID from a URL.
96 *
97 * @param object $attr attributes.
98 * @return string
99 */
100 public static function get_input_html_v2( &$attr ) {
101
102 $fields = $attr->fields;
103
104 $html = '';
105
106 foreach ( $fields as $f_id => $field ) {
107
108 if ( 'spacer' === $field->type ) {
109 $html .= self::get_spacer_html( $field );
110 continue;
111 }
112
113 $html .= '<div class="optn-block-form-field-wrapper" data-optn-form-field-id="' . esc_attr( $f_id ) . '">';
114
115 switch ( $field->type ) {
116 case 'consent':
117 case 'checkbox':
118 BlockUtils::add_google_font( $field->typo->fontFamily, array( $field->typo->fontWeight ) ); // phpcs:ignore
119 $html .= self::get_checkbox_html( $field );
120 break;
121 default:
122 $html .= self::get_text_html( $field );
123 break;
124 }
125
126 $html .= '</div>';
127 }
128
129 // Form Button.
130
131 $html .= '<div class="optn-block-form-field-wrapper" data-optn-form-field-id="button">';
132 $button_data = array(
133 'text' => $attr->btnText, // phpcs:ignore
134 'submittedText' => $attr->btnSuccessText, // phpcs:ignore
135 'submittingText' => $attr->btnWaitText, // phpcs:ignore
136 );
137 $html .= '<button class="optn-block-form-button" type="submit" ';
138 $html .= 'data-optn="' . esc_attr( wp_json_encode( $button_data ) ) . '">';
139 $html .= '<div class="optn-block-form-button-text">';
140 $html .= esc_html( $attr->btnText ); // phpcs:ignore
141 $html .= '</div>';
142 $html .= '</button>';
143 $html .= '</div>';
144
145 return $html;
146 }
147
148 /**
149 * Get spacer html
150 *
151 * @return string
152 */
153 private static function get_spacer_html( &$field ) {
154 return '<div class="optn-form-spacer" data-optn-form-field-id="' . esc_attr( $field->id ) . '"></div>';
155 }
156
157 /**
158 * Extract the Vimeo video ID from a URL.
159 *
160 * @param object $fields attributes.
161 * @return string
162 */
163 public static function get_input_html( &$fields ) {
164 $html = '';
165
166 foreach ( $fields as $field ) {
167 switch ( $field->type ) {
168 case 'consent':
169 case 'checkbox':
170 $html .= self::get_checkbox_html( $field );
171 break;
172 default:
173 $html .= self::get_text_html( $field );
174 break;
175 }
176 }
177
178 return $html;
179 }
180 }
181