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