Skip to content

Commit 4ad5a52

Browse files
authored
Improve wp comment spam output (#272)
Improve wp comment spam output
2 parents 4e23faa + 525b093 commit 4ad5a52

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

features/comment.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Feature: Manage WordPress comments
276276
When I run `wp comment spam {COMMENT_ID}`
277277
Then STDOUT should be:
278278
"""
279-
Success: Marked as spam comment {COMMENT_ID}.
279+
Success: Marked comment {COMMENT_ID} as spam.
280280
"""
281281

282282
When I run `wp comment list --format=count --status=spam`
@@ -301,7 +301,7 @@ Feature: Manage WordPress comments
301301
When I run `wp comment spam {COMMENT_ID}`
302302
Then STDOUT should be:
303303
"""
304-
Success: Marked as spam comment {COMMENT_ID}.
304+
Success: Marked comment {COMMENT_ID} as spam.
305305
"""
306306

307307
When I try `wp comment unspam {COMMENT_ID}`

src/Comment_Command.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,9 @@ private function call( $args, $status, $success, $failure ) {
429429
$func = "wp_{$status}_comment";
430430

431431
if ( ! $func( $comment_id ) ) {
432-
WP_CLI::error( "{$failure} comment {$comment_id}." );
432+
WP_CLI::error( sprintf( $failure, "comment {$comment_id}" ) );
433433
}
434-
435-
WP_CLI::success( "{$success} comment {$comment_id}." );
434+
WP_CLI::success( sprintf( $success, "comment {$comment_id}" ) );
436435
}
437436

438437
private function set_status( $args, $status, $success ) {
@@ -473,7 +472,7 @@ private function check_server_name() {
473472
*/
474473
public function trash( $args, $assoc_args ) {
475474
foreach ( $args as $id ) {
476-
$this->call( $id, __FUNCTION__, 'Trashed', 'Failed trashing' );
475+
$this->call( $id, __FUNCTION__, 'Trashed %s.', 'Failed trashing %s.' );
477476
}
478477
}
479478

@@ -494,7 +493,7 @@ public function trash( $args, $assoc_args ) {
494493
public function untrash( $args, $assoc_args ) {
495494
$this->check_server_name();
496495
foreach ( $args as $id ) {
497-
$this->call( $id, __FUNCTION__, 'Untrashed', 'Failed untrashing' );
496+
$this->call( $id, __FUNCTION__, 'Untrashed %s.', 'Failed untrashing %s.' );
498497
}
499498
}
500499

@@ -514,7 +513,7 @@ public function untrash( $args, $assoc_args ) {
514513
*/
515514
public function spam( $args, $assoc_args ) {
516515
foreach ( $args as $id ) {
517-
$this->call( $id, __FUNCTION__, 'Marked as spam', 'Failed marking as spam' );
516+
$this->call( $id, __FUNCTION__, 'Marked %s as spam.', 'Failed marking %s as spam.' );
518517
}
519518
}
520519

@@ -535,7 +534,7 @@ public function spam( $args, $assoc_args ) {
535534
public function unspam( $args, $assoc_args ) {
536535
$this->check_server_name();
537536
foreach ( $args as $id ) {
538-
$this->call( $id, __FUNCTION__, 'Unspammed', 'Failed unspamming' );
537+
$this->call( $id, __FUNCTION__, 'Unspammed %s.', 'Failed unspamming %s.' );
539538
}
540539
}
541540

0 commit comments

Comments
 (0)