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