Skip to content

Commit 17b7d97

Browse files
author
Kyam Harris
committed
Allow comment ID to be in middle of string
1 parent 250ed0d commit 17b7d97

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/Comment_Command.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,10 @@ private function call( $args, $status, $success, $failure ) {
428428

429429
$func = "wp_{$status}_comment";
430430

431-
if ( ! $func( $comment_id ) ) {
432-
WP_CLI::error( "{$failure} comment {$comment_id}." );
431+
if ( ! $func( $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

@@ -512,10 +511,10 @@ public function untrash( $args, $assoc_args ) {
512511
* $ wp comment spam 1337
513512
* Success: Marked as spam comment 1337.
514513
*/
515-
public function spam( $args, $assoc_args ) {
516-
foreach ( $args as $id ) {
517-
$this->call( $id, __FUNCTION__, 'Marked as spam', 'Failed marking as spam' );
518-
}
514+
public function spam( $args ) {
515+
foreach ( $args as $id ) {
516+
$this->call( $id, __FUNCTION__, 'Marked %s as spam.', 'Failed marking %s as spam.' );
517+
}
519518
}
520519

521520
/**
@@ -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)