SlideShare uma empresa Scribd logo
1 de 79
Take Command ofWordPressWith
WP-CLI
Diana Thompson
WordCamp Long Beach
October 5, 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 with the CLI
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
Check for available core update
$ wp core check-update
Update WordPress
$ wp core update
Convert to Multisite
$ wp core multisite-convert
Install Multisite
$ wp core multisite-install
--title="Welcome to the
WordPress" 
> --admin_user="username"
--admin_password="password" 
> --admin_email="user@email.com"
https://developer.wordpress.org/cli/commands/core/
Plugins
List plugins
$ wp plugin list
Install and activate 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
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
Change permalink structure, change time zone, block search engines, and close commenting
$ wp option update permalink_structure /%postname%/ | wp
option update gmt_offset -7 | $ wp option update blog_public 0
| $ wp option update default_comment_status closed
https://codex.wordpress.org/Option_Reference/
Comments
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
Import database
$ wp db import wpdb.sql
Export database
$ wp db export
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/
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
Update all sites
$ wp core update @all | wp theme update --all @all | wp plugin
update --all @all
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/
Shortening Commands with Bash
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/
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 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

Mais conteúdo relacionado

Mais procurados

Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonWordCamp Sydney
 
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
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIWP Engine
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWalter Ebert
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depthSanjay Willie
 
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
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Acquia
 
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
 
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
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django ChannelsAlbert O'Connor
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
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
 
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
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern ApproachAlessandro Fiore
 
