This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,30 @@
# Automation with WP-CLI
Use this file when turning an ops sequence into a repeatable script or CI job.
## `wp-cli.yml`
If the repo uses `wp-cli.yml`, use it to standardize:
- `path:` (WordPress root)
- `url:` (default site)
- PHP settings (memory limits)
## Shell scripting
Guardrails for scripts:
- `set -euo pipefail`
- print commands before running them
- make destructive operations require an explicit flag (e.g. `--apply`)
## CI jobs
Prefer CI jobs that are read-only by default:
- `wp core version`
- `wp plugin list`
- `wp theme list`
Only enable write operations in dedicated deploy/maintenance workflows.
@@ -0,0 +1,23 @@
# Cron, caches, and rewrites
Use this file when debugging background jobs or “changes not visible”.
## Cron
- List scheduled events:
- `wp cron event list`
- Run a specific event now:
- `wp cron event run <hook>`
## Cache + rewrite
- Flush object cache:
- `wp cache flush`
- Flush rewrite rules:
- `wp rewrite flush`
## Guardrails
- Dont “run all cron events” on production without understanding impact.
- Cache flush can cause load spikes; coordinate if needed.
@@ -0,0 +1,17 @@
# Debugging WP-CLI
## WP not found / wrong WP root
- Run `wp --info`.
- Provide `--path=<wordpress-root>` if WP is not in the current directory.
- Confirm `wp-config.php` exists in the expected root.
## HTTP/URL targeting issues
- On multisite, include `--url=<site-url>` for site-specific actions.
## Permission/file ownership issues
- If running in containers, ensure youre using the same user/volume mapping as the app.
- Avoid `--allow-root` unless you understand the environment and have no alternative.
@@ -0,0 +1,22 @@
# Multisite targeting
Use this file any time you might be operating on multisite.
## Key flags
- `--url=<site-url>` targets a specific site/blog context.
- `--network` applies to the network where supported.
## Common commands
- List sites:
- `wp site list`
- Get site options for a specific site:
- `wp option get siteurl --url=<site-url>`
## Guardrails
- Always include `--url` when you mean “one site” in a multisite install.
- If you need to run something across sites, prefer scripting:
- list sites → iterate → run a safe per-site command.
@@ -0,0 +1,22 @@
# Plugin/theme operations
Use this file for installs, activation, updates, and listing state.
## Common commands
- Plugins:
- `wp plugin list`
- `wp plugin status <slug>`
- `wp plugin activate <slug>`
- `wp plugin deactivate <slug>`
- `wp plugin update --all`
- Themes:
- `wp theme list`
- `wp theme activate <slug>`
- `wp theme update --all`
## Guardrails
- On production, avoid `update --all` without a maintenance window.
- On multisite, plugin activation may be per-site or network-wide; confirm intent.
@@ -0,0 +1,30 @@
# Safety rules (WP-CLI)
Use this file before running any write operations.
## Golden rules
- Assume production is **unsafe** unless explicitly confirmed.
- Always confirm targeting:
- `--path` (WordPress root)
- `--url` (multisite / specific site targeting)
- Prefer a backup (`wp db export`) before risky operations.
- Prefer `--dry-run` where available (especially `search-replace`).
## High-risk commands (require explicit confirmation)
- `wp db reset`
- `wp db import` (overwrites data)
- `wp search-replace` (can affect serialized data and URLs)
- bulk deletes (`wp post delete --force --all`, `wp user delete --reassign`, etc.)
- plugin/theme mass updates on production
## Logging
For ops scripts, log:
- date/time
- environment (dev/staging/prod)
- exact WP-CLI commands
- exit codes
@@ -0,0 +1,40 @@
# Safe `wp search-replace`
Use this file when migrating domains, switching http→https, or changing paths.
## Recommended workflow
1. Backup:
- `wp db export`
2. Dry run:
- `wp search-replace OLD NEW --dry-run`
3. Run for real (carefully choose scope):
- consider `--all-tables-with-prefix` if you need to include non-core tables with the WP prefix
4. Flush:
- `wp cache flush`
- `wp rewrite flush`
## Multisite notes
For multisite, decide whether youre replacing:
- a single site (`--url=...`), or
- across the network (`--network` or iterating `wp site list`).
Read:
- `references/multisite.md`
## Common flags
- `--dry-run`
- `--precise` (slower but can be safer in complex cases)
- `--skip-columns=...` (avoid touching large/binary columns)
- `--report-changed-only`
## Serialization caution
WP-CLI search-replace is designed to handle PHP serialized data, but you must still:
- avoid replacing within binary/blob columns
- validate results with application smoke tests