Respect the commenter decision when they have checked the checkbox to consent to cookies, and keep it checked when they reload the page or post another comment.

Props azaozz.
Merges [42815] to the 4.9 branch.
See #43436.
Built from https://develop.svn.wordpress.org/branches/4.9@43128


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-05-02 22:13:27 +00:00
parent 26fdba2c5b
commit 103ca5c6cf
2 changed files with 3 additions and 2 deletions

View File

@ -2194,6 +2194,7 @@ function comment_form( $args = array(), $post_id = null ) {
$req = get_option( 'require_name_email' ); $req = get_option( 'require_name_email' );
$html_req = ( $req ? " required='required'" : '' ); $html_req = ( $req ? " required='required'" : '' );
$html5 = 'html5' === $args['format']; $html5 = 'html5' === $args['format'];
$consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
$fields = array( $fields = array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>', '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>',
@ -2202,7 +2203,7 @@ function comment_form( $args = array(), $post_id = null ) {
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
'<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
'cookies' => '<p class="comment-form-cookies-consent"><label for="wp-comment-cookies-consent">' . 'cookies' => '<p class="comment-form-cookies-consent"><label for="wp-comment-cookies-consent">' .
'<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" />' . '<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
__( 'Save my name, email, and site URL in my browser for next time I post a comment.' ) . '</label></p>', __( 'Save my name, email, and site URL in my browser for next time I post a comment.' ) . '</label></p>',
); );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9.6-alpha-43127'; $wp_version = '4.9.6-alpha-43128';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.