wp comment

Создает, обновляет, удаляет и модерирует комментарии.

Список команд Описание
wp comment create Создает новый комментарий.
wp comment update Обновляет один или несколько комментариев.
wp comment generate Генерирует новые комментарии.
wp comment get Возвращает данные одного комментария.
wp comment list Получает список комментариев.
wp comment delete Удаляет комментарий.
wp comment trash Помещает в корзину или удаляет комментарий.
wp comment untrash Убирает комментарий из корзины.
wp comment spam Помечает комментарий как спам.
wp comment unspam Убирает комментарий из спама.
wp comment approve Утверждает комментарий.
wp comment unapprove Ставит статус комментария unapprove.
wp comment count Подсчитывает комментарии, на весь блог или на данный пост.
wp comment recount Пересчитывает значение comment_count для одной или нескольких записей.
wp comment status Возвращает статус комментария.
wp comment exists Проверяет, существует ли комментарий.
wp comment meta list Список всех метаданных, связанных с комментом.
wp comment meta get Получает значение мета-поля.
wp comment meta delete Удаление мета-поля.
wp comment meta add Добавляет мета-поле.
wp comment meta update Обновляет мета-поля.
wp comment meta pluck Получает вложенное значение из мета-поля (из сериал-го массива).
wp comment meta patch Обновляет вложенные значения мета-поля.

Примеры

wp comment

# Create a new comment.
$ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
Success: Created comment 932.

# Update an existing comment.
$ wp comment update 123 --comment_author='That Guy'
Success: Updated comment 123.

# Delete an existing comment.
$ wp comment delete 1337 --force
Success: Deleted comment 1337.

# Delete all spam comments.
$ wp comment delete $(wp comment list --status=spam --format=ids)
Success: Deleted comment 264.
Success: Deleted comment 262.

wp comment meta

# Set comment meta
$ wp comment meta set 123 description "Mary is a WordPress developer."
Success: Updated custom field 'description'.

# Get comment meta
$ wp comment meta get 123 description
Mary is a WordPress developer.

# Update comment meta
$ wp comment meta update 123 description "Mary is an awesome WordPress developer."
Success: Updated custom field 'description'.

# Delete comment meta
$ wp comment meta delete 123 description
Success: Deleted custom field.

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


wp comment create

Создает новый комментарий.

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

wp comment create [--{field}={value}] [--porcelain]

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

[--{field}={value}]
Associative args for the new comment. See wp_insert_comment().
[--porcelain]
Output just the new comment id.

Примеры

# Create comment.
$ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
Success: Created comment 932.

wp comment update

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

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

wp comment update {id}... --{field}={value}

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

{id}...
One or more IDs of comments to update.
--{field}={value}
One or more fields to update. See wp_update_comment().

Примеры

# Update comment.
$ wp comment update 123 --comment_author='That Guy'
Success: Updated comment 123.

wp comment generate

Генерирует новые комментарии.

Creates a specified number of new comments with dummy data.

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

wp comment generate [--count={number}] [--post_id={post-id}] [--format={format}]

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

[--count={number}]
How many comments to generate?
По умолчанию: 100
[--post_id={post-id}]
Assign comments to a specific post.
[--format={format}]

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

  • progress
  • ids

Примеры

# Generate comments for the given post.
$ wp comment generate --format=ids --count=3 --post_id=123
138 139 140
# Add meta to every generated comment.
$ wp comment generate --format=ids --count=3 | xargs -d ' ' -I % wp comment meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.

wp comment get

Возвращает данные одного комментария.

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

wp comment get {id} [--field={field}] [--fields={fields}] [--format={format}]

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

{id}
The comment to get.
[--field={field}]
Instead of returning the whole comment, 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

Примеры

# Get comment.
$ wp comment get 21 --field=content
Thanks for all the comments, everyone!

wp comment list

Получает список комментариев.

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

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

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

[--{field}={value}]
One or more args to pass to WP_Comment_Query.
[--field={field}]
Prints the value of a single field for each comment.
[--fields={fields}]
Limit the output to specific object fields.
[--format={format}]

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

  • table
  • ids
  • csv
  • json
  • count
  • yaml

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

These fields will be displayed by default for each comment:

  • comment_ID
  • comment_post_ID
  • comment_date
  • comment_approved
  • comment_author
  • comment_author_email

These fields are optionally available:

  • comment_author_url
  • comment_author_IP
  • comment_date_gmt
  • comment_content
  • comment_karma
  • comment_agent
  • comment_type
  • comment_parent
  • user_id
  • url

Примеры

# List comment IDs.
$ wp comment list --field=ID
22
23
24
# List comments of a post.
$ wp comment list --post_id=1 --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 1          | 2015-06-20 09:00:10 | Mr WordPress   |
+------------+---------------------+----------------+
# List approved comments.
$ wp comment list --number=3 --status=approve --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 1          | 2015-06-20 09:00:10 | Mr WordPress   |
| 30         | 2013-03-14 12:35:07 | John Doe       |
| 29         | 2013-03-14 11:56:08 | Jane Doe       |
+------------+---------------------+----------------+

wp comment delete

Удаляет комментарий.

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

wp comment delete {id}... [--force]

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

{id}...
One or more IDs of comments to delete.
[--force]
Skip the trash bin.

Примеры

# Delete comment.
$ wp comment delete 1337 --force
Success: Deleted comment 1337.
# Delete multiple comments.
$ wp comment delete 1337 2341 --force
Success: Deleted comment 1337.
Success: Deleted comment 2341.

wp comment trash

Помещает в корзину или удаляет комментарий.

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

wp comment trash {id}...

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

{id}...
The IDs of the comments to trash.

Примеры

