SlideShare une entreprise Scribd logo
1  sur  94
Take Command ofWordPressWith
WP-CLI
Diana Thompson
Foothills WordPress Meetup
September 25, 2019
Speaker
Diana Thompson
Pronouns: she/her
Like the Goddess
likethegoddess.com
@likethegoddess
hi@diana.fyi
Agenda
1. WP-CLI: What and Why
2. Getting Started
3. Commands
a. Mirroring the GUI
b. Behind the Scenes
4. Configuration
5. Packages
6. Writing Commands
What isWP-CLI?
WP-CLI is the official command line
interface for WordPress.
What is a command line interface?
A command-line interface…is a means of
program where the user issues commands to the
of successive lines of text. (Wikipedia)
WhyWP-CLI?
1. Execute tasks faster
2. Get more capabilities than the GUI
WhyWP-CLI? Do more in less time.
GETTING
STARTED
Let’s Go!
Requirements
UNIX-like server environment
PHP 5.4 or later
WordPress 3.7 or later
Terminal app: native apps, PuTTY
SSH access
Web HostsWithWP-CLI Installed
Bluehost
Dreamhost
HostGator
SiteGround
WPEngine
among others
https://make.wordpress.org/cli/handbook/hosting-companies/
WP-CLI Installation
1) Download wp-cli.phar
$ curl -O https://raw.githubusercontent.com/wp-cli/builds/
gh-pages/phar/wp-cli.phar
2) Confirm it works
$ php wp-cli.phar --info
3) Enable use of wp instead of php wp-cli.phar
$ chmod +x wp-cli.phar
$ sudo mv wp-cli.phar /usr/local/bin/wp
4) Confirm successful installation
$ wp --info
https://make.wordpress.org/cli/handbook/installing/
Navigation
pwd print working directory
ls list segments
(non-OS contents)
cd change directory
../ parent directory
/ system root
- last directory
~ home directory
Up and down arrow keys to review and
execute previous commands
Tab to autocomplete options (installation
required)
https://wp-cli.org/#tab-completions
WP-CLI Syntax
$ wp command subcommand [value] [--argument]
Examples:
$ wp core download
$ wp plugin update --all
$ wp theme install twentynineteen --activate
Global Parameters
Perform operation against a remote server over SSH
--ssh=[<scheme>:][<user>@]<host|container>[:<port>][<path>]
Path to the WordPress files
--path=<path>
Suppress informational messages
--quiet
Prompt the user to enter values for all arguments
--prompt
https://make.wordpress.org/cli/handbook/config/#global-parameters
COMMANDS Mirroring
the GUI
Core
Download core
$ wp core download
Check for available core update
$ wp core check-update
Update WordPress
$ wp core update
https://developer.wordpress.org/cli/commands/core/
Plugins
List plugins
$ wp plugin list
Install a plugin from wp plugin repository
$ wp plugin install akismet –-activate
Update plugins
$ wp plugin update akismet
$ wp plugin update akismet wp-super-cache woocommerce
$ wp plugin update --all
https://developer.wordpress.org/cli/commands/plugin/
Themes
List themes
$ wp theme list
Install and activate a theme from wp theme repository
$ wp theme install twentynineteen --activate
Update themes
$ wp theme update twentynineteen
$ wp theme update twentynineteen twentyseventeen twentysixteen
$ wp theme update --all
https://developer.wordpress.org/cli/commands/theme/
Combine Commands with Pipes
Update core, all plugins, and all themes
$ wp core update | wp plugin update --all | wp theme
update --all
Users
List users
$ wp user list
Create user
$ wp user create ann ann@example.com --porcelain --send-email
https://developer.wordpress.org/cli/commands/user/
Users
Reset user password
$ wp user reset-password john
$ wp user reset-password john@example.com ann@example.com
$ wp user reset-password 1 2 3
Delete user
$ wp user delete john --reassign=lynn
$ wp user delete john --yes
https://developer.wordpress.org/cli/commands/user/
Options
List site options
$ wp option list
Change site URL
$ wp option update siteurl http://new.siteurl.com
Change admin email
$ wp option update admin_email admin@siteurl.com
https://developer.wordpress.org/cli/commands/option/
Options
Change image thumbnail size
$ wp option update thumbnail_size_w 200 | wp option update
thumbnail_size_h 200 | $ wp media regenerate --yes
Block search engines, change site description and time zone,
close commenting
$ wp option update blog_public 0 | wp option update
blogdescription "My New Tagline" | wp option update gmt_offset
-7 | $ wp option update default_comment_status closed
https://codex.wordpress.org/Option_Reference/
Comments
List comments
$ wp comment list
Approve comment
$ wp comment approve 1337
Delete all spam comments
$ wp comment delete $(wp comment list --status=spam
--format=ids)
https://developer.wordpress.org/cli/commands/comment/
Multisite
Site for Multisite Installations
List sites
$ wp site list
Create a site
$ wp site create --slug=example
Deactivate a site
$ wp site deactivate 123
Archive a site
$ wp site archive 123
https://developer.wordpress.org/cli/commands/site/
SuperAdmin
List super admins
$ wp super-admin list
Add a super admin
$ wp super-admin add username
Remove a super admin
$ wp super-admin remove username
https://developer.wordpress.org/cli/commands/super-admin/
COMMANDS Behind the Scenes
WordPress Installation
1. wp db create –-dbuser=db-username --dbpass=db-password
2. wp core download
3. wp config create --dbname=database-name
--dbuser=dbuser --dbpass=db-password
--dbhost=hostname --dbprefix=prfx_
4. wp core install --url=example.com
--title="Site Title" --admin_user=username
--admin_email=admin@example.com
--prompt=admin_password < admin_password.txt
User Capabilities
List a user’s capabilities
$ wp user list-caps 21
Add a capability to user
$ wp user add-cap johnsmith edit_product
Remove a capability to user
$ wp user remove-cap john@smith.com publish_newsletters
https://developer.wordpress.org/cli/commands/user/
Role Capabilities
List the capabilities of a role, sorted alphabetically
$ wp cap list 'author' | sort
Add a capability to a role
$ wp cap add author spectate
Remove a capability from a role
$ wp cap remove author spectate
https://developer.wordpress.org/cli/commands/cap/
Roles
Create a role
$ wp role create productadmin "Product Administrator"
Delete a role
$ wp role delete productadmin
Reset roles
$ wp role reset administrator
$ wp role reset administrator author contributor
$ wp role reset --all
https://developer.wordpress.org/cli/commands/role/
Posts and Pages
Generate posts
$ wp post generate --count=10
Generate pages with lorem ipsum
$ curl http://loripsum.net/api/5 | wp post generate
--post_type=page --count=10
https://developer.wordpress.org/cli/commands/post/
Comments
Generate comments
$ wp comment generate --format=ids --count=3 --post_id=123
https://developer.wordpress.org/cli/commands/comment/
Scaffold
Scaffold ChildTheme
Create child theme
$ wp scaffold child-theme my-child-theme-slug
--parent_theme=parent-theme-slug --theme_name="My Child Theme
Name" --author="My Name" --author_uri=myurl.com
--theme_uri=mythemeurl.com --activate
https://developer.wordpress.org/cli/commands/scaffold/child-theme/
Scaffold UnderscoresTheme
Create theme based on Underscores
$ wp scaffold _s my-theme-slug --theme_name="My Theme Name"
--author="My Name" --author_uri=myurl.com --sassify
--woocommerce --activate
https://developer.wordpress.org/cli/commands/scaffold/underscores/
Scaffold Plugins
Generate starter code of a plugin
$ wp scaffold plugin my-plugin-slug --dir=path/to/plugins
--plugin_name="My Plugin Name" --plugin_description="My
Plugin Description" --plugin_author="My Name"
--plugin_author_uri=myurl.com --plugin_uri=mypluginurl.com
https://developer.wordpress.org/cli/commands/scaffold/plugin/
Scaffolded Plugin Contents
 bin
 tests
