diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index ca12ad7940..3714cbfc3c 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -2153,6 +2153,7 @@ function wp_list_comments( $args = array(), $comments = null ) { * in the array of fields. * * @since 3.0.0 + * @since 4.2.0 Introduced 'submit_button' and 'submit_fields' arguments. * * @param array $args { * Optional. Default arguments and form fields to override. @@ -2180,6 +2181,11 @@ function wp_list_comments( $args = array(), $comments = null ) { * where %s is the author of the comment being replied to. * @type string $cancel_reply_link The translatable 'cancel reply' button label. Default 'Cancel reply'. * @type string $label_submit The translatable 'submit' button label. Default 'Post a comment'. + * @type string $submit_button HTML format for the Submit button. + * Default: ''. + * @type string $submit_field HTML format for the markup surrounding the Submit button and comment hidden + * fields. Default: '

%1$s %2$s', where %1$s is the + * submit button markup and %2$s is the comment hidden fields. * @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. * } * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. @@ -2236,6 +2242,8 @@ function comment_form( $args = array(), $post_id = null ) { 'title_reply_to' => __( 'Leave a Reply to %s' ), 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Post Comment' ), + 'submit_button' => '', + 'submit_field' => '

%1$s %2$s

', 'format' => 'xhtml', ); @@ -2350,11 +2358,45 @@ function comment_form( $args = array(), $post_id = null ) { echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?> -

- - -

+ tag. * diff --git a/tests/phpunit/tests/comment/commentForm.php b/tests/phpunit/tests/comment/commentForm.php new file mode 100644 index 0000000000..689ccf6d0c --- /dev/null +++ b/tests/phpunit/tests/comment/commentForm.php @@ -0,0 +1,55 @@ +factory->post->create(); + + $args = array( + 'name_submit' => 'foo-name', + 'id_submit' => 'foo-id', + 'class_submit' => 'foo-class', + 'label_submit' => 'foo-label', + ); + $form = get_echo( 'comment_form', array( $args, $p ) ); + + $button = ''; + $hidden = get_comment_id_fields( $p ); + $this->assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); + } + + public function test_custom_submit_button() { + $p = $this->factory->post->create(); + + $args = array( + 'name_submit' => 'foo-name', + 'id_submit' => 'foo-id', + 'class_submit' => 'foo-class', + 'label_submit' => 'foo-label', + 'submit_button' => '' + ); + $form = get_echo( 'comment_form', array( $args, $p ) ); + + $button = ''; + $this->assertContains( $button, $form ); + } + + public function test_custom_submit_field() { + $p = $this->factory->post->create(); + + $args = array( + 'name_submit' => 'foo-name', + 'id_submit' => 'foo-id', + 'class_submit' => 'foo-class', + 'label_submit' => 'foo-label', + 'submit_field' => '

%1$s %2$s

' + ); + $form = get_echo( 'comment_form', array( $args, $p ) ); + + $button = ''; + $hidden = get_comment_id_fields( $p ); + $this->assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); + } +}