public function create( $args, $assoc_args ) {
		$assoc_args = wp_slash( $assoc_args );
		parent::_create(
			$args,
			$assoc_args,
			function ( $params ) {
				if ( isset( $params['comment_post_ID'] ) ) {
					$post_id = $params['comment_post_ID'];
					$post    = get_post( $post_id );
					if ( ! $post ) {
						return new WP_Error( 'no_post', "Can't find post {$post_id}." );
					}
				} else {
					// Make sure it's set for older WP versions else get undefined PHP notice.
					$params['comment_post_ID'] = 0;
				}

				// We use wp_insert_comment() instead of wp_new_comment() to stay at a low level and
				// avoid wp_die() formatted messages or notifications
				$comment_id = wp_insert_comment( $params );

				if ( ! $comment_id ) {
					return new WP_Error( 'db_error', 'Could not create comment.' );
				}

				return $comment_id;
			}
		);
	}
public function create( $args, $assoc_args ) {
		$assoc_args = wp_slash( $assoc_args );
		parent::_create(
			$args,
			$assoc_args,
			function ( $params ) {
				if ( isset( $params['comment_post_ID'] ) ) {
					$post_id = $params['comment_post_ID'];
					$post    = get_post( $post_id );
					if ( ! $post ) {
						return new WP_Error( 'no_post', "Can't find post {$post_id}." );
					}
				} else {
					// Make sure it's set for older WP versions else get undefined PHP notice.
					$params['comment_post_ID'] = 0;
				}

				// We use wp_insert_comment() instead of wp_new_comment() to stay at a low level and
				// avoid wp_die() formatted messages or notifications
				$comment_id = wp_insert_comment( $params );

				if ( ! $comment_id ) {
					return new WP_Error( 'db_error', 'Could not create comment.' );
				}

				return $comment_id;
			}
		);
	}
public function create ( $ args , $ assoc_args ) { $ assoc_args = wp_slash ( $ assoc_args ) ; parent :: _create ( $ args , $ assoc_args , function ( $ params ) { if ( isset ( $ params [ 'comment_post_ID' ] ) ) { $ post_id = $ params [ 'comment_post_ID' ] ; $ post = get_post ( $ post_id ) ; if ( ! $ post ) { return new WP_Error ( 'no_post' , "Can't find post {$post_id}." ) ; } } else { // Make sure it's set for older WP versions else get undefined PHP notice. $ params [ 'comment_post_ID' ] = 0 ; } // We use wp_insert_comment() instead of wp_new_comment() to stay at a low level and // avoid wp_die() formatted messages or notifications $ comment_id = wp_insert_comment ( $ params ) ; if ( ! $ comment_id ) { return new WP_Error ( 'db_error' , 'Could not create comment.' ) ; } return $ comment_id ; } ) ; }
Creates a new comment.

## OPTIONS

[--<field>=<value>]
: 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.
Creates a new comment .