Skip to content

Commit

Permalink
Update wp-clean.php
Browse files Browse the repository at this point in the history
wp-settings.php patch. Prevents displaying errors.
  • Loading branch information
BurakBoz authored May 19, 2022
1 parent c0a581f commit 2e63600
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion wp-clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@
}
}

// File patches
patchFile($path . "wp-settings.php", function ($src){
return str_replace('<?php', '<?php if(!defined("ABSPATH")) exit();', $src); // prevent display errors
});

// Create index.php for empty directories.
file_put_contents($path . "wp-content/index.php", $indexSource,FILE_BINARY);
// Create .htaccess file for routing.
Expand Down Expand Up @@ -441,4 +446,14 @@ function sendBuffer($chunk)
}
@flush();
@ob_flush();
}
}

function patchFile($file, callable $callback = null)
{
if(file_exists($file) and is_callable($callback))
{
$src = file_get_contents($file);
if($src !== false) return file_put_contents($file, $callback($src), FILE_BINARY);
}
return false;
}

0 comments on commit 2e63600

Please sign in to comment.