wp-cli/checksum-command
WP-CLI command to verify WordPress core file integrity by comparing local files against published WordPress.org checksums. Supports version/locale selection, optional root checks, file exclusions, and multiple output formats.
## Getting Started
### Minimal Steps
1. **Installation**: No additional installation required—this package ships with WP-CLI. For the latest version (v2.3.7), ensure you're using the latest WP-CLI:
```bash
wp package update --all
Or install directly:
wp package install git@github.com:wp-cli/checksum-command.git
First Use Case: Verify WordPress core files against official checksums:
wp core verify-checksums
wp plugin verify-checksums akismet
wp plugin verify-checksums --all
Where to Look First:
--version, --locale, --exclude, and --format for granular control.
--exclude parameter now trims whitespace from values (fixed in v2.3.7), so trailing spaces in exclusion lists are no longer problematic.--format=json or --format=csv for programmatic integration (e.g., CI/CD pipelines).Core File Integrity Checks:
wp core verify-checksums --version=$(wp core version)
.env, wp-config.php) with --include-root:
wp core verify-checksums --include-root --exclude="wp-config.php,.env"
Plugin-Specific Workflows:
wp plugin verify-checksums woocommerce jetpack --strict
wp plugin verify-checksums akismet --version=5.0
wp plugin verify-checksums --all --exclude="custom-plugin, my-theme" # Whitespace trimmed automatically
Automation in CI/CD:
wp plugin verify-checksums --all --format=json | jq '.[] | select(.message != null)'
wp core verify-checksums || exit 1
Debugging and Maintenance:
wp plugin verify-checksums --insecure
wp plugin verify-checksums --exclude-mu-plugins
Laravel-Specific Adaptations:
// app/Console/Commands/VerifyWordPressChecksums.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class VerifyWordPressChecksums extends Command
{
protected $signature = 'wp:verify-checksums {--core|--plugins}';
protected $description = 'Verify WordPress core or plugin checksums';
public function handle()
{
$process = new Process(['wp', 'core', 'verify-checksums']);
if ($this->option('plugins')) {
$process = new Process(['wp', 'plugin', 'verify-checksums', '--all']);
}
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
$this->info($process->getOutput());
}
}
app/Providers/AppServiceProvider:
public function boot()
{
if (app()->environment('production')) {
\Artisan::call('wp:verify-checksums', ['--core' => true]);
}
}
Custom Checksum Sources:
WpOrgApi:
// app/Services/CustomChecksumService.php
namespace App\Services;
use WP_CLI\Utils;
class CustomChecksumService
{
public function verifyChecksums(string $path, array $expectedChecksums): array
{
// Custom logic to fetch/checksums from your source
return Utils\get_checksums($path, $expectedChecksums);
}
}
Logging and Alerts:
\Log::info('Checksum verification results', [
'output' => $process->getOutput(),
'return_code' => $process->getReturnCode(),
]);
Locale/Version Mismatches:
wp core verify-checksums without --locale or --version may fail if the installed WordPress version/locale differs from the default checksum source.--locale and --version explicitly:
wp core verify-checksums --locale=en_US --version=$(wp core version)
False Positives:
wp-config.php, readme.html) or plugins with dynamic content (e.g., version.php) may trigger false mismatches.--exclude to skip known false positives. Note: Whitespace in exclusion values is now trimmed automatically (v2.3.7):
wp core verify-checksums --exclude="wp-config.php, readme.html" # Works as expected
Network Restrictions:
--insecure as a last resort (acknowledge MITM risks):
wp plugin verify-checksums --insecure
Must-Use Plugins:
mu-plugins) are excluded by default in wp plugin verify-checksums.wp plugin verify-checksums --exclude-mu-plugins=false
PHP Version Compatibility:
checksum-command.Exclusion List Quirks:
--exclude values could cause unexpected behavior.wp plugin verify-checksums --exclude="custom-plugin, my-plugin " # Works as "custom-plugin, my-plugin"
Verbose Output:
--debug with WP-CLI to diagnose issues:
WP_CLI_DEBUG=1 wp plugin verify-checksums --debug
Manual Checksum Comparison:
curl -O https://downloads.wordpress.org/release/core.md5
md5sum -c core.md5
Testing Edge Cases:
wp plugin verify-checksums hello --strict
CI/CD Debugging:
# .github/workflows/ci.yml
steps:
- run: wp plugin verify-checksums
How can I help you explore Laravel packages today?