Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Preview:

DESCRIPTION

Extending your WordPress Toolbelt with WP-CLI presentation from WordCamp Austin 2014. March 27, 2014.

Citation preview

Extending Your WordPress Toolbelt

with WP-CLI

WordCamp Austin 2014 Ryan Duff

# whoami

• WordPress Developer

• Open Source Contributor

• Sysadmin (sort of)

What is WP-CLI?

WP-CLI is a set of command-line tools for managing WordPress installations.

WP-CLI is a set of command-line tools for managing WordPress installations.

So Let’s Get Started

Requirements

• UNIX-like environment (OS X, Linux, FreeBSD, Cygwin)

• PHP 5.3.2 or later

• WordPress 3.5.2 or later

!

• Basic knowledge of the command line

What Does It Do?

What Does It Do?Everything... almost

!

!

!

!

!

What Does It Do?Everything... almost

!

!

!

!

Sorry… it won’t make you coffee.

Top Level Commands

Download, Configure, Install

wp core download!!

!!

wp core config !! --dbname=wcatx !! --dbuser=wcatx !! --dbpass=wcatx!

!

wp core install !! --url=“http://wcatx.dev” !! --title="Site Name" !! --admin_user=notadmin !! --admin_password=somethingstrong !! --admin_email="user@site.com"

wp option update timezone_string “America/New_York"!!wp rewrite structure ‘/%year%/%monthnum%/%postname%/‘ --hard

Install and Manage Plugins

Install and Manage Themes

Import / Export

wp import!!wp export

Managing the Database

wp db export!wp db import!!!wp db cli!!!wp site empty

Search and Replace

wp search-replace!!wp search-replace “oldsite.dev” “newsite.com”!!!--network!--dry-run

Posts

Comments

Media

wp media regenerate --yes

Users Roles

Capabilities

Multisite Rewrites Options

Terms Menus

Sidebars Widgets

Plugin or Theme developer?

English please?

Community Commands

Community Commands

http://wp-cli.org/package-index/

Dictator

Dictator

Your Own Commands

WP-CLI API

https://github.com/wp-cli/wp-cli/wiki/API

How to Install

The Quick Lazy Easy Way™

# mkdir -p ~/.wp-cli/bin !!# cd ~/.wp-cli!!# curl -L https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > bin/wp!!# chmod +x bin/wp!!!# curl -LO https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash

Almost ready…

Add to ~/.bash_profile, .zshrc, etc !

# add to $PATH export PATH=$HOME/.wp-cli/bin:$PATH !

# autocomplete source $HOME/.wp-cli/wp-completion.bash

Using ZSH?

# autocomplete autoload bashcompinit bashcompinit source $HOME/.wp-cli/wp-completion.bash

MAMP or other custom PHP

export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH

Installing the Better Way™

(so you can contribute, of course)

# git clone git@github.com:ryanduff/wp-cli.git ~/.wp-cli!!# cd wp-cli!!# git remote add upstream git@github.com:wp-cli/wp-cli.git!!# composer install

Almost ready…

Add to ~/.bash_profile, .zshrc, etc !

# add to $PATH export PATH=$HOME/.wp-cli/wp-cli/bin:$PATH !

# autocomplete source $HOME/.wp-cli/wp-cli/utils/wp-completion.bash

More InfoWeb: http://wp-cli.org/ !

Core Commands: http://wp-cli.org/commands/ !

Cookbook: https://github.com/wp-cli/wp-cli/wiki/Commands-Cookbook !

Github: https://github.com/wp-cli/wp-cli

Contributing

https://github.com/wp-cli/wp-cli/blob/master/CONTRIBUTING.md

!

https://help.github.com/articles/fork-a-repo

Questions?

Ryan Duff !

!

email: ryan@fusionized.com !

web: http://fusionized.com !

twitter: @ryancduff !

github: https://github.com/ryanduff