# wp plugin

Aide:

```bash
$ wp help plugin
```

```bash
NAME

  wp plugin

DESCRIPTION

  Manages plugins, including installs, activations, and updates.

SYNOPSIS

  wp plugin <command>

SUBCOMMANDS

  activate              Activates one or more plugins.
  deactivate            Deactivates one or more plugins.
  delete                Deletes plugin files without deactivating or uninstalling.
  get                   Gets details about an installed plugin.
  install               Installs one or more plugins.
  is-active             Checks if a given plugin is active.
  is-installed          Checks if a given plugin is installed.
  list                  Gets a list of plugins.
  path                  Gets the path to a plugin or to the plugin directory.
  search                Searches the WordPress.org plugin directory.
  status                Reveals the status of one or all plugins.
  toggle                Toggles a plugin's activation state.
  uninstall             Uninstalls one or more plugins.
  update                Updates one or more plugins.
  verify-checksums      Verifies plugin files against WordPress.org's checksums.
```

Liste des plug-ins:

```bash
$ wp plugin list --path=/Users/bruno/Sites/wordpress
+--------------------------------+----------+-----------+------------+
| name                           | status   | update    | version    |
+--------------------------------+----------+-----------+------------+
| admin-post-navigation          | active   | none      | 2.1        |
| akismet                        | inactive | none      | 4.0.8      |
| audio-story-images             | inactive | none      | 0.0.3      |
| boxers-and-swipers             | inactive | none      | 3.11       |
| captcha                        | active   | none      | 4.4.5      |
| contact-form-plugin            | active   | none      | 4.1.0      |
| easy-swipebox                  | inactive | none      | 1.1.0      |
| exif-caption                   | inactive | none      | 2.11       |
| thesography                    | inactive | none      | 1.3        |
| google-sitemap-generator       | inactive | none      | 4.0.9      |
| gutenberg                      | active   | available | 3.4.0      |
| hello                          | inactive | none      | 1.6        |
| jetpack                        | inactive | available | 6.3.3      |
| jquery-updater                 | inactive | none      | 3.3.1      |
| knowledge-base-cpt             | inactive | none      | 1.1.0      |
| link-manager                   | active   | none      | 0.1-beta   |
| meow-lightbox                  | active   | available | 1.1.2      |
| sola-newsletters               | active   | none      | 4.0.19     |
| regenerate-thumbnails          | active   | none      | 3.0.2      |
| responsive-lightbox            | inactive | none      | 2.0.5      |
| simple-tags                    | active   | none      | 2.4.7      |
| subscribe-to-comments-reloaded | inactive | none      | 180225     |
| theme-check                    | inactive | none      | 20160523.1 |
| wp-db-backup                   | inactive | none      | 2.3.3      |
| wp-jquery-lightbox             | inactive | none      | 1.4.8      |
| wp-print                       | inactive | none      | 2.58       |
| wp-image-protect               | inactive | none      | 2.7.1      |
| wp-log-viewer                  | inactive | none      | 1.2.1      |
| wp-mapeditor                   | inactive | none      | 0.2.2      |
| rest-api-oauth1                | inactive | none      | 0.3.0      |
| wp-retina-2x-pro               | active   | available | 5.4.0      |
| wp-super-cache                 | active   | available | 1.6.2      |
| wptouch-pro                    | inactive | none      | 4.0.17     |
| wp-xhprof-master               | inactive | none      | 0.1        |
| yada-wiki                      | inactive | none      | 3.0        |
| wordpress-seo                  | active   | available | 7.9        |
| zenlatest                      | inactive | none      | 1.3        |
| zenphotopress                  | inactive | none      | 1.8        |
| advanced-cache.php             | dropin   | none      |            |
+--------------------------------+----------+-----------+------------+
```

Choisir les champs:

```bash
$ wp plugin list --fields=name,version
+--------------------------------+------------+
| name                           | version    |
+--------------------------------+------------+
| admin-post-navigation          | 2.1        |
| akismet                        | 4.0.8      |
| audio-story-images             | 0.0.3      |
```

Liste des plug-ins activés:

```bash
$ wp plugin list --status=active
+-----------------------+--------+-----------+----------+
| name                  | status | update    | version  |
+-----------------------+--------+-----------+----------+
| admin-post-navigation | active | none      | 2.1      |
| captcha               | active | none      | 4.4.5    |
| contact-form-plugin   | active | none      | 4.1.0    |
| gutenberg             | active | available | 3.4.0    |
| link-manager          | active | none      | 0.1-beta |
| meow-lightbox         | active | available | 1.1.2    |
| sola-newsletters      | active | none      | 4.0.19   |
| regenerate-thumbnails | active | none      | 3.0.2    |
| simple-tags           | active | none      | 2.4.7    |
| wp-retina-2x-pro      | active | available | 5.4.0    |
| wp-super-cache        | active | available | 1.6.2    |
| wordpress-seo         | active | available | 7.9      |
+-----------------------+--------+-----------+----------+
```

Liste des plug-ins mis-à-jour:

```bash
$ wp plugin list --update=available
+------------------+--------+-----------+---------+
| name             | status | update    | version |
+------------------+--------+-----------+---------+
| gutenberg        | active | available | 3.4.0   |
| meow-lightbox    | active | available | 1.1.2   |
| wp-retina-2x-pro | active | available | 5.4.0   |
| wp-super-cache   | active | available | 1.6.2   |
| wordpress-seo    | active | available | 7.9     |
+------------------+--------+-----------+---------+
```

```bash
$ wp plugin list --fields=name,version --update=available
+------------------+---------+
| name             | version |
+------------------+---------+
| gutenberg        | 3.4.0   |
| meow-lightbox    | 1.1.2   |
| wp-retina-2x-pro | 5.4.0   |
| wp-super-cache   | 1.6.2   |
| wordpress-seo    | 7.9     |
+------------------+---------+
```

Résultat de la commande au format JSON:

```bash
$ wp plugin list --update=available --format=json
[{"name":"gutenberg","status":"active","update":"available","version":"3.4.0"},{"name":"meow-lightbox","status":"active","update":"available","version":"1.1.2"},{"name":"wp-retina-2x-pro","status":"active","update":"available","version":"5.4.0"},{"name":"wp-super-cache","status":"active","update":"available","version":"1.6.2"},{"name":"wordpress-seo","status":"active","update":"available","version":"7.9"}]
```

Résultat de la commande au format CSV:

```bash
$ wp plugin list --update=available --format=csv
name,status,update,version
gutenberg,active,available,3.4.0
meow-lightbox,active,available,1.1.2
wp-retina-2x-pro,active,available,5.4.0
wp-super-cache,active,available,1.6.2
wordpress-seo,active,available,7.9
```

Autres formats:
	- table
	– csv
	– count
	– json
	– yaml

Champs affichés par défaut:
	- name
	- status
	- update
	- version

Champs optionnels:
	- update_version
	- update_package (url)
	- update_id
	- title
	- description

Vérifier si des MAJ de plugins sont disponibles ?

```bash
$ wp plugin update --all --dry-run
Available plugin updates:
+------------------+--------+---------+----------------+
| name             | status | version | update_version |
+------------------+--------+---------+----------------+
| gutenberg        | active | 3.4.0   | 3.5.0          |
| meow-lightbox    | active | 1.1.2   | 1.2.1          |
| wp-retina-2x-pro | active | 5.4.0   | 5.4.1          |
| wp-super-cache   | active | 1.6.2   | 1.6.3          |
| wordpress-seo    | active | 7.9     | 7.9.1          |
+------------------+--------+---------+----------------+
```