.distignore
.editorconfig
.gitignore
.phpcs.xml.dist
.travis.yml
Gruntfile.js
my-plugin-slug.php
package.json
phpunit.xml.dist
readme.txt
 bin
install-wp-tests.sh
 tests
bootstrap.php
test-sample.php
Scaffold Blocks
Generate a block for a theme
$ wp scaffold block my-block-slug --title="My Block Title"
--theme=theme-slug
Generate a block for a plugin
$ wp scaffold block my-block-slug --title="My Block Title"
--plugin=plugin-slug
https://developer.wordpress.org/cli/commands/scaffold/block/
Scaffolded Block Contents
 my-block-slug
my-block-slug.php
 my-block-slug
editor.css
index.js
style.css
Scaffold PostTypes
Generate custom post type
$ wp scaffold post-type my-post-type-slug --label="My Post
Type" --textdomain="my-post-type"
Generate custom post type for a theme
$ wp scaffold post-type my-post-type-slug --label="My Post
Type" --theme=my-theme
Generate custom post type for a plugin
$ wp scaffold post-type my-post-type-slug --label="My Post
Type" --plugin=my-plugin
https://developer.wordpress.org/cli/commands/scaffold/post-type/
ScaffoldTaxonomies
Generate taxonomy
$ wp scaffold taxonomy taxonomy-slug --textdomain="taxonomy-
slug"
Generate taxonomy for a theme
$ wp scaffold taxonomy taxonomy-slug --post_types=my-post-
type-slug > taxonomy.php --theme="twentynineteen"
Generate taxonomy for a plugin
$ wp scaffold taxonomy taxonomy-slug --post_types=my-post-
type-slug > taxonomy.php --plugin="custom-plugin"
https://developer.wordpress.org/cli/commands/scaffold/taxonomy
Database
Config, Search/Replace, and More
Database
Create database
$ wp db create
Reset current database
$ wp db reset --yes
Delete existing database
$ wp db drop --yes
https://developer.wordpress.org/cli/commands/db/
Site
Remove pages, posts, and custom post types
$ wp site empty --yes
Remove pages, posts, custom post types, and uploads
$ wp site empty --uploads --yes
https://developer.wordpress.org/cli/commands/site/
Database
Import database
$ wp db import wpdb.sql
Export database
$ wp db export
Open a MySQL console
$ wp db cli
https://developer.wordpress.org/cli/commands/db/
DatabaseWith mysqlcheck
Check database
$ wp db check
Optimize database
$ wp db optimize
Repair database
$ wp db repair
https://dev.mysql.com/doc/refman/8.0/en/mysqlcheck.html
Config
Create wp-config.php
$ wp config create --dbname=database-name --dbuser=db-user
--dbpass=db-password --dbhost=hostname --dbprefix=prfx_
Set constants and variables
$ wp config set WP_DEBUG true --raw
Change salt keys
$ wp config shuffle-salts
https://developer.wordpress.org/cli/commands/config/
Search and Replace
Search for staging URL and replace with production URL
$ wp search-replace 'http://example.dev' 'http://example.com'
--dry-run
Search/replace to a SQL file without transforming the database
$ wp search-replace 'http://example.dev' 'http://example.com'
--export=database.sql
Run case-insensitive regex search/replace operation
$ wp search-replace '[foo id="([0-9]+)"' '[bar id="1"' --
regex --regex-flags='i'
https://developer.wordpress.org/cli/commands/search-replace/
Rewrite
List rewrite rules
$ wp rewrite list --format=csv
Update permalink structure
$ wp rewrite structure '/%postname%'
Flush rewrite rules
$ wp rewrite flush
https://developer.wordpress.org/cli/commands/rewrite/
Object Cache
Set cache
$ wp cache set my_key my_value my_group 300
Increase cache value
$ wp cache incr my_key 2 my_group
Decrease cache value
$ wp cache decr my_key 2 my_group
Flush cache
$ wp cache flush
https://developer.wordpress.org/cli/commands/cache/
Transient Cache
Set transient
$ wp transient set my_key "test data" 3600
Delete transients
$ wp transient delete my_key
$ wp transient delete --expired
$ wp transient delete --all
https://developer.wordpress.org/cli/commands/transient/
WP-Cron
List scheduled cron events
$ wp cron event list
Schedule a new cron event
$ wp cron event schedule cron_test
Test that cron runs successfully
$ wp cron test
https://developer.wordpress.org/cli/commands/cron/
More
Commands within plugins
Wrappers
Editor plugins
Vagrant boxes
https://make.wordpress.org/cli/handbook/tools/
CONFIGURATION For Efficiency and
Specificity
CLI Aliases
Add alias
$ wp cli alias add @staging --set-ssh=login@host --set-
path=/path/to/wp/install/ --set-user=wpcli
$ wp cli alias add @production --set-ssh=login@host --set-
path=/path/to/wp/install/ --set-user=wpcli
Create an alias group
$ wp cli alias add @ourservers --grouping=staging,production
https://developer.wordpress.org/cli/commands/cli/alias/
Executing CommandsWith Aliases
Update staging and production
$ wp core update @staging
$ wp core update @production
$ wp core update @ourservers
$ wp core update @all
Executing CommandsWith Aliases
Update all sites
$ wp core update @all | wp theme update --all @all | wp plugin
update --all @all
Create bash alias
$ alias update-all='wp core update @all && wp plugin update --
all @all && wp theme update --all @all'
Update core, themes, and plugins on all aliases
$ update-all
https://make.wordpress.org/cli/handbook/shell-friends/
Creating Aliases in Config Files
@staging:
ssh: username@hostname
user: username
path: /path/to/staging/install/
@production:
ssh: username@hostname
user: username
path: /path/to/production/install/
@ourservers:
- @staging
- @production
https://make.wordpress.org/cli/handbook/config/
Configuration Files
Arguments are interpreted in the following order:
1. Command-line arguments
2. wp-cli.local.yml
3. wp-cli.yml
4. ~/.wp-cli/config.yml
5. WP-CLI defaults
https://make.wordpress.org/cli/handbook/config/
PACKAGES Extend WP-CLI
Packages
List installed packages
$ wp package list
Install a package
$ wp package install package-slug
Update a package
$ wp package update package-slug
Uninstall a package
$ wp package uninstall package-slug
https://developer.wordpress.org/cli/commands/package/
Doctor
Install
$ wp package install git@github.com:wp-cli/doctor-command.git
Get list of checks wp doctor can perform
$ wp doctor list
Perform checks
$ wp doctor check core-verify-checksums
$ wp doctor check core-verify-checksums file-eval
php-in-uploads
$ wp doctor check --all
https://github.com/wp-cli/doctor-command
Profile
Install
$ wp package install git@github.com:wp-cli/profile-command.git
Run command
$ wp profile stage
$ wp profile hook
$ wp profile eval
$ wp profile eval-file
https://github.com/wp-cli/profile-command/
Profile Stage
Profile all stages
$ wp profile stage
Profile the bootstrap stage
$ wp profile stage bootstrap
Profile all stages with zero-ish values eliminated
$ wp profile stage --spotlight
https://developer.wordpress.org/cli/commands/profile/stage/
Profile Hook
Profile all hooks
$ wp profile hook
Profile the wp_head hook
$ wp profile hook wp_head
Profile all hooks with zero-ish values eliminated
$ wp profile hook --spotlight
https://developer.wordpress.org/cli/commands/profile/hook/
WRITING
COMMANDS
Make Your Own
Packages
Scaffold Package
1) Install Scaffold Package Command
$ wp package install git@github.com:wp-cli/scaffold-package-
command.git
2) Generate files for a basic WP-CLI command
$ wp scaffold package author/packagename
--description="My Description" --homepage=package-homepage.com
--dir=package-dir
3) Find your package
/home/usr/.wp-cli/packages/local/author/packagename
https://github.com/wp-cli/scaffold-package-command/
Scaffolded Package Content
 .github
 bin
 features
 utils