# Trash comment.
$ wp comment trash 1337
Success: Trashed comment 1337.

wp comment untrash

Убирает комментарий из корзины.

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

wp comment untrash {id}...

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

{id}...
The IDs of the comments to untrash.

Примеры

# Untrash comment.
$ wp comment untrash 1337
Success: Untrashed comment 1337.

wp comment spam

Помечает комментарий как спам.

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

wp comment spam {id}...

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

{id}...
The IDs of the comments to mark as spam.

Примеры

# Spam comment.
$ wp comment spam 1337
Success: Marked as spam comment 1337.

wp comment unspam

Убирает комментарий из спама.

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

wp comment unspam {id}...

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

{id}...
The IDs of the comments to unmark as spam.

Примеры

# Unspam comment.
$ wp comment unspam 1337
Success: Unspammed comment 1337.

wp comment approve

Утверждает комментарий.

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

wp comment approve {id}...

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

{id}...
The IDs of the comments to approve.

Примеры

# Approve comment.
$ wp comment approve 1337
Success: Approved comment 1337.

wp comment unapprove

Ставит статус комментария unapprove.

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

wp comment unapprove {id}...

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

{id}...
The IDs of the comments to unapprove.

Примеры

# Unapprove comment.
$ wp comment unapprove 1337
Success: Unapproved comment 1337.

wp comment count

Подсчитывает комментарии, на весь блог или на данный пост.

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

wp comment count [{post-id}]

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

[{post-id}]
The ID of the post to count comments in.

Примеры

# Count comments on whole blog.
$ wp comment count
approved:        33
spam:            3
trash:           1
post-trashed:    0
all:             34
moderated:       1
total_comments:  37
# Count comments in a post.
$ wp comment count 42
approved:        19
spam:            0
trash:           0
post-trashed:    0
all:             19
moderated:       0
total_comments:  19

wp comment recount

Пересчитывает значение comment_count для одной или нескольких записей.

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

wp comment recount {id}...

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

{id}...
IDs for one or more posts to update.

Примеры

# Recount comment for the post.
$ wp comment recount 123
Updated post 123 comment count to 67.

wp comment status

Возвращает статус комментария.

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

wp comment status {id}

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

{id}
The ID of the comment to check.

Примеры

# Get status of comment.
$ wp comment status 1337
approved

wp comment exists

Проверяет, существует ли комментарий.

Displays a success message if the comment does exist.

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

wp comment exists {id}

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

{id}
The ID of the comment to check.

Примеры

# Check whether comment exists.
$ wp comment exists 1337
Success: Comment with ID 1337 exists.

wp comment meta list

Список всех метаданных, связанных с комментом.

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

wp comment meta list {id} [--keys={keys}] [--fields={fields}] [--format={format}] [--orderby={fields}] [--order={order}]

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

{id}
ID for the object.
[--keys={keys}]
Limit output to metadata of specific keys.
[--fields={fields}]
Limit the output to specific row fields. Defaults to id,meta_key,meta_value.
[--format={format}]

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

  • table
  • csv
  • json
  • yaml
  • count
[--orderby={fields}]

Set orderby which field.
По умолчанию: id
Может быть:

  • id
  • meta_key
  • meta_value
[--order={order}]

Set ascending or descending order.
По умолчанию: asc
Может быть:

  • asc
  • desc

wp comment meta get

Получает значение мета-поля.

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

wp comment meta get {id} {key} [--format={format}]

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

{id}
The ID of the object.
{key}
The name of the meta field to get.
[--format={format}]

Get value in a particular format.
По умолчанию: var_export
Может быть:

  • var_export
  • json
  • yaml

wp comment meta delete

Удаление мета-поля.

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

wp comment meta delete {id} [{key}] [{value}] [--all]

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

{id}
The ID of the object.
[{key}]
The name of the meta field to delete.
[{value}]
The value to delete. If omitted, all rows with key will deleted.
[--all]
Delete all meta for the object.

wp comment meta add

Добавляет мета-поле.

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

wp comment meta add {id} {key} [{value}] [--format={format}]

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

{id}
The ID of the object.
{key}
The name of the meta field to create.
[{value}]
The value of the meta field. If omitted, the value is read from STDIN.
[--format={format}]

The serialization format for the value.
По умолчанию: plaintext
Может быть:

  • plaintext
  • json

wp comment meta update

Обновляет мета-поля.

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

wp comment meta update {id} {key} [{value}] [--format={format}]

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

{id}
The ID of the object.
{key}
The name of the meta field to update.
[{value}]
The new value. If omitted, the value is read from STDIN.
[--format={format}]

The serialization format for the value.
По умолчанию: plaintext
Может быть:

  • plaintext
  • json

wp comment meta pluck

Получает вложенное значение из мета-поля (из сериал-го массива).

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

wp comment meta pluck {id} {key} {key-path}... [--format={format}]

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

{id}
The ID of the object.
{key}
The name of the meta field to get.
{key-path}...
The name(s) of the keys within the value to locate the value to pluck.
[--format={format}]
The output format of the value.
--- По умолчанию: plaintext
Может быть:
  • plaintext
  • json
  • yaml

wp comment meta patch

Обновляет вложенные значения мета-поля.

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

wp comment meta patch {action} {id} {key} {key-path}... [{value}] [--format={format}]

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

{action}

Patch action to perform.

Может быть:

  • insert
  • update
  • delete
{id}
The ID of the object.
{key}
The name of the meta field to update.
{key-path}...
The name(s) of the keys within the value to locate the value to patch.
[{value}]
The new value. If omitted, the value is read from STDIN.
[--format={format}]

The serialization format for the value.
По умолчанию: plaintext
Может быть:

  • plaintext
  • json