PluginProbe ʕ •ᴥ•ʔ
Download Manager / trunk
Download Manager vtrunk
3.3.62 3.3.61 3.3.60 3.3.59 3.3.58 3.3.57 3.3.56 trunk 2.1.3 2.3.0 2.5.96 2.5.97 2.6.2 2.6.96 2.8.3 2.9.99 3.0.4 3.1.05 3.1.07 3.1.08 3.1.11 3.1.12 3.1.14 3.1.17 3.1.18 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.2.04 3.2.13 3.2.14 3.2.16 3.2.18 3.2.19 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 3.2.27 3.2.28 3.2.29 3.2.30 3.2.31 3.2.32 3.2.33 3.2.34 3.2.35 3.2.37 3.2.38 3.2.39 3.2.40 3.2.41 3.2.42 3.2.43 3.2.44 3.2.45 3.2.46 3.2.47 3.2.48 3.2.49 3.2.50 3.2.51 3.2.52 3.2.53 3.2.54 3.2.55 3.2.56 3.2.57 3.2.58 3.2.59 3.2.60 3.2.61 3.2.63 3.2.64 3.2.65 3.2.66 3.2.67 3.2.68 3.2.69 3.2.70 3.2.71 3.2.72 3.2.73 3.2.74 3.2.75 3.2.76 3.2.77 3.2.78 3.2.79 3.2.80 3.2.81 3.2.82 3.2.83 3.2.84 3.2.85 3.2.86 3.2.87 3.2.88 3.2.89 3.2.90 3.2.91 3.2.92 3.2.93 3.2.94 3.2.95 3.2.96 3.2.97 3.2.98 3.2.99 3.3.00 3.3.01 3.3.02 3.3.03 3.3.04 3.3.05 3.3.06 3.3.07 3.3.08 3.3.09 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 3.3.16 3.3.17 3.3.18 3.3.19 3.3.20 3.3.21 3.3.22 3.3.23 3.3.24 3.3.25 3.3.26 3.3.27 3.3.28 3.3.29 3.3.30 3.3.31 3.3.32 3.3.33 3.3.34 3.3.35 3.3.36 3.3.37 3.3.38 3.3.39 3.3.40 3.3.41 3.3.42 3.3.43 3.3.44 3.3.45 3.3.46 3.3.47 3.3.48 3.3.49 3.3.50 3.3.51 3.3.52 3.3.53 3.3.54 3.3.55
download-manager / src / Form / Field.php
download-manager / src / Form Last commit date
Field.php 5 months ago Form.php 5 months ago
Field.php
201 lines
1 <?php
2
3
4 namespace WPDM\Form;
5
6
7 use WPDM\__\__;
8
9 class Field
10 {
11
12 static function heading($attrs)
13 {
14 $_attrs = "";
15 $text = $attrs['text'];
16 unset($attrs['text']);
17 foreach ($attrs as $key => $value) {
18 $_attrs .= "{$key}='{$value}' ";
19 }
20 return "<div class=''>{$text}</div>";
21 }
22
23 static function hidden($attrs)
24 {
25 $_attrs = "";
26 foreach ($attrs as $key => $value) {
27 $_attrs .= "{$key}='{$value}' ";
28 }
29 $text = "<input type='hidden' $_attrs />";
30 return $text;
31 }
32
33 static function text($attrs)
34 {
35 $_attrs = "";
36 $attrs['class'] = isset($attrs['class']) ? "form-control " . $attrs['class'] : "form-control";
37 foreach ($attrs as $key => $value) {
38 $_attrs .= "{$key}='{$value}' ";
39 }
40 $text = "<input type='text' $_attrs />";
41 return $text;
42 }
43
44 static function textarea($attrs, $value = '')
45 {
46 $_attrs = "";
47 $attrs['class'] = isset($attrs['class']) ? "form-control " . $attrs['class'] : "form-control";
48 foreach ($attrs as $key => $_value) {
49 $_attrs .= "{$key}='{$_value}' ";
50 }
51 $value = stripslashes_deep($value);
52 $text = "<textarea $_attrs>{$value}</textarea>";
53 return $text;
54 }
55
56 static function number($attrs)
57 {
58 $_attrs = "";
59 $attrs['class'] = isset($attrs['class']) ? "form-control " . $attrs['class'] : "form-control";
60 foreach ($attrs as $key => $value) {
61 $_attrs .= "{$key}='{$value}' ";
62 }
63 $text = "<input type='number' $_attrs />";
64 return $text;
65 }
66
67 static function email($attrs)
68 {
69 $_attrs = "";
70 $attrs['class'] = isset($attrs['class']) ? "form-control " . $attrs['class'] : "form-control";
71 foreach ($attrs as $key => $value) {
72 $_attrs .= "{$key}='{$value}' ";
73 }
74 return "<input type='email' $_attrs />";
75 }
76
77 static function password($attrs)
78 {
79 $_attrs = "";
80 $attrs['class'] = isset($attrs['class']) ? "form-control " . $attrs['class'] : "form-control";
81 foreach ($attrs as $key => $value) {
82 $_attrs .= "{$key}='{$value}' ";
83 }
84 $strength = '';
85 if(isset($attrs['strength']) && $attrs['strength'] === 1) {
86 $strength = '<div class="progress bg-gray-50" style="height: 5px;position: absolute;width: calc(100% - 40px);background: #eee;margin-top: -5px;"><div id="progressbar" class="progress-bar progress-bar-striped progress-bar-animated bg-danger" role="progressbar" style="width: 10%;height: 5px;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div></div>';
87 $strength .= '<script type="text/javascript" src="'.WPDM_ASSET_URL.'js/password-strength.js"></script>';
88 }
89 return "<input type='password' {$_attrs} />{$strength}";
90 }
91
92 static function checkbox($attrs){
93 $_attrs = "";
94 if(isset($attrs['class'])) unset($attrs['class']);
95 $options = $attrs['options'];
96 unset($attrs['options']);
97 foreach ($attrs as $key => $value){
98 $_attrs .= "{$key}='{$value}' ";
99 }
100 $_options = "";
101 foreach ($options as $value => $label){
102 $_options .= "<div><label class='d-block option-label'><input type='checkbox' $_attrs value='{$value}'> {$label}</label></div>\r\n";
103 }
104 return $_options;
105 }
106
107 static function radio($attrs){
108 $_attrs = "";
109 if(isset($attrs['class'])) unset($attrs['class']);
110 $options = $attrs['options'];
111 unset($attrs['options']);
112 foreach ($attrs as $key => $value){
113 $_attrs .= "{$key}='{$value}' ";
114 }
115 $_options = "";
116 foreach ($options as $value => $label){
117 $_options .= "<div><label class='d-block option-label'><input type='radio' $_attrs value='{$value}'> {$label}</label></div>\r\n";
118 }
119 return $_options;
120 }
121
122 static function select($attrs, $value = '')
123 {
124 $_attrs = "";
125 $attrs['class'] = isset($attrs['class']) ? "form-control " . $attrs['class'] : "form-control";
126 $options = $attrs['options'];
127 unset($attrs['options']);
128 foreach ($attrs as $key => $_value) {
129 $_attrs .= "{$key}='{$_value}' ";
130 }
131 $_options = "";
132 foreach ($options as $_value => $label) {
133 $_options .= "<option value='{$_value}' " . selected($_value, $value, false) . ">{$label}</option>\r\n";
134 }
135 return "<select $_attrs>\r\n{$_options}\r\n</select>";
136 }
137
138 static function meidapicker($attrs, $value = '')
139 {
140 ob_start();
141 $_attrs = '';
142 if (is_array($attrs)) {
143 foreach ($attrs as $attr => $value) {
144 $_attrs .= "$attr='$value' ";
145 }
146 }
147 ?>
148 <div class="input-group">
149 <input <?php echo $_attrs; ?> type="url" value="<?php echo $value; ?>"/>
150 <span class="input-group-append">
151 <button class="btn btn-secondary btn-media-upload" type="button" rel="#<?php echo $attrs['id']; ?>"><i
152 class="far fa-image"></i></button>
153 </span>
154 </div>
155 <?php
156 return ob_get_clean();
157 }
158
159 static function reCaptcha($attrs){
160 ob_start();
161 ?>
162 <div class="form-group row">
163 <div class="col-sm-12">
164 <input type="hidden" id="<?php echo esc_attr($attrs['id']) ?>" name="<?php echo esc_attr($attrs['name']) ?>" value=""/>
165 <script src="https://www.google.com/recaptcha/enterprise.js?onload=onloadCallback&render=explicit"
166 async defer></script>
167 <div id="<?php echo esc_attr($attrs['id']) ?>_field" class="recap_field"></div>
168 <style>
169 .wp-core-ui .recap_field{ padding-bottom: 12px; }
170 .wp-core-ui #<?php echo esc_attr($attrs['id']) ?>_field iframe{ transform: scale(0.89); margin-left: -16px; margin-bottom: 12px; clear:both; }
171 .w3eden #<?php echo esc_attr($attrs['id']) ?>_field iframe{ transform: scale(1.16); margin-left: 24px; margin-top: 5px; margin-bottom: 5px; }
172 .w3eden #<?php echo esc_attr($attrs['id']) ?>_field{ padding-bottom: 10px !important; }
173 </style>
174 <script type="text/javascript">
175 var verifyCallback = function (response) {
176 jQuery('#<?php echo esc_js($attrs['id']) ?>').val(response);
177 };
178 var widgetId2;
179 var onloadCallback = function () {
180 grecaptcha.enterprise.render('<?php echo esc_js($attrs['id']) ?>_field', {
181 'sitekey': '<?php echo esc_js(get_option('_wpdm_recaptcha_site_key')); ?>',
182 'callback': verifyCallback,
183 'theme': 'light'
184 });
185 };
186 </script>
187 </div>
188
189 </div>
190 <?php
191 $captcha = ob_get_clean();
192 return $captcha;
193 }
194
195 static function custom($field, $attrs)
196 {
197 return call_user_func($field, $attrs);
198 }
199
200 }
201