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
- Build one option update script and run it with
wp eval-file. - Add one audit shell script for mandatory option keys.
- Record audit outputs in release notes for staging and production.
What's Next
- Continue to Module 11 Lesson 1: Installing ACF Pro with Composer and License Secrets.
- Review this module context in Module 10 Overview.
- Related lesson: Local JSON and Version Control Workflow.