diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 77f16d9ab2..2f1c59ee5d 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -2252,6 +2252,9 @@ function comment_form( $args = array(), $post_id = null ) { */ $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); + // Ensure that the filtered args contain all required default values. + $args = array_merge( $defaults, $args ); + if ( comments_open( $post_id ) ) : ?> assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); } + + /** + * @ticket 32312 + */ + public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() { + $p = $this->factory->post->create(); + + $args = array( + 'name_submit' => 'foo-name', + 'id_submit' => 'foo-id', + 'class_submit' => 'foo-class', + 'label_submit' => 'foo-label', + ); + + add_filter( 'comment_form_defaults', array( $this, 'filter_comment_form_defaults' ) ); + $form = get_echo( 'comment_form', array( $args, $p ) ); + remove_filter( 'comment_form_defaults', array( $this, 'filter_comment_form_defaults' ) ); + + $button = ''; + $hidden = get_comment_id_fields( $p ); + $this->assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); + } + + public function filter_comment_form_defaults( $defaults ) { + unset( $defaults['submit_field'] ); + unset( $defaults['submit_button'] ); + return $defaults; + } }