.distignore
.editorconfig
.gitignore
.travis.yml
command.php
composer.json
CONTRIBUTING.md
README.md
wp-cli.yml
HELP Is Available
Resources
Within WP-CLI
$ wp help
$ wp help <command>
$ wp help <command> <subcommand>
On the Web
https://wp-cli.org/
THANKS!
Diana Thompson
hi@diana.fyi
@likethegoddess
Slides: diana.fyi/wp-cli

Contenu connexe

Tendances

Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress WayMatt Wiebe
 
How to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's EncryptHow to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's EncryptMayeenul Islam
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsDylan Jay
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp HamiltonPaul Bearne
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depthSanjay Willie
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWalter Ebert
 
The goodies of zope, pyramid, and plone (2)
The goodies of zope, pyramid, and plone (2)The goodies of zope, pyramid, and plone (2)
The goodies of zope, pyramid, and plone (2)Dylan Jay
 
WordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress SecurityWordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress SecurityTiia Rantanen
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern ApproachAlessandro Fiore
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015Fernando Daciuk
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
High Performance Web Sites, With Ads: Don't let third parties make you slow
High Performance Web Sites, With Ads: Don't let third parties make you slowHigh Performance Web Sites, With Ads: Don't let third parties make you slow
High Performance Web Sites, With Ads: Don't let third parties make you slowTobias Järlund
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindDylan Jay
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django ChannelsAlbert O'Connor
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1Wataru OKAMOTO
 

