SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
WP-CLI: Save Time
by Managing
WordPress from the
Command Line
WordCamp Miami	

May 30, 2015	

@shawnhooper
• I’m Shawn Hooper, a web application
developer from Ottawa, Canada.
• I’ve been working in WordPress since
2009.
• I love the working from the command
prompt, reminds me of my days running
a BBS (in the days before the Internet)
Hi!
Command Line?!
• A set of command line tools that allows
you to manage WordPress from the
command line.

• http://www.wp-cli.org/
What is WP-CLI ?
• Anyone really, but mostly:
• Developers
• Theme Designers
• Server Administrators
Who is this for?
Don’t Fear The
Command Line
• http://www.wp-cli.org/
• Requires PHP 3.5.2 or later
• Requires WordPress 3.5.2 or later
• A “UNIX-like” environment:
• OSX (Macintosh)
• Linux
• Cygwin (Windows)
What do you need?
• You need to have SSH access to use
WP-CLI. Some shared hosting packages
do not allow SSH access
• SiteGround, Pantheon, BlueHost,
GoDaddy, Media Temple, Windows
Azure and more now have CLI support.
• VPS services like Digital Ocean and
Linode are ideal.
Hosts
• Download it:

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

• Set permissions: 

chmod +x wp-cli.phar

• Move it somewhere useful:

sudo mv wp-cli.phar /usr/local/bin/wp 

Installing WP-CLI
• Does it work? Type:



wp

Installing WP-CLI
Installing WP-CLI
Congratulations!
(that was the hard part)
Great… It’s installed.
So now what….
wp <command> <sub-command> <params>
Running Commands:
<param> — required
[—param] — optional flag
[—param=<value>] — optional w/ value
Running Commands:
• Check current WordPress version, or
see if there are updates available.
• Do the update!
• Install a brand new site
• Convert an existing site to Multisite!
• Verify core checksums
core
• Let’s try setting up a brand new site on
a development server using:



wp core download

wp core config

wp db create

wp core install --prompt
core
• Install, Delete Plugins
• Activate & Deactivate Plugins
• Update Plugins
• Search the repository for plugins
plugin
• Time savers!



wp plugin update — all



wp plugin deactivate — all
plugin
The “db” command interacts with
the MySQL database.
!
wp db export backup.sql



wp db import backup.sql



wp db cli
db
• Safe Search & Replace, including
serialized arrays!

• Supports --dry-run
search-replace
Generate Test Content !
wp post generate --count=500
post
Regenerate Thumbnails
!
wp media regenerate —yes
media
Start an underscores theme!
!
wp scaffold _s mytheme
scaffold
… or a child theme
!
wp scaffold child-theme mychild
—parent_theme=twentyfourteen
scaffold
… or a custom post type
!
wp scaffold post-type mycpt —
theme
scaffold
Download & Activate a Theme
from WordPress.org
!
wp theme install simone —activate
theme
wp user generate
wp user import-csv
Create Users
wp term list
wp term create
wp term generate
Taxonomies
Executes PHP code

* after loading the WordPress Core *
eval & eval-file
Add any functionality you want
that isn’t already included in the
WP-CLI core.
https://github.com/wp-cli/wp-cli/
wiki/List-of-community-commands
Community
Commands
You can either write them as a
plugin, or include it using the

—require parameter

on the command line.
Community
Commands
Thank you!
!
E-Mail: shawn@fivesense.ca
Twitter: @shawnhooper
!
www.shawnhooper.ca

Weitere ähnliche Inhalte

Was ist angesagt?

High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010
Barry Abrahamson
 
ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007
Barry Abrahamson
 

Was ist angesagt? (20)

SSDs are Awesome
SSDs are AwesomeSSDs are Awesome
SSDs are Awesome
 
WP-CLI: WordCamp Nashville 2016
WP-CLI: WordCamp Nashville 2016WP-CLI: WordCamp Nashville 2016
WP-CLI: WordCamp Nashville 2016
 
Week6 office-hours
Week6 office-hoursWeek6 office-hours
Week6 office-hours
 
Ryan Duff 2015 WordCamp US HTTP API
Ryan Duff 2015 WordCamp US HTTP APIRyan Duff 2015 WordCamp US HTTP API
Ryan Duff 2015 WordCamp US HTTP API
 
Working in harmony
Working in harmonyWorking in harmony
Working in harmony
 
High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010
 
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
 
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
 
Managing Multisite: Lessons from a Large Network
Managing Multisite: Lessons from a Large NetworkManaging Multisite: Lessons from a Large Network
Managing Multisite: Lessons from a Large Network
 
Don't worry with bower
Don't worry with bowerDon't worry with bower
Don't worry with bower
 
WordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityWordPress Fav Plugins & Security
WordPress Fav Plugins & Security
 
ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
WordCamp Boston WordPress plugins-8-2014
WordCamp Boston WordPress plugins-8-2014WordCamp Boston WordPress plugins-8-2014
WordCamp Boston WordPress plugins-8-2014
 
Liz Quilty – Security, Scaling & High End Hosting for WordPress sites
Liz Quilty – Security, Scaling & High End Hosting for WordPress sitesLiz Quilty – Security, Scaling & High End Hosting for WordPress sites
Liz Quilty – Security, Scaling & High End Hosting for WordPress sites
 
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
 
WP-MU 101: How to Install and Avoid Common Mistakes
WP-MU 101: How to Install and Avoid Common MistakesWP-MU 101: How to Install and Avoid Common Mistakes
WP-MU 101: How to Install and Avoid Common Mistakes
 
Making Magic with WP-CLI
Making Magic with WP-CLIMaking Magic with WP-CLI
Making Magic with WP-CLI
 
Wordpress vs Google Blogger/ Wampserver
Wordpress vs Google Blogger/ WampserverWordpress vs Google Blogger/ Wampserver
Wordpress vs Google Blogger/ Wampserver
 
Server Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.jsServer Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.js
 

Ähnlich wie WP-CLI - WordCamp Miami 2015

Wordpress website development
Wordpress website developmentWordpress website development
Wordpress website development
John Faust
 
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with SubversionProductivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
ryanduff
 

Ähnlich wie WP-CLI - WordCamp Miami 2015 (20)

WP-CLI Presentation from WordCamp NYC 2015
WP-CLI Presentation from WordCamp NYC 2015WP-CLI Presentation from WordCamp NYC 2015
WP-CLI Presentation from WordCamp NYC 2015
 
Manage WordPress From the Command Line with WP-CLI
Manage WordPress From the Command Line with WP-CLIManage WordPress From the Command Line with WP-CLI
Manage WordPress From the Command Line with WP-CLI
 
Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depth
 
Administer WordPress with WP-CLI
Administer WordPress with WP-CLIAdminister WordPress with WP-CLI
Administer WordPress with WP-CLI
 
Battling the WSOD - A Tech Support Tale
Battling the WSOD - A Tech Support TaleBattling the WSOD - A Tech Support Tale
Battling the WSOD - A Tech Support Tale
 
Wordpress website development
Wordpress website developmentWordpress website development
Wordpress website development
 
WordPress Plugins and Security
WordPress Plugins and SecurityWordPress Plugins and Security
WordPress Plugins and Security
 
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with SubversionProductivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
 
Working in Harmony: Manchester - Optimize development and content workflows
Working in Harmony: Manchester - Optimize development and content workflowsWorking in Harmony: Manchester - Optimize development and content workflows
Working in Harmony: Manchester - Optimize development and content workflows
 
Wordpress 101 presentation - Canadian Association of Labour Media (CALM)
Wordpress 101 presentation - Canadian Association of Labour Media (CALM)Wordpress 101 presentation - Canadian Association of Labour Media (CALM)
Wordpress 101 presentation - Canadian Association of Labour Media (CALM)
 
WP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and PluginsWP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and Plugins
 
Rapid WordPress theme development
Rapid WordPress theme developmentRapid WordPress theme development
Rapid WordPress theme development
 
The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.
 
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...
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate Workshop
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLI
 
The WordPress Way
The WordPress WayThe WordPress Way
The WordPress Way
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
 

Mehr von Shawn Hooper

Mehr von Shawn Hooper (13)

Introduction to WordPress Security
Introduction to WordPress SecurityIntroduction to WordPress Security
Introduction to WordPress Security
 
WP REST API: Actionable.co
WP REST API: Actionable.coWP REST API: Actionable.co
WP REST API: Actionable.co
 
Database Considerations for SaaS Products
Database Considerations for SaaS ProductsDatabase Considerations for SaaS Products
Database Considerations for SaaS Products
 
Payments Made Easy with Stripe
Payments Made Easy with StripePayments Made Easy with Stripe
Payments Made Easy with Stripe
 
WordPress Coding Standards & Best Practices
WordPress Coding Standards & Best PracticesWordPress Coding Standards & Best Practices
WordPress Coding Standards & Best Practices
 
Save Time By Manging WordPress from the Command Line
Save Time By Manging WordPress from the Command LineSave Time By Manging WordPress from the Command Line
Save Time By Manging WordPress from the Command Line
 
Writing Clean, Standards Compliant, Testable Code for WordPress
Writing Clean, Standards Compliant, Testable Code for WordPressWriting Clean, Standards Compliant, Testable Code for WordPress
Writing Clean, Standards Compliant, Testable Code for WordPress
 
