Your SlideShare is downloading. ×
0
LazyPress
Developing for WordPress on
the Command Line
Why CLI?
• All Keyboard Commands
• Efficient
• Fast
• Does Not Require the Web Server
resources
Installing WP-CLI
> curl http://wp-cli.org/installer.sh | bash
> PATH=$HOME/.composer/bin:$PATH
> source $HOME/.composer/v...
Using the wp
command
• wp core (config|download|install|update)
• wp comment (approve|count|spam|trash)
• wp export
• wp o...
Extending WP-CLI
• if( defined( ‘WP_CLI’ ) && WP_CLI )
• ExtendWP_CLI_Command
• Public methods become commands
• Methods t...
Extending WP-CLI
• $args is an array of positional elements
• e.g. wp command Hello World
• $args[0] == ‘Hello’
• $args[1]...
Extending WP-CLI
• $assoc_args is an array of flags
• e.g. wp command --foo=Hello
--bar=World
• $assoc_args[‘foo’] == ‘Hel...
Declaring Syntax
• Methods should have a Docblock using
@synopsis
• Square brackets designate optional
• @synopsis cmd <fo...
Printing to the CLI
• Use the line() method from the WP_CLI
class
• WP_CLI::line(‘Hello World is a Success!’);
Defining the
Command
• Use the add_command() method from
the WP_CLI class
• Argument 1 is the command name
• Argument 2 is...
Resources
• WP-CLI - http://wp-cli.org
• WP-CLI on Github -
http://github.com/wp-cli
• Sample Code -
https://github.com/te...
Credits
• “Boh” photo by Sidewalk Flying on Flickr
• “Crab” and “Aquarium” photos by
WallyG on Flickr
• “Oriole Bird” phot...
Upcoming SlideShare
Loading in...5
×

Wp cli-wcbalt

247

Published on

Published in: Technology, Sports
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
247
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Wp cli-wcbalt"

  1. 1. LazyPress Developing for WordPress on the Command Line
  2. 2. Why CLI? • All Keyboard Commands • Efficient • Fast • Does Not Require the Web Server resources
  3. 3. Installing WP-CLI > curl http://wp-cli.org/installer.sh | bash > PATH=$HOME/.composer/bin:$PATH > source $HOME/.composer/vendor/wp- cli/wp-cli/utils/wp-completion.bash
  4. 4. Using the wp command • wp core (config|download|install|update) • wp comment (approve|count|spam|trash) • wp export • wp option (add|update|delete|get) • wp plugin (install|activate|list|update) • Etc
  5. 5. Extending WP-CLI • if( defined( ‘WP_CLI’ ) && WP_CLI ) • ExtendWP_CLI_Command • Public methods become commands • Methods take $args and $assoc_args
  6. 6. Extending WP-CLI • $args is an array of positional elements • e.g. wp command Hello World • $args[0] == ‘Hello’ • $args[1] == ‘World’
  7. 7. Extending WP-CLI • $assoc_args is an array of flags • e.g. wp command --foo=Hello --bar=World • $assoc_args[‘foo’] == ‘Hello’ • $assoc_args[‘bar’] == ‘World’
  8. 8. Declaring Syntax • Methods should have a Docblock using @synopsis • Square brackets designate optional • @synopsis cmd <foo> --bar=<bar> [-- baz=<baz>]
  9. 9. Printing to the CLI • Use the line() method from the WP_CLI class • WP_CLI::line(‘Hello World is a Success!’);
  10. 10. Defining the Command • Use the add_command() method from the WP_CLI class • Argument 1 is the command name • Argument 2 is the Class name • WP_CLI::add_command( ‘hello’,‘world’); • Running wp hello instantiates the world class
  11. 11. Resources • WP-CLI - http://wp-cli.org • WP-CLI on Github - http://github.com/wp-cli • Sample Code - https://github.com/technosailor/baltimoreph p-wpcli • BreweryDB - http://brewerydb.com
  12. 12. Credits • “Boh” photo by Sidewalk Flying on Flickr • “Crab” and “Aquarium” photos by WallyG on Flickr • “Oriole Bird” photo by Keith Allison on Flickr • All photos used under the Creative Commons License
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×