wordpress and the command line

34
WordPress & the command line Kelly Dwan @ryelle NERD Summit • Sept 2014

Upload: kelly-dwan

Post on 14-Jun-2015

3.237 views

Category:

Technology


0 download

DESCRIPTION

How to use WP-CLI to manage your WordPress site via the command line. From basic management like installing & updating plugins and themes, to scripting a installation workflow, this tool is a WordPress DevOps' best friend.

TRANSCRIPT

Page 1: WordPress and The Command Line

WordPress & the command line

Kelly Dwan @ryelle

NERD Summit • Sept 2014

Page 2: WordPress and The Command Line

About Me

WordPress Developer

Core Contributor

Boston WordPress Organizer

Page 3: WordPress and The Command Line

“Why should I use the command line, when WordPress already has such a fantastic UI?”

Page 4: WordPress and The Command Line

• Already included in VVV, VIP Quickstart https://github.com/Varying-Vagrant-Vagrants/VVV/ https://github.com/Automattic/vip-quickstart

• Most major hosts include it: DreamHost, Media Temple, BlueHost, SiteGround, 1&1…

• Installation:http://wp-cli.org/#install

Page 5: WordPress and The Command Line

Basic Commands

Page 6: WordPress and The Command Line

wp command subcommand <argument> —flag

Page 7: WordPress and The Command Line

• wp core version

• wp core update

• wp plugin list

• wp plugin install <name> [--activate]

• wp theme list

• wp theme activate <name>

Page 8: WordPress and The Command Line

• wp core download

• wp core config

• wp core install / multisite-install

• wp core multisite-convert

Page 9: WordPress and The Command Line

wp help

wp help <command>

wp help <command> <subcommand>

Page 10: WordPress and The Command Line

Content Management

Page 11: WordPress and The Command Line

• wp post create

• wp post delete

• wp post url

• wp post meta list

• wp post meta update

Page 12: WordPress and The Command Line

• wp comment approve

• wp comment delete $(wp comment list --status=spam --format=ids)

Page 13: WordPress and The Command Line

• wp media import

Page 14: WordPress and The Command Line

• wp term create

• wp term generate

• wp term list

Page 15: WordPress and The Command Line

Tools

Page 16: WordPress and The Command Line

• wp export [—skip_comments]

• wp import

• wp media regenerate

Page 17: WordPress and The Command Line

Advanced Management

Page 18: WordPress and The Command Line

• wp user create

• wp user import-csv

• wp user remove-cap

• wp role list

• wp cap list

Page 19: WordPress and The Command Line

• wp cron test

• wp cron schedule list

• wp cron event list

• wp cron event run

Page 20: WordPress and The Command Line

• wp rewrite list

• wp rewrite flush

• wp rewrite structure

Page 21: WordPress and The Command Line

Custom Commands

Page 22: WordPress and The Command Line

–Matt Wiebe, Why You Should Develop Plugins With wp-cli

“Adding commands to your plugin is great for encouraging good API design, collaborating

amidst a changing data structure, efficiency, and better debugging.”

Page 23: WordPress and The Command Line

• Jetpack module control

• wp jetpack module list

• wp jetpack module activate

• BackUpWordPress

• wp backup [lots of options]

Page 24: WordPress and The Command Line

how to write your own

Page 25: WordPress and The Command Line

if ( defined('WP_CLI') && WP_CLI ) { include __DIR__ . '/my-command.php'; }

Page 26: WordPress and The Command Line

class Example_Command extends WP_CLI_Command { /** * Prints a greeting. * @synopsis <name> */ function hello( $args, $assoc_args ) { list( $name ) = $args; ! // Print a success message WP_CLI::success( "Hello, $name!" ); } } !WP_CLI::add_command( 'example', 'Example_Command' );

Page 27: WordPress and The Command Line

class Example_Command extends WP_CLI_Command { /** * Prints a greeting. * @synopsis <name> [<last-name>] */ function hello( $args, $assoc_args ) { list( $name ) = $args; ! // Print a success message WP_CLI::success( "Hello, $name!" ); } } !WP_CLI::add_command( 'example', 'Example_Command' );

Page 28: WordPress and The Command Line

• WP CLI Commands Cookbook walks through this in more detail.

Page 29: WordPress and The Command Line

Automated Migrations

Page 30: WordPress and The Command Line

From WordPress

Page 31: WordPress and The Command Line

• wp export [on source site]

• wp import [on destination]

• wp search-replace <old> <new> —skip-columns=guid —dry-run

Page 32: WordPress and The Command Line

From Other CMSs

Page 33: WordPress and The Command Line

• Importing (any!) Content with WP-CLI

Page 34: WordPress and The Command Line

• https://github.com/wp-cli/wp-cli/wiki/External-Resources

• http://redradar.net/nerds-wp-cli