```bash
$ wp plugin list --fields=name,version,update_version,description --update=available
+------------------+---------+----------------+-------------------------------------------------------------------------------------+
| name             | version | update_version | description                                                                         |
+------------------+---------+----------------+-------------------------------------------------------------------------------------+
| gutenberg        | 3.4.0   | 3.5.0          | Printing since 1440. This is the development plugin for the new block editor in cor |
|                  |         |                | e.                                                                                  |
| meow-lightbox    | 1.1.2   | 1.2.1          | Lightbox designed by and for photographers.                                         |
| wp-retina-2x-pro | 5.4.0   | 5.4.1          | Make your website look beautiful and crisp on modern displays by creating + display |
|                  |         |                | ing retina images.                                                                  |
| wp-super-cache   | 1.6.2   | 1.6.3          | Very fast caching plugin for WordPress.                                             |
| wordpress-seo    | 7.9     | 7.9.1          | The first true all-in-one SEO solution for WordPress, including on-page content ana |
|                  |         |                | lysis, XML sitemaps and much more.                                                  |
+------------------+---------+----------------+-------------------------------------------------------------------------------------+
```

Etat des plug-ins sur le site:

```bash
$ wp plugin status
21 installed plugins:
  A admin-post-navigation          2.1
  I akismet                        4.0.8
  I google-sitemap-generator       4.0.9
 UA gutenberg                      3.4.0
  I hello                          1.6
  I jetpack                        6.4.2
  I jquery-updater                 3.3.1
  A link-manager                   0.1-beta
 UA meow-lightbox                  1.1.2
  A sola-newsletters               4.0.19
  A regenerate-thumbnails          3.0.2
  I responsive-lightbox            2.0.5
  A simple-tags                    2.4.7
  I rest-api-oauth1                0.3.0
 UA wp-retina-2x-pro               5.4.0
 UA wp-super-cache                 1.6.2
  I wptouch-pro                    4.0.17
 UA wordpress-seo                  7.9
  I zenlatest                      1.3
  I zenphotopress                  1.8
  D advanced-cache.php

Legend: A = Active, I = Inactive, D = Drop-In, U = Update Available
```

Installer un plug-in:

```bash
$ wp plugin install <Plugin_Name>
```

Activer un plug-in:

```
$ wp plugin activate <Plugin_Name>
```

Installer et activer un plug-in:

```bash
$ wp plugin install <Plugin_Name> --activate
```

Installer plusieurs plug-in:

```bash
$ wp plugin install <Plugin_Name_1> <Plugin_Name_2> <Plugin_Name_3>
```

Installer un plug-in depuis un serveur:

```bash
$ wp plugin install https://d1qas1txbec8n.cloudfront.net/wp-content/uploads/2015/06/23073607/myplugin.zip
```

Installer une ancienne version:

```bash
$ wp plugin install wordpress-seo --version=4.8
```

Mettre-à-jour un plug-in:

```bash
$ wp plugin update jetpack
Téléchargement de la mise à jour depuis https://downloads.wordpress.org/plugin/jetpack.6.4.2.zip…
Décompression de la mise à jour...
Installation de la dernière version...
Retrait de l’ancienne version de l’extension...
L’extension a bien été mise à jour.
Success: Updated 1 of 1 plugins.
+---------+-------------+-------------+---------+
| name    | old_version | new_version | status  |
+---------+-------------+-------------+---------+
| jetpack | 6.3.3       | 6.4.2       | Updated |
+---------+-------------+-------------+---------+
```

Mettre-à-jour tous les plugins:

```bash
$ wp plugin update --all
$ wp plugin update --all --exclude=akismet

# mode quiet
$ wp plugin update --all --quiet > /dev/null 2>&1
```

Désactiver un plugin:

```bash
$ wp plugin deactivate <Plugin_Name>
```

Désactiver tous les plugins:

```bash
$ wp plugin deactivate --all
```

Désactiver puis dé-installer un plugin:

```bash
$ wp plugin deactivate <Plugin_Name> --uninstall
```

Dé-installer un plugin:
Par défaut, seuls les plugins désactivés peuvent être dé-installer.

```bash
$ wp plugin uninstall <Plugin_Name>
```

Désactive puis désinstalle un plugin:

```bash
$ wp plugin uninstall <Plugin_Name> --deactivate
```

Supprimer un plugin:

```bash
$ wp plugin delete <Plugin_Name>
```

Supprimer les plugins inactifs:

```bash
$ wp plugin delete $(wp plugin list --status=inactive --field=name)
```



