| @@ -52,14 +52,16 @@ | ||
| 52 | 52 | $pathArr = explode('/', $path); // like "fieldname/user => [Fieldname, user] |
| 53 | 53 | foreach ($pathArr as $d) { |
| 54 | 54 | $rootDir .= $d . DIRECTORY_SEPARATOR; |
| 55 | 55 | if (!realpath($rootDir)) { |
| 56 | - mkdir($rootDir); | |
| 56 | + wp_mkdir_p($rootDir); | |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | $fullPath = $rootDir . $fileName; |
| 60 | - $file = fopen($fullPath, $fileOpenMode); | |
| 61 | - fwrite($file, $log); | |
| 62 | - fclose($file); | |
| 60 | + if ('a' === $fileOpenMode) { | |
| 61 | + FileHandler::appendFile($fullPath, $log); | |
| 62 | + } else { | |
| 63 | + FileHandler::writeFile($fullPath, $log); | |
| 64 | + } | |
| 63 | 65 | return true; |
| 64 | 66 | } |
| 65 | 67 | } |