PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.16.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.16.2
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
← All changes | includes/Core/Util/FileHandler.php +302 -176 1.92.16.2 View file →
@@ -2,211 +2,337 @@
2 2
3 3 namespace BitCode\BitForm\Core\Util;
4 4
5 5 use BitCode\BitForm\Core\Form\FormManager;
6 -use WP_Error;
6 +use BitCode\BitForm\enshrined\svgSanitize\Sanitizer;
7 7
8 8 final class FileHandler
9 9 {
10 - public function rmrf($dir)
11 - {
12 - if (is_dir($dir)) {
13 - $objects = scandir($dir);
14 - foreach ($objects as $object) {
15 - if ($object != "." && $object != "..") {
16 - if (is_dir($dir. DIRECTORY_SEPARATOR .$object) && !is_link($dir.DIRECTORY_SEPARATOR.$object)) {
17 - $this->rmrf($dir. DIRECTORY_SEPARATOR .$object);
18 - } else {
19 - unlink($dir. DIRECTORY_SEPARATOR .$object);
20 - }
21 - }
22 - }
23 - rmdir($dir);
24 - } else {
25 - unlink($dir);
10 + public function rmrf($dir)
11 + {
12 + if (is_dir($dir)) {
13 + $objects = scandir($dir);
14 + foreach ($objects as $object) {
15 + if ('.' !== $object && '..' !== $object) {
16 + if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . DIRECTORY_SEPARATOR . $object)) {
17 + $this->rmrf($dir . DIRECTORY_SEPARATOR . $object);
18 + } else {
19 + wp_delete_file($dir . DIRECTORY_SEPARATOR . $object);
20 + }
26 21 }
22 + }
23 + rmdir($dir);
24 + } else {
25 + wp_delete_file($dir);
27 26 }
27 + }
28 28
29 - public function cpyr($source, $destination)
30 - {
31 - if (is_dir($source)) {
32 - mkdir($destination);
33 - // chmod($destination, 0744);
34 - $objects = scandir($source);
35 - foreach ($objects as $object) {
36 - if ($object != "." && $object != "..") {
37 - if (is_dir($source. DIRECTORY_SEPARATOR .$object) && !is_link($source.DIRECTORY_SEPARATOR.$object)) {
38 - cpyr($source. DIRECTORY_SEPARATOR .$object, $destination. DIRECTORY_SEPARATOR .$object);
39 - } elseif (is_file($source. DIRECTORY_SEPARATOR .$object)) {
40 - copy($source. DIRECTORY_SEPARATOR .$object, $destination. DIRECTORY_SEPARATOR .$object);
41 - // chmod($destination. DIRECTORY_SEPARATOR .$object, 0644);
42 - } else {
43 - symlink($source. DIRECTORY_SEPARATOR .$object, $destination. DIRECTORY_SEPARATOR .$object);
44 - }
45 - }
29 + public function cpyr($source, $destination)
30 + {
31 + if (is_dir($source)) {
32 + mkdir($destination);
33 + // chmod($destination, 0744);
34 + $objects = scandir($source);
35 + foreach ($objects as $object) {
36 + if ('.' !== $object && '..' !== $object) {
37 + if (is_dir($source . DIRECTORY_SEPARATOR . $object) && !is_link($source . DIRECTORY_SEPARATOR . $object)) {
38 + cpyr($source . DIRECTORY_SEPARATOR . $object, $destination . DIRECTORY_SEPARATOR . $object);
39 + } elseif (is_file($source . DIRECTORY_SEPARATOR . $object)) {
40 + copy($source . DIRECTORY_SEPARATOR . $object, $destination . DIRECTORY_SEPARATOR . $object);
41 + // chmod($destination. DIRECTORY_SEPARATOR .$object, 0644);
42 + } else {
43 + symlink($source . DIRECTORY_SEPARATOR . $object, $destination . DIRECTORY_SEPARATOR . $object);
44 + }
45 + }
46 + }
47 + } else {
48 + copy($source, $destination);
49 + }
50 + }
51 +
52 + public function moveUploadedFiles($file_details, $form_id, $entry_id)
53 + {
54 + $file_upoalded = [];
55 + $_upload_dir = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $form_id . DIRECTORY_SEPARATOR . $entry_id;
56 + wp_mkdir_p($_upload_dir);
57 + if (is_array($file_details['name'])) {
58 + foreach ($file_details['name'] as $key => $value) {
59 + //check accepted filetype in_array($file_details['name'][$key], $supported_files) else \
60 + if (!empty($value)) {
61 + $fileNameCount = 1;
62 + // $file_upoalded[$key] = time()."_$value";
63 + $file_upoalded[$key] = sanitize_file_name($value);
64 + while (file_exists($_upload_dir . DIRECTORY_SEPARATOR . $file_upoalded[$key])) {
65 + $fileNameWithSeparator = BITFORMS_BF_SEPARATOR . $fileNameCount;
66 + $file_upoalded[$key] = sanitize_file_name(preg_replace('/(.[a-z A-Z 0-9]+)$/', "{$fileNameWithSeparator}$1", $value));
67 + $fileNameCount = $fileNameCount + 1;
68 + if (11 === $fileNameCount) {
69 + break;
46 70 }
47 - } else {
48 - copy($source, $destination);
71 + }
72 + $move_status = \move_uploaded_file($file_details['tmp_name'][$key], $_upload_dir . DIRECTORY_SEPARATOR . $file_upoalded[$key]);
73 + if (!$move_status) {
74 + unset($file_upoalded[$key]);
75 + }
49 76 }
77 + }
78 + } else {
79 + if (!empty($file_details['name'])) {
80 + $fileNameCount = 1;
81 + $file_upoalded[0] = sanitize_file_name($file_details['name']);
82 + while (file_exists($_upload_dir . DIRECTORY_SEPARATOR . $file_upoalded[0])) {
83 + $fileNameWithSeparator = BITFORMS_BF_SEPARATOR . $fileNameCount;
84 + $file_upoalded[0] = sanitize_file_name(preg_replace('/(.[a-z A-Z 0-9]+)$/', "{$fileNameWithSeparator}$1", $file_details['name']));
85 + $fileNameCount = $fileNameCount + 1;
86 + if (11 === $fileNameCount) {
87 + break;
88 + }
89 + }
90 + $move_status = \move_uploaded_file($file_details['tmp_name'], $_upload_dir . DIRECTORY_SEPARATOR . $file_upoalded[0]);
91 + if (!$move_status) {
92 + unset($file_upoalded[0]);
93 + }
94 + }
50 95 }
96 + return $file_upoalded;
97 + }
51 98
52 - private function getByteSizeByUnit($sizeString)
53 - {
54 - // split 2MB into 2 and MB
55 - $size = preg_replace('/[^0-9\.]/', '', $sizeString);
56 - $unit = preg_replace('/[^a-zA-Z]/', '', $sizeString);
57 - $unit = strtolower($unit);
58 - if ('kb' === $unit) {
59 - return $size * 1024;
60 - } elseif ('mb' === $unit) {
61 - return $size * 1024 * 1024;
62 - } elseif ('gb' === $unit) {
63 - return $size * 1024 * 1024 * 1024;
99 + public function deleteFiles($form_id, $entry_id, $files)
100 + {
101 + $_upload_dir = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $form_id . DIRECTORY_SEPARATOR . $entry_id;
102 + foreach ($files as $name) {
103 + wp_delete_file($_upload_dir . DIRECTORY_SEPARATOR . $name);
104 + }
105 + }
106 +
107 + public static function getFileUploadError($code)
108 + {
109 + $errors = [
110 + 0 => __('Unknown upload error', 'bit-form'),
111 + 1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'bit-form'),
112 + 2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 'bit-form'),
113 + 3 => __('The uploaded file was only partially uploaded.', 'bit-form'),
114 + 4 => __('No file was uploaded.', 'bit-form'),
115 + 6 => __('Missing a temporary folder.', 'bit-form'),
116 + 7 => __('Failed to write file to disk.', 'bit-form'),
117 + 8 => __('A PHP extension stopped the file upload.', 'bit-form'),
118 + ];
119 + return $errors[$code];
120 + }
121 +
122 + public static function fileCopy($tmpdir, $destinationDir, $file)
123 + {
124 + $tmpFile = $tmpdir . DIRECTORY_SEPARATOR . $file;
125 + $newFile = $destinationDir . DIRECTORY_SEPARATOR . $file;
126 + if (file_exists($tmpFile)) {
127 + copy($tmpFile, $newFile);
128 + }
129 + }
130 +
131 + public static function tempDirToUploadDir($submitted_data, $fields, $formId, $entryID)
132 + {
133 + $upload_dir = wp_upload_dir();
134 + $tempDir = $upload_dir['basedir'] . '/bitforms/temp';
135 + $destinationDir = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formId . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR;
136 + if (!is_dir($destinationDir)) {
137 + mkdir($destinationDir);
138 + }
139 +
140 + foreach ($submitted_data as $key => $data) {
141 + if (isset($fields[$key]) && 'advanced-file-up' === $fields[$key]['type']) {
142 + $files = $data;
143 + $fldData = $submitted_data[$key];
144 + $files = explode(',', $fldData);
145 + if (is_array($files) && count($files) > 0) {
146 + foreach ($files as $file) {
147 + self::fileCopy($tempDir, $destinationDir, trim($file));
148 + }
64 149 } else {
65 - return $size;
150 + self::fileCopy($tempDir, $destinationDir, trim($files));
66 151 }
152 + if (!empty($files)) {
153 + $submitted_data[$key] = $files;
154 + }
155 + }
67 156 }
157 + array_map('unlink', array_filter(
158 + (array) array_merge(glob("$tempDir/*"))
159 + ));
68 160
69 - public function validation($field_key, $file_details, $form_id)
70 - {
71 - if (!function_exists('wp_check_filetype_and_ext')) {
72 - require_once ABSPATH . 'wp-admin/includes/file.php';
161 + return $submitted_data;
162 + }
163 +
164 + private function getByteSizeByUnit($sizeString)
165 + {
166 + // split 2MB into 2 and MB
167 + $size = preg_replace('/[^0-9\.]/', '', $sizeString);
168 + $unit = preg_replace('/[^a-zA-Z]/', '', $sizeString);
169 + $unit = strtolower($unit);
170 + if ('kb' === $unit) {
171 + return $size * 1024;
172 + } elseif ('mb' === $unit) {
173 + return $size * 1024 * 1024;
174 + } elseif ('gb' === $unit) {
175 + return $size * 1024 * 1024 * 1024;
176 + } else {
177 + return $size;
178 + }
179 + }
180 +
181 + public function validation($field_key, $file_details, $form_id)
182 + {
183 + if (!function_exists('wp_check_filetype_and_ext')) {
184 + require_once ABSPATH . 'wp-admin/includes/file.php';
185 + }
186 +
187 + $formManager = new FormManager($form_id);
188 + $form_contents = $formManager->getFormContent();
189 + $field_content_details = $form_contents->fields;
190 + $fieldDetail = $field_content_details->{$field_key};
191 + $fieldType = $fieldDetail->typ;
192 + $maxSizeDetails = [];
193 + $allowFileTypes = [];
194 + $maxSize = null;
195 + if ('file-up' === $fieldType) {
196 + $allowFileTypes = !empty($fieldDetail->config->allowedFileType) ? $fieldDetail->config->allowedFileType : [];
197 + if (!empty($fieldDetail->config->allowMaxSize)) {
198 + if (!empty($fieldDetail->config->maxSize)) {
199 + $maxSizeDetails['maxSize'] = $fieldDetail->config->maxSize . $fieldDetail->config->sizeUnit;
73 200 }
74 -
75 - $formManager = new FormManager($form_id);
76 - $form_contents = $formManager->getFormContent();
77 - $field_content_details = $form_contents->fields;
78 - $fieldDetail = $field_content_details->{$field_key};
79 - $fieldType = $fieldDetail->typ;
80 - $maxSizeDetails = [];
81 - $allowFileTypes = [];
82 - if ('file-up' === $fieldType) {
83 - $allowFileTypes = !empty($fieldDetail->exts) ? $fieldDetail->exts : '';
84 - if (!empty($fieldDetail->mxUp)) {
85 - if (!empty($fieldDetail->mxUp)) {
86 - $maxSizeDetails['maxSize'] = $fieldDetail->mxUp . $fieldDetail->unit;
87 - }
88 - }
89 - if (!empty($allowFileTypes)) {
90 - $allowFileTypes = explode(',', $allowFileTypes);
91 - }
201 + if (!empty($fieldDetail->config->isItTotalMax)) {
202 + $maxSizeDetails['maxTotalFileSize'] = $fieldDetail->config->maxSize . $fieldDetail->config->sizeUnit;
92 203 }
93 - if (!empty($maxSizeDetails['maxSize'])) {
94 - $maxSize = $this->getByteSizeByUnit($maxSizeDetails['maxSize']);
204 + }
205 + if (!empty($allowFileTypes)) {
206 + $allowFileTypes = explode(',', $allowFileTypes);
207 + }
208 + } elseif ('advanced-file-up' === $fieldType) {
209 + $allowFileTypes = !empty($fieldDetail->config->allowFileTypeValidation) ? $fieldDetail->config->acceptedFileTypes : [];
210 + if (!empty($fieldDetail->config->allowFileSizeValidation)) {
211 + if (!empty($fieldDetail->config->maxFileSize)) {
212 + $maxSizeDetails['maxSize'] = $fieldDetail->config->maxFileSize;
95 213 }
214 + if (!empty($fieldDetail->config->maxTotalFileSize)) {
215 + $maxSizeDetails['maxTotalFileSize'] = $fieldDetail->config->maxTotalFileSize;
216 + }
217 + }
218 + }
219 + if (!empty($maxSizeDetails['maxSize'])) {
220 + $maxSize = $this->getByteSizeByUnit($maxSizeDetails['maxSize']);
221 + }
222 + $maxTotalFileSize = null;
223 + if (!empty($maxSizeDetails['maxTotalFileSize'])) {
224 + $maxTotalFileSize = $this->getByteSizeByUnit($maxSizeDetails['maxTotalFileSize']);
225 + }
96 226
97 - $errorMessage = [
98 - 'message' => '',
99 - 'error_type'=> '',
100 - ];
227 + if ($formManager->isRepeatedField($field_key)) {
228 + foreach ($file_details['name'] as $rowIndex => $file) {
229 + if (!empty($file)) {
230 + $fileDetails = [
231 + 'name' => $file,
232 + 'type' => $file_details['type'][$rowIndex],
233 + 'tmp_name' => $file_details['tmp_name'][$rowIndex],
234 + 'error' => $file_details['error'][$rowIndex],
235 + 'size' => $file_details['size'][$rowIndex],
236 + ];
237 + $validateState = $this->validateFileInfo($fieldType, $fileDetails, $allowFileTypes, $maxSize, $maxTotalFileSize);
238 + if (!empty($validateState) && !empty($validateState['message'])) {
239 + return $validateState;
240 + }
241 + }
242 + }
243 + } else {
244 + return $this->validateFileInfo($fieldType, $file_details, $allowFileTypes, $maxSize, $maxTotalFileSize);
245 + }
246 + return [];
247 + }
101 248
102 - if (is_array($file_details['name'])) {
103 - $totalSize = 0;
104 - foreach ($file_details['name'] as $key => $file) {
105 - if (!empty($file)) {
106 - $fileInfo = [
107 - 'name' => $file,
108 - 'type' => $file_details['type'][$key],
109 - 'tmp_name' => $file_details['tmp_name'][$key],
110 - 'error' => $file_details['error'][$key],
111 - 'size' => $file_details['size'][$key],
112 - ];
113 - $totalSize += $fileInfo['size'];
114 - $validateState = $this->validateSingleFile($fieldType, $fileInfo, $allowFileTypes, $maxSize);
115 - if (!empty($validateState)) {
116 - return $validateState;
117 - }
118 - }
119 - }
120 - if (!is_null($maxTotalFileSize) && $totalSize > $maxTotalFileSize) {
121 - $errorMessage['message'] = __('Total File size is too large', 'bit-form');
122 - $errorMessage['error_type'] = 'file_size_error';
123 - return $errorMessage;
124 - }
125 - } else {
126 - $validateState = $this->validateSingleFile($fieldType, $file_details, $allowFileTypes, $maxSize);
127 - if (!empty($validateState)) {
128 - return $validateState;
129 - }
249 + private function validateFileInfo($fieldType, $file_details, $allowFileTypes, $maxSize, $maxTotalFileSize)
250 + {
251 + $errorMessage = [
252 + 'message' => '',
253 + 'error_type'=> '',
254 + ];
255 + if (is_array($file_details['name'])) {
256 + $totalSize = 0;
257 + foreach ($file_details['name'] as $key => $file) {
258 + if (!empty($file)) {
259 + $fileInfo = [
260 + 'name' => $file,
261 + 'type' => $file_details['type'][$key],
262 + 'tmp_name' => $file_details['tmp_name'][$key],
263 + 'error' => $file_details['error'][$key],
264 + 'size' => $file_details['size'][$key],
265 + ];
266 + $totalSize += $fileInfo['size'];
267 + $validateState = $this->validateSingleFile($fieldType, $fileInfo, $allowFileTypes, $maxSize);
268 + if (!empty($validateState)) {
269 + return $validateState;
270 + }
130 271 }
131 -
272 + }
273 + if (isset($maxTotalFileSize) && !is_null($maxTotalFileSize) && $totalSize > $maxTotalFileSize) {
274 + $errorMessage['message'] = __('Total File size is too large', 'bit-form');
275 + $errorMessage['error_type'] = 'file_size_error';
132 276 return $errorMessage;
277 + }
278 + } else {
279 + $validateState = $this->validateSingleFile($fieldType, $file_details, $allowFileTypes, $maxSize);
280 + if (!empty($validateState)) {
281 + return $validateState;
282 + }
133 283 }
134 284
135 - private function validateSingleFile($fieldType, $file, $allowTypes, $maxSize)
136 - {
137 - $fileName = sanitize_file_name($file['name']);
138 - if (!empty($fileName)) {
139 - $fileSize = $file['size'];
140 - if (!empty($maxSize) && $fileSize > $maxSize) {
141 - return [
142 - 'message' => __('File size is too large', 'bit-form'),
143 - 'error_type'=> 'file_size_error',
144 - ];
145 - }
285 + return $errorMessage;
286 + }
146 287
147 - $fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);
148 - $fileExtAllowedByWp = wp_check_filetype_and_ext($file['tmp_name'], $fileName);
149 - $isAllowedFileType = in_array('.' . $fileExtension, $allowTypes);
150 - if ((!empty($allowTypes) && !$isAllowedFileType) || (empty($allowTypes) && empty($fileExtAllowedByWp['ext']))) {
151 - return [
152 - 'message' => __(($fileExtension ? ".{$fileExtension}" : 'empty') . ' file extension is not allowed', 'bit-form'),
153 - 'error_type'=> 'file_type_error',
154 - ];
155 - }
156 - }
157 - }
288 + private function validateSingleFile($fieldType, &$file, $allowTypes, $maxSize = null)
289 + {
290 + $fileName = sanitize_file_name($file['name']);
291 + if (!empty($fileName)) {
292 + $fileSize = $file['size'];
293 + if (!empty($maxSize) && $fileSize > $maxSize) {
294 + return [
295 + 'message' => __('File size is too large', 'bit-form'),
296 + 'error_type'=> 'file_size_error',
297 + ];
298 + }
158 299
159 - public function moveUploadedFiles($file_details, $form_id, $entry_id)
160 - {
161 - $file_upoalded = array();
162 - $_upload_dir = BITFORMS_UPLOAD_DIR.DIRECTORY_SEPARATOR.$form_id.DIRECTORY_SEPARATOR.$entry_id;
163 - wp_mkdir_p($_upload_dir);
164 - if (is_array($file_details['name'])) {
165 - foreach ($file_details['name'] as $key => $value) {
166 - //check accepted filetype in_array($file_details['name'][$key], $supported_files) else \
167 - if (!empty($value)) {
168 - $fileNamePattern = '/\_/';
169 - $file_upoalded[$key] = preg_replace($fileNamePattern, '', $value);
170 - $extension = pathinfo($file_upoalded[$key], PATHINFO_EXTENSION);
171 - if (in_array($extension, ['php', 'html', 'xhtml', 'js'])) {
172 - $extension = 'txt';
173 - }
174 - $uniqueName = wp_generate_uuid4();
175 - $UploadedFieldName = $uniqueName . "." . $extension;
176 - $file_upoalded[$key] = $UploadedFieldName.'_'. $file_upoalded[$key];
177 - $move_status = \move_uploaded_file($file_details['tmp_name'][$key], $_upload_dir.DIRECTORY_SEPARATOR.$UploadedFieldName);
178 - if (!$move_status) {
179 - unset($file_upoalded[$key]);
180 - }
181 - }
182 - }
300 + $fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);
301 + $fileExtAllowedByWp = wp_check_filetype_and_ext($file['tmp_name'], $fileName);
302 + $isAllowedFileType = in_array('.' . $fileExtension, $allowTypes);
303 + if ('advanced-file-up' === $fieldType && !empty($allowTypes)) {
304 + if (function_exists('mime_content_type')) {
305 + $fileMimeType = mime_content_type($file['tmp_name']);
183 306 } else {
184 - if (!empty($file_details['name'])) {
185 - $fileNamePattern = '/\_/';
186 - $fileName = sanitize_file_name($file_details['name']);
187 - $file_upoalded[0] = preg_replace($fileNamePattern, '', $fileName);
188 - $extension = pathinfo($file_upoalded[0], PATHINFO_EXTENSION);
189 - if (in_array($extension, ['php', 'html', 'xhtml', 'js'])) {
190 - $extension = 'txt';
191 - }
192 - $uniqueName= wp_generate_uuid4();
193 - $UploadedFieldName = $uniqueName . "." . $extension;
194 - $move_status = \move_uploaded_file($file_details['tmp_name'], $_upload_dir.DIRECTORY_SEPARATOR.$UploadedFieldName);
195 - $file_upoalded[0] = $UploadedFieldName.'_'.$file_upoalded[0];
196 -
197 - if (!$move_status) {
198 - unset($file_upoalded[0]);
199 - }
200 - }
307 + $fileMimeType = $fileExtAllowedByWp['type'];
201 308 }
202 - return $file_upoalded;
309 + $isAllowedFileType = in_array($fileMimeType, $allowTypes);
310 + }
311 + if ((!empty($allowTypes) && !$isAllowedFileType) || (empty($allowTypes) && empty($fileExtAllowedByWp['ext']))) {
312 + return [
313 + 'message' => __(($fileExtension ? ".{$fileExtension}" : 'empty') . ' file extension is not allowed', 'bit-form'),
314 + 'error_type'=> 'file_type_error',
315 + ];
316 + }
317 + if ('svg' === $fileExtension) {
318 + $svg_sanitizer = new Sanitizer();
319 + $dirty_svg = file_get_contents($file['tmp_name']);
320 + $clean_svg = $svg_sanitizer->sanitize($dirty_svg);
321 + if (false === $clean_svg) {
322 + return [
323 + 'message' => __('SVG file is not valid', 'bit-form'),
324 + 'error_type'=> 'file_type_error',
325 + ];
326 + }
327 + file_put_contents($file['tmp_name'], $clean_svg);
328 + }
203 329 }
330 + }
204 331
205 - public function deleteFiles($form_id, $entry_id, $files)
206 - {
207 - $_upload_dir = BITFORMS_UPLOAD_DIR.DIRECTORY_SEPARATOR.$form_id.DIRECTORY_SEPARATOR.$entry_id;
208 - foreach ($files as $name) {
209 - unlink($_upload_dir.DIRECTORY_SEPARATOR.$name);
210 - }
332 + public static function deleteIsFileExists($path)
333 + {
334 + if (file_exists($path)) {
335 + wp_delete_file($path);
211 336 }
337 + }
212 338 }