Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
WP-CLI: Save Time by
Managing WordPress
from the Command Line
WordCamp NYC 2015 Designers Track	

!
Shawn Hooper

Chief Te...
• I’m Shawn Hooper, a web application
developer from Ottawa.
• I’ve been working in WordPress since
2009.
• I love the wor...
Command Line?!
@shawnhooper - shawnhooper.ca
• A set of command line tools that allows
you to manage WordPress from the
command line.

• http://www.wp-cli.org/
What is...
• Anyone really, but mostly:
• Developers
• Theme Designers
• Server Administrators
Who is this for?
@shawnhooper - shawnh...
Don’t Fear The
Command Line
@shawnhooper - shawnhooper.ca
• http://www.wp-cli.org/
• Requires PHP 5.3.2 or later
• Requires WordPress 3.5.2 or later
• A “UNIX-like” environment:
• ...
• You need to have SSH access to use
WP-CLI. Some shared hosting packages
do not allow SSH access
• PlanetHoster, SiteGrou...
• Download it:

curl -O https://raw.githubusercontent.com/
wp-cli/builds/gh-pages/phar/wp-cli.phar

• Set permissions: 

c...
• Does it work? Type:



wp

Installing WP-CLI
@shawnhooper - shawnhooper.ca
Installing WP-CLI
@shawnhooper - shawnhooper.ca
Congratulations!
(that was the hard part)
@shawnhooper - shawnhooper.ca
Great… It’s installed.
So now what….
@shawnhooper - shawnhooper.ca
wp <command> <sub-command> <params>
Running Commands:
@shawnhooper - shawnhooper.ca
<param> — required
[—param] — optional flag
[—param=<value>] — optional w/ value
Running Commands:
@shawnhooper - shawnhoop...
• Check current WordPress version, or
see if there are updates available.
• Do the update!
• Install a brand new site
• Co...
• Let’s try setting up a brand new site on
a development server using:



wp core download

wp core config

wp db create

w...
• Install, Delete Plugins
• Activate & Deactivate Plugins
• Update Plugins
• Search the repository for plugins
plugin
@sha...
• Time savers!



wp plugin update — all



wp plugin deactivate — all
plugin
@shawnhooper - shawnhooper.ca
The “db” command interacts with
the MySQL database.
!
wp db export backup.sql



wp db import backup.sql



wp db cli
db
@...
• Safe Search & Replace, including
serialized arrays!

• Supports --dry-run
search-replace
@shawnhooper - shawnhooper.ca
Generate Test Content !
wp post generate --count=500
post
@shawnhooper - shawnhooper.ca
Create Posts with Random
Content using Any Ipsum Plugin
!
wp plugin install any-ipsum —
activate

wp any-ipsum generate-po...
Regenerate Thumbnails
!
wp media regenerate —yes
media
@shawnhooper - shawnhooper.ca
Start an underscores theme!
!
wp scaffold _s mytheme
scaffold
@shawnhooper - shawnhooper.ca
… or a child theme
!
wp scaffold child-theme mychild
—parent_theme=twentyfourteen
scaffold
@shawnhooper - shawnhooper.ca
… or a custom post type
!
wp scaffold post-type mycpt —
theme
scaffold
@shawnhooper - shawnhooper.ca
Download & Activate a Theme
from WordPress.org
!
wp theme install simone —activate
theme
@shawnhooper - shawnhooper.ca
wp user generate
wp user import-csv
Create Users
@shawnhooper - shawnhooper.ca
wp term list
wp term create
wp term generate
Taxonomies
@shawnhooper - shawnhooper.ca
Executes PHP code

* after loading the WordPress Core *
eval & eval-file
@shawnhooper - shawnhooper.ca
wp role create
wp role list
wp role exists
!
new: —clone flag on create
role & cap
@shawnhooper - shawnhooper.ca
Launches PHP’s Built-in Web Server
!
wp server
server
@shawnhooper - shawnhooper.ca
Add any functionality you want
that isn’t already included in the
WP-CLI core.
https://github.com/wp-cli/wp-cli/
wiki/List...
You can either write them as a
plugin, or include it using the

—require parameter

on the command line.
Community
Command...
Thank you!

Slides: www.shawnhooper.ca

E-Mail: shawn@actionablebooks.com

Twitter: @shawnhooper

WordPress Slack: shooper...
Upcoming SlideShare
Loading in …5
×

WP-CLI Presentation from WordCamp NYC 2015

901 views

Published on

Managing WordPress from the Command Line. Presentation given in the designer track at WordCamp NYC 2015.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

