← All changes
|
includes/Frontend/Form/View/Theme/DefaultTheme.php
+86
-164
3.3.1
→
2.15.3
View file →
| @@ -13,37 +13,29 @@ | ||
| 13 | 13 | $maxUpload = isset($field->mxUp) ? 'Max ' . esc_html($field->mxUp) . ' MB' : ''; |
| 14 | 14 | $req = isset($field->req) ? 'required' : ''; |
| 15 | 15 | $mul = isset($field->mul) ? 'multiple' : ''; |
| 16 | 16 | $extention = isset($field->exts) ? "accept='" . esc_attr($field->exts) . "'" : ''; |
| 17 | - return sprintf( | |
| 18 | - ' <div class="btcd-f-input"> | |
| 17 | + return <<<FILEUPLOAD | |
| 18 | + <div class="btcd-f-input"> | |
| 19 | 19 | <div class="btcd-f-wrp"> |
| 20 | 20 | <div class="btn-wrp"> |
| 21 | 21 | <button class="btcd-inpBtn" type="button"> |
| 22 | 22 | <svg viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" width="15" height="15"><path d="M13.5 7.5l-5.757 5.757a4.243 4.243 0 01-6-6l5.929-5.929a2.828 2.828 0 014 4l-5.758 5.758a1.414 1.414 0 01-2-2L9.5 3.5" stroke="currentColor" /></svg> |
| 23 | - %1$s | |
| 23 | + $upBtnTxt | |
| 24 | 24 | </button> |
| 25 | 25 | </div> |
| 26 | 26 | <span class="btcd-f-title">No File Chosen</span> |
| 27 | - <small class="f-max">%2$s</small> | |
| 28 | - <input id="%3$s" name="%4$s" %5$s %6$s %7$s %8$s type="file" /> | |
| 27 | + <small class="f-max">$maxUpload</small> | |
| 28 | + <input id="$rowID" name="$name" $req $mul $extention $isDisabled type="file" /> | |
| 29 | 29 | </div> |
| 30 | - </div>', | |
| 31 | - $upBtnTxt, | |
| 32 | - $maxUpload, | |
| 33 | - $rowID, | |
| 34 | - $name, | |
| 35 | - $req, | |
| 36 | - $mul, | |
| 37 | - $extention, | |
| 38 | - $isDisabled | |
| 39 | - ); | |
| 30 | + </div> | |
| 31 | +FILEUPLOAD; | |
| 40 | 32 | } |
| 41 | 33 | |
| 42 | 34 | protected function submitBtns($field, $style, $field_id) |
| 43 | 35 | { |
| 44 | 36 | ob_start(); ?> |
| 45 | - <div class="<?php echo esc_attr($style); ?>"> | |
| 37 | + <div class="<?php echo $style; ?>"> | |
| 46 | 38 | <div> |
| 47 | 39 | <div class="btcd-frm-sub <?php 'center' === $field->align ? $this->setSingleValuedAttribute('j-c-c') : ''; ?><?php 'right' === $field->align ? $this->setSingleValuedAttribute('j-c-e') : ''; ?>"> |
| 48 | 40 | <button class="btcd-sub-btn btcd-sub <?php 'md' === $field->btnSiz ? $this->setSingleValuedAttribute('btcd-btn-md') : ''; ?> <?php $field->fulW ? $this->setSingleValuedAttribute('ful-w') : ''; ?>" type="submit" <?php isset($field->name) ? $this->setAttribute('name', $field->name) : '' ?>><?php echo esc_html($field->subBtnTxt) ?></button> |
| 49 | 41 | <?php //{'rstBtnTxt' in attr && <button className={`btcd-sub-btn btcd-rst ${attr.btnSiz === 'md' && 'btcd-btn-md'} ${attr.fulW && 'ful-w'}`} type="button">{attr.rstBtnTxt}</button>} |
| @@ -71,28 +63,20 @@ | ||
| 71 | 63 | } |
| 72 | 64 | $btnSizCls = 'md' === $field->btnSiz ? 'btcd-btn-md' : ''; |
| 73 | 65 | $btnfulW = !empty($field->fulW) ? 'ful-w' : ''; |
| 74 | 66 | $btnTyp = !empty($field->btnTyp) ? "type='$field->btnTyp'" : ''; |
| 75 | - return sprintf( | |
| 76 | - '<div class="btcd-frm-sub %1$s"> | |
| 67 | + return <<<BUTTON | |
| 68 | + <div class='btcd-frm-sub $align'> | |
| 77 | 69 | <button |
| 78 | - class="btcd-sub-btn %2$s %3$s %4$s" | |
| 79 | - %5$s | |
| 80 | - %6$s | |
| 81 | - %7$s | |
| 70 | + class='btcd-sub-btn $btnCls $btnSizCls $btnfulW' | |
| 71 | + $btnTyp | |
| 72 | + $name | |
| 73 | + $isDisabled | |
| 82 | 74 | > |
| 83 | - %8$s | |
| 75 | + $field->txt | |
| 84 | 76 | </button> |
| 85 | - </div>', | |
| 86 | - $align, | |
| 87 | - $btnCls, | |
| 88 | - $btnSizCls, | |
| 89 | - $btnfulW, | |
| 90 | - $btnTyp, | |
| 91 | - $name, | |
| 92 | - $isDisabled, | |
| 93 | - $field->txt | |
| 94 | - ); | |
| 77 | + </div> | |
| 78 | +BUTTON; | |
| 95 | 79 | } |
| 96 | 80 | |
| 97 | 81 | protected function textField($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 98 | 82 | { |
| @@ -104,22 +88,11 @@ | ||
| 104 | 88 | $mn = isset($field->mn) ? "min='" . esc_attr($field->mn) . "'" : ''; |
| 105 | 89 | $val = isset($value) ? "value='" . esc_attr($value) . "'" : ''; |
| 106 | 90 | $required = isset($field->valid->req) ? 'required' : ''; |
| 107 | 91 | |
| 108 | - return sprintf( | |
| 109 | - '<input id="%1$s" class="fld fld-%2$s no-drg" type="%3$s" %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s/>', | |
| 110 | - $rowID, | |
| 111 | - $formID, | |
| 112 | - $field->typ, | |
| 113 | - $name, | |
| 114 | - $ph, | |
| 115 | - $mx, | |
| 116 | - $mn, | |
| 117 | - $val, | |
| 118 | - $required, | |
| 119 | - $isDisabled, | |
| 120 | - $readonly | |
| 121 | - ); | |
| 92 | + return <<<TEXTFIELD | |
| 93 | + <input id="$rowID" class="fld fld-$formID no-drg" type="$field->typ" $name $ph $mx $mn $val $required $isDisabled $readonly/> | |
| 94 | +TEXTFIELD; | |
| 122 | 95 | } |
| 123 | 96 | |
| 124 | 97 | protected function textArea($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 125 | 98 | { |
| @@ -132,22 +105,13 @@ | ||
| 132 | 105 | $ph = isset($field->ph) ? "placeholder='$ph'" : ''; |
| 133 | 106 | $val = isset($value) ? $value : ''; |
| 134 | 107 | $required = isset($field->valid->req) ? 'required' : ''; |
| 135 | 108 | |
| 136 | - return sprintf( | |
| 137 | - '<div> | |
| 138 | - <textarea id="%1$s" class="fld fld-%2$s no-drg" type="%3$s" %4$s %5$s %6$s %7$s %8$s>%9$s</textArea> | |
| 139 | - </div>', | |
| 140 | - $rowID, | |
| 141 | - $formID, | |
| 142 | - $field->typ, | |
| 143 | - $name, | |
| 144 | - $ph, | |
| 145 | - $required, | |
| 146 | - $isDisabled, | |
| 147 | - $readonly, | |
| 148 | - $val | |
| 149 | - ); | |
| 109 | + return <<<TEXTAREA | |
| 110 | + <div> | |
| 111 | + <textarea id="$rowID" class="fld fld-$formID no-drg" type="$field->typ" $name $ph $required $isDisabled $readonly>$val</textArea> | |
| 112 | + </div> | |
| 113 | +TEXTAREA; | |
| 150 | 114 | } |
| 151 | 115 | |
| 152 | 116 | protected function dropDown($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 153 | 117 | { |
| @@ -172,14 +136,14 @@ | ||
| 172 | 136 | $defaultValuePlacehold = "<div data-msl='true' $ph class='msl-input' contenteditable='true'></div>"; |
| 173 | 137 | if (null !== $defaultValue && 1 === sizeof($defaultValue) && !$mul) { |
| 174 | 138 | $defaultValuePlacehold = "<span class='msl-single-value' data-msl='true'>$defaultValue[0]</span>"; |
| 175 | 139 | } |
| 176 | - return sprintf( | |
| 177 | - ' <div class="msl-wrp msl-vars no-drg %1$s fld fld-%2$s dpd" style="width: 100%%;"> | |
| 178 | - <input name="%3$s" type="hidden" value="%4$s"> | |
| 140 | + return <<<DROPDOWN | |
| 141 | + <div class="msl-wrp msl-vars no-drg $isDisabled fld fld-$formID dpd" style="width: 100%;"> | |
| 142 | + <input name="$field_name" type="hidden" value="$val"> | |
| 179 | 143 | <div data-msl="true" class="msl"> |
| 180 | 144 | <div data-msl="true" class="msl-input-wrp" tabindex="0"> |
| 181 | - %5$s | |
| 145 | + $defaultValuePlacehold | |
| 182 | 146 | </div> |
| 183 | 147 | <div class="msl-actions msl-flx"> |
| 184 | 148 | <div role="button" aria-label="toggle-menu" class="msl-btn msl-arrow-btn msl-flx"></div> |
| 185 | 149 | </div> |
| @@ -184,28 +148,26 @@ | ||
| 184 | 148 | <div role="button" aria-label="toggle-menu" class="msl-btn msl-arrow-btn msl-flx"></div> |
| 185 | 149 | </div> |
| 186 | 150 | </div> |
| 187 | 151 | <div class="msl-options"> |
| 188 | - %6$s | |
| 152 | + $options | |
| 189 | 153 | </div> |
| 190 | - </div>', | |
| 191 | - $isDisabled, | |
| 192 | - $formID, | |
| 193 | - $field_name, | |
| 194 | - $val, | |
| 195 | - $defaultValuePlacehold, | |
| 196 | - $options | |
| 197 | - ); | |
| 154 | + </div> | |
| 155 | +DROPDOWN; | |
| 198 | 156 | } |
| 199 | 157 | |
| 200 | 158 | protected function recaptcha($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 201 | 159 | { |
| 202 | - return '<div class="btcd-flx j-c-c" style="min-height=inherit"></div>'; | |
| 160 | + return <<<RECAPTCHA | |
| 161 | + <div class="btcd-flx j-c-c" style="min-height='inherit'"></div> | |
| 162 | +RECAPTCHA; | |
| 203 | 163 | } |
| 204 | 164 | |
| 205 | 165 | protected function paypal($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 206 | 166 | { |
| 207 | - return ' <div style="width: auto; min-width: 150px; max-width: 750px; margin-left: auto; margin-right: auto;"></div>'; | |
| 167 | + return <<<PAYPAL | |
| 168 | + <div style="width: auto; min-width: 150px; max-width: 750px; margin-left: auto; margin-right: auto;"></div> | |
| 169 | +PAYPAL; | |
| 208 | 170 | } |
| 209 | 171 | |
| 210 | 172 | protected function razorPay($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 211 | 173 | { |
| @@ -214,21 +176,15 @@ | ||
| 214 | 176 | $btnSiz = 'md' === $field->btnSiz ? 'btcd-btn-md' : ''; |
| 215 | 177 | $fulW = $field->fulW ? 'ful-w' : ''; |
| 216 | 178 | $btnTxt = isset($field->btnTxt) ? esc_html($field->btnTxt) : ''; |
| 217 | 179 | |
| 218 | - return sprintf( | |
| 219 | - '<div class="btcd-frm-sub %1$s %2$s"> | |
| 220 | - <button class="btcd-sub-btn btcd-sub %3$s %4$s" type="button" name="%5$s"> | |
| 221 | - %6$s | |
| 180 | + return <<<RAZORPAY | |
| 181 | + <div class="btcd-frm-sub $center $right"> | |
| 182 | + <button class="btcd-sub-btn btcd-sub $btnSiz $fulW" type="button" name="$field_name"> | |
| 183 | + $btnTxt | |
| 222 | 184 | </button> |
| 223 | - </div>', | |
| 224 | - $center, | |
| 225 | - $right, | |
| 226 | - $btnSiz, | |
| 227 | - $fulW, | |
| 228 | - $field_name, | |
| 229 | - $btnTxt | |
| 230 | - ); | |
| 185 | + </div> | |
| 186 | +RAZORPAY; | |
| 231 | 187 | } |
| 232 | 188 | |
| 233 | 189 | protected function checkBox($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 234 | 190 | { |
| @@ -245,32 +201,22 @@ | ||
| 245 | 201 | $value = null === $value ? '' : $value; |
| 246 | 202 | if ((!is_array($value) && false !== strpos($value, $checkBoxOptionValue)) || (isset($value) && \is_array($value) && $checkBoxOptionValue === $value[array_search($checkBoxOptionValue, $value)])) { |
| 247 | 203 | $checked = 'checked'; |
| 248 | 204 | } |
| 249 | - $options .= sprintf( | |
| 250 | - '<label class="btcd-ck-wrp btcd-ck-wrp-%1$s"> | |
| 251 | - <span>%2$s</span> | |
| 252 | - <input type="checkbox" %3$s %4$s %5$s value="%6$s" %7$s %8$s/> | |
| 253 | - <span class="btcd-mrk ck"></span> | |
| 254 | - </label>', | |
| 255 | - $formID, | |
| 256 | - $checkBoxOption->lbl, | |
| 257 | - $checked, | |
| 258 | - $required, | |
| 259 | - $name, | |
| 260 | - $checkBoxOptionValue, | |
| 261 | - $isDisabled, | |
| 262 | - $readonly | |
| 263 | - ); | |
| 205 | + $options .= <<<OPTION | |
| 206 | + <label class="btcd-ck-wrp btcd-ck-wrp-$formID"> | |
| 207 | + <span>$checkBoxOption->lbl</span> | |
| 208 | + <input type="checkbox" $checked $required $name value="$checkBoxOptionValue" $isDisabled $readonly/> | |
| 209 | + <span class="btcd-mrk ck"></span> | |
| 210 | + </label> | |
| 211 | +OPTION; | |
| 264 | 212 | } |
| 265 | 213 | |
| 266 | - return sprintf( | |
| 267 | - '<div class="no-drg fld btcd-ck-con %1$s"> | |
| 268 | - %2$s | |
| 269 | - </div>', | |
| 270 | - $round, | |
| 271 | - $options | |
| 272 | - ); | |
| 214 | + return <<<CHECKBOX | |
| 215 | + <div class="no-drg fld btcd-ck-con $round"> | |
| 216 | + $options | |
| 217 | + </div> | |
| 218 | +CHECKBOX; | |
| 273 | 219 | } |
| 274 | 220 | |
| 275 | 221 | protected function radioBox($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 276 | 222 | { |
| @@ -286,32 +232,22 @@ | ||
| 286 | 232 | $checked = ''; |
| 287 | 233 | if (isset($checkBoxOption->check) || $checkBoxOption->lbl === $value) { |
| 288 | 234 | $checked = 'checked'; |
| 289 | 235 | } |
| 290 | - $options .= sprintf( | |
| 291 | - '<label class="btcd-ck-wrp btcd-ck-wrp-%1$s"> | |
| 292 | - <span>%2$s</span> | |
| 293 | - <input type="radio" %3$s %4$s %5$s value="%6$s" %7$s %8$s/> | |
| 236 | + $options .= <<<OPTION | |
| 237 | + <label class="btcd-ck-wrp btcd-ck-wrp-$formID"> | |
| 238 | + <span>$checkBoxOption->lbl</span> | |
| 239 | + <input type="radio" $checked $required $name value="$optionValue" $isDisabled $readonly/> | |
| 294 | 240 | <span class="btcd-mrk rdo"></span> |
| 295 | - </label>', | |
| 296 | - $formID, | |
| 297 | - $checkBoxOption->lbl, | |
| 298 | - $checked, | |
| 299 | - $required, | |
| 300 | - $name, | |
| 301 | - $optionValue, | |
| 302 | - $isDisabled, | |
| 303 | - $readonly | |
| 304 | - ); | |
| 241 | + </label> | |
| 242 | +OPTION; | |
| 305 | 243 | } |
| 306 | 244 | |
| 307 | - return sprintf( | |
| 308 | - '<div class="no-drg fld btcd-ck-con %1$s"> | |
| 309 | - %2$s | |
| 310 | - </div>', | |
| 311 | - $round, | |
| 312 | - $options | |
| 313 | - ); | |
| 245 | + return <<<RADIOBOX | |
| 246 | + <div class="no-drg fld btcd-ck-con $round"> | |
| 247 | + $options | |
| 248 | + </div> | |
| 249 | +RADIOBOX; | |
| 314 | 250 | } |
| 315 | 251 | |
| 316 | 252 | protected function decisionBox($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 317 | 253 | { |
| @@ -324,38 +260,28 @@ | ||
| 324 | 260 | $size = $isRequired ? '1px' : ''; |
| 325 | 261 | |
| 326 | 262 | $lbl = !empty($field->lbl) ? wp_kses_post($field->lbl) : (isset($field->info) ? wp_kses_post($field->info->lbl) : ''); |
| 327 | 263 | |
| 328 | - return sprintf( | |
| 329 | - '<div class="no-drg fld fld-%1$s btcd-ck-con %2$s"> | |
| 264 | + return <<<DECISIONBOX | |
| 265 | + <div class="no-drg fld fld-{$formID} btcd-ck-con $round"> | |
| 330 | 266 | <input |
| 331 | - size="height: %3$s, width: %3$s" | |
| 267 | + size="height: {$size}, width: {$size}" | |
| 332 | 268 | type="checkbox" |
| 333 | - %4$s | |
| 334 | - %5$s | |
| 335 | - %6$s | |
| 336 | - %7$s | |
| 337 | - value="%8$s" | |
| 269 | + $isDisabled | |
| 270 | + $readonly | |
| 271 | + $isRequired | |
| 272 | + $isChecked | |
| 273 | + value="{$value}" | |
| 338 | 274 | /> |
| 339 | - <label class="btcd-ck-wrp btcd-ck-wrp-%1$s"> | |
| 275 | + <label class="btcd-ck-wrp btcd-ck-wrp-{$formID}"> | |
| 340 | 276 | <span class="decision-content"> |
| 341 | - %9$s | |
| 277 | + {$lbl} | |
| 342 | 278 | </span> |
| 343 | - <input type="hidden" value="%8$s" name="%10$s" /> | |
| 279 | + <input type="hidden" value="{$value}" name="{$field_name}" /> | |
| 344 | 280 | <span class="btcd-mrk ck"></span> |
| 345 | 281 | </label> |
| 346 | - </div>', | |
| 347 | - $formID, | |
| 348 | - $round, | |
| 349 | - $size, | |
| 350 | - $isDisabled, | |
| 351 | - $readonly, | |
| 352 | - $isRequired, | |
| 353 | - $isChecked, | |
| 354 | - $value, | |
| 355 | - $lbl, | |
| 356 | - $field_name | |
| 357 | - ); | |
| 282 | + </div> | |
| 283 | +DECISIONBOX; | |
| 358 | 284 | } |
| 359 | 285 | |
| 360 | 286 | protected function html($field, $rowID, $field_name, $formID, $error = null, $value = null) |
| 361 | 287 | { |
| @@ -362,17 +288,13 @@ | ||
| 362 | 288 | $isHidden = !empty($field->valid->hide) && $field->valid->hide ? 'vis-n' : null; |
| 363 | 289 | |
| 364 | 290 | $content = !empty($field->content) ? wp_kses_post($field->content) : ''; |
| 365 | 291 | |
| 366 | - return sprintf( | |
| 367 | - '<div class="btcd-fld-itm %1$s %2$s"> | |
| 368 | - <div class="fld-wrp fld-wrp-%3$s drag" btcd-fld="decision-box"> | |
| 369 | - %4$s | |
| 292 | + return <<<HTML | |
| 293 | + <div class="btcd-fld-itm $rowID $isHidden"> | |
| 294 | + <div class="fld-wrp fld-wrp-$formID drag" btcd-fld="decision-box"> | |
| 295 | + $content | |
| 370 | 296 | </div> |
| 371 | - </div>', | |
| 372 | - $rowID, | |
| 373 | - $isHidden, | |
| 374 | - $formID, | |
| 375 | - $content | |
| 376 | - ); | |
| 297 | + </div> | |
| 298 | +HTML; | |
| 377 | 299 | } |
| 378 | 300 | } |