Skip to content

Instantly share code, notes, and snippets.

@hiranthi

hiranthi/base.txt

Last active Mar 10, 2019
Embed
What would you like to do?
WP-CLI stuff :)
# Paths: DirectAdmin
# USER: change to correct username
# DOMAIN: change to the correct domainname
# Core stuff
$ wp core version --path=/home/USER/domains/DOMAIN/public_html/
$ wp core download --skip-content --force --version=latest --path=/home/USER/domains/DOMAIN/public_html/
$ wp core update-db --path=/home/USER/domains/DOMAIN/public_html/ --dry-run
$ wp core verify-checksums --path=/home/USER/domains/DOMAIN/public_html/
# Plugins
$ wp plugin list --format=table --fields=title,update_version --path=/home/USER/domains/DOMAIN/public_html/
$ wp plugin install wordfence --activate --path=/home/USER/domains/DOMAIN/public_html/
$ wp plugin update --all --path=/home/USER/domains/DOMAIN/public_html/ --dry-run
$ wp plugin verify-checksums --all --strict --path=/home/USER/domains/DOMAIN/public_html/
$ wp eval 'wordfence::importSettings($token_from_other_wordfence_install);' --path=/home/USER/domains/DOMAIN/public_html/
# Themes
$ wp theme list --format=table --fields=title,update_version --path=/home/USER/domains/DOMAIN/public_html/
$ wp theme update --path=/home/USER/domains/DOMAIN/public_html/ --dry-run
# Users
$ wp user list --path=/home/USER/domains/DOMAIN/public_html/
$ wp user reset-password admin editor --path=/home/USER/domains/DOMAIN/public_html/
# Comments
$ wp comment delete $(wp comment list --status=spam --format=ids) --path=/home/USER/domains/DOMAIN/public_html/
# Database
$ wp db check --path=/home/USER/domains/DOMAIN/public_html/
$ wp db repair --path=/home/USER/domains/DOMAIN/public_html/
$ wp db optimize --path=/home/USER/domains/DOMAIN/public_html/
$ wp config set DB_PASSWORD 'MY_AWESOME_UNIQUE_PASSWORD' --path=/home/USER/domains/DOMAIN/public_html/
$ wp db query < query.sql --path=/home/USER/domains/DOMAIN/public_html/
# Doctor
$ wp package install git@github.com:wp-cli/doctor-command.git
$ wp doctor check --all --format=table --path=/home/USER/domains/DOMAIN/public_html/
$ wp cache flush --path=/home/USER/domains/DOMAIN/public_html/
# Some awesome queries
<?php
/**
** Search / Replace (ie to change domainname)
**
** - https://github.com/wp-cli/search-replace-command
** - https://developer.wordpress.org/cli/commands/theme/mod/
**/
/**
** Running from PHP
**
** - https://github.com/wp-cli/wp-cli/issues/1924
** define( 'WP_CLI_ROOT', '/path/to/wp-cli' );
** include WP_CLI_ROOT . '/php/wp-cli.php';
**/
/**
** WP-config + Core
**
** - https://developer.wordpress.org/cli/commands/config/shuffle-salts/
** - https://developer.wordpress.org/cli/commands/config/list/
** - https://developer.wordpress.org/cli/commands/config/set/
** - https://developer.wordpress.org/cli/commands/core/download/
**/
/**
** Doctor command - add for WP-CLI
**
** - https://github.com/wp-cli/doctor-command
** - https://github.com/wp-cli/doctor-command/blob/master/bin/readme/overview-body.md
** - https://runcommand.io/
** - https://danielbachhuber.com/tip/write-custom-check/
** - https://danielbachhuber.com/tip/check-file-contents/
** - https://danielbachhuber.com/tip/customize-doctor-config/
** - https://danielbachhuber.com/tip/doctor-default-checks/
**
** - https://github.com/anhskohbo/wp-cli-themecheck
** - https://github.com/markri/wp-sec
** - https://developer.wordpress.org/cli/commands/profile/
**/
/**
** DB Management
**
** # Execute a SQL query stored in a file
** $ wp db query < debug.sql
**
** - https://developer.wordpress.org/cli/commands/db/
** - https://developer.wordpress.org/cli/commands/db/check/
** - https://developer.wordpress.org/cli/commands/db/optimize/
** - https://developer.wordpress.org/cli/commands/db/repair/
**
** - https://gist.github.com/tfirdaus/d67a03687217a7f462d516c5750a4fdd
**/
/**
** Comment Management
**
** # Delete all spam comments.
** $ wp comment delete $(wp comment list --status=spam --format=ids)
**
** - https://developer.wordpress.org/cli/commands/comment/
**/
/**
** User Management
**
** - https://developer.wordpress.org/cli/commands/user/
** - https://developer.wordpress.org/cli/commands/user/list/
** - https://developer.wordpress.org/cli/commands/user/spam/
** - https://developer.wordpress.org/cli/commands/user/reset-password/
** - https://developer.wordpress.org/cli/commands/user/delete/
**/
/**
** Other
**
** - https://danielbachhuber.com/tips/
** - https://danielbachhuber.com/tip/identify-wordpress-slowness/
** - http://wp-cli.org/package-index/
** - https://www.siteground.com/tutorials/wordpress/wp-cli/
** - http://wiki.devliegendebrigade.nl/WP-CLI_(commando%27s)
** - https://gist.github.com/petskratt/47618c879fa6ddbcb2b07d46bd1b21e5
** - https://tomjn.com/2014/03/01/wordpress-bash-magic/
** - https://make.wordpress.org/cli/handbook/config/
** - https://www.smashingmagazine.com/2015/09/wordpress-management-with-wp-cli/
** - https://make.wordpress.org/cli/handbook/internal-api/
** - https://guides.wp-bullet.com/how-to-batch-zip-backup-install-wordpress-plugins-with-wp-cli/
** - https://guides.wp-bullet.com/using-wp-cli-for-batch-updating-contact-form-7-postmeta-options/
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment