Last active
December 14, 2015 23:49
-
-
Save mbijon/5167992 to your computer and use it in GitHub Desktop.
WP_CLI slide presentation By Daniel Bachhuber at PDX WordPress Dev Meetup, on March 2013
source: http://danielbachhuber.com/2013/03/11/pdxwp-wp-cli-is-for-wp-devs-on-a-deadline/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined( 'WP_CLI' ) ) | |
return; | |
WP_CLI::add_command( 'pdxwp-presentation', 'PDXWP_WP_CLI_Presentation_Command' ); | |
class PDXWP_WP_CLI_Presentation_Command extends WP_CLI_Command { | |
/** | |
* Start the presentation with a demonstration | |
* | |
* @subcommand slide | |
* @synopsis <number> | |
*/ | |
public function slide( $args ) { | |
list( $num ) = $args; | |
$slides = array( | |
0 => array( | |
'header' => 'wp-cli is for WP devs on a deadline (http://wp-cli.org)', | |
'body' => array( | |
'Daniel Bachhuber', | |
'daniel@automattic.com', | |
'@danielbachhuber', | |
), | |
), | |
1 => array( | |
'header' => 'What is wp-cli?', | |
'body' => array( | |
'- A Command Line Interface for WordPress', | |
'- A powerful tool for manipulating WordPress', | |
'- A nascent WordPress community project with lots of opportunity for contributions', | |
), | |
), | |
2 => array( | |
'header' => 'Why is it useful to me?', | |
'body' => array( | |
'- Open wp shell to execute arbitrary functions', | |
'- Install, update, or delete plugins', | |
'- Create posts, users, terms', | |
'- More easily manage lots of client sites', | |
'- Export a large amount of data', | |
'- Scaffold a theme, plugin, or unit tests for a plugin', | |
), | |
), | |
3 => array( | |
'header' => 'Where do I start?', | |
'body' => array( | |
'- Install wp-cli', | |
'- (monkey dance)', | |
'- Profit!', | |
), | |
), | |
4 => array( | |
'header' => 'How do I install?', | |
'body' => array( | |
'On your command line:', | |
'- git clone git://github.com/wp-cli/wp-cli.git ~/git/wp-cli', | |
'- cd ~/git/wp-cli', | |
'- curl -sS https://getcomposer.org/installer | php', | |
'- php composer.phar install', | |
), | |
), | |
5 => array( | |
'header' => 'How do I write my own command?', | |
'body' => array( | |
'- Create a class extending WP_CLI_Command', | |
"- Register your command with WP_CLI::add_command( 'pdxwp-presentation', 'PDXWP_WP_CLI_Presentation_Command' );", | |
'- public methods are subcommands', | |
'- PHPdoc allows you to set a <synopsis>', | |
'- Sekret pro tip: Package useful commands with your plugins <img src="http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif?m=1129645325g" alt=":)" class="wp-smiley"> ', | |
), | |
), | |
6 => array( | |
'header' => 'Now go! http://wp-cli.org', | |
'body' => array( | |
), | |
), | |
); | |
passthru( '/opt/local/bin/clear' ); | |
if ( ! empty( $slides[(int)$num] ) ) { | |
$slide = $slides[(int)$num]; | |
for( $i = 0; $i < 23; $i++ ) { | |
if ( $i == 3 ) { | |
$this->line( $slide['header'] ); | |
continue; | |
} | |
if ( $i == 6 ) { | |
foreach( $slide['body'] as $line ) { | |
$this->line( $line ); | |
$i++; | |
} | |
} | |
$this->line(); | |
} | |
} else { | |
WP_CLI::error( "No slide #{$num}" ); | |
} | |
} | |
private function line( $out = '' ) { | |
WP_CLI::line( " " . $out ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment