SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
WP-CLI - Ein Kommandozeilen Interface 	

für WordPress 	

23.10.2013 Frank Staude <frank@staude.net>
WP-CLI ?
WP-CLI ( WordPress - Command Line Interface) ist ein Programm, mit dem man
Wordpress per Kommandozeile bedienen kann.	

!

Warum braucht man das?	

- Admins sind gewohnt mit der Tastatur zu arbeiten	

- Mit der Tastatur ist man in der Regel schneller als in einem Webinterface 	

- Mit Kommandos kann man Aufgaben automatisieren
Voraussetzungen
Um WP-CLI zu installieren braucht es ein paar Dinge	

!

- Unix shell. ( OS X, Linux, Windows mit Cygwin)	

- PHP 5.3 oder neuer 	

- php-cli im PHP aktiviert (php -v / phpinfo zum prüfen)	

- Git	

- Wordpress 3.4 oder neuer	

!
Installation
Ein Installationsscript kann direkt von GitHub geladen und ausgeführt werden.	

!

curl https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | bash	

!

Das installiert WP-CLI im Verzeichnis .wp-cli im Benutzerverzeichnis.	

Damit es von überall gefunden wird, sollte man danach noch das bin Verzeichnis von
wp-cli mit im Pfad seiner Shell aufnehmen. Eine Entsprechende Meldung gibt der
Installer aus.	

!

MySQL muss im Pfad liegen, sonst scheitert wp core config 	

!

Alternative Installationsmethoden: https://github.com/wp-cli/wp-cli/wiki/AlternativeInstall-Methods
Erster Start
Nun kann WP-CLI durch die Eingabe von wp aufgerufen werden.	

!
Mehr Komfort
WP-CLI bietet auch s.g. Tab completion, also die Funktionalität bei drücken der
Tabulator Taste das Kommando zu vervollständigen oder (wenn nicht eindeutig) die
Liste der Kommandos auszugeben.	

!

Dazu muss man seine .profile Datei ergänzen um	

!

source $HOME/.wp-cli/vendor/wp-cli/wp-cli/utils/wp-completion.bash	

!
!
wp
wp cache
wp cap
wp cli
wp comment
wp core
wp db
wp eval
wp eval-file
wp export
wp help
wp import
wp media
wp network-meta
wp option
wp plugin
wp post
wp post-meta
wp rewrite
wp role
wp scaffold
wp search-replace
wp site
wp term
wp theme
wp transient
wp user
wp user-meta
Beispiele: WP Version
Entweder man wechselt in das Verzeichnis der jeweiligen Wordpress
Installation	

!

staude$ cd Wordpress Dev/!
staude$ wp core version!
3.6.1!
!

oder man übergibt den Pfad mittels --path=‘pfad/zur/WP/Installation‘	

!

staude$ wp core version --path='/Users/staude/
Projekte/Wordpress Dev'!
3.6.1!
Beispiele: Plugins auflisten
staude$ wp plugin list!
+-----------------------------------+----------+--------+---------+!
| name
| status
| update | version |!
+-----------------------------------+----------+--------+---------+!
| akismet
| inactive | none
| 2.5.9
|!
| backend-startpage-customizer
| inactive | none
| 0.2
|!
| blog-description-randomizer
| inactive | none
| 0.1
|!
| codestyling-localization
| active
| none
| 1.99.30 |!
| disable-author-pages
| active
| none
| 0.2
|!
| disable-title
| active
| none
| 0.5
|!
| downloads-per-page
| active
| none
| 0.1
|!
| google-analytics-dashboard-for-wp | active
| none
| 4.2.1
|!
| mime-types-extended
| active
| none
| 0.7
|!
| my-own-plugins
| inactive | none
| 0.1
|!
| post-author-filter
| active
| none
| 0.1
|!
| random-blog-description
| inactive | none
| 1.0
|!
| scheduled-posts-dashboard-widget | active
| none
| 0.1
|!
| scheduled-jobs-dashboard-widget
| inactive | none
| 0.2.2
|!
| scheduled-unsticky
| inactive | none
| 0.2.2
|!
| widget-or-sidebar-per-shortcode
| inactive | none
| 0.4
|!
+-----------------------------------+----------+--------+---------+!
Beispiele: Plugins suchen
staude$ wp plugin search hello-dolly!
Success: Showing 10 of 20 plugins.!
+-------------------------------+-------------------------------+--------+!
| name
| slug
| rating |!
+-------------------------------+-------------------------------+--------+!
| Hello Dolly
| hello-dolly
| 67.4
|!
| Hello Dolly For Your Song
| hello-dolly-for-your-song
| 0
|!
| Hello Simpsons Chalkboard Gag | hello-simpsons-chalkboard-gag | 100
|!
| Hello Kurt
| hello-kurt
| 0
|!
| Fancy Dolly
| fancy-plugin
| 91.4
|!
| Hello Darth
| hello-darth
| 100
|!
| Hello Hollywood
| hello-hollywood
| 100
|!
| Hello Ziggy
| hello-ziggy
| 0
|!
| Hello HAL
| hello-hal
| 100
|!
| Unwanted Plugins Remover
| unwanted-plugins-remover
| 100
|!
+-------------------------------+-------------------------------+--------+!
Beispiele: Plugin installieren

