All Posts

Have you met the WP-CLI? post

The WP-CLI (a command line interface for WordPress) gives developers and system administrators easy access to a multitude of WordPress operations. This includes installing, activating, and deactivating plugins, as well as downloading, configuring, and installing WordPress itself. The functionality even extends to WordPress multisite tools.

A command line tool makes common tasks scriptable which opens new doors for developers web based services.

Examples

Plugins

  • wp plugin install ninja-forms
    • Installs Ninja Forms form the WordPress repository.
  • wp plugin activate ninja-forms
    • Activates Ninja Forms for the current site.
  • wp plugin path ninja-forms
    • Returns a path to the Ninja Forms plugin installation.

Plugin commands also include tasks like deactivate, delete, search, update, etc.

Themes have similar commands.

Core

  • wp core download
    • Downloads the core WordPress files.
  • wp core config
    • Generates a wp-config.php file
  • wp core install
    • Creates the WordPress tables in the database.

WordPress installs can be easily managed using this command line tool, even scripted to quickly install new copies of WordPress on a server.

Extending the WP-CLI

While the WP-CLI comes with a long list of commands, there are still infinite use cases for a command line tool. This is why the WordPress community develops and maintains numeruos Community Commands. Plugins that maintain their own custom commands include ACF, BackupBuddy, Migrate DB Pro, and many more.

Custom Commands

Next time I’ll go over building your own custom commands for extending the WP-CLI.