PHP Class Comment_Command, wp-cli

## EXAMPLES # 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.
Inheritance: extends WP_CLI\CommandWithDBObject
Afficher le fichier Open project: wp-cli/wp-cli

Protected Properties

Свойство Type Description
$obj_fields
$obj_id_key
$obj_type

Méthodes publiques

Méthode Description
__construct ( )
approve ( $args, $assoc_args ) Approve a comment.
count ( $args, $assoc_args ) Count comments, on whole blog or on a given post.
create ( $args, $assoc_args ) Create a new comment.
delete ( $args, $assoc_args ) Delete a comment.
exists ( $args ) Verify whether a comment exists.
generate ( $args, $assoc_args ) Generate some number of new dummy comments.
get ( $args, $assoc_args ) Get data of a single comment.
list_ ( $_, $assoc_args ) Get a list of comments.
recount ( $args ) Recalculate the comment_count value for one or more posts.
spam ( $args, $assoc_args ) Mark a comment as spam.
status ( $args, $assoc_args ) Get status of a comment.
trash ( $args, $assoc_args ) Trash a comment.
unapprove ( $args, $assoc_args ) Unapprove a comment.
unspam ( $args, $assoc_args ) Unmark a comment as spam.
untrash ( $args, $assoc_args ) Untrash a comment.
update ( $args, $assoc_args ) Update one or more comments.

Private Methods

Méthode Description
call ( $args, $status, $success, $failure )
set_status ( $args, $status, $success )

Method Details

__construct() public méthode

public __construct ( )

approve() public méthode

## OPTIONS ... : The IDs of the comments to approve. ## EXAMPLES # Approve comment. $ wp comment approve 1337 Success: Approved comment 1337.
public approve ( $args, $assoc_args )

count() public méthode

## OPTIONS [] : The ID of the post to count comments in. ## EXAMPLES # 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
public count ( $args, $assoc_args )

create() public méthode

## OPTIONS [--=] : Associative args for the new comment. See wp_insert_comment(). [--porcelain] : Output just the new comment id. ## EXAMPLES # Create comment. $ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli" Success: Created comment 932.
public create ( $args, $assoc_args )

delete() public méthode

## OPTIONS ... : One or more IDs of comments to delete. [--force] : Skip the trash bin. ## EXAMPLES # 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.
public delete ( $args, $assoc_args )

exists() public méthode

Displays a success message if the comment does exist. ## OPTIONS : The ID of the comment to check. ## EXAMPLES # Check whether comment exists. $ wp comment exists 1337 Success: Comment with ID 1337 exists.
public exists ( $args )

generate() public méthode

Creates a specified number of new comments with dummy data. ## OPTIONS [--count=] : How many comments to generate? --- default: 100 --- [--post_id=] : Assign comments to a specific post. [--format=] : Render output in a particular format. --- default: progress options: - progress - ids --- ## EXAMPLES # 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.
public generate ( $args, $assoc_args )

get() public méthode

## OPTIONS : The comment to get. [--field=] : Instead of returning the whole comment, returns the value of a single field. [--fields=] : Limit the output to specific fields. Defaults to all fields. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - yaml --- ## EXAMPLES # Get comment. $ wp comment get 21 --field=content Thanks for all the comments, everyone!
public get ( $args, $assoc_args )

list_() public méthode

## OPTIONS [--=] : One or more args to pass to WP_Comment_Query. [--field=] : Prints the value of a single field for each comment. [--fields=] : Limit the output to specific object fields. [--format=] : Render output in a particular format. --- default: table options: - table - ids - csv - json - count - yaml --- ## AVAILABLE FIELDS 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 ## EXAMPLES # 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 | +------------+---------------------+----------------+
public list_ ( $_, $assoc_args )

recount() public méthode

## OPTIONS ... : IDs for one or more posts to update. ## EXAMPLES # Recount comment for the post. $ wp comment recount 123 Updated post 123 comment count to 67.
public recount ( $args )

spam() public méthode

## OPTIONS ... : The IDs of the comments to mark as spam. ## EXAMPLES # Spam comment. $ wp comment spam 1337 Success: Marked as spam comment 1337.
public spam ( $args, $assoc_args )

status() public méthode

## OPTIONS : The ID of the comment to check. ## EXAMPLES # Get status of comment. $ wp comment status 1337 approved
public status ( $args, $assoc_args )

trash() public méthode

## OPTIONS ... : The IDs of the comments to trash. ## EXAMPLES # Trash comment. $ wp comment trash 1337 Success: Trashed comment 1337.
public trash ( $args, $assoc_args )

unapprove() public méthode

## OPTIONS ... : The IDs of the comments to unapprove. ## EXAMPLES # Unapprove comment. $ wp comment unapprove 1337 Success: Unapproved comment 1337.
public unapprove ( $args, $assoc_args )

unspam() public méthode

## OPTIONS ... : The IDs of the comments to unmark as spam. ## EXAMPLES # Unspam comment. $ wp comment unspam 1337 Success: Unspammed comment 1337.
public unspam ( $args, $assoc_args )

untrash() public méthode

## OPTIONS ... : The IDs of the comments to untrash. ## EXAMPLES # Untrash comment. $ wp comment untrash 1337 Success: Untrashed comment 1337.
public untrash ( $args, $assoc_args )

update() public méthode

## OPTIONS ... : One or more IDs of comments to update. --= : One or more fields to update. See wp_update_comment(). ## EXAMPLES # Update comment. $ wp comment update 123 --comment_author='That Guy' Success: Updated comment 123.
public update ( $args, $assoc_args )

Property Details

$obj_fields protected_oe property

protected $obj_fields

$obj_id_key protected_oe property

protected $obj_id_key

$obj_type protected_oe property

protected $obj_type