Tendances (20)

Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress Way
 
How to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's EncryptHow to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's Encrypt
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
wp-cli
wp-cliwp-cli
wp-cli
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depth
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
 
WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
The goodies of zope, pyramid, and plone (2)
The goodies of zope, pyramid, and plone (2)The goodies of zope, pyramid, and plone (2)
The goodies of zope, pyramid, and plone (2)
 
WordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress SecurityWordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress Security
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern Approach
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Powershell: Tu nuevo mejor amigo
Powershell: Tu nuevo mejor amigoPowershell: Tu nuevo mejor amigo
Powershell: Tu nuevo mejor amigo
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
High Performance Web Sites, With Ads: Don't let third parties make you slow
High Performance Web Sites, With Ads: Don't let third parties make you slowHigh Performance Web Sites, With Ads: Don't let third parties make you slow
High Performance Web Sites, With Ads: Don't let third parties make you slow
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mind
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django Channels
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1
 

Similaire à Take Command of WordPress With WP-CLI

Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineBehzod Saidov
 
Administer WordPress with WP-CLI
Administer WordPress with WP-CLIAdminister WordPress with WP-CLI
Administer WordPress with WP-CLISuwash Kunwar
 
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Andrea Cardinali
 
Workshop On WP-CLI
Workshop On WP-CLIWorkshop On WP-CLI
Workshop On WP-CLIAjit Bohra
 
Session: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from ScratchSession: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from ScratchRoald Umandal
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliGetSource
 
Extending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLIExtending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLIryanduff
 
WP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperWP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperChandra Patel
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressJeroen van Dijk
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressJeroen van Dijk
 
Advanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comAdvanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comInstaWP Inc
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliGetSource
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionSysdig
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeAJ Morris
 
WordPress and The Command Line
WordPress and The Command LineWordPress and The Command Line
WordPress and The Command LineKelly Dwan
 
Command Line WordPress with WP-CLI
Command Line WordPress with WP-CLICommand Line WordPress with WP-CLI
Command Line WordPress with WP-CLIJames Collins
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Dana Luther
 
Do more, faster, by extending WP-CLI
Do more, faster, by extending WP-CLIDo more, faster, by extending WP-CLI
Do more, faster, by extending WP-CLIdrywallbmb
 
WP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperWP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperChandra Patel
 

Similaire à Take Command of WordPress With WP-CLI (20)

Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command line
 
wp cli
wp cliwp cli
wp cli
 
Administer WordPress with WP-CLI
Administer WordPress with WP-CLIAdminister WordPress with WP-CLI
Administer WordPress with WP-CLI
 
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
 
Workshop On WP-CLI
Workshop On WP-CLIWorkshop On WP-CLI
Workshop On WP-CLI
 
Session: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from ScratchSession: WP Site Management using WP-CLI from Scratch
Session: WP Site Management using WP-CLI from Scratch
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
 
Extending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLIExtending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLI
 
WP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperWP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of Developer
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
Advanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comAdvanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.com
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your life
 
WordPress and The Command Line
WordPress and The Command LineWordPress and The Command Line
WordPress and The Command Line
 
Command Line WordPress with WP-CLI
Command Line WordPress with WP-CLICommand Line WordPress with WP-CLI
Command Line WordPress with WP-CLI
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
 
Do more, faster, by extending WP-CLI
Do more, faster, by extending WP-CLIDo more, faster, by extending WP-CLI
Do more, faster, by extending WP-CLI
 
WP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperWP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of Developer
 

Dernier

Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...sonatiwari757
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistKHM Anwar
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 

Dernier (20)

Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
 
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization Specialist
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 

