WP_CLI\Fetchers
Comment{}└─ Base
Fetch a WordPress comment based on one of its attributes.
No Hooks.
Usage
$Comment = new Comment(); // use class methods
Methods
- public get( $arg )
Comment{} Comment{} code WP-CLI 2.13.0-alpha
class Comment extends Base {
/**
* The message to display when an item is not found.
*
* @var string
*/
protected $msg = 'Could not find the comment with ID %d.';
/**
* Get a comment object by ID
*
* @param string $arg The raw CLI argument.
* @return WP_Comment|array|false The item if found; false otherwise.
*/
public function get( $arg ) {
$comment_id = (int) $arg;
$comment = get_comment( $comment_id );
if ( null === $comment ) {
return false;
}
return $comment;
}
}