The eggless Plone manifesto (or Plone the open source cms-as-a-service platf...
The eggless Plone manifesto (or Plone  the open source cms-as-a-service platf...The eggless Plone manifesto (or Plone  the open source cms-as-a-service platf...
The eggless Plone manifesto (or Plone the open source cms-as-a-service platf...Dylan Jay
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 

Mais procurados (20)

Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter Wilson
 
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)
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depth
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
 
WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
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
 
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
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django Channels
 
Real-Time Django
Real-Time DjangoReal-Time Django
Real-Time Django
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Powershell: Tu nuevo mejor amigo
Powershell: Tu nuevo mejor amigoPowershell: Tu nuevo mejor amigo
Powershell: Tu nuevo mejor amigo
 
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
 
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
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern Approach
 
The eggless Plone manifesto (or Plone the open source cms-as-a-service platf...
The eggless Plone manifesto (or Plone  the open source cms-as-a-service platf...The eggless Plone manifesto (or Plone  the open source cms-as-a-service platf...
The eggless Plone manifesto (or Plone the open source cms-as-a-service platf...
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 

Semelhante a Take Command of WordPress With WP-CLI at WordCamp Long Beach

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
 
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
 
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
 
Workshop On WP-CLI
Workshop On WP-CLIWorkshop On WP-CLI
Workshop On WP-CLIAjit Bohra
 
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
 
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
 
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
 
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
 
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
 
WordPress and The Command Line
WordPress and The Command LineWordPress and The Command Line
WordPress and The Command LineKelly Dwan
 
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
 
Command Line WordPress with WP-CLI
Command Line WordPress with WP-CLICommand Line WordPress with WP-CLI
Command Line WordPress with WP-CLIJames Collins
 
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
 
Advanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comAdvanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comInstaWP Inc
 
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
 
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
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin developmentMostafa Soufi
 
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
 

Semelhante a Take Command of WordPress With WP-CLI at WordCamp Long Beach (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
 
Administer WordPress with WP-CLI
Administer WordPress with WP-CLIAdminister WordPress with WP-CLI
Administer WordPress with WP-CLI
 
wp cli
wp cliwp cli
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
 
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
 
Workshop On WP-CLI
Workshop On WP-CLIWorkshop On WP-CLI
Workshop On 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...
 
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
 
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
 
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
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
WordPress and The Command Line
WordPress and The Command LineWordPress and The Command Line
WordPress and The Command Line
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
Command Line WordPress with WP-CLI
Command Line WordPress with WP-CLICommand Line WordPress with WP-CLI
Command Line WordPress with 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
 
Advanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.comAdvanced WordPress Tooling: By InstaWP.com
Advanced WordPress Tooling: By InstaWP.com
 
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
 
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]
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
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
 

Último

IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesLumiverse Solutions Pvt Ltd
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 

Último (9)

IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best Practices
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 

Take Command of WordPress With WP-CLI at WordCamp Long Beach

  • 1. Take Command ofWordPressWith WP-CLI Diana Thompson WordCamp Long Beach October 5, 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 with the CLI
  • 6. WhyWP-CLI? Do more in less time.
  • 8. Requirements UNIX-like server environment PHP 5.4 or later WordPress 3.7 or later Terminal app: native apps, PuTTY SSH access
  • 9. Web HostsWithWP-CLI Installed Bluehost Dreamhost HostGator SiteGround WPEngine among others https://make.wordpress.org/cli/handbook/hosting-companies/
  • 10. 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/
  • 11. 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
  • 12. WP-CLI Syntax $ wp command subcommand [value] [--argument] Examples: $ wp core download $ wp plugin update --all $ wp theme install twentynineteen --activate
  • 13. 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. Core Check for available core update $ wp core check-update Update WordPress $ wp core update Convert to Multisite $ wp core multisite-convert Install Multisite $ wp core multisite-install --title="Welcome to the WordPress" > --admin_user="username" --admin_password="password" > --admin_email="user@email.com" https://developer.wordpress.org/cli/commands/core/
  • 16. Plugins List plugins $ wp plugin list Install and activate 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/
  • 17. 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/
  • 18. Combine Commands with Pipes Update core, all plugins, and all themes $ wp core update | wp plugin update --all | wp theme update --all
  • 19. Users List users $ wp user list Create user $ wp user create ann ann@example.com --porcelain --send-email Delete user $ wp user delete john --reassign=lynn $ wp user delete john --yes https://developer.wordpress.org/cli/commands/user/
  • 20. 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/
  • 21. Options Change image thumbnail size $ wp option update thumbnail_size_w 200 | wp option update thumbnail_size_h 200 | $ wp media regenerate --yes Change permalink structure, change time zone, block search engines, and close commenting $ wp option update permalink_structure /%postname%/ | wp option update gmt_offset -7 | $ wp option update blog_public 0 | $ wp option update default_comment_status closed https://codex.wordpress.org/Option_Reference/
  • 22. Comments Delete all spam comments $ wp comment delete $(wp comment list --status=spam --format=ids) https://developer.wordpress.org/cli/commands/comment/
  • 24. 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/
  • 25. 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/
  • 27. 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
  • 28. 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/
  • 29. 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/
  • 30. 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/
  • 31. 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/
  • 32. Comments Generate comments $ wp comment generate --format=ids --count=3 --post_id=123 https://developer.wordpress.org/cli/commands/comment/
  • 34. 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/
  • 35. 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/
  • 36. 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/
  • 37. 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
  • 38. 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/
  • 39. Scaffolded Block Contents  my-block-slug my-block-slug.php  my-block-slug editor.css index.js style.css
  • 40. 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/
  • 41.
  • 42.
  • 43.
  • 44.
  • 45. 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
  • 46.
  • 47.
  • 48.
  • 50. Database Create database $ wp db create Import database $ wp db import wpdb.sql Export database $ wp db export Reset current database $ wp db reset --yes Delete existing database $ wp db drop --yes https://developer.wordpress.org/cli/commands/db/
  • 51. 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/
  • 52. 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
  • 53. 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/
  • 54. 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/
  • 55. 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/
  • 56. 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/
  • 57. 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/
  • 58. 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/
  • 59. More Commands within plugins Wrappers Editor plugins Vagrant boxes https://make.wordpress.org/cli/handbook/tools/
  • 60. CONFIGURATION For Efficiency and Specificity
  • 61. 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/
  • 62. Executing CommandsWith Aliases Update staging and production $ wp core update @staging $ wp core update @production $ wp core update @ourservers $ wp core update @all Update all sites $ wp core update @all | wp theme update --all @all | wp plugin update --all @all
  • 63. 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/
  • 64. 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/
  • 65. Shortening Commands with Bash 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/
  • 67. 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/
  • 68. 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
  • 69.
  • 70. 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/
  • 71. 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/
  • 72.
  • 74. 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/
  • 75. Scaffolded Package Content  .github  bin  features  utils .distignore .editorconfig .gitignore .travis.yml command.php composer.json CONTRIBUTING.md README.md wp-cli.yml
  • 76.
  • 78. Resources Within WP-CLI $ wp help $ wp help <command> $ wp help <command> <subcommand> On the Web https://wp-cli.org/

Notas do Editor

  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
  3. 1. Intro 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 Except uploading files, anything in the GUI in the CLI
  5. We have this GUI… 1a. Compare GUI & CLI b. Bundle tasks together c. Use or write packages 2a. Plugin, phpMyAdmin, hosting control panel b. Not switching taking up your time
  6. 1. Windows support To borrow a phrase, “UNIX is a requirement that begins where requirement ends.” 4. Choice of terminal apps.
  7. Full-service hosting, Good news. Bad news.
  8. a. Non-UNIX servers have own installations b. Can also install with Git, Composer, Homebrew, Docker
  9. If you’re new to command line, good place to start. Get a feel for executing commands Learn how to know where you are when you can’t see your whole tree at once Won’t break anything.
  10. EXAMPLES If you know WP, you know what these commands do. Low bar to entry. WP-CLI teaches you itself. Appreciate Hierarchical structure: wp = tool, command = area, subcommand =what you’re doing Flavor Efficiency: Compare examples with GUI Argument coming into play
  11. List includes names, status (activated), update availability, version 2. Like with themes… 3. As we’ve seen, update…
  12. One command to update all the thing Moving on…
  13. 1. username, display name, email, reg date/time, role 2. --porcelain suppressed password 3. --yes suppresses confirmation messages
  14. General, Reading, Writing 1. Option and value
  15. 2. String together commands you want to run after we’ve created a new WP install
  16. Here we are passing data from one command to another. List of status=spam in the form of ids
  17. 4. Last line to keep password from logging in bash history. ** What I was saying before about full-service hosts… You may not be able to create db or admin_password to txt file Your mileage may vary ? Anyone know of full-service host that allows creating db at CL
  18. Note: ID, username or email.
  19. Plugins remove load and security
  20. 1. And assign capabilities as previous 2. Delete role reverts user to previous role 3. Reset changes to default capabilities
  21. ***Themes, plugins, blocks, post types, taxonomies
  22. Child theme: includes style.css, function.php (enqueues scripts and styles), .editorconfig
  23. Same as underscores.me
  24. ** Creates a folder in Plugins folder
  25. Supporting and testing files
  26. ** Adds blocks/block-slug
  27. STDOUT Theme Plugin ** Adds post-types/post-type-slug.php
  28. Create custom messages
  29. Create custom messages
  30. Create custom messages
  31. Create custom messages
  32. --post_types param ** Adds taxonomies/taxonomy-slug.php
  33. Registering post type
  34. Labels
  35. Custom messages
  36. If you want a subtler approach…
  37. Use mysqlcheck utility
  38. As we’ve seen … without opening a file
  39. S/R will work on serialized data, but not inside a serialized object
  40. List Update Think about Flush
  41. Flush your blessed cache No, flush will not on CloudFlare
  42. List: shows hook, time (local and GMT), and recurrence rate
  43. Things I’m leaving out so there are some treasures you can find WC-CLI
  44. Create staging/production pairs Create staging group and production group
  45. 2. Update core, all themes, all plugins on all aliases
  46. Command line configuration is stored in config.yml 2. & 3. files inside the current working directory (or upwards) Fine-tune config to your needs But that’s not all
  47. ***LIST!!!
  48. ***LIST
  49. Diagnoses problems within WordPress.
  50. Checking security, performance, configuration
  51. **Helps identify where WordPress is slow.
  52. With spotlight, we’re getting four hooks of interest
  53. Try your hand
  54. We have a Scaffold Package command Keep track of your author/packagename to find it
  55. Let me know how it goes