Hitchhiker's guide

to

Arūnas Liuiza

WordPress Core Contributor, WordPress Kaunas Meetup co-organizer, WordCamp (Lithuania, Riga, Stockholm, Jyväskylä, Oslo, Norrköping, Dublin, Lisbon) speaker and one of the editors of the Lithuanian WordPress translation team.

 

 

Free & premium WordPress plugin developer

 

Engineering Manager at

The Answer to Life, the Universe
and Everything?

Any sufficiently advanced technology is indistinguishable from magic

- Arthur C. Clarke,1973

/whois WP-CLI

The official command line tool for interacting with and managing your WordPress sites.

 

Yup, the Terminal.

 

Official website: https://make.wordpress.org/cli/handbook/​

Requirements

  • UNIX-like environment (OS X, Linux, FreeBSD, Cygwin);
    • limited support in Windows environment
       
  • PHP 5.6 or later.
     
  • WordPress 3.7 or later.
    • Versions older than the latest WordPress release may have degraded functionality

Installation

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar


brew install wp-cli


composer global require wp-cli/wp-cli

 

 

https://deliciousbrains.com/complete-guide-to-installing-wp-cli/

The Basics

Anatomy of a Command

wp plugin update akismet --version=1.0.0
wp command action input --parameter=value

 

Global Parameters

--path=            a path to s WordPress directory

--url=               url of the site

--user=            set user

--skip-themes[=theme]

--skip-plugins[=plugin]

--dry-run         

--format=json|table|csv

https://make.wordpress.org/cli/handbook/config/#global-parameters

wp plugin <action>

wp plugin install tinycoffee

 

wp plugin activate tinycoffee

 

wp plugin update tinycoffee --version=0.1.0

 

https://developer.wordpress.org/cli/commands/plugin/update/

wp theme <action>

wp theme install twentytwentyfive

 

wp theme install twentytwentyfive

 

wp theme update twentytwentyfive --version=0.1.0

 

https://developer.wordpress.org/cli/commands/theme/update/

wp user <action>

wp user list

 

wp user create bob bob@example.com --role=author

 

wp user update 123 --display_name=Mary --user_pass=marypass


https://developer.wordpress.org/cli/commands/user/​

wp ... anything

wp config

wp core

wp cache

wp comment

wp cron

wp db

wp export

wp import

wp media

wp menu

wp network

wp option

wp package

wp post

wp post-type

wp profile

wp rewrite

wp role

wp server

wp sidebar

wp search-replace

wp site

wp super-admin

wp taxonomy

wp term

wp transient

wp widget

...

DIY

Build Your Own Commands

if ( class_exists( 'WP_CLI' ) ) {
  WP_CLI::add_command( 'hello', 'arunas_cli_hello' );
}
function arunas_cli_hello( $args, $options ) {
  WP_CLI::success( 'Hello, World!' );
}
    

Questions?

Hitchhiker's guide to WP-CLI - Kaunas

By Arūnas Liuiza

Hitchhiker's guide to WP-CLI - Kaunas

WordPress Meetup Kaunas 2024-11

  • 41