Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Making Your Whole* Life Easier With WP-CLI

Making Your Whole* Life Easier With WP-CLI

Presentation from WordCamp St. Louis 2014.

*Okay, maybe not your WHOLE life.

Doug Stewart

March 01, 2014
Tweet

More Decks by Doug Stewart

Other Decks in Programming

Transcript

  1. Doug Stewart ! @zamoose Senior Systems Engineer 10up *Okay, maybe

    not your whole life. Making Your Whole* Life Easier With WP-CLI WordCamp St. Louis 2014
  2. “A command-line interface (CLI) […] is a means of interacting

    with a computer program where the user (or client) issues commands to the program in the form of successive lines of text (command lines).” Source: Wikipedia (http://stwrt.org/cli-wiki)
  3. “Command-line interfaces are often preferred by more advanced computer users,

    as they often provide a more Source: Wikipedia (http://stwrt.org/cli-wiki) concise and powerful means to control a program or operating system.”
  4. “Programs with command-line interfaces are generally easier to automate via

    scripting.” Source: Wikipedia (http://stwrt.org/cli-wiki)
  5. The “Hard” Easy Way 1. Download WP. 2. Extract zip.

    3. Connect to your host using SFTP*. 4. Change to the right directory. 5. Upload WordPress directory. 6. Repeat steps 1-5 for any other sites you might be installing. *You are using SFTP, right? RIGHT?
  6. The Easy Way 1. Log in to server via SSH*.

    2. Change to the right directory**. 3. Run `wp core download`. 4. Run steps 2-3 for any other sites you might be installing. • Oh, by the way, WP-CLI caches the WP download, so every subsequent install will go even faster. *You are using SSH, right? RIGHT? **Technically, you can just pass “—path=[path to directory]” to WP-CLI
  7. Multisite the Hard Way 1. Prepare your WordPress 2. Allow

    Multisite A. Edit wp-config.php 3. Installing a Network B. Sub-domains or sub-folders? C. Double-check values D. Click “Install” 4. Enabling the Network E. Edit wp-config.php F. Edit .htaccess 5. Network Admin Settings 6. Administration From http://codex.wordpress.org/Create_A_Network
  8. Multisite the Easy Way 1. Change into your WordPress directory.

    2. `wp core multisite-install`* 3. `wp site create`
  9. *Due to a bug** in current versions of WP- CLI,

    .htaccess rules don’t get auto-generated. Copy and paste*** the rules from the Codex****. **http://stwrt.org/wp-cli-bug-790 ! ***C’mon, you’re already on the command line. A little vim won’t hurt. ! ****http://stwrt.org/codex-htaccess
  10. Test Users the Hard Way 1. Log in to /wp-admin/.

    2. Navigate to Users->Add New. 3. Fill out dummy information for your test users. 4. Repeat steps 2-3 a hundred times.
  11. Test Users the Easy Way 1. Log in to your

    server. 2.Change into your WordPress installation’s directory*. 3.Run `wp user generate`. 4.There is no step 4.
  12. Create Dummy Content the Hard Way 1. Navigate to Posts->Add

    New. 2. Open another browser tab. 3. Go to http://loripsum.net/ 4. Copy dummy text. 5. Go back to the New Post screen. 6. Paste the Lorem. 7. Save the post. 8. Repeat steps 1-7 several hojillion* times. *Old English Standard unit for measure of quantity. SI equivalent is “metric boat-load”
  13. Create Dummy Content the Easy Way 1. Log on to

    your server. 2. Change to your WordPress directory. 3. Run `curl http://loripsum.net/api/5 | wp post generate --post_content —count=[one hojillion]`
  14. Lots of stuff the Easy way 1. `wp scaffold` •

    Plugin • Child theme • _s • Custom post type • Custom taxonomy 2. `wp search-replace` 3. `wp db` • Optimize/repair/import/export/CLI 4. `wp theme-test` 5. `wp export`/`wp import`
  15. Straight From The Source* • http://wp-cli.org • Follow the instructions

    • *Pun intended. • You should also follow @wpcli on Twitter.
  16. • Amimoto • Bluehost • Dreamhost • Media Temple •

    NearlyFreeSpeech.NET • SiteGround • Synthesis • TVC.Net • WordPress.com VIP Via http://stwrt.org/wp-cli-hosting Site Hosts With WP-CLI
  17. • Varying Vagrant Vagrants (VVV) • http://stwrt.org/vvv • Automattic’s VIP

    Quickstart • http://stwrt.org/vip-quickstart Various WP Environments
  18. • @getsource’s WordCamp San Francisco 2013 talk: • Post: http://stwrt.org/getsource-post

    • PDF: http://stwrt.org/getsource-pdf • DigitalOcean’s awesome tutorial on proper use of WP-CLI: • http://stwrt.org/digitalocean-wp-cli • Using WP-CLI with MAMP: • http://stwrt.org/wp-cli-mamp • Neal Stephenson’s “In The Beginning Was The Command Line”: • http://stwrt.org/itbwtcl Further Reading
  19. Topics for advanced study 1. Puppet WP • http://stwrt.org/puppet-wp 2.

    Saltstack-WP • http://stwrt.org/saltstack-wp 3. Extending WP-CLI with your own commands • http://stwrt.org/wp-cli-commands 4. Packaging your commands for others • http://stwrt.org/wp-cli-packages 5. Community packages • http://stwrt.org/wp-cli-compkgs
  20. Reach out and touch someone. • Twitter: @zamoose • Email:

    [email protected] • Web: literalbarrage.org/blog/ • This presentation: http://stwrt.org/wcstl2014