WordPress.org

Make WordPress Core

Ticket #17976: 17976.2.patch

File 17976.2.patch, 3.1 KB (added by SergeyBiryukov, 7 years ago)
  • 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);
    98 }
     93do_action('set_comment_cookies');
    9994
    10095$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
    10196$location = apply_filters('comment_post_redirect', $location, $comment);
  • wp-includes/comment.php

     
    570570        return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value);
    571571}
    572572
     573/** 
     574 * Sets the cookies used to store an unauthenticated commentator's identity. Typically used 
     575 * to recall previous comments by this commentator that are still held in moderation. 
     576 * 
     577 * @param int $comment_id Comment ID.
     578 */ 
     579function set_comment_cookies($comment_id) { 
     580        global $user;
     581
     582        if ( !$comment = get_comment($comment_id) )
     583                return false;
     584
     585        if ( !$user->ID ) {
     586                $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
     587                setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     588                setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     589                setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     590        }
     591
     592
    573593/**
    574594 * Sanitizes the cookies sent to the user already.
    575595 *
  • wp-includes/default-filters.php

     
    240240add_action( 'do_feed_atom',               'do_feed_atom',            10, 1 );
    241241add_action( 'do_pings',                   'do_all_pings',            10, 1 );
    242242add_action( 'do_robots',                  'do_robots'                      );
     243add_action( 'set_comment_cookies',        'set_comment_cookies'            );
    243244add_action( 'sanitize_comment_cookies',   'sanitize_comment_cookies'       );
    244245add_action( 'admin_print_scripts',        'print_head_scripts',      20    );
    245246add_action( 'admin_print_footer_scripts', 'wp_print_footer_scripts', 20    );