← All changes
|
includes/Frontend/Form/View/Theme/Fields/FileUploadField.php
+102
-71
2.10.0
→
3.3.1
View file →
| @@ -19,98 +19,129 @@ | ||
| 19 | 19 | $prefixIcn = $fh->icon('prefixIcn', 'pre-i'); |
| 20 | 20 | $suffixIcn = $fh->icon('suffixIcn', 'suf-i'); |
| 21 | 21 | $name = $fh->name(); |
| 22 | 22 | $req = $fh->required(); |
| 23 | + $ariaDescribedBy = $fh->ariaDescribedBy(); | |
| 24 | + $ariaRequired = $fh->ariaRequired(); | |
| 23 | 25 | $readonlyCls = isset($field->readonly) ? 'readonly' : ''; |
| 24 | 26 | $disabledCls = isset($field->disabled) ? 'disabled' : ''; |
| 25 | 27 | $btnTxt = isset($field->btnTxt) ? $field->btnTxt : ''; |
| 26 | 28 | $showSelectStatus = ''; |
| 27 | 29 | $maxSizeSection = ''; |
| 28 | - $maxSize = isset($field->config->maxSize) ? $field->config->maxSize : ''; | |
| 29 | - $sizeUnit = isset($field->config->sizeUnit) ? $field->config->sizeUnit : ''; | |
| 30 | + $multiple = ''; | |
| 30 | 31 | $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds; |
| 31 | 32 | $contentCount = count($bfFrontendFormIds); |
| 32 | 33 | |
| 34 | + if ($fh->property_exists_nested($field, 'config->multiple', true)) { | |
| 35 | + $multiple = 'multiple'; | |
| 36 | + } | |
| 37 | + | |
| 33 | 38 | if ($fh->property_exists_nested($field, 'config->showSelectStatus', true)) { |
| 34 | - $showSelectStatus = <<<SHOWSELSTATUS | |
| 35 | - <div | |
| 36 | - {$fh->getCustomAttributes('file-select-status')} | |
| 37 | - class="{$fh->getAtomicCls('file-select-status')} {$fh->getCustomClasses('file-select-status')}" | |
| 38 | - > | |
| 39 | - No Choosen File | |
| 40 | - </div> | |
| 41 | -SHOWSELSTATUS; | |
| 39 | + $showSelectStatus = sprintf( | |
| 40 | + '<div | |
| 41 | + %1$s | |
| 42 | + class="%2$s %3$s" | |
| 43 | + > | |
| 44 | + No Choosen File | |
| 45 | + </div>', | |
| 46 | + $fh->getCustomAttributes('file-select-status'), | |
| 47 | + $fh->getAtomicCls('file-select-status'), | |
| 48 | + $fh->getCustomClasses('file-select-status') | |
| 49 | + ); | |
| 42 | 50 | } |
| 43 | 51 | |
| 44 | - if ( | |
| 45 | - $fh->property_exists_nested($field, 'config->allowMaxSize', true) | |
| 46 | - && $fh->property_exists_nested($field, 'config->showMaxSize', true) | |
| 47 | - && $fh->property_exists_nested($field, 'config->maxSize') | |
| 48 | - && 0 !== $field->config->maxSize | |
| 49 | - ) { | |
| 50 | - $maxSizeLbl = $fh->property_exists_nested($field, 'config->maxSizeLabel', '', 1) ? $field->config->maxSizeLabel : "(Max {$maxSize} ${sizeUnit})"; | |
| 51 | - $maxSizeSection = <<<MAXSIZE | |
| 52 | - <small | |
| 53 | - {$fh->getCustomAttributes('max-size-lbl')} | |
| 54 | - class="{$fh->getAtomicCls('max-size-lbl')} {$fh->getCustomClasses('max-size-lbl')}" | |
| 55 | - > | |
| 56 | - {$fh->esc_html($maxSizeLbl)} | |
| 57 | - </small> | |
| 58 | -MAXSIZE; | |
| 59 | - } | |
| 52 | + $maxSizeSection = apply_filters('bitform_file_max_size_section', '', $field, $fh); | |
| 60 | 53 | |
| 61 | - return <<<FILEUPLOADFIELD | |
| 62 | - <div | |
| 63 | - {$fh->getCustomAttributes('file-up-container')} | |
| 64 | - class="{$fh->getAtomicCls('file-up-container')} {$fh->getCustomClasses('file-up-container')}" | |
| 65 | - > | |
| 66 | - <div | |
| 67 | - {$fh->getCustomAttributes('file-up-wrpr')} | |
| 68 | - class="{$fh->getAtomicCls('file-up-wrpr')} {$fh->getCustomClasses('file-up-wrpr')} {$readonlyCls} {$disabledCls}" | |
| 54 | + return sprintf( | |
| 55 | + '<div | |
| 56 | + %1$s | |
| 57 | + class="%2$s %3$s" | |
| 69 | 58 | > |
| 70 | 59 | <div |
| 71 | - {$fh->getCustomAttributes('file-input-wrpr')} | |
| 72 | - class="{$fh->getAtomicCls('file-input-wrpr')} {$fh->getCustomClasses('file-input-wrpr')}" | |
| 60 | + %4$s | |
| 61 | + class="%5$s %6$s %7$s %8$s" | |
| 73 | 62 | > |
| 74 | 63 | <div |
| 75 | - {$fh->getCustomAttributes('btn-wrpr')} | |
| 76 | - class="{$fh->getAtomicCls('btn-wrpr')} {$fh->getCustomClasses('btn-wrpr')}" | |
| 64 | + %9$s | |
| 65 | + class="%10$s %11$s" | |
| 77 | 66 | > |
| 78 | - <button | |
| 79 | - {$fh->getCustomAttributes('inp-btn')} | |
| 80 | - type="button" | |
| 81 | - class="{$fh->getAtomicCls('inp-btn')} {$fh->getCustomClasses('inp-btn')}" | |
| 67 | + <div | |
| 68 | + %12$s | |
| 69 | + class="%13$s %14$s" | |
| 82 | 70 | > |
| 83 | - {$prefixIcn} | |
| 84 | - <span | |
| 85 | - {$fh->getCustomAttributes('btn-txt')} | |
| 86 | - class="{$fh->getAtomicCls('btn-txt')} {$fh->getCustomClasses('btn-txt')}" | |
| 71 | + <button | |
| 72 | + %15$s | |
| 73 | + type="button" | |
| 74 | + class="%16$s %17$s" | |
| 87 | 75 | > |
| 88 | - {$fh->kses_post($btnTxt)} | |
| 89 | - </span> | |
| 90 | - {$suffixIcn} | |
| 91 | - </button> | |
| 92 | - {$showSelectStatus} | |
| 93 | - {$maxSizeSection} | |
| 94 | - <input | |
| 95 | - {$fh->getCustomAttributes('file-upload-input')} | |
| 96 | - type="file" | |
| 97 | - class="{$fh->getAtomicCls('file-upload-input')} {$fh->getCustomClasses('file-upload-input')}" | |
| 98 | - id="{$rowID}-{$contentCount}" | |
| 99 | - {$name} | |
| 100 | - {$req} | |
| 101 | - {$fh->disabled()} | |
| 102 | - {$fh->readonly()} | |
| 103 | - aria-disabled="true" | |
| 104 | - tabindex="-1" | |
| 105 | - /> | |
| 76 | + %18$s | |
| 77 | + <span | |
| 78 | + %19$s | |
| 79 | + class="%20$s %21$s" | |
| 80 | + > | |
| 81 | + %22$s | |
| 82 | + </span> | |
| 83 | + %23$s | |
| 84 | + </button> | |
| 85 | + %24$s | |
| 86 | + %25$s | |
| 87 | + <input | |
| 88 | + %26$s | |
| 89 | + type="file" | |
| 90 | + class="%27$s %28$s" | |
| 91 | + id="%29$s-%30$s" | |
| 92 | + %31$s | |
| 93 | + %32$s | |
| 94 | + %33$s | |
| 95 | + %34$s | |
| 96 | + %35$s | |
| 97 | + aria-disabled="true" | |
| 98 | + tabindex="-1" | |
| 99 | + /> | |
| 100 | + </div> | |
| 101 | + <div | |
| 102 | + %36$s | |
| 103 | + class="err-wrp %37$s" | |
| 104 | + ></div> | |
| 106 | 105 | </div> |
| 107 | - <div | |
| 108 | - {$fh->getCustomAttributes('err-wrp')} | |
| 109 | - class="err-wrp {$fh->getCustomClasses('err-wrp')}" | |
| 110 | - ></div> | |
| 111 | 106 | </div> |
| 112 | - </div> | |
| 113 | - </div> | |
| 114 | -FILEUPLOADFIELD; | |
| 107 | + </div>', | |
| 108 | + $fh->getCustomAttributes('file-up-container'), | |
| 109 | + $fh->getAtomicCls('file-up-container'), | |
| 110 | + $fh->getCustomClasses('file-up-container'), | |
| 111 | + $fh->getCustomAttributes('file-up-wrpr'), | |
| 112 | + $fh->getAtomicCls('file-up-wrpr'), | |
| 113 | + $fh->getCustomClasses('file-up-wrpr'), | |
| 114 | + $readonlyCls, | |
| 115 | + $disabledCls, | |
| 116 | + $fh->getCustomAttributes('file-input-wrpr'), | |
| 117 | + $fh->getAtomicCls('file-input-wrpr'), | |
| 118 | + $fh->getCustomClasses('file-input-wrpr'), | |
| 119 | + $fh->getCustomAttributes('btn-wrpr'), | |
| 120 | + $fh->getAtomicCls('btn-wrpr'), | |
| 121 | + $fh->getCustomClasses('btn-wrpr'), | |
| 122 | + $fh->getCustomAttributes('inp-btn'), | |
| 123 | + $fh->getAtomicCls('inp-btn'), | |
| 124 | + $fh->getCustomClasses('inp-btn'), | |
| 125 | + $prefixIcn, | |
| 126 | + $fh->getCustomAttributes('btn-txt'), | |
| 127 | + $fh->getAtomicCls('btn-txt'), | |
| 128 | + $fh->getCustomClasses('btn-txt'), | |
| 129 | + $fh->kses_post($btnTxt), | |
| 130 | + $suffixIcn, | |
| 131 | + $showSelectStatus, | |
| 132 | + $maxSizeSection, | |
| 133 | + $fh->getCustomAttributes('file-upload-input'), | |
| 134 | + $fh->getAtomicCls('file-upload-input'), | |
| 135 | + $fh->getCustomClasses('file-upload-input'), | |
| 136 | + $rowID, | |
| 137 | + $contentCount, | |
| 138 | + $name, | |
| 139 | + $req, | |
| 140 | + $fh->disabled(), | |
| 141 | + $fh->readonly(), | |
| 142 | + $multiple, | |
| 143 | + $fh->getCustomAttributes('err-wrp'), | |
| 144 | + $fh->getCustomClasses('err-wrp') | |
| 145 | + ); | |
| 115 | 146 | } |
| 116 | 147 | } |