: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace NinjaForms\Includes\Admin\Processes;
* Deletes a file given file path
* Delete a file, given a filepath
* @param string $filePath
* @return string Result of the attempt to delete file
public function delete(string $filePath): string
$return = __('File could not be found for deletion', 'ninja-forms');
$dir = wp_get_upload_dir();
$fileinfo = pathinfo($filePath);
$allowed_dir = $dir['basedir'] . '/ninja-forms-tmp' === $fileinfo['dirname'];
$return = __('Permission denied to delete a file in that directory.', 'ninja-forms');
} else if (\file_exists($filePath)) {
$return = __('File was deleted', 'ninja-forms');
if (\file_exists($filePath)) {
// couldn't delete file for some reason
$return = __('File could not be deleted', 'ninja-forms');