WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/20/2018 12:37:40 AM (8 months ago)
Author:
SergeyBiryukov
Message:

Comments: Ensure that themes overriding default comment_form() fields still display the cookies consent checkbox.

The comment_form_default_fields filter can be used to remove the checkbox.

Props pross, SergeyBiryukov.
Fixes #44126.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/commentForm.php

    r42343 r43518  
    8181        return $defaults;
    8282    }
     83
     84    /**
     85     * @ticket 44126
     86     */
     87    public function test_fields_should_include_cookies_consent() {
     88        $p = self::factory()->post->create();
     89
     90        add_filter( 'option_show_comments_cookies_opt_in', '__return_true' );
     91
     92        $args = array(
     93            'fields' => array(
     94                'author' => 'Hello World!',
     95            ),
     96        );
     97        $form = get_echo( 'comment_form', array( $args, $p ) );
     98
     99        remove_filter( 'option_show_comments_cookies_opt_in', '__return_true' );
     100
     101        $this->assertRegExp( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form );
     102    }
    83103}
Note: See TracChangeset for help on using the changeset viewer.