Take Command of WordPress With WP-CLI

  • 1. Take Command ofWordPressWith WP-CLI Diana Thompson Foothills WordPress Meetup September 25, 2019
  • 2. Speaker Diana Thompson Pronouns: she/her Like the Goddess likethegoddess.com @likethegoddess hi@diana.fyi
  • 3. Agenda 1. WP-CLI: What and Why 2. Getting Started 3. Commands a. Mirroring the GUI b. Behind the Scenes 4. Configuration 5. Packages 6. Writing Commands
  • 4. What isWP-CLI? WP-CLI is the official command line interface for WordPress. What is a command line interface? A command-line interface…is a means of program where the user issues commands to the of successive lines of text. (Wikipedia)
  • 5. WhyWP-CLI? 1. Execute tasks faster 2. Get more capabilities than the GUI
  • 6. WhyWP-CLI? Do more in less time.
  • 7.
  • 9. Requirements UNIX-like server environment PHP 5.4 or later WordPress 3.7 or later Terminal app: native apps, PuTTY SSH access
  • 10. Web HostsWithWP-CLI Installed Bluehost Dreamhost HostGator SiteGround WPEngine among others https://make.wordpress.org/cli/handbook/hosting-companies/
  • 11. WP-CLI Installation 1) Download wp-cli.phar $ curl -O https://raw.githubusercontent.com/wp-cli/builds/ gh-pages/phar/wp-cli.phar 2) Confirm it works $ php wp-cli.phar --info 3) Enable use of wp instead of php wp-cli.phar $ chmod +x wp-cli.phar $ sudo mv wp-cli.phar /usr/local/bin/wp 4) Confirm successful installation $ wp --info https://make.wordpress.org/cli/handbook/installing/
  • 12. Navigation pwd print working directory ls list segments (non-OS contents) cd change directory ../ parent directory / system root - last directory ~ home directory Up and down arrow keys to review and execute previous commands Tab to autocomplete options (installation required) https://wp-cli.org/#tab-completions
  • 13. WP-CLI Syntax $ wp command subcommand [value] [--argument] Examples: $ wp core download $ wp plugin update --all $ wp theme install twentynineteen --activate
  • 14. Global Parameters Perform operation against a remote server over SSH --ssh=[<scheme>:][<user>@]<host|container>[:<port>][<path>] Path to the WordPress files --path=<path> Suppress informational messages --quiet Prompt the user to enter values for all arguments --prompt https://make.wordpress.org/cli/handbook/config/#global-parameters
  • 15.
  • 17. Core Download core $ wp core download Check for available core update $ wp core check-update Update WordPress $ wp core update https://developer.wordpress.org/cli/commands/core/
  • 18. Plugins List plugins $ wp plugin list Install a plugin from wp plugin repository $ wp plugin install akismet –-activate Update plugins $ wp plugin update akismet $ wp plugin update akismet wp-super-cache woocommerce $ wp plugin update --all https://developer.wordpress.org/cli/commands/plugin/
  • 19. Themes List themes $ wp theme list Install and activate a theme from wp theme repository $ wp theme install twentynineteen --activate Update themes $ wp theme update twentynineteen $ wp theme update twentynineteen twentyseventeen twentysixteen $ wp theme update --all https://developer.wordpress.org/cli/commands/theme/
  • 20.
  • 21. Combine Commands with Pipes Update core, all plugins, and all themes $ wp core update | wp plugin update --all | wp theme update --all
  • 22. Users List users $ wp user list Create user $ wp user create ann ann@example.com --porcelain --send-email https://developer.wordpress.org/cli/commands/user/
  • 23. Users Reset user password $ wp user reset-password john $ wp user reset-password john@example.com ann@example.com $ wp user reset-password 1 2 3 Delete user $ wp user delete john --reassign=lynn $ wp user delete john --yes https://developer.wordpress.org/cli/commands/user/
  • 24. Options List site options $ wp option list Change site URL $ wp option update siteurl http://new.siteurl.com Change admin email $ wp option update admin_email admin@siteurl.com https://developer.wordpress.org/cli/commands/option/
  • 25. Options Change image thumbnail size $ wp option update thumbnail_size_w 200 | wp option update thumbnail_size_h 200 | $ wp media regenerate --yes Block search engines, change site description and time zone, close commenting $ wp option update blog_public 0 | wp option update blogdescription "My New Tagline" | wp option update gmt_offset -7 | $ wp option update default_comment_status closed https://codex.wordpress.org/Option_Reference/
  • 26. Comments List comments $ wp comment list Approve comment $ wp comment approve 1337 Delete all spam comments $ wp comment delete $(wp comment list --status=spam --format=ids) https://developer.wordpress.org/cli/commands/comment/
  • 28. Site for Multisite Installations List sites $ wp site list Create a site $ wp site create --slug=example Deactivate a site $ wp site deactivate 123 Archive a site $ wp site archive 123 https://developer.wordpress.org/cli/commands/site/
  • 29. SuperAdmin List super admins $ wp super-admin list Add a super admin $ wp super-admin add username Remove a super admin $ wp super-admin remove username https://developer.wordpress.org/cli/commands/super-admin/
  • 30.
  • 32. WordPress Installation 1. wp db create –-dbuser=db-username --dbpass=db-password 2. wp core download 3. wp config create --dbname=database-name --dbuser=dbuser --dbpass=db-password --dbhost=hostname --dbprefix=prfx_ 4. wp core install --url=example.com --title="Site Title" --admin_user=username --admin_email=admin@example.com --prompt=admin_password < admin_password.txt
  • 33. User Capabilities List a user’s capabilities $ wp user list-caps 21 Add a capability to user $ wp user add-cap johnsmith edit_product Remove a capability to user $ wp user remove-cap john@smith.com publish_newsletters https://developer.wordpress.org/cli/commands/user/
  • 34. Role Capabilities List the capabilities of a role, sorted alphabetically $ wp cap list 'author' | sort Add a capability to a role $ wp cap add author spectate Remove a capability from a role $ wp cap remove author spectate https://developer.wordpress.org/cli/commands/cap/
  • 35. Roles Create a role $ wp role create productadmin "Product Administrator" Delete a role $ wp role delete productadmin Reset roles $ wp role reset administrator $ wp role reset administrator author contributor $ wp role reset --all https://developer.wordpress.org/cli/commands/role/
  • 36. Posts and Pages Generate posts $ wp post generate --count=10 Generate pages with lorem ipsum $ curl http://loripsum.net/api/5 | wp post generate --post_type=page --count=10 https://developer.wordpress.org/cli/commands/post/
  • 37. Comments Generate comments $ wp comment generate --format=ids --count=3 --post_id=123 https://developer.wordpress.org/cli/commands/comment/
  • 38.
  • 40. Scaffold ChildTheme Create child theme $ wp scaffold child-theme my-child-theme-slug --parent_theme=parent-theme-slug --theme_name="My Child Theme Name" --author="My Name" --author_uri=myurl.com --theme_uri=mythemeurl.com --activate https://developer.wordpress.org/cli/commands/scaffold/child-theme/
  • 41. Scaffold UnderscoresTheme Create theme based on Underscores $ wp scaffold _s my-theme-slug --theme_name="My Theme Name" --author="My Name" --author_uri=myurl.com --sassify --woocommerce --activate https://developer.wordpress.org/cli/commands/scaffold/underscores/
  • 42. Scaffold Plugins Generate starter code of a plugin $ wp scaffold plugin my-plugin-slug --dir=path/to/plugins --plugin_name="My Plugin Name" --plugin_description="My Plugin Description" --plugin_author="My Name" --plugin_author_uri=myurl.com --plugin_uri=mypluginurl.com https://developer.wordpress.org/cli/commands/scaffold/plugin/
  • 43. Scaffolded Plugin Contents  bin  tests .distignore .editorconfig .gitignore .phpcs.xml.dist .travis.yml Gruntfile.js my-plugin-slug.php package.json phpunit.xml.dist readme.txt  bin install-wp-tests.sh  tests bootstrap.php test-sample.php
  • 44. Scaffold Blocks Generate a block for a theme $ wp scaffold block my-block-slug --title="My Block Title" --theme=theme-slug Generate a block for a plugin $ wp scaffold block my-block-slug --title="My Block Title" --plugin=plugin-slug https://developer.wordpress.org/cli/commands/scaffold/block/
  • 45. Scaffolded Block Contents  my-block-slug my-block-slug.php  my-block-slug editor.css index.js style.css
  • 46. Scaffold PostTypes Generate custom post type $ wp scaffold post-type my-post-type-slug --label="My Post Type" --textdomain="my-post-type" Generate custom post type for a theme $ wp scaffold post-type my-post-type-slug --label="My Post Type" --theme=my-theme Generate custom post type for a plugin $ wp scaffold post-type my-post-type-slug --label="My Post Type" --plugin=my-plugin https://developer.wordpress.org/cli/commands/scaffold/post-type/
  • 47.
  • 48.
  • 49.
  • 50.
  • 51. ScaffoldTaxonomies Generate taxonomy $ wp scaffold taxonomy taxonomy-slug --textdomain="taxonomy- slug" Generate taxonomy for a theme $ wp scaffold taxonomy taxonomy-slug --post_types=my-post- type-slug > taxonomy.php --theme="twentynineteen" Generate taxonomy for a plugin $ wp scaffold taxonomy taxonomy-slug --post_types=my-post- type-slug > taxonomy.php --plugin="custom-plugin" https://developer.wordpress.org/cli/commands/scaffold/taxonomy
  • 52.
  • 53.
  • 54.
  • 55.
  • 57. Database Create database $ wp db create Reset current database $ wp db reset --yes Delete existing database $ wp db drop --yes https://developer.wordpress.org/cli/commands/db/
  • 58. Site Remove pages, posts, and custom post types $ wp site empty --yes Remove pages, posts, custom post types, and uploads $ wp site empty --uploads --yes https://developer.wordpress.org/cli/commands/site/
  • 59. Database Import database $ wp db import wpdb.sql Export database $ wp db export Open a MySQL console $ wp db cli https://developer.wordpress.org/cli/commands/db/
  • 60. DatabaseWith mysqlcheck Check database $ wp db check Optimize database $ wp db optimize Repair database $ wp db repair https://dev.mysql.com/doc/refman/8.0/en/mysqlcheck.html
  • 61. Config Create wp-config.php $ wp config create --dbname=database-name --dbuser=db-user --dbpass=db-password --dbhost=hostname --dbprefix=prfx_ Set constants and variables $ wp config set WP_DEBUG true --raw Change salt keys $ wp config shuffle-salts https://developer.wordpress.org/cli/commands/config/
  • 62. Search and Replace Search for staging URL and replace with production URL $ wp search-replace 'http://example.dev' 'http://example.com' --dry-run Search/replace to a SQL file without transforming the database $ wp search-replace 'http://example.dev' 'http://example.com' --export=database.sql Run case-insensitive regex search/replace operation $ wp search-replace '[foo id="([0-9]+)"' '[bar id="1"' -- regex --regex-flags='i' https://developer.wordpress.org/cli/commands/search-replace/
  • 63. Rewrite List rewrite rules $ wp rewrite list --format=csv Update permalink structure $ wp rewrite structure '/%postname%' Flush rewrite rules $ wp rewrite flush https://developer.wordpress.org/cli/commands/rewrite/
  • 64. Object Cache Set cache $ wp cache set my_key my_value my_group 300 Increase cache value $ wp cache incr my_key 2 my_group Decrease cache value $ wp cache decr my_key 2 my_group Flush cache $ wp cache flush https://developer.wordpress.org/cli/commands/cache/
  • 65. Transient Cache Set transient $ wp transient set my_key "test data" 3600 Delete transients $ wp transient delete my_key $ wp transient delete --expired $ wp transient delete --all https://developer.wordpress.org/cli/commands/transient/
  • 66. WP-Cron List scheduled cron events $ wp cron event list Schedule a new cron event $ wp cron event schedule cron_test Test that cron runs successfully $ wp cron test https://developer.wordpress.org/cli/commands/cron/
  • 67.
  • 68. More Commands within plugins Wrappers Editor plugins Vagrant boxes https://make.wordpress.org/cli/handbook/tools/
  • 69.
  • 70. CONFIGURATION For Efficiency and Specificity
  • 71. CLI Aliases Add alias $ wp cli alias add @staging --set-ssh=login@host --set- path=/path/to/wp/install/ --set-user=wpcli $ wp cli alias add @production --set-ssh=login@host --set- path=/path/to/wp/install/ --set-user=wpcli Create an alias group $ wp cli alias add @ourservers --grouping=staging,production https://developer.wordpress.org/cli/commands/cli/alias/
  • 72. Executing CommandsWith Aliases Update staging and production $ wp core update @staging $ wp core update @production $ wp core update @ourservers $ wp core update @all
  • 73. Executing CommandsWith Aliases Update all sites $ wp core update @all | wp theme update --all @all | wp plugin update --all @all Create bash alias $ alias update-all='wp core update @all && wp plugin update -- all @all && wp theme update --all @all' Update core, themes, and plugins on all aliases $ update-all https://make.wordpress.org/cli/handbook/shell-friends/
  • 74. Creating Aliases in Config Files @staging: ssh: username@hostname user: username path: /path/to/staging/install/ @production: ssh: username@hostname user: username path: /path/to/production/install/ @ourservers: - @staging - @production https://make.wordpress.org/cli/handbook/config/
  • 75. Configuration Files Arguments are interpreted in the following order: 1. Command-line arguments 2. wp-cli.local.yml 3. wp-cli.yml 4. ~/.wp-cli/config.yml 5. WP-CLI defaults https://make.wordpress.org/cli/handbook/config/
  • 76.
  • 78. Packages List installed packages $ wp package list Install a package $ wp package install package-slug Update a package $ wp package update package-slug Uninstall a package $ wp package uninstall package-slug https://developer.wordpress.org/cli/commands/package/
  • 79. Doctor Install $ wp package install git@github.com:wp-cli/doctor-command.git Get list of checks wp doctor can perform $ wp doctor list Perform checks $ wp doctor check core-verify-checksums $ wp doctor check core-verify-checksums file-eval php-in-uploads $ wp doctor check --all https://github.com/wp-cli/doctor-command
  • 80.
  • 81. Profile Install $ wp package install git@github.com:wp-cli/profile-command.git Run command $ wp profile stage $ wp profile hook $ wp profile eval $ wp profile eval-file https://github.com/wp-cli/profile-command/
  • 82. Profile Stage Profile all stages $ wp profile stage Profile the bootstrap stage $ wp profile stage bootstrap Profile all stages with zero-ish values eliminated $ wp profile stage --spotlight https://developer.wordpress.org/cli/commands/profile/stage/
  • 83.
  • 84. Profile Hook Profile all hooks $ wp profile hook Profile the wp_head hook $ wp profile hook wp_head Profile all hooks with zero-ish values eliminated $ wp profile hook --spotlight https://developer.wordpress.org/cli/commands/profile/hook/
  • 85.
  • 86.
  • 88. Scaffold Package 1) Install Scaffold Package Command $ wp package install git@github.com:wp-cli/scaffold-package- command.git 2) Generate files for a basic WP-CLI command $ wp scaffold package author/packagename --description="My Description" --homepage=package-homepage.com --dir=package-dir 3) Find your package /home/usr/.wp-cli/packages/local/author/packagename https://github.com/wp-cli/scaffold-package-command/
  • 89. Scaffolded Package Content  .github  bin  features  utils .distignore .editorconfig .gitignore .travis.yml command.php composer.json CONTRIBUTING.md README.md wp-cli.yml
  • 90.
  • 91.
  • 93. Resources Within WP-CLI $ wp help $ wp help <command> $ wp help <command> <subcommand> On the Web https://wp-cli.org/

