Slide 1

Slide 1 text

WP-CLI: Save Time by Managing WordPress from the Command Line Shawn Hooper
 Director of IT, Actionable @shawnhooper - shawnhooper.ca

Slide 2

Slide 2 text

•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 Hi! @shawnhooper - shawnhooper.ca

Slide 3

Slide 3 text

Command Line?! @shawnhooper - shawnhooper.ca

Slide 4

Slide 4 text

•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

Slide 5

Slide 5 text

•Anyone really, but mostly: •Developers •Theme Designers •Server Administrators Who is this for? @shawnhooper - shawnhooper.ca

Slide 6

Slide 6 text

Don’t Fear The Command Line @shawnhooper - shawnhooper.ca

Slide 7

Slide 7 text

•http://www.wp-cli.org/ •Requires PHP 5.3.29 or later •Requires WordPress 3.7 or later •A “UNIX-like” environment: •OSX (Macintosh) •Linux •Cygwin (Windows) What do you need? @shawnhooper - shawnhooper.ca

Slide 8

Slide 8 text

•You need to have SSH access to use WP-CLI. Some shared hosting packages do not allow SSH access •SiteGround, Pantheon, BlueHost, GoDaddy, CloudAccess and more now have CLI support. •VPS services like Digital Ocean and Linode are ideal. Hosts @shawnhooper - shawnhooper.ca

Slide 9

Slide 9 text

•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

Slide 10

Slide 10 text

•Does it work? Type:
 
 wp
 Installing WP-CLI @shawnhooper - shawnhooper.ca

Slide 11

Slide 11 text

Installing WP-CLI @shawnhooper - shawnhooper.ca

Slide 12

Slide 12 text

Congratulations! (that was the hard part) @shawnhooper - shawnhooper.ca

Slide 13

Slide 13 text

Great… It’s installed. So now @shawnhooper - shawnhooper.ca

Slide 14

Slide 14 text

wp Running Commands: @shawnhooper - shawnhooper.ca

Slide 15

Slide 15 text

— required [—param] — optional flag [—param=] — optional w/ value Running Commands: @shawnhooper - shawnhooper.ca

Slide 16

Slide 16 text

•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

Slide 17

Slide 17 text

•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

Slide 18

Slide 18 text

•Install, Delete Plugins •Activate & Deactivate Plugins •Update Plugins •Search the repository for plugins plugin @shawnhooper - shawnhooper.ca

Slide 19

Slide 19 text

•Time savers!
 
 wp plugin update — all
 
 wp plugin deactivate — all plugin @shawnhooper - shawnhooper.ca

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

• Safe Search & Replace, including serialized arrays!
 • Supports --dry-run search-replace @shawnhooper - shawnhooper.ca

Slide 22

Slide 22 text

Generate Test Content ! wp post generate -- count=500 post @shawnhooper - shawnhooper.ca

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

Regenerate Thumbnails wp media regenerate —yes media @shawnhooper - shawnhooper.ca

Slide 25

Slide 25 text

Start an underscores theme! wp scaffold _s mytheme scaffold @shawnhooper - shawnhooper.ca

Slide 26

Slide 26 text

… or a child theme wp scaffold child-theme mychild — parent_theme=twentyfourte en scaffold @shawnhooper - shawnhooper.ca

Slide 27

Slide 27 text

… or a custom post type wp scaffold post-type mycpt —theme scaffold @shawnhooper - shawnhooper.ca

Slide 28

Slide 28 text

Download & Activate a Theme from WordPress.org wp theme install simone — activate theme @shawnhooper - shawnhooper.ca

Slide 29

Slide 29 text

wp user generate wp user import-csv Create Users @shawnhooper - shawnhooper.ca

Slide 30

Slide 30 text

wp term list wp term create wp term generate Taxonomies @shawnhooper - shawnhooper.ca

Slide 31

Slide 31 text

Executes PHP code
 * after loading the WordPress Core * eval & eval-file @shawnhooper - shawnhooper.ca

Slide 32

Slide 32 text

wp role create wp role list wp role exists new: —clone flag on create role & cap @shawnhooper - shawnhooper.ca

Slide 33

Slide 33 text

Launches PHP’s Built-in Web Server wp server server @shawnhooper - shawnhooper.ca

Slide 34

Slide 34 text

Thank you!
 Slides: www.shawnhooper.ca
 E-Mail: [email protected]
 Twitter: @shawnhooper
 WordPress Slack: shooper @shawnhooper - shawnhooper.ca