Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to WP-CLI

Introduction to WP-CLI

Kyle B. Johnson

November 02, 2017
Tweet

More Decks by Kyle B. Johnson

Other Decks in Programming

Transcript

  1. $ wp plugin install ninja-forms Installing Ninja Forms (3.0) Downloading

    install package... Unpacking the package... Installing the plugin... Plugin installed successfully. Success: Installed 1 of 1 plugins.
  2. $ wp core download Downloading WordPress 4.8 Md5 hash verified:

    c5366d0521831dd029dfc38e56a5 Success: WordPress downloaded.
  3. $ wp plugin update Updating to version 4.9 Downloading update...

    Unpacking the update... Success: WordPress updated successfully.
  4. Example Use Cases • Plugin/Theme Development • Local Development Environments

    • Client Site Maintenance • WordPress as a Service
  5. Local Development Environments • Download/Install/Update WordPress • Auto install plugins/themes

    • Search/Replace database values (site migration) • Launch PHP’s built-in web server $ wp serve –-host=wordpress.dev ~/code/wordpress now available at wordpress.dev:80
  6. Client Site Maintenance • Remotely Update WordPress (SSH) • Check

    for plugin updates • Restore down sites (white-screen of death) $ wp plugin deactivate <plugin name> --skip-plugins Success: Plugin <plugin name> deactivated.
  7. WordPress as a Service • Check for updates • Create

    user accounts • Create new installs $ wp site create --slug=example Success: Site 3 created. wordpress.dev/example
  8. $ wp ninja-forms list-forms public function list_forms( $args, $assoc_args )

    { foreach( Ninja_Forms()->forms() as $form ){ WP_CLI::line( ‘#’ . $form[‘title’] ); } }
  9. Laravel $ artisan # Generate a new controller. $ artisan

    make:controller PostController # Re-run database migration with seed data. $ artisan migrate:refresh --seeds
  10. Drupal $ drush # Run pending updates on staging site.

    $ drush @staging updatedb # Synchronize staging files to production. $ drush rsync @staging @ list