Notes de l'éditeur

  1. BEFORE WE START: Who is familiar with command line? Who is using WP-CLI? 1) Lot of info Slides 2) Firehose Helicopter tour Scope Points of interest
  2. Professionally for 11 years Started with content and design, moving into development where I’m working happily these days.
  3. 1. Background 2. Basic Installation 3. Bulk of preso 4. Not required by helpful 5. Go over a couple packages to extend WP-CLI. 6. Touch on Writing Commands
  4. Stand-alone replacement for the GUI Anything in the GUI in the CLI, except uploading files
  5. We have this GUI… 1. a. Replaces GUI interactions with no browser refresh b. Bundle tasks together c. Use or write packages 2. a. Plugin, phpMyAdmin, hosting control panel b. Not switching taking up your time
  6. Requirements, Installation, Navigation, Syntax, Global parameters
  7. 1. Windows support To borrow a phrase, “UNIX is a requirement that begins where requirement ends.” 4. Choice of terminal apps. PuTTY GUI
  8. Full-service hosting, Good news. Bad news: Doesn’t mean they support everything
  9. ***non-UNIX servers or Git, Composer, Homebrew, Docker are supported and require their own approaches.
  10. Tight rope > balance beam If you’re new to command line, good place to start. Get a feel for executing commands Learn how to navigate when you can’t see everything at once Won’t break anything.
  11. EXAMPLES “If you know WP, you know what these commands do” Appreciate Hierarchical structure: wp = tool, command = area, subcommand =what you’re doing Flavor Efficiency: Compare examples with GUI Argument coming into play
  12. We also have global parameters to help us along --prompt, requires read times, cut the keystrokes in half
  13. 1. List includes names, status (activated), update availability, version
  14. 1. List includes names, status (activated), update, version 2. As we’ve seen 3.
  15. We’ve learned 3 commands. Might want to start combining
  16. One command to update all the thing
  17. 1. username, display name, email, reg date/time, role 2. --porcelain suppressed password, so it doesn’t end up in your bash history
  18. 1. Sends change email 2. --yes suppresses confirmation messages
  19. 1. Option and value
  20. 2. String together a bunch of commands you want to run after we’ve created a new WP install
  21. WAIT Add a post, edit a page, add a widget to sidebar, assign a menu to location I’ll leave some of those things for your own discovery.
  22. 4. Last line to keep password from logging in bash history. What I was saying before about full-service hosts 5. Note May not be able to create db with full-service hosting. 6. Your mileage may vary ***Anyone know of full-service host that allows creating db at CL
  23. *** LIST
  24. ** Assign capabilities, as previous 2. Delete role reverts user to previous role 3. Reset remove changes to capabilities
  25. Format-ids not required, but with get multiple error messages
  26. So, within areas we ordinarily work with in the GUI, we have deeper capabilities in the CLI We also have commands not associated with GUI commands
  27. ***Themes, plugins, blocks, post types, taxonomies
  28. Child theme: includes style.css, function.php (enqueues scripts and styles), .editorconfig
  29. Same as underscores.me
  30. * Create a folder in Plugins folder
  31. Supporting and testing files
  32. ** Adds blocks/block-slug
  33. STDOUT Theme Plugin Adds post-types/post-type-name.php
  34. Create custom messages
  35. Create custom messages
  36. Create custom messages
  37. Create custom messages
  38. --post_types param Adds taxonomies/taxonomy-slug.php
  39. Registering post type > split to make image more readable
  40. Registering post type > split to make image more readable
  41. Creating custom messages
  42. Handy things for theme and plugin dev
  43. Reset removes all tables, sets back to pre-install Drop deletes the db
  44. Use mysqlcheck utility to perform table maintenance Outputs results per table Check checks for errors Optimize optimizes (incl. --optimize=true) Repair can fix almost anything except unique keys that aren't unique. (incl. --repair=true)
  45. As we’ve seen … without opening a file
  46. S/R will work on serialized data, but not inside a serialized object
  47. List Update Think about Flush
  48. Flush your blessed cache No, flush will not on CloudFlare
  49. List: shows hook, time (local and GMT), and recurrence rate
  50. That’s a peek behind the scenes.
  51. 1. WC-CLI
  52. That’s the beginning Long commands, you may want more efficiency. Early point of verbose commands.
  53. 1) Create pairs ***@ALL alias When you’re doing this WP-CLI is setting up an @all alias
  54. Now you’re really updating all the things Or one command to rule them all
  55. Dare I say one command to update them all Don’t let the power go to your head
  56. 4. Where command line configuration is stored in config.yml 2. + 3. file inside the current working directory (or upwards) so you can fine-tune config to your needs
  57. While we’re talking about being efficient
  58. ***LIST!!!
  59. ***LIST
  60. Diagnoses problems within WordPress.
  61. Checking security, performance, configuration
  62. **Helps identify where WordPress is slow. Look for target page for stage?? Look up hook for specifics Remind yourself #2
  63. With spotlight, we’re getting four hooks of interest
  64. Used to be a repo for packages Check GitHub If you are inspired…
  65. Try your hand
  66. We have a Scaffold Package command Keep track of your author/packagename to find it
  67. Command.php
  68. Let me know how it goes