A Professional WP-CLI Toolkit for safe WordPress Automation, Content Operations, Metadata, Taxonomies, Media, Maintenance, and Bulk Administration.
This repository demonstrates practical, production-oriented patterns for administering WordPress at scale through WP-CLI: bulk content and metadata operations, taxonomy and multilingual auditing, and safe handling of destructive operations such as search-and-replace. It is built around a single principle: batch operations against a live site must default to reporting, not writing, until explicitly confirmed.
- Dry-run-by-default scripts for bulk post meta updates, featured image assignment, and search-and-replace.
- A mandatory backup step that exports the database and records core and plugin versions before any destructive operation.
- Read-only audit scripts for taxonomy structure, multilingual translation coverage (Polylang), and SEO metadata completeness (Yoast SEO).
- An environment check that verifies WP-CLI availability, a valid WordPress installation, and database connectivity before other scripts run.
- A custom WP-CLI command example and an mu-plugin helper example, both written to current WordPress Coding Standards with sanitization, validation, escaping, capability checks, and nonce verification where relevant.
Every script that can modify data follows the same pattern: dry run first,
explicit confirmation flag required to write, and a documented
recommendation to back up the database beforehand. Read-only audit scripts
never modify data and are safe to run repeatedly. PHP examples follow
current WordPress Coding Standards, use $wpdb->prepare() for any dynamic
SQL, sanitize all input, escape all output, and check user capabilities
before performing privileged actions.
- WP-CLI installed and available on the system path.
- A WordPress 6.x or later installation.
- Bash (or a compatible shell) for the shell scripts.
- Polylang, for the multilingual audit script.
- Yoast SEO, for the SEO metadata audit script.
# Verify the environment before running anything else.
./scripts/wp-cli-environment-check.sh --path=/path/to/wordpress
# Back up before any destructive operation.
./scripts/wp-cli-backup-before-destructive.sh \
--path=/path/to/wordpress --output=/path/to/backups
# Dry run a search-and-replace, then confirm.
./scripts/wp-cli-safe-search-replace.sh \
--path=/path/to/wordpress \
--search="http://old.example.com" --replace="https://new.example.com"
./scripts/wp-cli-safe-search-replace.sh \
--path=/path/to/wordpress \
--search="http://old.example.com" --replace="https://new.example.com" --confirm
# Bulk update post meta from a CSV file (dry run, then confirm).
./scripts/wp-cli-bulk-post-meta-update.sh \
--path=/path/to/wordpress --meta-key=_custom_field --csv=/path/to/values.csv
# Read-only audits.
./scripts/wp-cli-taxonomy-audit.sh --path=/path/to/wordpress
./scripts/wp-cli-multilingual-audit.sh --path=/path/to/wordpress --post-type=post
./scripts/wp-cli-seo-metadata-audit.sh --path=/path/to/wordpress --post-type=postwp-cli-operations-toolkit/
README.md
LICENSE
.gitignore
docs/
wp-cli-safety-guidelines.md
multilingual-wordpress-operations.md
seo-metadata-operations.md
scripts/
wp-cli-environment-check.sh
wp-cli-backup-before-destructive.sh
wp-cli-safe-search-replace.sh
wp-cli-bulk-post-meta-update.sh
wp-cli-featured-image-batch.sh
wp-cli-taxonomy-audit.sh
wp-cli-multilingual-audit.sh
wp-cli-seo-metadata-audit.sh
examples/
custom-wp-cli-command-bulk-meta-update.php
mu-plugin-safe-batch-helpers.php
featured-images-map.csv
- No script in this repository contains credentials, API keys, tokens, or environment-specific infrastructure details. All paths and domains in the usage examples are placeholders.
- Destructive scripts (
wp-cli-safe-search-replace.sh,wp-cli-bulk-post-meta-update.sh,wp-cli-featured-image-batch.sh) default to dry-run mode and require an explicit--confirmflag to write changes. - Run
wp-cli-backup-before-destructive.shbefore applying any destructive script to a production database. - These scripts are examples meant to be reviewed and adapted before use against a production site; they are not a packaged plugin.
See docs/wp-cli-safety-guidelines.md for the full safety guidelines.
This toolkit reflects the WordPress automation and administration practices used in production work by Didac Soria (https://didacsoria.com) and through StudioDDC (https://studioddc.com), a digital studio combining WordPress Engineering, Technical SEO, Web Development, and Web Infrastructure.
Released under the MIT License. See LICENSE for details.