Skip to content

Instantly share code, notes, and snippets.

@drawcard
Last active March 21, 2017 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drawcard/c48fe93ae60b7155ac083afdf0218492 to your computer and use it in GitHub Desktop.
Save drawcard/c48fe93ae60b7155ac083afdf0218492 to your computer and use it in GitHub Desktop.
Wordpress Setup & Management 2017

WP-CLI Stuff

Handy Shortcuts

Search & Replace Database

### Remove "dry-run" to write the changes to the DB! 
### Run "wp db export" to back up DB first!

DO NOT BLINDLY COPY AND PASTE THESE, CHANGE THE DIRECTORY PATHS IN THEM FIRST!

# Standard WP Single Sites
wp search-replace "//local.dev/clients/drawcard/www" "//example.com" --recurse-objects --skip-columns=guid --dry-run
wp search-replace "/var/www/public/clients/drawcard/www" "/home/useraccount/public_html" --recurse-objects --skip-columns=guid --dry-run

# Network / Multisites
wp search-replace --url=http://local.dev/clients/drawcard/www "//local.dev/clients/drawcard/www" "//example.com" --recurse-objects --network --skip-columns=guid --dry-run
wp search-replace --url=http://local.dev/clients/drawcard/www "/home/useraccount/public_html" "//example.com" --recurse-objects --network --skip-columns=guid --dry-run

Fix permissions in Wordpress directory (eg. if you get 403 Forbidden notices)

From this StackOverflow answer

cd /var/www
sudo gpasswd -a "$USER" www-data
sudo chown -R "$USER":www-data .
sudo find . -type f -exec chmod 0660 {} \;
sudo find . -type d -exec chmod 2770 {} \;
sudo chmod -R g+s . #set defaults for future files & folders

Create a new administrative user

wp user create [username] [user@email.com] --role=administrator

Reset a password

wp user list # Lookup the user's ID
wp user update [userid] --display_name=[username] --user_pass=[newpassword]

Install useful plugins

# Copy and paste this whole block into terminal.

wp plugin install --activate https://github.com/afragen/github-updater/archive/develop.zip `# Github Plugin Updater` 
wp plugin install --activate https://github.com/wp-sync-db/wp-sync-db/archive/master.zip `# WP Sync DB` 
wp plugin install --activate https://github.com/wp-sync-db/wp-sync-db-media-files/archive/master.zip `# WP Sync DB Media Files Addon` 
wp plugin install --activate wordfence `# Wordfence` 
wp plugin install --activate elementor `# Elementor (install the Pro plugin manually from www.elementor.com/pro)` 
wp plugin list

Sage

Handy Shortcuts

Kill all yarn processes; run a build && run a watch command

pkill node ; yarn run build:production && yarn run start &

config.json settings

For Digital Ocean site:

"publicPath": "/wp-content/themes/sage-clientname/",
"devUrl": "https://drawcard.site/clientname/",
"proxyUrl": "https://drawcard.site:3000/clientname",

General

Password protect directory on server

# If not already done so, get the useful "mellon" script
git clone https://github.com/drawcard/mellon ~/.mellon
echo "alias mellon='sh ~/.mellon/mellon'" >> ~/.bash_aliases
source ~/.bashrc
# Generate a htpasswd & htaccess combo
cd /path/to/wp/folder 
mellon foobar #foobar is the username you wish to create
# Answer the prompts with a password of your choice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment