Make WordPress Core

Changeset 43449


Ignore:
Timestamp:
07/16/2018 12:06:02 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Privacy: do not show the comment cookies opt-in checkbox (on the front-end comments form) when comment cookies are disabled.

Props felipeelia, johnbillion.
Merges [43370] to the 4.9 branch.
Fixes #44342.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/comment-template.php

    r43306 r43449  
    21972197    $html_req = ( $req ? " required='required'" : '' );
    21982198    $html5    = 'html5' === $args['format'];
    2199     $consent  = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
    22002199    $fields   =  array(
    22012200        'author'  => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
     
    22052204        'url'     => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
    22062205                     '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
    2207         'cookies' => '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
    2208                      '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>',
    22092206    );
    22102207
    2211     $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
     2208    if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) ) {
     2209        $consent           = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
     2210        $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
     2211                             '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>';
     2212    }
     2213
     2214    $required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' );
    22122215
    22132216    /**
Note: See TracChangeset for help on using the changeset viewer.