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
“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)
“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.”
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?
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
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
*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
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.
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.
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”
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]`
• @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
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