Skip to main content

Managing Option Values via CLI and Automation

Global options need scripted updates and audit checks to avoid silent drift.

Practical Use Cases

Use Case 1: Scripted option update with verification

scripts/update-site-options.php
<?php
update_field('support_hotline', '+6565509090', 'option');
update_field('support_email', 'support@example.com', 'option');

echo 'hotline=' . get_field('support_hotline', 'option') . PHP_EOL;
echo 'email=' . get_field('support_email', 'option') . PHP_EOL;
?>
run option update
wp eval-file scripts/update-site-options.php
Expected output
hotline=+6565509090
email=support@example.com

Use Case 2: Daily audit script for critical options

scripts/audit-critical-options.sh
#!/usr/bin/env bash
set -euo pipefail

wp eval 'echo "support_hotline=" . (get_field("support_hotline", "option") ?: "missing") . PHP_EOL;'
wp eval 'echo "support_email=" . (get_field("support_email", "option") ?: "missing") . PHP_EOL;'
Expected output
support_hotline=+6565509090
support_email=support@example.com

Hands-On Practice

  1. Build one option update script and run it with wp eval-file.
  2. Add one audit shell script for mandatory option keys.
  3. Record audit outputs in release notes for staging and production.

What's Next