← All changes
|
app/Services/FormBuilder/ValidationRuleSettings.php
+252
-174
3.6.42
→
6.2.15
View file →
| @@ -5,206 +5,284 @@ | ||
| 5 | 5 | * |
| 6 | 6 | * Returns an array of countries and codes. |
| 7 | 7 | * |
| 8 | 8 | * @author WooThemes |
| 9 | + * | |
| 9 | 10 | * @category i18n |
| 10 | 11 | * @package fluentform/i18n |
| 12 | + * | |
| 11 | 13 | * @version 2.5.0 |
| 12 | 14 | */ |
| 13 | - | |
| 14 | -if (!defined('ABSPATH')) { | |
| 15 | +if (! defined('ABSPATH')) { | |
| 15 | 16 | exit; |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | -$fileTypeOptions = array( | |
| 19 | - array( | |
| 19 | +$fluentformFileTypeOptions = [ | |
| 20 | + [ | |
| 20 | 21 | 'label' => __('Images (jpg, jpeg, gif, png, bmp)', 'fluentform'), |
| 21 | 22 | 'value' => 'jpg|jpeg|gif|png|bmp', |
| 22 | - ), | |
| 23 | - array( | |
| 23 | + ], | |
| 24 | + [ | |
| 24 | 25 | 'label' => __('Audio (mp3, wav, ogg, oga, wma, mka, m4a, ra, mid, midi)', 'fluentform'), |
| 25 | 26 | 'value' => 'mp3|wav|ogg|oga|wma|mka|m4a|ra|mid|midi|mpga', |
| 26 | - ), | |
| 27 | - array( | |
| 27 | + ], | |
| 28 | + [ | |
| 28 | 29 | 'label' => __('Video (avi, divx, flv, mov, ogv, mkv, mp4, m4v, divx, mpg, mpeg, mpe)', 'fluentform'), |
| 29 | 30 | 'value' => 'avi|divx|flv|mov|ogv|mkv|mp4|m4v|divx|mpg|mpeg|mpe|video/quicktime|qt', |
| 30 | - ), | |
| 31 | - array( | |
| 31 | + ], | |
| 32 | + [ | |
| 32 | 33 | 'label' => __('PDF (pdf)', 'fluentform'), |
| 33 | 34 | 'value' => 'pdf', |
| 34 | - ), | |
| 35 | - array( | |
| 35 | + ], | |
| 36 | + [ | |
| 36 | 37 | 'label' => __('Docs (doc, ppt, pps, xls, mdb, docx, xlsx, pptx, odt, odp, ods, odg, odc, odb, odf, rtf, txt)', 'fluentform'), |
| 37 | 38 | 'value' => 'doc|ppt|pps|xls|mdb|docx|xlsx|pptx|odt|odp|ods|odg|odc|odb|odf|rtf|txt', |
| 38 | - ), | |
| 39 | - array( | |
| 39 | + ], | |
| 40 | + [ | |
| 40 | 41 | 'label' => __('Zip Archives (zip, gz, gzip, rar, 7z)', 'fluentform'), |
| 41 | 42 | 'value' => 'zip|gz|gzip|rar|7z', |
| 42 | - ), | |
| 43 | - array( | |
| 43 | + ], | |
| 44 | + [ | |
| 44 | 45 | 'label' => __('Executable Files (exe)', 'fluentform'), |
| 45 | 46 | 'value' => 'exe', |
| 46 | - ), | |
| 47 | - array( | |
| 47 | + ], | |
| 48 | + [ | |
| 48 | 49 | 'label' => __('CSV (csv)', 'fluentform'), |
| 49 | 50 | 'value' => 'csv', |
| 50 | - ), | |
| 51 | + ], | |
| 52 | +]; | |
| 53 | + | |
| 54 | +$fluentformFileTypeOptions = apply_filters_deprecated( | |
| 55 | + 'fluentform_file_type_options', | |
| 56 | + [ | |
| 57 | + $fluentformFileTypeOptions | |
| 58 | + ], | |
| 59 | + FLUENTFORM_FRAMEWORK_UPGRADE, | |
| 60 | + 'fluentform/file_type_options', | |
| 61 | + 'Use fluentform/file_type_options instead of fluentform_file_type_options.' | |
| 51 | 62 | ); |
| 52 | 63 | |
| 53 | -$fileTypeOptions = apply_filters('fluentform_file_type_options', $fileTypeOptions); | |
| 64 | +$fluentformFileTypeOptions = apply_filters('fluentform/file_type_options', $fluentformFileTypeOptions); | |
| 54 | 65 | |
| 55 | -$validation_rule_settings = array( | |
| 56 | - 'required' => | |
| 57 | - array( | |
| 58 | - 'template' => 'inputRadio', | |
| 59 | - 'label' => __('Required', 'fluentform'), | |
| 60 | - 'help_text' => __('Select whether this field is a required field for the form or not.', 'fluentform'), | |
| 61 | - 'options' => | |
| 62 | - array( | |
| 63 | - array( | |
| 64 | - 'value' => true, | |
| 65 | - 'label' => __('Yes', 'fluentform'), | |
| 66 | - ), | |
| 67 | - array( | |
| 68 | - 'value' => false, | |
| 69 | - 'label' => __('No', 'fluentform'), | |
| 70 | - ), | |
| 71 | - ), | |
| 72 | - ), | |
| 73 | - 'min' => | |
| 74 | - array( | |
| 75 | - 'template' => 'inputText', | |
| 76 | - 'type' => 'number', | |
| 77 | - 'label' => __('Min Value', 'fluentform'), | |
| 78 | - 'help_text' => __('Minimum value for the input field.', 'fluentform'), | |
| 79 | - ), | |
| 80 | - 'max' => | |
| 81 | - array( | |
| 82 | - 'template' => 'inputText', | |
| 83 | - 'type' => 'number', | |
| 84 | - 'label' => __('Max Value', 'fluentform'), | |
| 85 | - 'help_text' => __('Maximum value for the input field.', 'fluentform'), | |
| 86 | - ), | |
| 87 | - 'max_file_size' => | |
| 88 | - array( | |
| 89 | - 'template' => 'maxFileSize', | |
| 90 | - 'label' => __('Max File Size', 'fluentform'), | |
| 91 | - 'help_text' => __('The file size limit uploaded by the user.', 'fluentform'), | |
| 92 | - ), | |
| 93 | - 'max_file_count' => | |
| 94 | - array( | |
| 95 | - 'template' => 'inputText', | |
| 96 | - 'type' => 'number', | |
| 97 | - 'label' => __('Max Files Count', 'fluentform'), | |
| 98 | - 'help_text' => __('Maximum user file upload number.', 'fluentform'), | |
| 99 | - ), | |
| 100 | - 'allowed_file_types' => | |
| 101 | - array( | |
| 102 | - 'template' => 'inputCheckbox', | |
| 103 | - 'label' => __('Allowed Files', 'fluentform'), | |
| 104 | - 'help_text' => __('Allowed Files', 'fluentform'), | |
| 105 | - 'fileTypes' => array( | |
| 106 | - array( | |
| 107 | - 'title' => __('Images', 'fluentform'), | |
| 108 | - 'types' => array('jpg', 'jpeg', 'gif', 'png', 'bmp'), | |
| 109 | - ), | |
| 110 | - array( | |
| 111 | - 'title' => __('Audio', 'fluentform'), | |
| 112 | - 'types' => array('mp3', 'wav', 'ogg', 'oga', 'wma', 'mka', 'm4a', 'ra', 'mid', 'midi'), | |
| 113 | - ), | |
| 114 | - array( | |
| 115 | - 'title' => __('Video', 'fluentform'), | |
| 116 | - 'types' => array( | |
| 117 | - 'avi', | |
| 118 | - 'divx', | |
| 119 | - 'flv', | |
| 120 | - 'mov', | |
| 121 | - 'ogv', | |
| 122 | - 'mkv', | |
| 123 | - 'mp4', | |
| 124 | - 'm4v', | |
| 125 | - 'divx', | |
| 126 | - 'mpg', | |
| 127 | - 'mpeg', | |
| 128 | - 'mpe', | |
| 129 | - ), | |
| 130 | - ), | |
| 131 | - array( | |
| 132 | - 'title' => __('PDF', 'fluentform'), | |
| 133 | - 'types' => array('pdf'), | |
| 134 | - ), | |
| 135 | - array( | |
| 136 | - 'title' => __('Docs', 'fluentform'), | |
| 137 | - 'types' => array( | |
| 138 | - 'doc', | |
| 139 | - 'ppt', | |
| 140 | - 'pps', | |
| 141 | - 'xls', | |
| 142 | - 'mdb', | |
| 143 | - 'docx', | |
| 144 | - 'xlsx', | |
| 145 | - 'pptx', | |
| 146 | - 'odt', | |
| 147 | - 'odp', | |
| 148 | - 'ods', | |
| 149 | - 'odg', | |
| 150 | - 'odc', | |
| 151 | - 'odb', | |
| 152 | - 'odf', | |
| 153 | - 'rtf', | |
| 154 | - 'txt' | |
| 155 | - ), | |
| 156 | - ), | |
| 157 | - array( | |
| 158 | - 'title' => __('Zip Archives', 'fluentform'), | |
| 159 | - 'types' => array('zip', 'gz', 'gzip', 'rar', '7z',), | |
| 160 | - ), | |
| 161 | - array( | |
| 162 | - 'title' => __('Executable Files', 'fluentform'), | |
| 163 | - 'types' => | |
| 164 | - array('exe'), | |
| 165 | - ), | |
| 166 | - array( | |
| 167 | - 'title' => __('CSV', 'fluentform'), | |
| 168 | - 'types' => array('csv'), | |
| 169 | - ), | |
| 170 | - ), | |
| 171 | - 'options' => $fileTypeOptions, | |
| 172 | - ), | |
| 173 | - 'allowed_image_types' => | |
| 174 | - array( | |
| 175 | - 'template' => 'inputCheckbox', | |
| 176 | - 'label' => __('Allowed Images', 'fluentform'), | |
| 177 | - 'help_text' => __('Allowed Images', 'fluentform'), | |
| 178 | - 'fileTypes' => | |
| 179 | - array( | |
| 180 | - array( | |
| 181 | - 'title' => __('JPG', 'fluentform'), | |
| 182 | - 'types' => array('jpg|jpeg',), | |
| 183 | - ), | |
| 184 | - array( | |
| 185 | - 'title' => __('PNG', 'fluentform'), | |
| 186 | - 'types' => array('png'), | |
| 187 | - ), | |
| 188 | - array( | |
| 189 | - 'title' => __('GIF', 'fluentform'), | |
| 190 | - 'types' => array('gif'), | |
| 191 | - ), | |
| 192 | - ), | |
| 193 | - 'options' => array( | |
| 194 | - array( | |
| 195 | - 'label' => __('JPG', 'fluentform'), | |
| 196 | - 'value' => 'jpg|jpeg', | |
| 197 | - ), | |
| 198 | - array( | |
| 199 | - 'label' => __('PNG', 'fluentform'), | |
| 200 | - 'value' => 'png', | |
| 201 | - ), | |
| 202 | - array( | |
| 203 | - 'label' => __('GIF', 'fluentform'), | |
| 204 | - 'value' => 'gif', | |
| 205 | - ), | |
| 206 | - ), | |
| 207 | - ) | |
| 66 | +$fluentformImageTypeOptions = [ | |
| 67 | + [ | |
| 68 | + 'label' => __('JPG', 'fluentform'), | |
| 69 | + 'value' => 'jpg|jpeg', | |
| 70 | + ], | |
| 71 | + [ | |
| 72 | + 'label' => __('PNG', 'fluentform'), | |
| 73 | + 'value' => 'png', | |
| 74 | + ], | |
| 75 | + [ | |
| 76 | + 'label' => __('GIF', 'fluentform'), | |
| 77 | + 'value' => 'gif', | |
| 78 | + ], | |
| 79 | +]; | |
| 80 | + | |
| 81 | +$fluentformImageTypeOptions = apply_filters('fluentform/image_type_options', $fluentformImageTypeOptions); | |
| 82 | + | |
| 83 | +$fluentformValidationRuleSettings = [ | |
| 84 | + 'required' => [ | |
| 85 | + 'template' => 'inputRadio', | |
| 86 | + 'label' => __('Required', 'fluentform'), | |
| 87 | + 'help_text' => __('Select whether this field is a required field for the form or not.', 'fluentform'), | |
| 88 | + 'options' => [ | |
| 89 | + [ | |
| 90 | + 'value' => true, | |
| 91 | + 'label' => __('Yes', 'fluentform'), | |
| 92 | + ], | |
| 93 | + [ | |
| 94 | + 'value' => false, | |
| 95 | + 'label' => __('No', 'fluentform'), | |
| 96 | + ], | |
| 97 | + ], | |
| 98 | + ], | |
| 99 | + 'valid_phone_number' => [ | |
| 100 | + 'template' => 'inputRadio', | |
| 101 | + 'label' => __('Validate Phone Number', 'fluentform'), | |
| 102 | + 'help_text' => __('Select whether the phone number should be validated or not.', 'fluentform'), | |
| 103 | + 'options' => [ | |
| 104 | + [ | |
| 105 | + 'value' => true, | |
| 106 | + 'label' => __('Yes', 'fluentform'), | |
| 107 | + ], | |
| 108 | + [ | |
| 109 | + 'value' => false, | |
| 110 | + 'label' => __('No', 'fluentform'), | |
| 111 | + ], | |
| 112 | + ], | |
| 113 | + ], | |
| 114 | + 'email' => [ | |
| 115 | + 'template' => 'inputRadio', | |
| 116 | + 'label' => __('Validate Email', 'fluentform'), | |
| 117 | + 'help_text' => __('Select whether to validate this field as email or not', 'fluentform'), | |
| 118 | + 'options' => [ | |
| 119 | + [ | |
| 120 | + 'value' => true, | |
| 121 | + 'label' => __('Yes', 'fluentform'), | |
| 122 | + ], | |
| 123 | + [ | |
| 124 | + 'value' => false, | |
| 125 | + 'label' => __('No', 'fluentform'), | |
| 126 | + ], | |
| 127 | + ], | |
| 128 | + ], | |
| 129 | + 'url' => [ | |
| 130 | + 'template' => 'inputRadio', | |
| 131 | + 'label' => __('Validate URL', 'fluentform'), | |
| 132 | + 'help_text' => __('Select whether to validate this field as URL or not', 'fluentform'), | |
| 133 | + 'options' => [ | |
| 134 | + [ | |
| 135 | + 'value' => true, | |
| 136 | + 'label' => __('Yes', 'fluentform'), | |
| 137 | + ], | |
| 138 | + [ | |
| 139 | + 'value' => false, | |
| 140 | + 'label' => __('No', 'fluentform'), | |
| 141 | + ], | |
| 142 | + ], | |
| 143 | + ], | |
| 144 | + 'min' => [ | |
| 145 | + 'template' => 'inputText', | |
| 146 | + 'type' => 'number', | |
| 147 | + 'label' => __('Min Value', 'fluentform'), | |
| 148 | + 'help_text' => __('Minimum value for the input field.', 'fluentform'), | |
| 149 | + ], | |
| 150 | + 'digits' => [ | |
| 151 | + 'template' => 'inputText', | |
| 152 | + 'type' => 'number', | |
| 153 | + 'label' => __('Digits', 'fluentform'), | |
| 154 | + 'help_text' => __('Number of digits for the input field.', 'fluentform'), | |
| 155 | + ], | |
| 156 | + 'max' => [ | |
| 157 | + 'template' => 'inputText', | |
| 158 | + 'type' => 'number', | |
| 159 | + 'label' => __('Max Value', 'fluentform'), | |
| 160 | + 'help_text' => __('Maximum value for the input field.', 'fluentform'), | |
| 161 | + ], | |
| 162 | + 'max_selection' => [ | |
| 163 | + 'template' => 'inputText', | |
| 164 | + 'type' => 'number', | |
| 165 | + 'label' => __('Max Selection', 'fluentform'), | |
| 166 | + 'help_text' => __('The most options a user may select. Leave empty for no maximum.', 'fluentform'), | |
| 167 | + ], | |
| 168 | + 'min_selection' => [ | |
| 169 | + 'template' => 'inputText', | |
| 170 | + 'type' => 'number', | |
| 171 | + 'label' => __('Min Selection', 'fluentform'), | |
| 172 | + 'help_text' => __('The fewest options a user may select. Leave empty for no minimum. A user who selects nothing is treated as having skipped the field, so this does not make an optional field required.', 'fluentform'), | |
| 173 | + ], | |
| 174 | + 'max_file_size' => [ | |
| 175 | + 'template' => 'maxFileSize', | |
| 176 | + 'label' => __('Max File Size', 'fluentform'), | |
| 177 | + 'help_text' => __('The file size limit uploaded by the user.', 'fluentform'), | |
| 178 | + ], | |
| 179 | + 'max_file_count' => [ | |
| 180 | + 'template' => 'inputText', | |
| 181 | + 'type' => 'number', | |
| 182 | + 'label' => __('Max Files Count', 'fluentform'), | |
| 183 | + 'help_text' => __('Maximum user file upload number.', 'fluentform'), | |
| 184 | + ], | |
| 185 | + 'allowed_file_types' => [ | |
| 186 | + 'template' => 'inputCheckbox', | |
| 187 | + 'label' => __('Allowed Files', 'fluentform'), | |
| 188 | + 'help_text' => __('Allowed Files', 'fluentform'), | |
| 189 | + 'fileTypes' => [ | |
| 190 | + [ | |
| 191 | + 'title' => __('Images', 'fluentform'), | |
| 192 | + 'types' => ['jpg', 'jpeg', 'gif', 'png', 'bmp'], | |
| 193 | + ], | |
| 194 | + [ | |
| 195 | + 'title' => __('Audio', 'fluentform'), | |
| 196 | + 'types' => ['mp3', 'wav', 'ogg', 'oga', 'wma', 'mka', 'm4a', 'ra', 'mid', 'midi'], | |
| 197 | + ], | |
| 198 | + [ | |
| 199 | + 'title' => __('Video', 'fluentform'), | |
| 200 | + 'types' => [ | |
| 201 | + 'avi', | |
| 202 | + 'divx', | |
| 203 | + 'flv', | |
| 204 | + 'mov', | |
| 205 | + 'ogv', | |
| 206 | + 'mkv', | |
| 207 | + 'mp4', | |
| 208 | + 'm4v', | |
| 209 | + 'divx', | |
| 210 | + 'mpg', | |
| 211 | + 'mpeg', | |
| 212 | + 'mpe', | |
| 213 | + ], | |
| 214 | + ], | |
| 215 | + [ | |
| 216 | + 'title' => __('PDF', 'fluentform'), | |
| 217 | + 'types' => ['pdf'], | |
| 218 | + ], | |
| 219 | + [ | |
| 220 | + 'title' => __('Docs', 'fluentform'), | |
| 221 | + 'types' => [ | |
| 222 | + 'doc', | |
| 223 | + 'ppt', | |
| 224 | + 'pps', | |
| 225 | + 'xls', | |
| 226 | + 'mdb', | |
| 227 | + 'docx', | |
| 228 | + 'xlsx', | |
| 229 | + 'pptx', | |
| 230 | + 'odt', | |
| 231 | + 'odp', | |
| 232 | + 'ods', | |
| 233 | + 'odg', | |
| 234 | + 'odc', | |
| 235 | + 'odb', | |
| 236 | + 'odf', | |
| 237 | + 'rtf', | |
| 238 | + 'txt', | |
| 239 | + ], | |
| 240 | + ], | |
| 241 | + [ | |
| 242 | + 'title' => __('Zip Archives', 'fluentform'), | |
| 243 | + 'types' => ['zip', 'gz', 'gzip', 'rar', '7z', ], | |
| 244 | + ], | |
| 245 | + [ | |
| 246 | + 'title' => __('Executable Files', 'fluentform'), | |
| 247 | + 'types' => ['exe'], | |
| 248 | + ], | |
| 249 | + [ | |
| 250 | + 'title' => __('CSV', 'fluentform'), | |
| 251 | + 'types' => ['csv'], | |
| 252 | + ], | |
| 253 | + ], | |
| 254 | + 'options' => $fluentformFileTypeOptions, | |
| 255 | + ], | |
| 256 | + 'allowed_image_types' => [ | |
| 257 | + 'template' => 'inputCheckbox', | |
| 258 | + 'label' => __('Allowed Images', 'fluentform'), | |
| 259 | + 'help_text' => __('Allowed Images', 'fluentform'), | |
| 260 | + 'fileTypes' => [ | |
| 261 | + [ | |
| 262 | + 'title' => __('JPG', 'fluentform'), | |
| 263 | + 'types' => ['jpg|jpeg', ], | |
| 264 | + ], | |
| 265 | + [ | |
| 266 | + 'title' => __('PNG', 'fluentform'), | |
| 267 | + 'types' => ['png'], | |
| 268 | + ], | |
| 269 | + [ | |
| 270 | + 'title' => __('GIF', 'fluentform'), | |
| 271 | + 'types' => ['gif'], | |
| 272 | + ], | |
| 273 | + ], | |
| 274 | + 'options' => $fluentformImageTypeOptions, | |
| 275 | + ], | |
| 276 | +]; | |
| 277 | + | |
| 278 | +$fluentformValidationRuleSettings = apply_filters_deprecated( | |
| 279 | + 'fluent_editor_validation_rule_settings', | |
| 280 | + [ | |
| 281 | + $fluentformValidationRuleSettings | |
| 282 | + ], | |
| 283 | + FLUENTFORM_FRAMEWORK_UPGRADE, | |
| 284 | + 'fluentform/editor_validation_rule_settings', | |
| 285 | + 'Use fluentform/editor_validation_rule_settings instead of fluent_editor_validation_rule_settings.' | |
| 208 | 286 | ); |
| 209 | 287 | |
| 210 | -return apply_filters('fluent_editor_validation_rule_settings', $validation_rule_settings); | |
| 288 | +return apply_filters('fluentform/editor_validation_rule_settings', $fluentformValidationRuleSettings); | |