WP-CLI (commando's)

Uit De Vliegende Brigade
Ga naar: navigatie, zoeken

Zie ook WP-CLI (algemeen).

wp cli update

Je kunt WP-CLI updaten middels

wp cli update

of door 'm opnieuw te installeren.

wp comment <subcommando>

https://developer.wordpress.org/cli/commands/comment/:

wp comment approve 	Approve a comment.
wp comment count 	Count comments, on whole blog or on a given post.
wp comment create 	Create a new comment.
wp comment delete 	Delete a comment.
wp comment exists 	Verify whether a comment exists.
wp comment generate 	Generate some number of new dummy comments.
wp comment get 	        Get data of a single comment.
wp comment list 	Get a list of comments.
wp comment meta 	Manage comment custom fields.
wp comment recount 	Recalculate the comment_count value for one or more posts.
wp comment spam 	Mark a comment as spam.
wp comment status 	Get status of a comment.
wp comment trash 	Trash a comment.
wp comment unapprove 	Unapprove a comment.
wp comment unspam 	Unmark a comment as spam.
wp comment untrash 	Untrash a comment.
wp comment update 	Update one or more comments.

wp comment delete

Bv.:

> wp comment list
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| comment_ID | comment_post_ID | comment_date       | comment_approved | comment_author     | comment_author_email  |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| 1          | 1               | 2017-10-13 13:02:3 | 1                | A WordPress Commen | wapuu@wordpress.examp |
|            |                 | 7                  |                  | ter                | le                    |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+

> wp comment delete 1
Success: Trashed comment 1.

wp comment list

Bv.:

> wp comment list
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| comment_ID | comment_post_ID | comment_date       | comment_approved | comment_author     | comment_author_email  |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| 1          | 1               | 2017-10-13 13:02:3 | 1                | A WordPress Commen | wapuu@wordpress.examp |
|            |                 | 7                  |                  | ter                | le                    |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+

wp config <subcommando>

* wp config create
* wp config get
* wp config path

wp core <subcommando>

Download, install, update and manage a WordPress install. Subcommando's:

* wp core check-update 	      Check for WordPress updates via Version Check API.
* wp core config              Creëer een config-bestand, voorafgaand aan installatie van een site
* wp core download 	      Download core WordPress files.
* wp core install 	      Runs the standard WordPress installation process.
* wp core is-installed 	      Check if WordPress is installed.
* wp core multisite-convert   Transform a single-site install into a WordPress multisite install.
* wp core multisite-install   Install WordPress multisite from scratch.
* wp core update 	      Update WordPress to a newer version.
* wp core update-db           Run the WordPress database update procedure.
* wp core version 	      Display the WordPress version.

wp core config

Creëer een nieuw wp-config.php-bestand. Dit commando wordt niet genoemd op de site. Daar heb je het vergelijkbare commando wp config create.

wp config create

   --dbname=<dbname>            Set the database name.
   --dbuser=<dbuser>            Set the database user.
   [--dbpass=<dbpass>]          Set the database user password.
   [--dbhost=<dbhost>]          Set the database host.
                                default: localhost
   [--dbprefix=<dbprefix>]      Set the database table prefix.
                                default: wp_
   [--dbcharset=<dbcharset>]    Set the database charset.
                                default: utf8
   [--dbcollate=<dbcollate>]    Set the database collation.
                                default:
   [--locale=<locale>]          Set the WPLANG constant. 
                                Defaults to $wp_local_package variable.
   [--extra-php]                If set, the command copies additional PHP code 
                                into wp-config.php from STDIN.
   [--skip-salts]               If set, keys and salts won’t be generated, 
                                but should instead be passed via --extra-php.
   [--skip-check]               If set, the database connection is not checked.
   [--force]                    Overwrites existing files, if present. 

wp core download

Voorbeeld van gedownloade WordPress-instanties als zip-bestanden

download een actuele WordPress-instantie en plaats die uitgepakt en MD5-geverifiëerd in de werkmap, of in de map die wordt meegegeven.

wp core download

   [--path=<path>]         Specify the path in which to install WordPress. Defaults to current directory.
   [--locale=<locale>]     Select which language you want to download.
   [--version=<version>]   Select which version you want to download. Accepts a version number, ‘latest’ or ‘nightly’
   [--force]               Overwrites existing files, if present. 

Wat-ie precies doet:

  • De WordPress-instantie wordt gedownload als gezipped phar-archief naar /tmp. Zie afbeelding hiernaast
  • md5-hash van dit archiefbestand wordt geverifiëerd
  • Het archiefbestand wordt uitgepakt naar een tijdelijke locatie

Foutmelding: Couldn't decompress

Het probleem:

wp core download
Downloading WordPress 4.8.2 (en_US)...
md5 hash verified: 2e8744a702a3d9527782d9135a4c9544
Error: Couldn't extract WordPress archive. unable to decompress gzipped phar archive "/tmp/wp_59c276fb45c4b.tar.gz" to temporary file

Aanvullende gegevens:

  • sudo chmod o+w /tmp - Hielp niet
  • sudo /usr/local/bin/wp core download --allow-root - Hielp niet
  • wp cli ge-update - Hielp niet

wp core install

Installeer een gedownloade WordPress-instantie:

wp core install 

   --url=<url> 
   --title=<site-title> 
   --admin_user=<username>
   [--admin_password=<password>]   # Defaults to randomly generated string
   [--admin_email=<email>]
   [--skip-email]                  # Don't send email notification
  • Dit commando moet uitgevoerd worden in de working map waar de installatiebestanden staan, en waar de site geïnstalleerd moet worden
  • Op mijn ontwikkelcomputer kreeg ik een foutmelding dat Sendmail niet gevonden kon worden. Ik weet niet of dat door het script komt, of een configuratiefout ergen op m'n computer.

wp core update

Simpel:

wp core update

Plugins worden hierbij niet bijgewerkt.

wp core update-db

Geen idee waarom er een apart commando is om de db bij te werken. Eén keer gedaan na update van een site die al een tijdje niet was bijgewerkt: Geen verschil.

wp plugin <subcommando>

* wp plugin activate 	   Activate a plugin.
* wp plugin deactivate 	   Deactivate a plugin.
* wp plugin delete 	   Delete plugin files without deactivating or uninstalling.
* wp plugin get 	   Get details about an installed plugin.
* wp plugin install 	   Install a plugin.
* wp plugin is-installed   Check if the plugin is installed.
* wp plugin list 	   Get a list of plugins.
* wp plugin path 	   Get the path to a plugin or to the plugin directory.
* wp plugin search 	   Search the WordPress.org plugin directory.
* wp plugin status 	   See the status of one or all plugins.
* wp plugin toggle 	   Toggle a plugin’s activation state.
* wp plugin uninstall 	   Uninstall a plugin.
* wp plugin update 	   Update one or more plugins.

wp plugin activate

Bv.

wp plugin activate hello

wp plugin deactivate

Bv.

wp plugin deactivate hello

wp plugin delete

Bv.

wp plugin delete hello

WP-CLI kan schrijven en bestanden verwijderen - Handig!

wp plugin install

Installeer een WP-plugin op een site:

wp plugin install

   <plugin-naam|zip|url>   # A plugin slug, the path to a local zip file, or URL to a remote zip file.

   [--version=<version>]   # If set, get that particular version from wordpress.org, 
                           # instead of the stable version

   [--force]               # If set, the command will overwrite any installed version of the plugin, 
                           # without prompting for confirmation.

   [--activate]            # If set, the plugin will be activated immediately after install.

   [--activate-network]    # If set, the plugin will be network activated immediately after install

Voorbeeld

wp plugin install duplicate-page --activate

wp plugin search

Zoek in de online plugin-bibliotheek:

wp plugin search

   <search>                  The string to search for.

   [--page=<page>]           Optional page to display.
                             default: 1

   [--per-page=<per-page>]   Optional number of results to display.
                             default: 10
   [--field=<field>]         Prints the value of a single field for each plugin.
   [--fields=<fields>]       Ask for specific fields from the API. Defaults to name,slug,author_profile,rating. Acceptable values:

    name: Plugin Name
    slug: Plugin Slug
    version: Current Version Number
    author: Plugin Author
    author_profile: Plugin Author Profile
    contributors: Plugin Contributors
    requires: Plugin Minimum Requirements
    tested: Plugin Tested Up To
    compatibility: Plugin Compatible With
    rating: Plugin Rating
    num_ratings: Number of Plugin Ratings
    homepage: Plugin Author’s Homepage
    description: Plugin’s Description
    short_description: Plugin’s Short Description 

[--format=<format>]          Render output in a particular format.

    default: table
    options:
    – table
    – csv
    – count
    – json
    – yaml

wp plugin status

Bv.:

wp plugin status

 installed plugins:
 UI akismet 3.3.3
  A hello   1.6

Legend: I = Inactive, A = Active, U = Update Available

wp plugin update

wp plugin update

   [<plugin>…]              One or more plugins to update.
   [--all]                  If set, all plugins that have updates will be updated.
   [--exclude=<name>]       Comma separated list of plugin names that should be excluded from updating.
   [--minor]                Only perform updates for minor releases (e.g. from 1.3 to 1.4 instead of 2.0)
   [--patch]                Only perform updates for patch releases (e.g. from 1.3 to 1.3.3 instead of 1.4)
   [--format=<format>]      Render output in a particular format.
    ---
    default: table
    options:
    – table
    – csv
    – json
    – summary
    ---
   [--version=<version>]   If set, the plugin will be updated to the specified version.
   [--dry-run]             Preview which plugins would be updated. 

Bv.:

wp plugin update --all

wp theme <subcommando>

Subcommando's:

wp theme activate 	Activate a theme.
wp theme delete 	Delete a theme.
wp theme disable 	Disable a theme on a WordPress multisite install.
wp theme enable 	Enable a theme on a WordPress multisite install.
wp theme get 		Get details about a theme.
wp theme install 	Install a theme.
wp theme is-installed 	Check if the theme is installed.
wp theme list 		Get a list of themes.
wp theme mod 		Manage theme mods.
wp theme path 		Get the path to a theme or to the theme directory.
wp theme search 	Search the WordPress.org theme directory.
wp theme status 	See the status of one or all themes.
wp theme update 	Update one or more themes.

wp theme delete

Bv.

$ wp theme status
4 installed themes:
  I divi            3.0.7
  I twentyfifteen   1.8
  A twentyseventeen 1.3
  I twentysixteen   1.3

Legend: I = Inactive, A = Active

$ wp theme delete divi
Deleted 'divi' theme.
Success: Deleted 1 of 1 themes.

$ wp theme status
3 installed themes:
  I twentyfifteen   1.8
  A twentyseventeen 1.3
  I twentysixteen   1.3

Legend: I = Inactive, A = Active 

wp theme status

Bv.

wp theme status

4 installed themes:
  I divi            3.0.7
  I twentyfifteen   1.8
  A twentyseventeen 1.3
  I twentysixteen   1.3

Legend: I = Inactive, A = Active

Bronnen