diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
index 77f16d9..2f1c59e 100644
|
|
function comment_form( $args = array(), $post_id = null ) { |
2252 | 2252 | */ |
2253 | 2253 | $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); |
2254 | 2254 | |
| 2255 | // Ensure that the filtered args contain all required default values. |
| 2256 | $args = array_merge( $defaults, $args ); |
| 2257 | |
2255 | 2258 | if ( comments_open( $post_id ) ) : ?> |
2256 | 2259 | <?php |
2257 | 2260 | /** |
diff --git tests/phpunit/tests/comment/commentForm.php tests/phpunit/tests/comment/commentForm.php
index 689ccf6..5573ebd 100644
|
|
class Tests_Comment_CommentForm extends WP_UnitTestCase { |
52 | 52 | $hidden = get_comment_id_fields( $p ); |
53 | 53 | $this->assertRegExp( '|<p class="my\-custom\-submit\-field">\s*' . $button . '\s*' . $hidden . '\s*|', $form ); |
54 | 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @ticket 32312 |
| 58 | */ |
| 59 | public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() { |
| 60 | $p = $this->factory->post->create(); |
| 61 | |
| 62 | $args = array( |
| 63 | 'name_submit' => 'foo-name', |
| 64 | 'id_submit' => 'foo-id', |
| 65 | 'class_submit' => 'foo-class', |
| 66 | 'label_submit' => 'foo-label', |
| 67 | ); |
| 68 | |
| 69 | add_filter( 'comment_form_defaults', array( $this, 'filter_comment_form_defaults' ) ); |
| 70 | $form = get_echo( 'comment_form', array( $args, $p ) ); |
| 71 | remove_filter( 'comment_form_defaults', array( $this, 'filter_comment_form_defaults' ) ); |
| 72 | |
| 73 | $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />'; |
| 74 | $hidden = get_comment_id_fields( $p ); |
| 75 | $this->assertRegExp( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form ); |
| 76 | } |
| 77 | |
| 78 | public function filter_comment_form_defaults( $defaults ) { |
| 79 | unset( $defaults['submit_field'] ); |
| 80 | unset( $defaults['submit_button'] ); |
| 81 | return $defaults; |
| 82 | } |
55 | 83 | } |