WordPress.org

Make WordPress Core

Ticket #18819: block-commenter-cookies.diff

File block-commenter-cookies.diff, 2.8 KB (added by WhiteJV, 7 years ago)

Overall Patch DIFF

  • wp-comments-post.php

     
    9090$comment_id = wp_new_comment( $commentdata );
    9191
    9292$comment = get_comment($comment_id);
    93 if ( !$user->ID ) {
    94         $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
    95         setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
    96         setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
    97         setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     93if ( (!defined('BLOCK_COMMENTER_COOKIES')) || (!BLOCK_COMMENTER_COOKIES) ) {
     94        if ( !$user->ID ) {
     95                $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
     96                setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     97                setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     98                setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     99        }
    98100}
    99101
    100102$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
  • wp-includes/comment.php

     
    11861186        // Cookies should already be sanitized.
    11871187
    11881188        $comment_author = '';
    1189         if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
    1190                 $comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
    1191 
    11921189        $comment_author_email = '';
    1193         if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
    1194                 $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
    1195 
    11961190        $comment_author_url = '';
    1197         if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
    1198                 $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
    11991191
     1192        if ( (!defined('BLOCK_COMMENTER_COOKIES')) || (!BLOCK_COMMENTER_COOKIES) ) {
     1193                if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
     1194                        $comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
     1195                if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
     1196                        $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
     1197                if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
     1198                        $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
     1199        }
     1200
    12001201        return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
    12011202}
    12021203