WP-CLI Presentation from WordCamp NYC 2015

  1. 1. WP-CLI: Save Time by Managing WordPress from the Command Line WordCamp NYC 2015 Designers Track ! Shawn Hooper
 Chief Technology Officer,Actionable Books @shawnhooper - shawnhooper.ca
  2. 2. • I’m Shawn Hooper, a web application developer from Ottawa. • I’ve been working in WordPress since 2009. • I love the working from the command prompt, reminds me of my days running a BBS (in the days before the Internet) Hi! @shawnhooper - shawnhooper.ca
  3. 3. Command Line?! @shawnhooper - shawnhooper.ca
  4. 4. • A set of command line tools that allows you to manage WordPress from the command line.
 • http://www.wp-cli.org/ What is WP-CLI ? @shawnhooper - shawnhooper.ca
  5. 5. • Anyone really, but mostly: • Developers • Theme Designers • Server Administrators Who is this for? @shawnhooper - shawnhooper.ca
  6. 6. Don’t Fear The Command Line @shawnhooper - shawnhooper.ca
  7. 7. • http://www.wp-cli.org/ • Requires PHP 5.3.2 or later • Requires WordPress 3.5.2 or later • A “UNIX-like” environment: • OSX (Macintosh) • Linux • Cygwin (Windows) What do you need? @shawnhooper - shawnhooper.ca
  8. 8. • You need to have SSH access to use WP-CLI. Some shared hosting packages do not allow SSH access • PlanetHoster, SiteGround, Pantheon, BlueHost, GoDaddy, Media Temple, Windows Azure and more now have CLI support. • VPS services like Digital Ocean and Linode, InterServer are ideal. Hosts @shawnhooper - shawnhooper.ca
  9. 9. • Download it:
 curl -O https://raw.githubusercontent.com/ wp-cli/builds/gh-pages/phar/wp-cli.phar
 • Set permissions: 
 chmod +x wp-cli.phar
 • Move it somewhere useful:
 sudo mv wp-cli.phar /usr/local/bin/wp 
 Installing WP-CLI @shawnhooper - shawnhooper.ca
  10. 10. • Does it work? Type:
 
 wp
 Installing WP-CLI @shawnhooper - shawnhooper.ca
  11. 11. Installing WP-CLI @shawnhooper - shawnhooper.ca
  12. 12. Congratulations! (that was the hard part) @shawnhooper - shawnhooper.ca
  13. 13. Great… It’s installed. So now what…. @shawnhooper - shawnhooper.ca
  14. 14. wp <command> <sub-command> <params> Running Commands: @shawnhooper - shawnhooper.ca
  15. 15. <param> — required [—param] — optional flag [—param=<value>] — optional w/ value Running Commands: @shawnhooper - shawnhooper.ca
  16. 16. • Check current WordPress version, or see if there are updates available. • Do the update! • Install a brand new site • Convert an existing site to Multisite! • Verify core checksums core @shawnhooper - shawnhooper.ca
  17. 17. • Let’s try setting up a brand new site on a development server using:
 
 wp core download
 wp core config
 wp db create
 wp core install --prompt core @shawnhooper - shawnhooper.ca
  18. 18. • Install, Delete Plugins • Activate & Deactivate Plugins • Update Plugins • Search the repository for plugins plugin @shawnhooper - shawnhooper.ca
  19. 19. • Time savers!
 
 wp plugin update — all
 
 wp plugin deactivate — all plugin @shawnhooper - shawnhooper.ca
  20. 20. The “db” command interacts with the MySQL database. ! wp db export backup.sql
 
 wp db import backup.sql
 
 wp db cli db @shawnhooper - shawnhooper.ca
  21. 21. • Safe Search & Replace, including serialized arrays!
 • Supports --dry-run search-replace @shawnhooper - shawnhooper.ca
  22. 22. Generate Test Content ! wp post generate --count=500 post @shawnhooper - shawnhooper.ca
  23. 23. Create Posts with Random Content using Any Ipsum Plugin ! wp plugin install any-ipsum — activate
 wp any-ipsum generate-posts 100 post @shawnhooper - shawnhooper.ca
  24. 24. Regenerate Thumbnails ! wp media regenerate —yes media @shawnhooper - shawnhooper.ca
  25. 25. Start an underscores theme! ! wp scaffold _s mytheme scaffold @shawnhooper - shawnhooper.ca
  26. 26. … or a child theme ! wp scaffold child-theme mychild —parent_theme=twentyfourteen scaffold @shawnhooper - shawnhooper.ca
  27. 27. … or a custom post type ! wp scaffold post-type mycpt — theme scaffold @shawnhooper - shawnhooper.ca
  28. 28. Download & Activate a Theme from WordPress.org ! wp theme install simone —activate theme @shawnhooper - shawnhooper.ca
  29. 29. wp user generate wp user import-csv Create Users @shawnhooper - shawnhooper.ca
  30. 30. wp term list wp term create wp term generate Taxonomies @shawnhooper - shawnhooper.ca
  31. 31. Executes PHP code
 * after loading the WordPress Core * eval & eval-file @shawnhooper - shawnhooper.ca
  32. 32. wp role create wp role list wp role exists ! new: —clone flag on create role & cap @shawnhooper - shawnhooper.ca
  33. 33. Launches PHP’s Built-in Web Server ! wp server server @shawnhooper - shawnhooper.ca
  34. 34. Add any functionality you want that isn’t already included in the WP-CLI core. https://github.com/wp-cli/wp-cli/ wiki/List-of-community-commands Community Commands @shawnhooper - shawnhooper.ca
  35. 35. You can either write them as a plugin, or include it using the
 —require parameter
 on the command line. Community Commands @shawnhooper - shawnhooper.ca
  36. 36. Thank you!
 Slides: www.shawnhooper.ca
 E-Mail: shawn@actionablebooks.com
 Twitter: @shawnhooper
 WordPress Slack: shooper @shawnhooper - shawnhooper.ca

×