staude$ wp plugin install hello-dolly!
Installing Hello Dolly (1.6)!
Runterladen des Installationspakets von http://downloads.wordpress.org/plugin/hellodolly.1.6.zip...!
Entpacken des Pakets...!
Das Plugin wird installiert...!
Das Plugin wurde erfolgreich installiert.!
Beispiele: Plugin aktivieren

staude$ wp plugin activate hello-dolly!
Success: Plugin 'hello-dolly' activated.!

!
!

staude$ wp plugin deactivate hello-dolly!
Success: Plugin 'hello-dolly' deactivated.!
Beispiele: WP installieren
In ein neues, leeres Verzeichnis gehen (oder --path überall angeben)!

!

staude$ wp core download!
Downloading latest WordPress (en_US)...!
Success: WordPress downloaded.!

!

staude$ wp core config --dbname=Datenbank --dbuser=Benutzer --dbpass=Kennwort!
Success: Generated wp-config.php file.!

!

staude$ wp core install --url=test.de --title=title --admin_user=adminBenutzer
--admin_password=adminKennwort --admin_email=admin@domain.tld!
Success: WordPress installed successfully.!
Plugin + WP-CLI
Plugins können ebenfalls das WP-CLI Interface implementieren und können dann ebenfalls perKomandozeile bedient werden.	

