60
Extending Your WordPress Toolbelt with WP-CLI WordCamp Austin 2014 Ryan Duff

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

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Extending Your WordPress Toolbelt

with WP-CLI

WordCamp Austin 2014 Ryan Duff

Page 2: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

# whoami

• WordPress Developer

• Open Source Contributor

• Sysadmin (sort of)

Page 3: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

What is WP-CLI?

Page 4: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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

Page 5: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 6: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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

Page 7: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

So Let’s Get Started

Page 8: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Requirements

Page 9: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

• 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

Page 10: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

What Does It Do?

Page 11: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

What Does It Do?Everything... almost

!

!

!

!

!

Page 12: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

What Does It Do?Everything... almost

!

!

!

!

Sorry… it won’t make you coffee.

Page 13: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Top Level Commands

Page 14: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Download, Configure, Install

Page 15: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

wp core download!!

!!

Page 16: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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="[email protected]"

Page 17: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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

Page 18: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Install and Manage Plugins

Page 19: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 20: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 21: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 22: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Install and Manage Themes

Page 23: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 24: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Import / Export

wp import!!wp export

Page 25: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Managing the Database

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

Page 26: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Search and Replace

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

Page 27: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Posts

Page 28: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Comments

Page 29: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Media

wp media regenerate --yes

Page 30: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Users Roles

Capabilities

Page 31: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Multisite Rewrites Options

Page 32: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Terms Menus

Sidebars Widgets

Page 33: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Plugin or Theme developer?

Page 34: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 35: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

English please?

Page 36: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Community Commands

Page 37: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Community Commands

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

Page 38: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Dictator

Page 39: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Dictator

Page 40: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Your Own Commands

Page 41: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 42: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 43: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

WP-CLI API

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

Page 44: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

How to Install

Page 45: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

The Quick Lazy Easy Way™

Page 46: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

# 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

Page 47: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 48: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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

Page 49: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Using ZSH?

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

Page 50: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

MAMP or other custom PHP

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

Page 51: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 52: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Installing the Better Way™

Page 53: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

(so you can contribute, of course)

Page 54: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

# git clone [email protected]:ryanduff/wp-cli.git ~/.wp-cli!!# cd wp-cli!!# git remote add upstream [email protected]:wp-cli/wp-cli.git!!# composer install

Page 55: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Page 56: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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

Page 57: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

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

Page 58: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Contributing

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

!

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

Page 59: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Questions?

Page 60: Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014

Ryan Duff !

!

email: [email protected] !

web: http://fusionized.com !

twitter: @ryancduff !

github: https://github.com/ryanduff