Make WordPress Core

Ticket #43436: 43436.diff

File 43436.diff, 3.6 KB (added by lakenh, 6 years ago)
  • wp-comments-post.php

    diff --git a/wp-comments-post.php b/wp-comments-post.php
    index 39bc5a8..46e7b3b 100644
    a b if ( is_wp_error( $comment ) ) { 
    3838}
    3939
    4040$user = wp_get_current_user();
     41$cookie_consent = ( isset( $_POST['cookies'] ) ) ? true : false;
    4142
    4243/**
    4344 * Perform other actions when comment cookies are set.
    4445 *
    4546 * @since 3.4.0
    4647 *
    47  * @param WP_Comment $comment Comment object.
    48  * @param WP_User    $user    User object. The user may not exist.
     48 * @param WP_Comment $comment        Comment object.
     49 * @param WP_User    $user           User object. The user may not exist.
     50 * @param string     $cookie_consent The 'cookies' parmater sent via $_POST.
    4951 */
    50 do_action( 'set_comment_cookies', $comment, $user );
     52do_action( 'set_comment_cookies', $comment, $user, $cookie_consent );
    5153
    5254$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
    5355
  • wp-includes/comment-template.php

    diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
    index 5795362..ee51083 100644
    a b function comment_form( $args = array(), $post_id = null ) { 
    22672267                                        '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>',
    22682268                'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
    22692269                                        '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
     2270                'cookies' => '<p class="comment-form-cookies"><input id="cookies" name="cookies" type="checkbox" />' .
     2271                                        '<label for="cookies">' . __('Save my name, email, and site URL in my browser for next time I post a comment.') . '</label></p>',
    22702272        );
    22712273
    22722274        $required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' );
  • wp-includes/comment.php

    diff --git a/wp-includes/comment.php b/wp-includes/comment.php
    index 0d35f09..a709496 100644
    a b function wp_queue_comments_for_comment_meta_lazyload( $comments ) { 
    542542 *
    543543 * @param WP_Comment $comment Comment object.
    544544 * @param object     $user    Comment author's object.
     545 * @param boolean    $cookie_consent Comment author's permission to store cookies.
    545546 *
    546547 * @since 3.4.0
    547548 */
    548 function wp_set_comment_cookies( $comment, $user ) {
    549         if ( $user->exists() ) {
     549function wp_set_comment_cookies( $comment, $user, $cookie_consent ) {
     550        // If the user already exists, or the user opted out of cookies, don't set cookies.
     551        if ( $user->exists() || ( false == $cookie_consent ) ) {
    550552                return;
    551553        }
    552554
  • wp-includes/default-filters.php

    diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
    index 6b60625..090adfe 100644
    a b add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 ); 
    327327add_action( 'do_feed_atom', 'do_feed_atom', 10, 1 );
    328328add_action( 'do_pings', 'do_all_pings', 10, 1 );
    329329add_action( 'do_robots', 'do_robots' );
    330 add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 2 );
     330add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 3 );
    331331add_action( 'sanitize_comment_cookies', 'sanitize_comment_cookies' );
    332332add_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    333333add_action( 'admin_print_scripts', 'print_head_scripts', 20 );