Creating Multilingual WordPress Websites
Creating Multilingual WordPress WebsitesCreating Multilingual WordPress Websites
Creating Multilingual WordPress Websites
 
Creating Multilingual WordPress Websites
Creating Multilingual WordPress WebsitesCreating Multilingual WordPress Websites
Creating Multilingual WordPress Websites
 
Securing WordPress
Securing WordPressSecuring WordPress
Securing WordPress
 
Writing Secure Code for WordPress
Writing Secure Code for WordPressWriting Secure Code for WordPress
Writing Secure Code for WordPress
 
Hooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp ColumbusHooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp Columbus
 
Time Code: Automating Tasks in WordPress with WP-Cron
Time Code: Automating Tasks in WordPress with WP-CronTime Code: Automating Tasks in WordPress with WP-Cron
Time Code: Automating Tasks in WordPress with WP-Cron
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

WP-CLI - WordCamp Miami 2015

  • 1. WP-CLI: Save Time by Managing WordPress from the Command Line WordCamp Miami May 30, 2015 @shawnhooper
  • 2. • I’m Shawn Hooper, a web application developer from Ottawa, Canada. • I’ve been working in WordPress since 2009. • I love the working from the command prompt, reminds me of my days running a BBS (in the days before the Internet) Hi!
  • 4. • A set of command line tools that allows you to manage WordPress from the command line.
 • http://www.wp-cli.org/ What is WP-CLI ?
  • 5. • Anyone really, but mostly: • Developers • Theme Designers • Server Administrators Who is this for?
  • 7. • http://www.wp-cli.org/ • Requires PHP 3.5.2 or later • Requires WordPress 3.5.2 or later • A “UNIX-like” environment: • OSX (Macintosh) • Linux • Cygwin (Windows) What do you need?
  • 8. • You need to have SSH access to use WP-CLI. Some shared hosting packages do not allow SSH access • SiteGround, Pantheon, BlueHost, GoDaddy, Media Temple, Windows Azure and more now have CLI support. • VPS services like Digital Ocean and Linode are ideal. Hosts
  • 9. • Download it:
 curl -O https://raw.githubusercontent.com/ wp-cli/builds/gh-pages/phar/wp-cli.phar
 • Set permissions: 
 chmod +x wp-cli.phar
 • Move it somewhere useful:
 sudo mv wp-cli.phar /usr/local/bin/wp 
 Installing WP-CLI
  • 10. • Does it work? Type:
 
 wp
 Installing WP-CLI
  • 14. wp <command> <sub-command> <params> Running Commands:
  • 15. <param> — required [—param] — optional flag [—param=<value>] — optional w/ value Running Commands:
  • 16. • Check current WordPress version, or see if there are updates available. • Do the update! • Install a brand new site • Convert an existing site to Multisite! • Verify core checksums core
  • 17. • Let’s try setting up a brand new site on a development server using:
 
 wp core download
 wp core config
 wp db create
 wp core install --prompt core
  • 18. • Install, Delete Plugins • Activate & Deactivate Plugins • Update Plugins • Search the repository for plugins plugin
  • 19. • Time savers!
 
 wp plugin update — all
 
 wp plugin deactivate — all plugin
  • 20. The “db” command interacts with the MySQL database. ! wp db export backup.sql
 
 wp db import backup.sql
 
 wp db cli db
  • 21. • Safe Search & Replace, including serialized arrays!
 • Supports --dry-run search-replace
  • 22. Generate Test Content ! wp post generate --count=500 post
  • 23. Regenerate Thumbnails ! wp media regenerate —yes media
  • 24. Start an underscores theme! ! wp scaffold _s mytheme scaffold
  • 25. … or a child theme ! wp scaffold child-theme mychild —parent_theme=twentyfourteen scaffold
  • 26. … or a custom post type ! wp scaffold post-type mycpt — theme scaffold
  • 27. Download & Activate a Theme from WordPress.org ! wp theme install simone —activate theme
  • 28. wp user generate wp user import-csv Create Users
  • 29. wp term list wp term create wp term generate Taxonomies
  • 30. Executes PHP code
 * after loading the WordPress Core * eval & eval-file
  • 31. Add any functionality you want that isn’t already included in the WP-CLI core. https://github.com/wp-cli/wp-cli/ wiki/List-of-community-commands Community Commands
  • 32. You can either write them as a plugin, or include it using the
 —require parameter
 on the command line. Community Commands
  • 33. Thank you! ! E-Mail: shawn@fivesense.ca Twitter: @shawnhooper ! www.shawnhooper.ca