// Now check for correct file permissions for old file
// Now check for correct file permissions for old file
clearstatcache();
clearstatcache();
if (is_writable($current_file)) {
if (is_writable($current_file)) {
// Everything OK; delete the file
// Everything OK; delete the file
unlink($current_file);
unlink($current_file);
}
}
else {
else {
// File exists, but has wrong permissions. Let the user know.
// File exists, but has wrong permissions. Let the user know.
printf( esc_html__('The file %1$s can not be deleted by the web server, most likely because the permissions on the file are wrong.', "enable-media-replace"), $current_file);
printf( esc_html__('The file %1$s can not be deleted by the web server, most likely because the permissions on the file are wrong.', "enable-media-replace"), $current_file);
exit;
exit;
}
}
}
}
// Delete old resized versions if this was an image
// Delete old resized versions if this was an image