wp plugin

Управляет подключаемыми плагинами: установка, активация, обновление.

See the WordPress Plugin Handbook developer resource for more information on plugins.

Список команд Описание
wp plugin status Показывает статус одного или всех плагинов.
wp plugin search Поиск плагина по каталогу WordPress.org.
wp plugin activate Активирует один или несколько плагинов.
wp plugin deactivate Деактивирует один или несколько плагинов.
wp plugin toggle Переключает активацию плагина.
wp plugin path Получает путь плагина или путь каталога плагинов.
wp plugin update Обновляет один или несколько плагинов.
wp plugin install Устанавливает один или несколько плагинов.
wp plugin get Получает сведения об установленном плагине.
wp plugin uninstall Удаляет один или несколько плагинов.
wp plugin is-installed Проверяет, установлен ли данный плагин.
wp plugin is-active Проверяет, активен ли данный плагин.
wp plugin delete Удаляет файлы плагинов без деактивации или удаления.
wp plugin list Возвращает список плагинов.
wp plugin verify-checksums Сверяет контрольную сумму файлов плагина с каталогом WordPress.org.

Примеры

# Activate plugin
$ wp plugin activate hello
Plugin 'hello' activated.
Success: Activated 1 of 1 plugins.

# Deactivate plugin
$ wp plugin deactivate hello
Plugin 'hello' deactivated.
Success: Deactivated 1 of 1 plugins.

# Delete plugin
$ wp plugin delete hello
Deleted 'hello' plugin.
Success: Deleted 1 of 1 plugins.

# Install the latest version from wordpress.org and activate
$ wp plugin install bbpress --activate
Installing bbPress (2.5.9)
Downloading install package from https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip...
Using cached file '/home/vagrant/.wp-cli/cache/plugin/bbpress-2.5.9.zip'...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'bbpress'...
Plugin 'bbpress' activated.
Success: Installed 1 of 1 plugins.

Исходный код команд


wp plugin status

Показывает статус одного или всех плагинов.

Использование

wp plugin status {#status} [{plugin}]

Можно указать Глобальные параметры и следующие:

[{plugin}]
A particular plugin to show the status for.

Примеры

# Displays status of all plugins
$ wp plugin status
5 installed plugins:
  I akismet                3.1.11
  I easy-digital-downloads 2.5.16
  A theme-check            20160523.1
  I wen-logo-slider        2.0.3
  M ns-pack                1.0.0
Legend: I = Inactive, A = Active, M = Must Use
# Displays status of a plugin
$ wp plugin status theme-check
Plugin theme-check details:
	Name: Theme Check
	Status: Active
	Version: 20160523.1
	Author: Otto42, pross
	Description: A simple and easy way to test your theme for all the latest WordPress standards and practices. A great theme development tool!

Поиск плагина по каталогу WordPress.org.

Displays plugins in the WordPress.org plugin directory matching a given search query.

Использование

wp plugin search {#search} {search} [--page={page}] [--per-page={per-page}] [--field={field}] [--fields={fields}] [--format={format}]

Можно указать Глобальные параметры и следующие:

{search}
The string to search for.
[--page={page}]
Optional page to display.
По умолчанию: 1
[--per-page={per-page}]
Optional number of results to display.
По умолчанию: 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 in Percent and Total Number
ratings: Plugin Ratings for each star (1-5)
num_ratings: Number of Plugin Ratings
homepage: Plugin Author's Homepage
description: Plugin's Description
short_description: Plugin's Short Description
sections: Plugin Readme Sections: description, installation, FAQ, screenshots, other notes, and changelog
downloaded: Plugin Download Count
last_updated: Plugin's Last Update
added: Plugin's Date Added to wordpress.org Repository
tags: Plugin's Tags
versions: Plugin's Available Versions with D/L Link
donate_link: Plugin's Donation Link
banners: Plugin's Banner Image Link
icons: Plugin's Icon Image Link
active_installs: Plugin's Number of Active Installs
contributors: Plugin's List of Contributors
url: Plugin's URL on wordpress.org

[--format={format}]

Render output in a particular format.
По умолчанию: table
Может быть:

  • table
  • csv
  • count
  • json
  • yaml

Примеры

$ wp plugin search dsgnwrks --per-page=20 --format=json
Success: Showing 3 of 3 plugins.
[{"name":"DsgnWrks Instagram Importer Debug","slug":"dsgnwrks-instagram-importer-debug","rating":0},{"name":"DsgnWrks Instagram Importer","slug":"dsgnwrks-instagram-importer","rating":84},{"name":"DsgnWrks Twitter Importer","slug":"dsgnwrks-twitter-importer","rating":80}]
$ wp plugin search dsgnwrks --fields=name,version,slug,rating,num_ratings
Success: Showing 3 of 3 plugins.
+-----------------------------------+---------+-----------------------------------+--------+-------------+
| name                              | version | slug                              | rating | num_ratings |
+-----------------------------------+---------+-----------------------------------+--------+-------------+
| DsgnWrks Instagram Importer Debug | 0.1.6   | dsgnwrks-instagram-importer-debug | 0      | 0           |
| DsgnWrks Instagram Importer       | 1.3.7   | dsgnwrks-instagram-importer       | 84     | 23          |
| DsgnWrks Twitter Importer         | 1.1.1   | dsgnwrks-twitter-importer         | 80     | 1           |
+-----------------------------------+---------+-----------------------------------+--------+-------------+

wp plugin activate

Активирует один или несколько плагинов.

Использование

wp plugin activate {#activate} [{plugin}...] [--all] [--network]

Можно указать Глобальные параметры и следующие:

[{plugin}...]
Один или несколько плагинов для активации.
[--all]
Если указано, то будут активированы все установленные плагины.
[--network]
Если указано, то плагин будет установлен для сети сайтов.

Примеры

# Активация плагина Kama Thumbnail
$ wp plugin activate kama-thumbnail
Plugin 'kama-thumbnail' activated.
Success: Activated 1 of 1 plugins.
# Активация плагина Kama Thumbnail для сети сайтов
$ wp plugin activate kama-thumbnail --network
Plugin 'kama-thumbnail' network activated.
Success: Network activated 1 of 1 plugins.

wp plugin deactivate

Деактивирует один или несколько плагинов.

Использование

wp plugin deactivate {#deactivate} [{plugin}...] [--uninstall] [--all] [--network]

Можно указать Глобальные параметры и следующие:

[{plugin}...]
One or more plugins to deactivate.
[--uninstall]
Uninstall the plugin after deactivation.
[--all]
If set, all plugins will be deactivated.
[--network]
If set, the plugin will be deactivated for the entire multisite network.

Примеры

# Deactivate plugin
$ wp plugin deactivate hello
Plugin 'hello' deactivated.
Success: Deactivated 1 of 1 plugins.

wp plugin toggle

Переключает активацию плагина.

If the plugin is active, then it will be deactivated. If the plugin is inactive, then it will be activated.

Использование

wp plugin toggle {#toggle} {plugin}... [--network]

Можно указать Глобальные параметры и следующие:

{plugin}...
One or more plugins to toggle.
[--network]
If set, the plugin will be toggled for the entire multisite network.

Примеры

# Akismet is currently activated
$ wp plugin toggle akismet
Plugin 'akismet' deactivated.
Success: Toggled 1 of 1 plugins.
# Akismet is currently deactivated
$ wp plugin toggle akismet
Plugin 'akismet' activated.
Success: Toggled 1 of 1 plugins.

wp plugin path

Получает путь плагина или путь каталога плагинов.

Использование

wp plugin path {#path} [{plugin}] [--dir]

Можно указать Глобальные параметры и следующие:

[{plugin}]
The plugin to get the path to. If not set, will return the path to the plugins directory.
[--dir]
If set, get the path to the closest parent directory, instead of the plugin file.

Примеры

$ wp plugin path
/var/www/html/wp-content/plugins
$ cd $(wp plugin path) && pwd
/var/www/wordpress/wp-content/plugins

wp plugin update

Обновляет один или несколько плагинов.

Использование

wp plugin update {#update} [{plugin}...] [--all] [--exclude={name}] [--minor] [--patch] [--format={format}] [--version={version}] [--dry-run]

Можно указать Глобальные параметры и следующие:

[{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.
По умолчанию: table
Может быть:

  • 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.

Примеры

$ wp plugin update bbpress --version=dev
	Installing bbPress (Development Version)
	Downloading install package from https://downloads.wordpress.org/plugin/bbpress.zip...
	Unpacking the package...
	Installing the plugin...
	Removing the old version of the plugin...
	Plugin updated successfully.
	Success: Updated 1 of 2 plugins.
$ wp plugin update --all
	Enabling Maintenance mode...
	Downloading update from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
	Unpacking the update...
	Installing the latest version...
	Removing the old version of the plugin...
	Plugin updated successfully.
	Downloading update from https://downloads.wordpress.org/plugin/nginx-champuru.3.2.0.zip...
	Unpacking the update...
	Installing the latest version...
	Removing the old version of the plugin...
	Plugin updated successfully.
	Disabling Maintenance mode...
	+------------------------+-------------+-------------+---------+
	| name                   | old_version | new_version | status  |
	+------------------------+-------------+-------------+---------+
	| akismet                | 3.1.3       | 3.1.11      | Updated |
	| nginx-cache-controller | 3.1.1       | 3.2.0       | Updated |
	+------------------------+-------------+-------------+---------+
	Success: Updated 2 of 2 plugins.
$ wp plugin update --all --exclude=akismet
	Enabling Maintenance mode...
	Downloading update from https://downloads.wordpress.org/plugin/nginx-champuru.3.2.0.zip...
	Unpacking the update...
	Installing the latest version...
	Removing the old version of the plugin...
	Plugin updated successfully.
	Disabling Maintenance mode...
	+------------------------+-------------+-------------+---------+
	| name                   | old_version | new_version | status  |
	+------------------------+-------------+-------------+---------+
	| nginx-cache-controller | 3.1.1       | 3.2.0       | Updated |
	+------------------------+-------------+-------------+---------+

wp plugin install

Устанавливает один или несколько плагинов.

Использование

wp plugin install {#install} {plugin|zip|url}... [--version={version}] [--force] [--activate] [--activate-network]

Можно указать Глобальные параметры и следующие:

{plugin|zip|url}...
One or more plugins to install. Accepts a plugin slug, the path to a local zip file, or a 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

Примеры

# Install the latest version from wordpress.org and activate
$ wp plugin install bbpress --activate
	Installing bbPress (2.5.9)
	Downloading install package from https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip...
	Using cached file '/home/vagrant/.wp-cli/cache/plugin/bbpress-2.5.9.zip'...
	Unpacking the package...
	Installing the plugin...
	Plugin installed successfully.
	Activating 'bbpress'...
	Plugin 'bbpress' activated.
	Success: Installed 1 of 1 plugins.
# Install the development version from wordpress.org
$ wp plugin install bbpress --version=dev
	Installing bbPress (Development Version)
	Downloading install package from https://downloads.wordpress.org/plugin/bbpress.zip...
	Unpacking the package...
	Installing the plugin...
	Plugin installed successfully.
	Success: Installed 1 of 1 plugins.
# Install from a local zip file
$ wp plugin install ../my-plugin.zip
	Unpacking the package...
	Installing the plugin...
	Plugin installed successfully.
	Success: Installed 1 of 1 plugins.
# Install from a remote zip file
$ wp plugin install http://s3.amazonaws.com/bucketname/my-plugin.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef
	Downloading install package from http://s3.amazonaws.com/bucketname/my-plugin.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef
	Unpacking the package...
	Installing the plugin...
	Plugin installed successfully.
	Success: Installed 1 of 1 plugins.
# Update from a remote zip file
$ wp plugin install https://github.com/envato/wp-envato-market/archive/master.zip --force
	Downloading install package from https://github.com/envato/wp-envato-market/archive/master.zip
	Unpacking the package...
	Installing the plugin...
	Renamed Github-based project from 'wp-envato-market-master' to 'wp-envato-market'.
	Plugin updated successfully
	Success: Installed 1 of 1 plugins.
# Forcefully re-install all installed plugins
$ wp plugin install $(wp plugin list --field=name) --force
	Installing Akismet (3.1.11)
	Downloading install package from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
	Unpacking the package...
	Installing the plugin...
	Removing the old version of the plugin...
	Plugin updated successfully
	Success: Installed 1 of 1 plugins.

wp plugin get

Получает сведения об установленном плагине.

Использование

wp plugin get {#get} {plugin} [--field={field}] [--fields={fields}] [--format={format}]

Можно указать Глобальные параметры и следующие:

{plugin}
The plugin to get.
[--field={field}]
Instead of returning the whole plugin, returns the value of a single field.
[--fields={fields}]
Limit the output to specific fields. Defaults to all fields.
[--format={format}]

Render output in a particular format.
По умолчанию: table
Может быть:

  • table
  • csv
  • json
  • yaml

Примеры

$ wp plugin get svg-support
+-------------+---------------------------------------+
| Field       | Value                                 |
+-------------+---------------------------------------+
| name        | svg-support                           |
| title       | SVG Support                           |
| author      | Benbodhi                              |
| version     | 2.4.2                                 |
| description | Upload SVG files to the Media Library |
|             | sing CSS/JS.                          |
| status      | active-network                        |
+-------------+---------------------------------------+
$ wp plugin get bbpress --format=json
{"name":"bbpress","title":"bbPress","author":"The bbPress Contributors","version":"2.6-alpha","description":"bbPress is forum software with a twist from the creators of WordPress.","status":"active"}

wp plugin uninstall

Удаляет один или несколько плагинов.

Использование

wp plugin uninstall {#uninstall} [{plugin}...] [--deactivate] [--skip-delete] [--all]

Можно указать Глобальные параметры и следующие:

[{plugin}...]
Один или несколько плагинов для удаления.
[--deactivate]
Деактивирует плагин перед удалением. Если не указать, а плагин будет активным, то удаление вызовет предупреждение о том, что удаление активного плагина невозможно.
[--skip-delete]
Если указать, то файлы плагинов не будут удалены. Будет запущена только процедура удаления плагина.
[--all]
Если указать, то все плагины будут удалены.

Примеры

$ wp plugin uninstall hello
Uninstalled and deleted 'hello' plugin.
Success: Installed 1 of 1 plugins.

# Если плагина нет
$ wp plugin uninstall hello
Warning: The 'hello' plugin could not be found.
Error: No plugins uninstalled.

# Удаление с предварительной деактивацией
$ wp plugin uninstall query-monitor --deactivate
Deactivating 'query-monitor'...
Plugin 'query-monitor' deactivated.
Uninstalled and deleted 'query-monitor' plugin.
Success: Uninstalled 1 of 1 plugins.

wp plugin is-installed

Проверяет, установлен ли данный плагин.

Returns exit code 0 when installed, 1 when uninstalled.

Использование

wp plugin is-installed {#is-installed} {plugin}

Можно указать Глобальные параметры и следующие:

{plugin}
The plugin to check.

Примеры

# Check whether plugin is installed; exit status 0 if installed, otherwise 1
$ wp plugin is-installed hello
$ echo $?
1

wp plugin is-active

Проверяет, активен ли данный плагин.

Returns exit code 0 when active, 1 when not active.

Использование

wp plugin is-active {#is-active} {plugin}

Можно указать Глобальные параметры и следующие:

{plugin}
The plugin to check.

Примеры

# Check whether plugin is Active; exit status 0 if active, otherwise 1
$ wp plugin is-active hello
$ echo $?
1

wp plugin delete

Удаляет файлы плагинов без деактивации или удаления.

Использование

wp plugin delete {#delete} [{plugin}...] [--all]

Можно указать Глобальные параметры и следующие:

[{plugin}...]
One or more plugins to delete.
[--all]
If set, all plugins will be deleted.

Примеры

# Delete plugin
$ wp plugin delete hello
Deleted 'hello' plugin.
Success: Deleted 1 of 1 plugins.
# Delete inactive plugins
$ wp plugin delete $(wp plugin list --status=inactive --field=name)
Deleted 'tinymce-templates' plugin.
Success: Deleted 1 of 1 plugins.

wp plugin list

Возвращает список плагинов.

Displays a list of the plugins installed on the site with activation status, whether or not there's an update available, etc.

Use --status=dropin to list installed dropins (e.g. object-cache.php).

Использование

wp plugin list {#list} [--{field}={value}] [--field={field}] [--fields={fields}] [--format={format}]

Можно указать Глобальные параметры и следующие:

[--{field}={value}]
Filter results based on the value of a field.
[--field={field}]
Prints the value of a single field for each plugin.
[--fields={fields}]
Limit the output to specific object fields.
[--format={format}]

Render output in a particular format.
По умолчанию: table
Может быть:

  • table
  • csv
  • count
  • json
  • yaml

Доступные поля

These fields will be displayed by default for each plugin:

  • name
  • status
  • update
  • version

These fields are optionally available:

  • update_version
  • update_package
  • update_id
  • title
  • description

Примеры

# List active plugins on the site.
$ wp plugin list --status=active --format=json
[{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2"},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3"},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4"},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1"}]
# List plugins on each site in a network.
$ wp site list --field=url | xargs -I % wp plugin list --url=%
+---------+----------------+--------+---------+
| name    | status         | update | version |
+---------+----------------+--------+---------+
| akismet | active-network | none   | 3.1.11  |
| hello   | inactive       | none   | 1.6     |
+---------+----------------+--------+---------+
+---------+----------------+--------+---------+
| name    | status         | update | version |
+---------+----------------+--------+---------+
| akismet | active-network | none   | 3.1.11  |
| hello   | inactive       | none   | 1.6     |
+---------+----------------+--------+---------+

wp plugin verify-checksums

Сверяет контрольную сумму файлов плагина с каталогом WordPress.org.

  • Если у плагина не указана версия, то будет пропущен.
  • Если плагин не из репозитория, то будет пропущен.
  • Сверяется та версия плагина, которая установлена на сайте.

Команда используется, когда нужно проверить оригинальные ли файлы плагина используются. Актуально при заражении файлов плагина вирусами и другими вмешательствами. Чтобы восстановить плагин, используйте команду install.

Параметры

Можно указать Глобальные параметры и следующие:

[{plugin}...]
Один или несколько плагинов для проверки.
[--all]
Если указано, то все плагины будут проверены.
[--strict]
Если указано, то даже «мягкие изменения» в таких файлах как readme.txt, будут вызывать ошибки контрольной суммы.
[--format={format}]
Формат вывода данных. Может быть: table, json, csv, yaml, count.
По умолчанию: table

Примеры

Проверим (успешно) контрольные суммы всех плагинов
$ wp plugin verify-checksums --all
Success: Verified 8 of 8 plugins.
Проверим (с ошибками) контрольные суммы всех плагинов
$ wp plugin verify-checksums --all
Warning: Could not retrieve the checksums for version  of plugin tests, skipping.
Warning: Could not retrieve the checksums for version 5.8.7 of plugin advanced-custom-fields-pro, skipping.
+----------------+------------------------------------+-------------------------+
| plugin_name    | file                               | message                 |
+----------------+------------------------------------+-------------------------+
| kama-thumbnail | class.Kama_Make_Thumb.php          | File is missing         |
| kama-thumbnail | class.Kama_Thumbnail.php           | File is missing         |
| kama-thumbnail | class.Kama_Thumbnail-olo-lo.php    | File was added          |
| elementor      | elementor.php                      | Checksum does not match |
+----------------+------------------------------------+-------------------------+
Error: Only verified 21 of 25 plugins (2 failed, 2 skipped).

При проверке 25 плагинов 4 не прошли проверку, потому что:

  • Плагин Test: самописный плагин. Не имеет версии - проверка пропущена.
  • Плагин Advanced Custom Fields PRO: платный плагин. Не в репозитории WP - проверка пропущена.
  • Плагин Kama Thumbnail: Файл class.Kama_Thumbnail.php переименован в class.Kama_Thumbnail-olo-lo.php.
  • Плагин Kama Thumbnail: Файл class.Kama_Make_Thumb.php удален.
  • Плагин Elementor: Файл elementor.php был изменен.
Проверим (успешно) контрольную сумму у плагина Akismet
$ wp plugin verify-checksums akismet
Success: Verified 1 of 1 plugins.
Проверка (успешно) контрольных сумм у плагинов Kama Thumbnail и Query Monitor
$ wp plugin verify-checksums kama-thumbnail query-monitor
Success: Verified 2 of 2 plugins.
Проверка (с ошибкой) контрольных сумм у плагинов Kama Thumbnail и Query Monitor

В данном примере не получилось запросить информацию для сверки с сервера WP для плагина Query Monitor.

$ wp plugin verify-checksums kama-thumbnail query-monitor
Error: Failed to get url 'https://downloads.wordpress.org/plugin-checksums/query-monitor/3.5.2.json': cURL error 28: Connection timed out after 10000 milliseconds.
Проверка (с ошибкой) контрольных сумм у плагина Kama Thumbnail

Для примера было сделано следующее

  • Файл class.Kama_Thumbnail.php переименован в class.Kama_Thumbnail-olo-lo.php.
  • Файл class.Kama_Make_Thumb.php удален.
$ wp plugin verify-checksums kama-thumbnail
+----------------+---------------------------------+-----------------+
| plugin_name    | file                            | message         |
+----------------+---------------------------------+-----------------+
| kama-thumbnail | class.Kama_Make_Thumb.php       | File is missing |
| kama-thumbnail | class.Kama_Thumbnail.php        | File is missing |
| kama-thumbnail | class.Kama_Thumbnail-olo-lo.php | File was added  |
+----------------+---------------------------------+-----------------+
Error: No plugins verified (1 failed).
Использование параметра strict

Для проверки будет использоваться плагин Elementor.

Файлы без изменений - успешная проверка

$ wp plugin verify-checksums elementor
Success: Verified 1 of 1 plugins.

Изменен только файл elementor.php - проверка провалена

$ wp plugin verify-checksums elementor
+-------------+---------------+-------------------------+
| plugin_name | file          | message                 |
+-------------+---------------+-------------------------+
| elementor   | elementor.php | Checksum does not match |
+-------------+---------------+-------------------------+
Error: No plugins verified (1 failed).

Изменен только файл readme.txt - успешная проверка

$ wp plugin verify-checksums elementor
Success: Verified 1 of 1 plugins.

Изменен только файл readme.txt, но указан параметр strict - проверка провалена

$ wp plugin verify-checksums elementor --strict
+-------------+------------+-------------------------+
| plugin_name | file       | message                 |
+-------------+------------+-------------------------+
| elementor   | readme.txt | Checksum does not match |
+-------------+------------+-------------------------+
Error: No plugins verified (1 failed).