Skip to content

Commit 2e63600

Browse files
authored
Update wp-clean.php
wp-settings.php patch. Prevents displaying errors.
1 parent c0a581f commit 2e63600

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

wp-clean.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@
245245
}
246246
}
247247

248+
// File patches
249+
patchFile($path . "wp-settings.php", function ($src){
250+
return str_replace('<?php', '<?php if(!defined("ABSPATH")) exit();', $src); // prevent display errors
251+
});
252+
248253
// Create index.php for empty directories.
249254
file_put_contents($path . "wp-content/index.php", $indexSource,FILE_BINARY);
250255
// Create .htaccess file for routing.
@@ -441,4 +446,14 @@ function sendBuffer($chunk)
441446
}
442447
@flush();
443448
@ob_flush();
444-
}
449+
}
450+
451+
function patchFile($file, callable $callback = null)
452+
{
453+
if(file_exists($file) and is_callable($callback))
454+
{
455+
$src = file_get_contents($file);
456+
if($src !== false) return file_put_contents($file, $callback($src), FILE_BINARY);
457+
}
458+
return false;
459+
}

0 commit comments

Comments
 (0)