Advertisement
Advertisement

More Related Content

Advertisement

WP-CLI Talk from WordCamp Montreal

  1. WP-CLI: Save Time by Managing WordPress from the Command Line WordCamp Montreal, July 4, 2015 ! Shawn Hooper, CTO,Actionable Books @shawnhooper - shawn@actionablebooks.com
  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!
  3. Command Line?!
  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 ?
  5. • Anyone really, but mostly: • Developers • Theme Designers • Server Administrators Who is this for?
  6. Don’t Fear The Command Line
  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?
  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 are ideal. Hosts
  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
  10. • Does it work? Type:
 
 wp
 Installing WP-CLI
  11. Installing WP-CLI
  12. Congratulations! (that was the hard part)
  13. Great… It’s installed. So now what….
  14. wp <command> <sub-command> <params> Running Commands:
  15. <param> — required [—param] — optional flag [—param=<value>] — optional w/ value Running Commands:
  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
  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
  18. • Install, Delete Plugins • Activate & Deactivate Plugins • Update Plugins • Search the repository for plugins plugin
  19. • Time savers!
 
 wp plugin update — all
 
 wp plugin deactivate — all plugin
  20. The “db” command interacts with the MySQL database. ! wp db export backup.sql
 
 wp db import backup.sql
 
 wp db cli db
  21. • Safe Search & Replace, including serialized arrays!
 • Supports --dry-run search-replace
  22. Generate Test Content ! wp post generate --count=500 post
  23. Regenerate Thumbnails ! wp media regenerate —yes media
  24. Start an underscores theme! ! wp scaffold _s mytheme scaffold
  25. … or a child theme ! wp scaffold child-theme mychild —parent_theme=twentyfourteen scaffold
  26. … or a custom post type ! wp scaffold post-type mycpt — theme scaffold
  27. Download & Activate a Theme from WordPress.org ! wp theme install simone —activate theme
  28. wp user generate wp user import-csv Create Users
  29. wp term list wp term create wp term generate Taxonomies
  30. Executes PHP code
 * after loading the WordPress Core * eval & eval-file
  31. 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
  32. You can either write them as a plugin, or include it using the
 —require parameter
 on the command line. Community Commands
  33. Thank you! ! E-Mail: shawn@actionablebooks.com ! ! Twitter: @shawnhooper WordPress Slack: shooper
Advertisement