Files
argus-wp-defence/bin/strip-comments.php
T
root df0f2fccb8 ARGUS WordPress Defence 1.0.0 — first production release
Automatic WordPress security: local firewall, malware and file-integrity
scanning, vulnerability protection, quarantine, scheduled backups, an
optional page cache, and automatic global threat intelligence.

See README.md for installation, update, and uninstall instructions.
2026-08-09 13:40:16 +00:00

34 lines
900 B
PHP

<?php
$dir = $argv[1] ?? null;
if ( ! $dir || ! is_dir( $dir ) ) {
fwrite( STDERR, "Usage: php strip-comments.php <directory>\n" );
exit( 1 );
}
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $dir, FilesystemIterator::SKIP_DOTS )
);
$count = 0;
$skipped = 0;
foreach ( $iterator as $file ) {
if ( 'php' !== strtolower( $file->getExtension() ) ) {
continue;
}
if ( 'argus-wordpress-defence.php' === $file->getFilename() ) {
$skipped++;
continue;
}
$path = $file->getPathname();
$stripped = php_strip_whitespace( $path );
if ( '' === trim( (string) $stripped ) ) {
fwrite( STDERR, "WARNING: stripping produced empty output for {$path}, leaving original untouched\n" );
continue;
}
file_put_contents( $path, $stripped );
$count++;
}
echo "Stripped comments/whitespace from {$count} PHP files ({$skipped} skipped: plugin header file).\n";