Zum Beispiel das Plugin Developer ( http://wordpress.org/plugins/developer ). 	


!

staude$ wp plugin install developer!
Installing Developer (1.2.5)!
Runterladen des Installationspakets von http://downloads.wordpress.org/plugin/
developer.1.2.5.zip...!
Entpacken des Pakets...!
Das Plugin wird installiert...!
Das Plugin wurde erfolgreich installiert.!

!

staude$ wp plugin activate developer!
Success: Plugin 'developer' activated.!

!
!

staude$ wp developer!
usage: wp developer install-plugins --type=<type> [--activate]!

!

See 'wp help developer <subcommand>' for more information on a specific subcommand.!
Eigenes Plugin + WP-CLI
Am Beispiel meines Plugins scheduled-unsticky ( http://wordpress.org/plugins/scheduled-unsticky/ )
demonstriere ich die Arbeiten um ein Plugin per WP-CLI steuerbar zu machen. 	

!
Abfragen des WP-CLI defines im Constructor und ggf laden einer Klasse die das CLI Interface
implementiert.	

!
if ( defined ( 'WP_CLI' ) && WP_CLI ) {!
require_once( __DIR__ . '/class-wp-cli-commands.php' );!
}
Eigenes Plugin + WP-CLI
Und die Implementierung!

!

<?php!
class Scheduled_Unsticky_WP_CLI_Command extends WP_CLI_Command {!
/**!
* @subcommand info!
*/
!
function info( $args, $assoc_args ) {!
$cron = get_option('scheduled_unsticky_cron');!
$days = get_option( 'scheduled_unsticky_days' );!
if ($cron != 0) {!
$schedules = wp_get_schedules();!
$cron = $schedules[$cron];!
}!
WP_CLI::line('interval: '. $cron );!
WP_CLI::line('days
: '. $days);!
}!
/**!
* @subcommand days !
* @synopsis <days>!
*/!
function days( $args ) {!
$days = $args[0];!
update_option( 'scheduled_unsticky_days', $days );!
WP_CLI::success('days: '. $days);!
}!
}!

!

WP_CLI::add_command( 'scheduled-unsticky', 'Scheduled_Unsticky_WP_CLI_Command' );!

!
Eigenes Plugin + WP-CLI
staude$ wp scheduled-unsticky!
usage: wp scheduled-unsticky days <days>!
or: wp scheduled-unsticky info!

!

See 'wp help scheduled-unsticky <subcommand>' for more information on a specific subcommand.!

!
!

staude$ wp scheduled-unsticky info!
interval: twicedaily!
days
: 2!

!
!

staude$ wp scheduled-unsticky days 3!
Success: days: 3!

!
!

staude$ wp scheduled-unsticky info!
interval: twicedaily!
days
: 3!

!
!
Links
WP-CLI !
http://wp-cli.org/!

!

WP-CLI Wiki!
https://github.com/wp-cli/wp-cli/wiki!

!

WP-CLI Installation!
http://wp-cli.org/!

!

Alternative Installationsmöglichkeiten!
https://github.com/wp-cli/wp-cli/wiki/Alternative-Install-Methods!

!

Command Cookbook - für Implementierung eigener Erweiterungen!
https://github.com/wp-cli/wp-cli/wiki/Commands-Cookbook!

!

Scheduled Unsticky Plugin!
http://wordpress.org/plugins/scheduled-unsticky/!

Más contenido relacionado

La actualidad más candente

WordPress Professional II
WordPress Professional IIWordPress Professional II
WordPress Professional IISebastian Blum
 
Neos CMS - das Kompendium (Version 2.0.0)
Neos CMS - das Kompendium (Version 2.0.0)Neos CMS - das Kompendium (Version 2.0.0)
Neos CMS - das Kompendium (Version 2.0.0)die.agilen GmbH
 
AdminCamp 14 - IBM Connections Deep Dive
AdminCamp 14 - IBM Connections Deep DiveAdminCamp 14 - IBM Connections Deep Dive
AdminCamp 14 - IBM Connections Deep DiveKlaus Bild
 
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...Klaus Bild
 
OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...
OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...
OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...NETWAYS
 
Die Zukunft der Webstandards - Webinale 31.05.2010
Die Zukunft der Webstandards - Webinale 31.05.2010Die Zukunft der Webstandards - Webinale 31.05.2010
Die Zukunft der Webstandards - Webinale 31.05.2010Patrick Lauke
 
Einführung Progressive Web App
Einführung Progressive Web AppEinführung Progressive Web App
Einführung Progressive Web AppSebastian Blum
 
TYPO3 Performance (TYPO3camp München)
TYPO3 Performance (TYPO3camp München)TYPO3 Performance (TYPO3camp München)
TYPO3 Performance (TYPO3camp München)Marcus Schwemer
 
Fix & fertig: Best Practises für "XPages-Migranten"
Fix & fertig: Best Practises für "XPages-Migranten"Fix & fertig: Best Practises für "XPages-Migranten"
Fix & fertig: Best Practises für "XPages-Migranten"Oliver Busse
 
Gearman - Distributed Job System
Gearman - Distributed Job SystemGearman - Distributed Job System
Gearman - Distributed Job SystemMayflower GmbH
 
WordPress absichern - WP Camp 2012 in Berlin
WordPress absichern - WP Camp 2012 in BerlinWordPress absichern - WP Camp 2012 in Berlin
WordPress absichern - WP Camp 2012 in BerlinTorsten Landsiedel
 
TYPO3 CMS 7.0 - Die Neuerungen - pluswerk
TYPO3 CMS 7.0 - Die Neuerungen - pluswerkTYPO3 CMS 7.0 - Die Neuerungen - pluswerk
TYPO3 CMS 7.0 - Die Neuerungen - pluswerkdie.agilen GmbH
 

La actualidad más candente (20)

WordPress Professional II
WordPress Professional IIWordPress Professional II
WordPress Professional II
 
Neos CMS - das Kompendium (Version 2.0.0)
Neos CMS - das Kompendium (Version 2.0.0)Neos CMS - das Kompendium (Version 2.0.0)
Neos CMS - das Kompendium (Version 2.0.0)
 
Wordpress Security
Wordpress SecurityWordpress Security
Wordpress Security
 
Deployment 2.0
Deployment 2.0Deployment 2.0
Deployment 2.0
 
AdminCamp 14 - IBM Connections Deep Dive
AdminCamp 14 - IBM Connections Deep DiveAdminCamp 14 - IBM Connections Deep Dive
AdminCamp 14 - IBM Connections Deep Dive
 
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
 
Hdc2012 cordova-präsi
Hdc2012 cordova-präsiHdc2012 cordova-präsi
Hdc2012 cordova-präsi
 
OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...
OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...
OSDC 2013 | Enterprise open source virtualization with oVirt and RHEV by René...
 
Die Zukunft der Webstandards - Webinale 31.05.2010
Die Zukunft der Webstandards - Webinale 31.05.2010Die Zukunft der Webstandards - Webinale 31.05.2010
Die Zukunft der Webstandards - Webinale 31.05.2010
 
Dockerize It - Mit apex in die amazon cloud
Dockerize It - Mit apex in die amazon cloudDockerize It - Mit apex in die amazon cloud
Dockerize It - Mit apex in die amazon cloud
 
Einführung Progressive Web App
Einführung Progressive Web AppEinführung Progressive Web App
Einführung Progressive Web App
 
Nginx
NginxNginx
Nginx
 
TYPO3 Performance (TYPO3camp München)
TYPO3 Performance (TYPO3camp München)TYPO3 Performance (TYPO3camp München)
TYPO3 Performance (TYPO3camp München)
 
Fix & fertig: Best Practises für "XPages-Migranten"
Fix & fertig: Best Practises für "XPages-Migranten"Fix & fertig: Best Practises für "XPages-Migranten"
Fix & fertig: Best Practises für "XPages-Migranten"
 
Gearman - Distributed Job System
Gearman - Distributed Job SystemGearman - Distributed Job System
Gearman - Distributed Job System
 
"WordPress Blog Aufsetzen und Pimpen"
"WordPress Blog Aufsetzen und Pimpen""WordPress Blog Aufsetzen und Pimpen"
"WordPress Blog Aufsetzen und Pimpen"
 
Einführung in Docker
Einführung in DockerEinführung in Docker
Einführung in Docker
 
WordPress absichern - WP Camp 2012 in Berlin
WordPress absichern - WP Camp 2012 in BerlinWordPress absichern - WP Camp 2012 in Berlin
WordPress absichern - WP Camp 2012 in Berlin
 
Chrome for Work | CLOUDPILOTS FastTrack Update
Chrome for Work | CLOUDPILOTS FastTrack UpdateChrome for Work | CLOUDPILOTS FastTrack Update
Chrome for Work | CLOUDPILOTS FastTrack Update
 
TYPO3 CMS 7.0 - Die Neuerungen - pluswerk
TYPO3 CMS 7.0 - Die Neuerungen - pluswerkTYPO3 CMS 7.0 - Die Neuerungen - pluswerk
TYPO3 CMS 7.0 - Die Neuerungen - pluswerk
 

Similar a WP-CLI - Das Kommandozeilen Interface für Wordpress

Bestehende WordPress-Seiten auf Multisite migrieren
Bestehende WordPress-Seiten auf Multisite migrierenBestehende WordPress-Seiten auf Multisite migrieren
Bestehende WordPress-Seiten auf Multisite migrierenWalter Ebert
 
Cloud Provisioning mit Juju
Cloud Provisioning mit JujuCloud Provisioning mit Juju
Cloud Provisioning mit JujuFrank Müller
 
Word Press Als Blog Und Cms O
Word Press Als Blog Und Cms OWord Press Als Blog Und Cms O
Word Press Als Blog Und Cms Osol777
 
Word Press Als Blog Und Cms O
Word Press Als Blog Und Cms OWord Press Als Blog Und Cms O
Word Press Als Blog Und Cms Osol777
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Torsten Kleiber
 
Forms and Reports 12c - Processes and Automation in Development and Operations
Forms and Reports 12c - Processes and Automation in Development and OperationsForms and Reports 12c - Processes and Automation in Development and Operations
Forms and Reports 12c - Processes and Automation in Development and OperationsTorsten Kleiber
 
AdminCamp 14: Make your IBM Connections deployment your own - Customize it!
AdminCamp 14: Make your IBM Connections deployment your own - Customize it!AdminCamp 14: Make your IBM Connections deployment your own - Customize it!
AdminCamp 14: Make your IBM Connections deployment your own - Customize it!Klaus Bild
 
SEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-Freaks
SEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-FreaksSEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-Freaks
SEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-FreaksSEARCH ONE
 
Ausrollen von Multi-Tier-Applikationen mit Docker
Ausrollen von Multi-Tier-Applikationen mit DockerAusrollen von Multi-Tier-Applikationen mit Docker
Ausrollen von Multi-Tier-Applikationen mit DockerB1 Systems GmbH
 
Drupal 7 Einblick und Ausblick
Drupal 7 Einblick und AusblickDrupal 7 Einblick und Ausblick
Drupal 7 Einblick und AusblickAmazee Labs
 
SNoUG 2015 - Vaadin - XPages 2.0?
SNoUG 2015 - Vaadin - XPages 2.0?SNoUG 2015 - Vaadin - XPages 2.0?
SNoUG 2015 - Vaadin - XPages 2.0?René Winkelmeyer
 
Wordpress Template Workshop
Wordpress Template WorkshopWordpress Template Workshop
Wordpress Template Workshopphillipgroschup
 
Docker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-PatternsDocker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-PatternsQAware GmbH
 
Docker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-PatternsDocker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-PatternsJosef Adersberger
 
PowerShell Sicherheit in 6 Schritten produktiv absichern
PowerShell Sicherheit in 6 Schritten produktiv absichernPowerShell Sicherheit in 6 Schritten produktiv absichern
PowerShell Sicherheit in 6 Schritten produktiv absichernAttila Krick
 
Web-Automatisierung mit WWW::Mechanize
Web-Automatisierung mit WWW::MechanizeWeb-Automatisierung mit WWW::Mechanize
Web-Automatisierung mit WWW::MechanizeThomas Fahle
 
WordPress sicherer machen - Basics
WordPress sicherer machen - BasicsWordPress sicherer machen - Basics
WordPress sicherer machen - BasicsAndreas Rudorfer
 
Automatischer Build mit Maven - OPITZ CONSULTING - Stefan Scheidt
Automatischer Build mit Maven - OPITZ CONSULTING - Stefan ScheidtAutomatischer Build mit Maven - OPITZ CONSULTING - Stefan Scheidt
Automatischer Build mit Maven - OPITZ CONSULTING - Stefan ScheidtOPITZ CONSULTING Deutschland
 
Versionskontrolle in Machine-Learning-Projekten
Versionskontrolle in Machine-Learning-ProjektenVersionskontrolle in Machine-Learning-Projekten
Versionskontrolle in Machine-Learning-Projektencusy GmbH
 

Similar a WP-CLI - Das Kommandozeilen Interface für Wordpress (20)

Bestehende WordPress-Seiten auf Multisite migrieren
Bestehende WordPress-Seiten auf Multisite migrierenBestehende WordPress-Seiten auf Multisite migrieren
Bestehende WordPress-Seiten auf Multisite migrieren
 
Cloud Provisioning mit Juju
Cloud Provisioning mit JujuCloud Provisioning mit Juju
Cloud Provisioning mit Juju
 
Word Press Als Blog Und Cms O
Word Press Als Blog Und Cms OWord Press Als Blog Und Cms O
Word Press Als Blog Und Cms O
 
Word Press Als Blog Und Cms O
Word Press Als Blog Und Cms OWord Press Als Blog Und Cms O
Word Press Als Blog Und Cms O
 
Automatisierung mit grunt
Automatisierung mit gruntAutomatisierung mit grunt
Automatisierung mit grunt
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
 
Forms and Reports 12c - Processes and Automation in Development and Operations
Forms and Reports 12c - Processes and Automation in Development and OperationsForms and Reports 12c - Processes and Automation in Development and Operations
Forms and Reports 12c - Processes and Automation in Development and Operations
 
AdminCamp 14: Make your IBM Connections deployment your own - Customize it!
AdminCamp 14: Make your IBM Connections deployment your own - Customize it!AdminCamp 14: Make your IBM Connections deployment your own - Customize it!
AdminCamp 14: Make your IBM Connections deployment your own - Customize it!
 
SEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-Freaks
SEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-FreaksSEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-Freaks
SEO Day 2016: Perfekte Ladezeiten und SEO-Hosting für Speed-Freaks
 
Ausrollen von Multi-Tier-Applikationen mit Docker
Ausrollen von Multi-Tier-Applikationen mit DockerAusrollen von Multi-Tier-Applikationen mit Docker
Ausrollen von Multi-Tier-Applikationen mit Docker
 
Drupal 7 Einblick und Ausblick
Drupal 7 Einblick und AusblickDrupal 7 Einblick und Ausblick
Drupal 7 Einblick und Ausblick
 
SNoUG 2015 - Vaadin - XPages 2.0?
SNoUG 2015 - Vaadin - XPages 2.0?SNoUG 2015 - Vaadin - XPages 2.0?
SNoUG 2015 - Vaadin - XPages 2.0?
 
Wordpress Template Workshop
Wordpress Template WorkshopWordpress Template Workshop
Wordpress Template Workshop
 
Docker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-PatternsDocker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-Patterns
 
Docker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-PatternsDocker und Kubernetes Patterns & Anti-Patterns
Docker und Kubernetes Patterns & Anti-Patterns
 
PowerShell Sicherheit in 6 Schritten produktiv absichern
PowerShell Sicherheit in 6 Schritten produktiv absichernPowerShell Sicherheit in 6 Schritten produktiv absichern
PowerShell Sicherheit in 6 Schritten produktiv absichern
 
Web-Automatisierung mit WWW::Mechanize
Web-Automatisierung mit WWW::MechanizeWeb-Automatisierung mit WWW::Mechanize
Web-Automatisierung mit WWW::Mechanize
 
WordPress sicherer machen - Basics
WordPress sicherer machen - BasicsWordPress sicherer machen - Basics
WordPress sicherer machen - Basics
 
Automatischer Build mit Maven - OPITZ CONSULTING - Stefan Scheidt
Automatischer Build mit Maven - OPITZ CONSULTING - Stefan ScheidtAutomatischer Build mit Maven - OPITZ CONSULTING - Stefan Scheidt
Automatischer Build mit Maven - OPITZ CONSULTING - Stefan Scheidt
 
Versionskontrolle in Machine-Learning-Projekten
Versionskontrolle in Machine-Learning-ProjektenVersionskontrolle in Machine-Learning-Projekten
Versionskontrolle in Machine-Learning-Projekten
 

Más de frankstaude

State of TV – Vortragsaufzeichnung, aktueller Stand und Ausblick
State of TV – Vortragsaufzeichnung, aktueller Stand und AusblickState of TV – Vortragsaufzeichnung, aktueller Stand und Ausblick
State of TV – Vortragsaufzeichnung, aktueller Stand und Ausblickfrankstaude
 
Automatisierung in Zeiten von Social Media, Messenger-Diensten und Bots
Automatisierung in Zeiten von Social Media, Messenger-Diensten und BotsAutomatisierung in Zeiten von Social Media, Messenger-Diensten und Bots
Automatisierung in Zeiten von Social Media, Messenger-Diensten und Botsfrankstaude
 
CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?
CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?
CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?frankstaude
 
TablePress - Warum und welche Erweiterungen gibt es?
TablePress - Warum und welche Erweiterungen gibt es?TablePress - Warum und welche Erweiterungen gibt es?
TablePress - Warum und welche Erweiterungen gibt es?frankstaude
 
Gamifizierung mit WordPress – Eine Einführung und Einsatz in der Schule
Gamifizierung mit WordPress – Eine Einführung und Einsatz in der SchuleGamifizierung mit WordPress – Eine Einführung und Einsatz in der Schule
Gamifizierung mit WordPress – Eine Einführung und Einsatz in der Schulefrankstaude
 
Erneute Bestellung in WooCommerce
Erneute Bestellung in WooCommerceErneute Bestellung in WooCommerce
Erneute Bestellung in WooCommercefrankstaude
 
Gamification mit WordPress
Gamification mit WordPressGamification mit WordPress
Gamification mit WordPressfrankstaude
 
Mobile Apps mit WordPress
Mobile Apps mit WordPressMobile Apps mit WordPress
Mobile Apps mit WordPressfrankstaude
 
Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?frankstaude
 
State of TV - Stand der Vortragsaufzeichnung 11/2017
State of TV - Stand der Vortragsaufzeichnung 11/2017State of TV - Stand der Vortragsaufzeichnung 11/2017
State of TV - Stand der Vortragsaufzeichnung 11/2017frankstaude
 
Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?frankstaude
 
Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?frankstaude
 
Themes – Wieso, Weshalb, Warum!?
Themes – Wieso, Weshalb, Warum!?Themes – Wieso, Weshalb, Warum!?
Themes – Wieso, Weshalb, Warum!?frankstaude
 
Eine WordPress Meetup Webseite auf Autopilot
Eine WordPress Meetup Webseite auf AutopilotEine WordPress Meetup Webseite auf Autopilot
Eine WordPress Meetup Webseite auf Autopilotfrankstaude
 
Vorträge aufzeichnen ohne Nachbearbeitung
Vorträge aufzeichnen ohne NachbearbeitungVorträge aufzeichnen ohne Nachbearbeitung
Vorträge aufzeichnen ohne Nachbearbeitungfrankstaude
 
Nürnberg WordPress Meetup - Custom Post Types mit PODS.io
Nürnberg WordPress Meetup - Custom Post Types mit PODS.ioNürnberg WordPress Meetup - Custom Post Types mit PODS.io
Nürnberg WordPress Meetup - Custom Post Types mit PODS.iofrankstaude
 
WordPress - eigene Plugins erstellen
WordPress - eigene Plugins erstellenWordPress - eigene Plugins erstellen
WordPress - eigene Plugins erstellenfrankstaude
 
Custom Post Types mit PODS.io
Custom Post Types mit PODS.ioCustom Post Types mit PODS.io
Custom Post Types mit PODS.iofrankstaude
 
Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?frankstaude
 

Más de frankstaude (20)

State of TV – Vortragsaufzeichnung, aktueller Stand und Ausblick
State of TV – Vortragsaufzeichnung, aktueller Stand und AusblickState of TV – Vortragsaufzeichnung, aktueller Stand und Ausblick
State of TV – Vortragsaufzeichnung, aktueller Stand und Ausblick
 
Automatisierung in Zeiten von Social Media, Messenger-Diensten und Bots
Automatisierung in Zeiten von Social Media, Messenger-Diensten und BotsAutomatisierung in Zeiten von Social Media, Messenger-Diensten und Bots
Automatisierung in Zeiten von Social Media, Messenger-Diensten und Bots
 
CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?
CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?
CPT UI und ACF - Wie werden Inhalte sinnvoll strukturiert?
 
TablePress - Warum und welche Erweiterungen gibt es?
TablePress - Warum und welche Erweiterungen gibt es?TablePress - Warum und welche Erweiterungen gibt es?
TablePress - Warum und welche Erweiterungen gibt es?
 
Gamifizierung mit WordPress – Eine Einführung und Einsatz in der Schule
Gamifizierung mit WordPress – Eine Einführung und Einsatz in der SchuleGamifizierung mit WordPress – Eine Einführung und Einsatz in der Schule
Gamifizierung mit WordPress – Eine Einführung und Einsatz in der Schule
 
Erneute Bestellung in WooCommerce
Erneute Bestellung in WooCommerceErneute Bestellung in WooCommerce
Erneute Bestellung in WooCommerce
 
Gamification mit WordPress
Gamification mit WordPressGamification mit WordPress
Gamification mit WordPress
 
Mobile Apps mit WordPress
Mobile Apps mit WordPressMobile Apps mit WordPress
Mobile Apps mit WordPress
 
Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?
 
State of TV - Stand der Vortragsaufzeichnung 11/2017
State of TV - Stand der Vortragsaufzeichnung 11/2017State of TV - Stand der Vortragsaufzeichnung 11/2017
State of TV - Stand der Vortragsaufzeichnung 11/2017
 
Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?Suchst du noch - Oder findest du schon?
Suchst du noch - Oder findest du schon?
 
Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?
 
Themes – Wieso, Weshalb, Warum!?
Themes – Wieso, Weshalb, Warum!?Themes – Wieso, Weshalb, Warum!?
Themes – Wieso, Weshalb, Warum!?
 
Eine WordPress Meetup Webseite auf Autopilot
Eine WordPress Meetup Webseite auf AutopilotEine WordPress Meetup Webseite auf Autopilot
Eine WordPress Meetup Webseite auf Autopilot
 
Vorträge aufzeichnen ohne Nachbearbeitung
Vorträge aufzeichnen ohne NachbearbeitungVorträge aufzeichnen ohne Nachbearbeitung
Vorträge aufzeichnen ohne Nachbearbeitung
 
Nürnberg WordPress Meetup - Custom Post Types mit PODS.io
Nürnberg WordPress Meetup - Custom Post Types mit PODS.ioNürnberg WordPress Meetup - Custom Post Types mit PODS.io
Nürnberg WordPress Meetup - Custom Post Types mit PODS.io
 
WordPress - eigene Plugins erstellen
WordPress - eigene Plugins erstellenWordPress - eigene Plugins erstellen
WordPress - eigene Plugins erstellen
 
Custom Post Types mit PODS.io
Custom Post Types mit PODS.ioCustom Post Types mit PODS.io
Custom Post Types mit PODS.io
 
Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?Suchst du noch? Oder findest du schon?
Suchst du noch? Oder findest du schon?
 
Pressmatic
PressmaticPressmatic
Pressmatic
 

WP-CLI - Das Kommandozeilen Interface für Wordpress

  • 1. WP-CLI - Ein Kommandozeilen Interface für WordPress 23.10.2013 Frank Staude <frank@staude.net>
  • 2. WP-CLI ? WP-CLI ( WordPress - Command Line Interface) ist ein Programm, mit dem man Wordpress per Kommandozeile bedienen kann. ! Warum braucht man das? - Admins sind gewohnt mit der Tastatur zu arbeiten - Mit der Tastatur ist man in der Regel schneller als in einem Webinterface - Mit Kommandos kann man Aufgaben automatisieren
  • 3. Voraussetzungen Um WP-CLI zu installieren braucht es ein paar Dinge ! - Unix shell. ( OS X, Linux, Windows mit Cygwin) - PHP 5.3 oder neuer - php-cli im PHP aktiviert (php -v / phpinfo zum prüfen) - Git - Wordpress 3.4 oder neuer !
  • 4. Installation Ein Installationsscript kann direkt von GitHub geladen und ausgeführt werden. ! curl https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | bash ! Das installiert WP-CLI im Verzeichnis .wp-cli im Benutzerverzeichnis. Damit es von überall gefunden wird, sollte man danach noch das bin Verzeichnis von wp-cli mit im Pfad seiner Shell aufnehmen. Eine Entsprechende Meldung gibt der Installer aus. ! MySQL muss im Pfad liegen, sonst scheitert wp core config ! Alternative Installationsmethoden: https://github.com/wp-cli/wp-cli/wiki/AlternativeInstall-Methods
  • 5. Erster Start Nun kann WP-CLI durch die Eingabe von wp aufgerufen werden. !
  • 6. Mehr Komfort WP-CLI bietet auch s.g. Tab completion, also die Funktionalität bei drücken der Tabulator Taste das Kommando zu vervollständigen oder (wenn nicht eindeutig) die Liste der Kommandos auszugeben. ! Dazu muss man seine .profile Datei ergänzen um ! source $HOME/.wp-cli/vendor/wp-cli/wp-cli/utils/wp-completion.bash ! !
  • 7. wp
  • 13. wp db
  • 35. Beispiele: WP Version Entweder man wechselt in das Verzeichnis der jeweiligen Wordpress Installation ! staude$ cd Wordpress Dev/! staude$ wp core version! 3.6.1! ! oder man übergibt den Pfad mittels --path=‘pfad/zur/WP/Installation‘ ! staude$ wp core version --path='/Users/staude/ Projekte/Wordpress Dev'! 3.6.1!
  • 36. Beispiele: Plugins auflisten staude$ wp plugin list! +-----------------------------------+----------+--------+---------+! | name | status | update | version |! +-----------------------------------+----------+--------+---------+! | akismet | inactive | none | 2.5.9 |! | backend-startpage-customizer | inactive | none | 0.2 |! | blog-description-randomizer | inactive | none | 0.1 |! | codestyling-localization | active | none | 1.99.30 |! | disable-author-pages | active | none | 0.2 |! | disable-title | active | none | 0.5 |! | downloads-per-page | active | none | 0.1 |! | google-analytics-dashboard-for-wp | active | none | 4.2.1 |! | mime-types-extended | active | none | 0.7 |! | my-own-plugins | inactive | none | 0.1 |! | post-author-filter | active | none | 0.1 |! | random-blog-description | inactive | none | 1.0 |! | scheduled-posts-dashboard-widget | active | none | 0.1 |! | scheduled-jobs-dashboard-widget | inactive | none | 0.2.2 |! | scheduled-unsticky | inactive | none | 0.2.2 |! | widget-or-sidebar-per-shortcode | inactive | none | 0.4 |! +-----------------------------------+----------+--------+---------+!
  • 37. Beispiele: Plugins suchen staude$ wp plugin search hello-dolly! Success: Showing 10 of 20 plugins.! +-------------------------------+-------------------------------+--------+! | name | slug | rating |! +-------------------------------+-------------------------------+--------+! | Hello Dolly | hello-dolly | 67.4 |! | Hello Dolly For Your Song | hello-dolly-for-your-song | 0 |! | Hello Simpsons Chalkboard Gag | hello-simpsons-chalkboard-gag | 100 |! | Hello Kurt | hello-kurt | 0 |! | Fancy Dolly | fancy-plugin | 91.4 |! | Hello Darth | hello-darth | 100 |! | Hello Hollywood | hello-hollywood | 100 |! | Hello Ziggy | hello-ziggy | 0 |! | Hello HAL | hello-hal | 100 |! | Unwanted Plugins Remover | unwanted-plugins-remover | 100 |! +-------------------------------+-------------------------------+--------+!
  • 38. Beispiele: Plugin installieren staude$ wp plugin install hello-dolly! Installing Hello Dolly (1.6)! Runterladen des Installationspakets von http://downloads.wordpress.org/plugin/hellodolly.1.6.zip...! Entpacken des Pakets...! Das Plugin wird installiert...! Das Plugin wurde erfolgreich installiert.!
  • 39. Beispiele: Plugin aktivieren staude$ wp plugin activate hello-dolly! Success: Plugin 'hello-dolly' activated.! ! ! staude$ wp plugin deactivate hello-dolly! Success: Plugin 'hello-dolly' deactivated.!
  • 40. Beispiele: WP installieren In ein neues, leeres Verzeichnis gehen (oder --path überall angeben)! ! staude$ wp core download! Downloading latest WordPress (en_US)...! Success: WordPress downloaded.! ! staude$ wp core config --dbname=Datenbank --dbuser=Benutzer --dbpass=Kennwort! Success: Generated wp-config.php file.! ! staude$ wp core install --url=test.de --title=title --admin_user=adminBenutzer --admin_password=adminKennwort --admin_email=admin@domain.tld! Success: WordPress installed successfully.!
  • 41. Plugin + WP-CLI Plugins können ebenfalls das WP-CLI Interface implementieren und können dann ebenfalls perKomandozeile bedient werden. Zum Beispiel das Plugin Developer ( http://wordpress.org/plugins/developer ). ! staude$ wp plugin install developer! Installing Developer (1.2.5)! Runterladen des Installationspakets von http://downloads.wordpress.org/plugin/ developer.1.2.5.zip...! Entpacken des Pakets...! Das Plugin wird installiert...! Das Plugin wurde erfolgreich installiert.! ! staude$ wp plugin activate developer! Success: Plugin 'developer' activated.! ! ! staude$ wp developer! usage: wp developer install-plugins --type=<type> [--activate]! ! See 'wp help developer <subcommand>' for more information on a specific subcommand.!
  • 42. Eigenes Plugin + WP-CLI Am Beispiel meines Plugins scheduled-unsticky ( http://wordpress.org/plugins/scheduled-unsticky/ ) demonstriere ich die Arbeiten um ein Plugin per WP-CLI steuerbar zu machen. ! Abfragen des WP-CLI defines im Constructor und ggf laden einer Klasse die das CLI Interface implementiert. ! if ( defined ( 'WP_CLI' ) && WP_CLI ) {! require_once( __DIR__ . '/class-wp-cli-commands.php' );! }
  • 43. Eigenes Plugin + WP-CLI Und die Implementierung! ! <?php! class Scheduled_Unsticky_WP_CLI_Command extends WP_CLI_Command {! /**! * @subcommand info! */ ! function info( $args, $assoc_args ) {! $cron = get_option('scheduled_unsticky_cron');! $days = get_option( 'scheduled_unsticky_days' );! if ($cron != 0) {! $schedules = wp_get_schedules();! $cron = $schedules[$cron];! }! WP_CLI::line('interval: '. $cron );! WP_CLI::line('days : '. $days);! }! /**! * @subcommand days ! * @synopsis <days>! */! function days( $args ) {! $days = $args[0];! update_option( 'scheduled_unsticky_days', $days );! WP_CLI::success('days: '. $days);! }! }! ! WP_CLI::add_command( 'scheduled-unsticky', 'Scheduled_Unsticky_WP_CLI_Command' );! !
  • 44. Eigenes Plugin + WP-CLI staude$ wp scheduled-unsticky! usage: wp scheduled-unsticky days <days>! or: wp scheduled-unsticky info! ! See 'wp help scheduled-unsticky <subcommand>' for more information on a specific subcommand.! ! ! staude$ wp scheduled-unsticky info! interval: twicedaily! days : 2! ! ! staude$ wp scheduled-unsticky days 3! Success: days: 3! ! ! staude$ wp scheduled-unsticky info! interval: twicedaily! days : 3! ! !
  • 45. Links WP-CLI ! http://wp-cli.org/! ! WP-CLI Wiki! https://github.com/wp-cli/wp-cli/wiki! ! WP-CLI Installation! http://wp-cli.org/! ! Alternative Installationsmöglichkeiten! https://github.com/wp-cli/wp-cli/wiki/Alternative-Install-Methods! ! Command Cookbook - für Implementierung eigener Erweiterungen! https://github.com/wp-cli/wp-cli/wiki/Commands-Cookbook! ! Scheduled Unsticky Plugin! http://wordpress.org/plugins/scheduled-unsticky/!